From rhettinger at users.sourceforge.net Thu Jul 1 02:44:54 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Thu Jul 1 02:44:59 2004 Subject: [Python-checkins] python/nondist/sandbox/decimal test_Decimal.py, 1.24, 1.25 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/decimal In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18130 Modified Files: test_Decimal.py Log Message: Test cleanup: Use comments and informative test names instead of docstrings. Index: test_Decimal.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/decimal/test_Decimal.py,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** test_Decimal.py 30 Jun 2004 07:19:21 -0000 1.24 --- test_Decimal.py 1 Jul 2004 06:44:52 -0000 1.25 *************** *** 31,35 **** import os, sys import pickle, copy - from Decimal import * from test.test_support import TestSkipped, run_unittest, run_doctest --- 31,34 ---- *************** *** 367,380 **** '''Unit tests for Explicit Construction cases of Decimal.''' ! def test_empty(self): ! '''Explicit construction without parameters.''' self.assertEqual(Decimal(), Decimal("0")) ! def test_from_None(self): ! '''Explicit construction passing None as value.''' self.assertRaises(TypeError, Decimal, None) ! def test_from_int(self): ! '''Explicit construction with int or long.''' #positive --- 366,376 ---- '''Unit tests for Explicit Construction cases of Decimal.''' ! def test_explicit_empty(self): self.assertEqual(Decimal(), Decimal("0")) ! def test_explicit_from_None(self): self.assertRaises(TypeError, Decimal, None) ! def test_explicit_from_int(self): #positive *************** *** 394,398 **** self.assertEqual(str(d), '0') ! def test_from_string(self): '''Explicit construction with string.''' --- 390,394 ---- self.assertEqual(str(d), '0') ! def test_explicit_from_string(self): '''Explicit construction with string.''' *************** *** 412,417 **** self.assertEqual(str(Decimal('ugly')), 'NaN') ! def test_from_tuples(self): ! '''Explicit construction with tuples.''' #zero --- 408,412 ---- self.assertEqual(str(Decimal('ugly')), 'NaN') ! def test_explicit_from_tuples(self): #zero *************** *** 444,449 **** self.assertRaises(ValueError, Decimal, (1, (4, -3, 4, 9, 1), 2) ) ! def test_from_Decimal(self): ! '''Explicit construction with Decimal.''' #positive --- 439,443 ---- self.assertRaises(ValueError, Decimal, (1, (4, -3, 4, 9, 1), 2) ) ! def test_explicit_from_Decimal(self): #positive *************** *** 471,476 **** self.assertNotEqual(id(d), id(e)) ! def test_context_create_decimal(self): ! '''Explicit construction through context.create_decimal().''' nc = copy.copy(getcontext()) nc.prec = 3 --- 465,470 ---- self.assertNotEqual(id(d), id(e)) ! def test_explicit_context_create_decimal(self): ! nc = copy.copy(getcontext()) nc.prec = 3 *************** *** 511,543 **** '''Unit tests for Implicit Construction cases of Decimal.''' ! def test_from_None(self): ! '''Implicit construction with None.''' ! self.assertRaises(TypeError, eval, 'Decimal(5) + None', globals()) ! def test_from_int(self): ! '''Implicit construction with int or long.''' ! #normal self.assertEqual(str(Decimal(5) + 45), '50') - #exceeding precision self.assertEqual(Decimal(5) + 123456789000, Decimal(123456789000)) ! def test_from_string(self): ! '''Implicit construction with string.''' ! ! #just any string self.assertRaises(TypeError, eval, 'Decimal(5) + "3"', globals()) ! def test_from_float(self): ! '''Implicit construction with float.''' ! ! #just any float self.assertRaises(TypeError, eval, 'Decimal(5) + 2.2', globals()) ! def test_from_Decimal(self): ! '''Implicit construction with Decimal.''' ! self.assertEqual(Decimal(5) + Decimal(45), Decimal(50)) --- 505,524 ---- '''Unit tests for Implicit Construction cases of Decimal.''' ! def test_implicit_from_None(self): self.assertRaises(TypeError, eval, 'Decimal(5) + None', globals()) ! def test_implicit_from_int(self): #normal self.assertEqual(str(Decimal(5) + 45), '50') #exceeding precision self.assertEqual(Decimal(5) + 123456789000, Decimal(123456789000)) ! def test_implicit_from_string(self): self.assertRaises(TypeError, eval, 'Decimal(5) + "3"', globals()) ! def test_implicit_from_float(self): self.assertRaises(TypeError, eval, 'Decimal(5) + 2.2', globals()) ! def test_implicit_from_Decimal(self): self.assertEqual(Decimal(5) + Decimal(45), Decimal(50)) *************** *** 547,551 **** def test_addition(self): - '''Test addition in all its ways.''' d1 = Decimal('-11.1') --- 528,531 ---- *************** *** 575,579 **** def test_subtraction(self): - '''Test subtraction in all its ways.''' d1 = Decimal('-11.1') --- 555,558 ---- *************** *** 603,607 **** def test_multiplication(self): - '''Test multiplication in all its ways.''' d1 = Decimal('-5') --- 582,585 ---- *************** *** 631,635 **** def test_division(self): - '''Test division in all its ways.''' d1 = Decimal('-5') --- 609,612 ---- *************** *** 715,719 **** def test_module(self): - '''Test module in all its ways.''' d1 = Decimal('5') --- 692,695 ---- *************** *** 743,747 **** def test_floor_div_module(self): - '''Test floor division with module in all its ways.''' d1 = Decimal('5') --- 719,722 ---- *************** *** 770,783 **** def test_unary_operators(self): ! '''Testing -, +, abs.''' ! ! #test '+' ! self.assertEqual(+Decimal(45), Decimal(+45)) ! ! #test '-' ! self.assertEqual(-Decimal(45), Decimal(-45)) ! ! #test abs ! self.assertEqual(abs(Decimal(45)), abs(Decimal(-45))) --- 745,751 ---- def test_unary_operators(self): ! self.assertEqual(+Decimal(45), Decimal(+45)) # + ! self.assertEqual(-Decimal(45), Decimal(-45)) # - ! self.assertEqual(abs(Decimal(45)), abs(Decimal(-45))) # abs *************** *** 813,817 **** def test_threading(self): ! '''Test the "threading isolation" of a Context.''' self.synchro = threading.Event() --- 781,785 ---- def test_threading(self): ! #Test the "threading isolation" of a Context. self.synchro = threading.Event() *************** *** 874,880 **** else: self.fail('Did not raised an error!') ! def test_copy_methods(self): ! '''Test copy and deepcopy.''' ! d = Decimal('43.24') c = copy.copy(d) --- 842,846 ---- else: self.fail('Did not raised an error!') ! def test_copy_and_deepcopy_methods(self): d = Decimal('43.24') c = copy.copy(d) *************** *** 884,897 **** def test_hash_method(self): - '''Test hash.''' - #just that it's hashable hash(Decimal(23)) - #the same hash that to an int self.assertEqual(hash(Decimal(23)), hash(23)) ! def test_minmax_methods(self): ! '''Test min and max between Decimal and others.''' d1 = Decimal('15.32') --- 850,859 ---- def test_hash_method(self): #just that it's hashable hash(Decimal(23)) #the same hash that to an int self.assertEqual(hash(Decimal(23)), hash(23)) ! def test_min_and_max_methods(self): d1 = Decimal('15.32') *************** *** 912,937 **** self.failUnless(max(d2,l1) is d2) ! def test_as_boolean(self): ! '''Test that it can be used as boolean.''' ! #as false self.failIf(Decimal(0)) - #as true self.failUnless(Decimal('0.372')) def test_tostring_methods(self): ! '''Test str and repr methods.''' d = Decimal('15.32') ! ! #str ! self.assertEqual(str(d), '15.32') ! ! #repr ! self.assertEqual(repr(d), 'Decimal("15.32")') def test_tonum_methods(self): ! '''Test float, int and long methods.''' d1 = Decimal('66') --- 874,892 ---- self.failUnless(max(d2,l1) is d2) ! def test_as_nonzero(self): #as false self.failIf(Decimal(0)) #as true self.failUnless(Decimal('0.372')) def test_tostring_methods(self): ! #Test str and repr methods. d = Decimal('15.32') ! self.assertEqual(str(d), '15.32') # str ! self.assertEqual(repr(d), 'Decimal("15.32")') # repr def test_tonum_methods(self): ! #Test float, int and long methods. d1 = Decimal('66') *************** *** 950,955 **** self.assertEqual(float(d2), 15.32) ! def test_round_trip(self): ! '''Testing that d == eval(repr(d)) with d as Decimal.''' #with zero --- 905,909 ---- self.assertEqual(float(d2), 15.32) ! def test_eval_round_trip(self): #with zero *************** *** 970,974 **** def test_as_tuple(self): - '''Test as_tuple to show the internals.''' #with zero --- 924,927 ---- *************** *** 989,993 **** def test_immutability_onpurpose(self): ! '''Try to change internal objects and see if immutable.''' d = Decimal(42) --- 942,946 ---- def test_immutability_onpurpose(self): ! #Try to change internal objects and see if immutable. d = Decimal(42) *************** *** 1017,1021 **** def test_immutability_operations(self): ! '''Do operations and check that it didn't change change internal objects.''' d1 = Decimal('-25e55') --- 970,974 ---- def test_immutability_operations(self): ! # Do operations and check that it didn't change change internal objects. d1 = Decimal('-25e55') From rhettinger at users.sourceforge.net Thu Jul 1 04:21:31 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Thu Jul 1 04:21:37 2004 Subject: [Python-checkins] python/nondist/sandbox/decimal Decimal.py, 1.35, 1.36 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/decimal In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1300 Modified Files: Decimal.py Log Message: * Have context doctests use the DefaultContext instead of creating new ones. * Simplify the thicket of constants non specifically required by the spec. Index: Decimal.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/decimal/Decimal.py,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** Decimal.py 1 Jul 2004 01:47:03 -0000 1.35 --- Decimal.py 1 Jul 2004 08:21:28 -0000 1.36 *************** *** 14,20 **** # Consider having a SimpleDecimal subclass implementing X3.274 semantics # Add an __all__ attribute - # Improve docstrings and add more doctests # Improve the Context API # Provide a clean way of attaching monetary format representations """ --- 14,20 ---- # Consider having a SimpleDecimal subclass implementing X3.274 semantics # Add an __all__ attribute # Improve the Context API # Provide a clean way of attaching monetary format representations + # Review all exposed constants for utility vs. namespace clutter """ *************** *** 128,169 **** xor = operator.xor - #Capitals: 1E+10, not 1e10 - CAPITALS = 1 - - # Clamp: When finishing operation, change exponents if too high: - # maxExponent: 10 - # precision: 4 - # clamp: 1 - # add 0 1e10 -> 1.000e10 - - CLAMP = 0 - - # Default Context - - BASIC_DEFAULT_CONTEXT = 'basic' - - # Basic default context: - # - # flags: all set to 0 - # trap-enablers: inexact, rounded, and subnormal are set to 0; - # all others are set to 1 - # precision: is set to 9 - # rounding: is set to round-half-up - - EXTENDED_DEFAULT_CONTEXT = 'extended' - - # Extended default context: - # flags: all set to 0 - # trap-enablers: all set to 0 (IEEE 854 7) - # precision: is set to the designated single precision - # rounding: is set to round-half-even (IEEE 854 4.1) - - DEFAULT_CONTEXT = EXTENDED_DEFAULT_CONTEXT - #Precision ! BASIC_DEFAULT_PRECISION = 9 ! EXTENDED_DEFAULT_PRECISION = 9 ! DEFAULT_MAX_EXPONENT = 999999999 DEFAULT_MIN_EXPONENT = -999999999 --- 128,135 ---- xor = operator.xor #Precision + SINGLE_PRECISION = 9 ! #Exponent Range DEFAULT_MAX_EXPONENT = 999999999 DEFAULT_MIN_EXPONENT = -999999999 *************** *** 178,194 **** ROUND_HALF_DOWN = 'half_down' - BASIC_DEFAULT_ROUNDING = ROUND_HALF_UP - EXTENDED_DEFAULT_ROUNDING = ROUND_HALF_EVEN - #Rounding decision - NEVER_ROUND = 'never' # Round in division (non-divmod), sqrt ONLY ALWAYS_ROUND = 'always' # Every operation rounds at end. - - BASIC_DEFAULT_ROUNDING_DECISION = ALWAYS_ROUND - EXTENDED_DEFAULT_ROUNDING_DECISION = ALWAYS_ROUND - - #Errors --- 144,151 ---- *************** *** 1442,1445 **** --- 1399,1404 ---- def __int__(self): """Converts self to a int, truncating if necessary.""" + # XXX This should be implemented in terms of tested + # functions in the standard if self._isnan(): context = getcontext() *************** *** 1674,1677 **** --- 1633,1637 ---- return tmp return tmp + def _round_ceiling(self, prec, expdiff, context): """Rounds up (not away from 0 if negative.)""" *************** *** 2144,2147 **** --- 2104,2108 ---- Decimal._pick_rounding_function[val] = name + DefaultLock = threading.Lock() class Context(object): *************** *** 2158,2171 **** (Whether or not the trap_enabler is set) Should be reset by user of Decimal instance. ! Emin - Minimum exponent ! Emax - Maximum exponent ! capitals - If 1, 1*10^1 is printed as 1E+1. If 0, printed as 1e1 """ def __init__(self, prec=None, rounding=None, trap_enablers=None, flags=None, _rounding_decision=None, ! Emin=None, Emax=None, ! capitals=None, _clamp=None, ! _ignored_flags=None): DefaultLock.acquire() for name, val in locals().items(): --- 2119,2135 ---- (Whether or not the trap_enabler is set) Should be reset by user of Decimal instance. ! Emin - Minimum exponent (defaults to -999999999) ! Emax - Maximum exponent (defaults to 999999999) ! capitals - If 1, 1*10^1 is printed as 1E+1. ! If 0, printed as 1e1 ! (Defaults to 1) ! clamp - If 1, change exponents if too high (Default 0) """ def __init__(self, prec=None, rounding=None, trap_enablers=None, flags=None, _rounding_decision=None, ! Emin=DEFAULT_MIN_EXPONENT, Emax=DEFAULT_MAX_EXPONENT, ! capitals=1, _clamp=0, ! _ignored_flags=[]): DefaultLock.acquire() for name, val in locals().items(): *************** *** 2285,2295 **** the plus operation on the operand. ! >>> Context(prec=9).abs(Decimal('2.1')) Decimal("2.1") ! >>> Context(prec=9).abs(Decimal('-100')) Decimal("100") ! >>> Context(prec=9).abs(Decimal('101.5')) Decimal("101.5") ! >>> Context(prec=9).abs(Decimal('-101.5')) Decimal("101.5") """ --- 2249,2259 ---- the plus operation on the operand. ! >>> DefaultContext.abs(Decimal('2.1')) Decimal("2.1") ! >>> DefaultContext.abs(Decimal('-100')) Decimal("100") ! >>> DefaultContext.abs(Decimal('101.5')) Decimal("101.5") ! >>> DefaultContext.abs(Decimal('-101.5')) Decimal("101.5") """ *************** *** 2299,2305 **** """Return the sum of the two operands. ! >>> Context(prec=9).add(Decimal('12'), Decimal('7.00')) Decimal("19.00") ! >>> Context(prec=9).add(Decimal('1E+2'), Decimal('1.01E+4')) Decimal("1.02E+4") """ --- 2263,2269 ---- """Return the sum of the two operands. ! >>> DefaultContext.add(Decimal('12'), Decimal('7.00')) Decimal("19.00") ! >>> DefaultContext.add(Decimal('1E+2'), Decimal('1.01E+4')) Decimal("1.02E+4") """ *************** *** 2323,2337 **** zero or negative zero, or ’1’ if the result is greater than zero. ! >>> Context(prec=9).compare(Decimal('2.1'), Decimal('3')) Decimal("-1") ! >>> Context(prec=9).compare(Decimal('2.1'), Decimal('2.1')) Decimal("0") ! >>> Context(prec=9).compare(Decimal('2.1'), Decimal('2.10')) Decimal("0") ! >>> Context(prec=9).compare(Decimal('3'), Decimal('2.1')) Decimal("1") ! >>> Context(prec=9).compare(Decimal('2.1'), Decimal('-3')) Decimal("1") ! >>> Context(prec=9).compare(Decimal('-3'), Decimal('2.1')) Decimal("-1") """ --- 2287,2301 ---- zero or negative zero, or ’1’ if the result is greater than zero. ! >>> DefaultContext.compare(Decimal('2.1'), Decimal('3')) Decimal("-1") ! >>> DefaultContext.compare(Decimal('2.1'), Decimal('2.1')) Decimal("0") ! >>> DefaultContext.compare(Decimal('2.1'), Decimal('2.10')) Decimal("0") ! >>> DefaultContext.compare(Decimal('3'), Decimal('2.1')) Decimal("1") ! >>> DefaultContext.compare(Decimal('2.1'), Decimal('-3')) Decimal("1") ! >>> DefaultContext.compare(Decimal('-3'), Decimal('2.1')) Decimal("-1") """ *************** *** 2341,2363 **** """Decimal division in a specified context. ! >>> Context(prec=9).divide(Decimal('1'), Decimal('3')) Decimal("0.333333333") ! >>> Context(prec=9).divide(Decimal('2'), Decimal('3')) Decimal("0.666666667") ! >>> Context(prec=9).divide(Decimal('5'), Decimal('2')) Decimal("2.5") ! >>> Context(prec=9).divide(Decimal('1'), Decimal('10')) Decimal("0.1") ! >>> Context(prec=9).divide(Decimal('12'), Decimal('12')) Decimal("1") ! >>> Context(prec=9).divide(Decimal('8.00'), Decimal('2')) Decimal("4.00") ! >>> Context(prec=9).divide(Decimal('2.400'), Decimal('2.0')) Decimal("1.20") ! >>> Context(prec=9).divide(Decimal('1000'), Decimal('100')) Decimal("10") ! >>> Context(prec=9).divide(Decimal('1000'), Decimal('1')) Decimal("1000") ! >>> Context(prec=9).divide(Decimal('2.40E+6'), Decimal('2')) Decimal("1.20E+6") """ --- 2305,2327 ---- """Decimal division in a specified context. ! >>> DefaultContext.divide(Decimal('1'), Decimal('3')) Decimal("0.333333333") ! >>> DefaultContext.divide(Decimal('2'), Decimal('3')) Decimal("0.666666667") ! >>> DefaultContext.divide(Decimal('5'), Decimal('2')) Decimal("2.5") ! >>> DefaultContext.divide(Decimal('1'), Decimal('10')) Decimal("0.1") ! >>> DefaultContext.divide(Decimal('12'), Decimal('12')) Decimal("1") ! >>> DefaultContext.divide(Decimal('8.00'), Decimal('2')) Decimal("4.00") ! >>> DefaultContext.divide(Decimal('2.400'), Decimal('2.0')) Decimal("1.20") ! >>> DefaultContext.divide(Decimal('1000'), Decimal('100')) Decimal("10") ! >>> DefaultContext.divide(Decimal('1000'), Decimal('1')) Decimal("1000") ! >>> DefaultContext.divide(Decimal('2.40E+6'), Decimal('2')) Decimal("1.20E+6") """ *************** *** 2367,2375 **** """Divides two numbers and returns the integer part of the result. ! >>> Context(prec=9).divide_int(Decimal('2'), Decimal('3')) Decimal("0") ! >>> Context(prec=9).divide_int(Decimal('10'), Decimal('3')) Decimal("3") ! >>> Context(prec=9).divide_int(Decimal('1'), Decimal('0.3')) Decimal("3") """ --- 2331,2339 ---- """Divides two numbers and returns the integer part of the result. ! >>> DefaultContext.divide_int(Decimal('2'), Decimal('3')) Decimal("0") ! >>> DefaultContext.divide_int(Decimal('10'), Decimal('3')) Decimal("3") ! >>> DefaultContext.divide_int(Decimal('1'), Decimal('0.3')) Decimal("3") """ *************** *** 2388,2396 **** infinity) of the two operands is chosen as the result. ! >>> Context(prec=9).max(Decimal('3'), Decimal('2')) Decimal("3") ! >>> Context(prec=9).max(Decimal('-10'), Decimal('3')) Decimal("3") ! >>> Context(prec=9).max(Decimal('1.0'), Decimal('1')) Decimal("1.0") """ --- 2352,2360 ---- infinity) of the two operands is chosen as the result. ! >>> DefaultContext.max(Decimal('3'), Decimal('2')) Decimal("3") ! >>> DefaultContext.max(Decimal('-10'), Decimal('3')) Decimal("3") ! >>> DefaultContext.max(Decimal('1.0'), Decimal('1')) Decimal("1.0") """ *************** *** 2406,2414 **** infinity) of the two operands is chosen as the result. ! >>> Context(prec=9).min(Decimal('3'), Decimal('2')) Decimal("2") ! >>> Context(prec=9).min(Decimal('-10'), Decimal('3')) Decimal("-10") ! >>> Context(prec=9).min(Decimal('1.0'), Decimal('1')) Decimal("1.0") """ --- 2370,2378 ---- infinity) of the two operands is chosen as the result. ! >>> DefaultContext.min(Decimal('3'), Decimal('2')) Decimal("2") ! >>> DefaultContext.min(Decimal('-10'), Decimal('3')) Decimal("-10") ! >>> DefaultContext.min(Decimal('1.0'), Decimal('1')) Decimal("1.0") """ *************** *** 2422,2428 **** has the same exponent as the operand. ! >>> Context(prec=9).minus(Decimal('1.3')) Decimal("-1.3") ! >>> Context(prec=9).minus(Decimal('-1.3')) Decimal("1.3") """ --- 2386,2392 ---- has the same exponent as the operand. ! >>> DefaultContext.minus(Decimal('1.3')) Decimal("-1.3") ! >>> DefaultContext.minus(Decimal('-1.3')) Decimal("1.3") """ *************** *** 2437,2449 **** of the two operands. ! >>> Context(prec=9).multiply(Decimal('1.20'), Decimal('3')) Decimal("3.60") ! >>> Context(prec=9).multiply(Decimal('7'), Decimal('3')) Decimal("21") ! >>> Context(prec=9).multiply(Decimal('0.9'), Decimal('0.8')) Decimal("0.72") ! >>> Context(prec=9).multiply(Decimal('0.9'), Decimal('-0')) Decimal("-0.0") ! >>> Context(prec=9).multiply(Decimal('654321'), Decimal('654321')) Decimal("4.28135971E+11") """ --- 2401,2413 ---- of the two operands. ! >>> DefaultContext.multiply(Decimal('1.20'), Decimal('3')) Decimal("3.60") ! >>> DefaultContext.multiply(Decimal('7'), Decimal('3')) Decimal("21") ! >>> DefaultContext.multiply(Decimal('0.9'), Decimal('0.8')) Decimal("0.72") ! >>> DefaultContext.multiply(Decimal('0.9'), Decimal('-0')) Decimal("-0.0") ! >>> DefaultContext.multiply(Decimal('654321'), Decimal('654321')) Decimal("4.28135971E+11") """ *************** *** 2456,2470 **** result. ! >>> Context(prec=9).normalize(Decimal('2.1')) Decimal("2.1") ! >>> Context(prec=9).normalize(Decimal('-2.0')) Decimal("-2") ! >>> Context(prec=9).normalize(Decimal('1.200')) Decimal("1.2") ! >>> Context(prec=9).normalize(Decimal('-120')) Decimal("-1.2E+2") ! >>> Context(prec=9).normalize(Decimal('120.00')) Decimal("1.2E+2") ! >>> Context(prec=9).normalize(Decimal('0.00')) Decimal("0") """ --- 2420,2434 ---- result. ! >>> DefaultContext.normalize(Decimal('2.1')) Decimal("2.1") ! >>> DefaultContext.normalize(Decimal('-2.0')) Decimal("-2") ! >>> DefaultContext.normalize(Decimal('1.200')) Decimal("1.2") ! >>> DefaultContext.normalize(Decimal('-120')) Decimal("-1.2E+2") ! >>> DefaultContext.normalize(Decimal('120.00')) Decimal("1.2E+2") ! >>> DefaultContext.normalize(Decimal('0.00')) Decimal("0") """ *************** *** 2478,2484 **** has the same exponent as the operand. ! >>> Context(prec=9).plus(Decimal('1.3')) Decimal("1.3") ! >>> Context(prec=9).plus(Decimal('-1.3')) Decimal("-1.3") """ --- 2442,2448 ---- has the same exponent as the operand. ! >>> DefaultContext.plus(Decimal('1.3')) Decimal("1.3") ! >>> DefaultContext.plus(Decimal('-1.3')) Decimal("-1.3") """ *************** *** 2503,2533 **** continues. ! >>> Context(prec=9).power(Decimal('2'), Decimal('3')) Decimal("8") ! >>> Context(prec=9).power(Decimal('2'), Decimal('-3')) Decimal("0.125") ! >>> Context(prec=9).power(Decimal('1.7'), Decimal('8')) Decimal("69.7575744") ! >>> Context(prec=9).power(Decimal('Infinity'), Decimal('-2')) Decimal("0") ! >>> Context(prec=9).power(Decimal('Infinity'), Decimal('-1')) Decimal("0") ! >>> Context(prec=9).power(Decimal('Infinity'), Decimal('0')) Decimal("1") ! >>> Context(prec=9).power(Decimal('Infinity'), Decimal('1')) Decimal("Infinity") ! >>> Context(prec=9).power(Decimal('Infinity'), Decimal('2')) Decimal("Infinity") ! >>> Context(prec=9).power(Decimal('-Infinity'), Decimal('-2')) Decimal("0") ! >>> Context(prec=9).power(Decimal('-Infinity'), Decimal('-1')) Decimal("-0") ! >>> Context(prec=9).power(Decimal('-Infinity'), Decimal('0')) Decimal("1") ! >>> Context(prec=9).power(Decimal('-Infinity'), Decimal('1')) Decimal("-Infinity") ! >>> Context(prec=9).power(Decimal('-Infinity'), Decimal('2')) Decimal("Infinity") ! >>> Context(prec=9).power(Decimal('0'), Decimal('0')) Decimal("NaN") """ --- 2467,2497 ---- continues. ! >>> DefaultContext.power(Decimal('2'), Decimal('3')) Decimal("8") ! >>> DefaultContext.power(Decimal('2'), Decimal('-3')) Decimal("0.125") ! >>> DefaultContext.power(Decimal('1.7'), Decimal('8')) Decimal("69.7575744") ! >>> DefaultContext.power(Decimal('Infinity'), Decimal('-2')) Decimal("0") ! >>> DefaultContext.power(Decimal('Infinity'), Decimal('-1')) Decimal("0") ! >>> DefaultContext.power(Decimal('Infinity'), Decimal('0')) Decimal("1") ! >>> DefaultContext.power(Decimal('Infinity'), Decimal('1')) Decimal("Infinity") ! >>> DefaultContext.power(Decimal('Infinity'), Decimal('2')) Decimal("Infinity") ! >>> DefaultContext.power(Decimal('-Infinity'), Decimal('-2')) Decimal("0") ! >>> DefaultContext.power(Decimal('-Infinity'), Decimal('-1')) Decimal("-0") ! >>> DefaultContext.power(Decimal('-Infinity'), Decimal('0')) Decimal("1") ! >>> DefaultContext.power(Decimal('-Infinity'), Decimal('1')) Decimal("-Infinity") ! >>> DefaultContext.power(Decimal('-Infinity'), Decimal('2')) Decimal("Infinity") ! >>> DefaultContext.power(Decimal('0'), Decimal('0')) Decimal("NaN") """ *************** *** 2552,2584 **** if the result is subnormal and inexact. ! >>> Context(prec=9).quantize(Decimal('2.17'), Decimal('0.001')) Decimal("2.170") ! >>> Context(prec=9).quantize(Decimal('2.17'), Decimal('0.01')) Decimal("2.17") ! >>> Context(prec=9).quantize(Decimal('2.17'), Decimal('0.1')) Decimal("2.2") ! >>> Context(prec=9).quantize(Decimal('2.17'), Decimal('1e+0')) Decimal("2") ! >>> Context(prec=9).quantize(Decimal('2.17'), Decimal('1e+1')) Decimal("0E+1") ! >>> Context(prec=9).quantize(Decimal('-Inf'), Decimal('Infinity')) Decimal("-Infinity") ! >>> Context(prec=9).quantize(Decimal('2'), Decimal('Infinity')) Decimal("NaN") ! >>> Context(prec=9).quantize(Decimal('-0.1'), Decimal('1')) Decimal("-0") ! >>> Context(prec=9).quantize(Decimal('-0'), Decimal('1e+5')) Decimal("-0E+5") ! >>> Context(prec=9).quantize(Decimal('+35236450.6'), Decimal('1e-2')) Decimal("NaN") ! >>> Context(prec=9).quantize(Decimal('-35236450.6'), Decimal('1e-2')) Decimal("NaN") ! >>> Context(prec=9).quantize(Decimal('217'), Decimal('1e-1')) Decimal("217.0") ! >>> Context(prec=9).quantize(Decimal('217'), Decimal('1e-0')) Decimal("217") ! >>> Context(prec=9).quantize(Decimal('217'), Decimal('1e+1')) Decimal("2.2E+2") ! >>> Context(prec=9).quantize(Decimal('217'), Decimal('1e+2')) Decimal("2E+2") """ --- 2516,2548 ---- if the result is subnormal and inexact. ! >>> DefaultContext.quantize(Decimal('2.17'), Decimal('0.001')) Decimal("2.170") ! >>> DefaultContext.quantize(Decimal('2.17'), Decimal('0.01')) Decimal("2.17") ! >>> DefaultContext.quantize(Decimal('2.17'), Decimal('0.1')) Decimal("2.2") ! >>> DefaultContext.quantize(Decimal('2.17'), Decimal('1e+0')) Decimal("2") ! >>> DefaultContext.quantize(Decimal('2.17'), Decimal('1e+1')) Decimal("0E+1") ! >>> DefaultContext.quantize(Decimal('-Inf'), Decimal('Infinity')) Decimal("-Infinity") ! >>> DefaultContext.quantize(Decimal('2'), Decimal('Infinity')) Decimal("NaN") ! >>> DefaultContext.quantize(Decimal('-0.1'), Decimal('1')) Decimal("-0") ! >>> DefaultContext.quantize(Decimal('-0'), Decimal('1e+5')) Decimal("-0E+5") ! >>> DefaultContext.quantize(Decimal('+35236450.6'), Decimal('1e-2')) Decimal("NaN") ! >>> DefaultContext.quantize(Decimal('-35236450.6'), Decimal('1e-2')) Decimal("NaN") ! >>> DefaultContext.quantize(Decimal('217'), Decimal('1e-1')) Decimal("217.0") ! >>> DefaultContext.quantize(Decimal('217'), Decimal('1e-0')) Decimal("217") ! >>> DefaultContext.quantize(Decimal('217'), Decimal('1e+1')) Decimal("2.2E+2") ! >>> DefaultContext.quantize(Decimal('217'), Decimal('1e+2')) Decimal("2E+2") """ *************** *** 2597,2611 **** remainder cannot be calculated). ! >>> Context(prec=9).remainder(Decimal('2.1'), Decimal('3')) Decimal("2.1") ! >>> Context(prec=9).remainder(Decimal('10'), Decimal('3')) Decimal("1") ! >>> Context(prec=9).remainder(Decimal('-10'), Decimal('3')) Decimal("-1") ! >>> Context(prec=9).remainder(Decimal('10.2'), Decimal('1')) Decimal("0.2") ! >>> Context(prec=9).remainder(Decimal('10'), Decimal('0.3')) Decimal("0.1") ! >>> Context(prec=9).remainder(Decimal('3.6'), Decimal('1.3')) Decimal("1.0") """ --- 2561,2575 ---- remainder cannot be calculated). ! >>> DefaultContext.remainder(Decimal('2.1'), Decimal('3')) Decimal("2.1") ! >>> DefaultContext.remainder(Decimal('10'), Decimal('3')) Decimal("1") ! >>> DefaultContext.remainder(Decimal('-10'), Decimal('3')) Decimal("-1") ! >>> DefaultContext.remainder(Decimal('10.2'), Decimal('1')) Decimal("0.2") ! >>> DefaultContext.remainder(Decimal('10'), Decimal('0.3')) Decimal("0.1") ! >>> DefaultContext.remainder(Decimal('3.6'), Decimal('1.3')) Decimal("1.0") """ *************** *** 2622,2638 **** remainder cannot be calculated). ! >>> Context(prec=9).remainder_near(Decimal('2.1'), Decimal('3')) Decimal("-0.9") ! >>> Context(prec=9).remainder_near(Decimal('10'), Decimal('6')) Decimal("-2") ! >>> Context(prec=9).remainder_near(Decimal('10'), Decimal('3')) Decimal("1") ! >>> Context(prec=9).remainder_near(Decimal('-10'), Decimal('3')) Decimal("-1") ! >>> Context(prec=9).remainder_near(Decimal('10.2'), Decimal('1')) Decimal("0.2") ! >>> Context(prec=9).remainder_near(Decimal('10'), Decimal('0.3')) Decimal("0.1") ! >>> Context(prec=9).remainder_near(Decimal('3.6'), Decimal('1.3')) Decimal("-0.3") """ --- 2586,2602 ---- remainder cannot be calculated). ! >>> DefaultContext.remainder_near(Decimal('2.1'), Decimal('3')) Decimal("-0.9") ! >>> DefaultContext.remainder_near(Decimal('10'), Decimal('6')) Decimal("-2") ! >>> DefaultContext.remainder_near(Decimal('10'), Decimal('3')) Decimal("1") ! >>> DefaultContext.remainder_near(Decimal('-10'), Decimal('3')) Decimal("-1") ! >>> DefaultContext.remainder_near(Decimal('10.2'), Decimal('1')) Decimal("0.2") ! >>> DefaultContext.remainder_near(Decimal('10'), Decimal('0.3')) Decimal("0.1") ! >>> DefaultContext.remainder_near(Decimal('3.6'), Decimal('1.3')) Decimal("-0.3") """ *************** *** 2645,2655 **** either operand. ! >>> Context(prec=9).same_quantum(Decimal('2.17'), Decimal('0.001')) False ! >>> Context(prec=9).same_quantum(Decimal('2.17'), Decimal('0.01')) True ! >>> Context(prec=9).same_quantum(Decimal('2.17'), Decimal('1')) False ! >>> Context(prec=9).same_quantum(Decimal('Inf'), Decimal('-Inf')) True """ --- 2609,2619 ---- either operand. ! >>> DefaultContext.same_quantum(Decimal('2.17'), Decimal('0.001')) False ! >>> DefaultContext.same_quantum(Decimal('2.17'), Decimal('0.01')) True ! >>> DefaultContext.same_quantum(Decimal('2.17'), Decimal('1')) False ! >>> DefaultContext.same_quantum(Decimal('Inf'), Decimal('-Inf')) True """ *************** *** 2662,2682 **** algorithm. ! >>> Context(prec=9).sqrt(Decimal('0')) Decimal("0") ! >>> Context(prec=9).sqrt(Decimal('-0')) Decimal("-0") ! >>> Context(prec=9).sqrt(Decimal('0.39')) Decimal("0.624499800") ! >>> Context(prec=9).sqrt(Decimal('100')) Decimal("10") ! >>> Context(prec=9).sqrt(Decimal('1')) Decimal("1") ! >>> Context(prec=9).sqrt(Decimal('1.0')) Decimal("1.0") ! >>> Context(prec=9).sqrt(Decimal('1.00')) Decimal("1.0") ! >>> Context(prec=9).sqrt(Decimal('7')) Decimal("2.64575131") ! >>> Context(prec=9).sqrt(Decimal('10')) Decimal("3.16227766") """ --- 2626,2646 ---- algorithm. ! >>> DefaultContext.sqrt(Decimal('0')) Decimal("0") ! >>> DefaultContext.sqrt(Decimal('-0')) Decimal("-0") ! >>> DefaultContext.sqrt(Decimal('0.39')) Decimal("0.624499800") ! >>> DefaultContext.sqrt(Decimal('100')) Decimal("10") ! >>> DefaultContext.sqrt(Decimal('1')) Decimal("1") ! >>> DefaultContext.sqrt(Decimal('1.0')) Decimal("1.0") ! >>> DefaultContext.sqrt(Decimal('1.00')) Decimal("1.0") ! >>> DefaultContext.sqrt(Decimal('7')) Decimal("2.64575131") ! >>> DefaultContext.sqrt(Decimal('10')) Decimal("3.16227766") """ *************** *** 2686,2694 **** """Return the sum of the two operands. ! >>> Context(prec=9).subtract(Decimal('1.3'), Decimal('1.07')) Decimal("0.23") ! >>> Context(prec=9).subtract(Decimal('1.3'), Decimal('1.30')) Decimal("0.00") ! >>> Context(prec=9).subtract(Decimal('1.3'), Decimal('2.07')) Decimal("-0.77") """ --- 2650,2658 ---- """Return the sum of the two operands. ! >>> DefaultContext.subtract(Decimal('1.3'), Decimal('1.07')) Decimal("0.23") ! >>> DefaultContext.subtract(Decimal('1.3'), Decimal('1.30')) Decimal("0.00") ! >>> DefaultContext.subtract(Decimal('1.3'), Decimal('2.07')) Decimal("-0.77") """ *************** *** 2718,2736 **** be set. The rounding mode is taken from the context. ! >>> Context(prec=9).to_integral(Decimal('2.1')) Decimal("2") ! >>> Context(prec=9).to_integral(Decimal('100')) Decimal("100") ! >>> Context(prec=9).to_integral(Decimal('100.0')) Decimal("100") ! >>> Context(prec=9).to_integral(Decimal('101.5')) Decimal("102") ! >>> Context(prec=9).to_integral(Decimal('-101.5')) Decimal("-102") ! >>> Context(prec=9).to_integral(Decimal('10E+5')) Decimal("1.0E+6") ! >>> Context(prec=9).to_integral(Decimal('7.89E+77')) Decimal("7.89E+77") ! >>> Context(prec=9).to_integral(Decimal('-Inf')) Decimal("-Infinity") """ --- 2682,2700 ---- be set. The rounding mode is taken from the context. ! >>> DefaultContext.to_integral(Decimal('2.1')) Decimal("2") ! >>> DefaultContext.to_integral(Decimal('100')) Decimal("100") ! >>> DefaultContext.to_integral(Decimal('100.0')) Decimal("100") ! >>> DefaultContext.to_integral(Decimal('101.5')) Decimal("102") ! >>> DefaultContext.to_integral(Decimal('-101.5')) Decimal("-102") ! >>> DefaultContext.to_integral(Decimal('10E+5')) Decimal("1.0E+6") ! >>> DefaultContext.to_integral(Decimal('7.89E+77')) Decimal("7.89E+77") ! >>> DefaultContext.to_integral(Decimal('-Inf')) Decimal("-Infinity") """ *************** *** 2924,2999 **** return op1, op2, adjust ! ! BASIC_DEFAULT_TRAPS = {} ! BASIC_DEFAULT_FLAGS = {} ! ! EXTENDED_DEFAULT_TRAPS = {} ! EXTENDED_DEFAULT_FLAGS = {} ! ! for exception in ExceptionList: ! BASIC_DEFAULT_TRAPS[exception] = exception.default ! BASIC_DEFAULT_FLAGS[exception] = 0 ! EXTENDED_DEFAULT_TRAPS[exception] = 0 ! EXTENDED_DEFAULT_FLAGS[exception] = 0 ! ! ! DEFAULT_PRECISION = EXTENDED_DEFAULT_PRECISION ! DEFAULT_ROUNDING = EXTENDED_DEFAULT_ROUNDING ! DEFAULT_TRAPS = EXTENDED_DEFAULT_TRAPS ! DEFAULT_FLAGS= EXTENDED_DEFAULT_FLAGS ! DEFAULT_ROUNDING_DECISION = EXTENDED_DEFAULT_ROUNDING_DECISION ! ! IGNORED_FLAGS = [] ! ! DefaultLock = threading.Lock() ! DefaultContext = Context(DEFAULT_PRECISION, DEFAULT_ROUNDING, ! DEFAULT_TRAPS.copy(), ! DEFAULT_FLAGS.copy(), DEFAULT_ROUNDING_DECISION, ! DEFAULT_MIN_EXPONENT, DEFAULT_MAX_EXPONENT, ! CAPITALS, CLAMP, IGNORED_FLAGS) ! ! #Used in SetDefaultContext ! DefaultAttributeDict= {'DEFAULT_PRECISION' : 'prec', ! 'DEFAULT_TRAPS' : 'trap_enablers', ! 'DEFAULT_FLAGS' : 'flags', ! 'DEFAULT_ROUNDING' : 'rounding', ! 'DEFAULT_ROUNDING_DECISION' : '_rounding_decision', ! 'DEFAULT_MIN_EXPONENT' : 'Emin', ! 'DEFAULT_MAX_EXPONENT' : 'Emax'} ! ! ! def SetDefaultContext(context=None): ! """Changes DefaultContext to the DEFAULT_* ! ! If context (default None) is BASIC_DEFAULT_CONTEXT or ! EXTENDED_DEFAULT_CONTEXT, sets DEFAULT_* to BASIC_DEFAULT_* or ! EXTENDED_DEFAULT_*. ! ! Whether that happened or not, change DefaultContext to use those. ! """ ! global DEFAULT_CONTEXT, DEFAULT_PRECISION, DEFAULT_TRAPS ! global DEFAULT_FLAGS, DEFAULT_ROUNDING, DEFAULT_ROUNDING_DECISION ! global DEFAULT_MIN_EXPONENT, DEFAULT_MAX_EXPONENT ! DEFAULT_CONTEXT = context ! if DEFAULT_CONTEXT == BASIC_DEFAULT_CONTEXT: ! DEFAULT_PRECISION = BASIC_DEFAULT_PRECISION ! DEFAULT_ROUNDING = BASIC_DEFAULT_ROUNDING ! DEFAULT_TRAPS = BASIC_DEFAULT_TRAPS ! DEFAULT_FLAGS= BASIC_DEFAULT_FLAGS ! DEFAULT_ROUNDING_DECISION = BASIC_DEFAULT_ROUNDING_DECISION ! ! elif DEFAULT_CONTEXT == EXTENDED_DEFAULT_CONTEXT: ! DEFAULT_PRECISION = EXTENDED_DEFAULT_PRECISION ! DEFAULT_ROUNDING = EXTENDED_DEFAULT_ROUNDING ! DEFAULT_TRAPS = EXTENDED_DEFAULT_TRAPS ! DEFAULT_FLAGS= EXTENDED_DEFAULT_FLAGS ! DEFAULT_ROUNDING_DECISION = EXTENDED_DEFAULT_ROUNDING_DECISION ! ! for key, val in DefaultAttributeDict.items(): ! setattr(DefaultContext, val, ! copy.copy(globals()[key])) ! ! ! SetDefaultContext(DEFAULT_CONTEXT) _infinity_map = { --- 2888,2892 ---- return op1, op2, adjust ! ##### Helper Functions ######################################## _infinity_map = { *************** *** 3043,3046 **** --- 2936,2984 ---- return 0 + + ##### Setup Specific Contexts ################################ + + def _zero_exceptions(): + "Helper function mapping all exceptions to zero." + d = {} + for exception in ExceptionList: + d[exception] = 0 + return d + + # The default context prototype used by Context() + # Is mutable, so than new contexts can have different default values + + DefaultContext = Context( + prec=SINGLE_PRECISION, rounding=ROUND_HALF_EVEN, + trap_enablers=_zero_exceptions(), + flags=_zero_exceptions(), + _rounding_decision=ALWAYS_ROUND, + ) + + # Pre-made alternate contexts offered by the specification + # Don't change these; the user should be able to select these + # contexts and be able to reproduce results from other implementations + # of the spec. + + _basic_traps = _zero_exceptions() + _basic_traps.update({Inexact:1, Rounded:1, Subnormal:1}) + + BasicDefaultContext = Context( + prec=9, rounding=ROUND_HALF_UP, + trap_enablers=_basic_traps, + flags=_zero_exceptions(), + _rounding_decision=ALWAYS_ROUND, + ) + + ExtendedDefaultContext = Context( + prec=SINGLE_PRECISION, rounding=ROUND_HALF_EVEN, + trap_enablers=_zero_exceptions(), + flags=_zero_exceptions(), + _rounding_decision=ALWAYS_ROUND, + ) + + + ##### Useful Constants ###################################### + #Reusable defaults Inf = Decimal('Inf') *************** *** 3052,3056 **** NaN = Decimal('NaN') ! # crud for parsing strings import re --- 2990,2995 ---- NaN = Decimal('NaN') ! ! ##### crud for parsing strings ################################# import re From rhettinger at users.sourceforge.net Thu Jul 1 05:27:33 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Thu Jul 1 05:27:37 2004 Subject: [Python-checkins] python/nondist/sandbox/decimal test_Decimal.py, 1.25, 1.26 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/decimal In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13344 Modified Files: test_Decimal.py Log Message: Adjust test logic to handle -u resource option from regrtest.py to control whether the full set of arithmetic tests are run. Index: test_Decimal.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/decimal/test_Decimal.py,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** test_Decimal.py 1 Jul 2004 06:44:52 -0000 1.25 --- test_Decimal.py 1 Jul 2004 09:27:30 -0000 1.26 *************** *** 32,36 **** import pickle, copy from Decimal import * ! from test.test_support import TestSkipped, run_unittest, run_doctest --- 32,36 ---- import pickle, copy from Decimal import * ! from test.test_support import TestSkipped, run_unittest, run_doctest, is_resource_enabled *************** *** 1047,1072 **** self.assertEqual(d, e) ! def test_main(which=None, verbose=None): """ Execute the tests. ! If called with "Arithmetic", just executes the arithmetic tests. ! If called with "Behaviour", just executes the pythonic behaviour tests. ! Otherwise, executes both of them. """ ! test_classes = [] ! if which is None or which.lower().startswith("arith"): test_classes.extend([DecimalTest]) - if which is None or which.lower().startswith("behav"): - test_classes.extend([ - DecimalExplicitConstructionTest, - DecimalImplicitConstructionTest, - DecimalArithmeticOperatorsTest, - DecimalUseOfContextTest, - DecimalUsabilityTest, - DecimalPythonAPItests, - ]) - run_unittest(*test_classes) import Decimal as DecimalModule --- 1047,1068 ---- self.assertEqual(d, e) ! def test_main(arith=False, verbose=None): """ Execute the tests. ! Runs arithmetic tests if arith is True or if the "decimal" resource ! is enables in regrtest.py """ ! test_classes = [ ! DecimalExplicitConstructionTest, ! DecimalImplicitConstructionTest, ! DecimalArithmeticOperatorsTest, ! DecimalUseOfContextTest, ! DecimalUsabilityTest, ! DecimalPythonAPItests, ! ] ! if arith or is_resource_enabled('decimal'): test_classes.extend([DecimalTest]) run_unittest(*test_classes) import Decimal as DecimalModule *************** *** 1076,1083 **** if __name__ == '__main__': if len(sys.argv) == 1: ! test_main(verbose=True) elif len(sys.argv) == 2: ! test_main(sys.argv[1], verbose=True) else: ! raise ValueError, "test called with wrong arguments, use test_Decimal [Arithmetic|Behaviour]" --- 1072,1082 ---- if __name__ == '__main__': + # Calling with no arguments runs all tests. + # Calling with "Skip" will skipover the arithmetic tests. if len(sys.argv) == 1: ! test_main(arith=True, verbose=True) elif len(sys.argv) == 2: ! arith = sys.argv[1].lower() != 'skip' ! test_main(arith=arith, verbose=True) else: ! raise ValueError("test called with wrong arguments, use test_Decimal [Skip]") From rhettinger at users.sourceforge.net Thu Jul 1 06:01:59 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Thu Jul 1 06:02:03 2004 Subject: [Python-checkins] python/nondist/sandbox/decimal Decimal.py, 1.36, 1.37 test_Decimal.py, 1.26, 1.27 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/decimal In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18515 Modified Files: Decimal.py test_Decimal.py Log Message: * Add an __all__ attribute to Decimal.py * Add a missing "import threading" to test_Decimal.py * Mark some non-API globals as private Index: Decimal.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/decimal/Decimal.py,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** Decimal.py 1 Jul 2004 08:21:28 -0000 1.36 --- Decimal.py 1 Jul 2004 10:01:42 -0000 1.37 *************** *** 11,20 **** # Todo: # Add deepcopy and pickle support for contexts - # Rename to decimal.Decimal before moving into production # Consider having a SimpleDecimal subclass implementing X3.274 semantics - # Add an __all__ attribute # Improve the Context API # Provide a clean way of attaching monetary format representations # Review all exposed constants for utility vs. namespace clutter """ --- 11,24 ---- # Todo: # Add deepcopy and pickle support for contexts # Consider having a SimpleDecimal subclass implementing X3.274 semantics # Improve the Context API + # Especially with respect to setting flags and traps + # Consider adding a clear_flags() method to Context # Provide a clean way of attaching monetary format representations # Review all exposed constants for utility vs. namespace clutter + # When moving into core + # rename Decimal.py and test_Decimal.py to lowercase decimal + # retarget the test directory to decimaltestdata + """ *************** *** 120,124 **** """ ! # XXX Add an __all__ attribute import threading --- 124,155 ---- """ ! __all__ = [ ! # Two major classes ! 'Decimal', 'Context', ! ! # Contexts ! 'DefaultContext', 'BasicDefaultContext', 'ExtendedDefaultContext', ! ! # Exceptions ! 'DecimalException', 'Clamped', 'InvalidOperation', 'ConversionSyntax', ! 'DivisionByZero', 'DivisionImpossible', 'DivisionUndefined', ! 'Inexact', 'InvalidContext', 'Rounded', 'Subnormal', 'Overflow', ! 'Underflow', ! ! # Module parameters ! 'SINGLE_PRECISION', 'DEFAULT_MAX_EXPONENT', 'DEFAULT_MIN_EXPONENT', ! ! # Constants for use in setting up contexts ! 'ROUND_DOWN', 'ROUND_HALF_UP', 'ROUND_HALF_EVEN', 'ROUND_CEILING', ! 'ROUND_FLOOR', 'ROUND_UP', 'ROUND_HALF_DOWN', ! 'NEVER_ROUND', 'ALWAYS_ROUND', ! 'ExceptionList', # <-- Used for building trap/flag dictionaries ! ! # Functions for manipulating contexts ! 'setcontext', 'getcontext', ! ! # Functions for working with decimals ! 'isinfinity', 'isnan', ! ] import threading *************** *** 376,380 **** ! def filterfunct(obj): """Returns true if a subclass of DecimalException""" try: --- 407,411 ---- ! def _filterfunct(obj): """Returns true if a subclass of DecimalException""" try: *************** *** 384,388 **** #ExceptionList holds the exceptions ! ExceptionList = filter(filterfunct, globals().values()) #To fix reloading, force it to create a new context --- 415,419 ---- #ExceptionList holds the exceptions ! ExceptionList = filter(_filterfunct, globals().values()) #To fix reloading, force it to create a new context *************** *** 2979,2983 **** ! ##### Useful Constants ###################################### #Reusable defaults --- 3010,3014 ---- ! ##### Useful Constants (internal use only###################### #Reusable defaults Index: test_Decimal.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/decimal/test_Decimal.py,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** test_Decimal.py 1 Jul 2004 09:27:30 -0000 1.26 --- test_Decimal.py 1 Jul 2004 10:01:42 -0000 1.27 *************** *** 33,37 **** from Decimal import * from test.test_support import TestSkipped, run_unittest, run_doctest, is_resource_enabled ! TESTDATADIR = 'tests' --- 33,37 ---- from Decimal import * from test.test_support import TestSkipped, run_unittest, run_doctest, is_resource_enabled ! import threading TESTDATADIR = 'tests' From rhettinger at users.sourceforge.net Thu Jul 1 06:30:37 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Thu Jul 1 06:30:41 2004 Subject: [Python-checkins] python/nondist/sandbox/decimal Decimal.py, 1.37, 1.38 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/decimal In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22541 Modified Files: Decimal.py Log Message: * Enable module self-test by using a doctest at the end. * Comment out a test which mysteriously fails the self-test but passes the doctester in test_Decimal.py. * Remove non-Ascii characters from the file. * Add some Py2.2 compatability code. * Note that one doctest fails under Py2.2 by returning a NaN instead of the expected value. Index: Decimal.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/decimal/Decimal.py,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** Decimal.py 1 Jul 2004 10:01:42 -0000 1.37 --- Decimal.py 1 Jul 2004 10:30:33 -0000 1.38 *************** *** 1,3 **** ! # Copyright (c) 2004 Python Software Foundation. # All rights reserved. --- 1,3 ---- ! # Copyright (c) 2004 Python Software Foundation. # All rights reserved. *************** *** 20,24 **** # rename Decimal.py and test_Decimal.py to lowercase decimal # retarget the test directory to decimaltestdata ! """ --- 20,27 ---- # rename Decimal.py and test_Decimal.py to lowercase decimal # retarget the test directory to decimaltestdata ! # Fix doctest for _fixedpoint which fails only when run from this file ! # but works fine in the doctest in test_decimal. ! # Checkout the doctest for Decimal("123.45e12345678901234567890") ! # which works in Py2.3 and Py2.4 but returns a NaN in Py2.2. """ *************** *** 269,273 **** The result of the operation is [sign,inf], where sign is the exclusive or of the signs of the operands for divide, or is 1 for an odd power of ! –0, for power. """ --- 272,276 ---- The result of the operation is [sign,inf], where sign is the exclusive or of the signs of the operands for divide, or is 1 for an odd power of ! -0, for power. """ *************** *** 407,411 **** ! def _filterfunct(obj): """Returns true if a subclass of DecimalException""" try: --- 410,414 ---- ! def _filterfunc(obj): """Returns true if a subclass of DecimalException""" try: *************** *** 415,419 **** #ExceptionList holds the exceptions ! ExceptionList = filter(_filterfunct, globals().values()) #To fix reloading, force it to create a new context --- 418,444 ---- #ExceptionList holds the exceptions ! ExceptionList = filter(_filterfunc, globals().values()) ! ! del _filterfunc ! ! ! ##### Py2.2 Compatability ##################################### ! ! try: ! basestring ! except NameError: ! basestring = (str, unicode) ! ! try: ! True ! except NameError: ! True = (1==1) ! ! try: ! False ! except NameError: ! False = (1!=1) ! ! ##### Context Functions ####################################### #To fix reloading, force it to create a new context *************** *** 441,444 **** --- 466,471 ---- + ##### Decimal class ########################################### + class Decimal(object): """Floating point class for decimal arithmetic.""" *************** *** 1680,1692 **** def _fixedPoint(self, digits, rounding = None, context=None): ! """Rounds to a number of digits around the decimal point. ! ! Convenience function to allow rounding to a specified number of ! places after the decimal point. Negative numbers indicate ! rounding before the decimal point. ! ! >>> str(Decimal("1234.34567")._fixedPoint(2)) ! '1234.35' ! """ numdigits = len(self._int)+self._exp ans = self._round(numdigits+digits, rounding, context=context) --- 1707,1718 ---- def _fixedPoint(self, digits, rounding = None, context=None): ! ## """Rounds to a number of digits around the decimal point. ! ## ! ## Convenience function to allow rounding to a specified number of ! ## places after the decimal point. Negative numbers indicate ! ## rounding before the decimal point. ! ## ! ## >>> str(Decimal("1234.34567")._fixedPoint(2)) ! ## '1234.35' numdigits = len(self._int)+self._exp ans = self._round(numdigits+digits, rounding, context=context) *************** *** 2308,2313 **** If the signs of the operands differ, a value representing each operand ! (’-1’ if the operand is less than zero, ’0’ if the operand is zero or ! negative zero, or ’1’ if the operand is greater than zero) is used in place of that operand for the comparison instead of the actual operand. --- 2334,2339 ---- If the signs of the operands differ, a value representing each operand ! ('-1' if the operand is less than zero, '0' if the operand is zero or ! negative zero, or '1' if the operand is greater than zero) is used in place of that operand for the comparison instead of the actual operand. *************** *** 2315,2320 **** The comparison is then effected by subtracting the second operand from the first and then returning a value according to the result of the ! subtraction: ’-1’ if the result is less than zero, ’0’ if the result is ! zero or negative zero, or ’1’ if the result is greater than zero. >>> DefaultContext.compare(Decimal('2.1'), Decimal('3')) --- 2341,2346 ---- The comparison is then effected by subtracting the second operand from the first and then returning a value according to the result of the ! subtraction: '-1' if the result is less than zero, '0' if the result is ! zero or negative zero, or '1' if the result is greater than zero. >>> DefaultContext.compare(Decimal('2.1'), Decimal('3')) *************** *** 2414,2418 **** The operation is evaluated using the same rules as subtract; the ! operation minus(a) is calculated as subtract(’0’, a) where the ’0’ has the same exponent as the operand. --- 2440,2444 ---- The operation is evaluated using the same rules as subtract; the ! operation minus(a) is calculated as subtract('0', a) where the '0' has the same exponent as the operand. *************** *** 2428,2432 **** If either operand is a special value then the general rules apply. ! Otherwise, the operands are multiplied together (‘long multiplication’), resulting in a number which may be as long as the sum of the lengths of the two operands. --- 2454,2458 ---- If either operand is a special value then the general rules apply. ! Otherwise, the operands are multiplied together ('long multiplication'), resulting in a number which may be as long as the sum of the lengths of the two operands. *************** *** 2470,2474 **** The operation is evaluated using the same rules as add; the ! operation plus(a) is calculated as add(’0’, a) where the ’0’ has the same exponent as the operand. --- 2496,2500 ---- The operation is evaluated using the same rules as add; the ! operation plus(a) is calculated as add('0', a) where the '0' has the same exponent as the operand. *************** *** 2608,2613 **** def remainder_near(self, a, b): ! """Returns to be a – b × n, where n is the integer nearest the exact ! value of a ÷ b (if two integers are equally near then the even one is chosen). If the result is equal to 0 then its sign will be the sign of a. --- 2634,2639 ---- def remainder_near(self, a, b): ! """Returns to be "a - b * n", where n is the integer nearest the exact ! value of "x / b" (if two integers are equally near then the even one is chosen). If the result is equal to 0 then its sign will be the sign of a. *************** *** 3091,3095 **** ! ##if __name__ == '__main__': ! ## import doctest, sys ! ## doctest.testmod(sys.modules[__name__]) --- 3117,3121 ---- ! if __name__ == '__main__': ! import doctest, sys ! doctest.testmod(sys.modules[__name__]) From rhettinger at users.sourceforge.net Thu Jul 1 06:35:47 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Thu Jul 1 06:35:50 2004 Subject: [Python-checkins] python/nondist/sandbox/decimal Decimal.py, 1.38, 1.39 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/decimal In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23601 Modified Files: Decimal.py Log Message: Remove unused private method. Index: Decimal.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/decimal/Decimal.py,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** Decimal.py 1 Jul 2004 10:30:33 -0000 1.38 --- Decimal.py 1 Jul 2004 10:35:45 -0000 1.39 *************** *** 20,25 **** # rename Decimal.py and test_Decimal.py to lowercase decimal # retarget the test directory to decimaltestdata - # Fix doctest for _fixedpoint which fails only when run from this file - # but works fine in the doctest in test_decimal. # Checkout the doctest for Decimal("123.45e12345678901234567890") # which works in Py2.3 and Py2.4 but returns a NaN in Py2.2. --- 20,23 ---- *************** *** 1706,1722 **** return self._round_up(prec, expdiff, context) - def _fixedPoint(self, digits, rounding = None, context=None): - ## """Rounds to a number of digits around the decimal point. - ## - ## Convenience function to allow rounding to a specified number of - ## places after the decimal point. Negative numbers indicate - ## rounding before the decimal point. - ## - ## >>> str(Decimal("1234.34567")._fixedPoint(2)) - ## '1234.35' - numdigits = len(self._int)+self._exp - ans = self._round(numdigits+digits, rounding, context=context) - return ans - def __pow__(self, n, modulo = None, context=None): """Return self ** n (mod modulo) --- 1704,1707 ---- From rhettinger at users.sourceforge.net Thu Jul 1 06:53:46 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Thu Jul 1 06:53:49 2004 Subject: [Python-checkins] python/dist/src/Lib/test/decimaltestdata - New directory Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test/decimaltestdata In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25836/decimaltestdata Log Message: Directory /cvsroot/python/python/dist/src/Lib/test/decimaltestdata added to the repository From rhettinger at users.sourceforge.net Thu Jul 1 07:01:33 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Thu Jul 1 07:01:37 2004 Subject: [Python-checkins] python/dist/src/Lib decimal.py,NONE,1.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26988/Lib Added Files: decimal.py Log Message: Move Decimal from the sandbox into production. --- NEW FILE: decimal.py --- # Copyright (c) 2004 Python Software Foundation. # All rights reserved. # Written by Eric Price # and Facundo Batista # and Raymond Hettinger # and Aahz (aahz at pobox.com) # and Tim Peters # Todo: # Add deepcopy and pickle support for contexts # Consider having a SimpleDecimal subclass implementing X3.274 semantics # Improve the Context API # Especially with respect to setting flags and traps # Consider adding a clear_flags() method to Context # Provide a clean way of attaching monetary format representations # Review all exposed constants for utility vs. namespace clutter [...3046 lines suppressed...] mantissa = intpart + fracpart tmp = map(int, mantissa) backup = tmp while tmp and tmp[0] == 0: del tmp[0] # It's a zero if not tmp: if backup: return (sign, tuple(backup), exp) return (sign, (0,), exp) mantissa = tuple(tmp) return (sign, mantissa, exp) if __name__ == '__main__': import doctest, sys doctest.testmod(sys.modules[__name__]) From rhettinger at users.sourceforge.net Thu Jul 1 07:01:37 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Thu Jul 1 07:01:53 2004 Subject: [Python-checkins] python/dist/src/Lib/test/decimaltestdata abs.decTest, NONE, 1.1 add.decTest, NONE, 1.1 base.decTest, NONE, 1.1 clamp.decTest, NONE, 1.1 compare.decTest, NONE, 1.1 decimal64.decTest, NONE, 1.1 divide.decTest, NONE, 1.1 divideint.decTest, NONE, 1.1 inexact.decTest, NONE, 1.1 integer.decTest, NONE, 1.1 max.decTest, NONE, 1.1 min.decTest, NONE, 1.1 minus.decTest, NONE, 1.1 multiply.decTest, NONE, 1.1 normalize.decTest, NONE, 1.1 plus.decTest, NONE, 1.1 power.decTest, NONE, 1.1 quantize.decTest, NONE, 1.1 randomBound32.decTest, NONE, 1.1 randoms.decTest, NONE, 1.1 remainder.decTest, NONE, 1.1 remainderNear.decTest, NONE, 1.1 rescale.decTest, NONE, 1.1 rounding.decTest, NONE, 1.1 samequantum.decTest, NONE, 1.1 squareroot.decTest, NONE, 1.1 subtract.decTest, NONE, 1.1 testall.decTest, NONE, 1.1 tointegral.decTest, NONE, 1.1 trim.decTest, NONE, 1.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test/decimaltestdata In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26988/Lib/test/decimaltestdata Added Files: abs.decTest add.decTest base.decTest clamp.decTest compare.decTest decimal64.decTest divide.decTest divideint.decTest inexact.decTest integer.decTest max.decTest min.decTest minus.decTest multiply.decTest normalize.decTest plus.decTest power.decTest quantize.decTest randomBound32.decTest randoms.decTest remainder.decTest remainderNear.decTest rescale.decTest rounding.decTest samequantum.decTest squareroot.decTest subtract.decTest testall.decTest tointegral.decTest trim.decTest Log Message: Move Decimal from the sandbox into production. --- NEW FILE: abs.decTest --- ------------------------------------------------------------------------ -- abs.decTest -- decimal absolute value -- -- Copyright (c) IBM Corporation, 1981, 2004. All rights reserved. -- ------------------------------------------------------------------------ -- Please see the document "General Decimal Arithmetic Testcases" -- -- at http://www2.hursley.ibm.com/decimal for the description of -- -- these testcases. -- -- -- -- These testcases are experimental ('beta' versions), and they -- -- may contain errors. They are offered on an as-is basis. In -- -- particular, achieving the same results as the tests here is not -- -- a guarantee that an implementation complies with any Standard -- -- or specification. The tests are not exhaustive. -- -- -- -- Please send comments, suggestions, and corrections to the author: -- -- Mike Cowlishaw, IBM Fellow -- -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ version: 2.38 -- This set of tests primarily tests the existence of the operator. -- Additon, subtraction, rounding, and more overflows are tested -- elsewhere. precision: 9 rounding: half_up maxExponent: 384 minexponent: -383 extended: 1 absx001 abs '1' -> '1' absx002 abs '-1' -> '1' absx003 abs '1.00' -> '1.00' absx004 abs '-1.00' -> '1.00' absx005 abs '0' -> '0' absx006 abs '0.00' -> '0.00' absx007 abs '00.0' -> '0.0' absx008 abs '00.00' -> '0.00' absx009 abs '00' -> '0' absx010 abs '-2' -> '2' absx011 abs '2' -> '2' absx012 abs '-2.00' -> '2.00' absx013 abs '2.00' -> '2.00' absx014 abs '-0' -> '0' absx015 abs '-0.00' -> '0.00' absx016 abs '-00.0' -> '0.0' absx017 abs '-00.00' -> '0.00' absx018 abs '-00' -> '0' absx020 abs '-2000000' -> '2000000' absx021 abs '2000000' -> '2000000' precision: 7 absx022 abs '-2000000' -> '2000000' absx023 abs '2000000' -> '2000000' precision: 6 absx024 abs '-2000000' -> '2.00000E+6' Rounded absx025 abs '2000000' -> '2.00000E+6' Rounded precision: 3 absx026 abs '-2000000' -> '2.00E+6' Rounded absx027 abs '2000000' -> '2.00E+6' Rounded absx030 abs '+0.1' -> '0.1' absx031 abs '-0.1' -> '0.1' absx032 abs '+0.01' -> '0.01' absx033 abs '-0.01' -> '0.01' absx034 abs '+0.001' -> '0.001' absx035 abs '-0.001' -> '0.001' absx036 abs '+0.000001' -> '0.000001' absx037 abs '-0.000001' -> '0.000001' absx038 abs '+0.000000000001' -> '1E-12' absx039 abs '-0.000000000001' -> '1E-12' -- examples from decArith precision: 9 absx040 abs '2.1' -> '2.1' absx041 abs '-100' -> '100' absx042 abs '101.5' -> '101.5' absx043 abs '-101.5' -> '101.5' -- more fixed, potential LHS swaps/overlays if done by subtract 0 precision: 9 absx060 abs '-56267E-10' -> '0.0000056267' absx061 abs '-56267E-5' -> '0.56267' absx062 abs '-56267E-2' -> '562.67' absx063 abs '-56267E-1' -> '5626.7' absx065 abs '-56267E-0' -> '56267' -- overflow tests maxexponent: 999999999 minexponent: -999999999 precision: 3 absx120 abs 9.999E+999999999 -> Infinity Inexact Overflow Rounded -- subnormals and underflow precision: 3 maxexponent: 999 minexponent: -999 absx210 abs 1.00E-999 -> 1.00E-999 absx211 abs 0.1E-999 -> 1E-1000 Subnormal absx212 abs 0.10E-999 -> 1.0E-1000 Subnormal absx213 abs 0.100E-999 -> 1.0E-1000 Subnormal Rounded absx214 abs 0.01E-999 -> 1E-1001 Subnormal -- next is rounded to Emin absx215 abs 0.999E-999 -> 1.00E-999 Inexact Rounded Subnormal Underflow absx216 abs 0.099E-999 -> 1.0E-1000 Inexact Rounded Subnormal Underflow absx217 abs 0.009E-999 -> 1E-1001 Inexact Rounded Subnormal Underflow absx218 abs 0.001E-999 -> 0E-1001 Inexact Rounded Subnormal Underflow absx219 abs 0.0009E-999 -> 0E-1001 Inexact Rounded Subnormal Underflow absx220 abs 0.0001E-999 -> 0E-1001 Inexact Rounded Subnormal Underflow absx230 abs -1.00E-999 -> 1.00E-999 absx231 abs -0.1E-999 -> 1E-1000 Subnormal absx232 abs -0.10E-999 -> 1.0E-1000 Subnormal absx233 abs -0.100E-999 -> 1.0E-1000 Subnormal Rounded absx234 abs -0.01E-999 -> 1E-1001 Subnormal -- next is rounded to Emin absx235 abs -0.999E-999 -> 1.00E-999 Inexact Rounded Subnormal Underflow absx236 abs -0.099E-999 -> 1.0E-1000 Inexact Rounded Subnormal Underflow absx237 abs -0.009E-999 -> 1E-1001 Inexact Rounded Subnormal Underflow absx238 abs -0.001E-999 -> 0E-1001 Inexact Rounded Subnormal Underflow absx239 abs -0.0009E-999 -> 0E-1001 Inexact Rounded Subnormal Underflow absx240 abs -0.0001E-999 -> 0E-1001 Inexact Rounded Subnormal Underflow -- long operand tests maxexponent: 999 minexponent: -999 precision: 9 absx301 abs 12345678000 -> 1.23456780E+10 Rounded absx302 abs 1234567800 -> 1.23456780E+9 Rounded absx303 abs 1234567890 -> 1.23456789E+9 Rounded absx304 abs 1234567891 -> 1.23456789E+9 Inexact Rounded absx305 abs 12345678901 -> 1.23456789E+10 Inexact Rounded absx306 abs 1234567896 -> 1.23456790E+9 Inexact Rounded precision: 15 absx321 abs 12345678000 -> 12345678000 absx322 abs 1234567800 -> 1234567800 absx323 abs 1234567890 -> 1234567890 absx324 abs 1234567891 -> 1234567891 absx325 abs 12345678901 -> 12345678901 absx326 abs 1234567896 -> 1234567896 -- Specials precision: 9 -- specials absx520 abs 'Inf' -> 'Infinity' absx521 abs '-Inf' -> 'Infinity' absx522 abs NaN -> NaN absx523 abs sNaN -> NaN Invalid_operation absx524 abs NaN22 -> NaN22 absx525 abs sNaN33 -> NaN33 Invalid_operation absx526 abs -NaN22 -> -NaN22 absx527 abs -sNaN33 -> -NaN33 Invalid_operation -- Null tests absx900 abs # -> NaN Invalid_operation --- NEW FILE: add.decTest --- ------------------------------------------------------------------------ -- add.decTest -- decimal addition -- -- Copyright (c) IBM Corporation, 1981, 2004. All rights reserved. -- ------------------------------------------------------------------------ -- Please see the document "General Decimal Arithmetic Testcases" -- -- at http://www2.hursley.ibm.com/decimal for the description of -- -- these testcases. -- -- -- -- These testcases are experimental ('beta' versions), and they -- -- may contain errors. They are offered on an as-is basis. In -- -- particular, achieving the same results as the tests here is not -- -- a guarantee that an implementation complies with any Standard -- -- or specification. The tests are not exhaustive. -- -- -- -- Please send comments, suggestions, and corrections to the author: -- -- Mike Cowlishaw, IBM Fellow -- -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ [...1088 lines suppressed...] addx1141 add 10E-101 -1e-200 -> 9E-101 Subnormal Inexact Rounded Underflow addx1142 add 1E-101 -1e-200 -> 0E-101 Subnormal Inexact Rounded Underflow addx1143 add 0E-101 -1e-200 -> -0E-101 Subnormal Inexact Rounded Underflow addx1144 add 1E-102 -1e-200 -> 0E-101 Subnormal Inexact Rounded Underflow addx1151 add 10000E-102 -1e-200 -> 9.99E-99 Subnormal Inexact Rounded Underflow addx1152 add 1000E-102 -1e-200 -> 9.9E-100 Subnormal Inexact Rounded Underflow addx1153 add 100E-102 -1e-200 -> 9E-101 Subnormal Inexact Rounded Underflow addx1154 add 10E-102 -1e-200 -> 0E-101 Subnormal Inexact Rounded Underflow addx1155 add 1E-102 -1e-200 -> 0E-101 Subnormal Inexact Rounded Underflow addx1156 add 0E-102 -1e-200 -> -0E-101 Subnormal Inexact Rounded Underflow addx1157 add 1E-103 -1e-200 -> 0E-101 Subnormal Inexact Rounded Underflow addx1160 add 100E-105 -1e-101 -> -0E-101 Subnormal Inexact Rounded Underflow addx1161 add 100E-105 -1e-201 -> 0E-101 Subnormal Inexact Rounded Underflow -- Null tests addx9990 add 10 # -> NaN Invalid_operation addx9991 add # 10 -> NaN Invalid_operation --- NEW FILE: base.decTest --- ------------------------------------------------------------------------ -- base.decTest -- base decimal <--> string conversions -- -- Copyright (c) IBM Corporation, 1981, 2003. All rights reserved. -- ------------------------------------------------------------------------ -- Please see the document "General Decimal Arithmetic Testcases" -- -- at http://www2.hursley.ibm.com/decimal for the description of -- -- these testcases. -- -- -- -- These testcases are experimental ('beta' versions), and they -- -- may contain errors. They are offered on an as-is basis. In -- -- particular, achieving the same results as the tests here is not -- -- a guarantee that an implementation complies with any Standard -- -- or specification. The tests are not exhaustive. -- -- -- -- Please send comments, suggestions, and corrections to the author: -- -- Mike Cowlishaw, IBM Fellow -- -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ [...1227 lines suppressed...] basx1026 tosci 1e-2147483649 -> 0E-1000000014 Underflow Subnormal Inexact Rounded -- same unbalanced precision: 7 maxExponent: 96 minexponent: -95 basx1031 tosci 1e+2147483649 -> Infinity Overflow Inexact Rounded basx1032 tosci 1e+2147483648 -> Infinity Overflow Inexact Rounded basx1033 tosci 1e+2147483647 -> Infinity Overflow Inexact Rounded basx1034 tosci 1e-2147483647 -> 0E-101 Underflow Subnormal Inexact Rounded basx1035 tosci 1e-2147483648 -> 0E-101 Underflow Subnormal Inexact Rounded basx1036 tosci 1e-2147483649 -> 0E-101 Underflow Subnormal Inexact Rounded -- check for double-rounded subnormals precision: 5 maxexponent: 79 minexponent: -79 basx1041 toSci 1.52444E-80 -> 1.524E-80 Inexact Rounded Subnormal Underflow basx1042 toSci 1.52445E-80 -> 1.524E-80 Inexact Rounded Subnormal Underflow basx1043 toSci 1.52446E-80 -> 1.524E-80 Inexact Rounded Subnormal Underflow --- NEW FILE: clamp.decTest --- ------------------------------------------------------------------------ -- clamp.decTest -- clamped exponent tests (format-independent) -- -- Copyright (c) IBM Corporation, 2000, 2003. All rights reserved. -- ------------------------------------------------------------------------ -- Please see the document "General Decimal Arithmetic Testcases" -- -- at http://www2.hursley.ibm.com/decimal for the description of -- -- these testcases. -- -- -- -- These testcases are experimental ('beta' versions), and they -- -- may contain errors. They are offered on an as-is basis. In -- -- particular, achieving the same results as the tests here is not -- -- a guarantee that an implementation complies with any Standard -- -- or specification. The tests are not exhaustive. -- -- -- -- Please send comments, suggestions, and corrections to the author: -- -- Mike Cowlishaw, IBM Fellow -- -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ version: 2.38 -- This set of tests uses the same limits as the 8-byte concrete -- representation, but applies clamping without using format-specific -- conversions. extended: 1 precision: 16 rounding: half_even maxExponent: 384 minExponent: -383 clamp: 1 -- General testcases -- Normality clam010 apply 1234567890123456 -> 1234567890123456 clam011 apply 1234567890123456.0 -> 1234567890123456 Rounded clam012 apply 1234567890123456.1 -> 1234567890123456 Rounded Inexact clam013 apply -1234567890123456 -> -1234567890123456 clam014 apply -1234567890123456.0 -> -1234567890123456 Rounded clam015 apply -1234567890123456.1 -> -1234567890123456 Rounded Inexact -- Nmax and similar clam022 apply 9.999999999999999E+384 -> 9.999999999999999E+384 clam024 apply 1.234567890123456E+384 -> 1.234567890123456E+384 -- fold-downs (more below) clam030 apply 1.23E+384 -> 1.230000000000000E+384 Clamped clam032 apply 1E+384 -> 1.000000000000000E+384 Clamped clam051 apply 12345 -> 12345 clam053 apply 1234 -> 1234 clam055 apply 123 -> 123 clam057 apply 12 -> 12 clam059 apply 1 -> 1 clam061 apply 1.23 -> 1.23 clam063 apply 123.45 -> 123.45 -- Nmin and below clam071 apply 1E-383 -> 1E-383 clam073 apply 1.000000000000000E-383 -> 1.000000000000000E-383 clam075 apply 1.000000000000001E-383 -> 1.000000000000001E-383 clam077 apply 0.100000000000000E-383 -> 1.00000000000000E-384 Subnormal clam079 apply 0.000000000000010E-383 -> 1.0E-397 Subnormal clam081 apply 0.00000000000001E-383 -> 1E-397 Subnormal clam083 apply 0.000000000000001E-383 -> 1E-398 Subnormal -- underflows clam090 apply 1e-398 -> #0000000000000001 Subnormal clam091 apply 1.9e-398 -> #0000000000000002 Subnormal Underflow Inexact Rounded clam092 apply 1.1e-398 -> #0000000000000001 Subnormal Underflow Inexact Rounded clam093 apply 1.00000000001e-398 -> #0000000000000001 Subnormal Underflow Inexact Rounded clam094 apply 1.00000000000001e-398 -> #0000000000000001 Subnormal Underflow Inexact Rounded clam095 apply 1.000000000000001e-398 -> #0000000000000001 Subnormal Underflow Inexact Rounded clam096 apply 0.1e-398 -> #0000000000000000 Subnormal Underflow Inexact Rounded clam097 apply 0.00000000001e-398 -> #0000000000000000 Subnormal Underflow Inexact Rounded clam098 apply 0.00000000000001e-398 -> #0000000000000000 Subnormal Underflow Inexact Rounded clam099 apply 0.000000000000001e-398 -> #0000000000000000 Subnormal Underflow Inexact Rounded -- Same again, negatives -- Nmax and similar clam122 apply -9.999999999999999E+384 -> -9.999999999999999E+384 clam124 apply -1.234567890123456E+384 -> -1.234567890123456E+384 -- fold-downs (more below) clam130 apply -1.23E+384 -> -1.230000000000000E+384 Clamped clam132 apply -1E+384 -> -1.000000000000000E+384 Clamped clam151 apply -12345 -> -12345 clam153 apply -1234 -> -1234 clam155 apply -123 -> -123 clam157 apply -12 -> -12 clam159 apply -1 -> -1 clam161 apply -1.23 -> -1.23 clam163 apply -123.45 -> -123.45 -- Nmin and below clam171 apply -1E-383 -> -1E-383 clam173 apply -1.000000000000000E-383 -> -1.000000000000000E-383 clam175 apply -1.000000000000001E-383 -> -1.000000000000001E-383 clam177 apply -0.100000000000000E-383 -> -1.00000000000000E-384 Subnormal clam179 apply -0.000000000000010E-383 -> -1.0E-397 Subnormal clam181 apply -0.00000000000001E-383 -> -1E-397 Subnormal clam183 apply -0.000000000000001E-383 -> -1E-398 Subnormal -- underflows clam189 apply -1e-398 -> #8000000000000001 Subnormal clam190 apply -1.0e-398 -> #8000000000000001 Subnormal Rounded clam191 apply -1.9e-398 -> #8000000000000002 Subnormal Underflow Inexact Rounded clam192 apply -1.1e-398 -> #8000000000000001 Subnormal Underflow Inexact Rounded clam193 apply -1.00000000001e-398 -> #8000000000000001 Subnormal Underflow Inexact Rounded clam194 apply -1.00000000000001e-398 -> #8000000000000001 Subnormal Underflow Inexact Rounded clam195 apply -1.000000000000001e-398 -> #8000000000000001 Subnormal Underflow Inexact Rounded clam196 apply -0.1e-398 -> #8000000000000000 Subnormal Underflow Inexact Rounded clam197 apply -0.00000000001e-398 -> #8000000000000000 Subnormal Underflow Inexact Rounded clam198 apply -0.00000000000001e-398 -> #8000000000000000 Subnormal Underflow Inexact Rounded clam199 apply -0.000000000000001e-398 -> #8000000000000000 Subnormal Underflow Inexact Rounded -- zeros clam401 apply 0E-500 -> 0E-398 Clamped clam402 apply 0E-400 -> 0E-398 Clamped clam403 apply 0E-398 -> 0E-398 clam404 apply 0.000000000000000E-383 -> 0E-398 clam405 apply 0E-2 -> 0.00 clam406 apply 0 -> 0 clam407 apply 0E+3 -> 0E+3 clam408 apply 0E+369 -> 0E+369 -- clamped zeros... clam410 apply 0E+370 -> 0E+369 Clamped clam411 apply 0E+384 -> 0E+369 Clamped clam412 apply 0E+400 -> 0E+369 Clamped clam413 apply 0E+500 -> 0E+369 Clamped -- negative zeros clam420 apply -0E-500 -> -0E-398 Clamped clam421 apply -0E-400 -> -0E-398 Clamped clam422 apply -0E-398 -> -0E-398 clam423 apply -0.000000000000000E-383 -> -0E-398 clam424 apply -0E-2 -> -0.00 clam425 apply -0 -> -0 clam426 apply -0E+3 -> -0E+3 clam427 apply -0E+369 -> -0E+369 -- clamped zeros... clam431 apply -0E+370 -> -0E+369 Clamped clam432 apply -0E+384 -> -0E+369 Clamped clam433 apply -0E+400 -> -0E+369 Clamped clam434 apply -0E+500 -> -0E+369 Clamped -- fold-down full sequence clam601 apply 1E+384 -> 1.000000000000000E+384 Clamped clam603 apply 1E+383 -> 1.00000000000000E+383 Clamped clam605 apply 1E+382 -> 1.0000000000000E+382 Clamped clam607 apply 1E+381 -> 1.000000000000E+381 Clamped clam609 apply 1E+380 -> 1.00000000000E+380 Clamped clam611 apply 1E+379 -> 1.0000000000E+379 Clamped clam613 apply 1E+378 -> 1.000000000E+378 Clamped clam615 apply 1E+377 -> 1.00000000E+377 Clamped clam617 apply 1E+376 -> 1.0000000E+376 Clamped clam619 apply 1E+375 -> 1.000000E+375 Clamped clam621 apply 1E+374 -> 1.00000E+374 Clamped clam623 apply 1E+373 -> 1.0000E+373 Clamped clam625 apply 1E+372 -> 1.000E+372 Clamped clam627 apply 1E+371 -> 1.00E+371 Clamped clam629 apply 1E+370 -> 1.0E+370 Clamped clam631 apply 1E+369 -> 1E+369 clam633 apply 1E+368 -> 1E+368 -- same with 9s clam641 apply 9E+384 -> 9.000000000000000E+384 Clamped clam643 apply 9E+383 -> 9.00000000000000E+383 Clamped clam645 apply 9E+382 -> 9.0000000000000E+382 Clamped clam647 apply 9E+381 -> 9.000000000000E+381 Clamped clam649 apply 9E+380 -> 9.00000000000E+380 Clamped clam651 apply 9E+379 -> 9.0000000000E+379 Clamped clam653 apply 9E+378 -> 9.000000000E+378 Clamped clam655 apply 9E+377 -> 9.00000000E+377 Clamped clam657 apply 9E+376 -> 9.0000000E+376 Clamped clam659 apply 9E+375 -> 9.000000E+375 Clamped clam661 apply 9E+374 -> 9.00000E+374 Clamped clam663 apply 9E+373 -> 9.0000E+373 Clamped clam665 apply 9E+372 -> 9.000E+372 Clamped clam667 apply 9E+371 -> 9.00E+371 Clamped clam669 apply 9E+370 -> 9.0E+370 Clamped clam671 apply 9E+369 -> 9E+369 clam673 apply 9E+368 -> 9E+368 -- example from documentation precision: 7 rounding: half_even maxExponent: +96 minExponent: -95 clamp: 0 clam700 apply 1.23E+96 -> 1.23E+96 clamp: 1 clam701 apply 1.23E+96 -> 1.230000E+96 Clamped --- NEW FILE: compare.decTest --- ------------------------------------------------------------------------ -- compare.decTest -- decimal comparison -- -- Copyright (c) IBM Corporation, 1981, 2003. All rights reserved. -- ------------------------------------------------------------------------ -- Please see the document "General Decimal Arithmetic Testcases" -- -- at http://www2.hursley.ibm.com/decimal for the description of -- -- these testcases. -- -- -- -- These testcases are experimental ('beta' versions), and they -- -- may contain errors. They are offered on an as-is basis. In -- -- particular, achieving the same results as the tests here is not -- -- a guarantee that an implementation complies with any Standard -- -- or specification. The tests are not exhaustive. -- -- -- -- Please send comments, suggestions, and corrections to the author: -- -- Mike Cowlishaw, IBM Fellow -- -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ version: 2.38 -- Note that we cannot assume add/subtract tests cover paths adequately, -- here, because the code might be quite different (comparison cannot -- overflow or underflow, so actual subtractions are not necesary). extended: 1 precision: 9 rounding: half_up maxExponent: 999 minexponent: -999 -- sanity checks comx001 compare -2 -2 -> 0 comx002 compare -2 -1 -> -1 comx003 compare -2 0 -> -1 comx004 compare -2 1 -> -1 comx005 compare -2 2 -> -1 comx006 compare -1 -2 -> 1 comx007 compare -1 -1 -> 0 comx008 compare -1 0 -> -1 comx009 compare -1 1 -> -1 comx010 compare -1 2 -> -1 comx011 compare 0 -2 -> 1 comx012 compare 0 -1 -> 1 comx013 compare 0 0 -> 0 comx014 compare 0 1 -> -1 comx015 compare 0 2 -> -1 comx016 compare 1 -2 -> 1 comx017 compare 1 -1 -> 1 comx018 compare 1 0 -> 1 comx019 compare 1 1 -> 0 comx020 compare 1 2 -> -1 comx021 compare 2 -2 -> 1 comx022 compare 2 -1 -> 1 comx023 compare 2 0 -> 1 comx025 compare 2 1 -> 1 comx026 compare 2 2 -> 0 comx031 compare -20 -20 -> 0 comx032 compare -20 -10 -> -1 comx033 compare -20 00 -> -1 comx034 compare -20 10 -> -1 comx035 compare -20 20 -> -1 comx036 compare -10 -20 -> 1 comx037 compare -10 -10 -> 0 comx038 compare -10 00 -> -1 comx039 compare -10 10 -> -1 comx040 compare -10 20 -> -1 comx041 compare 00 -20 -> 1 comx042 compare 00 -10 -> 1 comx043 compare 00 00 -> 0 comx044 compare 00 10 -> -1 comx045 compare 00 20 -> -1 comx046 compare 10 -20 -> 1 comx047 compare 10 -10 -> 1 comx048 compare 10 00 -> 1 comx049 compare 10 10 -> 0 comx050 compare 10 20 -> -1 comx051 compare 20 -20 -> 1 comx052 compare 20 -10 -> 1 comx053 compare 20 00 -> 1 comx055 compare 20 10 -> 1 comx056 compare 20 20 -> 0 comx061 compare -2.0 -2.0 -> 0 comx062 compare -2.0 -1.0 -> -1 comx063 compare -2.0 0.0 -> -1 comx064 compare -2.0 1.0 -> -1 comx065 compare -2.0 2.0 -> -1 comx066 compare -1.0 -2.0 -> 1 comx067 compare -1.0 -1.0 -> 0 comx068 compare -1.0 0.0 -> -1 comx069 compare -1.0 1.0 -> -1 comx070 compare -1.0 2.0 -> -1 comx071 compare 0.0 -2.0 -> 1 comx072 compare 0.0 -1.0 -> 1 comx073 compare 0.0 0.0 -> 0 comx074 compare 0.0 1.0 -> -1 comx075 compare 0.0 2.0 -> -1 comx076 compare 1.0 -2.0 -> 1 comx077 compare 1.0 -1.0 -> 1 comx078 compare 1.0 0.0 -> 1 comx079 compare 1.0 1.0 -> 0 comx080 compare 1.0 2.0 -> -1 comx081 compare 2.0 -2.0 -> 1 comx082 compare 2.0 -1.0 -> 1 comx083 compare 2.0 0.0 -> 1 comx085 compare 2.0 1.0 -> 1 comx086 compare 2.0 2.0 -> 0 -- now some cases which might overflow if subtract were used maxexponent: 999999999 minexponent: -999999999 comx090 compare 9.99999999E+999999999 9.99999999E+999999999 -> 0 comx091 compare -9.99999999E+999999999 9.99999999E+999999999 -> -1 comx092 compare 9.99999999E+999999999 -9.99999999E+999999999 -> 1 comx093 compare -9.99999999E+999999999 -9.99999999E+999999999 -> 0 -- some differing length/exponent cases comx100 compare 7.0 7.0 -> 0 comx101 compare 7.0 7 -> 0 comx102 compare 7 7.0 -> 0 comx103 compare 7E+0 7.0 -> 0 comx104 compare 70E-1 7.0 -> 0 comx105 compare 0.7E+1 7 -> 0 comx106 compare 70E-1 7 -> 0 comx107 compare 7.0 7E+0 -> 0 comx108 compare 7.0 70E-1 -> 0 comx109 compare 7 0.7E+1 -> 0 comx110 compare 7 70E-1 -> 0 comx120 compare 8.0 7.0 -> 1 comx121 compare 8.0 7 -> 1 comx122 compare 8 7.0 -> 1 comx123 compare 8E+0 7.0 -> 1 comx124 compare 80E-1 7.0 -> 1 comx125 compare 0.8E+1 7 -> 1 comx126 compare 80E-1 7 -> 1 comx127 compare 8.0 7E+0 -> 1 comx128 compare 8.0 70E-1 -> 1 comx129 compare 8 0.7E+1 -> 1 comx130 compare 8 70E-1 -> 1 comx140 compare 8.0 9.0 -> -1 comx141 compare 8.0 9 -> -1 comx142 compare 8 9.0 -> -1 comx143 compare 8E+0 9.0 -> -1 comx144 compare 80E-1 9.0 -> -1 comx145 compare 0.8E+1 9 -> -1 comx146 compare 80E-1 9 -> -1 comx147 compare 8.0 9E+0 -> -1 comx148 compare 8.0 90E-1 -> -1 comx149 compare 8 0.9E+1 -> -1 comx150 compare 8 90E-1 -> -1 -- and again, with sign changes -+ .. comx200 compare -7.0 7.0 -> -1 comx201 compare -7.0 7 -> -1 comx202 compare -7 7.0 -> -1 comx203 compare -7E+0 7.0 -> -1 comx204 compare -70E-1 7.0 -> -1 comx205 compare -0.7E+1 7 -> -1 comx206 compare -70E-1 7 -> -1 comx207 compare -7.0 7E+0 -> -1 comx208 compare -7.0 70E-1 -> -1 comx209 compare -7 0.7E+1 -> -1 comx210 compare -7 70E-1 -> -1 comx220 compare -8.0 7.0 -> -1 comx221 compare -8.0 7 -> -1 comx222 compare -8 7.0 -> -1 comx223 compare -8E+0 7.0 -> -1 comx224 compare -80E-1 7.0 -> -1 comx225 compare -0.8E+1 7 -> -1 comx226 compare -80E-1 7 -> -1 comx227 compare -8.0 7E+0 -> -1 comx228 compare -8.0 70E-1 -> -1 comx229 compare -8 0.7E+1 -> -1 comx230 compare -8 70E-1 -> -1 comx240 compare -8.0 9.0 -> -1 comx241 compare -8.0 9 -> -1 comx242 compare -8 9.0 -> -1 comx243 compare -8E+0 9.0 -> -1 comx244 compare -80E-1 9.0 -> -1 comx245 compare -0.8E+1 9 -> -1 comx246 compare -80E-1 9 -> -1 comx247 compare -8.0 9E+0 -> -1 comx248 compare -8.0 90E-1 -> -1 comx249 compare -8 0.9E+1 -> -1 comx250 compare -8 90E-1 -> -1 -- and again, with sign changes +- .. comx300 compare 7.0 -7.0 -> 1 comx301 compare 7.0 -7 -> 1 comx302 compare 7 -7.0 -> 1 comx303 compare 7E+0 -7.0 -> 1 comx304 compare 70E-1 -7.0 -> 1 comx305 compare .7E+1 -7 -> 1 comx306 compare 70E-1 -7 -> 1 comx307 compare 7.0 -7E+0 -> 1 comx308 compare 7.0 -70E-1 -> 1 comx309 compare 7 -.7E+1 -> 1 comx310 compare 7 -70E-1 -> 1 comx320 compare 8.0 -7.0 -> 1 comx321 compare 8.0 -7 -> 1 comx322 compare 8 -7.0 -> 1 comx323 compare 8E+0 -7.0 -> 1 comx324 compare 80E-1 -7.0 -> 1 comx325 compare .8E+1 -7 -> 1 comx326 compare 80E-1 -7 -> 1 comx327 compare 8.0 -7E+0 -> 1 comx328 compare 8.0 -70E-1 -> 1 comx329 compare 8 -.7E+1 -> 1 comx330 compare 8 -70E-1 -> 1 comx340 compare 8.0 -9.0 -> 1 comx341 compare 8.0 -9 -> 1 comx342 compare 8 -9.0 -> 1 comx343 compare 8E+0 -9.0 -> 1 comx344 compare 80E-1 -9.0 -> 1 comx345 compare .8E+1 -9 -> 1 comx346 compare 80E-1 -9 -> 1 comx347 compare 8.0 -9E+0 -> 1 comx348 compare 8.0 -90E-1 -> 1 comx349 compare 8 -.9E+1 -> 1 comx350 compare 8 -90E-1 -> 1 -- and again, with sign changes -- .. comx400 compare -7.0 -7.0 -> 0 comx401 compare -7.0 -7 -> 0 comx402 compare -7 -7.0 -> 0 comx403 compare -7E+0 -7.0 -> 0 comx404 compare -70E-1 -7.0 -> 0 comx405 compare -.7E+1 -7 -> 0 comx406 compare -70E-1 -7 -> 0 comx407 compare -7.0 -7E+0 -> 0 comx408 compare -7.0 -70E-1 -> 0 comx409 compare -7 -.7E+1 -> 0 comx410 compare -7 -70E-1 -> 0 comx420 compare -8.0 -7.0 -> -1 comx421 compare -8.0 -7 -> -1 comx422 compare -8 -7.0 -> -1 comx423 compare -8E+0 -7.0 -> -1 comx424 compare -80E-1 -7.0 -> -1 comx425 compare -.8E+1 -7 -> -1 comx426 compare -80E-1 -7 -> -1 comx427 compare -8.0 -7E+0 -> -1 comx428 compare -8.0 -70E-1 -> -1 comx429 compare -8 -.7E+1 -> -1 comx430 compare -8 -70E-1 -> -1 comx440 compare -8.0 -9.0 -> 1 comx441 compare -8.0 -9 -> 1 comx442 compare -8 -9.0 -> 1 comx443 compare -8E+0 -9.0 -> 1 comx444 compare -80E-1 -9.0 -> 1 comx445 compare -.8E+1 -9 -> 1 comx446 compare -80E-1 -9 -> 1 comx447 compare -8.0 -9E+0 -> 1 comx448 compare -8.0 -90E-1 -> 1 comx449 compare -8 -.9E+1 -> 1 comx450 compare -8 -90E-1 -> 1 -- testcases that subtract to lots of zeros at boundaries [pgr] precision: 40 comx470 compare 123.4560000000000000E789 123.456E789 -> 0 comx471 compare 123.456000000000000E-89 123.456E-89 -> 0 comx472 compare 123.45600000000000E789 123.456E789 -> 0 comx473 compare 123.4560000000000E-89 123.456E-89 -> 0 comx474 compare 123.456000000000E789 123.456E789 -> 0 comx475 compare 123.45600000000E-89 123.456E-89 -> 0 comx476 compare 123.4560000000E789 123.456E789 -> 0 comx477 compare 123.456000000E-89 123.456E-89 -> 0 comx478 compare 123.45600000E789 123.456E789 -> 0 comx479 compare 123.4560000E-89 123.456E-89 -> 0 comx480 compare 123.456000E789 123.456E789 -> 0 comx481 compare 123.45600E-89 123.456E-89 -> 0 comx482 compare 123.4560E789 123.456E789 -> 0 comx483 compare 123.456E-89 123.456E-89 -> 0 comx484 compare 123.456E-89 123.4560000000000000E-89 -> 0 comx485 compare 123.456E789 123.456000000000000E789 -> 0 comx486 compare 123.456E-89 123.45600000000000E-89 -> 0 comx487 compare 123.456E789 123.4560000000000E789 -> 0 comx488 compare 123.456E-89 123.456000000000E-89 -> 0 comx489 compare 123.456E789 123.45600000000E789 -> 0 comx490 compare 123.456E-89 123.4560000000E-89 -> 0 comx491 compare 123.456E789 123.456000000E789 -> 0 comx492 compare 123.456E-89 123.45600000E-89 -> 0 comx493 compare 123.456E789 123.4560000E789 -> 0 comx494 compare 123.456E-89 123.456000E-89 -> 0 comx495 compare 123.456E789 123.45600E789 -> 0 comx496 compare 123.456E-89 123.4560E-89 -> 0 comx497 compare 123.456E789 123.456E789 -> 0 -- wide-ranging, around precision; signs equal precision: 9 comx500 compare 1 1E-15 -> 1 comx501 compare 1 1E-14 -> 1 comx502 compare 1 1E-13 -> 1 comx503 compare 1 1E-12 -> 1 comx504 compare 1 1E-11 -> 1 comx505 compare 1 1E-10 -> 1 comx506 compare 1 1E-9 -> 1 comx507 compare 1 1E-8 -> 1 comx508 compare 1 1E-7 -> 1 comx509 compare 1 1E-6 -> 1 comx510 compare 1 1E-5 -> 1 comx511 compare 1 1E-4 -> 1 comx512 compare 1 1E-3 -> 1 comx513 compare 1 1E-2 -> 1 comx514 compare 1 1E-1 -> 1 comx515 compare 1 1E-0 -> 0 comx516 compare 1 1E+1 -> -1 comx517 compare 1 1E+2 -> -1 comx518 compare 1 1E+3 -> -1 comx519 compare 1 1E+4 -> -1 comx521 compare 1 1E+5 -> -1 comx522 compare 1 1E+6 -> -1 comx523 compare 1 1E+7 -> -1 comx524 compare 1 1E+8 -> -1 comx525 compare 1 1E+9 -> -1 comx526 compare 1 1E+10 -> -1 comx527 compare 1 1E+11 -> -1 comx528 compare 1 1E+12 -> -1 comx529 compare 1 1E+13 -> -1 comx530 compare 1 1E+14 -> -1 comx531 compare 1 1E+15 -> -1 -- LR swap comx540 compare 1E-15 1 -> -1 comx541 compare 1E-14 1 -> -1 comx542 compare 1E-13 1 -> -1 comx543 compare 1E-12 1 -> -1 comx544 compare 1E-11 1 -> -1 comx545 compare 1E-10 1 -> -1 comx546 compare 1E-9 1 -> -1 comx547 compare 1E-8 1 -> -1 comx548 compare 1E-7 1 -> -1 comx549 compare 1E-6 1 -> -1 comx550 compare 1E-5 1 -> -1 comx551 compare 1E-4 1 -> -1 comx552 compare 1E-3 1 -> -1 comx553 compare 1E-2 1 -> -1 comx554 compare 1E-1 1 -> -1 comx555 compare 1E-0 1 -> 0 comx556 compare 1E+1 1 -> 1 comx557 compare 1E+2 1 -> 1 comx558 compare 1E+3 1 -> 1 comx559 compare 1E+4 1 -> 1 comx561 compare 1E+5 1 -> 1 comx562 compare 1E+6 1 -> 1 comx563 compare 1E+7 1 -> 1 comx564 compare 1E+8 1 -> 1 comx565 compare 1E+9 1 -> 1 comx566 compare 1E+10 1 -> 1 comx567 compare 1E+11 1 -> 1 comx568 compare 1E+12 1 -> 1 comx569 compare 1E+13 1 -> 1 comx570 compare 1E+14 1 -> 1 comx571 compare 1E+15 1 -> 1 -- similar with an useful coefficient, one side only comx580 compare 0.000000987654321 1E-15 -> 1 comx581 compare 0.000000987654321 1E-14 -> 1 comx582 compare 0.000000987654321 1E-13 -> 1 comx583 compare 0.000000987654321 1E-12 -> 1 comx584 compare 0.000000987654321 1E-11 -> 1 comx585 compare 0.000000987654321 1E-10 -> 1 comx586 compare 0.000000987654321 1E-9 -> 1 comx587 compare 0.000000987654321 1E-8 -> 1 comx588 compare 0.000000987654321 1E-7 -> 1 comx589 compare 0.000000987654321 1E-6 -> -1 comx590 compare 0.000000987654321 1E-5 -> -1 comx591 compare 0.000000987654321 1E-4 -> -1 comx592 compare 0.000000987654321 1E-3 -> -1 comx593 compare 0.000000987654321 1E-2 -> -1 comx594 compare 0.000000987654321 1E-1 -> -1 comx595 compare 0.000000987654321 1E-0 -> -1 comx596 compare 0.000000987654321 1E+1 -> -1 comx597 compare 0.000000987654321 1E+2 -> -1 comx598 compare 0.000000987654321 1E+3 -> -1 comx599 compare 0.000000987654321 1E+4 -> -1 -- check some unit-y traps precision: 20 comx600 compare 12 12.2345 -> -1 comx601 compare 12.0 12.2345 -> -1 comx602 compare 12.00 12.2345 -> -1 comx603 compare 12.000 12.2345 -> -1 comx604 compare 12.0000 12.2345 -> -1 comx605 compare 12.00000 12.2345 -> -1 comx606 compare 12.000000 12.2345 -> -1 comx607 compare 12.0000000 12.2345 -> -1 comx608 compare 12.00000000 12.2345 -> -1 comx609 compare 12.000000000 12.2345 -> -1 comx610 compare 12.1234 12 -> 1 comx611 compare 12.1234 12.0 -> 1 comx612 compare 12.1234 12.00 -> 1 comx613 compare 12.1234 12.000 -> 1 comx614 compare 12.1234 12.0000 -> 1 comx615 compare 12.1234 12.00000 -> 1 comx616 compare 12.1234 12.000000 -> 1 comx617 compare 12.1234 12.0000000 -> 1 comx618 compare 12.1234 12.00000000 -> 1 comx619 compare 12.1234 12.000000000 -> 1 comx620 compare -12 -12.2345 -> 1 comx621 compare -12.0 -12.2345 -> 1 comx622 compare -12.00 -12.2345 -> 1 comx623 compare -12.000 -12.2345 -> 1 comx624 compare -12.0000 -12.2345 -> 1 comx625 compare -12.00000 -12.2345 -> 1 comx626 compare -12.000000 -12.2345 -> 1 comx627 compare -12.0000000 -12.2345 -> 1 comx628 compare -12.00000000 -12.2345 -> 1 comx629 compare -12.000000000 -12.2345 -> 1 comx630 compare -12.1234 -12 -> -1 comx631 compare -12.1234 -12.0 -> -1 comx632 compare -12.1234 -12.00 -> -1 comx633 compare -12.1234 -12.000 -> -1 comx634 compare -12.1234 -12.0000 -> -1 comx635 compare -12.1234 -12.00000 -> -1 comx636 compare -12.1234 -12.000000 -> -1 comx637 compare -12.1234 -12.0000000 -> -1 comx638 compare -12.1234 -12.00000000 -> -1 comx639 compare -12.1234 -12.000000000 -> -1 precision: 9 -- extended zeros comx640 compare 0 0 -> 0 comx641 compare 0 -0 -> 0 comx642 compare 0 -0.0 -> 0 comx643 compare 0 0.0 -> 0 comx644 compare -0 0 -> 0 comx645 compare -0 -0 -> 0 comx646 compare -0 -0.0 -> 0 comx647 compare -0 0.0 -> 0 comx648 compare 0.0 0 -> 0 comx649 compare 0.0 -0 -> 0 comx650 compare 0.0 -0.0 -> 0 comx651 compare 0.0 0.0 -> 0 comx652 compare -0.0 0 -> 0 comx653 compare -0.0 -0 -> 0 comx654 compare -0.0 -0.0 -> 0 comx655 compare -0.0 0.0 -> 0 comx656 compare -0E1 0.0 -> 0 comx657 compare -0E2 0.0 -> 0 comx658 compare 0E1 0.0 -> 0 comx659 compare 0E2 0.0 -> 0 comx660 compare -0E1 0 -> 0 comx661 compare -0E2 0 -> 0 comx662 compare 0E1 0 -> 0 comx663 compare 0E2 0 -> 0 comx664 compare -0E1 -0E1 -> 0 comx665 compare -0E2 -0E1 -> 0 comx666 compare 0E1 -0E1 -> 0 comx667 compare 0E2 -0E1 -> 0 comx668 compare -0E1 -0E2 -> 0 comx669 compare -0E2 -0E2 -> 0 comx670 compare 0E1 -0E2 -> 0 comx671 compare 0E2 -0E2 -> 0 comx672 compare -0E1 0E1 -> 0 comx673 compare -0E2 0E1 -> 0 comx674 compare 0E1 0E1 -> 0 comx675 compare 0E2 0E1 -> 0 comx676 compare -0E1 0E2 -> 0 comx677 compare -0E2 0E2 -> 0 comx678 compare 0E1 0E2 -> 0 comx679 compare 0E2 0E2 -> 0 -- trailing zeros; unit-y precision: 20 comx680 compare 12 12 -> 0 comx681 compare 12 12.0 -> 0 comx682 compare 12 12.00 -> 0 comx683 compare 12 12.000 -> 0 comx684 compare 12 12.0000 -> 0 comx685 compare 12 12.00000 -> 0 comx686 compare 12 12.000000 -> 0 comx687 compare 12 12.0000000 -> 0 comx688 compare 12 12.00000000 -> 0 comx689 compare 12 12.000000000 -> 0 comx690 compare 12 12 -> 0 comx691 compare 12.0 12 -> 0 comx692 compare 12.00 12 -> 0 comx693 compare 12.000 12 -> 0 comx694 compare 12.0000 12 -> 0 comx695 compare 12.00000 12 -> 0 comx696 compare 12.000000 12 -> 0 comx697 compare 12.0000000 12 -> 0 comx698 compare 12.00000000 12 -> 0 comx699 compare 12.000000000 12 -> 0 -- long operand checks maxexponent: 999 minexponent: -999 precision: 9 comx701 compare 12345678000 1 -> 1 comx702 compare 1 12345678000 -> -1 comx703 compare 1234567800 1 -> 1 comx704 compare 1 1234567800 -> -1 comx705 compare 1234567890 1 -> 1 comx706 compare 1 1234567890 -> -1 comx707 compare 1234567891 1 -> 1 comx708 compare 1 1234567891 -> -1 comx709 compare 12345678901 1 -> 1 comx710 compare 1 12345678901 -> -1 comx711 compare 1234567896 1 -> 1 comx712 compare 1 1234567896 -> -1 comx713 compare -1234567891 1 -> -1 comx714 compare 1 -1234567891 -> 1 comx715 compare -12345678901 1 -> -1 comx716 compare 1 -12345678901 -> 1 comx717 compare -1234567896 1 -> -1 comx718 compare 1 -1234567896 -> 1 precision: 15 -- same with plenty of precision comx721 compare 12345678000 1 -> 1 comx722 compare 1 12345678000 -> -1 comx723 compare 1234567800 1 -> 1 comx724 compare 1 1234567800 -> -1 comx725 compare 1234567890 1 -> 1 comx726 compare 1 1234567890 -> -1 comx727 compare 1234567891 1 -> 1 comx728 compare 1 1234567891 -> -1 comx729 compare 12345678901 1 -> 1 comx730 compare 1 12345678901 -> -1 comx731 compare 1234567896 1 -> 1 comx732 compare 1 1234567896 -> -1 -- residue cases precision: 5 comx740 compare 1 0.9999999 -> 1 comx741 compare 1 0.999999 -> 1 comx742 compare 1 0.99999 -> 1 comx743 compare 1 1.0000 -> 0 comx744 compare 1 1.00001 -> -1 comx745 compare 1 1.000001 -> -1 comx746 compare 1 1.0000001 -> -1 comx750 compare 0.9999999 1 -> -1 comx751 compare 0.999999 1 -> -1 comx752 compare 0.99999 1 -> -1 comx753 compare 1.0000 1 -> 0 comx754 compare 1.00001 1 -> 1 comx755 compare 1.000001 1 -> 1 comx756 compare 1.0000001 1 -> 1 -- a selection of longies comx760 compare -36852134.84194296250843579428931 -5830629.8347085025808756560357940 -> -1 comx761 compare -36852134.84194296250843579428931 -36852134.84194296250843579428931 -> 0 comx762 compare -36852134.94194296250843579428931 -36852134.84194296250843579428931 -> -1 comx763 compare -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1 -- precisions above or below the difference should have no effect precision: 11 comx764 compare -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1 precision: 10 comx765 compare -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1 precision: 9 comx766 compare -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1 precision: 8 comx767 compare -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1 precision: 7 comx768 compare -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1 precision: 6 comx769 compare -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1 precision: 5 comx770 compare -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1 precision: 4 comx771 compare -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1 precision: 3 comx772 compare -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1 precision: 2 comx773 compare -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1 precision: 1 comx774 compare -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1 -- Specials precision: 9 comx780 compare Inf -Inf -> 1 comx781 compare Inf -1000 -> 1 comx782 compare Inf -1 -> 1 comx783 compare Inf -0 -> 1 comx784 compare Inf 0 -> 1 comx785 compare Inf 1 -> 1 comx786 compare Inf 1000 -> 1 comx787 compare Inf Inf -> 0 comx788 compare -1000 Inf -> -1 comx789 compare -Inf Inf -> -1 comx790 compare -1 Inf -> -1 comx791 compare -0 Inf -> -1 comx792 compare 0 Inf -> -1 comx793 compare 1 Inf -> -1 comx794 compare 1000 Inf -> -1 comx795 compare Inf Inf -> 0 comx800 compare -Inf -Inf -> 0 comx801 compare -Inf -1000 -> -1 comx802 compare -Inf -1 -> -1 comx803 compare -Inf -0 -> -1 comx804 compare -Inf 0 -> -1 comx805 compare -Inf 1 -> -1 comx806 compare -Inf 1000 -> -1 comx807 compare -Inf Inf -> -1 comx808 compare -Inf -Inf -> 0 comx809 compare -1000 -Inf -> 1 comx810 compare -1 -Inf -> 1 comx811 compare -0 -Inf -> 1 comx812 compare 0 -Inf -> 1 comx813 compare 1 -Inf -> 1 comx814 compare 1000 -Inf -> 1 comx815 compare Inf -Inf -> 1 comx821 compare NaN -Inf -> NaN comx822 compare NaN -1000 -> NaN comx823 compare NaN -1 -> NaN comx824 compare NaN -0 -> NaN comx825 compare NaN 0 -> NaN comx826 compare NaN 1 -> NaN comx827 compare NaN 1000 -> NaN comx828 compare NaN Inf -> NaN comx829 compare NaN NaN -> NaN comx830 compare -Inf NaN -> NaN comx831 compare -1000 NaN -> NaN comx832 compare -1 NaN -> NaN comx833 compare -0 NaN -> NaN comx834 compare 0 NaN -> NaN comx835 compare 1 NaN -> NaN comx836 compare 1000 NaN -> NaN comx837 compare Inf NaN -> NaN comx838 compare -NaN -NaN -> -NaN comx839 compare +NaN -NaN -> NaN comx840 compare -NaN +NaN -> -NaN comx841 compare sNaN -Inf -> NaN Invalid_operation comx842 compare sNaN -1000 -> NaN Invalid_operation comx843 compare sNaN -1 -> NaN Invalid_operation comx844 compare sNaN -0 -> NaN Invalid_operation comx845 compare sNaN 0 -> NaN Invalid_operation comx846 compare sNaN 1 -> NaN Invalid_operation comx847 compare sNaN 1000 -> NaN Invalid_operation comx848 compare sNaN NaN -> NaN Invalid_operation comx849 compare sNaN sNaN -> NaN Invalid_operation comx850 compare NaN sNaN -> NaN Invalid_operation comx851 compare -Inf sNaN -> NaN Invalid_operation comx852 compare -1000 sNaN -> NaN Invalid_operation comx853 compare -1 sNaN -> NaN Invalid_operation comx854 compare -0 sNaN -> NaN Invalid_operation comx855 compare 0 sNaN -> NaN Invalid_operation comx856 compare 1 sNaN -> NaN Invalid_operation comx857 compare 1000 sNaN -> NaN Invalid_operation comx858 compare Inf sNaN -> NaN Invalid_operation comx859 compare NaN sNaN -> NaN Invalid_operation -- propagating NaNs comx860 compare NaN9 -Inf -> NaN9 comx861 compare NaN8 999 -> NaN8 comx862 compare NaN77 Inf -> NaN77 comx863 compare -NaN67 NaN5 -> -NaN67 comx864 compare -Inf -NaN4 -> -NaN4 comx865 compare -999 -NaN33 -> -NaN33 comx866 compare Inf NaN2 -> NaN2 comx867 compare -NaN41 -NaN42 -> -NaN41 comx868 compare +NaN41 -NaN42 -> NaN41 comx869 compare -NaN41 +NaN42 -> -NaN41 comx870 compare +NaN41 +NaN42 -> NaN41 comx871 compare -sNaN99 -Inf -> -NaN99 Invalid_operation comx872 compare sNaN98 -11 -> NaN98 Invalid_operation comx873 compare sNaN97 NaN -> NaN97 Invalid_operation comx874 compare sNaN16 sNaN94 -> NaN16 Invalid_operation comx875 compare NaN85 sNaN83 -> NaN83 Invalid_operation comx876 compare -Inf sNaN92 -> NaN92 Invalid_operation comx877 compare 088 sNaN81 -> NaN81 Invalid_operation comx878 compare Inf sNaN90 -> NaN90 Invalid_operation comx879 compare NaN -sNaN89 -> -NaN89 Invalid_operation -- overflow and underflow tests .. subnormal results now allowed maxExponent: 999999999 minexponent: -999999999 comx880 compare +1.23456789012345E-0 9E+999999999 -> -1 comx881 compare 9E+999999999 +1.23456789012345E-0 -> 1 comx882 compare +0.100 9E-999999999 -> 1 comx883 compare 9E-999999999 +0.100 -> -1 comx885 compare -1.23456789012345E-0 9E+999999999 -> -1 comx886 compare 9E+999999999 -1.23456789012345E-0 -> 1 comx887 compare -0.100 9E-999999999 -> -1 comx888 compare 9E-999999999 -0.100 -> 1 comx889 compare 1e-599999999 1e-400000001 -> -1 comx890 compare 1e-599999999 1e-400000000 -> -1 comx891 compare 1e-600000000 1e-400000000 -> -1 comx892 compare 9e-999999998 0.01 -> -1 comx893 compare 9e-999999998 0.1 -> -1 comx894 compare 0.01 9e-999999998 -> 1 comx895 compare 1e599999999 1e400000001 -> 1 comx896 compare 1e599999999 1e400000000 -> 1 comx897 compare 1e600000000 1e400000000 -> 1 comx898 compare 9e999999998 100 -> 1 comx899 compare 9e999999998 10 -> 1 comx900 compare 100 9e999999998 -> -1 -- signs comx901 compare 1e+777777777 1e+411111111 -> 1 comx902 compare 1e+777777777 -1e+411111111 -> 1 comx903 compare -1e+777777777 1e+411111111 -> -1 comx904 compare -1e+777777777 -1e+411111111 -> -1 comx905 compare 1e-777777777 1e-411111111 -> -1 comx906 compare 1e-777777777 -1e-411111111 -> 1 comx907 compare -1e-777777777 1e-411111111 -> -1 comx908 compare -1e-777777777 -1e-411111111 -> 1 -- Null tests comx990 compare 10 # -> NaN Invalid_operation comx991 compare # 10 -> NaN Invalid_operation --- NEW FILE: decimal64.decTest --- ------------------------------------------------------------------------ -- decimal64.decTest -- decimal eight-byte format testcases -- -- Copyright (c) IBM Corporation, 2000, 2003. All rights reserved. -- ------------------------------------------------------------------------ -- Please see the document "General Decimal Arithmetic Testcases" -- -- at http://www2.hursley.ibm.com/decimal for the description of -- -- these testcases. -- -- -- -- These testcases are experimental ('beta' versions), and they -- -- may contain errors. They are offered on an as-is basis. In -- -- particular, achieving the same results as the tests here is not -- -- a guarantee that an implementation complies with any Standard -- -- or specification. The tests are not exhaustive. -- -- -- -- Please send comments, suggestions, and corrections to the author: -- -- Mike Cowlishaw, IBM Fellow -- -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ version: 2.28 -- This set of tests is for the eight-byte concrete representation. -- Its characteristics are: -- -- 1 bit sign -- 5 bits combination field -- 8 bits exponent continuation -- 50 bits coefficient continuation -- -- Total exponent length 10 bits -- Total coefficient length 54 bits (16 digits) -- -- Elimit = 767 (maximum encoded exponent) -- Emax = 384 (largest exponent value) -- Emin = -383 (smallest exponent value) -- bias = 398 (subtracted from encoded exponent) = -Etiny extended: 1 precision: 16 rounding: half_up maxExponent: 384 minExponent: -383 -- General testcases -- (mostly derived from the Strawman 4 document and examples) dece001 apply #A2300000000003D0 -> -7.50 dece002 apply -7.50 -> #A2300000000003D0 -- Normality dece010 apply 1234567890123456 -> #263934b9c1e28e56 dece011 apply 1234567890123456.0 -> #263934b9c1e28e56 Rounded dece012 apply 1234567890123456.1 -> #263934b9c1e28e56 Rounded Inexact dece013 apply -1234567890123456 -> #a63934b9c1e28e56 dece014 apply -1234567890123456.0 -> #a63934b9c1e28e56 Rounded dece015 apply -1234567890123456.1 -> #a63934b9c1e28e56 Rounded Inexact -- Nmax and similar dece022 apply 9.999999999999999E+384 -> #77fcff3fcff3fcff dece023 apply #77fcff3fcff3fcff -> 9.999999999999999E+384 dece024 apply 1.234567890123456E+384 -> #47fd34b9c1e28e56 dece025 apply #47fd34b9c1e28e56 -> 1.234567890123456E+384 -- fold-downs (more below) dece030 apply 1.23E+384 -> #47fd300000000000 Clamped dece031 apply #47fd300000000000 -> 1.230000000000000E+384 dece032 apply 1E+384 -> #47fc000000000000 Clamped dece033 apply #47fc000000000000 -> 1.000000000000000E+384 -- overflows maxExponent: 999 -- set high so conversion causes the overflow minExponent: -999 dece040 apply 10E+384 -> #7800000000000000 Overflow Rounded Inexact dece041 apply 1.000000000000000E+385 -> #7800000000000000 Overflow Rounded Inexact maxExponent: 384 minExponent: -383 dece051 apply 12345 -> #22380000000049c5 dece052 apply #22380000000049c5 -> 12345 dece053 apply 1234 -> #2238000000000534 dece054 apply #2238000000000534 -> 1234 dece055 apply 123 -> #22380000000000a3 dece056 apply #22380000000000a3 -> 123 dece057 apply 12 -> #2238000000000012 dece058 apply #2238000000000012 -> 12 dece059 apply 1 -> #2238000000000001 dece060 apply #2238000000000001 -> 1 dece061 apply 1.23 -> #22300000000000a3 dece062 apply #22300000000000a3 -> 1.23 dece063 apply 123.45 -> #22300000000049c5 dece064 apply #22300000000049c5 -> 123.45 -- Nmin and below dece071 apply 1E-383 -> #003c000000000001 dece072 apply #003c000000000001 -> 1E-383 dece073 apply 1.000000000000000E-383 -> #0400000000000000 dece074 apply #0400000000000000 -> 1.000000000000000E-383 dece075 apply 1.000000000000001E-383 -> #0400000000000001 dece076 apply #0400000000000001 -> 1.000000000000001E-383 dece077 apply 0.100000000000000E-383 -> #0000800000000000 Subnormal dece078 apply #0000800000000000 -> 1.00000000000000E-384 Subnormal dece079 apply 0.000000000000010E-383 -> #0000000000000010 Subnormal dece080 apply #0000000000000010 -> 1.0E-397 Subnormal dece081 apply 0.00000000000001E-383 -> #0004000000000001 Subnormal dece082 apply #0004000000000001 -> 1E-397 Subnormal dece083 apply 0.000000000000001E-383 -> #0000000000000001 Subnormal dece084 apply #0000000000000001 -> 1E-398 Subnormal -- underflows dece090 apply 1e-398 -> #0000000000000001 Subnormal dece091 apply 1.9e-398 -> #0000000000000002 Subnormal Underflow Inexact Rounded dece092 apply 1.1e-398 -> #0000000000000001 Subnormal Underflow Inexact Rounded dece093 apply 1.00000000001e-398 -> #0000000000000001 Subnormal Underflow Inexact Rounded dece094 apply 1.00000000000001e-398 -> #0000000000000001 Subnormal Underflow Inexact Rounded dece095 apply 1.000000000000001e-398 -> #0000000000000001 Subnormal Underflow Inexact Rounded dece096 apply 0.1e-398 -> #0000000000000000 Subnormal Underflow Inexact Rounded dece097 apply 0.00000000001e-398 -> #0000000000000000 Subnormal Underflow Inexact Rounded dece098 apply 0.00000000000001e-398 -> #0000000000000000 Subnormal Underflow Inexact Rounded dece099 apply 0.000000000000001e-398 -> #0000000000000000 Subnormal Underflow Inexact Rounded -- Same again, negatives -- Nmax and similar dece122 apply -9.999999999999999E+384 -> #f7fcff3fcff3fcff dece123 apply #f7fcff3fcff3fcff -> -9.999999999999999E+384 dece124 apply -1.234567890123456E+384 -> #c7fd34b9c1e28e56 dece125 apply #c7fd34b9c1e28e56 -> -1.234567890123456E+384 -- fold-downs (more below) dece130 apply -1.23E+384 -> #c7fd300000000000 Clamped dece131 apply #c7fd300000000000 -> -1.230000000000000E+384 dece132 apply -1E+384 -> #c7fc000000000000 Clamped dece133 apply #c7fc000000000000 -> -1.000000000000000E+384 -- overflows maxExponent: 999 -- set high so conversion causes the overflow minExponent: -999 dece140 apply -10E+384 -> #f800000000000000 Overflow Rounded Inexact dece141 apply -1.000000000000000E+385 -> #f800000000000000 Overflow Rounded Inexact maxExponent: 384 minExponent: -383 dece151 apply -12345 -> #a2380000000049c5 dece152 apply #a2380000000049c5 -> -12345 dece153 apply -1234 -> #a238000000000534 dece154 apply #a238000000000534 -> -1234 dece155 apply -123 -> #a2380000000000a3 dece156 apply #a2380000000000a3 -> -123 dece157 apply -12 -> #a238000000000012 dece158 apply #a238000000000012 -> -12 dece159 apply -1 -> #a238000000000001 dece160 apply #a238000000000001 -> -1 dece161 apply -1.23 -> #a2300000000000a3 dece162 apply #a2300000000000a3 -> -1.23 dece163 apply -123.45 -> #a2300000000049c5 dece164 apply #a2300000000049c5 -> -123.45 -- Nmin and below dece171 apply -1E-383 -> #803c000000000001 dece172 apply #803c000000000001 -> -1E-383 dece173 apply -1.000000000000000E-383 -> #8400000000000000 dece174 apply #8400000000000000 -> -1.000000000000000E-383 dece175 apply -1.000000000000001E-383 -> #8400000000000001 dece176 apply #8400000000000001 -> -1.000000000000001E-383 dece177 apply -0.100000000000000E-383 -> #8000800000000000 Subnormal dece178 apply #8000800000000000 -> -1.00000000000000E-384 Subnormal dece179 apply -0.000000000000010E-383 -> #8000000000000010 Subnormal dece180 apply #8000000000000010 -> -1.0E-397 Subnormal dece181 apply -0.00000000000001E-383 -> #8004000000000001 Subnormal dece182 apply #8004000000000001 -> -1E-397 Subnormal dece183 apply -0.000000000000001E-383 -> #8000000000000001 Subnormal dece184 apply #8000000000000001 -> -1E-398 Subnormal -- underflows dece189 apply -1e-398 -> #8000000000000001 Subnormal dece190 apply -1.0e-398 -> #8000000000000001 Subnormal Rounded dece191 apply -1.9e-398 -> #8000000000000002 Subnormal Underflow Inexact Rounded dece192 apply -1.1e-398 -> #8000000000000001 Subnormal Underflow Inexact Rounded dece193 apply -1.00000000001e-398 -> #8000000000000001 Subnormal Underflow Inexact Rounded dece194 apply -1.00000000000001e-398 -> #8000000000000001 Subnormal Underflow Inexact Rounded dece195 apply -1.000000000000001e-398 -> #8000000000000001 Subnormal Underflow Inexact Rounded dece196 apply -0.1e-398 -> #8000000000000000 Subnormal Underflow Inexact Rounded dece197 apply -0.00000000001e-398 -> #8000000000000000 Subnormal Underflow Inexact Rounded dece198 apply -0.00000000000001e-398 -> #8000000000000000 Subnormal Underflow Inexact Rounded dece199 apply -0.000000000000001e-398 -> #8000000000000000 Subnormal Underflow Inexact Rounded -- zeros dece401 apply 0E-500 -> #0000000000000000 Clamped dece402 apply 0E-400 -> #0000000000000000 Clamped dece403 apply 0E-398 -> #0000000000000000 dece404 apply #0000000000000000 -> 0E-398 dece405 apply 0.000000000000000E-383 -> #0000000000000000 dece406 apply #0000000000000000 -> 0E-398 dece407 apply 0E-2 -> #2230000000000000 dece408 apply #2230000000000000 -> 0.00 dece409 apply 0 -> #2238000000000000 dece410 apply #2238000000000000 -> 0 dece411 apply 0E+3 -> #2244000000000000 dece412 apply #2244000000000000 -> 0E+3 dece413 apply 0E+369 -> #43fc000000000000 dece414 apply #43fc000000000000 -> 0E+369 -- clamped zeros... dece415 apply 0E+370 -> #43fc000000000000 Clamped dece416 apply #43fc000000000000 -> 0E+369 dece417 apply 0E+384 -> #43fc000000000000 Clamped dece418 apply #43fc000000000000 -> 0E+369 dece419 apply 0E+400 -> #43fc000000000000 Clamped dece420 apply #43fc000000000000 -> 0E+369 dece421 apply 0E+500 -> #43fc000000000000 Clamped dece422 apply #43fc000000000000 -> 0E+369 -- negative zeros dece431 apply -0E-400 -> #8000000000000000 Clamped dece432 apply -0E-400 -> #8000000000000000 Clamped dece433 apply -0E-398 -> #8000000000000000 dece434 apply #8000000000000000 -> -0E-398 dece435 apply -0.000000000000000E-383 -> #8000000000000000 dece436 apply #8000000000000000 -> -0E-398 dece437 apply -0E-2 -> #a230000000000000 dece438 apply #a230000000000000 -> -0.00 dece439 apply -0 -> #a238000000000000 dece440 apply #a238000000000000 -> -0 dece441 apply -0E+3 -> #a244000000000000 dece442 apply #a244000000000000 -> -0E+3 dece443 apply -0E+369 -> #c3fc000000000000 dece444 apply #c3fc000000000000 -> -0E+369 -- clamped zeros... dece445 apply -0E+370 -> #c3fc000000000000 Clamped dece446 apply #c3fc000000000000 -> -0E+369 dece447 apply -0E+384 -> #c3fc000000000000 Clamped dece448 apply #c3fc000000000000 -> -0E+369 dece449 apply -0E+400 -> #c3fc000000000000 Clamped dece450 apply #c3fc000000000000 -> -0E+369 dece451 apply -0E+500 -> #c3fc000000000000 Clamped dece452 apply #c3fc000000000000 -> -0E+369 -- Specials dece501 apply #7878787878787878 -> #7800000000000000 dece502 apply #7800000000000000 -> Infinity dece503 apply #7979797979797979 -> #7800000000000000 dece504 apply #7900000000000000 -> Infinity dece505 apply #7a7a7a7a7a7a7a7a -> #7800000000000000 dece506 apply #7a00000000000000 -> Infinity dece507 apply #7b7b7b7b7b7b7b7b -> #7800000000000000 dece508 apply #7b00000000000000 -> Infinity dece509 apply #7c7c7c7c7c7c7c7c -> #7dffffffffffffff dece510 apply #7c00000000000000 -> NaN dece511 apply #7d7d7d7d7d7d7d7d -> #7dffffffffffffff dece512 apply #7d00000000000000 -> NaN dece513 apply #7e7e7e7e7e7e7e7e -> #7fffffffffffffff dece514 apply #7e00000000000000 -> sNaN dece515 apply #7f7f7f7f7f7f7f7f -> #7fffffffffffffff dece516 apply #7f00000000000000 -> sNaN dece521 apply #f878787878787878 -> #f800000000000000 dece522 apply #f800000000000000 -> -Infinity dece523 apply #f979797979797979 -> #f800000000000000 dece524 apply #f900000000000000 -> -Infinity dece525 apply #fa7a7a7a7a7a7a7a -> #f800000000000000 dece526 apply #fa00000000000000 -> -Infinity dece527 apply #fb7b7b7b7b7b7b7b -> #f800000000000000 dece528 apply #fb00000000000000 -> -Infinity dece529 apply #fc7c7c7c7c7c7c7c -> #7dffffffffffffff dece530 apply #fc00000000000000 -> NaN dece531 apply #fd7d7d7d7d7d7d7d -> #7dffffffffffffff dece532 apply #fd00000000000000 -> NaN dece533 apply #fe7e7e7e7e7e7e7e -> #7fffffffffffffff dece534 apply #fe00000000000000 -> sNaN dece535 apply #ff7f7f7f7f7f7f7f -> #7fffffffffffffff dece536 apply #ff00000000000000 -> sNaN -- fold-down full sequence dece601 apply 1E+384 -> #47fc000000000000 Clamped dece602 apply #47fc000000000000 -> 1.000000000000000E+384 dece603 apply 1E+383 -> #43fc800000000000 Clamped dece604 apply #43fc800000000000 -> 1.00000000000000E+383 dece605 apply 1E+382 -> #43fc100000000000 Clamped dece606 apply #43fc100000000000 -> 1.0000000000000E+382 dece607 apply 1E+381 -> #43fc010000000000 Clamped dece608 apply #43fc010000000000 -> 1.000000000000E+381 dece609 apply 1E+380 -> #43fc002000000000 Clamped dece610 apply #43fc002000000000 -> 1.00000000000E+380 dece611 apply 1E+379 -> #43fc000400000000 Clamped dece612 apply #43fc000400000000 -> 1.0000000000E+379 dece613 apply 1E+378 -> #43fc000040000000 Clamped dece614 apply #43fc000040000000 -> 1.000000000E+378 dece615 apply 1E+377 -> #43fc000008000000 Clamped dece616 apply #43fc000008000000 -> 1.00000000E+377 dece617 apply 1E+376 -> #43fc000001000000 Clamped dece618 apply #43fc000001000000 -> 1.0000000E+376 dece619 apply 1E+375 -> #43fc000000100000 Clamped dece620 apply #43fc000000100000 -> 1.000000E+375 dece621 apply 1E+374 -> #43fc000000020000 Clamped dece622 apply #43fc000000020000 -> 1.00000E+374 dece623 apply 1E+373 -> #43fc000000004000 Clamped dece624 apply #43fc000000004000 -> 1.0000E+373 dece625 apply 1E+372 -> #43fc000000000400 Clamped dece626 apply #43fc000000000400 -> 1.000E+372 dece627 apply 1E+371 -> #43fc000000000080 Clamped dece628 apply #43fc000000000080 -> 1.00E+371 dece629 apply 1E+370 -> #43fc000000000010 Clamped dece630 apply #43fc000000000010 -> 1.0E+370 dece631 apply 1E+369 -> #43fc000000000001 dece632 apply #43fc000000000001 -> 1E+369 dece633 apply 1E+368 -> #43f8000000000001 dece634 apply #43f8000000000001 -> 1E+368 -- same with 9s dece641 apply 9E+384 -> #77fc000000000000 Clamped dece642 apply #77fc000000000000 -> 9.000000000000000E+384 dece643 apply 9E+383 -> #43fc8c0000000000 Clamped dece644 apply #43fc8c0000000000 -> 9.00000000000000E+383 dece645 apply 9E+382 -> #43fc1a0000000000 Clamped dece646 apply #43fc1a0000000000 -> 9.0000000000000E+382 dece647 apply 9E+381 -> #43fc090000000000 Clamped dece648 apply #43fc090000000000 -> 9.000000000000E+381 dece649 apply 9E+380 -> #43fc002300000000 Clamped dece650 apply #43fc002300000000 -> 9.00000000000E+380 dece651 apply 9E+379 -> #43fc000680000000 Clamped dece652 apply #43fc000680000000 -> 9.0000000000E+379 dece653 apply 9E+378 -> #43fc000240000000 Clamped dece654 apply #43fc000240000000 -> 9.000000000E+378 dece655 apply 9E+377 -> #43fc000008c00000 Clamped dece656 apply #43fc000008c00000 -> 9.00000000E+377 dece657 apply 9E+376 -> #43fc000001a00000 Clamped dece658 apply #43fc000001a00000 -> 9.0000000E+376 dece659 apply 9E+375 -> #43fc000000900000 Clamped dece660 apply #43fc000000900000 -> 9.000000E+375 dece661 apply 9E+374 -> #43fc000000023000 Clamped dece662 apply #43fc000000023000 -> 9.00000E+374 dece663 apply 9E+373 -> #43fc000000006800 Clamped dece664 apply #43fc000000006800 -> 9.0000E+373 dece665 apply 9E+372 -> #43fc000000002400 Clamped dece666 apply #43fc000000002400 -> 9.000E+372 dece667 apply 9E+371 -> #43fc00000000008c Clamped dece668 apply #43fc00000000008c -> 9.00E+371 dece669 apply 9E+370 -> #43fc00000000001a Clamped dece670 apply #43fc00000000001a -> 9.0E+370 dece671 apply 9E+369 -> #43fc000000000009 dece672 apply #43fc000000000009 -> 9E+369 dece673 apply 9E+368 -> #43f8000000000009 dece674 apply #43f8000000000009 -> 9E+368 -- Selected DPD codes dece700 apply #2238000000000000 -> 0 dece701 apply #2238000000000009 -> 9 dece702 apply #2238000000000010 -> 10 dece703 apply #2238000000000019 -> 19 dece704 apply #2238000000000020 -> 20 dece705 apply #2238000000000029 -> 29 dece706 apply #2238000000000030 -> 30 dece707 apply #2238000000000039 -> 39 dece708 apply #2238000000000040 -> 40 dece709 apply #2238000000000049 -> 49 dece710 apply #2238000000000050 -> 50 dece711 apply #2238000000000059 -> 59 dece712 apply #2238000000000060 -> 60 dece713 apply #2238000000000069 -> 69 dece714 apply #2238000000000070 -> 70 dece715 apply #2238000000000071 -> 71 dece716 apply #2238000000000072 -> 72 dece717 apply #2238000000000073 -> 73 dece718 apply #2238000000000074 -> 74 dece719 apply #2238000000000075 -> 75 dece720 apply #2238000000000076 -> 76 dece721 apply #2238000000000077 -> 77 dece722 apply #2238000000000078 -> 78 dece723 apply #2238000000000079 -> 79 dece730 apply #223800000000029e -> 994 dece731 apply #223800000000029f -> 995 dece732 apply #22380000000002a0 -> 520 dece733 apply #22380000000002a1 -> 521 -- DPD: one of each of the huffman groups dece740 apply #22380000000003f7 -> 777 dece741 apply #22380000000003f8 -> 778 dece742 apply #22380000000003eb -> 787 dece743 apply #223800000000037d -> 877 dece744 apply #223800000000039f -> 997 dece745 apply #22380000000003bf -> 979 dece746 apply #22380000000003df -> 799 dece747 apply #223800000000006e -> 888 -- DPD all-highs cases (includes the 24 redundant codes) dece750 apply #223800000000006e -> 888 dece751 apply #223800000000016e -> 888 dece752 apply #223800000000026e -> 888 dece753 apply #223800000000036e -> 888 dece754 apply #223800000000006f -> 889 dece755 apply #223800000000016f -> 889 dece756 apply #223800000000026f -> 889 dece757 apply #223800000000036f -> 889 dece760 apply #223800000000007e -> 898 dece761 apply #223800000000017e -> 898 dece762 apply #223800000000027e -> 898 dece763 apply #223800000000037e -> 898 dece764 apply #223800000000007f -> 899 dece765 apply #223800000000017f -> 899 dece766 apply #223800000000027f -> 899 dece767 apply #223800000000037f -> 899 dece770 apply #22380000000000ee -> 988 dece771 apply #22380000000001ee -> 988 dece772 apply #22380000000002ee -> 988 dece773 apply #22380000000003ee -> 988 dece774 apply #22380000000000ef -> 989 dece775 apply #22380000000001ef -> 989 dece776 apply #22380000000002ef -> 989 dece777 apply #22380000000003ef -> 989 dece780 apply #22380000000000fe -> 998 dece781 apply #22380000000001fe -> 998 dece782 apply #22380000000002fe -> 998 dece783 apply #22380000000003fe -> 998 dece784 apply #22380000000000ff -> 999 dece785 apply #22380000000001ff -> 999 dece786 apply #22380000000002ff -> 999 dece787 apply #22380000000003ff -> 999 --- NEW FILE: divide.decTest --- ------------------------------------------------------------------------ -- divide.decTest -- decimal division -- -- Copyright (c) IBM Corporation, 1981, 2004. All rights reserved. -- ------------------------------------------------------------------------ -- Please see the document "General Decimal Arithmetic Testcases" -- -- at http://www2.hursley.ibm.com/decimal for the description of -- -- these testcases. -- -- -- -- These testcases are experimental ('beta' versions), and they -- -- may contain errors. They are offered on an as-is basis. In -- -- particular, achieving the same results as the tests here is not -- -- a guarantee that an implementation complies with any Standard -- -- or specification. The tests are not exhaustive. -- -- -- -- Please send comments, suggestions, and corrections to the author: -- -- Mike Cowlishaw, IBM Fellow -- -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ version: 2.38 extended: 1 precision: 9 rounding: half_up maxExponent: 384 minexponent: -383 -- sanity checks divx001 divide 1 1 -> 1 divx002 divide 2 1 -> 2 divx003 divide 1 2 -> 0.5 divx004 divide 2 2 -> 1 divx005 divide 0 1 -> 0 divx006 divide 0 2 -> 0 divx007 divide 1 3 -> 0.333333333 Inexact Rounded divx008 divide 2 3 -> 0.666666667 Inexact Rounded divx009 divide 3 3 -> 1 divx010 divide 2.4 1 -> 2.4 divx011 divide 2.4 -1 -> -2.4 divx012 divide -2.4 1 -> -2.4 divx013 divide -2.4 -1 -> 2.4 divx014 divide 2.40 1 -> 2.40 divx015 divide 2.400 1 -> 2.400 divx016 divide 2.4 2 -> 1.2 divx017 divide 2.400 2 -> 1.200 divx018 divide 2. 2 -> 1 divx019 divide 20 20 -> 1 divx020 divide 187 187 -> 1 divx021 divide 5 2 -> 2.5 divx022 divide 5 2.0 -> 2.5 divx023 divide 5 2.000 -> 2.5 divx024 divide 5 0.20 -> 25 divx025 divide 5 0.200 -> 25 divx026 divide 10 1 -> 10 divx027 divide 100 1 -> 100 divx028 divide 1000 1 -> 1000 divx029 divide 1000 100 -> 10 divx030 divide 1 2 -> 0.5 divx031 divide 1 4 -> 0.25 divx032 divide 1 8 -> 0.125 divx033 divide 1 16 -> 0.0625 divx034 divide 1 32 -> 0.03125 divx035 divide 1 64 -> 0.015625 divx040 divide 1 -2 -> -0.5 divx041 divide 1 -4 -> -0.25 divx042 divide 1 -8 -> -0.125 divx043 divide 1 -16 -> -0.0625 divx044 divide 1 -32 -> -0.03125 divx045 divide 1 -64 -> -0.015625 divx050 divide -1 2 -> -0.5 divx051 divide -1 4 -> -0.25 divx052 divide -1 8 -> -0.125 divx053 divide -1 16 -> -0.0625 divx054 divide -1 32 -> -0.03125 divx055 divide -1 64 -> -0.015625 divx060 divide -1 -2 -> 0.5 divx061 divide -1 -4 -> 0.25 divx062 divide -1 -8 -> 0.125 divx063 divide -1 -16 -> 0.0625 divx064 divide -1 -32 -> 0.03125 divx065 divide -1 -64 -> 0.015625 divx070 divide 999999999 1 -> 999999999 divx071 divide 999999999.4 1 -> 999999999 Inexact Rounded divx072 divide 999999999.5 1 -> 1.00000000E+9 Inexact Rounded divx073 divide 999999999.9 1 -> 1.00000000E+9 Inexact Rounded divx074 divide 999999999.999 1 -> 1.00000000E+9 Inexact Rounded precision: 6 divx080 divide 999999999 1 -> 1.00000E+9 Inexact Rounded divx081 divide 99999999 1 -> 1.00000E+8 Inexact Rounded divx082 divide 9999999 1 -> 1.00000E+7 Inexact Rounded divx083 divide 999999 1 -> 999999 divx084 divide 99999 1 -> 99999 divx085 divide 9999 1 -> 9999 divx086 divide 999 1 -> 999 divx087 divide 99 1 -> 99 divx088 divide 9 1 -> 9 precision: 9 divx090 divide 0. 1 -> 0 divx091 divide .0 1 -> 0.0 divx092 divide 0.00 1 -> 0.00 divx093 divide 0.00E+9 1 -> 0E+7 divx094 divide 0.0000E-50 1 -> 0E-54 divx095 divide 1 1E-8 -> 1E+8 divx096 divide 1 1E-9 -> 1E+9 divx097 divide 1 1E-10 -> 1E+10 divx098 divide 1 1E-11 -> 1E+11 divx099 divide 1 1E-12 -> 1E+12 divx100 divide 1 1 -> 1 divx101 divide 1 2 -> 0.5 divx102 divide 1 3 -> 0.333333333 Inexact Rounded divx103 divide 1 4 -> 0.25 divx104 divide 1 5 -> 0.2 divx105 divide 1 6 -> 0.166666667 Inexact Rounded divx106 divide 1 7 -> 0.142857143 Inexact Rounded divx107 divide 1 8 -> 0.125 divx108 divide 1 9 -> 0.111111111 Inexact Rounded divx109 divide 1 10 -> 0.1 divx110 divide 1 1 -> 1 divx111 divide 2 1 -> 2 divx112 divide 3 1 -> 3 divx113 divide 4 1 -> 4 divx114 divide 5 1 -> 5 divx115 divide 6 1 -> 6 divx116 divide 7 1 -> 7 divx117 divide 8 1 -> 8 divx118 divide 9 1 -> 9 divx119 divide 10 1 -> 10 divx120 divide 3E+1 0.001 -> 3E+4 divx121 divide 2.200 2 -> 1.100 divx130 divide 12345 4.999 -> 2469.49390 Inexact Rounded divx131 divide 12345 4.99 -> 2473.94790 Inexact Rounded divx132 divide 12345 4.9 -> 2519.38776 Inexact Rounded divx133 divide 12345 5 -> 2469 divx134 divide 12345 5.1 -> 2420.58824 Inexact Rounded divx135 divide 12345 5.01 -> 2464.07186 Inexact Rounded divx136 divide 12345 5.001 -> 2468.50630 Inexact Rounded precision: 9 maxexponent: 999999999 minexponent: -999999999 -- test possibly imprecise results divx220 divide 391 597 -> 0.654941374 Inexact Rounded divx221 divide 391 -597 -> -0.654941374 Inexact Rounded divx222 divide -391 597 -> -0.654941374 Inexact Rounded divx223 divide -391 -597 -> 0.654941374 Inexact Rounded -- test some cases that are close to exponent overflow maxexponent: 999999999 minexponent: -999999999 divx270 divide 1 1e999999999 -> 1E-999999999 divx271 divide 1 0.9e999999999 -> 1.11111111E-999999999 Inexact Rounded divx272 divide 1 0.99e999999999 -> 1.01010101E-999999999 Inexact Rounded divx273 divide 1 0.999999999e999999999 -> 1.00000000E-999999999 Inexact Rounded divx274 divide 9e999999999 1 -> 9E+999999999 divx275 divide 9.9e999999999 1 -> 9.9E+999999999 divx276 divide 9.99e999999999 1 -> 9.99E+999999999 divx277 divide 9.99999999e999999999 1 -> 9.99999999E+999999999 divx280 divide 0.1 9e-999999999 -> 1.11111111E+999999997 Inexact Rounded divx281 divide 0.1 99e-999999999 -> 1.01010101E+999999996 Inexact Rounded divx282 divide 0.1 999e-999999999 -> 1.00100100E+999999995 Inexact Rounded divx283 divide 0.1 9e-999999998 -> 1.11111111E+999999996 Inexact Rounded divx284 divide 0.1 99e-999999998 -> 1.01010101E+999999995 Inexact Rounded divx285 divide 0.1 999e-999999998 -> 1.00100100E+999999994 Inexact Rounded divx286 divide 0.1 999e-999999997 -> 1.00100100E+999999993 Inexact Rounded divx287 divide 0.1 9999e-999999997 -> 1.00010001E+999999992 Inexact Rounded divx288 divide 0.1 99999e-999999997 -> 1.00001000E+999999991 Inexact Rounded -- Divide into 0 tests divx301 divide 0 7 -> 0 divx302 divide 0 7E-5 -> 0E+5 divx303 divide 0 7E-1 -> 0E+1 divx304 divide 0 7E+1 -> 0.0 divx305 divide 0 7E+5 -> 0.00000 divx306 divide 0 7E+6 -> 0.000000 divx307 divide 0 7E+7 -> 0E-7 divx308 divide 0 70E-5 -> 0E+5 divx309 divide 0 70E-1 -> 0E+1 divx310 divide 0 70E+0 -> 0 divx311 divide 0 70E+1 -> 0.0 divx312 divide 0 70E+5 -> 0.00000 divx313 divide 0 70E+6 -> 0.000000 divx314 divide 0 70E+7 -> 0E-7 divx315 divide 0 700E-5 -> 0E+5 divx316 divide 0 700E-1 -> 0E+1 divx317 divide 0 700E+0 -> 0 divx318 divide 0 700E+1 -> 0.0 divx319 divide 0 700E+5 -> 0.00000 divx320 divide 0 700E+6 -> 0.000000 divx321 divide 0 700E+7 -> 0E-7 divx322 divide 0 700E+77 -> 0E-77 divx331 divide 0E-3 7E-5 -> 0E+2 divx332 divide 0E-3 7E-1 -> 0.00 divx333 divide 0E-3 7E+1 -> 0.0000 divx334 divide 0E-3 7E+5 -> 0E-8 divx335 divide 0E-1 7E-5 -> 0E+4 divx336 divide 0E-1 7E-1 -> 0 divx337 divide 0E-1 7E+1 -> 0.00 divx338 divide 0E-1 7E+5 -> 0.000000 divx339 divide 0E+1 7E-5 -> 0E+6 divx340 divide 0E+1 7E-1 -> 0E+2 divx341 divide 0E+1 7E+1 -> 0 divx342 divide 0E+1 7E+5 -> 0.0000 divx343 divide 0E+3 7E-5 -> 0E+8 divx344 divide 0E+3 7E-1 -> 0E+4 divx345 divide 0E+3 7E+1 -> 0E+2 divx346 divide 0E+3 7E+5 -> 0.00 maxexponent: 92 minexponent: -92 precision: 7 divx351 divide 0E-92 7E-1 -> 0E-91 divx352 divide 0E-92 7E+1 -> 0E-93 divx353 divide 0E-92 7E+5 -> 0E-97 divx354 divide 0E-92 7E+6 -> 0E-98 divx355 divide 0E-92 7E+7 -> 0E-98 Clamped divx356 divide 0E-92 777E-1 -> 0E-91 divx357 divide 0E-92 777E+1 -> 0E-93 divx358 divide 0E-92 777E+3 -> 0E-95 divx359 divide 0E-92 777E+4 -> 0E-96 divx360 divide 0E-92 777E+5 -> 0E-97 divx361 divide 0E-92 777E+6 -> 0E-98 divx362 divide 0E-92 777E+7 -> 0E-98 Clamped divx363 divide 0E-92 7E+92 -> 0E-98 Clamped divx371 divide 0E-92 700E-1 -> 0E-91 divx372 divide 0E-92 700E+1 -> 0E-93 divx373 divide 0E-92 700E+3 -> 0E-95 divx374 divide 0E-92 700E+4 -> 0E-96 divx375 divide 0E-92 700E+5 -> 0E-97 divx376 divide 0E-92 700E+6 -> 0E-98 divx377 divide 0E-92 700E+7 -> 0E-98 Clamped divx381 divide 0E+92 7E+1 -> 0E+91 divx382 divide 0E+92 7E+0 -> 0E+92 divx383 divide 0E+92 7E-1 -> 0E+92 Clamped divx384 divide 0E+90 777E+1 -> 0E+89 divx385 divide 0E+90 777E-1 -> 0E+91 divx386 divide 0E+90 777E-2 -> 0E+92 divx387 divide 0E+90 777E-3 -> 0E+92 Clamped divx388 divide 0E+90 777E-4 -> 0E+92 Clamped divx391 divide 0E+90 700E+1 -> 0E+89 divx392 divide 0E+90 700E-1 -> 0E+91 divx393 divide 0E+90 700E-2 -> 0E+92 divx394 divide 0E+90 700E-3 -> 0E+92 Clamped divx395 divide 0E+90 700E-4 -> 0E+92 Clamped -- input rounding checks maxexponent: 999 minexponent: -999 precision: 9 divx401 divide 12345678000 1 -> 1.23456780E+10 Rounded divx402 divide 1 12345678000 -> 8.10000066E-11 Inexact Rounded divx403 divide 1234567800 1 -> 1.23456780E+9 Rounded divx404 divide 1 1234567800 -> 8.10000066E-10 Inexact Rounded divx405 divide 1234567890 1 -> 1.23456789E+9 Rounded divx406 divide 1 1234567890 -> 8.10000007E-10 Inexact Rounded divx407 divide 1234567891 1 -> 1.23456789E+9 Inexact Rounded divx408 divide 1 1234567891 -> 8.10000007E-10 Inexact Rounded divx409 divide 12345678901 1 -> 1.23456789E+10 Inexact Rounded divx410 divide 1 12345678901 -> 8.10000007E-11 Inexact Rounded divx411 divide 1234567896 1 -> 1.23456790E+9 Inexact Rounded divx412 divide 1 1234567896 -> 8.10000003E-10 Inexact Rounded divx413 divide 1 1234567897 -> 8.10000003E-10 Inexact Rounded divx414 divide 1 1234567898 -> 8.10000002E-10 Inexact Rounded divx415 divide 1 1234567899 -> 8.10000001E-10 Inexact Rounded divx416 divide 1 1234567900 -> 8.10000001E-10 Inexact Rounded divx417 divide 1 1234567901 -> 8.10000000E-10 Inexact Rounded divx418 divide 1 1234567902 -> 8.09999999E-10 Inexact Rounded -- some longies divx421 divide 1234567896.000000000000 1 -> 1.23456790E+9 Inexact Rounded divx422 divide 1 1234567896.000000000000 -> 8.10000003E-10 Inexact Rounded divx423 divide 1234567896.000000000001 1 -> 1.23456790E+9 Inexact Rounded divx424 divide 1 1234567896.000000000001 -> 8.10000003E-10 Inexact Rounded divx425 divide 1234567896.000000000000000000000000000000000000000009 1 -> 1.23456790E+9 Inexact Rounded divx426 divide 1 1234567896.000000000000000000000000000000000000000009 -> 8.10000003E-10 Inexact Rounded divx427 divide 1234567897.900010000000000000000000000000000000000009 1 -> 1.23456790E+9 Inexact Rounded divx428 divide 1 1234567897.900010000000000000000000000000000000000009 -> 8.10000002E-10 Inexact Rounded precision: 15 -- still checking... divx441 divide 12345678000 1 -> 12345678000 divx442 divide 1 12345678000 -> 8.10000066420005E-11 Inexact Rounded divx443 divide 1234567800 1 -> 1234567800 divx444 divide 1 1234567800 -> 8.10000066420005E-10 Inexact Rounded divx445 divide 1234567890 1 -> 1234567890 divx446 divide 1 1234567890 -> 8.10000007371000E-10 Inexact Rounded divx447 divide 1234567891 1 -> 1234567891 divx448 divide 1 1234567891 -> 8.10000006714900E-10 Inexact Rounded divx449 divide 12345678901 1 -> 12345678901 divx450 divide 1 12345678901 -> 8.10000007305390E-11 Inexact Rounded divx451 divide 1234567896 1 -> 1234567896 divx452 divide 1 1234567896 -> 8.10000003434400E-10 Inexact Rounded -- high-lows divx453 divide 1e+1 1 -> 1E+1 divx454 divide 1e+1 1.0 -> 1E+1 divx455 divide 1e+1 1.00 -> 1E+1 divx456 divide 1e+2 2 -> 5E+1 divx457 divide 1e+2 2.0 -> 5E+1 divx458 divide 1e+2 2.00 -> 5E+1 -- some from IEEE discussions divx460 divide 3e0 2e0 -> 1.5 divx461 divide 30e-1 2e0 -> 1.5 divx462 divide 300e-2 2e0 -> 1.50 divx464 divide 3000e-3 2e0 -> 1.500 divx465 divide 3e0 20e-1 -> 1.5 divx466 divide 30e-1 20e-1 -> 1.5 divx467 divide 300e-2 20e-1 -> 1.5 divx468 divide 3000e-3 20e-1 -> 1.50 divx469 divide 3e0 200e-2 -> 1.5 divx470 divide 30e-1 200e-2 -> 1.5 divx471 divide 300e-2 200e-2 -> 1.5 divx472 divide 3000e-3 200e-2 -> 1.5 divx473 divide 3e0 2000e-3 -> 1.5 divx474 divide 30e-1 2000e-3 -> 1.5 divx475 divide 300e-2 2000e-3 -> 1.5 divx476 divide 3000e-3 2000e-3 -> 1.5 -- some reciprocals divx480 divide 1 1.0E+33 -> 1E-33 divx481 divide 1 10E+33 -> 1E-34 divx482 divide 1 1.0E-33 -> 1E+33 divx483 divide 1 10E-33 -> 1E+32 -- RMS discussion table maxexponent: 96 minexponent: -95 precision: 7 divx484 divide 0e5 1e3 -> 0E+2 divx485 divide 0e5 2e3 -> 0E+2 divx486 divide 0e5 10e2 -> 0E+3 divx487 divide 0e5 20e2 -> 0E+3 divx488 divide 0e5 100e1 -> 0E+4 divx489 divide 0e5 200e1 -> 0E+4 divx491 divide 1e5 1e3 -> 1E+2 divx492 divide 1e5 2e3 -> 5E+1 divx493 divide 1e5 10e2 -> 1E+2 divx494 divide 1e5 20e2 -> 5E+1 divx495 divide 1e5 100e1 -> 1E+2 divx496 divide 1e5 200e1 -> 5E+1 -- tryzeros cases precision: 7 rounding: half_up maxExponent: 92 minexponent: -92 divx497 divide 0E+86 1000E-13 -> 0E+92 Clamped divx498 divide 0E-98 1000E+13 -> 0E-98 Clamped precision: 9 rounding: half_up maxExponent: 999 minexponent: -999 -- focus on trailing zeros issues precision: 9 divx500 divide 1 9.9 -> 0.101010101 Inexact Rounded precision: 8 divx501 divide 1 9.9 -> 0.10101010 Inexact Rounded precision: 7 divx502 divide 1 9.9 -> 0.1010101 Inexact Rounded precision: 6 divx503 divide 1 9.9 -> 0.101010 Inexact Rounded precision: 9 divx511 divide 1 2 -> 0.5 divx512 divide 1.0 2 -> 0.5 divx513 divide 1.00 2 -> 0.50 divx514 divide 1.000 2 -> 0.500 divx515 divide 1.0000 2 -> 0.5000 divx516 divide 1.00000 2 -> 0.50000 divx517 divide 1.000000 2 -> 0.500000 divx518 divide 1.0000000 2 -> 0.5000000 divx519 divide 1.00 2.00 -> 0.5 divx521 divide 2 1 -> 2 divx522 divide 2 1.0 -> 2 divx523 divide 2 1.00 -> 2 divx524 divide 2 1.000 -> 2 divx525 divide 2 1.0000 -> 2 divx526 divide 2 1.00000 -> 2 divx527 divide 2 1.000000 -> 2 divx528 divide 2 1.0000000 -> 2 divx529 divide 2.00 1.00 -> 2 divx530 divide 2.40 2 -> 1.20 divx531 divide 2.40 4 -> 0.60 divx532 divide 2.40 10 -> 0.24 divx533 divide 2.40 2.0 -> 1.2 divx534 divide 2.40 4.0 -> 0.6 divx535 divide 2.40 10.0 -> 0.24 divx536 divide 2.40 2.00 -> 1.2 divx537 divide 2.40 4.00 -> 0.6 divx538 divide 2.40 10.00 -> 0.24 divx539 divide 0.9 0.1 -> 9 divx540 divide 0.9 0.01 -> 9E+1 divx541 divide 0.9 0.001 -> 9E+2 divx542 divide 5 2 -> 2.5 divx543 divide 5 2.0 -> 2.5 divx544 divide 5 2.00 -> 2.5 divx545 divide 5 20 -> 0.25 divx546 divide 5 20.0 -> 0.25 divx547 divide 2.400 2 -> 1.200 divx548 divide 2.400 2.0 -> 1.20 divx549 divide 2.400 2.400 -> 1 divx550 divide 240 1 -> 240 divx551 divide 240 10 -> 24 divx552 divide 240 100 -> 2.4 divx553 divide 240 1000 -> 0.24 divx554 divide 2400 1 -> 2400 divx555 divide 2400 10 -> 240 divx556 divide 2400 100 -> 24 divx557 divide 2400 1000 -> 2.4 -- +ve exponent precision: 5 divx570 divide 2.4E+6 2 -> 1.2E+6 divx571 divide 2.40E+6 2 -> 1.20E+6 divx572 divide 2.400E+6 2 -> 1.200E+6 divx573 divide 2.4000E+6 2 -> 1.2000E+6 divx574 divide 24E+5 2 -> 1.2E+6 divx575 divide 240E+4 2 -> 1.20E+6 divx576 divide 2400E+3 2 -> 1.200E+6 divx577 divide 24000E+2 2 -> 1.2000E+6 precision: 6 divx580 divide 2.4E+6 2 -> 1.2E+6 divx581 divide 2.40E+6 2 -> 1.20E+6 divx582 divide 2.400E+6 2 -> 1.200E+6 divx583 divide 2.4000E+6 2 -> 1.2000E+6 divx584 divide 24E+5 2 -> 1.2E+6 divx585 divide 240E+4 2 -> 1.20E+6 divx586 divide 2400E+3 2 -> 1.200E+6 divx587 divide 24000E+2 2 -> 1.2000E+6 precision: 7 divx590 divide 2.4E+6 2 -> 1.2E+6 divx591 divide 2.40E+6 2 -> 1.20E+6 divx592 divide 2.400E+6 2 -> 1.200E+6 divx593 divide 2.4000E+6 2 -> 1.2000E+6 divx594 divide 24E+5 2 -> 1.2E+6 divx595 divide 240E+4 2 -> 1.20E+6 divx596 divide 2400E+3 2 -> 1.200E+6 divx597 divide 24000E+2 2 -> 1.2000E+6 precision: 9 divx600 divide 2.4E+9 2 -> 1.2E+9 divx601 divide 2.40E+9 2 -> 1.20E+9 divx602 divide 2.400E+9 2 -> 1.200E+9 divx603 divide 2.4000E+9 2 -> 1.2000E+9 divx604 divide 24E+8 2 -> 1.2E+9 divx605 divide 240E+7 2 -> 1.20E+9 divx606 divide 2400E+6 2 -> 1.200E+9 divx607 divide 24000E+5 2 -> 1.2000E+9 -- long operand triangle precision: 33 divx610 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -41011408883796817797.8131097703792 Inexact Rounded precision: 32 divx611 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -41011408883796817797.813109770379 Inexact Rounded precision: 31 divx612 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -41011408883796817797.81310977038 Inexact Rounded precision: 30 divx613 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -41011408883796817797.8131097704 Inexact Rounded precision: 29 divx614 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -41011408883796817797.813109770 Inexact Rounded precision: 28 divx615 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -41011408883796817797.81310977 Inexact Rounded precision: 27 divx616 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -41011408883796817797.8131098 Inexact Rounded precision: 26 divx617 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -41011408883796817797.813110 Inexact Rounded precision: 25 divx618 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -41011408883796817797.81311 Inexact Rounded precision: 24 divx619 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -41011408883796817797.8131 Inexact Rounded precision: 23 divx620 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -41011408883796817797.813 Inexact Rounded precision: 22 divx621 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -41011408883796817797.81 Inexact Rounded precision: 21 divx622 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -41011408883796817797.8 Inexact Rounded precision: 20 divx623 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -41011408883796817798 Inexact Rounded precision: 19 divx624 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -4.101140888379681780E+19 Inexact Rounded precision: 18 divx625 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -4.10114088837968178E+19 Inexact Rounded precision: 17 divx626 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -4.1011408883796818E+19 Inexact Rounded precision: 16 divx627 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -4.101140888379682E+19 Inexact Rounded precision: 15 divx628 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -4.10114088837968E+19 Inexact Rounded precision: 14 divx629 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -4.1011408883797E+19 Inexact Rounded precision: 13 divx630 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -4.101140888380E+19 Inexact Rounded precision: 12 divx631 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -4.10114088838E+19 Inexact Rounded precision: 11 divx632 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -4.1011408884E+19 Inexact Rounded precision: 10 divx633 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -4.101140888E+19 Inexact Rounded precision: 9 divx634 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -4.10114089E+19 Inexact Rounded precision: 8 divx635 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -4.1011409E+19 Inexact Rounded precision: 7 divx636 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -4.101141E+19 Inexact Rounded precision: 6 divx637 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -4.10114E+19 Inexact Rounded precision: 5 divx638 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -4.1011E+19 Inexact Rounded precision: 4 divx639 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -4.101E+19 Inexact Rounded precision: 3 divx640 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -4.10E+19 Inexact Rounded precision: 2 divx641 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -4.1E+19 Inexact Rounded precision: 1 divx642 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -4E+19 Inexact Rounded -- more zeros, etc. precision: 16 rounding: half_up maxExponent: 384 minExponent: -383 divx731 divide 5.00 1E-3 -> 5.00E+3 divx732 divide 00.00 0.000 -> NaN Division_undefined divx733 divide 00.00 0E-3 -> NaN Division_undefined divx734 divide 0 -0 -> NaN Division_undefined divx735 divide -0 0 -> NaN Division_undefined divx736 divide -0 -0 -> NaN Division_undefined divx741 divide 0 -1 -> -0 divx742 divide -0 -1 -> 0 divx743 divide 0 1 -> 0 divx744 divide -0 1 -> -0 divx745 divide -1 0 -> -Infinity Division_by_zero divx746 divide -1 -0 -> Infinity Division_by_zero divx747 divide 1 0 -> Infinity Division_by_zero divx748 divide 1 -0 -> -Infinity Division_by_zero divx751 divide 0.0 -1 -> -0.0 divx752 divide -0.0 -1 -> 0.0 divx753 divide 0.0 1 -> 0.0 divx754 divide -0.0 1 -> -0.0 divx755 divide -1.0 0 -> -Infinity Division_by_zero divx756 divide -1.0 -0 -> Infinity Division_by_zero divx757 divide 1.0 0 -> Infinity Division_by_zero divx758 divide 1.0 -0 -> -Infinity Division_by_zero divx761 divide 0 -1.0 -> -0E+1 divx762 divide -0 -1.0 -> 0E+1 divx763 divide 0 1.0 -> 0E+1 divx764 divide -0 1.0 -> -0E+1 divx765 divide -1 0.0 -> -Infinity Division_by_zero divx766 divide -1 -0.0 -> Infinity Division_by_zero divx767 divide 1 0.0 -> Infinity Division_by_zero divx768 divide 1 -0.0 -> -Infinity Division_by_zero divx771 divide 0.0 -1.0 -> -0 divx772 divide -0.0 -1.0 -> 0 divx773 divide 0.0 1.0 -> 0 divx774 divide -0.0 1.0 -> -0 divx775 divide -1.0 0.0 -> -Infinity Division_by_zero divx776 divide -1.0 -0.0 -> Infinity Division_by_zero divx777 divide 1.0 0.0 -> Infinity Division_by_zero divx778 divide 1.0 -0.0 -> -Infinity Division_by_zero -- Specials divx780 divide Inf -Inf -> NaN Invalid_operation divx781 divide Inf -1000 -> -Infinity divx782 divide Inf -1 -> -Infinity divx783 divide Inf -0 -> -Infinity divx784 divide Inf 0 -> Infinity divx785 divide Inf 1 -> Infinity divx786 divide Inf 1000 -> Infinity divx787 divide Inf Inf -> NaN Invalid_operation divx788 divide -1000 Inf -> -0E-398 Clamped divx789 divide -Inf Inf -> NaN Invalid_operation divx790 divide -1 Inf -> -0E-398 Clamped divx791 divide -0 Inf -> -0E-398 Clamped divx792 divide 0 Inf -> 0E-398 Clamped divx793 divide 1 Inf -> 0E-398 Clamped divx794 divide 1000 Inf -> 0E-398 Clamped divx795 divide Inf Inf -> NaN Invalid_operation divx800 divide -Inf -Inf -> NaN Invalid_operation divx801 divide -Inf -1000 -> Infinity divx802 divide -Inf -1 -> Infinity divx803 divide -Inf -0 -> Infinity divx804 divide -Inf 0 -> -Infinity divx805 divide -Inf 1 -> -Infinity divx806 divide -Inf 1000 -> -Infinity divx807 divide -Inf Inf -> NaN Invalid_operation divx808 divide -1000 Inf -> -0E-398 Clamped divx809 divide -Inf -Inf -> NaN Invalid_operation divx810 divide -1 -Inf -> 0E-398 Clamped divx811 divide -0 -Inf -> 0E-398 Clamped divx812 divide 0 -Inf -> -0E-398 Clamped divx813 divide 1 -Inf -> -0E-398 Clamped divx814 divide 1000 -Inf -> -0E-398 Clamped divx815 divide Inf -Inf -> NaN Invalid_operation divx821 divide NaN -Inf -> NaN divx822 divide NaN -1000 -> NaN divx823 divide NaN -1 -> NaN divx824 divide NaN -0 -> NaN divx825 divide NaN 0 -> NaN divx826 divide NaN 1 -> NaN divx827 divide NaN 1000 -> NaN divx828 divide NaN Inf -> NaN divx829 divide NaN NaN -> NaN divx830 divide -Inf NaN -> NaN divx831 divide -1000 NaN -> NaN divx832 divide -1 NaN -> NaN divx833 divide -0 NaN -> NaN divx834 divide 0 NaN -> NaN divx835 divide 1 NaN -> NaN divx836 divide 1000 NaN -> NaN divx837 divide Inf NaN -> NaN divx841 divide sNaN -Inf -> NaN Invalid_operation divx842 divide sNaN -1000 -> NaN Invalid_operation divx843 divide sNaN -1 -> NaN Invalid_operation divx844 divide sNaN -0 -> NaN Invalid_operation divx845 divide sNaN 0 -> NaN Invalid_operation divx846 divide sNaN 1 -> NaN Invalid_operation divx847 divide sNaN 1000 -> NaN Invalid_operation divx848 divide sNaN NaN -> NaN Invalid_operation divx849 divide sNaN sNaN -> NaN Invalid_operation divx850 divide NaN sNaN -> NaN Invalid_operation divx851 divide -Inf sNaN -> NaN Invalid_operation divx852 divide -1000 sNaN -> NaN Invalid_operation divx853 divide -1 sNaN -> NaN Invalid_operation divx854 divide -0 sNaN -> NaN Invalid_operation divx855 divide 0 sNaN -> NaN Invalid_operation divx856 divide 1 sNaN -> NaN Invalid_operation divx857 divide 1000 sNaN -> NaN Invalid_operation divx858 divide Inf sNaN -> NaN Invalid_operation divx859 divide NaN sNaN -> NaN Invalid_operation -- propagating NaNs divx861 divide NaN9 -Inf -> NaN9 divx862 divide NaN8 1000 -> NaN8 divx863 divide NaN7 Inf -> NaN7 divx864 divide NaN6 NaN5 -> NaN6 divx865 divide -Inf NaN4 -> NaN4 divx866 divide -1000 NaN3 -> NaN3 divx867 divide Inf NaN2 -> NaN2 divx871 divide sNaN99 -Inf -> NaN99 Invalid_operation divx872 divide sNaN98 -1 -> NaN98 Invalid_operation divx873 divide sNaN97 NaN -> NaN97 Invalid_operation divx874 divide sNaN96 sNaN94 -> NaN96 Invalid_operation divx875 divide NaN95 sNaN93 -> NaN93 Invalid_operation divx876 divide -Inf sNaN92 -> NaN92 Invalid_operation divx877 divide 0 sNaN91 -> NaN91 Invalid_operation divx878 divide Inf sNaN90 -> NaN90 Invalid_operation divx879 divide NaN sNaN89 -> NaN89 Invalid_operation divx881 divide -NaN9 -Inf -> -NaN9 divx882 divide -NaN8 1000 -> -NaN8 divx883 divide -NaN7 Inf -> -NaN7 divx884 divide -NaN6 -NaN5 -> -NaN6 divx885 divide -Inf -NaN4 -> -NaN4 divx886 divide -1000 -NaN3 -> -NaN3 divx887 divide Inf -NaN2 -> -NaN2 divx891 divide -sNaN99 -Inf -> -NaN99 Invalid_operation divx892 divide -sNaN98 -1 -> -NaN98 Invalid_operation divx893 divide -sNaN97 NaN -> -NaN97 Invalid_operation divx894 divide -sNaN96 -sNaN94 -> -NaN96 Invalid_operation divx895 divide -NaN95 -sNaN93 -> -NaN93 Invalid_operation divx896 divide -Inf -sNaN92 -> -NaN92 Invalid_operation divx897 divide 0 -sNaN91 -> -NaN91 Invalid_operation divx898 divide Inf -sNaN90 -> -NaN90 Invalid_operation divx899 divide -NaN -sNaN89 -> -NaN89 Invalid_operation maxexponent: 999999999 minexponent: -999999999 -- Various flavours of divide by 0 divx901 divide 0 0 -> NaN Division_undefined divx902 divide 0.0E5 0 -> NaN Division_undefined divx903 divide 0.000 0 -> NaN Division_undefined divx904 divide 0.0001 0 -> Infinity Division_by_zero divx905 divide 0.01 0 -> Infinity Division_by_zero divx906 divide 0.1 0 -> Infinity Division_by_zero divx907 divide 1 0 -> Infinity Division_by_zero divx908 divide 1 0.0 -> Infinity Division_by_zero divx909 divide 10 0.0 -> Infinity Division_by_zero divx910 divide 1E+100 0.0 -> Infinity Division_by_zero divx911 divide 1E+1000 0 -> Infinity Division_by_zero divx921 divide -0.0001 0 -> -Infinity Division_by_zero divx922 divide -0.01 0 -> -Infinity Division_by_zero divx923 divide -0.1 0 -> -Infinity Division_by_zero divx924 divide -1 0 -> -Infinity Division_by_zero divx925 divide -1 0.0 -> -Infinity Division_by_zero divx926 divide -10 0.0 -> -Infinity Division_by_zero divx927 divide -1E+100 0.0 -> -Infinity Division_by_zero divx928 divide -1E+1000 0 -> -Infinity Division_by_zero divx931 divide 0.0001 -0 -> -Infinity Division_by_zero divx932 divide 0.01 -0 -> -Infinity Division_by_zero divx933 divide 0.1 -0 -> -Infinity Division_by_zero divx934 divide 1 -0 -> -Infinity Division_by_zero divx935 divide 1 -0.0 -> -Infinity Division_by_zero divx936 divide 10 -0.0 -> -Infinity Division_by_zero divx937 divide 1E+100 -0.0 -> -Infinity Division_by_zero divx938 divide 1E+1000 -0 -> -Infinity Division_by_zero divx941 divide -0.0001 -0 -> Infinity Division_by_zero divx942 divide -0.01 -0 -> Infinity Division_by_zero divx943 divide -0.1 -0 -> Infinity Division_by_zero divx944 divide -1 -0 -> Infinity Division_by_zero divx945 divide -1 -0.0 -> Infinity Division_by_zero divx946 divide -10 -0.0 -> Infinity Division_by_zero divx947 divide -1E+100 -0.0 -> Infinity Division_by_zero divx948 divide -1E+1000 -0 -> Infinity Division_by_zero -- overflow and underflow tests precision: 9 maxexponent: 999999999 minexponent: -999999999 divx951 divide 9E+999999999 +0.23456789012345E-0 -> Infinity Inexact Overflow Rounded divx952 divide +0.100 9E+999999999 -> 1.111111E-1000000001 Inexact Rounded Underflow Subnormal divx953 divide 9E-999999999 +9.100 -> 9.8901099E-1000000000 Inexact Rounded Underflow Subnormal divx954 divide -1.23456789 9E+999999999 -> -1.3717421E-1000000000 Subnormal divx955 divide -1.23456789012345E-0 9E+999999999 -> -1.3717421E-1000000000 Underflow Subnormal Rounded Inexact divx956 divide -1.23456789012345E-0 7E+999999999 -> -1.7636684E-1000000000 Inexact Rounded Underflow Subnormal divx957 divide 9E+999999999 -0.83456789012345E-0 -> -Infinity Inexact Overflow Rounded divx958 divide -0.100 9E+999999999 -> -1.111111E-1000000001 Subnormal Inexact Rounded Underflow divx959 divide 9E-999999999 -9.100 -> -9.8901099E-1000000000 Inexact Rounded Underflow Subnormal -- overflow and underflow (additional edge tests in multiply.decTest) -- 'subnormal' results now possible (all hard underflow or overflow in -- base arithemtic) divx960 divide 1e-600000000 1e+400000001 -> 1E-1000000001 Subnormal divx961 divide 1e-600000000 1e+400000002 -> 1E-1000000002 Subnormal divx962 divide 1e-600000000 1e+400000003 -> 1E-1000000003 Subnormal divx963 divide 1e-600000000 1e+400000004 -> 1E-1000000004 Subnormal divx964 divide 1e-600000000 1e+400000005 -> 1E-1000000005 Subnormal divx965 divide 1e-600000000 1e+400000006 -> 1E-1000000006 Subnormal divx966 divide 1e-600000000 1e+400000007 -> 1E-1000000007 Subnormal divx967 divide 1e-600000000 1e+400000008 -> 0E-1000000007 Underflow Subnormal Inexact Rounded divx968 divide 1e-600000000 1e+400000009 -> 0E-1000000007 Underflow Subnormal Inexact Rounded divx969 divide 1e-600000000 1e+400000010 -> 0E-1000000007 Underflow Subnormal Inexact Rounded -- [no equivalent of 'subnormal' for overflow] divx970 divide 1e+600000000 1e-400000001 -> Infinity Overflow Inexact Rounded divx971 divide 1e+600000000 1e-400000002 -> Infinity Overflow Inexact Rounded divx972 divide 1e+600000000 1e-400000003 -> Infinity Overflow Inexact Rounded divx973 divide 1e+600000000 1e-400000004 -> Infinity Overflow Inexact Rounded divx974 divide 1e+600000000 1e-400000005 -> Infinity Overflow Inexact Rounded divx975 divide 1e+600000000 1e-400000006 -> Infinity Overflow Inexact Rounded divx976 divide 1e+600000000 1e-400000007 -> Infinity Overflow Inexact Rounded divx977 divide 1e+600000000 1e-400000008 -> Infinity Overflow Inexact Rounded divx978 divide 1e+600000000 1e-400000009 -> Infinity Overflow Inexact Rounded divx979 divide 1e+600000000 1e-400000010 -> Infinity Overflow Inexact Rounded -- Sign after overflow and underflow divx980 divide 1e-600000000 1e+400000009 -> 0E-1000000007 Underflow Subnormal Inexact Rounded divx981 divide 1e-600000000 -1e+400000009 -> -0E-1000000007 Underflow Subnormal Inexact Rounded divx982 divide -1e-600000000 1e+400000009 -> -0E-1000000007 Underflow Subnormal Inexact Rounded divx983 divide -1e-600000000 -1e+400000009 -> 0E-1000000007 Underflow Subnormal Inexact Rounded divx984 divide 1e+600000000 1e-400000009 -> Infinity Overflow Inexact Rounded divx985 divide 1e+600000000 -1e-400000009 -> -Infinity Overflow Inexact Rounded divx986 divide -1e+600000000 1e-400000009 -> -Infinity Overflow Inexact Rounded divx987 divide -1e+600000000 -1e-400000009 -> Infinity Overflow Inexact Rounded -- Long operand overflow may be a different path precision: 3 divx990 divide 1000 9.999E-999999999 -> Infinity Inexact Overflow Rounded divx991 divide 1000 -9.999E-999999999 -> -Infinity Inexact Overflow Rounded divx992 divide 9.999E+999999999 0.01 -> Infinity Inexact Overflow Rounded divx993 divide -9.999E+999999999 0.01 -> -Infinity Inexact Overflow Rounded -- check for double-rounded subnormals precision: 5 maxexponent: 79 minexponent: -79 divx1001 divide 1.52444E-80 1 -> 1.524E-80 Inexact Rounded Subnormal Underflow divx1002 divide 1.52445E-80 1 -> 1.524E-80 Inexact Rounded Subnormal Underflow divx1003 divide 1.52446E-80 1 -> 1.524E-80 Inexact Rounded Subnormal Underflow -- a rounding problem in one implementation precision: 34 rounding: half_up maxExponent: 6144 minExponent: -6143 -- Unbounded answer to 40 digits: -- 1.465811965811965811965811965811965811966E+7000 divx1010 divide 343E6000 234E-1000 -> Infinity Overflow Inexact Rounded -- Null tests divx9998 divide 10 # -> NaN Invalid_operation divx9999 divide # 10 -> NaN Invalid_operation --- NEW FILE: divideint.decTest --- ------------------------------------------------------------------------ -- divideint.decTest -- decimal integer division -- -- Copyright (c) IBM Corporation, 1981, 2004. All rights reserved. -- ------------------------------------------------------------------------ -- Please see the document "General Decimal Arithmetic Testcases" -- -- at http://www2.hursley.ibm.com/decimal for the description of -- -- these testcases. -- -- -- -- These testcases are experimental ('beta' versions), and they -- -- may contain errors. They are offered on an as-is basis. In -- -- particular, achieving the same results as the tests here is not -- -- a guarantee that an implementation complies with any Standard -- -- or specification. The tests are not exhaustive. -- -- -- -- Please send comments, suggestions, and corrections to the author: -- -- Mike Cowlishaw, IBM Fellow -- -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ version: 2.38 extended: 1 precision: 9 rounding: half_up maxExponent: 384 minexponent: -383 dvix001 divideint 1 1 -> 1 dvix002 divideint 2 1 -> 2 dvix003 divideint 1 2 -> 0 dvix004 divideint 2 2 -> 1 dvix005 divideint 0 1 -> 0 dvix006 divideint 0 2 -> 0 dvix007 divideint 1 3 -> 0 dvix008 divideint 2 3 -> 0 dvix009 divideint 3 3 -> 1 dvix010 divideint 2.4 1 -> 2 dvix011 divideint 2.4 -1 -> -2 dvix012 divideint -2.4 1 -> -2 dvix013 divideint -2.4 -1 -> 2 dvix014 divideint 2.40 1 -> 2 dvix015 divideint 2.400 1 -> 2 dvix016 divideint 2.4 2 -> 1 dvix017 divideint 2.400 2 -> 1 dvix018 divideint 2. 2 -> 1 dvix019 divideint 20 20 -> 1 dvix020 divideint 187 187 -> 1 dvix021 divideint 5 2 -> 2 dvix022 divideint 5 2.0 -> 2 dvix023 divideint 5 2.000 -> 2 dvix024 divideint 5 0.200 -> 25 dvix025 divideint 5 0.200 -> 25 dvix030 divideint 1 2 -> 0 dvix031 divideint 1 4 -> 0 dvix032 divideint 1 8 -> 0 dvix033 divideint 1 16 -> 0 dvix034 divideint 1 32 -> 0 dvix035 divideint 1 64 -> 0 dvix040 divideint 1 -2 -> -0 dvix041 divideint 1 -4 -> -0 dvix042 divideint 1 -8 -> -0 dvix043 divideint 1 -16 -> -0 dvix044 divideint 1 -32 -> -0 dvix045 divideint 1 -64 -> -0 dvix050 divideint -1 2 -> -0 dvix051 divideint -1 4 -> -0 dvix052 divideint -1 8 -> -0 dvix053 divideint -1 16 -> -0 dvix054 divideint -1 32 -> -0 dvix055 divideint -1 64 -> -0 dvix060 divideint -1 -2 -> 0 dvix061 divideint -1 -4 -> 0 dvix062 divideint -1 -8 -> 0 dvix063 divideint -1 -16 -> 0 dvix064 divideint -1 -32 -> 0 dvix065 divideint -1 -64 -> 0 -- similar with powers of ten dvix160 divideint 1 1 -> 1 dvix161 divideint 1 10 -> 0 dvix162 divideint 1 100 -> 0 dvix163 divideint 1 1000 -> 0 dvix164 divideint 1 10000 -> 0 dvix165 divideint 1 100000 -> 0 dvix166 divideint 1 1000000 -> 0 dvix167 divideint 1 10000000 -> 0 dvix168 divideint 1 100000000 -> 0 dvix170 divideint 1 -1 -> -1 dvix171 divideint 1 -10 -> -0 dvix172 divideint 1 -100 -> -0 dvix173 divideint 1 -1000 -> -0 dvix174 divideint 1 -10000 -> -0 dvix175 divideint 1 -100000 -> -0 dvix176 divideint 1 -1000000 -> -0 dvix177 divideint 1 -10000000 -> -0 dvix178 divideint 1 -100000000 -> -0 dvix180 divideint -1 1 -> -1 dvix181 divideint -1 10 -> -0 dvix182 divideint -1 100 -> -0 dvix183 divideint -1 1000 -> -0 dvix184 divideint -1 10000 -> -0 dvix185 divideint -1 100000 -> -0 dvix186 divideint -1 1000000 -> -0 dvix187 divideint -1 10000000 -> -0 dvix188 divideint -1 100000000 -> -0 dvix190 divideint -1 -1 -> 1 dvix191 divideint -1 -10 -> 0 dvix192 divideint -1 -100 -> 0 dvix193 divideint -1 -1000 -> 0 dvix194 divideint -1 -10000 -> 0 dvix195 divideint -1 -100000 -> 0 dvix196 divideint -1 -1000000 -> 0 dvix197 divideint -1 -10000000 -> 0 dvix198 divideint -1 -100000000 -> 0 -- some long operand cases here dvix070 divideint 999999999 1 -> 999999999 dvix071 divideint 999999999.4 1 -> 999999999 dvix072 divideint 999999999.5 1 -> 999999999 dvix073 divideint 999999999.9 1 -> 999999999 dvix074 divideint 999999999.999 1 -> 999999999 precision: 6 dvix080 divideint 999999999 1 -> NaN Division_impossible dvix081 divideint 99999999 1 -> NaN Division_impossible dvix082 divideint 9999999 1 -> NaN Division_impossible dvix083 divideint 999999 1 -> 999999 dvix084 divideint 99999 1 -> 99999 dvix085 divideint 9999 1 -> 9999 dvix086 divideint 999 1 -> 999 dvix087 divideint 99 1 -> 99 dvix088 divideint 9 1 -> 9 precision: 9 dvix090 divideint 0. 1 -> 0 dvix091 divideint .0 1 -> 0 dvix092 divideint 0.00 1 -> 0 dvix093 divideint 0.00E+9 1 -> 0 dvix094 divideint 0.0000E-50 1 -> 0 dvix100 divideint 1 1 -> 1 dvix101 divideint 1 2 -> 0 dvix102 divideint 1 3 -> 0 dvix103 divideint 1 4 -> 0 dvix104 divideint 1 5 -> 0 dvix105 divideint 1 6 -> 0 dvix106 divideint 1 7 -> 0 dvix107 divideint 1 8 -> 0 dvix108 divideint 1 9 -> 0 dvix109 divideint 1 10 -> 0 dvix110 divideint 1 1 -> 1 dvix111 divideint 2 1 -> 2 dvix112 divideint 3 1 -> 3 dvix113 divideint 4 1 -> 4 dvix114 divideint 5 1 -> 5 dvix115 divideint 6 1 -> 6 dvix116 divideint 7 1 -> 7 dvix117 divideint 8 1 -> 8 dvix118 divideint 9 1 -> 9 dvix119 divideint 10 1 -> 10 -- from DiagBigDecimal dvix131 divideint 101.3 1 -> 101 dvix132 divideint 101.0 1 -> 101 dvix133 divideint 101.3 3 -> 33 dvix134 divideint 101.0 3 -> 33 dvix135 divideint 2.4 1 -> 2 dvix136 divideint 2.400 1 -> 2 dvix137 divideint 18 18 -> 1 dvix138 divideint 1120 1000 -> 1 dvix139 divideint 2.4 2 -> 1 dvix140 divideint 2.400 2 -> 1 dvix141 divideint 0.5 2.000 -> 0 dvix142 divideint 8.005 7 -> 1 dvix143 divideint 5 2 -> 2 dvix144 divideint 0 2 -> 0 dvix145 divideint 0.00 2 -> 0 -- Others dvix150 divideint 12345 4.999 -> 2469 dvix151 divideint 12345 4.99 -> 2473 dvix152 divideint 12345 4.9 -> 2519 dvix153 divideint 12345 5 -> 2469 dvix154 divideint 12345 5.1 -> 2420 dvix155 divideint 12345 5.01 -> 2464 dvix156 divideint 12345 5.001 -> 2468 dvix157 divideint 101 7.6 -> 13 -- Various flavours of divideint by 0 maxexponent: 999999999 minexponent: -999999999 dvix201 divideint 0 0 -> NaN Division_undefined dvix202 divideint 0.0E5 0 -> NaN Division_undefined dvix203 divideint 0.000 0 -> NaN Division_undefined dvix204 divideint 0.0001 0 -> Infinity Division_by_zero dvix205 divideint 0.01 0 -> Infinity Division_by_zero dvix206 divideint 0.1 0 -> Infinity Division_by_zero dvix207 divideint 1 0 -> Infinity Division_by_zero dvix208 divideint 1 0.0 -> Infinity Division_by_zero dvix209 divideint 10 0.0 -> Infinity Division_by_zero dvix210 divideint 1E+100 0.0 -> Infinity Division_by_zero dvix211 divideint 1E+1000 0 -> Infinity Division_by_zero dvix214 divideint -0.0001 0 -> -Infinity Division_by_zero dvix215 divideint -0.01 0 -> -Infinity Division_by_zero dvix216 divideint -0.1 0 -> -Infinity Division_by_zero dvix217 divideint -1 0 -> -Infinity Division_by_zero dvix218 divideint -1 0.0 -> -Infinity Division_by_zero dvix219 divideint -10 0.0 -> -Infinity Division_by_zero dvix220 divideint -1E+100 0.0 -> -Infinity Division_by_zero dvix221 divideint -1E+1000 0 -> -Infinity Division_by_zero -- test some cases that are close to exponent overflow maxexponent: 999999999 minexponent: -999999999 dvix270 divideint 1 1e999999999 -> 0 dvix271 divideint 1 0.9e999999999 -> 0 dvix272 divideint 1 0.99e999999999 -> 0 dvix273 divideint 1 0.999999999e999999999 -> 0 dvix274 divideint 9e999999999 1 -> NaN Division_impossible dvix275 divideint 9.9e999999999 1 -> NaN Division_impossible dvix276 divideint 9.99e999999999 1 -> NaN Division_impossible dvix277 divideint 9.99999999e999999999 1 -> NaN Division_impossible dvix280 divideint 0.1 9e-999999999 -> NaN Division_impossible dvix281 divideint 0.1 99e-999999999 -> NaN Division_impossible dvix282 divideint 0.1 999e-999999999 -> NaN Division_impossible dvix283 divideint 0.1 9e-999999998 -> NaN Division_impossible dvix284 divideint 0.1 99e-999999998 -> NaN Division_impossible dvix285 divideint 0.1 999e-999999998 -> NaN Division_impossible dvix286 divideint 0.1 999e-999999997 -> NaN Division_impossible dvix287 divideint 0.1 9999e-999999997 -> NaN Division_impossible dvix288 divideint 0.1 99999e-999999997 -> NaN Division_impossible -- overflow and underflow tests [from divide] maxexponent: 999999999 minexponent: -999999999 dvix330 divideint +1.23456789012345E-0 9E+999999999 -> 0 dvix331 divideint 9E+999999999 +0.23456789012345E-0 -> NaN Division_impossible dvix332 divideint +0.100 9E+999999999 -> 0 dvix333 divideint 9E-999999999 +9.100 -> 0 dvix335 divideint -1.23456789012345E-0 9E+999999999 -> -0 dvix336 divideint 9E+999999999 -0.83456789012345E-0 -> NaN Division_impossible dvix337 divideint -0.100 9E+999999999 -> -0 dvix338 divideint 9E-999999999 -9.100 -> -0 -- long operand checks maxexponent: 999 minexponent: -999 precision: 9 dvix401 divideint 12345678000 100 -> 123456780 dvix402 divideint 1 12345678000 -> 0 dvix403 divideint 1234567800 10 -> 123456780 dvix404 divideint 1 1234567800 -> 0 dvix405 divideint 1234567890 10 -> 123456789 dvix406 divideint 1 1234567890 -> 0 dvix407 divideint 1234567891 10 -> 123456789 dvix408 divideint 1 1234567891 -> 0 dvix409 divideint 12345678901 100 -> 123456789 dvix410 divideint 1 12345678901 -> 0 dvix411 divideint 1234567896 10 -> 123456789 dvix412 divideint 1 1234567896 -> 0 dvix413 divideint 12345678948 100 -> 123456789 dvix414 divideint 12345678949 100 -> 123456789 dvix415 divideint 12345678950 100 -> 123456789 dvix416 divideint 12345678951 100 -> 123456789 dvix417 divideint 12345678999 100 -> 123456789 precision: 15 dvix441 divideint 12345678000 1 -> 12345678000 dvix442 divideint 1 12345678000 -> 0 dvix443 divideint 1234567800 1 -> 1234567800 dvix444 divideint 1 1234567800 -> 0 dvix445 divideint 1234567890 1 -> 1234567890 dvix446 divideint 1 1234567890 -> 0 dvix447 divideint 1234567891 1 -> 1234567891 dvix448 divideint 1 1234567891 -> 0 dvix449 divideint 12345678901 1 -> 12345678901 dvix450 divideint 1 12345678901 -> 0 dvix451 divideint 1234567896 1 -> 1234567896 dvix452 divideint 1 1234567896 -> 0 precision: 9 rounding: half_up maxExponent: 999 minexponent: -999 -- more zeros, etc. dvix531 divideint 5.00 1E-3 -> 5000 dvix532 divideint 00.00 0.000 -> NaN Division_undefined dvix533 divideint 00.00 0E-3 -> NaN Division_undefined dvix534 divideint 0 -0 -> NaN Division_undefined dvix535 divideint -0 0 -> NaN Division_undefined dvix536 divideint -0 -0 -> NaN Division_undefined dvix541 divideint 0 -1 -> -0 dvix542 divideint -0 -1 -> 0 dvix543 divideint 0 1 -> 0 dvix544 divideint -0 1 -> -0 dvix545 divideint -1 0 -> -Infinity Division_by_zero dvix546 divideint -1 -0 -> Infinity Division_by_zero dvix547 divideint 1 0 -> Infinity Division_by_zero dvix548 divideint 1 -0 -> -Infinity Division_by_zero dvix551 divideint 0.0 -1 -> -0 dvix552 divideint -0.0 -1 -> 0 dvix553 divideint 0.0 1 -> 0 dvix554 divideint -0.0 1 -> -0 dvix555 divideint -1.0 0 -> -Infinity Division_by_zero dvix556 divideint -1.0 -0 -> Infinity Division_by_zero dvix557 divideint 1.0 0 -> Infinity Division_by_zero dvix558 divideint 1.0 -0 -> -Infinity Division_by_zero dvix561 divideint 0 -1.0 -> -0 dvix562 divideint -0 -1.0 -> 0 dvix563 divideint 0 1.0 -> 0 dvix564 divideint -0 1.0 -> -0 dvix565 divideint -1 0.0 -> -Infinity Division_by_zero dvix566 divideint -1 -0.0 -> Infinity Division_by_zero dvix567 divideint 1 0.0 -> Infinity Division_by_zero dvix568 divideint 1 -0.0 -> -Infinity Division_by_zero dvix571 divideint 0.0 -1.0 -> -0 dvix572 divideint -0.0 -1.0 -> 0 dvix573 divideint 0.0 1.0 -> 0 dvix574 divideint -0.0 1.0 -> -0 dvix575 divideint -1.0 0.0 -> -Infinity Division_by_zero dvix576 divideint -1.0 -0.0 -> Infinity Division_by_zero dvix577 divideint 1.0 0.0 -> Infinity Division_by_zero dvix578 divideint 1.0 -0.0 -> -Infinity Division_by_zero -- Specials dvix580 divideint Inf -Inf -> NaN Invalid_operation dvix581 divideint Inf -1000 -> -Infinity dvix582 divideint Inf -1 -> -Infinity dvix583 divideint Inf -0 -> -Infinity dvix584 divideint Inf 0 -> Infinity dvix585 divideint Inf 1 -> Infinity dvix586 divideint Inf 1000 -> Infinity dvix587 divideint Inf Inf -> NaN Invalid_operation dvix588 divideint -1000 Inf -> -0 dvix589 divideint -Inf Inf -> NaN Invalid_operation dvix590 divideint -1 Inf -> -0 dvix591 divideint -0 Inf -> -0 dvix592 divideint 0 Inf -> 0 dvix593 divideint 1 Inf -> 0 dvix594 divideint 1000 Inf -> 0 dvix595 divideint Inf Inf -> NaN Invalid_operation dvix600 divideint -Inf -Inf -> NaN Invalid_operation dvix601 divideint -Inf -1000 -> Infinity dvix602 divideint -Inf -1 -> Infinity dvix603 divideint -Inf -0 -> Infinity dvix604 divideint -Inf 0 -> -Infinity dvix605 divideint -Inf 1 -> -Infinity dvix606 divideint -Inf 1000 -> -Infinity dvix607 divideint -Inf Inf -> NaN Invalid_operation dvix608 divideint -1000 Inf -> -0 dvix609 divideint -Inf -Inf -> NaN Invalid_operation dvix610 divideint -1 -Inf -> 0 dvix611 divideint -0 -Inf -> 0 dvix612 divideint 0 -Inf -> -0 dvix613 divideint 1 -Inf -> -0 dvix614 divideint 1000 -Inf -> -0 dvix615 divideint Inf -Inf -> NaN Invalid_operation dvix621 divideint NaN -Inf -> NaN dvix622 divideint NaN -1000 -> NaN dvix623 divideint NaN -1 -> NaN dvix624 divideint NaN -0 -> NaN dvix625 divideint NaN 0 -> NaN dvix626 divideint NaN 1 -> NaN dvix627 divideint NaN 1000 -> NaN dvix628 divideint NaN Inf -> NaN dvix629 divideint NaN NaN -> NaN dvix630 divideint -Inf NaN -> NaN dvix631 divideint -1000 NaN -> NaN dvix632 divideint -1 NaN -> NaN dvix633 divideint -0 NaN -> NaN dvix634 divideint 0 NaN -> NaN dvix635 divideint 1 NaN -> NaN dvix636 divideint 1000 NaN -> NaN dvix637 divideint Inf NaN -> NaN dvix641 divideint sNaN -Inf -> NaN Invalid_operation dvix642 divideint sNaN -1000 -> NaN Invalid_operation dvix643 divideint sNaN -1 -> NaN Invalid_operation dvix644 divideint sNaN -0 -> NaN Invalid_operation dvix645 divideint sNaN 0 -> NaN Invalid_operation dvix646 divideint sNaN 1 -> NaN Invalid_operation dvix647 divideint sNaN 1000 -> NaN Invalid_operation dvix648 divideint sNaN NaN -> NaN Invalid_operation dvix649 divideint sNaN sNaN -> NaN Invalid_operation dvix650 divideint NaN sNaN -> NaN Invalid_operation dvix651 divideint -Inf sNaN -> NaN Invalid_operation dvix652 divideint -1000 sNaN -> NaN Invalid_operation dvix653 divideint -1 sNaN -> NaN Invalid_operation dvix654 divideint -0 sNaN -> NaN Invalid_operation dvix655 divideint 0 sNaN -> NaN Invalid_operation dvix656 divideint 1 sNaN -> NaN Invalid_operation dvix657 divideint 1000 sNaN -> NaN Invalid_operation dvix658 divideint Inf sNaN -> NaN Invalid_operation dvix659 divideint NaN sNaN -> NaN Invalid_operation -- propagating NaNs dvix661 divideint NaN9 -Inf -> NaN9 dvix662 divideint NaN8 1000 -> NaN8 dvix663 divideint NaN7 Inf -> NaN7 dvix664 divideint -NaN6 NaN5 -> -NaN6 dvix665 divideint -Inf NaN4 -> NaN4 dvix666 divideint -1000 NaN3 -> NaN3 dvix667 divideint Inf -NaN2 -> -NaN2 dvix671 divideint -sNaN99 -Inf -> -NaN99 Invalid_operation dvix672 divideint sNaN98 -1 -> NaN98 Invalid_operation dvix673 divideint sNaN97 NaN -> NaN97 Invalid_operation dvix674 divideint sNaN96 sNaN94 -> NaN96 Invalid_operation dvix675 divideint NaN95 sNaN93 -> NaN93 Invalid_operation dvix676 divideint -Inf sNaN92 -> NaN92 Invalid_operation dvix677 divideint 0 sNaN91 -> NaN91 Invalid_operation dvix678 divideint Inf -sNaN90 -> -NaN90 Invalid_operation dvix679 divideint NaN sNaN89 -> NaN89 Invalid_operation -- some long operand cases again precision: 8 dvix710 divideint 100000001 1 -> NaN Division_impossible dvix711 divideint 100000000.4 1 -> NaN Division_impossible dvix712 divideint 100000000.5 1 -> NaN Division_impossible dvix713 divideint 100000000.9 1 -> NaN Division_impossible dvix714 divideint 100000000.999 1 -> NaN Division_impossible precision: 6 dvix720 divideint 100000000 1 -> NaN Division_impossible dvix721 divideint 10000000 1 -> NaN Division_impossible dvix722 divideint 1000000 1 -> NaN Division_impossible dvix723 divideint 100000 1 -> 100000 dvix724 divideint 10000 1 -> 10000 dvix725 divideint 1000 1 -> 1000 dvix726 divideint 100 1 -> 100 dvix727 divideint 10 1 -> 10 dvix728 divideint 1 1 -> 1 dvix729 divideint 1 10 -> 0 precision: 9 maxexponent: 999999999 minexponent: -999999999 dvix732 divideint 1 0.99e999999999 -> 0 dvix733 divideint 1 0.999999999e999999999 -> 0 dvix734 divideint 9e999999999 1 -> NaN Division_impossible dvix735 divideint 9.9e999999999 1 -> NaN Division_impossible dvix736 divideint 9.99e999999999 1 -> NaN Division_impossible dvix737 divideint 9.99999999e999999999 1 -> NaN Division_impossible dvix740 divideint 0.1 9e-999999999 -> NaN Division_impossible dvix741 divideint 0.1 99e-999999999 -> NaN Division_impossible dvix742 divideint 0.1 999e-999999999 -> NaN Division_impossible dvix743 divideint 0.1 9e-999999998 -> NaN Division_impossible dvix744 divideint 0.1 99e-999999998 -> NaN Division_impossible dvix745 divideint 0.1 999e-999999998 -> NaN Division_impossible dvix746 divideint 0.1 999e-999999997 -> NaN Division_impossible dvix747 divideint 0.1 9999e-999999997 -> NaN Division_impossible dvix748 divideint 0.1 99999e-999999997 -> NaN Division_impossible -- Null tests dvix900 divideint 10 # -> NaN Invalid_operation dvix901 divideint # 10 -> NaN Invalid_operation --- NEW FILE: inexact.decTest --- ------------------------------------------------------------------------ -- inexact.decTest -- decimal inexact and rounded edge cases -- -- Copyright (c) IBM Corporation, 1981, 2003. All rights reserved. -- ------------------------------------------------------------------------ -- Please see the document "General Decimal Arithmetic Testcases" -- -- at http://www2.hursley.ibm.com/decimal for the description of -- -- these testcases. -- -- -- -- These testcases are experimental ('beta' versions), and they -- -- may contain errors. They are offered on an as-is basis. In -- -- particular, achieving the same results as the tests here is not -- -- a guarantee that an implementation complies with any Standard -- -- or specification. The tests are not exhaustive. -- -- -- -- Please send comments, suggestions, and corrections to the author: -- -- Mike Cowlishaw, IBM Fellow -- -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ version: 2.38 extended: 1 precision: 9 rounding: half_up maxExponent: 999 minexponent: -999 inx001 add 1 1 -> 2 inx002 add 123456789 0 -> 123456789 inx003 add 123456789 0.0 -> 123456789 Rounded inx004 add 123456789 0.00 -> 123456789 Rounded inx005 add 123456789 1 -> 123456790 inx006 add 123456789 0.1 -> 123456789 Inexact Rounded inx007 add 123456789 0.01 -> 123456789 Inexact Rounded inx008 add 123456789 0.001 -> 123456789 Inexact Rounded inx009 add 123456789 0.000001 -> 123456789 Inexact Rounded inx010 add 123456789 0.000000001 -> 123456789 Inexact Rounded inx011 add 123456789 0.000000000001 -> 123456789 Inexact Rounded inx012 add 123456789 0.9 -> 123456790 Inexact Rounded inx013 add 123456789 0.09 -> 123456789 Inexact Rounded inx014 add 123456789 0.009 -> 123456789 Inexact Rounded inx015 add 123456789 0.000009 -> 123456789 Inexact Rounded inx016 add 123456789 0.000000009 -> 123456789 Inexact Rounded inx017 add 123456789 0.000000000009 -> 123456789 Inexact Rounded inx021 add 1 -1 -> 0 inx022 add 123456789 -0 -> 123456789 inx023 add 123456789 -0.0 -> 123456789 Rounded inx024 add 123456789 -0.00 -> 123456789 Rounded inx025 add 123456789 -1 -> 123456788 inx026 add 123456789 -0.1 -> 123456789 Inexact Rounded inx027 add 123456789 -0.01 -> 123456789 Inexact Rounded inx028 add 123456789 -0.001 -> 123456789 Inexact Rounded inx029 add 123456789 -0.000001 -> 123456789 Inexact Rounded inx030 add 123456789 -0.000000001 -> 123456789 Inexact Rounded inx031 add 123456789 -0.000000000001 -> 123456789 Inexact Rounded inx032 add 123456789 -0.9 -> 123456788 Inexact Rounded inx033 add 123456789 -0.09 -> 123456789 Inexact Rounded inx034 add 123456789 -0.009 -> 123456789 Inexact Rounded inx035 add 123456789 -0.000009 -> 123456789 Inexact Rounded inx036 add 123456789 -0.000000009 -> 123456789 Inexact Rounded inx037 add 123456789 -0.000000000009 -> 123456789 Inexact Rounded inx042 add 0 123456789 -> 123456789 inx043 add 0.0 123456789 -> 123456789 Rounded inx044 add 0.00 123456789 -> 123456789 Rounded inx045 add 1 123456789 -> 123456790 inx046 add 0.1 123456789 -> 123456789 Inexact Rounded inx047 add 0.01 123456789 -> 123456789 Inexact Rounded inx048 add 0.001 123456789 -> 123456789 Inexact Rounded inx049 add 0.000001 123456789 -> 123456789 Inexact Rounded inx050 add 0.000000001 123456789 -> 123456789 Inexact Rounded inx051 add 0.000000000001 123456789 -> 123456789 Inexact Rounded inx052 add 0.9 123456789 -> 123456790 Inexact Rounded inx053 add 0.09 123456789 -> 123456789 Inexact Rounded inx054 add 0.009 123456789 -> 123456789 Inexact Rounded inx055 add 0.000009 123456789 -> 123456789 Inexact Rounded inx056 add 0.000000009 123456789 -> 123456789 Inexact Rounded inx057 add 0.000000000009 123456789 -> 123456789 Inexact Rounded inx062 add -0 123456789 -> 123456789 inx063 add -0.0 123456789 -> 123456789 Rounded inx064 add -0.00 123456789 -> 123456789 Rounded inx065 add -1 123456789 -> 123456788 inx066 add -0.1 123456789 -> 123456789 Inexact Rounded inx067 add -0.01 123456789 -> 123456789 Inexact Rounded inx068 add -0.001 123456789 -> 123456789 Inexact Rounded inx069 add -0.000001 123456789 -> 123456789 Inexact Rounded inx070 add -0.000000001 123456789 -> 123456789 Inexact Rounded inx071 add -0.000000000001 123456789 -> 123456789 Inexact Rounded inx072 add -0.9 123456789 -> 123456788 Inexact Rounded inx073 add -0.09 123456789 -> 123456789 Inexact Rounded inx074 add -0.009 123456789 -> 123456789 Inexact Rounded inx075 add -0.000009 123456789 -> 123456789 Inexact Rounded inx076 add -0.000000009 123456789 -> 123456789 Inexact Rounded inx077 add -0.000000000009 123456789 -> 123456789 Inexact Rounded -- some boundaries inx081 add 999999999 0 -> 999999999 inx082 add 0.999999999 0.000000000 -> 0.999999999 inx083 add 999999999 1 -> 1.00000000E+9 Rounded inx084 add 0.999999999 0.000000001 -> 1.00000000 Rounded inx085 add 999999999 2 -> 1.00000000E+9 Inexact Rounded inx086 add 0.999999999 0.000000002 -> 1.00000000 Inexact Rounded inx087 add 999999999 3 -> 1.00000000E+9 Inexact Rounded inx089 add 0.999999999 0.000000003 -> 1.00000000 Inexact Rounded -- minus, plus, and subtract all assumed to work like add. -- multiply precision: 8 inx101 multiply 1000 1000 -> 1000000 inx102 multiply 9000 9000 -> 81000000 inx103 multiply 9999 9999 -> 99980001 inx104 multiply 1000 10000 -> 10000000 inx105 multiply 10000 10000 -> 1.0000000E+8 Rounded inx106 multiply 10001 10000 -> 1.0001000E+8 Rounded inx107 multiply 10001 10001 -> 1.0002000E+8 Inexact Rounded inx108 multiply 10101 10001 -> 1.0102010E+8 Inexact Rounded inx109 multiply 10001 10101 -> 1.0102010E+8 Inexact Rounded -- divide precision: 4 inx201 divide 1000 1000 -> 1 inx202 divide 1000 1 -> 1000 inx203 divide 1000 2 -> 500 inx204 divide 1000 3 -> 333.3 Inexact Rounded inx205 divide 1000 4 -> 250 inx206 divide 1000 5 -> 200 inx207 divide 1000 6 -> 166.7 Inexact Rounded inx208 divide 1000 7 -> 142.9 Inexact Rounded inx209 divide 1000 8 -> 125 inx210 divide 1000 9 -> 111.1 Inexact Rounded inx211 divide 1000 10 -> 100 inx220 divide 1 1 -> 1 inx221 divide 1 2 -> 0.5 inx222 divide 1 4 -> 0.25 inx223 divide 1 8 -> 0.125 inx224 divide 1 16 -> 0.0625 inx225 divide 1 32 -> 0.03125 inx226 divide 1 64 -> 0.01563 Inexact Rounded inx227 divide 1 128 -> 0.007813 Inexact Rounded precision: 5 inx230 divide 1 1 -> 1 inx231 divide 1 2 -> 0.5 inx232 divide 1 4 -> 0.25 inx233 divide 1 8 -> 0.125 inx234 divide 1 16 -> 0.0625 inx235 divide 1 32 -> 0.03125 inx236 divide 1 64 -> 0.015625 inx237 divide 1 128 -> 0.0078125 precision: 3 inx240 divide 1 1 -> 1 inx241 divide 1 2 -> 0.5 inx242 divide 1 4 -> 0.25 inx243 divide 1 8 -> 0.125 inx244 divide 1 16 -> 0.0625 inx245 divide 1 32 -> 0.0313 Inexact Rounded inx246 divide 1 64 -> 0.0156 Inexact Rounded inx247 divide 1 128 -> 0.00781 Inexact Rounded precision: 2 inx250 divide 1 1 -> 1 inx251 divide 1 2 -> 0.5 inx252 divide 1 4 -> 0.25 inx253 divide 1 8 -> 0.13 Inexact Rounded inx254 divide 1 16 -> 0.063 Inexact Rounded inx255 divide 1 32 -> 0.031 Inexact Rounded inx256 divide 1 64 -> 0.016 Inexact Rounded inx257 divide 1 128 -> 0.0078 Inexact Rounded precision: 1 inx260 divide 1 1 -> 1 inx261 divide 1 2 -> 0.5 inx262 divide 1 4 -> 0.3 Inexact Rounded inx263 divide 1 8 -> 0.1 Inexact Rounded inx264 divide 1 16 -> 0.06 Inexact Rounded inx265 divide 1 32 -> 0.03 Inexact Rounded inx266 divide 1 64 -> 0.02 Inexact Rounded inx267 divide 1 128 -> 0.008 Inexact Rounded -- power precision: 4 inx301 power 0.5 2 -> 0.25 inx302 power 0.5 4 -> 0.0625 inx303 power 0.5 8 -> 0.003906 Inexact Rounded inx304 power 0.5 16 -> 0.00001526 Inexact Rounded inx305 power 0.5 32 -> 2.328E-10 Inexact Rounded -- compare, divideInteger, and remainder are always exact -- rescale precision: 4 inx401 rescale 0 0 -> 0 inx402 rescale 1 0 -> 1 inx403 rescale 0.1 +2 -> 0E+2 Inexact Rounded inx404 rescale 0.1 +1 -> 0E+1 Inexact Rounded inx405 rescale 0.1 0 -> 0 Inexact Rounded inx406 rescale 0.1 -1 -> 0.1 inx407 rescale 0.1 -2 -> 0.10 -- long operands cause rounding too precision: 9 inx801 plus 123456789 -> 123456789 inx802 plus 1234567890 -> 1.23456789E+9 Rounded inx803 plus 1234567891 -> 1.23456789E+9 Inexact Rounded inx804 plus 1234567892 -> 1.23456789E+9 Inexact Rounded inx805 plus 1234567899 -> 1.23456790E+9 Inexact Rounded inx806 plus 1234567900 -> 1.23456790E+9 Rounded --- NEW FILE: integer.decTest --- ------------------------------------------------------------------------ -- integer.decTest -- round decimal to integer -- -- Copyright (c) IBM Corporation, 2001, 2003. All rights reserved. -- ------------------------------------------------------------------------ -- Please see the document "General Decimal Arithmetic Testcases" -- -- at http://www2.hursley.ibm.com/decimal for the description of -- -- these testcases. -- -- -- -- These testcases are experimental ('beta' versions), and they -- -- may contain errors. They are offered on an as-is basis. In -- -- particular, achieving the same results as the tests here is not -- -- a guarantee that an implementation complies with any Standard -- -- or specification. The tests are not exhaustive. -- -- -- -- Please send comments, suggestions, and corrections to the author: -- -- Mike Cowlishaw, IBM Fellow -- -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ version: 2.26 -- This set of tests tests the extended specification 'round-to-integer' -- operation (from IEEE 854). All non-zero results are defined as -- being those from either plus or rescale, so those are assumed to have -- been tested. extended: 1 precision: 9 rounding: half_up maxExponent: 999 minExponent: -999 intx001 integer 0 -> 0 intx002 integer 0.0 -> 0 intx003 integer 0.1 -> 0 Rounded Inexact intx004 integer 0.2 -> 0 Rounded Inexact intx005 integer 0.3 -> 0 Rounded Inexact intx006 integer 0.4 -> 0 Rounded Inexact intx007 integer 0.5 -> 1 Rounded Inexact intx008 integer 0.6 -> 1 Rounded Inexact intx009 integer 0.7 -> 1 Rounded Inexact intx010 integer 0.8 -> 1 Rounded Inexact intx011 integer 0.9 -> 1 Rounded Inexact intx012 integer 1 -> 1 intx013 integer 1.0 -> 1 Rounded intx014 integer 1.1 -> 1 Rounded Inexact intx015 integer 1.2 -> 1 Rounded Inexact intx016 integer 1.3 -> 1 Rounded Inexact intx017 integer 1.4 -> 1 Rounded Inexact intx018 integer 1.5 -> 2 Rounded Inexact intx019 integer 1.6 -> 2 Rounded Inexact intx020 integer 1.7 -> 2 Rounded Inexact intx021 integer 1.8 -> 2 Rounded Inexact intx022 integer 1.9 -> 2 Rounded Inexact -- negatives intx031 integer -0 -> -0 intx032 integer -0.0 -> -0 intx033 integer -0.1 -> -0 Rounded Inexact intx034 integer -0.2 -> -0 Rounded Inexact intx035 integer -0.3 -> -0 Rounded Inexact intx036 integer -0.4 -> -0 Rounded Inexact intx037 integer -0.5 -> -1 Rounded Inexact intx038 integer -0.6 -> -1 Rounded Inexact intx039 integer -0.7 -> -1 Rounded Inexact intx040 integer -0.8 -> -1 Rounded Inexact intx041 integer -0.9 -> -1 Rounded Inexact intx042 integer -1 -> -1 intx043 integer -1.0 -> -1 Rounded intx044 integer -1.1 -> -1 Rounded Inexact intx045 integer -1.2 -> -1 Rounded Inexact intx046 integer -1.3 -> -1 Rounded Inexact intx047 integer -1.4 -> -1 Rounded Inexact intx048 integer -1.5 -> -2 Rounded Inexact intx049 integer -1.6 -> -2 Rounded Inexact intx050 integer -1.7 -> -2 Rounded Inexact intx051 integer -1.8 -> -2 Rounded Inexact intx052 integer -1.9 -> -2 Rounded Inexact intx053 integer 10E+30 -> NaN Invalid_operation intx054 integer -10E+30 -> NaN Invalid_operation -- numbers around precision precision: 9 intx060 integer '56267E-10' -> '0' Inexact Rounded intx061 integer '56267E-5' -> '1' Inexact Rounded intx062 integer '56267E-2' -> '563' Inexact Rounded intx063 integer '56267E-1' -> '5627' Inexact Rounded intx065 integer '56267E-0' -> '56267' intx066 integer '56267E+0' -> '56267' intx067 integer '56267E+1' -> '562670' intx068 integer '56267E+2' -> '5626700' intx069 integer '56267E+3' -> '56267000' intx070 integer '56267E+4' -> '562670000' intx071 integer '56267E+5' -> NaN Invalid_operation intx072 integer '56267E+6' -> NaN Invalid_operation intx080 integer '-56267E-10' -> '-0' Inexact Rounded intx081 integer '-56267E-5' -> '-1' Inexact Rounded intx082 integer '-56267E-2' -> '-563' Inexact Rounded intx083 integer '-56267E-1' -> '-5627' Inexact Rounded intx085 integer '-56267E-0' -> '-56267' intx086 integer '-56267E+0' -> '-56267' intx087 integer '-56267E+1' -> '-562670' intx088 integer '-56267E+2' -> '-5626700' intx089 integer '-56267E+3' -> '-56267000' intx090 integer '-56267E+4' -> '-562670000' intx091 integer '-56267E+5' -> NaN Invalid_operation intx092 integer '-56267E+6' -> NaN Invalid_operation -- specials and zeros intx120 integer 'Inf' -> NaN Invalid_operation intx121 integer '-Inf' -> NaN Invalid_operation intx122 integer NaN -> NaN intx123 integer sNaN -> NaN Invalid_operation intx124 integer 0 -> 0 intx125 integer -0 -> -0 intx126 integer 0.000 -> 0 intx127 integer 0.00 -> 0 intx128 integer 0.0 -> 0 intx129 integer 0 -> 0 intx130 integer 0E-3 -> 0 intx131 integer 0E-2 -> 0 intx132 integer 0E-1 -> 0 intx133 integer 0E-0 -> 0 intx134 integer 0E+1 -> 0 intx135 integer 0E+2 -> 0 intx136 integer 0E+3 -> 0 intx137 integer 0E+4 -> 0 intx138 integer 0E+5 -> 0 intx139 integer -0.000 -> -0 intx140 integer -0.00 -> -0 intx141 integer -0.0 -> -0 intx142 integer -0 -> -0 intx143 integer -0E-3 -> -0 intx144 integer -0E-2 -> -0 intx145 integer -0E-1 -> -0 intx146 integer -0E-0 -> -0 intx147 integer -0E+1 -> -0 intx148 integer -0E+2 -> -0 intx149 integer -0E+3 -> -0 intx150 integer -0E+4 -> -0 intx151 integer -0E+5 -> -0 -- examples rounding: half_up precision: 9 intx200 integer 2.1 -> 2 Rounded Inexact intx201 integer 100 -> 100 intx202 integer 100.0 -> 100 Rounded intx203 integer 101.5 -> 102 Rounded Inexact intx204 integer -101.5 -> -102 Rounded Inexact intx205 integer 10E+5 -> 1000000 --- NEW FILE: max.decTest --- ------------------------------------------------------------------------ -- max.decTest -- decimal maximum -- -- Copyright (c) IBM Corporation, 1981, 2004. All rights reserved. -- ------------------------------------------------------------------------ -- Please see the document "General Decimal Arithmetic Testcases" -- -- at http://www2.hursley.ibm.com/decimal for the description of -- -- these testcases. -- -- -- -- These testcases are experimental ('beta' versions), and they -- -- may contain errors. They are offered on an as-is basis. In -- -- particular, achieving the same results as the tests here is not -- -- a guarantee that an implementation complies with any Standard -- -- or specification. The tests are not exhaustive. -- -- -- -- Please send comments, suggestions, and corrections to the author: -- -- Mike Cowlishaw, IBM Fellow -- -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ version: 2.38 -- we assume that base comparison is tested in compare.decTest, so -- these mainly cover special cases and rounding extended: 1 precision: 9 rounding: half_up maxExponent: 384 minexponent: -383 -- sanity checks maxx001 max -2 -2 -> -2 maxx002 max -2 -1 -> -1 maxx003 max -2 0 -> 0 maxx004 max -2 1 -> 1 maxx005 max -2 2 -> 2 maxx006 max -1 -2 -> -1 maxx007 max -1 -1 -> -1 maxx008 max -1 0 -> 0 maxx009 max -1 1 -> 1 maxx010 max -1 2 -> 2 maxx011 max 0 -2 -> 0 maxx012 max 0 -1 -> 0 maxx013 max 0 0 -> 0 maxx014 max 0 1 -> 1 maxx015 max 0 2 -> 2 maxx016 max 1 -2 -> 1 maxx017 max 1 -1 -> 1 maxx018 max 1 0 -> 1 maxx019 max 1 1 -> 1 maxx020 max 1 2 -> 2 maxx021 max 2 -2 -> 2 maxx022 max 2 -1 -> 2 maxx023 max 2 0 -> 2 maxx025 max 2 1 -> 2 maxx026 max 2 2 -> 2 -- extended zeros maxx030 max 0 0 -> 0 maxx031 max 0 -0 -> 0 maxx032 max 0 -0.0 -> 0 maxx033 max 0 0.0 -> 0 maxx034 max -0 0 -> -0 -- note: -0 = 0 maxx035 max -0 -0 -> -0 maxx036 max -0 -0.0 -> -0 maxx037 max -0 0.0 -> -0 maxx038 max 0.0 0 -> 0.0 maxx039 max 0.0 -0 -> 0.0 maxx040 max 0.0 -0.0 -> 0.0 maxx041 max 0.0 0.0 -> 0.0 maxx042 max -0.0 0 -> -0.0 maxx043 max -0.0 -0 -> -0.0 maxx044 max -0.0 -0.0 -> -0.0 maxx045 max -0.0 0.0 -> -0.0 maxx046 max -0E1 0E2 -> -0E+1 maxx047 max 0E2 0E1 -> 0E+2 maxx048 max 0E1 0E2 -> 0E+1 maxx049 max -0E3 -0E2 -> -0E+3 -- Specials precision: 9 maxx090 max Inf -Inf -> Infinity maxx091 max Inf -1000 -> Infinity maxx092 max Inf -1 -> Infinity maxx093 max Inf -0 -> Infinity maxx094 max Inf 0 -> Infinity maxx095 max Inf 1 -> Infinity maxx096 max Inf 1000 -> Infinity maxx097 max Inf Inf -> Infinity maxx098 max -1000 Inf -> Infinity maxx099 max -Inf Inf -> Infinity maxx100 max -1 Inf -> Infinity maxx101 max -0 Inf -> Infinity maxx102 max 0 Inf -> Infinity maxx103 max 1 Inf -> Infinity maxx104 max 1000 Inf -> Infinity maxx105 max Inf Inf -> Infinity maxx120 max -Inf -Inf -> -Infinity maxx121 max -Inf -1000 -> -1000 maxx122 max -Inf -1 -> -1 maxx123 max -Inf -0 -> -0 maxx124 max -Inf 0 -> 0 maxx125 max -Inf 1 -> 1 maxx126 max -Inf 1000 -> 1000 maxx127 max -Inf Inf -> Infinity maxx128 max -Inf -Inf -> -Infinity maxx129 max -1000 -Inf -> -1000 maxx130 max -1 -Inf -> -1 maxx131 max -0 -Inf -> -0 maxx132 max 0 -Inf -> 0 maxx133 max 1 -Inf -> 1 maxx134 max 1000 -Inf -> 1000 maxx135 max Inf -Inf -> Infinity maxx141 max NaN -Inf -> NaN maxx142 max NaN -1000 -> NaN maxx143 max NaN -1 -> NaN maxx144 max NaN -0 -> NaN maxx145 max NaN 0 -> NaN maxx146 max NaN 1 -> NaN maxx147 max NaN 1000 -> NaN maxx148 max NaN Inf -> NaN maxx149 max NaN NaN -> NaN maxx150 max -Inf NaN -> NaN maxx151 max -1000 NaN -> NaN maxx152 max -1 NaN -> NaN maxx153 max -0 NaN -> NaN maxx154 max 0 NaN -> NaN maxx155 max 1 NaN -> NaN maxx156 max 1000 NaN -> NaN maxx157 max Inf NaN -> NaN maxx161 max sNaN -Inf -> NaN Invalid_operation maxx162 max sNaN -1000 -> NaN Invalid_operation maxx163 max sNaN -1 -> NaN Invalid_operation maxx164 max sNaN -0 -> NaN Invalid_operation maxx165 max sNaN 0 -> NaN Invalid_operation maxx166 max sNaN 1 -> NaN Invalid_operation maxx167 max sNaN 1000 -> NaN Invalid_operation maxx168 max sNaN NaN -> NaN Invalid_operation maxx169 max sNaN sNaN -> NaN Invalid_operation maxx170 max NaN sNaN -> NaN Invalid_operation maxx171 max -Inf sNaN -> NaN Invalid_operation maxx172 max -1000 sNaN -> NaN Invalid_operation maxx173 max -1 sNaN -> NaN Invalid_operation maxx174 max -0 sNaN -> NaN Invalid_operation maxx175 max 0 sNaN -> NaN Invalid_operation maxx176 max 1 sNaN -> NaN Invalid_operation maxx177 max 1000 sNaN -> NaN Invalid_operation maxx178 max Inf sNaN -> NaN Invalid_operation maxx179 max NaN sNaN -> NaN Invalid_operation -- propagating NaNs maxx181 max NaN9 -Inf -> NaN9 maxx182 max NaN8 9 -> NaN8 maxx183 max -NaN7 Inf -> -NaN7 maxx184 max NaN6 NaN5 -> NaN6 maxx185 max -Inf NaN4 -> NaN4 maxx186 max -9 -NaN3 -> -NaN3 maxx187 max Inf NaN2 -> NaN2 maxx191 max sNaN99 -Inf -> NaN99 Invalid_operation maxx192 max sNaN98 -1 -> NaN98 Invalid_operation maxx193 max -sNaN97 NaN -> -NaN97 Invalid_operation maxx194 max sNaN96 sNaN94 -> NaN96 Invalid_operation maxx195 max NaN95 sNaN93 -> NaN93 Invalid_operation maxx196 max -Inf sNaN92 -> NaN92 Invalid_operation maxx197 max 0 sNaN91 -> NaN91 Invalid_operation maxx198 max Inf -sNaN90 -> -NaN90 Invalid_operation maxx199 max NaN sNaN89 -> NaN89 Invalid_operation -- rounding checks maxexponent: 999 minexponent: -999 precision: 9 maxx201 max 12345678000 1 -> 1.23456780E+10 Rounded maxx202 max 1 12345678000 -> 1.23456780E+10 Rounded maxx203 max 1234567800 1 -> 1.23456780E+9 Rounded maxx204 max 1 1234567800 -> 1.23456780E+9 Rounded maxx205 max 1234567890 1 -> 1.23456789E+9 Rounded maxx206 max 1 1234567890 -> 1.23456789E+9 Rounded maxx207 max 1234567891 1 -> 1.23456789E+9 Inexact Rounded maxx208 max 1 1234567891 -> 1.23456789E+9 Inexact Rounded maxx209 max 12345678901 1 -> 1.23456789E+10 Inexact Rounded maxx210 max 1 12345678901 -> 1.23456789E+10 Inexact Rounded maxx211 max 1234567896 1 -> 1.23456790E+9 Inexact Rounded maxx212 max 1 1234567896 -> 1.23456790E+9 Inexact Rounded maxx213 max -1234567891 1 -> 1 maxx214 max 1 -1234567891 -> 1 maxx215 max -12345678901 1 -> 1 maxx216 max 1 -12345678901 -> 1 maxx217 max -1234567896 1 -> 1 maxx218 max 1 -1234567896 -> 1 precision: 15 maxx221 max 12345678000 1 -> 12345678000 maxx222 max 1 12345678000 -> 12345678000 maxx223 max 1234567800 1 -> 1234567800 maxx224 max 1 1234567800 -> 1234567800 maxx225 max 1234567890 1 -> 1234567890 maxx226 max 1 1234567890 -> 1234567890 maxx227 max 1234567891 1 -> 1234567891 maxx228 max 1 1234567891 -> 1234567891 maxx229 max 12345678901 1 -> 12345678901 maxx230 max 1 12345678901 -> 12345678901 maxx231 max 1234567896 1 -> 1234567896 maxx232 max 1 1234567896 -> 1234567896 maxx233 max -1234567891 1 -> 1 maxx234 max 1 -1234567891 -> 1 maxx235 max -12345678901 1 -> 1 maxx236 max 1 -12345678901 -> 1 maxx237 max -1234567896 1 -> 1 maxx238 max 1 -1234567896 -> 1 -- from examples maxx280 max '3' '2' -> '3' maxx281 max '-10' '3' -> '3' maxx282 max '1.0' '1' -> '1.0' maxx283 max '1' '1.0' -> '1' -- overflow and underflow tests ... maxExponent: 999999999 minexponent: -999999999 maxx330 max +1.23456789012345E-0 9E+999999999 -> 9E+999999999 maxx331 max 9E+999999999 +1.23456789012345E-0 -> 9E+999999999 maxx332 max +0.100 9E-999999999 -> 0.100 maxx333 max 9E-999999999 +0.100 -> 0.100 maxx335 max -1.23456789012345E-0 9E+999999999 -> 9E+999999999 maxx336 max 9E+999999999 -1.23456789012345E-0 -> 9E+999999999 maxx337 max -0.100 9E-999999999 -> 9E-999999999 maxx338 max 9E-999999999 -0.100 -> 9E-999999999 maxx339 max 1e-599999999 1e-400000001 -> 1E-400000001 maxx340 max 1e-599999999 1e-400000000 -> 1E-400000000 maxx341 max 1e-600000000 1e-400000000 -> 1E-400000000 maxx342 max 9e-999999998 0.01 -> 0.01 maxx343 max 9e-999999998 0.1 -> 0.1 maxx344 max 0.01 9e-999999998 -> 0.01 maxx345 max 1e599999999 1e400000001 -> 1E+599999999 maxx346 max 1e599999999 1e400000000 -> 1E+599999999 maxx347 max 1e600000000 1e400000000 -> 1E+600000000 maxx348 max 9e999999998 100 -> 9E+999999998 maxx349 max 9e999999998 10 -> 9E+999999998 maxx350 max 100 9e999999998 -> 9E+999999998 -- signs maxx351 max 1e+777777777 1e+411111111 -> 1E+777777777 maxx352 max 1e+777777777 -1e+411111111 -> 1E+777777777 maxx353 max -1e+777777777 1e+411111111 -> 1E+411111111 maxx354 max -1e+777777777 -1e+411111111 -> -1E+411111111 maxx355 max 1e-777777777 1e-411111111 -> 1E-411111111 maxx356 max 1e-777777777 -1e-411111111 -> 1E-777777777 maxx357 max -1e-777777777 1e-411111111 -> 1E-411111111 maxx358 max -1e-777777777 -1e-411111111 -> -1E-777777777 -- overflow tests maxexponent: 999999999 minexponent: -999999999 precision: 3 maxx400 max 9.999E+999999999 0 -> Infinity Inexact Overflow Rounded maxx401 max -9.999E+999999999 0 -> 0 -- subnormals and underflow precision: 3 maxexponent: 999 minexponent: -999 maxx410 max 1.00E-999 0 -> 1.00E-999 maxx411 max 0.1E-999 0 -> 1E-1000 Subnormal maxx412 max 0.10E-999 0 -> 1.0E-1000 Subnormal maxx413 max 0.100E-999 0 -> 1.0E-1000 Subnormal Rounded maxx414 max 0.01E-999 0 -> 1E-1001 Subnormal -- next is rounded to Emin maxx415 max 0.999E-999 0 -> 1.00E-999 Inexact Rounded Subnormal Underflow maxx416 max 0.099E-999 0 -> 1.0E-1000 Inexact Rounded Subnormal Underflow maxx417 max 0.009E-999 0 -> 1E-1001 Inexact Rounded Subnormal Underflow maxx418 max 0.001E-999 0 -> 0E-1001 Inexact Rounded Subnormal Underflow maxx419 max 0.0009E-999 0 -> 0E-1001 Inexact Rounded Subnormal Underflow maxx420 max 0.0001E-999 0 -> 0E-1001 Inexact Rounded Subnormal Underflow maxx430 max -1.00E-999 0 -> 0 maxx431 max -0.1E-999 0 -> 0 maxx432 max -0.10E-999 0 -> 0 maxx433 max -0.100E-999 0 -> 0 maxx434 max -0.01E-999 0 -> 0 maxx435 max -0.999E-999 0 -> 0 maxx436 max -0.099E-999 0 -> 0 maxx437 max -0.009E-999 0 -> 0 maxx438 max -0.001E-999 0 -> 0 maxx439 max -0.0009E-999 0 -> 0 maxx440 max -0.0001E-999 0 -> 0 -- Null tests maxx900 max 10 # -> NaN Invalid_operation maxx901 max # 10 -> NaN Invalid_operation --- NEW FILE: min.decTest --- ------------------------------------------------------------------------ -- min.decTest -- decimal minimum -- -- Copyright (c) IBM Corporation, 1981, 2004. All rights reserved. -- ------------------------------------------------------------------------ -- Please see the document "General Decimal Arithmetic Testcases" -- -- at http://www2.hursley.ibm.com/decimal for the description of -- -- these testcases. -- -- -- -- These testcases are experimental ('beta' versions), and they -- -- may contain errors. They are offered on an as-is basis. In -- -- particular, achieving the same results as the tests here is not -- -- a guarantee that an implementation complies with any Standard -- -- or specification. The tests are not exhaustive. -- -- -- -- Please send comments, suggestions, and corrections to the author: -- -- Mike Cowlishaw, IBM Fellow -- -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ version: 2.38 -- we assume that base comparison is tested in compare.decTest, so -- these mainly cover special cases and rounding extended: 1 precision: 9 rounding: half_up maxExponent: 384 minexponent: -383 -- sanity checks mnmx001 min -2 -2 -> -2 mnmx002 min -2 -1 -> -2 mnmx003 min -2 0 -> -2 mnmx004 min -2 1 -> -2 mnmx005 min -2 2 -> -2 mnmx006 min -1 -2 -> -2 mnmx007 min -1 -1 -> -1 mnmx008 min -1 0 -> -1 mnmx009 min -1 1 -> -1 mnmx010 min -1 2 -> -1 mnmx011 min 0 -2 -> -2 mnmx012 min 0 -1 -> -1 mnmx013 min 0 0 -> 0 mnmx014 min 0 1 -> 0 mnmx015 min 0 2 -> 0 mnmx016 min 1 -2 -> -2 mnmx017 min 1 -1 -> -1 mnmx018 min 1 0 -> 0 mnmx019 min 1 1 -> 1 mnmx020 min 1 2 -> 1 mnmx021 min 2 -2 -> -2 mnmx022 min 2 -1 -> -1 mnmx023 min 2 0 -> 0 mnmx025 min 2 1 -> 1 mnmx026 min 2 2 -> 2 -- extended zeros mnmx030 min 0 0 -> 0 mnmx031 min 0 -0 -> 0 mnmx032 min 0 -0.0 -> 0 mnmx033 min 0 0.0 -> 0 mnmx034 min -0 0 -> -0 mnmx035 min -0 -0 -> -0 mnmx036 min -0 -0.0 -> -0 mnmx037 min -0 0.0 -> -0 mnmx038 min 0.0 0 -> 0.0 mnmx039 min 0.0 -0 -> 0.0 mnmx040 min 0.0 -0.0 -> 0.0 mnmx041 min 0.0 0.0 -> 0.0 mnmx042 min -0.0 0 -> -0.0 mnmx043 min -0.0 -0 -> -0.0 mnmx044 min -0.0 -0.0 -> -0.0 mnmx045 min -0.0 0.0 -> -0.0 mnmx046 min -0E1 0E2 -> -0E+1 mnmx047 min 0E2 0E1 -> 0E+2 mnmx048 min 0E1 0E2 -> 0E+1 mnmx049 min -0E3 -0E2 -> -0E+3 -- Specials precision: 9 mnmx090 min Inf -Inf -> -Infinity mnmx091 min Inf -1000 -> -1000 mnmx092 min Inf -1 -> -1 mnmx093 min Inf -0 -> -0 mnmx094 min Inf 0 -> 0 mnmx095 min Inf 1 -> 1 mnmx096 min Inf 1000 -> 1000 mnmx097 min Inf Inf -> Infinity mnmx098 min -1000 Inf -> -1000 mnmx099 min -Inf Inf -> -Infinity mnmx100 min -1 Inf -> -1 mnmx101 min -0 Inf -> -0 mnmx102 min 0 Inf -> 0 mnmx103 min 1 Inf -> 1 mnmx104 min 1000 Inf -> 1000 mnmx105 min Inf Inf -> Infinity mnmx120 min -Inf -Inf -> -Infinity mnmx121 min -Inf -1000 -> -Infinity mnmx122 min -Inf -1 -> -Infinity mnmx123 min -Inf -0 -> -Infinity mnmx124 min -Inf 0 -> -Infinity mnmx125 min -Inf 1 -> -Infinity mnmx126 min -Inf 1000 -> -Infinity mnmx127 min -Inf Inf -> -Infinity mnmx128 min -Inf -Inf -> -Infinity mnmx129 min -1000 -Inf -> -Infinity mnmx130 min -1 -Inf -> -Infinity mnmx131 min -0 -Inf -> -Infinity mnmx132 min 0 -Inf -> -Infinity mnmx133 min 1 -Inf -> -Infinity mnmx134 min 1000 -Inf -> -Infinity mnmx135 min Inf -Inf -> -Infinity mnmx141 min NaN -Inf -> NaN mnmx142 min NaN -1000 -> NaN mnmx143 min NaN -1 -> NaN mnmx144 min NaN -0 -> NaN mnmx145 min NaN 0 -> NaN mnmx146 min NaN 1 -> NaN mnmx147 min NaN 1000 -> NaN mnmx148 min NaN Inf -> NaN mnmx149 min NaN NaN -> NaN mnmx150 min -Inf NaN -> NaN mnmx151 min -1000 NaN -> NaN mnmx152 min -1 -NaN -> -NaN mnmx153 min -0 NaN -> NaN mnmx154 min 0 -NaN -> -NaN mnmx155 min 1 NaN -> NaN mnmx156 min 1000 NaN -> NaN mnmx157 min Inf NaN -> NaN mnmx161 min sNaN -Inf -> NaN Invalid_operation mnmx162 min sNaN -1000 -> NaN Invalid_operation mnmx163 min sNaN -1 -> NaN Invalid_operation mnmx164 min sNaN -0 -> NaN Invalid_operation mnmx165 min -sNaN 0 -> -NaN Invalid_operation mnmx166 min -sNaN 1 -> -NaN Invalid_operation mnmx167 min sNaN 1000 -> NaN Invalid_operation mnmx168 min sNaN NaN -> NaN Invalid_operation mnmx169 min sNaN sNaN -> NaN Invalid_operation mnmx170 min NaN sNaN -> NaN Invalid_operation mnmx171 min -Inf sNaN -> NaN Invalid_operation mnmx172 min -1000 sNaN -> NaN Invalid_operation mnmx173 min -1 sNaN -> NaN Invalid_operation mnmx174 min -0 sNaN -> NaN Invalid_operation mnmx175 min 0 sNaN -> NaN Invalid_operation mnmx176 min 1 sNaN -> NaN Invalid_operation mnmx177 min 1000 sNaN -> NaN Invalid_operation mnmx178 min Inf sNaN -> NaN Invalid_operation mnmx179 min NaN sNaN -> NaN Invalid_operation -- propagating NaNs mnmx181 min NaN9 -Inf -> NaN9 mnmx182 min -NaN8 9990 -> -NaN8 mnmx183 min NaN71 Inf -> NaN71 mnmx184 min NaN6 NaN51 -> NaN6 mnmx185 min -Inf NaN41 -> NaN41 mnmx186 min -9999 -NaN33 -> -NaN33 mnmx187 min Inf NaN2 -> NaN2 mnmx191 min sNaN99 -Inf -> NaN99 Invalid_operation mnmx192 min sNaN98 -11 -> NaN98 Invalid_operation mnmx193 min -sNaN97 NaN -> -NaN97 Invalid_operation mnmx194 min sNaN69 sNaN94 -> NaN69 Invalid_operation mnmx195 min NaN95 sNaN93 -> NaN93 Invalid_operation mnmx196 min -Inf sNaN92 -> NaN92 Invalid_operation mnmx197 min 088 sNaN91 -> NaN91 Invalid_operation mnmx198 min Inf -sNaN90 -> -NaN90 Invalid_operation mnmx199 min NaN sNaN86 -> NaN86 Invalid_operation -- rounding checks -- chosen is rounded, or not maxExponent: 999 minexponent: -999 precision: 9 mnmx201 min -12345678000 1 -> -1.23456780E+10 Rounded mnmx202 min 1 -12345678000 -> -1.23456780E+10 Rounded mnmx203 min -1234567800 1 -> -1.23456780E+9 Rounded mnmx204 min 1 -1234567800 -> -1.23456780E+9 Rounded mnmx205 min -1234567890 1 -> -1.23456789E+9 Rounded mnmx206 min 1 -1234567890 -> -1.23456789E+9 Rounded mnmx207 min -1234567891 1 -> -1.23456789E+9 Inexact Rounded mnmx208 min 1 -1234567891 -> -1.23456789E+9 Inexact Rounded mnmx209 min -12345678901 1 -> -1.23456789E+10 Inexact Rounded mnmx210 min 1 -12345678901 -> -1.23456789E+10 Inexact Rounded mnmx211 min -1234567896 1 -> -1.23456790E+9 Inexact Rounded mnmx212 min 1 -1234567896 -> -1.23456790E+9 Inexact Rounded mnmx213 min 1234567891 1 -> 1 mnmx214 min 1 1234567891 -> 1 mnmx215 min 12345678901 1 -> 1 mnmx216 min 1 12345678901 -> 1 mnmx217 min 1234567896 1 -> 1 mnmx218 min 1 1234567896 -> 1 precision: 15 mnmx221 min -12345678000 1 -> -12345678000 mnmx222 min 1 -12345678000 -> -12345678000 mnmx223 min -1234567800 1 -> -1234567800 mnmx224 min 1 -1234567800 -> -1234567800 mnmx225 min -1234567890 1 -> -1234567890 mnmx226 min 1 -1234567890 -> -1234567890 mnmx227 min -1234567891 1 -> -1234567891 mnmx228 min 1 -1234567891 -> -1234567891 mnmx229 min -12345678901 1 -> -12345678901 mnmx230 min 1 -12345678901 -> -12345678901 mnmx231 min -1234567896 1 -> -1234567896 mnmx232 min 1 -1234567896 -> -1234567896 mnmx233 min 1234567891 1 -> 1 mnmx234 min 1 1234567891 -> 1 mnmx235 min 12345678901 1 -> 1 mnmx236 min 1 12345678901 -> 1 mnmx237 min 1234567896 1 -> 1 mnmx238 min 1 1234567896 -> 1 -- from examples mnmx280 min '3' '2' -> '2' mnmx281 min '-10' '3' -> '-10' mnmx282 min '1.0' '1' -> '1.0' mnmx283 min '1' '1.0' -> '1' -- overflow and underflow tests .. subnormal results [inputs] now allowed maxExponent: 999999999 minexponent: -999999999 mnmx330 min -1.23456789012345E-0 -9E+999999999 -> -9E+999999999 mnmx331 min -9E+999999999 -1.23456789012345E-0 -> -9E+999999999 mnmx332 min -0.100 -9E-999999999 -> -0.100 mnmx333 min -9E-999999999 -0.100 -> -0.100 mnmx335 min +1.23456789012345E-0 -9E+999999999 -> -9E+999999999 mnmx336 min -9E+999999999 1.23456789012345E-0 -> -9E+999999999 mnmx337 min +0.100 -9E-999999999 -> -9E-999999999 mnmx338 min -9E-999999999 0.100 -> -9E-999999999 mnmx339 min -1e-599999999 -1e-400000001 -> -1E-400000001 mnmx340 min -1e-599999999 -1e-400000000 -> -1E-400000000 mnmx341 min -1e-600000000 -1e-400000000 -> -1E-400000000 mnmx342 min -9e-999999998 -0.01 -> -0.01 mnmx343 min -9e-999999998 -0.1 -> -0.1 mnmx344 min -0.01 -9e-999999998 -> -0.01 mnmx345 min -1e599999999 -1e400000001 -> -1E+599999999 mnmx346 min -1e599999999 -1e400000000 -> -1E+599999999 mnmx347 min -1e600000000 -1e400000000 -> -1E+600000000 mnmx348 min -9e999999998 -100 -> -9E+999999998 mnmx349 min -9e999999998 -10 -> -9E+999999998 mnmx350 min -100 -9e999999998 -> -9E+999999998 -- signs mnmx351 min -1e+777777777 -1e+411111111 -> -1E+777777777 mnmx352 min -1e+777777777 +1e+411111111 -> -1E+777777777 mnmx353 min +1e+777777777 -1e+411111111 -> -1E+411111111 mnmx354 min +1e+777777777 +1e+411111111 -> 1E+411111111 mnmx355 min -1e-777777777 -1e-411111111 -> -1E-411111111 mnmx356 min -1e-777777777 +1e-411111111 -> -1E-777777777 mnmx357 min +1e-777777777 -1e-411111111 -> -1E-411111111 mnmx358 min +1e-777777777 +1e-411111111 -> 1E-777777777 -- overflow tests maxexponent: 999999999 minexponent: -999999999 precision: 3 mnmx400 min 9.999E+999999999 0 -> 0 mnmx401 min -9.999E+999999999 0 -> -Infinity Inexact Overflow Rounded -- subnormals and underflow precision: 3 maxexponent: 999 minexponent: -999 mnmx410 min 1.00E-999 0 -> 0 mnmx411 min 0.1E-999 0 -> 0 mnmx412 min 0.10E-999 0 -> 0 mnmx413 min 0.100E-999 0 -> 0 mnmx414 min 0.01E-999 0 -> 0 mnmx415 min 0.999E-999 0 -> 0 mnmx416 min 0.099E-999 0 -> 0 mnmx417 min 0.009E-999 0 -> 0 mnmx418 min 0.001E-999 0 -> 0 mnmx419 min 0.0009E-999 0 -> 0 mnmx420 min 0.0001E-999 0 -> 0 mnmx430 min -1.00E-999 0 -> -1.00E-999 mnmx431 min -0.1E-999 0 -> -1E-1000 Subnormal mnmx432 min -0.10E-999 0 -> -1.0E-1000 Subnormal mnmx433 min -0.100E-999 0 -> -1.0E-1000 Subnormal Rounded mnmx434 min -0.01E-999 0 -> -1E-1001 Subnormal -- next is rounded to Emin mnmx435 min -0.999E-999 0 -> -1.00E-999 Inexact Rounded Subnormal Underflow mnmx436 min -0.099E-999 0 -> -1.0E-1000 Inexact Rounded Subnormal Underflow mnmx437 min -0.009E-999 0 -> -1E-1001 Inexact Rounded Subnormal Underflow mnmx438 min -0.001E-999 0 -> -0E-1001 Inexact Rounded Subnormal Underflow mnmx439 min -0.0009E-999 0 -> -0E-1001 Inexact Rounded Subnormal Underflow mnmx440 min -0.0001E-999 0 -> -0E-1001 Inexact Rounded Subnormal Underflow -- Null tests mnm900 min 10 # -> NaN Invalid_operation mnm901 min # 10 -> NaN Invalid_operation --- NEW FILE: minus.decTest --- ------------------------------------------------------------------------ -- minus.decTest -- decimal negation -- -- Copyright (c) IBM Corporation, 1981, 2004. All rights reserved. -- ------------------------------------------------------------------------ -- Please see the document "General Decimal Arithmetic Testcases" -- -- at http://www2.hursley.ibm.com/decimal for the description of -- -- these testcases. -- -- -- -- These testcases are experimental ('beta' versions), and they -- -- may contain errors. They are offered on an as-is basis. In -- -- particular, achieving the same results as the tests here is not -- -- a guarantee that an implementation complies with any Standard -- -- or specification. The tests are not exhaustive. -- -- -- -- Please send comments, suggestions, and corrections to the author: -- -- Mike Cowlishaw, IBM Fellow -- -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ version: 2.38 -- This set of tests primarily tests the existence of the operator. -- Subtraction, rounding, and more overflows are tested elsewhere. extended: 1 precision: 9 rounding: half_up maxExponent: 384 minexponent: -383 minx001 minus '1' -> '-1' minx002 minus '-1' -> '1' minx003 minus '1.00' -> '-1.00' minx004 minus '-1.00' -> '1.00' minx005 minus '0' -> '0' minx006 minus '0.00' -> '0.00' minx007 minus '00.0' -> '0.0' minx008 minus '00.00' -> '0.00' minx009 minus '00' -> '0' minx010 minus '-2' -> '2' minx011 minus '2' -> '-2' minx012 minus '-2.00' -> '2.00' minx013 minus '2.00' -> '-2.00' minx014 minus '-0' -> '0' minx015 minus '-0.00' -> '0.00' minx016 minus '-00.0' -> '0.0' minx017 minus '-00.00' -> '0.00' minx018 minus '-00' -> '0' -- "lhs" zeros in plus and minus have exponent = operand minx020 minus '-0E3' -> '0E+3' minx021 minus '-0E2' -> '0E+2' minx022 minus '-0E1' -> '0E+1' minx023 minus '-0E0' -> '0' minx024 minus '+0E0' -> '0' minx025 minus '+0E1' -> '0E+1' minx026 minus '+0E2' -> '0E+2' minx027 minus '+0E3' -> '0E+3' minx030 minus '-5E3' -> '5E+3' minx031 minus '-5E8' -> '5E+8' minx032 minus '-5E13' -> '5E+13' minx033 minus '-5E18' -> '5E+18' minx034 minus '+5E3' -> '-5E+3' minx035 minus '+5E8' -> '-5E+8' minx036 minus '+5E13' -> '-5E+13' minx037 minus '+5E18' -> '-5E+18' minx050 minus '-2000000' -> '2000000' minx051 minus '2000000' -> '-2000000' precision: 7 minx052 minus '-2000000' -> '2000000' minx053 minus '2000000' -> '-2000000' precision: 6 minx054 minus '-2000000' -> '2.00000E+6' Rounded minx055 minus '2000000' -> '-2.00000E+6' Rounded precision: 3 minx056 minus '-2000000' -> '2.00E+6' Rounded minx057 minus '2000000' -> '-2.00E+6' Rounded -- more fixed, potential LHS swaps/overlays if done by 0 subtract x precision: 9 minx060 minus '56267E-10' -> '-0.0000056267' minx061 minus '56267E-5' -> '-0.56267' minx062 minus '56267E-2' -> '-562.67' minx063 minus '56267E-1' -> '-5626.7' minx065 minus '56267E-0' -> '-56267' minx066 minus '56267E+0' -> '-56267' minx067 minus '56267E+1' -> '-5.6267E+5' minx068 minus '56267E+2' -> '-5.6267E+6' minx069 minus '56267E+3' -> '-5.6267E+7' minx070 minus '56267E+4' -> '-5.6267E+8' minx071 minus '56267E+5' -> '-5.6267E+9' minx072 minus '56267E+6' -> '-5.6267E+10' minx080 minus '-56267E-10' -> '0.0000056267' minx081 minus '-56267E-5' -> '0.56267' minx082 minus '-56267E-2' -> '562.67' minx083 minus '-56267E-1' -> '5626.7' minx085 minus '-56267E-0' -> '56267' minx086 minus '-56267E+0' -> '56267' minx087 minus '-56267E+1' -> '5.6267E+5' minx088 minus '-56267E+2' -> '5.6267E+6' minx089 minus '-56267E+3' -> '5.6267E+7' minx090 minus '-56267E+4' -> '5.6267E+8' minx091 minus '-56267E+5' -> '5.6267E+9' minx092 minus '-56267E+6' -> '5.6267E+10' -- overflow tests maxexponent: 999999999 minexponent: -999999999 precision: 3 minx100 minus 9.999E+999999999 -> -Infinity Inexact Overflow Rounded minx101 minus -9.999E+999999999 -> Infinity Inexact Overflow Rounded -- subnormals and underflow precision: 3 maxexponent: 999 minexponent: -999 minx110 minus 1.00E-999 -> -1.00E-999 minx111 minus 0.1E-999 -> -1E-1000 Subnormal minx112 minus 0.10E-999 -> -1.0E-1000 Subnormal minx113 minus 0.100E-999 -> -1.0E-1000 Subnormal Rounded minx114 minus 0.01E-999 -> -1E-1001 Subnormal -- next is rounded to Emin minx115 minus 0.999E-999 -> -1.00E-999 Inexact Rounded Subnormal Underflow minx116 minus 0.099E-999 -> -1.0E-1000 Inexact Rounded Subnormal Underflow minx117 minus 0.009E-999 -> -1E-1001 Inexact Rounded Subnormal Underflow minx118 minus 0.001E-999 -> -0E-1001 Inexact Rounded Subnormal Underflow minx119 minus 0.0009E-999 -> -0E-1001 Inexact Rounded Subnormal Underflow minx120 minus 0.0001E-999 -> -0E-1001 Inexact Rounded Subnormal Underflow minx130 minus -1.00E-999 -> 1.00E-999 minx131 minus -0.1E-999 -> 1E-1000 Subnormal minx132 minus -0.10E-999 -> 1.0E-1000 Subnormal minx133 minus -0.100E-999 -> 1.0E-1000 Subnormal Rounded minx134 minus -0.01E-999 -> 1E-1001 Subnormal -- next is rounded to Emin minx135 minus -0.999E-999 -> 1.00E-999 Inexact Rounded Subnormal Underflow minx136 minus -0.099E-999 -> 1.0E-1000 Inexact Rounded Subnormal Underflow minx137 minus -0.009E-999 -> 1E-1001 Inexact Rounded Subnormal Underflow minx138 minus -0.001E-999 -> 0E-1001 Inexact Rounded Subnormal Underflow minx139 minus -0.0009E-999 -> 0E-1001 Inexact Rounded Subnormal Underflow minx140 minus -0.0001E-999 -> 0E-1001 Inexact Rounded Subnormal Underflow -- long operand checks maxexponent: 999 minexponent: -999 precision: 9 minx301 minus 12345678000 -> -1.23456780E+10 Rounded minx302 minus 1234567800 -> -1.23456780E+9 Rounded minx303 minus 1234567890 -> -1.23456789E+9 Rounded minx304 minus 1234567891 -> -1.23456789E+9 Inexact Rounded minx305 minus 12345678901 -> -1.23456789E+10 Inexact Rounded minx306 minus 1234567896 -> -1.23456790E+9 Inexact Rounded precision: 15 -- still checking minx321 minus 12345678000 -> -12345678000 minx322 minus 1234567800 -> -1234567800 minx323 minus 1234567890 -> -1234567890 minx324 minus 1234567891 -> -1234567891 minx325 minus 12345678901 -> -12345678901 minx326 minus 1234567896 -> -1234567896 -- specials minx420 minus 'Inf' -> '-Infinity' minx421 minus '-Inf' -> 'Infinity' minx422 minus NaN -> NaN minx423 minus sNaN -> NaN Invalid_operation minx424 minus NaN255 -> NaN255 minx425 minus sNaN256 -> NaN256 Invalid_operation minx426 minus -NaN -> -NaN minx427 minus -sNaN -> -NaN Invalid_operation minx428 minus -NaN255 -> -NaN255 minx429 minus -sNaN256 -> -NaN256 Invalid_operation -- Null tests minx900 minus # -> NaN Invalid_operation --- NEW FILE: multiply.decTest --- ------------------------------------------------------------------------ -- multiply.decTest -- decimal multiplication -- -- Copyright (c) IBM Corporation, 1981, 2004. All rights reserved. -- ------------------------------------------------------------------------ -- Please see the document "General Decimal Arithmetic Testcases" -- -- at http://www2.hursley.ibm.com/decimal for the description of -- -- these testcases. -- -- -- -- These testcases are experimental ('beta' versions), and they -- -- may contain errors. They are offered on an as-is basis. In -- -- particular, achieving the same results as the tests here is not -- -- a guarantee that an implementation complies with any Standard -- -- or specification. The tests are not exhaustive. -- -- -- -- Please send comments, suggestions, and corrections to the author: -- -- Mike Cowlishaw, IBM Fellow -- -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ version: 2.38 extended: 1 precision: 9 rounding: half_up maxExponent: 384 minexponent: -383 -- sanity checks (as base, above) mulx000 multiply 2 2 -> 4 mulx001 multiply 2 3 -> 6 mulx002 multiply 5 1 -> 5 mulx003 multiply 5 2 -> 10 mulx004 multiply 1.20 2 -> 2.40 mulx005 multiply 1.20 0 -> 0.00 mulx006 multiply 1.20 -2 -> -2.40 mulx007 multiply -1.20 2 -> -2.40 mulx008 multiply -1.20 0 -> -0.00 mulx009 multiply -1.20 -2 -> 2.40 mulx010 multiply 5.09 7.1 -> 36.139 mulx011 multiply 2.5 4 -> 10.0 mulx012 multiply 2.50 4 -> 10.00 mulx013 multiply 1.23456789 1.00000000 -> 1.23456789 Rounded mulx014 multiply 9.999999999 9.999999999 -> 100.000000 Inexact Rounded mulx015 multiply 2.50 4 -> 10.00 precision: 6 mulx016 multiply 2.50 4 -> 10.00 mulx017 multiply 9.999999999 9.999999999 -> 100.000 Inexact Rounded -- 1999.12.21: next one is a edge case if intermediate longs are used precision: 15 mulx019 multiply 999999999999 9765625 -> 9.76562499999023E+18 Inexact Rounded precision: 30 mulx160 multiply 999999999999 9765625 -> 9765624999990234375 precision: 9 ----- -- zeros, etc. mulx020 multiply 0 0 -> 0 mulx021 multiply 0 -0 -> -0 mulx022 multiply -0 0 -> -0 mulx023 multiply -0 -0 -> 0 mulx030 multiply 5.00 1E-3 -> 0.00500 mulx031 multiply 00.00 0.000 -> 0.00000 mulx032 multiply 00.00 0E-3 -> 0.00000 -- rhs is 0 mulx033 multiply 0E-3 00.00 -> 0.00000 -- lhs is 0 mulx034 multiply -5.00 1E-3 -> -0.00500 mulx035 multiply -00.00 0.000 -> -0.00000 mulx036 multiply -00.00 0E-3 -> -0.00000 -- rhs is 0 mulx037 multiply -0E-3 00.00 -> -0.00000 -- lhs is 0 mulx038 multiply 5.00 -1E-3 -> -0.00500 mulx039 multiply 00.00 -0.000 -> -0.00000 mulx040 multiply 00.00 -0E-3 -> -0.00000 -- rhs is 0 mulx041 multiply 0E-3 -00.00 -> -0.00000 -- lhs is 0 mulx042 multiply -5.00 -1E-3 -> 0.00500 mulx043 multiply -00.00 -0.000 -> 0.00000 mulx044 multiply -00.00 -0E-3 -> 0.00000 -- rhs is 0 mulx045 multiply -0E-3 -00.00 -> 0.00000 -- lhs is 0 -- examples from decarith mulx050 multiply 1.20 3 -> 3.60 mulx051 multiply 7 3 -> 21 mulx052 multiply 0.9 0.8 -> 0.72 mulx053 multiply 0.9 -0 -> -0.0 mulx054 multiply 654321 654321 -> 4.28135971E+11 Inexact Rounded mulx060 multiply 123.45 1e7 -> 1.2345E+9 mulx061 multiply 123.45 1e8 -> 1.2345E+10 mulx062 multiply 123.45 1e+9 -> 1.2345E+11 mulx063 multiply 123.45 1e10 -> 1.2345E+12 mulx064 multiply 123.45 1e11 -> 1.2345E+13 mulx065 multiply 123.45 1e12 -> 1.2345E+14 mulx066 multiply 123.45 1e13 -> 1.2345E+15 -- test some intermediate lengths precision: 9 mulx080 multiply 0.1 123456789 -> 12345678.9 mulx081 multiply 0.1 1234567891 -> 123456789 Inexact Rounded mulx082 multiply 0.1 12345678912 -> 1.23456789E+9 Inexact Rounded mulx083 multiply 0.1 12345678912345 -> 1.23456789E+12 Inexact Rounded mulx084 multiply 0.1 123456789 -> 12345678.9 precision: 8 mulx085 multiply 0.1 12345678912 -> 1.2345679E+9 Inexact Rounded mulx086 multiply 0.1 12345678912345 -> 1.2345679E+12 Inexact Rounded precision: 7 mulx087 multiply 0.1 12345678912 -> 1.234568E+9 Inexact Rounded mulx088 multiply 0.1 12345678912345 -> 1.234568E+12 Inexact Rounded precision: 9 mulx090 multiply 123456789 0.1 -> 12345678.9 mulx091 multiply 1234567891 0.1 -> 123456789 Inexact Rounded mulx092 multiply 12345678912 0.1 -> 1.23456789E+9 Inexact Rounded mulx093 multiply 12345678912345 0.1 -> 1.23456789E+12 Inexact Rounded mulx094 multiply 123456789 0.1 -> 12345678.9 precision: 8 mulx095 multiply 12345678912 0.1 -> 1.2345679E+9 Inexact Rounded mulx096 multiply 12345678912345 0.1 -> 1.2345679E+12 Inexact Rounded precision: 7 mulx097 multiply 12345678912 0.1 -> 1.234568E+9 Inexact Rounded mulx098 multiply 12345678912345 0.1 -> 1.234568E+12 Inexact Rounded -- test some more edge cases and carries maxexponent: 9999 minexponent: -9999 precision: 33 mulx101 multiply 9 9 -> 81 mulx102 multiply 9 90 -> 810 mulx103 multiply 9 900 -> 8100 mulx104 multiply 9 9000 -> 81000 mulx105 multiply 9 90000 -> 810000 mulx106 multiply 9 900000 -> 8100000 mulx107 multiply 9 9000000 -> 81000000 mulx108 multiply 9 90000000 -> 810000000 mulx109 multiply 9 900000000 -> 8100000000 mulx110 multiply 9 9000000000 -> 81000000000 mulx111 multiply 9 90000000000 -> 810000000000 mulx112 multiply 9 900000000000 -> 8100000000000 mulx113 multiply 9 9000000000000 -> 81000000000000 mulx114 multiply 9 90000000000000 -> 810000000000000 mulx115 multiply 9 900000000000000 -> 8100000000000000 mulx116 multiply 9 9000000000000000 -> 81000000000000000 mulx117 multiply 9 90000000000000000 -> 810000000000000000 mulx118 multiply 9 900000000000000000 -> 8100000000000000000 mulx119 multiply 9 9000000000000000000 -> 81000000000000000000 mulx120 multiply 9 90000000000000000000 -> 810000000000000000000 mulx121 multiply 9 900000000000000000000 -> 8100000000000000000000 mulx122 multiply 9 9000000000000000000000 -> 81000000000000000000000 mulx123 multiply 9 90000000000000000000000 -> 810000000000000000000000 -- test some more edge cases without carries mulx131 multiply 3 3 -> 9 mulx132 multiply 3 30 -> 90 mulx133 multiply 3 300 -> 900 mulx134 multiply 3 3000 -> 9000 mulx135 multiply 3 30000 -> 90000 mulx136 multiply 3 300000 -> 900000 mulx137 multiply 3 3000000 -> 9000000 mulx138 multiply 3 30000000 -> 90000000 mulx139 multiply 3 300000000 -> 900000000 mulx140 multiply 3 3000000000 -> 9000000000 mulx141 multiply 3 30000000000 -> 90000000000 mulx142 multiply 3 300000000000 -> 900000000000 mulx143 multiply 3 3000000000000 -> 9000000000000 mulx144 multiply 3 30000000000000 -> 90000000000000 mulx145 multiply 3 300000000000000 -> 900000000000000 mulx146 multiply 3 3000000000000000 -> 9000000000000000 mulx147 multiply 3 30000000000000000 -> 90000000000000000 mulx148 multiply 3 300000000000000000 -> 900000000000000000 mulx149 multiply 3 3000000000000000000 -> 9000000000000000000 mulx150 multiply 3 30000000000000000000 -> 90000000000000000000 mulx151 multiply 3 300000000000000000000 -> 900000000000000000000 mulx152 multiply 3 3000000000000000000000 -> 9000000000000000000000 mulx153 multiply 3 30000000000000000000000 -> 90000000000000000000000 maxexponent: 999999999 minexponent: -999999999 precision: 9 -- test some cases that are close to exponent overflow/underflow mulx170 multiply 1 9e999999999 -> 9E+999999999 mulx171 multiply 1 9.9e999999999 -> 9.9E+999999999 mulx172 multiply 1 9.99e999999999 -> 9.99E+999999999 mulx173 multiply 9e999999999 1 -> 9E+999999999 mulx174 multiply 9.9e999999999 1 -> 9.9E+999999999 mulx176 multiply 9.99e999999999 1 -> 9.99E+999999999 mulx177 multiply 1 9.99999999e999999999 -> 9.99999999E+999999999 mulx178 multiply 9.99999999e999999999 1 -> 9.99999999E+999999999 mulx180 multiply 0.1 9e-999999998 -> 9E-999999999 mulx181 multiply 0.1 99e-999999998 -> 9.9E-999999998 mulx182 multiply 0.1 999e-999999998 -> 9.99E-999999997 mulx183 multiply 0.1 9e-999999998 -> 9E-999999999 mulx184 multiply 0.1 99e-999999998 -> 9.9E-999999998 mulx185 multiply 0.1 999e-999999998 -> 9.99E-999999997 mulx186 multiply 0.1 999e-999999997 -> 9.99E-999999996 mulx187 multiply 0.1 9999e-999999997 -> 9.999E-999999995 mulx188 multiply 0.1 99999e-999999997 -> 9.9999E-999999994 mulx190 multiply 1 9e-999999998 -> 9E-999999998 mulx191 multiply 1 99e-999999998 -> 9.9E-999999997 mulx192 multiply 1 999e-999999998 -> 9.99E-999999996 mulx193 multiply 9e-999999998 1 -> 9E-999999998 mulx194 multiply 99e-999999998 1 -> 9.9E-999999997 mulx195 multiply 999e-999999998 1 -> 9.99E-999999996 mulx196 multiply 1e-599999999 1e-400000000 -> 1E-999999999 mulx197 multiply 1e-600000000 1e-399999999 -> 1E-999999999 mulx198 multiply 1.2e-599999999 1.2e-400000000 -> 1.44E-999999999 mulx199 multiply 1.2e-600000000 1.2e-399999999 -> 1.44E-999999999 mulx201 multiply 1e599999999 1e400000000 -> 1E+999999999 mulx202 multiply 1e600000000 1e399999999 -> 1E+999999999 mulx203 multiply 1.2e599999999 1.2e400000000 -> 1.44E+999999999 mulx204 multiply 1.2e600000000 1.2e399999999 -> 1.44E+999999999 -- long operand triangle precision: 33 mulx246 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.290801193369671916511992830 Inexact Rounded precision: 32 mulx247 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.29080119336967191651199283 Inexact Rounded precision: 31 mulx248 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.2908011933696719165119928 Inexact Rounded precision: 30 mulx249 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.290801193369671916511993 Inexact Rounded precision: 29 mulx250 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.29080119336967191651199 Inexact Rounded precision: 28 mulx251 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.2908011933696719165120 Inexact Rounded precision: 27 mulx252 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.290801193369671916512 Inexact Rounded precision: 26 mulx253 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.29080119336967191651 Inexact Rounded precision: 25 mulx254 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.2908011933696719165 Inexact Rounded precision: 24 mulx255 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.290801193369671917 Inexact Rounded precision: 23 mulx256 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.29080119336967192 Inexact Rounded precision: 22 mulx257 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.2908011933696719 Inexact Rounded precision: 21 mulx258 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.290801193369672 Inexact Rounded precision: 20 mulx259 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.29080119336967 Inexact Rounded precision: 19 mulx260 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.2908011933697 Inexact Rounded precision: 18 mulx261 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.290801193370 Inexact Rounded precision: 17 mulx262 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.29080119337 Inexact Rounded precision: 16 mulx263 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.2908011934 Inexact Rounded precision: 15 mulx264 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.290801193 Inexact Rounded precision: 14 mulx265 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.29080119 Inexact Rounded precision: 13 mulx266 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.2908012 Inexact Rounded precision: 12 mulx267 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.290801 Inexact Rounded precision: 11 mulx268 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.29080 Inexact Rounded precision: 10 mulx269 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.2908 Inexact Rounded precision: 9 mulx270 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.291 Inexact Rounded precision: 8 mulx271 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.29 Inexact Rounded precision: 7 mulx272 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.3 Inexact Rounded precision: 6 mulx273 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433 Inexact Rounded precision: 5 mulx274 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 1.4543E+5 Inexact Rounded precision: 4 mulx275 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 1.454E+5 Inexact Rounded precision: 3 mulx276 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 1.45E+5 Inexact Rounded precision: 2 mulx277 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 1.5E+5 Inexact Rounded precision: 1 mulx278 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 1E+5 Inexact Rounded -- tryzeros cases precision: 7 rounding: half_up maxExponent: 92 minexponent: -92 mulx504 multiply 0E-60 1000E-60 -> 0E-98 Clamped mulx505 multiply 100E+60 0E+60 -> 0E+92 Clamped -- mixed with zeros maxexponent: 999999999 minexponent: -999999999 precision: 9 mulx541 multiply 0 -1 -> -0 mulx542 multiply -0 -1 -> 0 mulx543 multiply 0 1 -> 0 mulx544 multiply -0 1 -> -0 mulx545 multiply -1 0 -> -0 mulx546 multiply -1 -0 -> 0 mulx547 multiply 1 0 -> 0 mulx548 multiply 1 -0 -> -0 mulx551 multiply 0.0 -1 -> -0.0 mulx552 multiply -0.0 -1 -> 0.0 mulx553 multiply 0.0 1 -> 0.0 mulx554 multiply -0.0 1 -> -0.0 mulx555 multiply -1.0 0 -> -0.0 mulx556 multiply -1.0 -0 -> 0.0 mulx557 multiply 1.0 0 -> 0.0 mulx558 multiply 1.0 -0 -> -0.0 mulx561 multiply 0 -1.0 -> -0.0 mulx562 multiply -0 -1.0 -> 0.0 mulx563 multiply 0 1.0 -> 0.0 mulx564 multiply -0 1.0 -> -0.0 mulx565 multiply -1 0.0 -> -0.0 mulx566 multiply -1 -0.0 -> 0.0 mulx567 multiply 1 0.0 -> 0.0 mulx568 multiply 1 -0.0 -> -0.0 mulx571 multiply 0.0 -1.0 -> -0.00 mulx572 multiply -0.0 -1.0 -> 0.00 mulx573 multiply 0.0 1.0 -> 0.00 mulx574 multiply -0.0 1.0 -> -0.00 mulx575 multiply -1.0 0.0 -> -0.00 mulx576 multiply -1.0 -0.0 -> 0.00 mulx577 multiply 1.0 0.0 -> 0.00 mulx578 multiply 1.0 -0.0 -> -0.00 -- Specials mulx580 multiply Inf -Inf -> -Infinity mulx581 multiply Inf -1000 -> -Infinity mulx582 multiply Inf -1 -> -Infinity mulx583 multiply Inf -0 -> NaN Invalid_operation mulx584 multiply Inf 0 -> NaN Invalid_operation mulx585 multiply Inf 1 -> Infinity mulx586 multiply Inf 1000 -> Infinity mulx587 multiply Inf Inf -> Infinity mulx588 multiply -1000 Inf -> -Infinity mulx589 multiply -Inf Inf -> -Infinity mulx590 multiply -1 Inf -> -Infinity mulx591 multiply -0 Inf -> NaN Invalid_operation mulx592 multiply 0 Inf -> NaN Invalid_operation mulx593 multiply 1 Inf -> Infinity mulx594 multiply 1000 Inf -> Infinity mulx595 multiply Inf Inf -> Infinity mulx600 multiply -Inf -Inf -> Infinity mulx601 multiply -Inf -1000 -> Infinity mulx602 multiply -Inf -1 -> Infinity mulx603 multiply -Inf -0 -> NaN Invalid_operation mulx604 multiply -Inf 0 -> NaN Invalid_operation mulx605 multiply -Inf 1 -> -Infinity mulx606 multiply -Inf 1000 -> -Infinity mulx607 multiply -Inf Inf -> -Infinity mulx608 multiply -1000 Inf -> -Infinity mulx609 multiply -Inf -Inf -> Infinity mulx610 multiply -1 -Inf -> Infinity mulx611 multiply -0 -Inf -> NaN Invalid_operation mulx612 multiply 0 -Inf -> NaN Invalid_operation mulx613 multiply 1 -Inf -> -Infinity mulx614 multiply 1000 -Inf -> -Infinity mulx615 multiply Inf -Inf -> -Infinity mulx621 multiply NaN -Inf -> NaN mulx622 multiply NaN -1000 -> NaN mulx623 multiply NaN -1 -> NaN mulx624 multiply NaN -0 -> NaN mulx625 multiply NaN 0 -> NaN mulx626 multiply NaN 1 -> NaN mulx627 multiply NaN 1000 -> NaN mulx628 multiply NaN Inf -> NaN mulx629 multiply NaN NaN -> NaN mulx630 multiply -Inf NaN -> NaN mulx631 multiply -1000 NaN -> NaN mulx632 multiply -1 NaN -> NaN mulx633 multiply -0 NaN -> NaN mulx634 multiply 0 NaN -> NaN mulx635 multiply 1 NaN -> NaN mulx636 multiply 1000 NaN -> NaN mulx637 multiply Inf NaN -> NaN mulx641 multiply sNaN -Inf -> NaN Invalid_operation mulx642 multiply sNaN -1000 -> NaN Invalid_operation mulx643 multiply sNaN -1 -> NaN Invalid_operation mulx644 multiply sNaN -0 -> NaN Invalid_operation mulx645 multiply sNaN 0 -> NaN Invalid_operation mulx646 multiply sNaN 1 -> NaN Invalid_operation mulx647 multiply sNaN 1000 -> NaN Invalid_operation mulx648 multiply sNaN NaN -> NaN Invalid_operation mulx649 multiply sNaN sNaN -> NaN Invalid_operation mulx650 multiply NaN sNaN -> NaN Invalid_operation mulx651 multiply -Inf sNaN -> NaN Invalid_operation mulx652 multiply -1000 sNaN -> NaN Invalid_operation mulx653 multiply -1 sNaN -> NaN Invalid_operation mulx654 multiply -0 sNaN -> NaN Invalid_operation mulx655 multiply 0 sNaN -> NaN Invalid_operation mulx656 multiply 1 sNaN -> NaN Invalid_operation mulx657 multiply 1000 sNaN -> NaN Invalid_operation mulx658 multiply Inf sNaN -> NaN Invalid_operation mulx659 multiply NaN sNaN -> NaN Invalid_operation -- propagating NaNs mulx661 multiply NaN9 -Inf -> NaN9 mulx662 multiply NaN8 999 -> NaN8 mulx663 multiply NaN71 Inf -> NaN71 mulx664 multiply NaN6 NaN5 -> NaN6 mulx665 multiply -Inf NaN4 -> NaN4 mulx666 multiply -999 NaN33 -> NaN33 mulx667 multiply Inf NaN2 -> NaN2 mulx671 multiply sNaN99 -Inf -> NaN99 Invalid_operation mulx672 multiply sNaN98 -11 -> NaN98 Invalid_operation mulx673 multiply sNaN97 NaN -> NaN97 Invalid_operation mulx674 multiply sNaN16 sNaN94 -> NaN16 Invalid_operation mulx675 multiply NaN95 sNaN93 -> NaN93 Invalid_operation mulx676 multiply -Inf sNaN92 -> NaN92 Invalid_operation mulx677 multiply 088 sNaN91 -> NaN91 Invalid_operation mulx678 multiply Inf sNaN90 -> NaN90 Invalid_operation mulx679 multiply NaN sNaN89 -> NaN89 Invalid_operation mulx681 multiply -NaN9 -Inf -> -NaN9 mulx682 multiply -NaN8 999 -> -NaN8 mulx683 multiply -NaN71 Inf -> -NaN71 mulx684 multiply -NaN6 -NaN5 -> -NaN6 mulx685 multiply -Inf -NaN4 -> -NaN4 mulx686 multiply -999 -NaN33 -> -NaN33 mulx687 multiply Inf -NaN2 -> -NaN2 mulx691 multiply -sNaN99 -Inf -> -NaN99 Invalid_operation mulx692 multiply -sNaN98 -11 -> -NaN98 Invalid_operation mulx693 multiply -sNaN97 NaN -> -NaN97 Invalid_operation mulx694 multiply -sNaN16 -sNaN94 -> -NaN16 Invalid_operation mulx695 multiply -NaN95 -sNaN93 -> -NaN93 Invalid_operation mulx696 multiply -Inf -sNaN92 -> -NaN92 Invalid_operation mulx697 multiply 088 -sNaN91 -> -NaN91 Invalid_operation mulx698 multiply Inf -sNaN90 -> -NaN90 Invalid_operation mulx699 multiply -NaN -sNaN89 -> -NaN89 Invalid_operation mulx701 multiply -NaN -Inf -> -NaN mulx702 multiply -NaN 999 -> -NaN mulx703 multiply -NaN Inf -> -NaN mulx704 multiply -NaN -NaN -> -NaN mulx705 multiply -Inf -NaN0 -> -NaN mulx706 multiply -999 -NaN -> -NaN mulx707 multiply Inf -NaN -> -NaN mulx711 multiply -sNaN -Inf -> -NaN Invalid_operation mulx712 multiply -sNaN -11 -> -NaN Invalid_operation mulx713 multiply -sNaN00 NaN -> -NaN Invalid_operation mulx714 multiply -sNaN -sNaN -> -NaN Invalid_operation mulx715 multiply -NaN -sNaN -> -NaN Invalid_operation mulx716 multiply -Inf -sNaN -> -NaN Invalid_operation mulx717 multiply 088 -sNaN -> -NaN Invalid_operation mulx718 multiply Inf -sNaN -> -NaN Invalid_operation mulx719 multiply -NaN -sNaN -> -NaN Invalid_operation -- overflow and underflow tests .. note subnormal results maxexponent: 999999999 minexponent: -999999999 mulx730 multiply +1.23456789012345E-0 9E+999999999 -> Infinity Inexact Overflow Rounded mulx731 multiply 9E+999999999 +1.23456789012345E-0 -> Infinity Inexact Overflow Rounded mulx732 multiply +0.100 9E-999999999 -> 9.00E-1000000000 Subnormal mulx733 multiply 9E-999999999 +0.100 -> 9.00E-1000000000 Subnormal mulx735 multiply -1.23456789012345E-0 9E+999999999 -> -Infinity Inexact Overflow Rounded mulx736 multiply 9E+999999999 -1.23456789012345E-0 -> -Infinity Inexact Overflow Rounded mulx737 multiply -0.100 9E-999999999 -> -9.00E-1000000000 Subnormal mulx738 multiply 9E-999999999 -0.100 -> -9.00E-1000000000 Subnormal mulx739 multiply 1e-599999999 1e-400000001 -> 1E-1000000000 Subnormal mulx740 multiply 1e-599999999 1e-400000000 -> 1E-999999999 mulx741 multiply 1e-600000000 1e-400000000 -> 1E-1000000000 Subnormal mulx742 multiply 9e-999999998 0.01 -> 9E-1000000000 Subnormal mulx743 multiply 9e-999999998 0.1 -> 9E-999999999 mulx744 multiply 0.01 9e-999999998 -> 9E-1000000000 Subnormal mulx745 multiply 1e599999999 1e400000001 -> Infinity Overflow Inexact Rounded mulx746 multiply 1e599999999 1e400000000 -> 1E+999999999 mulx747 multiply 1e600000000 1e400000000 -> Infinity Overflow Inexact Rounded mulx748 multiply 9e999999998 100 -> Infinity Overflow Inexact Rounded mulx749 multiply 9e999999998 10 -> 9.0E+999999999 mulx750 multiply 100 9e999999998 -> Infinity Overflow Inexact Rounded -- signs mulx751 multiply 1e+777777777 1e+411111111 -> Infinity Overflow Inexact Rounded mulx752 multiply 1e+777777777 -1e+411111111 -> -Infinity Overflow Inexact Rounded mulx753 multiply -1e+777777777 1e+411111111 -> -Infinity Overflow Inexact Rounded mulx754 multiply -1e+777777777 -1e+411111111 -> Infinity Overflow Inexact Rounded mulx755 multiply 1e-777777777 1e-411111111 -> 0E-1000000007 Underflow Subnormal Inexact Rounded mulx756 multiply 1e-777777777 -1e-411111111 -> -0E-1000000007 Underflow Subnormal Inexact Rounded mulx757 multiply -1e-777777777 1e-411111111 -> -0E-1000000007 Underflow Subnormal Inexact Rounded mulx758 multiply -1e-777777777 -1e-411111111 -> 0E-1000000007 Underflow Subnormal Inexact Rounded -- 'subnormal' boundary (all hard underflow or overflow in base arithemtic) precision: 9 mulx760 multiply 1e-600000000 1e-400000001 -> 1E-1000000001 Subnormal mulx761 multiply 1e-600000000 1e-400000002 -> 1E-1000000002 Subnormal mulx762 multiply 1e-600000000 1e-400000003 -> 1E-1000000003 Subnormal mulx763 multiply 1e-600000000 1e-400000004 -> 1E-1000000004 Subnormal mulx764 multiply 1e-600000000 1e-400000005 -> 1E-1000000005 Subnormal mulx765 multiply 1e-600000000 1e-400000006 -> 1E-1000000006 Subnormal mulx766 multiply 1e-600000000 1e-400000007 -> 1E-1000000007 Subnormal mulx767 multiply 1e-600000000 1e-400000008 -> 0E-1000000007 Underflow Subnormal Inexact Rounded mulx768 multiply 1e-600000000 1e-400000009 -> 0E-1000000007 Underflow Subnormal Inexact Rounded mulx769 multiply 1e-600000000 1e-400000010 -> 0E-1000000007 Underflow Subnormal Inexact Rounded -- [no equivalent of 'subnormal' for overflow] mulx770 multiply 1e+600000000 1e+400000001 -> Infinity Overflow Inexact Rounded mulx771 multiply 1e+600000000 1e+400000002 -> Infinity Overflow Inexact Rounded mulx772 multiply 1e+600000000 1e+400000003 -> Infinity Overflow Inexact Rounded mulx773 multiply 1e+600000000 1e+400000004 -> Infinity Overflow Inexact Rounded mulx774 multiply 1e+600000000 1e+400000005 -> Infinity Overflow Inexact Rounded mulx775 multiply 1e+600000000 1e+400000006 -> Infinity Overflow Inexact Rounded mulx776 multiply 1e+600000000 1e+400000007 -> Infinity Overflow Inexact Rounded mulx777 multiply 1e+600000000 1e+400000008 -> Infinity Overflow Inexact Rounded mulx778 multiply 1e+600000000 1e+400000009 -> Infinity Overflow Inexact Rounded mulx779 multiply 1e+600000000 1e+400000010 -> Infinity Overflow Inexact Rounded -- 'subnormal' test edge condition at higher precisions precision: 99 mulx780 multiply 1e-600000000 1e-400000007 -> 1E-1000000007 Subnormal mulx781 multiply 1e-600000000 1e-400000008 -> 1E-1000000008 Subnormal mulx782 multiply 1e-600000000 1e-400000097 -> 1E-1000000097 Subnormal mulx783 multiply 1e-600000000 1e-400000098 -> 0E-1000000097 Underflow Subnormal Inexact Rounded precision: 999 mulx784 multiply 1e-600000000 1e-400000997 -> 1E-1000000997 Subnormal mulx785 multiply 1e-600000000 1e-400000998 -> 0E-1000000997 Underflow Subnormal Inexact Rounded -- following testcases [through mulx800] not yet run against code precision: 9999 mulx786 multiply 1e-600000000 1e-400009997 -> 1E-1000009997 Subnormal mulx787 multiply 1e-600000000 1e-400009998 -> 0E-1000009997 Underflow Subnormal Inexact Rounded precision: 99999 mulx788 multiply 1e-600000000 1e-400099997 -> 1E-1000099997 Subnormal mulx789 multiply 1e-600000000 1e-400099998 -> 0E-1000099997 Underflow Subnormal Inexact Rounded precision: 999999 mulx790 multiply 1e-600000000 1e-400999997 -> 1E-1000999997 Subnormal mulx791 multiply 1e-600000000 1e-400999998 -> 0E-1000999997 Underflow Subnormal Inexact Rounded precision: 9999999 mulx792 multiply 1e-600000000 1e-409999997 -> 1E-1009999997 Subnormal mulx793 multiply 1e-600000000 1e-409999998 -> 0E-1009999997 Underflow Subnormal Inexact Rounded precision: 99999999 mulx794 multiply 1e-600000000 1e-499999997 -> 1E-1099999997 Subnormal mulx795 multiply 1e-600000000 1e-499999998 -> 0E-1099999997 Underflow Subnormal Inexact Rounded precision: 999999999 mulx796 multiply 1e-999999999 1e-999999997 -> 1E-1999999996 Subnormal mulx797 multiply 1e-999999999 1e-999999998 -> 1E-1999999997 Subnormal mulx798 multiply 1e-999999999 1e-999999999 -> 0E-1999999997 Underflow Subnormal Inexact Rounded mulx799 multiply 1e-600000000 1e-400000007 -> 1E-1000000007 Subnormal mulx800 multiply 1e-600000000 1e-400000008 -> 1E-1000000008 Subnormal -- test subnormals rounding precision: 5 maxExponent: 999 minexponent: -999 rounding: half_even mulx801 multiply 1.0000E-999 1 -> 1.0000E-999 mulx802 multiply 1.000E-999 1e-1 -> 1.000E-1000 Subnormal mulx803 multiply 1.00E-999 1e-2 -> 1.00E-1001 Subnormal mulx804 multiply 1.0E-999 1e-3 -> 1.0E-1002 Subnormal mulx805 multiply 1.0E-999 1e-4 -> 1E-1003 Subnormal Rounded mulx806 multiply 1.3E-999 1e-4 -> 1E-1003 Underflow Subnormal Inexact Rounded mulx807 multiply 1.5E-999 1e-4 -> 2E-1003 Underflow Subnormal Inexact Rounded mulx808 multiply 1.7E-999 1e-4 -> 2E-1003 Underflow Subnormal Inexact Rounded mulx809 multiply 2.3E-999 1e-4 -> 2E-1003 Underflow Subnormal Inexact Rounded mulx810 multiply 2.5E-999 1e-4 -> 2E-1003 Underflow Subnormal Inexact Rounded mulx811 multiply 2.7E-999 1e-4 -> 3E-1003 Underflow Subnormal Inexact Rounded mulx812 multiply 1.49E-999 1e-4 -> 1E-1003 Underflow Subnormal Inexact Rounded mulx813 multiply 1.50E-999 1e-4 -> 2E-1003 Underflow Subnormal Inexact Rounded mulx814 multiply 1.51E-999 1e-4 -> 2E-1003 Underflow Subnormal Inexact Rounded mulx815 multiply 2.49E-999 1e-4 -> 2E-1003 Underflow Subnormal Inexact Rounded mulx816 multiply 2.50E-999 1e-4 -> 2E-1003 Underflow Subnormal Inexact Rounded mulx817 multiply 2.51E-999 1e-4 -> 3E-1003 Underflow Subnormal Inexact Rounded mulx818 multiply 1E-999 1e-4 -> 1E-1003 Subnormal mulx819 multiply 3E-999 1e-5 -> 0E-1003 Underflow Subnormal Inexact Rounded mulx820 multiply 5E-999 1e-5 -> 0E-1003 Underflow Subnormal Inexact Rounded mulx821 multiply 7E-999 1e-5 -> 1E-1003 Underflow Subnormal Inexact Rounded mulx822 multiply 9E-999 1e-5 -> 1E-1003 Underflow Subnormal Inexact Rounded mulx823 multiply 9.9E-999 1e-5 -> 1E-1003 Underflow Subnormal Inexact Rounded mulx824 multiply 1E-999 -1e-4 -> -1E-1003 Subnormal mulx825 multiply 3E-999 -1e-5 -> -0E-1003 Underflow Subnormal Inexact Rounded mulx826 multiply -5E-999 1e-5 -> -0E-1003 Underflow Subnormal Inexact Rounded mulx827 multiply 7E-999 -1e-5 -> -1E-1003 Underflow Subnormal Inexact Rounded mulx828 multiply -9E-999 1e-5 -> -1E-1003 Underflow Subnormal Inexact Rounded mulx829 multiply 9.9E-999 -1e-5 -> -1E-1003 Underflow Subnormal Inexact Rounded mulx830 multiply 3.0E-999 -1e-5 -> -0E-1003 Underflow Subnormal Inexact Rounded mulx831 multiply 1.0E-501 1e-501 -> 1.0E-1002 Subnormal mulx832 multiply 2.0E-501 2e-501 -> 4.0E-1002 Subnormal mulx833 multiply 4.0E-501 4e-501 -> 1.60E-1001 Subnormal mulx834 multiply 10.0E-501 10e-501 -> 1.000E-1000 Subnormal mulx835 multiply 30.0E-501 30e-501 -> 9.000E-1000 Subnormal mulx836 multiply 40.0E-501 40e-501 -> 1.6000E-999 -- squares mulx840 multiply 1E-502 1e-502 -> 0E-1003 Underflow Subnormal Inexact Rounded mulx841 multiply 1E-501 1e-501 -> 1E-1002 Subnormal mulx842 multiply 2E-501 2e-501 -> 4E-1002 Subnormal mulx843 multiply 4E-501 4e-501 -> 1.6E-1001 Subnormal mulx844 multiply 10E-501 10e-501 -> 1.00E-1000 Subnormal mulx845 multiply 30E-501 30e-501 -> 9.00E-1000 Subnormal mulx846 multiply 40E-501 40e-501 -> 1.600E-999 -- cubes mulx850 multiply 1E-670 1e-335 -> 0E-1003 Underflow Subnormal Inexact Rounded mulx851 multiply 1E-668 1e-334 -> 1E-1002 Subnormal mulx852 multiply 4E-668 2e-334 -> 8E-1002 Subnormal mulx853 multiply 9E-668 3e-334 -> 2.7E-1001 Subnormal mulx854 multiply 16E-668 4e-334 -> 6.4E-1001 Subnormal mulx855 multiply 25E-668 5e-334 -> 1.25E-1000 Subnormal mulx856 multiply 10E-668 100e-334 -> 1.000E-999 -- test from 0.099 ** 999 at 15 digits precision: 19 mulx860 multiply 6636851557994578716E-520 6636851557994578716E-520 -> 4.40477986028551E-1003 Underflow Subnormal Inexact Rounded -- Long operand overflow may be a different path precision: 3 maxExponent: 999999999 minexponent: -999999999 mulx870 multiply 1 9.999E+999999999 -> Infinity Inexact Overflow Rounded mulx871 multiply 1 -9.999E+999999999 -> -Infinity Inexact Overflow Rounded mulx872 multiply 9.999E+999999999 1 -> Infinity Inexact Overflow Rounded mulx873 multiply -9.999E+999999999 1 -> -Infinity Inexact Overflow Rounded -- check for double-rounded subnormals precision: 5 maxexponent: 79 minexponent: -79 mulx881 multiply 1.2347E-40 1.2347E-40 -> 1.524E-80 Inexact Rounded Subnormal Underflow mulx882 multiply 1.234E-40 1.234E-40 -> 1.523E-80 Inexact Rounded Subnormal Underflow mulx883 multiply 1.23E-40 1.23E-40 -> 1.513E-80 Inexact Rounded Subnormal Underflow mulx884 multiply 1.2E-40 1.2E-40 -> 1.44E-80 Subnormal mulx885 multiply 1.2E-40 1.2E-41 -> 1.44E-81 Subnormal mulx886 multiply 1.2E-40 1.2E-42 -> 1.4E-82 Subnormal Inexact Rounded Underflow mulx887 multiply 1.2E-40 1.3E-42 -> 1.6E-82 Subnormal Inexact Rounded Underflow mulx888 multiply 1.3E-40 1.3E-42 -> 1.7E-82 Subnormal Inexact Rounded Underflow mulx891 multiply 1.2345E-39 1.234E-40 -> 1.5234E-79 Inexact Rounded mulx892 multiply 1.23456E-39 1.234E-40 -> 1.5234E-79 Inexact Rounded mulx893 multiply 1.2345E-40 1.234E-40 -> 1.523E-80 Inexact Rounded Subnormal Underflow mulx894 multiply 1.23456E-40 1.234E-40 -> 1.523E-80 Inexact Rounded Subnormal Underflow mulx895 multiply 1.2345E-41 1.234E-40 -> 1.52E-81 Inexact Rounded Subnormal Underflow mulx896 multiply 1.23456E-41 1.234E-40 -> 1.52E-81 Inexact Rounded Subnormal Underflow -- Null tests mulx900 multiply 10 # -> NaN Invalid_operation mulx901 multiply # 10 -> NaN Invalid_operation --- NEW FILE: normalize.decTest --- ------------------------------------------------------------------------ -- normalize.decTest -- remove trailing zeros -- -- Copyright (c) IBM Corporation, 2003. All rights reserved. -- ------------------------------------------------------------------------ -- Please see the document "General Decimal Arithmetic Testcases" -- -- at http://www2.hursley.ibm.com/decimal for the description of -- -- these testcases. -- -- -- -- These testcases are experimental ('beta' versions), and they -- -- may contain errors. They are offered on an as-is basis. In -- -- particular, achieving the same results as the tests here is not -- -- a guarantee that an implementation complies with any Standard -- -- or specification. The tests are not exhaustive. -- -- -- -- Please send comments, suggestions, and corrections to the author: -- -- Mike Cowlishaw, IBM Fellow -- -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ version: 2.38 extended: 1 precision: 9 rounding: half_up maxExponent: 999 minexponent: -999 nrmx001 normalize '1' -> '1' nrmx002 normalize '-1' -> '-1' nrmx003 normalize '1.00' -> '1' nrmx004 normalize '-1.00' -> '-1' nrmx005 normalize '0' -> '0' nrmx006 normalize '0.00' -> '0' nrmx007 normalize '00.0' -> '0' nrmx008 normalize '00.00' -> '0' nrmx009 normalize '00' -> '0' nrmx010 normalize '0E+1' -> '0' nrmx011 normalize '0E+5' -> '0' nrmx012 normalize '-2' -> '-2' nrmx013 normalize '2' -> '2' nrmx014 normalize '-2.00' -> '-2' nrmx015 normalize '2.00' -> '2' nrmx016 normalize '-0' -> '-0' nrmx017 normalize '-0.00' -> '-0' nrmx018 normalize '-00.0' -> '-0' nrmx019 normalize '-00.00' -> '-0' nrmx020 normalize '-00' -> '-0' nrmx021 normalize '-0E+5' -> '-0' nrmx022 normalize '-0E+1' -> '-0' nrmx030 normalize '+0.1' -> '0.1' nrmx031 normalize '-0.1' -> '-0.1' nrmx032 normalize '+0.01' -> '0.01' nrmx033 normalize '-0.01' -> '-0.01' nrmx034 normalize '+0.001' -> '0.001' nrmx035 normalize '-0.001' -> '-0.001' nrmx036 normalize '+0.000001' -> '0.000001' nrmx037 normalize '-0.000001' -> '-0.000001' nrmx038 normalize '+0.000000000001' -> '1E-12' nrmx039 normalize '-0.000000000001' -> '-1E-12' nrmx041 normalize 1.1 -> 1.1 nrmx042 normalize 1.10 -> 1.1 nrmx043 normalize 1.100 -> 1.1 nrmx044 normalize 1.110 -> 1.11 nrmx045 normalize -1.1 -> -1.1 nrmx046 normalize -1.10 -> -1.1 nrmx047 normalize -1.100 -> -1.1 nrmx048 normalize -1.110 -> -1.11 nrmx049 normalize 9.9 -> 9.9 nrmx050 normalize 9.90 -> 9.9 nrmx051 normalize 9.900 -> 9.9 nrmx052 normalize 9.990 -> 9.99 nrmx053 normalize -9.9 -> -9.9 nrmx054 normalize -9.90 -> -9.9 nrmx055 normalize -9.900 -> -9.9 nrmx056 normalize -9.990 -> -9.99 -- some trailing fractional zeros with zeros in units nrmx060 normalize 10.0 -> 1E+1 nrmx061 normalize 10.00 -> 1E+1 nrmx062 normalize 100.0 -> 1E+2 nrmx063 normalize 100.00 -> 1E+2 nrmx064 normalize 1.1000E+3 -> 1.1E+3 nrmx065 normalize 1.10000E+3 -> 1.1E+3 nrmx066 normalize -10.0 -> -1E+1 nrmx067 normalize -10.00 -> -1E+1 nrmx068 normalize -100.0 -> -1E+2 nrmx069 normalize -100.00 -> -1E+2 nrmx070 normalize -1.1000E+3 -> -1.1E+3 nrmx071 normalize -1.10000E+3 -> -1.1E+3 -- some insignificant trailing zeros with positive exponent nrmx080 normalize 10E+1 -> 1E+2 nrmx081 normalize 100E+1 -> 1E+3 nrmx082 normalize 1.0E+2 -> 1E+2 nrmx083 normalize 1.0E+3 -> 1E+3 nrmx084 normalize 1.1E+3 -> 1.1E+3 nrmx085 normalize 1.00E+3 -> 1E+3 nrmx086 normalize 1.10E+3 -> 1.1E+3 nrmx087 normalize -10E+1 -> -1E+2 nrmx088 normalize -100E+1 -> -1E+3 nrmx089 normalize -1.0E+2 -> -1E+2 nrmx090 normalize -1.0E+3 -> -1E+3 nrmx091 normalize -1.1E+3 -> -1.1E+3 nrmx092 normalize -1.00E+3 -> -1E+3 nrmx093 normalize -1.10E+3 -> -1.1E+3 -- some significant trailing zeros, were we to be trimming nrmx100 normalize 11 -> 11 nrmx101 normalize 10 -> 1E+1 nrmx102 normalize 10. -> 1E+1 nrmx103 normalize 1.1E+1 -> 11 nrmx104 normalize 1.0E+1 -> 1E+1 nrmx105 normalize 1.10E+2 -> 1.1E+2 nrmx106 normalize 1.00E+2 -> 1E+2 nrmx107 normalize 1.100E+3 -> 1.1E+3 nrmx108 normalize 1.000E+3 -> 1E+3 nrmx109 normalize 1.000000E+6 -> 1E+6 nrmx110 normalize -11 -> -11 nrmx111 normalize -10 -> -1E+1 nrmx112 normalize -10. -> -1E+1 nrmx113 normalize -1.1E+1 -> -11 nrmx114 normalize -1.0E+1 -> -1E+1 nrmx115 normalize -1.10E+2 -> -1.1E+2 nrmx116 normalize -1.00E+2 -> -1E+2 nrmx117 normalize -1.100E+3 -> -1.1E+3 nrmx118 normalize -1.000E+3 -> -1E+3 nrmx119 normalize -1.00000E+5 -> -1E+5 nrmx120 normalize -1.000000E+6 -> -1E+6 nrmx121 normalize -10.00000E+6 -> -1E+7 nrmx122 normalize -100.0000E+6 -> -1E+8 nrmx123 normalize -1000.000E+6 -> -1E+9 nrmx124 normalize -10000.00E+6 -> -1E+10 nrmx125 normalize -100000.0E+6 -> -1E+11 nrmx126 normalize -1000000.E+6 -> -1E+12 -- examples from decArith nrmx140 normalize '2.1' -> '2.1' nrmx141 normalize '-2.0' -> '-2' nrmx142 normalize '1.200' -> '1.2' nrmx143 normalize '-120' -> '-1.2E+2' nrmx144 normalize '120.00' -> '1.2E+2' nrmx145 normalize '0.00' -> '0' -- overflow tests maxexponent: 999999999 minexponent: -999999999 precision: 3 nrmx160 normalize 9.999E+999999999 -> Infinity Inexact Overflow Rounded nrmx161 normalize -9.999E+999999999 -> -Infinity Inexact Overflow Rounded -- subnormals and underflow precision: 3 maxexponent: 999 minexponent: -999 nrmx210 normalize 1.00E-999 -> 1E-999 nrmx211 normalize 0.1E-999 -> 1E-1000 Subnormal nrmx212 normalize 0.10E-999 -> 1E-1000 Subnormal nrmx213 normalize 0.100E-999 -> 1E-1000 Subnormal Rounded nrmx214 normalize 0.01E-999 -> 1E-1001 Subnormal -- next is rounded to Emin nrmx215 normalize 0.999E-999 -> 1E-999 Inexact Rounded Subnormal Underflow nrmx216 normalize 0.099E-999 -> 1E-1000 Inexact Rounded Subnormal Underflow nrmx217 normalize 0.009E-999 -> 1E-1001 Inexact Rounded Subnormal Underflow nrmx218 normalize 0.001E-999 -> 0 Inexact Rounded Subnormal Underflow nrmx219 normalize 0.0009E-999 -> 0 Inexact Rounded Subnormal Underflow nrmx220 normalize 0.0001E-999 -> 0 Inexact Rounded Subnormal Underflow nrmx230 normalize -1.00E-999 -> -1E-999 nrmx231 normalize -0.1E-999 -> -1E-1000 Subnormal nrmx232 normalize -0.10E-999 -> -1E-1000 Subnormal nrmx233 normalize -0.100E-999 -> -1E-1000 Subnormal Rounded nrmx234 normalize -0.01E-999 -> -1E-1001 Subnormal -- next is rounded to Emin nrmx235 normalize -0.999E-999 -> -1E-999 Inexact Rounded Subnormal Underflow nrmx236 normalize -0.099E-999 -> -1E-1000 Inexact Rounded Subnormal Underflow nrmx237 normalize -0.009E-999 -> -1E-1001 Inexact Rounded Subnormal Underflow nrmx238 normalize -0.001E-999 -> -0 Inexact Rounded Subnormal Underflow nrmx239 normalize -0.0009E-999 -> -0 Inexact Rounded Subnormal Underflow nrmx240 normalize -0.0001E-999 -> -0 Inexact Rounded Subnormal Underflow -- more reshaping precision: 9 nrmx260 normalize '56260E-10' -> '0.000005626' nrmx261 normalize '56260E-5' -> '0.5626' nrmx262 normalize '56260E-2' -> '562.6' nrmx263 normalize '56260E-1' -> '5626' nrmx265 normalize '56260E-0' -> '5.626E+4' nrmx266 normalize '56260E+0' -> '5.626E+4' nrmx267 normalize '56260E+1' -> '5.626E+5' nrmx268 normalize '56260E+2' -> '5.626E+6' nrmx269 normalize '56260E+3' -> '5.626E+7' nrmx270 normalize '56260E+4' -> '5.626E+8' nrmx271 normalize '56260E+5' -> '5.626E+9' nrmx272 normalize '56260E+6' -> '5.626E+10' nrmx280 normalize '-56260E-10' -> '-0.000005626' nrmx281 normalize '-56260E-5' -> '-0.5626' nrmx282 normalize '-56260E-2' -> '-562.6' nrmx283 normalize '-56260E-1' -> '-5626' nrmx285 normalize '-56260E-0' -> '-5.626E+4' nrmx286 normalize '-56260E+0' -> '-5.626E+4' nrmx287 normalize '-56260E+1' -> '-5.626E+5' nrmx288 normalize '-56260E+2' -> '-5.626E+6' nrmx289 normalize '-56260E+3' -> '-5.626E+7' nrmx290 normalize '-56260E+4' -> '-5.626E+8' nrmx291 normalize '-56260E+5' -> '-5.626E+9' nrmx292 normalize '-56260E+6' -> '-5.626E+10' -- specials nrmx820 normalize 'Inf' -> 'Infinity' nrmx821 normalize '-Inf' -> '-Infinity' nrmx822 normalize NaN -> NaN nrmx823 normalize sNaN -> NaN Invalid_operation nrmx824 normalize NaN101 -> NaN101 nrmx825 normalize sNaN010 -> NaN10 Invalid_operation nrmx827 normalize -NaN -> -NaN nrmx828 normalize -sNaN -> -NaN Invalid_operation nrmx829 normalize -NaN101 -> -NaN101 nrmx830 normalize -sNaN010 -> -NaN10 Invalid_operation -- Null test nrmx900 normalize # -> NaN Invalid_operation --- NEW FILE: plus.decTest --- ------------------------------------------------------------------------ -- plus.decTest -- decimal monadic addition -- -- Copyright (c) IBM Corporation, 1981, 2004. All rights reserved. -- ------------------------------------------------------------------------ -- Please see the document "General Decimal Arithmetic Testcases" -- -- at http://www2.hursley.ibm.com/decimal for the description of -- -- these testcases. -- -- -- -- These testcases are experimental ('beta' versions), and they -- -- may contain errors. They are offered on an as-is basis. In -- -- particular, achieving the same results as the tests here is not -- -- a guarantee that an implementation complies with any Standard -- -- or specification. The tests are not exhaustive. -- -- -- -- Please send comments, suggestions, and corrections to the author: -- -- Mike Cowlishaw, IBM Fellow -- -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ version: 2.38 -- This set of tests primarily tests the existence of the operator. -- Addition and rounding, and most overflows, are tested elsewhere. extended: 1 precision: 9 rounding: half_up maxExponent: 384 minexponent: -383 plux001 plus '1' -> '1' plux002 plus '-1' -> '-1' plux003 plus '1.00' -> '1.00' plux004 plus '-1.00' -> '-1.00' plux005 plus '0' -> '0' plux006 plus '0.00' -> '0.00' plux007 plus '00.0' -> '0.0' plux008 plus '00.00' -> '0.00' plux009 plus '00' -> '0' plux010 plus '-2' -> '-2' plux011 plus '2' -> '2' plux012 plus '-2.00' -> '-2.00' plux013 plus '2.00' -> '2.00' plux014 plus '-0' -> '0' plux015 plus '-0.00' -> '0.00' plux016 plus '-00.0' -> '0.0' plux017 plus '-00.00' -> '0.00' plux018 plus '-00' -> '0' plux020 plus '-2000000' -> '-2000000' plux021 plus '2000000' -> '2000000' precision: 7 plux022 plus '-2000000' -> '-2000000' plux023 plus '2000000' -> '2000000' precision: 6 plux024 plus '-2000000' -> '-2.00000E+6' Rounded plux025 plus '2000000' -> '2.00000E+6' Rounded precision: 3 plux026 plus '-2000000' -> '-2.00E+6' Rounded plux027 plus '2000000' -> '2.00E+6' Rounded -- more fixed, potential LHS swaps if done by add 0 precision: 9 plux060 plus '56267E-10' -> '0.0000056267' plux061 plus '56267E-5' -> '0.56267' plux062 plus '56267E-2' -> '562.67' plux063 plus '56267E-1' -> '5626.7' plux065 plus '56267E-0' -> '56267' plux066 plus '56267E+0' -> '56267' plux067 plus '56267E+1' -> '5.6267E+5' plux068 plus '56267E+2' -> '5.6267E+6' plux069 plus '56267E+3' -> '5.6267E+7' plux070 plus '56267E+4' -> '5.6267E+8' plux071 plus '56267E+5' -> '5.6267E+9' plux072 plus '56267E+6' -> '5.6267E+10' plux080 plus '-56267E-10' -> '-0.0000056267' plux081 plus '-56267E-5' -> '-0.56267' plux082 plus '-56267E-2' -> '-562.67' plux083 plus '-56267E-1' -> '-5626.7' plux085 plus '-56267E-0' -> '-56267' plux086 plus '-56267E+0' -> '-56267' plux087 plus '-56267E+1' -> '-5.6267E+5' plux088 plus '-56267E+2' -> '-5.6267E+6' plux089 plus '-56267E+3' -> '-5.6267E+7' plux090 plus '-56267E+4' -> '-5.6267E+8' plux091 plus '-56267E+5' -> '-5.6267E+9' plux092 plus '-56267E+6' -> '-5.6267E+10' -- "lhs" zeros in plus and minus have exponent = operand plux120 plus '-0E3' -> '0E+3' plux121 plus '-0E2' -> '0E+2' plux122 plus '-0E1' -> '0E+1' plux123 plus '-0E0' -> '0' plux124 plus '+0E0' -> '0' plux125 plus '+0E1' -> '0E+1' plux126 plus '+0E2' -> '0E+2' plux127 plus '+0E3' -> '0E+3' plux130 plus '-5E3' -> '-5E+3' plux131 plus '-5E8' -> '-5E+8' plux132 plus '-5E13' -> '-5E+13' plux133 plus '-5E18' -> '-5E+18' plux134 plus '+5E3' -> '5E+3' plux135 plus '+5E8' -> '5E+8' plux136 plus '+5E13' -> '5E+13' plux137 plus '+5E18' -> '5E+18' -- specials plux150 plus 'Inf' -> 'Infinity' plux151 plus '-Inf' -> '-Infinity' plux152 plus NaN -> NaN plux153 plus sNaN -> NaN Invalid_operation plux154 plus NaN77 -> NaN77 plux155 plus sNaN88 -> NaN88 Invalid_operation plux156 plus -NaN -> -NaN plux157 plus -sNaN -> -NaN Invalid_operation plux158 plus -NaN77 -> -NaN77 plux159 plus -sNaN88 -> -NaN88 Invalid_operation -- overflow tests maxexponent: 999999999 minexponent: -999999999 precision: 3 plux160 plus 9.999E+999999999 -> Infinity Inexact Overflow Rounded plux161 plus -9.999E+999999999 -> -Infinity Inexact Overflow Rounded -- subnormals and underflow precision: 3 maxexponent: 999 minexponent: -999 plux210 plus 1.00E-999 -> 1.00E-999 plux211 plus 0.1E-999 -> 1E-1000 Subnormal plux212 plus 0.10E-999 -> 1.0E-1000 Subnormal plux213 plus 0.100E-999 -> 1.0E-1000 Subnormal Rounded plux214 plus 0.01E-999 -> 1E-1001 Subnormal -- next is rounded to Emin plux215 plus 0.999E-999 -> 1.00E-999 Inexact Rounded Subnormal Underflow plux216 plus 0.099E-999 -> 1.0E-1000 Inexact Rounded Subnormal Underflow plux217 plus 0.009E-999 -> 1E-1001 Inexact Rounded Subnormal Underflow plux218 plus 0.001E-999 -> 0E-1001 Inexact Rounded Subnormal Underflow plux219 plus 0.0009E-999 -> 0E-1001 Inexact Rounded Subnormal Underflow plux220 plus 0.0001E-999 -> 0E-1001 Inexact Rounded Subnormal Underflow plux230 plus -1.00E-999 -> -1.00E-999 plux231 plus -0.1E-999 -> -1E-1000 Subnormal plux232 plus -0.10E-999 -> -1.0E-1000 Subnormal plux233 plus -0.100E-999 -> -1.0E-1000 Subnormal Rounded plux234 plus -0.01E-999 -> -1E-1001 Subnormal -- next is rounded to Emin plux235 plus -0.999E-999 -> -1.00E-999 Inexact Rounded Subnormal Underflow plux236 plus -0.099E-999 -> -1.0E-1000 Inexact Rounded Subnormal Underflow plux237 plus -0.009E-999 -> -1E-1001 Inexact Rounded Subnormal Underflow plux238 plus -0.001E-999 -> -0E-1001 Inexact Rounded Subnormal Underflow plux239 plus -0.0009E-999 -> -0E-1001 Inexact Rounded Subnormal Underflow plux240 plus -0.0001E-999 -> -0E-1001 Inexact Rounded Subnormal Underflow -- long operand checks maxexponent: 999 minexponent: -999 precision: 9 plux301 plus 12345678000 -> 1.23456780E+10 Rounded plux302 plus 1234567800 -> 1.23456780E+9 Rounded plux303 plus 1234567890 -> 1.23456789E+9 Rounded plux304 plus 1234567891 -> 1.23456789E+9 Inexact Rounded plux305 plus 12345678901 -> 1.23456789E+10 Inexact Rounded plux306 plus 1234567896 -> 1.23456790E+9 Inexact Rounded -- still checking precision: 15 plux321 plus 12345678000 -> 12345678000 plux322 plus 1234567800 -> 1234567800 plux323 plus 1234567890 -> 1234567890 plux324 plus 1234567891 -> 1234567891 plux325 plus 12345678901 -> 12345678901 plux326 plus 1234567896 -> 1234567896 precision: 9 -- Null tests plu900 plus # -> NaN Invalid_operation --- NEW FILE: power.decTest --- ---------------------------------------------------------------------- -- power.decTest -- decimal exponentiation -- -- Copyright (c) IBM Corporation, 1981, 2003. All rights reserved. -- ------------------------------------------------------------------------ -- Please see the document "General Decimal Arithmetic Testcases" -- -- at http://www2.hursley.ibm.com/decimal for the description of -- -- these testcases. -- -- -- -- These testcases are experimental ('beta' versions), and they -- -- may contain errors. They are offered on an as-is basis. In -- -- particular, achieving the same results as the tests here is not -- -- a guarantee that an implementation complies with any Standard -- -- or specification. The tests are not exhaustive. -- -- -- -- Please send comments, suggestions, and corrections to the author: -- -- Mike Cowlishaw, IBM Fellow -- -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ version: 2.38 -- This set of testcases tests raising numbers to an integer power only. -- If arbitrary powers were supported, 1 ulp differences would be -- permitted. extended: 1 precision: 9 rounding: half_up maxExponent: 999 minexponent: -999 -- base checks. Note 0**0 is an error. powx001 power '0' '0' -> NaN Invalid_operation powx002 power '0' '1' -> '0' powx003 power '0' '2' -> '0' powx004 power '1' '0' -> '1' powx005 power '1' '1' -> '1' powx006 power '1' '2' -> '1' powx010 power '2' '0' -> '1' powx011 power '2' '1' -> '2' powx012 power '2' '2' -> '4' powx013 power '2' '3' -> '8' powx014 power '2' '4' -> '16' powx015 power '2' '5' -> '32' powx016 power '2' '6' -> '64' powx017 power '2' '7' -> '128' powx018 power '2' '8' -> '256' powx019 power '2' '9' -> '512' powx020 power '2' '10' -> '1024' powx021 power '2' '11' -> '2048' powx022 power '2' '12' -> '4096' powx023 power '2' '15' -> '32768' powx024 power '2' '16' -> '65536' powx025 power '2' '31' -> '2.14748365E+9' Inexact Rounded -- NB 0 not stripped in next powx026 power '2' '32' -> '4.29496730E+9' Inexact Rounded precision: 10 powx027 power '2' '31' -> '2147483648' powx028 power '2' '32' -> '4294967296' precision: 9 powx030 power '3' '2' -> 9 powx031 power '4' '2' -> 16 powx032 power '5' '2' -> 25 powx033 power '6' '2' -> 36 powx034 power '7' '2' -> 49 powx035 power '8' '2' -> 64 powx036 power '9' '2' -> 81 powx037 power '10' '2' -> 100 powx038 power '11' '2' -> 121 powx039 power '12' '2' -> 144 powx040 power '3' '3' -> 27 powx041 power '4' '3' -> 64 powx042 power '5' '3' -> 125 powx043 power '6' '3' -> 216 powx044 power '7' '3' -> 343 powx050 power '10' '0' -> 1 powx051 power '10' '1' -> 10 powx052 power '10' '2' -> 100 powx053 power '10' '3' -> 1000 powx054 power '10' '4' -> 10000 powx055 power '10' '5' -> 100000 powx056 power '10' '6' -> 1000000 powx057 power '10' '7' -> 10000000 powx058 power '10' '8' -> 100000000 powx059 power '10' '9' -> 1.00000000E+9 Rounded powx060 power '10' '22' -> 1.00000000E+22 Rounded powx061 power '10' '77' -> 1.00000000E+77 Rounded powx062 power '10' '99' -> 1.00000000E+99 Rounded maxexponent: 999999999 minexponent: -999999999 powx063 power '10' '999999999' -> '1.00000000E+999999999' Rounded powx064 power '10' '999999998' -> '1.00000000E+999999998' Rounded powx065 power '10' '999999997' -> '1.00000000E+999999997' Rounded powx066 power '10' '333333333' -> '1.00000000E+333333333' Rounded powx070 power '0.3' '0' -> '1' powx071 power '0.3' '1' -> '0.3' powx072 power '0.3' '1.00' -> '0.3' powx073 power '0.3' '2.00' -> '0.09' powx074 power '0.3' '2.000000000' -> '0.09' powx075 power '6.0' '1' -> '6.0' -- NB zeros not stripped powx076 power '6.0' '2' -> '36.00' -- .. powx077 power '-3' '2' -> '9' -- from NetRexx book powx078 power '4' '3' -> '64' -- .. (sort of) powx080 power 0.1 0 -> 1 powx081 power 0.1 1 -> 0.1 powx082 power 0.1 2 -> 0.01 powx083 power 0.1 3 -> 0.001 powx084 power 0.1 4 -> 0.0001 powx085 power 0.1 5 -> 0.00001 powx086 power 0.1 6 -> 0.000001 powx087 power 0.1 7 -> 1E-7 powx088 power 0.1 8 -> 1E-8 powx089 power 0.1 9 -> 1E-9 powx090 power 101 2 -> 10201 powx091 power 101 3 -> 1030301 powx092 power 101 4 -> 104060401 powx093 power 101 5 -> 1.05101005E+10 Inexact Rounded powx094 power 101 6 -> 1.06152015E+12 Inexact Rounded powx095 power 101 7 -> 1.07213535E+14 Inexact Rounded -- negative powers powx101 power '2' '-1' -> 0.5 powx102 power '2' '-2' -> 0.25 powx103 power '2' '-4' -> 0.0625 powx104 power '2' '-8' -> 0.00390625 powx105 power '2' '-16' -> 0.0000152587891 Inexact Rounded powx106 power '2' '-32' -> 2.32830644E-10 Inexact Rounded powx108 power '2' '-64' -> 5.42101086E-20 Inexact Rounded powx110 power '10' '-8' -> 1E-8 powx111 power '10' '-7' -> 1E-7 powx112 power '10' '-6' -> 0.000001 powx113 power '10' '-5' -> 0.00001 powx114 power '10' '-4' -> 0.0001 powx115 power '10' '-3' -> 0.001 powx116 power '10' '-2' -> 0.01 powx117 power '10' '-1' -> 0.1 powx118 power '10' '-333333333' -> 1E-333333333 powx119 power '10' '-999999998' -> 1E-999999998 powx120 power '10' '-999999999' -> 1E-999999999 powx121 power '10' '-77' -> '1E-77' powx122 power '10' '-22' -> '1E-22' powx123 power '2' '-1' -> '0.5' powx124 power '2' '-2' -> '0.25' powx125 power '2' '-4' -> '0.0625' powx126 power '0' '-1' -> Infinity Division_by_zero powx127 power '0' '-2' -> Infinity Division_by_zero powx128 power -0 '-1' -> -Infinity Division_by_zero powx129 power -0 '-2' -> Infinity Division_by_zero -- out-of-range edge cases powx181 power '7' '999999998' -> 2.10892313E+845098038 Inexact Rounded powx182 power '7' '999999999' -> 1.47624619E+845098039 Inexact Rounded powx183 power '7' '1000000000' -> NaN Invalid_operation powx184 power '7' '1000000001' -> NaN Invalid_operation powx185 power '7' '10000000000' -> NaN Invalid_operation powx186 power '7' '-1000000001' -> NaN Invalid_operation powx187 power '7' '-1000000000' -> NaN Invalid_operation powx189 power '7' '-999999999' -> 6.77393787E-845098040 Inexact Rounded powx190 power '7' '-999999998' -> 4.74175651E-845098039 Inexact Rounded -- some baddies [more below] powx191 power '2' '2.000001' -> NaN Invalid_operation powx192 power '2' '2.00000000' -> 4 powx193 power '2' '2.000000001' -> NaN Invalid_operation powx194 power '2' '2.0000000001' -> NaN Invalid_operation -- "0.5" tests from original Rexx diagnostics [loop unrolled] powx200 power 0.5 0 -> 1 powx201 power 0.5 1 -> 0.5 powx202 power 0.5 2 -> 0.25 powx203 power 0.5 3 -> 0.125 powx204 power 0.5 4 -> 0.0625 powx205 power 0.5 5 -> 0.03125 powx206 power 0.5 6 -> 0.015625 powx207 power 0.5 7 -> 0.0078125 powx208 power 0.5 8 -> 0.00390625 powx209 power 0.5 9 -> 0.001953125 powx210 power 0.5 10 -> 0.0009765625 -- A (rare) case where the last digit is not within 0.5 ULP precision: 9 powx215 power "-21971575.0E+31454441" "-7" -> "-4.04549503E-220181139" Inexact Rounded precision: 20 powx216 power "-21971575.0E+31454441" "-7" -> "-4.0454950249324891788E-220181139" Inexact Rounded -- The Vienna case. Checks both setup and 1/acc working precision -- Modified 1998.12.14 as RHS no longer rounded before use (must fit) -- Modified 1990.02.04 as LHS is now rounded (instead of truncated to guard) -- '123456789E+10' -- lhs .. rounded to 1.23E+18 -- '-1.23000e+2' -- rhs .. [was: -1.23455e+2, rounds to -123] -- Modified 2002.10.06 -- finally, no input rounding -- With input rounding, result would be 8.74E-2226 precision: 3 powx219 power '123456789E+10' '-1.23000e+2' -> '5.54E-2226' Inexact Rounded -- whole number checks precision: 9 powx221 power 1 1234 -> 1 precision: 4 powx222 power 1 1234 -> 1 precision: 3 powx223 power 1 1234 -> 1 powx224 power 1 12.34e+2 -> 1 powx225 power 1 12.3 -> NaN Invalid_operation powx226 power 1 12.0 -> 1 powx227 power 1 1.01 -> NaN Invalid_operation powx228 power 2 1.00 -> 2 powx229 power 2 2.00 -> 4 precision: 9 powx230 power 1 1.0001 -> NaN Invalid_operation powx231 power 1 1.0000001 -> NaN Invalid_operation powx232 power 1 1.0000000001 -> NaN Invalid_operation powx233 power 1 1.0000000000001 -> NaN Invalid_operation precision: 5 powx234 power 1 1.0001 -> NaN Invalid_operation powx235 power 1 1.0000001 -> NaN Invalid_operation powx236 power 1 1.0000000001 -> NaN Invalid_operation powx237 power 1 1.0000000000001 -> NaN Invalid_operation powx238 power 1 1.0000000000001 -> NaN Invalid_operation maxexponent: 999999999 minexponent: -999999999 powx239 power 1 5.67E-987654321 -> NaN Invalid_operation powx240 power 1 100000000 -> 1 powx241 power 1 999999998 -> 1 powx242 power 1 999999999 -> 1 powx243 power 1 1000000000 -> NaN Invalid_operation powx244 power 1 9999999999 -> NaN Invalid_operation -- Checks for 'Too much precision needed' -- For x^12, digits+elength+1 = digits+3 precision: 999999999 powx249 add 1 1 -> 2 -- check basic operation at this precision powx250 power 2 12 -> Infinity Overflow precision: 999999998 powx251 power 2 12 -> Infinity Overflow precision: 999999997 powx252 power 2 12 -> Infinity Overflow precision: 999999996 powx253 power 2 12 -> 4096 precision: 999999995 powx254 power 2 12 -> 4096 -- zeros maxexponent: +96 minexponent: -95 precision: 7 powx260 power 0E-34 3 -> 0E-101 Clamped powx261 power 0E-33 3 -> 0E-99 powx262 power 0E-32 3 -> 0E-96 powx263 power 0E-30 3 -> 0E-90 powx264 power 0E-10 3 -> 0E-30 powx265 power 0E-1 3 -> 0.000 powx266 power 0E+0 3 -> 0 powx267 power 0 3 -> 0 powx268 power 0E+1 3 -> 0E+3 powx269 power 0E+10 3 -> 0E+30 powx270 power 0E+30 3 -> 0E+90 powx271 power 0E+32 3 -> 0E+96 powx272 power 0E+33 3 -> 0E+96 Clamped -- overflow and underflow tests maxexponent: 999999999 minexponent: -999999999 precision: 9 powx280 power 9 999999999 -> 3.05550054E+954242508 Inexact Rounded powx281 power 10 999999999 -> 1.00000000E+999999999 Rounded powx282 power 10.0001 999999999 -> Infinity Overflow Inexact Rounded powx283 power 10.1 999999999 -> Infinity Overflow Inexact Rounded powx284 power 11 999999999 -> Infinity Overflow Inexact Rounded powx285 power 12 999999999 -> Infinity Overflow Inexact Rounded powx286 power 999 999999999 -> Infinity Overflow Inexact Rounded powx287 power 999999 999999999 -> Infinity Overflow Inexact Rounded powx288 power 999999999 999999999 -> Infinity Overflow Inexact Rounded powx289 power 9.9E999999999 999999999 -> Infinity Overflow Inexact Rounded powx290 power 0.5 999999999 -> 4.33559594E-301029996 Inexact Rounded powx291 power 0.1 999999999 -> 1E-999999999 -- unrounded powx292 power 0.09 999999999 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped powx293 power 0.05 999999999 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped powx294 power 0.01 999999999 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped powx295 power 0.0001 999999999 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped powx297 power 0.0000001 999999999 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped powx298 power 0.0000000001 999999999 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped powx299 power 1E-999999999 999999999 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped powx310 power -9 999999999 -> -3.05550054E+954242508 Inexact Rounded powx311 power -10 999999999 -> -1.00000000E+999999999 Rounded powx312 power -10.0001 999999999 -> -Infinity Overflow Inexact Rounded powx313 power -10.1 999999999 -> -Infinity Overflow Inexact Rounded powx314 power -11 999999999 -> -Infinity Overflow Inexact Rounded powx315 power -12 999999999 -> -Infinity Overflow Inexact Rounded powx316 power -999 999999999 -> -Infinity Overflow Inexact Rounded powx317 power -999999 999999999 -> -Infinity Overflow Inexact Rounded powx318 power -999999999 999999999 -> -Infinity Overflow Inexact Rounded powx319 power -9.9E999999999 999999999 -> -Infinity Overflow Inexact Rounded powx320 power -0.5 999999999 -> -4.33559594E-301029996 Inexact Rounded powx321 power -0.1 999999999 -> -1E-999999999 powx322 power -0.09 999999999 -> -0E-1000000007 Underflow Subnormal Inexact Rounded Clamped powx323 power -0.05 999999999 -> -0E-1000000007 Underflow Subnormal Inexact Rounded Clamped powx324 power -0.01 999999999 -> -0E-1000000007 Underflow Subnormal Inexact Rounded Clamped powx325 power -0.0001 999999999 -> -0E-1000000007 Underflow Subnormal Inexact Rounded Clamped powx327 power -0.0000001 999999999 -> -0E-1000000007 Underflow Subnormal Inexact Rounded Clamped powx328 power -0.0000000001 999999999 -> -0E-1000000007 Underflow Subnormal Inexact Rounded Clamped powx329 power -1E-999999999 999999999 -> -0E-1000000007 Underflow Subnormal Inexact Rounded Clamped -- note no trim of next result powx330 power -9 999999998 -> 3.39500060E+954242507 Inexact Rounded powx331 power -10 999999998 -> 1.00000000E+999999998 Rounded powx332 power -10.0001 999999998 -> Infinity Overflow Inexact Rounded powx333 power -10.1 999999998 -> Infinity Overflow Inexact Rounded powx334 power -11 999999998 -> Infinity Overflow Inexact Rounded powx335 power -12 999999998 -> Infinity Overflow Inexact Rounded powx336 power -999 999999998 -> Infinity Overflow Inexact Rounded powx337 power -999999 999999998 -> Infinity Overflow Inexact Rounded powx338 power -999999999 999999998 -> Infinity Overflow Inexact Rounded powx339 power -9.9E999999999 999999998 -> Infinity Overflow Inexact Rounded powx340 power -0.5 999999998 -> 8.67119187E-301029996 Inexact Rounded powx341 power -0.1 999999998 -> 1E-999999998 -- NB exact unrounded powx342 power -0.09 999999998 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped powx343 power -0.05 999999998 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped powx344 power -0.01 999999998 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped powx345 power -0.0001 999999998 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped powx347 power -0.0000001 999999998 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped powx348 power -0.0000000001 999999998 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped powx349 power -1E-999999999 999999998 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped -- some subnormals precision: 9 -- [precision is 9, so smallest exponent is -1000000007 powx350 power 1e-1 500000000 -> 1E-500000000 powx351 power 1e-2 999999999 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped powx352 power 1e-2 500000000 -> 1E-1000000000 Subnormal powx353 power 1e-2 500000001 -> 1E-1000000002 Subnormal powx354 power 1e-2 500000002 -> 1E-1000000004 Subnormal powx355 power 1e-2 500000003 -> 1E-1000000006 Subnormal powx356 power 1e-2 500000004 -> 0E-1000000007 Underflow Subnormal Inexact Rounded powx360 power 0.010001 500000000 -> 4.34941988E-999978287 Inexact Rounded powx361 power 0.010000001 500000000 -> 5.18469257E-999999979 Inexact Rounded powx362 power 0.010000001 500000001 -> 5.18469309E-999999981 Inexact Rounded powx363 power 0.0100000009 500000000 -> 3.49342003E-999999981 Inexact Rounded powx364 power 0.0100000001 500000000 -> 1.48413155E-999999998 Inexact Rounded powx365 power 0.01 500000000 -> 1E-1000000000 Subnormal powx366 power 0.0099999999 500000000 -> 6.7379E-1000000003 Underflow Subnormal Inexact Rounded powx367 power 0.0099999998 500000000 -> 4.54E-1000000005 Underflow Subnormal Inexact Rounded powx368 power 0.0099999997 500000000 -> 3E-1000000007 Underflow Subnormal Inexact Rounded powx369 power 0.0099999996 500000000 -> 0E-1000000007 Underflow Subnormal Inexact Rounded powx370 power 0.009 500000000 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped -- 1/subnormal -> overflow powx371 power 1e-1 -500000000 -> 1E+500000000 powx372 power 1e-2 -999999999 -> Infinity Overflow Inexact Rounded powx373 power 1e-2 -500000000 -> Infinity Overflow Inexact Rounded powx374 power 1e-2 -500000001 -> Infinity Overflow Inexact Rounded powx375 power 1e-2 -500000002 -> Infinity Overflow Inexact Rounded powx376 power 1e-2 -500000003 -> Infinity Overflow Inexact Rounded powx377 power 1e-2 -500000004 -> Infinity Overflow Inexact Rounded powx381 power 0.010001 -500000000 -> 2.29915719E+999978286 Inexact Rounded powx382 power 0.010000001 -500000000 -> 1.92875467E+999999978 Inexact Rounded powx383 power 0.010000001 -500000001 -> 1.92875448E+999999980 Inexact Rounded powx384 power 0.0100000009 -500000000 -> 2.86252438E+999999980 Inexact Rounded powx385 power 0.0100000001 -500000000 -> 6.73794717E+999999997 Inexact Rounded powx386 power 0.01 -500000000 -> Infinity Overflow Inexact Rounded powx387 power 0.009999 -500000000 -> Infinity Overflow Inexact Rounded -- negative power giving subnormal powx388 power 100.000001 -500000000 -> 6.7379E-1000000003 Underflow Subnormal Inexact Rounded -- some more edge cases precision: 15 maxExponent: 999 minexponent: -999 powx391 power 0.1 999 -> 1E-999 powx392 power 0.099 999 -> 4.360732062E-1004 Underflow Subnormal Inexact Rounded powx393 power 0.098 999 -> 1.71731E-1008 Underflow Subnormal Inexact Rounded powx394 power 0.097 999 -> 6E-1013 Underflow Subnormal Inexact Rounded powx395 power 0.096 999 -> 0E-1013 Underflow Subnormal Inexact Rounded powx396 power 0.01 999 -> 0E-1013 Underflow Subnormal Inexact Rounded Clamped -- multiply tests are here to aid checking and test for consistent handling -- of underflow precision: 5 maxexponent: 999 minexponent: -999 -- squares mulx400 multiply 1E-502 1e-502 -> 0E-1003 Subnormal Inexact Underflow Rounded mulx401 multiply 1E-501 1e-501 -> 1E-1002 Subnormal mulx402 multiply 2E-501 2e-501 -> 4E-1002 Subnormal mulx403 multiply 4E-501 4e-501 -> 1.6E-1001 Subnormal mulx404 multiply 10E-501 10e-501 -> 1.00E-1000 Subnormal mulx405 multiply 30E-501 30e-501 -> 9.00E-1000 Subnormal mulx406 multiply 40E-501 40e-501 -> 1.600E-999 powx400 power 1E-502 2 -> 0E-1003 Underflow Subnormal Inexact Rounded powx401 power 1E-501 2 -> 1E-1002 Subnormal powx402 power 2E-501 2 -> 4E-1002 Subnormal powx403 power 4E-501 2 -> 1.6E-1001 Subnormal powx404 power 10E-501 2 -> 1.00E-1000 Subnormal powx405 power 30E-501 2 -> 9.00E-1000 Subnormal powx406 power 40E-501 2 -> 1.600E-999 -- cubes mulx410 multiply 1E-670 1e-335 -> 0E-1003 Underflow Subnormal Inexact Rounded mulx411 multiply 1E-668 1e-334 -> 1E-1002 Subnormal mulx412 multiply 4E-668 2e-334 -> 8E-1002 Subnormal mulx413 multiply 9E-668 3e-334 -> 2.7E-1001 Subnormal mulx414 multiply 16E-668 4e-334 -> 6.4E-1001 Subnormal mulx415 multiply 25E-668 5e-334 -> 1.25E-1000 Subnormal mulx416 multiply 10E-668 100e-334 -> 1.000E-999 powx410 power 1E-335 3 -> 0E-1003 Underflow Subnormal Inexact Rounded powx411 power 1E-334 3 -> 1E-1002 Subnormal powx412 power 2E-334 3 -> 8E-1002 Subnormal powx413 power 3E-334 3 -> 2.7E-1001 Subnormal powx414 power 4E-334 3 -> 6.4E-1001 Subnormal powx415 power 5E-334 3 -> 1.25E-1000 Subnormal powx416 power 10E-334 3 -> 1.000E-999 -- negative powers, testing subnormals precision: 5 maxExponent: 999 minexponent: -999 powx421 power 2.5E-501 -2 -> Infinity Overflow Inexact Rounded powx422 power 2.5E-500 -2 -> 1.6E+999 powx423 power 2.5E+499 -2 -> 1.6E-999 powx424 power 2.5E+500 -2 -> 1.6E-1001 Subnormal powx425 power 2.5E+501 -2 -> 2E-1003 Underflow Subnormal Inexact Rounded powx426 power 2.5E+502 -2 -> 0E-1003 Underflow Subnormal Inexact Rounded powx427 power 0.25E+499 -2 -> 1.6E-997 powx428 power 0.25E+500 -2 -> 1.6E-999 powx429 power 0.25E+501 -2 -> 1.6E-1001 Subnormal powx430 power 0.25E+502 -2 -> 2E-1003 Underflow Subnormal Inexact Rounded powx431 power 0.25E+503 -2 -> 0E-1003 Underflow Subnormal Inexact Rounded powx432 power 0.04E+499 -2 -> 6.25E-996 powx433 power 0.04E+500 -2 -> 6.25E-998 powx434 power 0.04E+501 -2 -> 6.25E-1000 Subnormal powx435 power 0.04E+502 -2 -> 6.3E-1002 Underflow Subnormal Inexact Rounded powx436 power 0.04E+503 -2 -> 1E-1003 Underflow Subnormal Inexact Rounded powx437 power 0.04E+504 -2 -> 0E-1003 Underflow Subnormal Inexact Rounded powx441 power 0.04E+334 -3 -> 1.5625E-998 powx442 power 0.04E+335 -3 -> 1.56E-1001 Underflow Subnormal Inexact Rounded powx443 power 0.04E+336 -3 -> 0E-1003 Underflow Subnormal Inexact Rounded powx444 power 0.25E+333 -3 -> 6.4E-998 powx445 power 0.25E+334 -3 -> 6.4E-1001 Subnormal powx446 power 0.25E+335 -3 -> 1E-1003 Underflow Subnormal Inexact Rounded powx447 power 0.25E+336 -3 -> 0E-1003 Underflow Subnormal Inexact Rounded Clamped -- check sign for cubes and a few squares powx448 power -0.04E+334 -3 -> -1.5625E-998 powx449 power -0.04E+335 -3 -> -1.56E-1001 Underflow Subnormal Inexact Rounded powx450 power -0.04E+336 -3 -> -0E-1003 Underflow Subnormal Inexact Rounded powx451 power -0.25E+333 -3 -> -6.4E-998 powx452 power -0.25E+334 -3 -> -6.4E-1001 Subnormal powx453 power -0.25E+335 -3 -> -1E-1003 Underflow Subnormal Inexact Rounded powx454 power -0.25E+336 -3 -> -0E-1003 Underflow Subnormal Inexact Rounded Clamped powx455 power -0.04E+499 -2 -> 6.25E-996 powx456 power -0.04E+500 -2 -> 6.25E-998 powx457 power -0.04E+501 -2 -> 6.25E-1000 Subnormal powx458 power -0.04E+502 -2 -> 6.3E-1002 Underflow Subnormal Inexact Rounded -- test -0s precision: 9 powx560 power 0 0 -> NaN Invalid_operation powx561 power 0 -0 -> NaN Invalid_operation powx562 power -0 0 -> NaN Invalid_operation powx563 power -0 -0 -> NaN Invalid_operation powx564 power 1 0 -> 1 powx565 power 1 -0 -> 1 powx566 power -1 0 -> 1 powx567 power -1 -0 -> 1 powx568 power 0 1 -> 0 powx569 power 0 -1 -> Infinity Division_by_zero powx570 power -0 1 -> -0 powx571 power -0 -1 -> -Infinity Division_by_zero powx572 power 0 2 -> 0 powx573 power 0 -2 -> Infinity Division_by_zero powx574 power -0 2 -> 0 powx575 power -0 -2 -> Infinity Division_by_zero powx576 power 0 3 -> 0 powx577 power 0 -3 -> Infinity Division_by_zero powx578 power -0 3 -> -0 powx579 power -0 -3 -> -Infinity Division_by_zero -- Specials powx580 power Inf -Inf -> NaN Invalid_operation powx581 power Inf -1000 -> 0 powx582 power Inf -1 -> 0 powx583 power Inf -0 -> 1 powx584 power Inf 0 -> 1 powx585 power Inf 1 -> Infinity powx586 power Inf 1000 -> Infinity powx587 power Inf Inf -> NaN Invalid_operation powx588 power -1000 Inf -> NaN Invalid_operation powx589 power -Inf Inf -> NaN Invalid_operation powx590 power -1 Inf -> NaN Invalid_operation powx591 power -0 Inf -> NaN Invalid_operation powx592 power 0 Inf -> NaN Invalid_operation powx593 power 1 Inf -> NaN Invalid_operation powx594 power 1000 Inf -> NaN Invalid_operation powx595 power Inf Inf -> NaN Invalid_operation powx600 power -Inf -Inf -> NaN Invalid_operation powx601 power -Inf -1000 -> 0 powx602 power -Inf -1 -> -0 powx603 power -Inf -0 -> 1 powx604 power -Inf 0 -> 1 powx605 power -Inf 1 -> -Infinity powx606 power -Inf 1000 -> Infinity powx607 power -Inf Inf -> NaN Invalid_operation powx608 power -1000 Inf -> NaN Invalid_operation powx609 power -Inf -Inf -> NaN Invalid_operation powx610 power -1 -Inf -> NaN Invalid_operation powx611 power -0 -Inf -> NaN Invalid_operation powx612 power 0 -Inf -> NaN Invalid_operation powx613 power 1 -Inf -> NaN Invalid_operation powx614 power 1000 -Inf -> NaN Invalid_operation powx615 power Inf -Inf -> NaN Invalid_operation powx621 power NaN -Inf -> NaN Invalid_operation powx622 power NaN -1000 -> NaN powx623 power NaN -1 -> NaN powx624 power NaN -0 -> NaN powx625 power NaN 0 -> NaN powx626 power NaN 1 -> NaN powx627 power NaN 1000 -> NaN powx628 power NaN Inf -> NaN Invalid_operation powx629 power NaN NaN -> NaN powx630 power -Inf NaN -> NaN powx631 power -1000 NaN -> NaN powx632 power -1 NaN -> NaN powx633 power -0 NaN -> NaN powx634 power 0 NaN -> NaN powx635 power 1 NaN -> NaN powx636 power 1000 NaN -> NaN powx637 power Inf NaN -> NaN powx641 power sNaN -Inf -> NaN Invalid_operation powx642 power sNaN -1000 -> NaN Invalid_operation powx643 power sNaN -1 -> NaN Invalid_operation powx644 power sNaN -0 -> NaN Invalid_operation powx645 power sNaN 0 -> NaN Invalid_operation powx646 power sNaN 1 -> NaN Invalid_operation powx647 power sNaN 1000 -> NaN Invalid_operation powx648 power sNaN NaN -> NaN Invalid_operation powx649 power sNaN sNaN -> NaN Invalid_operation powx650 power NaN sNaN -> NaN Invalid_operation powx651 power -Inf sNaN -> NaN Invalid_operation powx652 power -1000 sNaN -> NaN Invalid_operation powx653 power -1 sNaN -> NaN Invalid_operation powx654 power -0 sNaN -> NaN Invalid_operation powx655 power 0 sNaN -> NaN Invalid_operation powx656 power 1 sNaN -> NaN Invalid_operation powx657 power 1000 sNaN -> NaN Invalid_operation powx658 power Inf sNaN -> NaN Invalid_operation powx659 power NaN sNaN -> NaN Invalid_operation -- NaN propagation powx660 power NaN3 sNaN7 -> NaN7 Invalid_operation powx661 power sNaN8 NaN6 -> NaN8 Invalid_operation powx662 power 1 sNaN7 -> NaN7 Invalid_operation powx663 power sNaN8 1 -> NaN8 Invalid_operation powx664 power Inf sNaN7 -> NaN7 Invalid_operation powx665 power sNaN8 Inf -> NaN Invalid_operation powx666 power Inf NaN9 -> NaN9 powx667 power NaN6 Inf -> NaN Invalid_operation powx668 power 1 NaN5 -> NaN5 powx669 power NaN2 1 -> NaN2 powx670 power NaN2 Nan4 -> NaN2 powx671 power NaN Nan4 -> NaN powx672 power NaN345 Nan -> NaN345 powx673 power Inf -sNaN7 -> -NaN7 Invalid_operation powx674 power -sNaN8 Inf -> NaN Invalid_operation powx675 power Inf -NaN9 -> -NaN9 powx676 power -NaN6 Inf -> NaN Invalid_operation powx677 power -NaN2 -Nan4 -> -NaN2 -- Examples from extended specification powx690 power Inf -2 -> 0 powx691 power Inf -1 -> 0 powx692 power Inf 0 -> 1 powx693 power Inf 1 -> Infinity powx694 power Inf 2 -> Infinity powx695 power -Inf -2 -> 0 powx696 power -Inf -1 -> -0 powx697 power -Inf 0 -> 1 powx698 power -Inf 1 -> -Infinity powx699 power -Inf 2 -> Infinity powx700 power 0 0 -> NaN Invalid_operation -- long operand and RHS range checks maxexponent: 999 minexponent: -999 precision: 9 powx701 power 12345678000 1 -> 1.23456780E+10 Rounded powx702 power 1234567800 1 -> 1.23456780E+9 Rounded powx703 power 1234567890 1 -> 1.23456789E+9 Rounded powx704 power 1234567891 1 -> 1.23456789E+9 Inexact Rounded powx705 power 12345678901 1 -> 1.23456789E+10 Inexact Rounded powx706 power 1234567896 1 -> 1.23456790E+9 Inexact Rounded powx707 power 1 12345678000 -> NaN Invalid_operation powx708 power 1 1234567800 -> NaN Invalid_operation powx709 power 1 1234567890 -> NaN Invalid_operation powx710 power 1 11234567891 -> NaN Invalid_operation powx711 power 1 12345678901 -> NaN Invalid_operation powx712 power 1 1234567896 -> NaN Invalid_operation powx713 power 1 -1234567896 -> NaN Invalid_operation powx714 power 1 1000000000 -> NaN Invalid_operation powx715 power 1 -1000000000 -> NaN Invalid_operation precision: 15 -- still checking powx741 power 12345678000 1 -> 12345678000 powx742 power 1234567800 1 -> 1234567800 powx743 power 1234567890 1 -> 1234567890 powx744 power 1234567891 1 -> 1234567891 powx745 power 12345678901 1 -> 12345678901 powx746 power 1234567896 1 -> 1234567896 powx747 power 1 12345678000 -> NaN Invalid_operation powx748 power 1 -1234567896 -> NaN Invalid_operation powx749 power 1 1000000000 -> NaN Invalid_operation powx740 power 1 -1000000000 -> NaN Invalid_operation -- check for double-rounded subnormals precision: 5 maxexponent: 79 minexponent: -79 powx750 power 1.2347E-40 2 -> 1.524E-80 Inexact Rounded Subnormal Underflow -- Null tests powx900 power 1 # -> NaN Invalid_operation powx901 power # 1 -> NaN Invalid_operation --- NEW FILE: quantize.decTest --- ------------------------------------------------------------------------ -- quantize.decTest -- decimal quantize operation -- -- Copyright (c) IBM Corporation, 1981, 2004. All rights reserved. -- ------------------------------------------------------------------------ -- Please see the document "General Decimal Arithmetic Testcases" -- -- at http://www2.hursley.ibm.com/decimal for the description of -- -- these testcases. -- -- -- -- These testcases are experimental ('beta' versions), and they -- -- may contain errors. They are offered on an as-is basis. In -- -- particular, achieving the same results as the tests here is not -- -- a guarantee that an implementation complies with any Standard -- -- or specification. The tests are not exhaustive. -- -- -- -- Please send comments, suggestions, and corrections to the author: -- -- Mike Cowlishaw, IBM Fellow -- -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ version: 2.38 -- Most of the tests here assume a "regular pattern", where the -- sign and coefficient are +1. -- 2004.03.15 Underflow for quantize is suppressed extended: 1 precision: 9 rounding: half_up maxExponent: 999 minexponent: -999 -- sanity checks quax001 quantize 0 1e0 -> 0 quax002 quantize 1 1e0 -> 1 quax003 quantize 0.1 1e+2 -> 0E+2 Inexact Rounded quax005 quantize 0.1 1e+1 -> 0E+1 Inexact Rounded quax006 quantize 0.1 1e0 -> 0 Inexact Rounded quax007 quantize 0.1 1e-1 -> 0.1 quax008 quantize 0.1 1e-2 -> 0.10 quax009 quantize 0.1 1e-3 -> 0.100 quax010 quantize 0.9 1e+2 -> 0E+2 Inexact Rounded quax011 quantize 0.9 1e+1 -> 0E+1 Inexact Rounded quax012 quantize 0.9 1e+0 -> 1 Inexact Rounded quax013 quantize 0.9 1e-1 -> 0.9 quax014 quantize 0.9 1e-2 -> 0.90 quax015 quantize 0.9 1e-3 -> 0.900 -- negatives quax021 quantize -0 1e0 -> -0 quax022 quantize -1 1e0 -> -1 quax023 quantize -0.1 1e+2 -> -0E+2 Inexact Rounded quax025 quantize -0.1 1e+1 -> -0E+1 Inexact Rounded quax026 quantize -0.1 1e0 -> -0 Inexact Rounded quax027 quantize -0.1 1e-1 -> -0.1 quax028 quantize -0.1 1e-2 -> -0.10 quax029 quantize -0.1 1e-3 -> -0.100 quax030 quantize -0.9 1e+2 -> -0E+2 Inexact Rounded quax031 quantize -0.9 1e+1 -> -0E+1 Inexact Rounded quax032 quantize -0.9 1e+0 -> -1 Inexact Rounded quax033 quantize -0.9 1e-1 -> -0.9 quax034 quantize -0.9 1e-2 -> -0.90 quax035 quantize -0.9 1e-3 -> -0.900 quax036 quantize -0.5 1e+2 -> -0E+2 Inexact Rounded quax037 quantize -0.5 1e+1 -> -0E+1 Inexact Rounded quax038 quantize -0.5 1e+0 -> -1 Inexact Rounded quax039 quantize -0.5 1e-1 -> -0.5 quax040 quantize -0.5 1e-2 -> -0.50 quax041 quantize -0.5 1e-3 -> -0.500 quax042 quantize -0.9 1e+2 -> -0E+2 Inexact Rounded quax043 quantize -0.9 1e+1 -> -0E+1 Inexact Rounded quax044 quantize -0.9 1e+0 -> -1 Inexact Rounded quax045 quantize -0.9 1e-1 -> -0.9 quax046 quantize -0.9 1e-2 -> -0.90 quax047 quantize -0.9 1e-3 -> -0.900 -- examples from Specification quax060 quantize 2.17 0.001 -> 2.170 quax061 quantize 2.17 0.01 -> 2.17 quax062 quantize 2.17 0.1 -> 2.2 Inexact Rounded quax063 quantize 2.17 1e+0 -> 2 Inexact Rounded quax064 quantize 2.17 1e+1 -> 0E+1 Inexact Rounded quax065 quantize -Inf Inf -> -Infinity quax066 quantize 2 Inf -> NaN Invalid_operation quax067 quantize -0.1 1 -> -0 Inexact Rounded quax068 quantize -0 1e+5 -> -0E+5 quax069 quantize +35236450.6 1e-2 -> NaN Invalid_operation quax070 quantize -35236450.6 1e-2 -> NaN Invalid_operation quax071 quantize 217 1e-1 -> 217.0 quax072 quantize 217 1e+0 -> 217 quax073 quantize 217 1e+1 -> 2.2E+2 Inexact Rounded quax074 quantize 217 1e+2 -> 2E+2 Inexact Rounded -- general tests .. quax089 quantize 12 1e+4 -> 0E+4 Inexact Rounded quax090 quantize 12 1e+3 -> 0E+3 Inexact Rounded quax091 quantize 12 1e+2 -> 0E+2 Inexact Rounded quax092 quantize 12 1e+1 -> 1E+1 Inexact Rounded quax093 quantize 1.2345 1e-2 -> 1.23 Inexact Rounded quax094 quantize 1.2355 1e-2 -> 1.24 Inexact Rounded quax095 quantize 1.2345 1e-6 -> 1.234500 quax096 quantize 9.9999 1e-2 -> 10.00 Inexact Rounded quax097 quantize 0.0001 1e-2 -> 0.00 Inexact Rounded quax098 quantize 0.001 1e-2 -> 0.00 Inexact Rounded quax099 quantize 0.009 1e-2 -> 0.01 Inexact Rounded quax100 quantize 92 1e+2 -> 1E+2 Inexact Rounded quax101 quantize -1 1e0 -> -1 quax102 quantize -1 1e-1 -> -1.0 quax103 quantize -1 1e-2 -> -1.00 quax104 quantize 0 1e0 -> 0 quax105 quantize 0 1e-1 -> 0.0 quax106 quantize 0 1e-2 -> 0.00 quax107 quantize 0.00 1e0 -> 0 quax108 quantize 0 1e+1 -> 0E+1 quax109 quantize 0 1e+2 -> 0E+2 quax110 quantize +1 1e0 -> 1 quax111 quantize +1 1e-1 -> 1.0 quax112 quantize +1 1e-2 -> 1.00 quax120 quantize 1.04 1e-3 -> 1.040 quax121 quantize 1.04 1e-2 -> 1.04 quax122 quantize 1.04 1e-1 -> 1.0 Inexact Rounded quax123 quantize 1.04 1e0 -> 1 Inexact Rounded quax124 quantize 1.05 1e-3 -> 1.050 quax125 quantize 1.05 1e-2 -> 1.05 quax126 quantize 1.05 1e-1 -> 1.1 Inexact Rounded quax127 quantize 1.05 1e0 -> 1 Inexact Rounded quax128 quantize 1.05 1e-3 -> 1.050 quax129 quantize 1.05 1e-2 -> 1.05 quax130 quantize 1.05 1e-1 -> 1.1 Inexact Rounded quax131 quantize 1.05 1e0 -> 1 Inexact Rounded quax132 quantize 1.06 1e-3 -> 1.060 quax133 quantize 1.06 1e-2 -> 1.06 quax134 quantize 1.06 1e-1 -> 1.1 Inexact Rounded quax135 quantize 1.06 1e0 -> 1 Inexact Rounded quax140 quantize -10 1e-2 -> -10.00 quax141 quantize +1 1e-2 -> 1.00 quax142 quantize +10 1e-2 -> 10.00 quax143 quantize 1E+10 1e-2 -> NaN Invalid_operation quax144 quantize 1E-10 1e-2 -> 0.00 Inexact Rounded quax145 quantize 1E-3 1e-2 -> 0.00 Inexact Rounded quax146 quantize 1E-2 1e-2 -> 0.01 quax147 quantize 1E-1 1e-2 -> 0.10 quax148 quantize 0E-10 1e-2 -> 0.00 quax150 quantize 1.0600 1e-5 -> 1.06000 quax151 quantize 1.0600 1e-4 -> 1.0600 quax152 quantize 1.0600 1e-3 -> 1.060 Rounded quax153 quantize 1.0600 1e-2 -> 1.06 Rounded quax154 quantize 1.0600 1e-1 -> 1.1 Inexact Rounded quax155 quantize 1.0600 1e0 -> 1 Inexact Rounded -- base tests with non-1 coefficients quax161 quantize 0 -9e0 -> 0 quax162 quantize 1 -7e0 -> 1 quax163 quantize 0.1 -1e+2 -> 0E+2 Inexact Rounded quax165 quantize 0.1 0e+1 -> 0E+1 Inexact Rounded quax166 quantize 0.1 2e0 -> 0 Inexact Rounded quax167 quantize 0.1 3e-1 -> 0.1 quax168 quantize 0.1 44e-2 -> 0.10 quax169 quantize 0.1 555e-3 -> 0.100 quax170 quantize 0.9 6666e+2 -> 0E+2 Inexact Rounded quax171 quantize 0.9 -777e+1 -> 0E+1 Inexact Rounded quax172 quantize 0.9 -88e+0 -> 1 Inexact Rounded quax173 quantize 0.9 -9e-1 -> 0.9 quax174 quantize 0.9 0e-2 -> 0.90 quax175 quantize 0.9 1.1e-3 -> 0.9000 -- negatives quax181 quantize -0 1.1e0 -> -0.0 quax182 quantize -1 -1e0 -> -1 quax183 quantize -0.1 11e+2 -> -0E+2 Inexact Rounded quax185 quantize -0.1 111e+1 -> -0E+1 Inexact Rounded quax186 quantize -0.1 71e0 -> -0 Inexact Rounded quax187 quantize -0.1 -91e-1 -> -0.1 quax188 quantize -0.1 -.1e-2 -> -0.100 quax189 quantize -0.1 -1e-3 -> -0.100 quax190 quantize -0.9 0e+2 -> -0E+2 Inexact Rounded quax191 quantize -0.9 -0e+1 -> -0E+1 Inexact Rounded quax192 quantize -0.9 -10e+0 -> -1 Inexact Rounded quax193 quantize -0.9 100e-1 -> -0.9 quax194 quantize -0.9 999e-2 -> -0.90 -- +ve exponents .. quax201 quantize -1 1e+0 -> -1 quax202 quantize -1 1e+1 -> -0E+1 Inexact Rounded quax203 quantize -1 1e+2 -> -0E+2 Inexact Rounded quax204 quantize 0 1e+0 -> 0 quax205 quantize 0 1e+1 -> 0E+1 quax206 quantize 0 1e+2 -> 0E+2 quax207 quantize +1 1e+0 -> 1 quax208 quantize +1 1e+1 -> 0E+1 Inexact Rounded quax209 quantize +1 1e+2 -> 0E+2 Inexact Rounded quax220 quantize 1.04 1e+3 -> 0E+3 Inexact Rounded quax221 quantize 1.04 1e+2 -> 0E+2 Inexact Rounded quax222 quantize 1.04 1e+1 -> 0E+1 Inexact Rounded quax223 quantize 1.04 1e+0 -> 1 Inexact Rounded quax224 quantize 1.05 1e+3 -> 0E+3 Inexact Rounded quax225 quantize 1.05 1e+2 -> 0E+2 Inexact Rounded quax226 quantize 1.05 1e+1 -> 0E+1 Inexact Rounded quax227 quantize 1.05 1e+0 -> 1 Inexact Rounded quax228 quantize 1.05 1e+3 -> 0E+3 Inexact Rounded quax229 quantize 1.05 1e+2 -> 0E+2 Inexact Rounded quax230 quantize 1.05 1e+1 -> 0E+1 Inexact Rounded quax231 quantize 1.05 1e+0 -> 1 Inexact Rounded quax232 quantize 1.06 1e+3 -> 0E+3 Inexact Rounded quax233 quantize 1.06 1e+2 -> 0E+2 Inexact Rounded quax234 quantize 1.06 1e+1 -> 0E+1 Inexact Rounded quax235 quantize 1.06 1e+0 -> 1 Inexact Rounded quax240 quantize -10 1e+1 -> -1E+1 Rounded quax241 quantize +1 1e+1 -> 0E+1 Inexact Rounded quax242 quantize +10 1e+1 -> 1E+1 Rounded quax243 quantize 1E+1 1e+1 -> 1E+1 -- underneath this is E+1 quax244 quantize 1E+2 1e+1 -> 1.0E+2 -- underneath this is E+1 quax245 quantize 1E+3 1e+1 -> 1.00E+3 -- underneath this is E+1 quax246 quantize 1E+4 1e+1 -> 1.000E+4 -- underneath this is E+1 quax247 quantize 1E+5 1e+1 -> 1.0000E+5 -- underneath this is E+1 quax248 quantize 1E+6 1e+1 -> 1.00000E+6 -- underneath this is E+1 quax249 quantize 1E+7 1e+1 -> 1.000000E+7 -- underneath this is E+1 quax250 quantize 1E+8 1e+1 -> 1.0000000E+8 -- underneath this is E+1 quax251 quantize 1E+9 1e+1 -> 1.00000000E+9 -- underneath this is E+1 -- next one tries to add 9 zeros quax252 quantize 1E+10 1e+1 -> NaN Invalid_operation quax253 quantize 1E-10 1e+1 -> 0E+1 Inexact Rounded quax254 quantize 1E-2 1e+1 -> 0E+1 Inexact Rounded quax255 quantize 0E-10 1e+1 -> 0E+1 quax256 quantize -0E-10 1e+1 -> -0E+1 quax257 quantize -0E-1 1e+1 -> -0E+1 quax258 quantize -0 1e+1 -> -0E+1 quax259 quantize -0E+1 1e+1 -> -0E+1 quax260 quantize -10 1e+2 -> -0E+2 Inexact Rounded quax261 quantize +1 1e+2 -> 0E+2 Inexact Rounded quax262 quantize +10 1e+2 -> 0E+2 Inexact Rounded quax263 quantize 1E+1 1e+2 -> 0E+2 Inexact Rounded quax264 quantize 1E+2 1e+2 -> 1E+2 quax265 quantize 1E+3 1e+2 -> 1.0E+3 quax266 quantize 1E+4 1e+2 -> 1.00E+4 quax267 quantize 1E+5 1e+2 -> 1.000E+5 quax268 quantize 1E+6 1e+2 -> 1.0000E+6 quax269 quantize 1E+7 1e+2 -> 1.00000E+7 quax270 quantize 1E+8 1e+2 -> 1.000000E+8 quax271 quantize 1E+9 1e+2 -> 1.0000000E+9 quax272 quantize 1E+10 1e+2 -> 1.00000000E+10 quax273 quantize 1E-10 1e+2 -> 0E+2 Inexact Rounded quax274 quantize 1E-2 1e+2 -> 0E+2 Inexact Rounded quax275 quantize 0E-10 1e+2 -> 0E+2 quax280 quantize -10 1e+3 -> -0E+3 Inexact Rounded quax281 quantize +1 1e+3 -> 0E+3 Inexact Rounded quax282 quantize +10 1e+3 -> 0E+3 Inexact Rounded quax283 quantize 1E+1 1e+3 -> 0E+3 Inexact Rounded quax284 quantize 1E+2 1e+3 -> 0E+3 Inexact Rounded quax285 quantize 1E+3 1e+3 -> 1E+3 quax286 quantize 1E+4 1e+3 -> 1.0E+4 quax287 quantize 1E+5 1e+3 -> 1.00E+5 quax288 quantize 1E+6 1e+3 -> 1.000E+6 quax289 quantize 1E+7 1e+3 -> 1.0000E+7 quax290 quantize 1E+8 1e+3 -> 1.00000E+8 quax291 quantize 1E+9 1e+3 -> 1.000000E+9 quax292 quantize 1E+10 1e+3 -> 1.0000000E+10 quax293 quantize 1E-10 1e+3 -> 0E+3 Inexact Rounded quax294 quantize 1E-2 1e+3 -> 0E+3 Inexact Rounded quax295 quantize 0E-10 1e+3 -> 0E+3 -- round up from below [sign wrong in JIT compiler once] quax300 quantize 0.0078 1e-5 -> 0.00780 quax301 quantize 0.0078 1e-4 -> 0.0078 quax302 quantize 0.0078 1e-3 -> 0.008 Inexact Rounded quax303 quantize 0.0078 1e-2 -> 0.01 Inexact Rounded quax304 quantize 0.0078 1e-1 -> 0.0 Inexact Rounded quax305 quantize 0.0078 1e0 -> 0 Inexact Rounded quax306 quantize 0.0078 1e+1 -> 0E+1 Inexact Rounded quax307 quantize 0.0078 1e+2 -> 0E+2 Inexact Rounded quax310 quantize -0.0078 1e-5 -> -0.00780 quax311 quantize -0.0078 1e-4 -> -0.0078 quax312 quantize -0.0078 1e-3 -> -0.008 Inexact Rounded quax313 quantize -0.0078 1e-2 -> -0.01 Inexact Rounded quax314 quantize -0.0078 1e-1 -> -0.0 Inexact Rounded quax315 quantize -0.0078 1e0 -> -0 Inexact Rounded quax316 quantize -0.0078 1e+1 -> -0E+1 Inexact Rounded quax317 quantize -0.0078 1e+2 -> -0E+2 Inexact Rounded quax320 quantize 0.078 1e-5 -> 0.07800 quax321 quantize 0.078 1e-4 -> 0.0780 quax322 quantize 0.078 1e-3 -> 0.078 quax323 quantize 0.078 1e-2 -> 0.08 Inexact Rounded quax324 quantize 0.078 1e-1 -> 0.1 Inexact Rounded quax325 quantize 0.078 1e0 -> 0 Inexact Rounded quax326 quantize 0.078 1e+1 -> 0E+1 Inexact Rounded quax327 quantize 0.078 1e+2 -> 0E+2 Inexact Rounded quax330 quantize -0.078 1e-5 -> -0.07800 quax331 quantize -0.078 1e-4 -> -0.0780 quax332 quantize -0.078 1e-3 -> -0.078 quax333 quantize -0.078 1e-2 -> -0.08 Inexact Rounded quax334 quantize -0.078 1e-1 -> -0.1 Inexact Rounded quax335 quantize -0.078 1e0 -> -0 Inexact Rounded quax336 quantize -0.078 1e+1 -> -0E+1 Inexact Rounded quax337 quantize -0.078 1e+2 -> -0E+2 Inexact Rounded quax340 quantize 0.78 1e-5 -> 0.78000 quax341 quantize 0.78 1e-4 -> 0.7800 quax342 quantize 0.78 1e-3 -> 0.780 quax343 quantize 0.78 1e-2 -> 0.78 quax344 quantize 0.78 1e-1 -> 0.8 Inexact Rounded quax345 quantize 0.78 1e0 -> 1 Inexact Rounded quax346 quantize 0.78 1e+1 -> 0E+1 Inexact Rounded quax347 quantize 0.78 1e+2 -> 0E+2 Inexact Rounded quax350 quantize -0.78 1e-5 -> -0.78000 quax351 quantize -0.78 1e-4 -> -0.7800 quax352 quantize -0.78 1e-3 -> -0.780 quax353 quantize -0.78 1e-2 -> -0.78 quax354 quantize -0.78 1e-1 -> -0.8 Inexact Rounded quax355 quantize -0.78 1e0 -> -1 Inexact Rounded quax356 quantize -0.78 1e+1 -> -0E+1 Inexact Rounded quax357 quantize -0.78 1e+2 -> -0E+2 Inexact Rounded quax360 quantize 7.8 1e-5 -> 7.80000 quax361 quantize 7.8 1e-4 -> 7.8000 quax362 quantize 7.8 1e-3 -> 7.800 quax363 quantize 7.8 1e-2 -> 7.80 quax364 quantize 7.8 1e-1 -> 7.8 quax365 quantize 7.8 1e0 -> 8 Inexact Rounded quax366 quantize 7.8 1e+1 -> 1E+1 Inexact Rounded quax367 quantize 7.8 1e+2 -> 0E+2 Inexact Rounded quax368 quantize 7.8 1e+3 -> 0E+3 Inexact Rounded quax370 quantize -7.8 1e-5 -> -7.80000 quax371 quantize -7.8 1e-4 -> -7.8000 quax372 quantize -7.8 1e-3 -> -7.800 quax373 quantize -7.8 1e-2 -> -7.80 quax374 quantize -7.8 1e-1 -> -7.8 quax375 quantize -7.8 1e0 -> -8 Inexact Rounded quax376 quantize -7.8 1e+1 -> -1E+1 Inexact Rounded quax377 quantize -7.8 1e+2 -> -0E+2 Inexact Rounded quax378 quantize -7.8 1e+3 -> -0E+3 Inexact Rounded -- some individuals precision: 9 quax380 quantize 352364.506 1e-2 -> 352364.51 Inexact Rounded quax381 quantize 3523645.06 1e-2 -> 3523645.06 quax382 quantize 35236450.6 1e-2 -> NaN Invalid_operation quax383 quantize 352364506 1e-2 -> NaN Invalid_operation quax384 quantize -352364.506 1e-2 -> -352364.51 Inexact Rounded quax385 quantize -3523645.06 1e-2 -> -3523645.06 quax386 quantize -35236450.6 1e-2 -> NaN Invalid_operation quax387 quantize -352364506 1e-2 -> NaN Invalid_operation rounding: down quax389 quantize 35236450.6 1e-2 -> NaN Invalid_operation -- ? should that one instead have been: -- quax389 quantize 35236450.6 1e-2 -> NaN Invalid_operation rounding: half_up -- and a few more from e-mail discussions precision: 7 quax391 quantize 12.34567 1e-3 -> 12.346 Inexact Rounded quax392 quantize 123.4567 1e-3 -> 123.457 Inexact Rounded quax393 quantize 1234.567 1e-3 -> 1234.567 quax394 quantize 12345.67 1e-3 -> NaN Invalid_operation quax395 quantize 123456.7 1e-3 -> NaN Invalid_operation quax396 quantize 1234567. 1e-3 -> NaN Invalid_operation -- some 9999 round-up cases precision: 9 quax400 quantize 9.999 1e-5 -> 9.99900 quax401 quantize 9.999 1e-4 -> 9.9990 quax402 quantize 9.999 1e-3 -> 9.999 quax403 quantize 9.999 1e-2 -> 10.00 Inexact Rounded quax404 quantize 9.999 1e-1 -> 10.0 Inexact Rounded quax405 quantize 9.999 1e0 -> 10 Inexact Rounded quax406 quantize 9.999 1e1 -> 1E+1 Inexact Rounded quax407 quantize 9.999 1e2 -> 0E+2 Inexact Rounded quax410 quantize 0.999 1e-5 -> 0.99900 quax411 quantize 0.999 1e-4 -> 0.9990 quax412 quantize 0.999 1e-3 -> 0.999 quax413 quantize 0.999 1e-2 -> 1.00 Inexact Rounded quax414 quantize 0.999 1e-1 -> 1.0 Inexact Rounded quax415 quantize 0.999 1e0 -> 1 Inexact Rounded quax416 quantize 0.999 1e1 -> 0E+1 Inexact Rounded quax420 quantize 0.0999 1e-5 -> 0.09990 quax421 quantize 0.0999 1e-4 -> 0.0999 quax422 quantize 0.0999 1e-3 -> 0.100 Inexact Rounded quax423 quantize 0.0999 1e-2 -> 0.10 Inexact Rounded quax424 quantize 0.0999 1e-1 -> 0.1 Inexact Rounded quax425 quantize 0.0999 1e0 -> 0 Inexact Rounded quax426 quantize 0.0999 1e1 -> 0E+1 Inexact Rounded quax430 quantize 0.00999 1e-5 -> 0.00999 quax431 quantize 0.00999 1e-4 -> 0.0100 Inexact Rounded quax432 quantize 0.00999 1e-3 -> 0.010 Inexact Rounded quax433 quantize 0.00999 1e-2 -> 0.01 Inexact Rounded quax434 quantize 0.00999 1e-1 -> 0.0 Inexact Rounded quax435 quantize 0.00999 1e0 -> 0 Inexact Rounded quax436 quantize 0.00999 1e1 -> 0E+1 Inexact Rounded quax440 quantize 0.000999 1e-5 -> 0.00100 Inexact Rounded quax441 quantize 0.000999 1e-4 -> 0.0010 Inexact Rounded quax442 quantize 0.000999 1e-3 -> 0.001 Inexact Rounded quax443 quantize 0.000999 1e-2 -> 0.00 Inexact Rounded quax444 quantize 0.000999 1e-1 -> 0.0 Inexact Rounded quax445 quantize 0.000999 1e0 -> 0 Inexact Rounded quax446 quantize 0.000999 1e1 -> 0E+1 Inexact Rounded precision: 8 quax449 quantize 9.999E-15 1e-23 -> NaN Invalid_operation quax450 quantize 9.999E-15 1e-22 -> 9.9990000E-15 quax451 quantize 9.999E-15 1e-21 -> 9.999000E-15 quax452 quantize 9.999E-15 1e-20 -> 9.99900E-15 quax453 quantize 9.999E-15 1e-19 -> 9.9990E-15 quax454 quantize 9.999E-15 1e-18 -> 9.999E-15 quax455 quantize 9.999E-15 1e-17 -> 1.000E-14 Inexact Rounded quax456 quantize 9.999E-15 1e-16 -> 1.00E-14 Inexact Rounded quax457 quantize 9.999E-15 1e-15 -> 1.0E-14 Inexact Rounded quax458 quantize 9.999E-15 1e-14 -> 1E-14 Inexact Rounded quax459 quantize 9.999E-15 1e-13 -> 0E-13 Inexact Rounded quax460 quantize 9.999E-15 1e-12 -> 0E-12 Inexact Rounded quax461 quantize 9.999E-15 1e-11 -> 0E-11 Inexact Rounded quax462 quantize 9.999E-15 1e-10 -> 0E-10 Inexact Rounded quax463 quantize 9.999E-15 1e-9 -> 0E-9 Inexact Rounded quax464 quantize 9.999E-15 1e-8 -> 0E-8 Inexact Rounded quax465 quantize 9.999E-15 1e-7 -> 0E-7 Inexact Rounded quax466 quantize 9.999E-15 1e-6 -> 0.000000 Inexact Rounded quax467 quantize 9.999E-15 1e-5 -> 0.00000 Inexact Rounded quax468 quantize 9.999E-15 1e-4 -> 0.0000 Inexact Rounded quax469 quantize 9.999E-15 1e-3 -> 0.000 Inexact Rounded quax470 quantize 9.999E-15 1e-2 -> 0.00 Inexact Rounded quax471 quantize 9.999E-15 1e-1 -> 0.0 Inexact Rounded quax472 quantize 9.999E-15 1e0 -> 0 Inexact Rounded quax473 quantize 9.999E-15 1e1 -> 0E+1 Inexact Rounded -- long operand checks [rhs checks removed] maxexponent: 999 minexponent: -999 precision: 9 quax481 quantize 12345678000 1e+3 -> 1.2345678E+10 Rounded quax482 quantize 1234567800 1e+1 -> 1.23456780E+9 Rounded quax483 quantize 1234567890 1e+1 -> 1.23456789E+9 Rounded quax484 quantize 1234567891 1e+1 -> 1.23456789E+9 Inexact Rounded quax485 quantize 12345678901 1e+2 -> 1.23456789E+10 Inexact Rounded quax486 quantize 1234567896 1e+1 -> 1.23456790E+9 Inexact Rounded -- a potential double-round quax487 quantize 1234.987643 1e-4 -> 1234.9876 Inexact Rounded quax488 quantize 1234.987647 1e-4 -> 1234.9876 Inexact Rounded precision: 15 quax491 quantize 12345678000 1e+3 -> 1.2345678E+10 Rounded quax492 quantize 1234567800 1e+1 -> 1.23456780E+9 Rounded quax493 quantize 1234567890 1e+1 -> 1.23456789E+9 Rounded quax494 quantize 1234567891 1e+1 -> 1.23456789E+9 Inexact Rounded quax495 quantize 12345678901 1e+2 -> 1.23456789E+10 Inexact Rounded quax496 quantize 1234567896 1e+1 -> 1.23456790E+9 Inexact Rounded quax497 quantize 1234.987643 1e-4 -> 1234.9876 Inexact Rounded quax498 quantize 1234.987647 1e-4 -> 1234.9876 Inexact Rounded -- Zeros quax500 quantize 0 1e1 -> 0E+1 quax501 quantize 0 1e0 -> 0 quax502 quantize 0 1e-1 -> 0.0 quax503 quantize 0.0 1e-1 -> 0.0 quax504 quantize 0.0 1e0 -> 0 quax505 quantize 0.0 1e+1 -> 0E+1 quax506 quantize 0E+1 1e-1 -> 0.0 quax507 quantize 0E+1 1e0 -> 0 quax508 quantize 0E+1 1e+1 -> 0E+1 quax509 quantize -0 1e1 -> -0E+1 quax510 quantize -0 1e0 -> -0 quax511 quantize -0 1e-1 -> -0.0 quax512 quantize -0.0 1e-1 -> -0.0 quax513 quantize -0.0 1e0 -> -0 quax514 quantize -0.0 1e+1 -> -0E+1 quax515 quantize -0E+1 1e-1 -> -0.0 quax516 quantize -0E+1 1e0 -> -0 quax517 quantize -0E+1 1e+1 -> -0E+1 -- Suspicious RHS values maxexponent: 999999999 minexponent: -999999999 precision: 15 quax520 quantize 1.234 1e999999000 -> 0E+999999000 Inexact Rounded quax521 quantize 123.456 1e999999000 -> 0E+999999000 Inexact Rounded quax522 quantize 1.234 1e999999999 -> 0E+999999999 Inexact Rounded quax523 quantize 123.456 1e999999999 -> 0E+999999999 Inexact Rounded quax524 quantize 123.456 1e1000000000 -> NaN Invalid_operation quax525 quantize 123.456 1e12345678903 -> NaN Invalid_operation -- next four are "won't fit" overflows quax526 quantize 1.234 1e-999999000 -> NaN Invalid_operation quax527 quantize 123.456 1e-999999000 -> NaN Invalid_operation quax528 quantize 1.234 1e-999999999 -> NaN Invalid_operation quax529 quantize 123.456 1e-999999999 -> NaN Invalid_operation quax530 quantize 123.456 1e-1000000014 -> NaN Invalid_operation quax531 quantize 123.456 1e-12345678903 -> NaN Invalid_operation maxexponent: 999 minexponent: -999 precision: 15 quax532 quantize 1.234E+999 1e999 -> 1E+999 Inexact Rounded quax533 quantize 1.234E+998 1e999 -> 0E+999 Inexact Rounded quax534 quantize 1.234 1e999 -> 0E+999 Inexact Rounded quax535 quantize 1.234 1e1000 -> NaN Invalid_operation quax536 quantize 1.234 1e5000 -> NaN Invalid_operation quax537 quantize 0 1e-999 -> 0E-999 -- next two are "won't fit" overflows quax538 quantize 1.234 1e-999 -> NaN Invalid_operation quax539 quantize 1.234 1e-1000 -> NaN Invalid_operation quax540 quantize 1.234 1e-5000 -> NaN Invalid_operation -- [more below] -- check bounds (lhs maybe out of range for destination, etc.) precision: 7 quax541 quantize 1E+999 1e+999 -> 1E+999 quax542 quantize 1E+1000 1e+999 -> NaN Invalid_operation quax543 quantize 1E+999 1e+1000 -> NaN Invalid_operation quax544 quantize 1E-999 1e-999 -> 1E-999 quax545 quantize 1E-1000 1e-999 -> 0E-999 Inexact Rounded quax546 quantize 1E-999 1e-1000 -> 1.0E-999 quax547 quantize 1E-1005 1e-999 -> 0E-999 Inexact Rounded quax548 quantize 1E-1006 1e-999 -> 0E-999 Inexact Rounded quax549 quantize 1E-1007 1e-999 -> 0E-999 Inexact Rounded quax550 quantize 1E-998 1e-1005 -> NaN Invalid_operation -- won't fit quax551 quantize 1E-999 1e-1005 -> 1.000000E-999 quax552 quantize 1E-1000 1e-1005 -> 1.00000E-1000 Subnormal quax553 quantize 1E-999 1e-1006 -> NaN Invalid_operation quax554 quantize 1E-999 1e-1007 -> NaN Invalid_operation -- related subnormal rounding quax555 quantize 1.666666E-999 1e-1005 -> 1.666666E-999 quax556 quantize 1.666666E-1000 1e-1005 -> 1.66667E-1000 Subnormal Inexact Rounded quax557 quantize 1.666666E-1001 1e-1005 -> 1.6667E-1001 Subnormal Inexact Rounded quax558 quantize 1.666666E-1002 1e-1005 -> 1.667E-1002 Subnormal Inexact Rounded quax559 quantize 1.666666E-1003 1e-1005 -> 1.67E-1003 Subnormal Inexact Rounded quax560 quantize 1.666666E-1004 1e-1005 -> 1.7E-1004 Subnormal Inexact Rounded quax561 quantize 1.666666E-1005 1e-1005 -> 2E-1005 Subnormal Inexact Rounded quax562 quantize 1.666666E-1006 1e-1005 -> 0E-1005 Inexact Rounded quax563 quantize 1.666666E-1007 1e-1005 -> 0E-1005 Inexact Rounded -- Specials quax580 quantize Inf -Inf -> Infinity quax581 quantize Inf 1e-1000 -> NaN Invalid_operation quax582 quantize Inf 1e-1 -> NaN Invalid_operation quax583 quantize Inf 1e0 -> NaN Invalid_operation quax584 quantize Inf 1e1 -> NaN Invalid_operation quax585 quantize Inf 1e1000 -> NaN Invalid_operation quax586 quantize Inf Inf -> Infinity quax587 quantize -1000 Inf -> NaN Invalid_operation quax588 quantize -Inf Inf -> -Infinity quax589 quantize -1 Inf -> NaN Invalid_operation quax590 quantize 0 Inf -> NaN Invalid_operation quax591 quantize 1 Inf -> NaN Invalid_operation quax592 quantize 1000 Inf -> NaN Invalid_operation quax593 quantize Inf Inf -> Infinity quax594 quantize Inf 1e-0 -> NaN Invalid_operation quax595 quantize -0 Inf -> NaN Invalid_operation quax600 quantize -Inf -Inf -> -Infinity quax601 quantize -Inf 1e-1000 -> NaN Invalid_operation quax602 quantize -Inf 1e-1 -> NaN Invalid_operation quax603 quantize -Inf 1e0 -> NaN Invalid_operation quax604 quantize -Inf 1e1 -> NaN Invalid_operation quax605 quantize -Inf 1e1000 -> NaN Invalid_operation quax606 quantize -Inf Inf -> -Infinity quax607 quantize -1000 Inf -> NaN Invalid_operation quax608 quantize -Inf -Inf -> -Infinity quax609 quantize -1 -Inf -> NaN Invalid_operation quax610 quantize 0 -Inf -> NaN Invalid_operation quax611 quantize 1 -Inf -> NaN Invalid_operation quax612 quantize 1000 -Inf -> NaN Invalid_operation quax613 quantize Inf -Inf -> Infinity quax614 quantize -Inf 1e-0 -> NaN Invalid_operation quax615 quantize -0 -Inf -> NaN Invalid_operation quax621 quantize NaN -Inf -> NaN quax622 quantize NaN 1e-1000 -> NaN quax623 quantize NaN 1e-1 -> NaN quax624 quantize NaN 1e0 -> NaN quax625 quantize NaN 1e1 -> NaN quax626 quantize NaN 1e1000 -> NaN quax627 quantize NaN Inf -> NaN quax628 quantize NaN NaN -> NaN quax629 quantize -Inf NaN -> NaN quax630 quantize -1000 NaN -> NaN quax631 quantize -1 NaN -> NaN quax632 quantize 0 NaN -> NaN quax633 quantize 1 NaN -> NaN quax634 quantize 1000 NaN -> NaN quax635 quantize Inf NaN -> NaN quax636 quantize NaN 1e-0 -> NaN quax637 quantize -0 NaN -> NaN quax641 quantize sNaN -Inf -> NaN Invalid_operation quax642 quantize sNaN 1e-1000 -> NaN Invalid_operation quax643 quantize sNaN 1e-1 -> NaN Invalid_operation quax644 quantize sNaN 1e0 -> NaN Invalid_operation quax645 quantize sNaN 1e1 -> NaN Invalid_operation quax646 quantize sNaN 1e1000 -> NaN Invalid_operation quax647 quantize sNaN NaN -> NaN Invalid_operation quax648 quantize sNaN sNaN -> NaN Invalid_operation quax649 quantize NaN sNaN -> NaN Invalid_operation quax650 quantize -Inf sNaN -> NaN Invalid_operation quax651 quantize -1000 sNaN -> NaN Invalid_operation quax652 quantize -1 sNaN -> NaN Invalid_operation quax653 quantize 0 sNaN -> NaN Invalid_operation quax654 quantize 1 sNaN -> NaN Invalid_operation quax655 quantize 1000 sNaN -> NaN Invalid_operation quax656 quantize Inf sNaN -> NaN Invalid_operation quax657 quantize NaN sNaN -> NaN Invalid_operation quax658 quantize sNaN 1e-0 -> NaN Invalid_operation quax659 quantize -0 sNaN -> NaN Invalid_operation -- propagating NaNs quax661 quantize NaN9 -Inf -> NaN9 quax662 quantize NaN8 919 -> NaN8 quax663 quantize NaN71 Inf -> NaN71 quax664 quantize NaN6 NaN5 -> NaN6 quax665 quantize -Inf NaN4 -> NaN4 quax666 quantize -919 NaN31 -> NaN31 quax667 quantize Inf NaN2 -> NaN2 quax671 quantize sNaN99 -Inf -> NaN99 Invalid_operation quax672 quantize sNaN98 -11 -> NaN98 Invalid_operation quax673 quantize sNaN97 NaN -> NaN97 Invalid_operation quax674 quantize sNaN16 sNaN94 -> NaN16 Invalid_operation quax675 quantize NaN95 sNaN93 -> NaN93 Invalid_operation quax676 quantize -Inf sNaN92 -> NaN92 Invalid_operation quax677 quantize 088 sNaN91 -> NaN91 Invalid_operation quax678 quantize Inf sNaN90 -> NaN90 Invalid_operation quax679 quantize NaN sNaN88 -> NaN88 Invalid_operation quax681 quantize -NaN9 -Inf -> -NaN9 quax682 quantize -NaN8 919 -> -NaN8 quax683 quantize -NaN71 Inf -> -NaN71 quax684 quantize -NaN6 -NaN5 -> -NaN6 quax685 quantize -Inf -NaN4 -> -NaN4 quax686 quantize -919 -NaN31 -> -NaN31 quax687 quantize Inf -NaN2 -> -NaN2 quax691 quantize -sNaN99 -Inf -> -NaN99 Invalid_operation quax692 quantize -sNaN98 -11 -> -NaN98 Invalid_operation quax693 quantize -sNaN97 NaN -> -NaN97 Invalid_operation quax694 quantize -sNaN16 sNaN94 -> -NaN16 Invalid_operation quax695 quantize -NaN95 -sNaN93 -> -NaN93 Invalid_operation quax696 quantize -Inf -sNaN92 -> -NaN92 Invalid_operation quax697 quantize 088 -sNaN91 -> -NaN91 Invalid_operation quax698 quantize Inf -sNaN90 -> -NaN90 Invalid_operation quax699 quantize NaN -sNaN88 -> -NaN88 Invalid_operation -- subnormals and underflow precision: 4 maxexponent: 999 minexponent: -999 quax710 quantize 1.00E-999 1e-999 -> 1E-999 Rounded quax711 quantize 0.1E-999 2e-1000 -> 1E-1000 Subnormal quax712 quantize 0.10E-999 3e-1000 -> 1E-1000 Subnormal Rounded quax713 quantize 0.100E-999 4e-1000 -> 1E-1000 Subnormal Rounded quax714 quantize 0.01E-999 5e-1001 -> 1E-1001 Subnormal -- next is rounded to Emin quax715 quantize 0.999E-999 1e-999 -> 1E-999 Inexact Rounded quax716 quantize 0.099E-999 10e-1000 -> 1E-1000 Inexact Rounded Subnormal quax717 quantize 0.009E-999 1e-1001 -> 1E-1001 Inexact Rounded Subnormal quax718 quantize 0.001E-999 1e-1001 -> 0E-1001 Inexact Rounded quax719 quantize 0.0009E-999 1e-1001 -> 0E-1001 Inexact Rounded quax720 quantize 0.0001E-999 1e-1001 -> 0E-1001 Inexact Rounded quax730 quantize -1.00E-999 1e-999 -> -1E-999 Rounded quax731 quantize -0.1E-999 1e-999 -> -0E-999 Rounded Inexact quax732 quantize -0.10E-999 1e-999 -> -0E-999 Rounded Inexact quax733 quantize -0.100E-999 1e-999 -> -0E-999 Rounded Inexact quax734 quantize -0.01E-999 1e-999 -> -0E-999 Inexact Rounded -- next is rounded to Emin quax735 quantize -0.999E-999 90e-999 -> -1E-999 Inexact Rounded quax736 quantize -0.099E-999 -1e-999 -> -0E-999 Inexact Rounded quax737 quantize -0.009E-999 -1e-999 -> -0E-999 Inexact Rounded quax738 quantize -0.001E-999 -0e-999 -> -0E-999 Inexact Rounded quax739 quantize -0.0001E-999 0e-999 -> -0E-999 Inexact Rounded quax740 quantize -1.00E-999 1e-1000 -> -1.0E-999 Rounded quax741 quantize -0.1E-999 1e-1000 -> -1E-1000 Subnormal quax742 quantize -0.10E-999 1e-1000 -> -1E-1000 Subnormal Rounded quax743 quantize -0.100E-999 1e-1000 -> -1E-1000 Subnormal Rounded quax744 quantize -0.01E-999 1e-1000 -> -0E-1000 Inexact Rounded -- next is rounded to Emin quax745 quantize -0.999E-999 1e-1000 -> -1.0E-999 Inexact Rounded quax746 quantize -0.099E-999 1e-1000 -> -1E-1000 Inexact Rounded Subnormal quax747 quantize -0.009E-999 1e-1000 -> -0E-1000 Inexact Rounded quax748 quantize -0.001E-999 1e-1000 -> -0E-1000 Inexact Rounded quax749 quantize -0.0001E-999 1e-1000 -> -0E-1000 Inexact Rounded quax750 quantize -1.00E-999 1e-1001 -> -1.00E-999 quax751 quantize -0.1E-999 1e-1001 -> -1.0E-1000 Subnormal quax752 quantize -0.10E-999 1e-1001 -> -1.0E-1000 Subnormal quax753 quantize -0.100E-999 1e-1001 -> -1.0E-1000 Subnormal Rounded quax754 quantize -0.01E-999 1e-1001 -> -1E-1001 Subnormal -- next is rounded to Emin quax755 quantize -0.999E-999 1e-1001 -> -1.00E-999 Inexact Rounded quax756 quantize -0.099E-999 1e-1001 -> -1.0E-1000 Inexact Rounded Subnormal quax757 quantize -0.009E-999 1e-1001 -> -1E-1001 Inexact Rounded Subnormal quax758 quantize -0.001E-999 1e-1001 -> -0E-1001 Inexact Rounded quax759 quantize -0.0001E-999 1e-1001 -> -0E-1001 Inexact Rounded quax760 quantize -1.00E-999 1e-1002 -> -1.000E-999 quax761 quantize -0.1E-999 1e-1002 -> -1.00E-1000 Subnormal quax762 quantize -0.10E-999 1e-1002 -> -1.00E-1000 Subnormal quax763 quantize -0.100E-999 1e-1002 -> -1.00E-1000 Subnormal quax764 quantize -0.01E-999 1e-1002 -> -1.0E-1001 Subnormal quax765 quantize -0.999E-999 1e-1002 -> -9.99E-1000 Subnormal quax766 quantize -0.099E-999 1e-1002 -> -9.9E-1001 Subnormal quax767 quantize -0.009E-999 1e-1002 -> -9E-1002 Subnormal quax768 quantize -0.001E-999 1e-1002 -> -1E-1002 Subnormal quax769 quantize -0.0001E-999 1e-1002 -> -0E-1002 Inexact Rounded -- rhs must be no less than Etiny quax770 quantize -1.00E-999 1e-1003 -> NaN Invalid_operation quax771 quantize -0.1E-999 1e-1003 -> NaN Invalid_operation quax772 quantize -0.10E-999 1e-1003 -> NaN Invalid_operation quax773 quantize -0.100E-999 1e-1003 -> NaN Invalid_operation quax774 quantize -0.01E-999 1e-1003 -> NaN Invalid_operation quax775 quantize -0.999E-999 1e-1003 -> NaN Invalid_operation quax776 quantize -0.099E-999 1e-1003 -> NaN Invalid_operation quax777 quantize -0.009E-999 1e-1003 -> NaN Invalid_operation quax778 quantize -0.001E-999 1e-1003 -> NaN Invalid_operation quax779 quantize -0.0001E-999 1e-1003 -> NaN Invalid_operation quax780 quantize -0.0001E-999 1e-1004 -> NaN Invalid_operation precision: 9 maxExponent: 999999999 minexponent: -999999999 -- some extremes derived from Rescale testcases quax801 quantize 0 1e1000000000 -> NaN Invalid_operation quax802 quantize 0 1e-1000000000 -> 0E-1000000000 quax803 quantize 0 1e2000000000 -> NaN Invalid_operation quax804 quantize 0 1e-2000000000 -> NaN Invalid_operation quax805 quantize 0 1e3000000000 -> NaN Invalid_operation quax806 quantize 0 1e-3000000000 -> NaN Invalid_operation quax807 quantize 0 1e4000000000 -> NaN Invalid_operation quax808 quantize 0 1e-4000000000 -> NaN Invalid_operation quax809 quantize 0 1e5000000000 -> NaN Invalid_operation quax810 quantize 0 1e-5000000000 -> NaN Invalid_operation quax811 quantize 0 1e6000000000 -> NaN Invalid_operation quax812 quantize 0 1e-6000000000 -> NaN Invalid_operation quax813 quantize 0 1e7000000000 -> NaN Invalid_operation quax814 quantize 0 1e-7000000000 -> NaN Invalid_operation quax815 quantize 0 1e8000000000 -> NaN Invalid_operation quax816 quantize 0 1e-8000000000 -> NaN Invalid_operation quax817 quantize 0 1e9000000000 -> NaN Invalid_operation quax818 quantize 0 1e-9000000000 -> NaN Invalid_operation quax819 quantize 0 1e9999999999 -> NaN Invalid_operation quax820 quantize 0 1e-9999999999 -> NaN Invalid_operation quax821 quantize 0 1e10000000000 -> NaN Invalid_operation quax822 quantize 0 1e-10000000000 -> NaN Invalid_operation quax843 quantize 0 1e999999999 -> 0E+999999999 quax844 quantize 0 1e1000000000 -> NaN Invalid_operation quax845 quantize 0 1e-999999999 -> 0E-999999999 quax846 quantize 0 1e-1000000000 -> 0E-1000000000 quax847 quantize 0 1e-1000000001 -> 0E-1000000001 quax848 quantize 0 1e-1000000002 -> 0E-1000000002 quax849 quantize 0 1e-1000000003 -> 0E-1000000003 quax850 quantize 0 1e-1000000004 -> 0E-1000000004 quax851 quantize 0 1e-1000000005 -> 0E-1000000005 quax852 quantize 0 1e-1000000006 -> 0E-1000000006 quax853 quantize 0 1e-1000000007 -> 0E-1000000007 quax854 quantize 0 1e-1000000008 -> NaN Invalid_operation quax861 quantize 1 1e+2147483649 -> NaN Invalid_operation quax862 quantize 1 1e+2147483648 -> NaN Invalid_operation quax863 quantize 1 1e+2147483647 -> NaN Invalid_operation quax864 quantize 1 1e-2147483647 -> NaN Invalid_operation quax865 quantize 1 1e-2147483648 -> NaN Invalid_operation quax866 quantize 1 1e-2147483649 -> NaN Invalid_operation -- Null tests quax900 quantize 10 # -> NaN Invalid_operation quax901 quantize # 1e10 -> NaN Invalid_operation --- NEW FILE: randomBound32.decTest --- ------------------------------------------------------------------------ -- randomBound32.decTest -- decimal testcases -- boundaries near 32 -- -- Copyright (c) IBM Corporation, 1981, 2003. All rights reserved. -- ------------------------------------------------------------------------ -- Please see the document "General Decimal Arithmetic Testcases" -- -- at http://www2.hursley.ibm.com/decimal for the description of -- -- these testcases. -- -- -- -- These testcases are experimental ('beta' versions), and they -- -- may contain errors. They are offered on an as-is basis. In -- -- particular, achieving the same results as the tests here is not -- -- a guarantee that an implementation complies with any Standard -- -- or specification. The tests are not exhaustive. -- -- -- -- Please send comments, suggestions, and corrections to the author: -- -- Mike Cowlishaw, IBM Fellow -- -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ [...2404 lines suppressed...] mulx3498 multiply 91936087917435.5974889495278215874 -67080823344.8903392584327136082486E-757 -> -6.16714847260980448099292763939423E-733 Inexact Rounded powx3498 power 91936087917435.5974889495278215874 -7 -> 1.80134899939035708719659065082630E-98 Inexact Rounded remx3498 remainder 91936087917435.5974889495278215874 -67080823344.8903392584327136082486E-757 -> NaN Division_impossible subx3498 subtract 91936087917435.5974889495278215874 -67080823344.8903392584327136082486E-757 -> 91936087917435.5974889495278215874 Inexact Rounded addx3499 add -07345.6422518528556136521417259811E-600 41188325.7041362608934957584583381E-763 -> -7.34564225185285561365214172598110E-597 Inexact Rounded comx3499 compare -07345.6422518528556136521417259811E-600 41188325.7041362608934957584583381E-763 -> -1 divx3499 divide -07345.6422518528556136521417259811E-600 41188325.7041362608934957584583381E-763 -> -1.78342822299163842247184303878022E+159 Inexact Rounded dvix3499 divideint -07345.6422518528556136521417259811E-600 41188325.7041362608934957584583381E-763 -> NaN Division_impossible mulx3499 multiply -07345.6422518528556136521417259811E-600 41188325.7041362608934957584583381E-763 -> -3.02554705575380338274126867655676E-1352 Inexact Rounded powx3499 power -07345.6422518528556136521417259811E-600 4 -> 2.91151541552217582082937236255996E-2385 Inexact Rounded remx3499 remainder -07345.6422518528556136521417259811E-600 41188325.7041362608934957584583381E-763 -> NaN Division_impossible subx3499 subtract -07345.6422518528556136521417259811E-600 41188325.7041362608934957584583381E-763 -> -7.34564225185285561365214172598110E-597 Inexact Rounded addx3500 add -253280724.939458021588167965038184 616988.426425908872398170896375634E+396 -> 6.16988426425908872398170896375634E+401 Inexact Rounded comx3500 compare -253280724.939458021588167965038184 616988.426425908872398170896375634E+396 -> -1 divx3500 divide -253280724.939458021588167965038184 616988.426425908872398170896375634E+396 -> -4.10511306357337753351655511866170E-394 Inexact Rounded dvix3500 divideint -253280724.939458021588167965038184 616988.426425908872398170896375634E+396 -> -0 mulx3500 multiply -253280724.939458021588167965038184 616988.426425908872398170896375634E+396 -> -1.56271275924409657991913620522315E+410 Inexact Rounded powx3500 power -253280724.939458021588167965038184 6 -> 2.64005420221406808782284459794424E+50 Inexact Rounded remx3500 remainder -253280724.939458021588167965038184 616988.426425908872398170896375634E+396 -> -253280724.939458021588167965038184 subx3500 subtract -253280724.939458021588167965038184 616988.426425908872398170896375634E+396 -> -6.16988426425908872398170896375634E+401 Inexact Rounded --- NEW FILE: randoms.decTest --- ------------------------------------------------------------------------ -- randoms.decTest -- decimal random testcases -- -- Copyright (c) IBM Corporation, 1981, 2003. All rights reserved. -- ------------------------------------------------------------------------ -- Please see the document "General Decimal Arithmetic Testcases" -- -- at http://www2.hursley.ibm.com/decimal for the description of -- -- these testcases. -- -- -- -- These testcases are experimental ('beta' versions), and they -- -- may contain errors. They are offered on an as-is basis. In -- -- particular, achieving the same results as the tests here is not -- -- a guarantee that an implementation complies with any Standard -- -- or specification. The tests are not exhaustive. -- -- -- -- Please send comments, suggestions, and corrections to the author: -- -- Mike Cowlishaw, IBM Fellow -- -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ [...3990 lines suppressed...] xmul498 multiply -7.27403536 -481469656E-835183700 -> 3.50222730E-835183691 Inexact Rounded xpow498 power -7.27403536 -5 -> -0.0000491046885 Inexact Rounded xrem498 remainder -7.27403536 -481469656E-835183700 -> NaN Division_impossible xsub498 subtract -7.27403536 -481469656E-835183700 -> -7.27403536 Inexact Rounded xadd499 add -6157.74292 -94075286.2E+92555877 -> -9.40752862E+92555884 Inexact Rounded xcom499 compare -6157.74292 -94075286.2E+92555877 -> 1 xdiv499 divide -6157.74292 -94075286.2E+92555877 -> 6.54554790E-92555882 Inexact Rounded xdvi499 divideint -6157.74292 -94075286.2E+92555877 -> 0 xmul499 multiply -6157.74292 -94075286.2E+92555877 -> 5.79291428E+92555888 Inexact Rounded xpow499 power -6157.74292 -9 -> -7.85608218E-35 Inexact Rounded xrem499 remainder -6157.74292 -94075286.2E+92555877 -> -6157.74292 xsub499 subtract -6157.74292 -94075286.2E+92555877 -> 9.40752862E+92555884 Inexact Rounded xadd500 add -525445087.E+231529167 188227460 -> -5.25445087E+231529175 Inexact Rounded xcom500 compare -525445087.E+231529167 188227460 -> -1 xdiv500 divide -525445087.E+231529167 188227460 -> -2.79154321E+231529167 Inexact Rounded xdvi500 divideint -525445087.E+231529167 188227460 -> NaN Division_impossible xmul500 multiply -525445087.E+231529167 188227460 -> -9.89031941E+231529183 Inexact Rounded xpow500 power -525445087.E+231529167 188227460 -> Infinity Overflow Inexact Rounded xrem500 remainder -525445087.E+231529167 188227460 -> NaN Division_impossible xsub500 subtract -525445087.E+231529167 188227460 -> -5.25445087E+231529175 Inexact Rounded --- NEW FILE: remainder.decTest --- ------------------------------------------------------------------------ -- remainder.decTest -- decimal remainder -- -- Copyright (c) IBM Corporation, 1981, 2004. All rights reserved. -- ------------------------------------------------------------------------ -- Please see the document "General Decimal Arithmetic Testcases" -- -- at http://www2.hursley.ibm.com/decimal for the description of -- -- these testcases. -- -- -- -- These testcases are experimental ('beta' versions), and they -- -- may contain errors. They are offered on an as-is basis. In -- -- particular, achieving the same results as the tests here is not -- -- a guarantee that an implementation complies with any Standard -- -- or specification. The tests are not exhaustive. -- -- -- -- Please send comments, suggestions, and corrections to the author: -- -- Mike Cowlishaw, IBM Fellow -- -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ version: 2.38 extended: 1 precision: 9 rounding: half_up maxExponent: 384 minexponent: -383 -- sanity checks (as base, above) remx001 remainder 1 1 -> 0 remx002 remainder 2 1 -> 0 remx003 remainder 1 2 -> 1 remx004 remainder 2 2 -> 0 remx005 remainder 0 1 -> 0 remx006 remainder 0 2 -> 0 remx007 remainder 1 3 -> 1 remx008 remainder 2 3 -> 2 remx009 remainder 3 3 -> 0 remx010 remainder 2.4 1 -> 0.4 remx011 remainder 2.4 -1 -> 0.4 remx012 remainder -2.4 1 -> -0.4 remx013 remainder -2.4 -1 -> -0.4 remx014 remainder 2.40 1 -> 0.40 remx015 remainder 2.400 1 -> 0.400 remx016 remainder 2.4 2 -> 0.4 remx017 remainder 2.400 2 -> 0.400 remx018 remainder 2. 2 -> 0 remx019 remainder 20 20 -> 0 remx020 remainder 187 187 -> 0 remx021 remainder 5 2 -> 1 remx022 remainder 5 2.0 -> 1.0 remx023 remainder 5 2.000 -> 1.000 remx024 remainder 5 0.200 -> 0.000 remx025 remainder 5 0.200 -> 0.000 remx030 remainder 1 2 -> 1 remx031 remainder 1 4 -> 1 remx032 remainder 1 8 -> 1 remx033 remainder 1 16 -> 1 remx034 remainder 1 32 -> 1 remx035 remainder 1 64 -> 1 remx040 remainder 1 -2 -> 1 remx041 remainder 1 -4 -> 1 remx042 remainder 1 -8 -> 1 remx043 remainder 1 -16 -> 1 remx044 remainder 1 -32 -> 1 remx045 remainder 1 -64 -> 1 remx050 remainder -1 2 -> -1 remx051 remainder -1 4 -> -1 remx052 remainder -1 8 -> -1 remx053 remainder -1 16 -> -1 remx054 remainder -1 32 -> -1 remx055 remainder -1 64 -> -1 remx060 remainder -1 -2 -> -1 remx061 remainder -1 -4 -> -1 remx062 remainder -1 -8 -> -1 remx063 remainder -1 -16 -> -1 remx064 remainder -1 -32 -> -1 remx065 remainder -1 -64 -> -1 remx066 remainder 999999999 1 -> 0 remx067 remainder 999999999.4 1 -> 0.4 remx068 remainder 999999999.5 1 -> 0.5 remx069 remainder 999999999.9 1 -> 0.9 remx070 remainder 999999999.999 1 -> 0.999 precision: 6 remx071 remainder 999999999 1 -> NaN Division_impossible remx072 remainder 99999999 1 -> NaN Division_impossible remx073 remainder 9999999 1 -> NaN Division_impossible remx074 remainder 999999 1 -> 0 remx075 remainder 99999 1 -> 0 remx076 remainder 9999 1 -> 0 remx077 remainder 999 1 -> 0 remx078 remainder 99 1 -> 0 remx079 remainder 9 1 -> 0 precision: 9 remx080 remainder 0. 1 -> 0 remx081 remainder .0 1 -> 0.0 remx082 remainder 0.00 1 -> 0.00 remx083 remainder 0.00E+9 1 -> 0 remx084 remainder 0.00E+3 1 -> 0 remx085 remainder 0.00E+2 1 -> 0 remx086 remainder 0.00E+1 1 -> 0.0 remx087 remainder 0.00E+0 1 -> 0.00 remx088 remainder 0.00E-0 1 -> 0.00 remx089 remainder 0.00E-1 1 -> 0.000 remx090 remainder 0.00E-2 1 -> 0.0000 remx091 remainder 0.00E-3 1 -> 0.00000 remx092 remainder 0.00E-4 1 -> 0.000000 remx093 remainder 0.00E-5 1 -> 0E-7 remx094 remainder 0.00E-6 1 -> 0E-8 remx095 remainder 0.0000E-50 1 -> 0E-54 -- Various flavours of remainder by 0 precision: 9 maxexponent: 999999999 minexponent: -999999999 remx101 remainder 0 0 -> NaN Division_undefined remx102 remainder 0 -0 -> NaN Division_undefined remx103 remainder -0 0 -> NaN Division_undefined remx104 remainder -0 -0 -> NaN Division_undefined remx105 remainder 0.0E5 0 -> NaN Division_undefined remx106 remainder 0.000 0 -> NaN Division_undefined -- [Some think this next group should be Division_by_zero exception, but -- IEEE 854 is explicit that it is Invalid operation .. for -- remainder-near, anyway] remx107 remainder 0.0001 0 -> NaN Invalid_operation remx108 remainder 0.01 0 -> NaN Invalid_operation remx109 remainder 0.1 0 -> NaN Invalid_operation remx110 remainder 1 0 -> NaN Invalid_operation remx111 remainder 1 0.0 -> NaN Invalid_operation remx112 remainder 10 0.0 -> NaN Invalid_operation remx113 remainder 1E+100 0.0 -> NaN Invalid_operation remx114 remainder 1E+1000 0 -> NaN Invalid_operation remx115 remainder 0.0001 -0 -> NaN Invalid_operation remx116 remainder 0.01 -0 -> NaN Invalid_operation remx119 remainder 0.1 -0 -> NaN Invalid_operation remx120 remainder 1 -0 -> NaN Invalid_operation remx121 remainder 1 -0.0 -> NaN Invalid_operation remx122 remainder 10 -0.0 -> NaN Invalid_operation remx123 remainder 1E+100 -0.0 -> NaN Invalid_operation remx124 remainder 1E+1000 -0 -> NaN Invalid_operation -- and zeros on left remx130 remainder 0 1 -> 0 remx131 remainder 0 -1 -> 0 remx132 remainder 0.0 1 -> 0.0 remx133 remainder 0.0 -1 -> 0.0 remx134 remainder -0 1 -> -0 remx135 remainder -0 -1 -> -0 remx136 remainder -0.0 1 -> -0.0 remx137 remainder -0.0 -1 -> -0.0 -- 0.5ers remx143 remainder 0.5 2 -> 0.5 remx144 remainder 0.5 2.1 -> 0.5 remx145 remainder 0.5 2.01 -> 0.50 remx146 remainder 0.5 2.001 -> 0.500 remx147 remainder 0.50 2 -> 0.50 remx148 remainder 0.50 2.01 -> 0.50 remx149 remainder 0.50 2.001 -> 0.500 -- steadies remx150 remainder 1 1 -> 0 remx151 remainder 1 2 -> 1 remx152 remainder 1 3 -> 1 remx153 remainder 1 4 -> 1 remx154 remainder 1 5 -> 1 remx155 remainder 1 6 -> 1 remx156 remainder 1 7 -> 1 remx157 remainder 1 8 -> 1 remx158 remainder 1 9 -> 1 remx159 remainder 1 10 -> 1 remx160 remainder 1 1 -> 0 remx161 remainder 2 1 -> 0 remx162 remainder 3 1 -> 0 remx163 remainder 4 1 -> 0 remx164 remainder 5 1 -> 0 remx165 remainder 6 1 -> 0 remx166 remainder 7 1 -> 0 remx167 remainder 8 1 -> 0 remx168 remainder 9 1 -> 0 remx169 remainder 10 1 -> 0 -- some differences from remainderNear remx171 remainder 0.4 1.020 -> 0.400 remx172 remainder 0.50 1.020 -> 0.500 remx173 remainder 0.51 1.020 -> 0.510 remx174 remainder 0.52 1.020 -> 0.520 remx175 remainder 0.6 1.020 -> 0.600 -- More flavours of remainder by 0 maxexponent: 999999999 minexponent: -999999999 remx201 remainder 0 0 -> NaN Division_undefined remx202 remainder 0.0E5 0 -> NaN Division_undefined remx203 remainder 0.000 0 -> NaN Division_undefined remx204 remainder 0.0001 0 -> NaN Invalid_operation remx205 remainder 0.01 0 -> NaN Invalid_operation remx206 remainder 0.1 0 -> NaN Invalid_operation remx207 remainder 1 0 -> NaN Invalid_operation remx208 remainder 1 0.0 -> NaN Invalid_operation remx209 remainder 10 0.0 -> NaN Invalid_operation remx210 remainder 1E+100 0.0 -> NaN Invalid_operation remx211 remainder 1E+1000 0 -> NaN Invalid_operation -- some differences from remainderNear remx231 remainder -0.4 1.020 -> -0.400 remx232 remainder -0.50 1.020 -> -0.500 remx233 remainder -0.51 1.020 -> -0.510 remx234 remainder -0.52 1.020 -> -0.520 remx235 remainder -0.6 1.020 -> -0.600 -- high Xs remx240 remainder 1E+2 1.00 -> 0.00 -- test some cases that are close to exponent overflow maxexponent: 999999999 minexponent: -999999999 remx270 remainder 1 1e999999999 -> 1 remx271 remainder 1 0.9e999999999 -> 1 remx272 remainder 1 0.99e999999999 -> 1 remx273 remainder 1 0.999999999e999999999 -> 1 remx274 remainder 9e999999999 1 -> NaN Division_impossible remx275 remainder 9.9e999999999 1 -> NaN Division_impossible remx276 remainder 9.99e999999999 1 -> NaN Division_impossible remx277 remainder 9.99999999e999999999 1 -> NaN Division_impossible remx280 remainder 0.1 9e-999999999 -> NaN Division_impossible remx281 remainder 0.1 99e-999999999 -> NaN Division_impossible remx282 remainder 0.1 999e-999999999 -> NaN Division_impossible remx283 remainder 0.1 9e-999999998 -> NaN Division_impossible remx284 remainder 0.1 99e-999999998 -> NaN Division_impossible remx285 remainder 0.1 999e-999999998 -> NaN Division_impossible remx286 remainder 0.1 999e-999999997 -> NaN Division_impossible remx287 remainder 0.1 9999e-999999997 -> NaN Division_impossible remx288 remainder 0.1 99999e-999999997 -> NaN Division_impossible -- remx3xx are from DiagBigDecimal remx301 remainder 1 3 -> 1 remx302 remainder 5 5 -> 0 remx303 remainder 13 10 -> 3 remx304 remainder 13 50 -> 13 remx305 remainder 13 100 -> 13 remx306 remainder 13 1000 -> 13 remx307 remainder .13 1 -> 0.13 remx308 remainder 0.133 1 -> 0.133 remx309 remainder 0.1033 1 -> 0.1033 remx310 remainder 1.033 1 -> 0.033 remx311 remainder 10.33 1 -> 0.33 remx312 remainder 10.33 10 -> 0.33 remx313 remainder 103.3 1 -> 0.3 remx314 remainder 133 10 -> 3 remx315 remainder 1033 10 -> 3 remx316 remainder 1033 50 -> 33 remx317 remainder 101.0 3 -> 2.0 remx318 remainder 102.0 3 -> 0.0 remx319 remainder 103.0 3 -> 1.0 remx320 remainder 2.40 1 -> 0.40 remx321 remainder 2.400 1 -> 0.400 remx322 remainder 2.4 1 -> 0.4 remx323 remainder 2.4 2 -> 0.4 remx324 remainder 2.400 2 -> 0.400 remx325 remainder 1 0.3 -> 0.1 remx326 remainder 1 0.30 -> 0.10 remx327 remainder 1 0.300 -> 0.100 remx328 remainder 1 0.3000 -> 0.1000 remx329 remainder 1.0 0.3 -> 0.1 remx330 remainder 1.00 0.3 -> 0.10 remx331 remainder 1.000 0.3 -> 0.100 remx332 remainder 1.0000 0.3 -> 0.1000 remx333 remainder 0.5 2 -> 0.5 remx334 remainder 0.5 2.1 -> 0.5 remx335 remainder 0.5 2.01 -> 0.50 remx336 remainder 0.5 2.001 -> 0.500 remx337 remainder 0.50 2 -> 0.50 remx338 remainder 0.50 2.01 -> 0.50 remx339 remainder 0.50 2.001 -> 0.500 remx340 remainder 0.5 0.5000001 -> 0.5000000 remx341 remainder 0.5 0.50000001 -> 0.50000000 remx342 remainder 0.5 0.500000001 -> 0.500000000 remx343 remainder 0.5 0.5000000001 -> 0.500000000 Rounded remx344 remainder 0.5 0.50000000001 -> 0.500000000 Rounded remx345 remainder 0.5 0.4999999 -> 1E-7 remx346 remainder 0.5 0.49999999 -> 1E-8 remx347 remainder 0.5 0.499999999 -> 1E-9 remx348 remainder 0.5 0.4999999999 -> 1E-10 remx349 remainder 0.5 0.49999999999 -> 1E-11 remx350 remainder 0.5 0.499999999999 -> 1E-12 remx351 remainder 0.03 7 -> 0.03 remx352 remainder 5 2 -> 1 remx353 remainder 4.1 2 -> 0.1 remx354 remainder 4.01 2 -> 0.01 remx355 remainder 4.001 2 -> 0.001 remx356 remainder 4.0001 2 -> 0.0001 remx357 remainder 4.00001 2 -> 0.00001 remx358 remainder 4.000001 2 -> 0.000001 remx359 remainder 4.0000001 2 -> 1E-7 remx360 remainder 1.2 0.7345 -> 0.4655 remx361 remainder 0.8 12 -> 0.8 remx362 remainder 0.8 0.2 -> 0.0 remx363 remainder 0.8 0.3 -> 0.2 remx364 remainder 0.800 12 -> 0.800 remx365 remainder 0.800 1.7 -> 0.800 remx366 remainder 2.400 2 -> 0.400 precision: 6 remx371 remainder 2.400 2 -> 0.400 precision: 3 -- long operand, rounded, case remx372 remainder 12345678900000 12e+12 -> 3.46E+11 Inexact Rounded -- 12000000000000 precision: 5 remx381 remainder 12345 1 -> 0 remx382 remainder 12345 1.0001 -> 0.7657 remx383 remainder 12345 1.001 -> 0.668 remx384 remainder 12345 1.01 -> 0.78 remx385 remainder 12345 1.1 -> 0.8 remx386 remainder 12355 4 -> 3 remx387 remainder 12345 4 -> 1 remx388 remainder 12355 4.0001 -> 2.6912 remx389 remainder 12345 4.0001 -> 0.6914 remx390 remainder 12345 4.9 -> 1.9 remx391 remainder 12345 4.99 -> 4.73 remx392 remainder 12345 4.999 -> 2.469 remx393 remainder 12345 4.9999 -> 0.2469 remx394 remainder 12345 5 -> 0 remx395 remainder 12345 5.0001 -> 4.7532 remx396 remainder 12345 5.001 -> 2.532 remx397 remainder 12345 5.01 -> 0.36 remx398 remainder 12345 5.1 -> 3.0 precision: 9 -- the nasty division-by-1 cases remx401 remainder 0.5 1 -> 0.5 remx402 remainder 0.55 1 -> 0.55 remx403 remainder 0.555 1 -> 0.555 remx404 remainder 0.5555 1 -> 0.5555 remx405 remainder 0.55555 1 -> 0.55555 remx406 remainder 0.555555 1 -> 0.555555 remx407 remainder 0.5555555 1 -> 0.5555555 remx408 remainder 0.55555555 1 -> 0.55555555 remx409 remainder 0.555555555 1 -> 0.555555555 -- Specials remx680 remainder Inf -Inf -> NaN Invalid_operation remx681 remainder Inf -1000 -> NaN Invalid_operation remx682 remainder Inf -1 -> NaN Invalid_operation remx683 remainder Inf 0 -> NaN Invalid_operation remx684 remainder Inf -0 -> NaN Invalid_operation remx685 remainder Inf 1 -> NaN Invalid_operation remx686 remainder Inf 1000 -> NaN Invalid_operation remx687 remainder Inf Inf -> NaN Invalid_operation remx688 remainder -1000 Inf -> -1000 remx689 remainder -Inf Inf -> NaN Invalid_operation remx691 remainder -1 Inf -> -1 remx692 remainder 0 Inf -> 0 remx693 remainder -0 Inf -> -0 remx694 remainder 1 Inf -> 1 remx695 remainder 1000 Inf -> 1000 remx696 remainder Inf Inf -> NaN Invalid_operation remx700 remainder -Inf -Inf -> NaN Invalid_operation remx701 remainder -Inf -1000 -> NaN Invalid_operation remx702 remainder -Inf -1 -> NaN Invalid_operation remx703 remainder -Inf -0 -> NaN Invalid_operation remx704 remainder -Inf 0 -> NaN Invalid_operation remx705 remainder -Inf 1 -> NaN Invalid_operation remx706 remainder -Inf 1000 -> NaN Invalid_operation remx707 remainder -Inf Inf -> NaN Invalid_operation remx708 remainder -Inf -Inf -> NaN Invalid_operation remx709 remainder -1000 Inf -> -1000 remx710 remainder -1 -Inf -> -1 remx711 remainder -0 -Inf -> -0 remx712 remainder 0 -Inf -> 0 remx713 remainder 1 -Inf -> 1 remx714 remainder 1000 -Inf -> 1000 remx715 remainder Inf -Inf -> NaN Invalid_operation remx721 remainder NaN -Inf -> NaN remx722 remainder NaN -1000 -> NaN remx723 remainder NaN -1 -> NaN remx724 remainder NaN -0 -> NaN remx725 remainder -NaN 0 -> -NaN remx726 remainder NaN 1 -> NaN remx727 remainder NaN 1000 -> NaN remx728 remainder NaN Inf -> NaN remx729 remainder NaN -NaN -> NaN remx730 remainder -Inf NaN -> NaN remx731 remainder -1000 NaN -> NaN remx732 remainder -1 NaN -> NaN remx733 remainder -0 -NaN -> -NaN remx734 remainder 0 NaN -> NaN remx735 remainder 1 -NaN -> -NaN remx736 remainder 1000 NaN -> NaN remx737 remainder Inf NaN -> NaN remx741 remainder sNaN -Inf -> NaN Invalid_operation remx742 remainder sNaN -1000 -> NaN Invalid_operation remx743 remainder -sNaN -1 -> -NaN Invalid_operation remx744 remainder sNaN -0 -> NaN Invalid_operation remx745 remainder sNaN 0 -> NaN Invalid_operation remx746 remainder sNaN 1 -> NaN Invalid_operation remx747 remainder sNaN 1000 -> NaN Invalid_operation remx749 remainder sNaN NaN -> NaN Invalid_operation remx750 remainder sNaN sNaN -> NaN Invalid_operation remx751 remainder NaN sNaN -> NaN Invalid_operation remx752 remainder -Inf sNaN -> NaN Invalid_operation remx753 remainder -1000 sNaN -> NaN Invalid_operation remx754 remainder -1 sNaN -> NaN Invalid_operation remx755 remainder -0 sNaN -> NaN Invalid_operation remx756 remainder 0 sNaN -> NaN Invalid_operation remx757 remainder 1 sNaN -> NaN Invalid_operation remx758 remainder 1000 sNaN -> NaN Invalid_operation remx759 remainder Inf -sNaN -> -NaN Invalid_operation -- propaging NaNs remx760 remainder NaN1 NaN7 -> NaN1 remx761 remainder sNaN2 NaN8 -> NaN2 Invalid_operation remx762 remainder NaN3 sNaN9 -> NaN9 Invalid_operation remx763 remainder sNaN4 sNaN10 -> NaN4 Invalid_operation remx764 remainder 15 NaN11 -> NaN11 remx765 remainder NaN6 NaN12 -> NaN6 remx766 remainder Inf NaN13 -> NaN13 remx767 remainder NaN14 -Inf -> NaN14 remx768 remainder 0 NaN15 -> NaN15 remx769 remainder NaN16 -0 -> NaN16 -- test some cases that are close to exponent overflow maxexponent: 999999999 minexponent: -999999999 remx770 remainder 1 1e999999999 -> 1 remx771 remainder 1 0.9e999999999 -> 1 remx772 remainder 1 0.99e999999999 -> 1 remx773 remainder 1 0.999999999e999999999 -> 1 remx774 remainder 9e999999999 1 -> NaN Division_impossible remx775 remainder 9.9e999999999 1 -> NaN Division_impossible remx776 remainder 9.99e999999999 1 -> NaN Division_impossible remx777 remainder 9.99999999e999999999 1 -> NaN Division_impossible -- long operand checks maxexponent: 999 minexponent: -999 precision: 9 remx801 remainder 12345678000 100 -> 0 remx802 remainder 1 12345678000 -> 1 remx803 remainder 1234567800 10 -> 0 remx804 remainder 1 1234567800 -> 1 remx805 remainder 1234567890 10 -> 0 remx806 remainder 1 1234567890 -> 1 remx807 remainder 1234567891 10 -> 1 remx808 remainder 1 1234567891 -> 1 remx809 remainder 12345678901 100 -> 1 remx810 remainder 1 12345678901 -> 1 remx811 remainder 1234567896 10 -> 6 remx812 remainder 1 1234567896 -> 1 precision: 15 remx821 remainder 12345678000 100 -> 0 remx822 remainder 1 12345678000 -> 1 remx823 remainder 1234567800 10 -> 0 remx824 remainder 1 1234567800 -> 1 remx825 remainder 1234567890 10 -> 0 remx826 remainder 1 1234567890 -> 1 remx827 remainder 1234567891 10 -> 1 remx828 remainder 1 1234567891 -> 1 remx829 remainder 12345678901 100 -> 1 remx830 remainder 1 12345678901 -> 1 remx831 remainder 1234567896 10 -> 6 remx832 remainder 1 1234567896 -> 1 -- worries from divideint precision: 8 remx840 remainder 100000000.0 1 -> NaN Division_impossible remx841 remainder 100000000.4 1 -> NaN Division_impossible remx842 remainder 100000000.5 1 -> NaN Division_impossible remx843 remainder 100000000.9 1 -> NaN Division_impossible remx844 remainder 100000000.999 1 -> NaN Division_impossible precision: 6 remx850 remainder 100000003 5 -> NaN Division_impossible remx851 remainder 10000003 5 -> NaN Division_impossible remx852 remainder 1000003 5 -> 3 remx853 remainder 100003 5 -> 3 remx854 remainder 10003 5 -> 3 remx855 remainder 1003 5 -> 3 remx856 remainder 103 5 -> 3 remx857 remainder 13 5 -> 3 remx858 remainder 1 5 -> 1 -- Vladimir's cases remx860 remainder 123.0e1 10000000000000000 -> 1230 remx861 remainder 1230 10000000000000000 -> 1230 remx862 remainder 12.3e2 10000000000000000 -> 1230 remx863 remainder 1.23e3 10000000000000000 -> 1230 remx864 remainder 123e1 10000000000000000 -> 1230 remx870 remainder 123e1 1000000000000000 -> 1230 remx871 remainder 123e1 100000000000000 -> 1230 remx872 remainder 123e1 10000000000000 -> 1230 remx873 remainder 123e1 1000000000000 -> 1230 remx874 remainder 123e1 100000000000 -> 1230 remx875 remainder 123e1 10000000000 -> 1230 remx876 remainder 123e1 1000000000 -> 1230 remx877 remainder 123e1 100000000 -> 1230 remx878 remainder 1230 100000000 -> 1230 remx879 remainder 123e1 10000000 -> 1230 remx880 remainder 123e1 1000000 -> 1230 remx881 remainder 123e1 100000 -> 1230 remx882 remainder 123e1 10000 -> 1230 remx883 remainder 123e1 1000 -> 230 remx884 remainder 123e1 100 -> 30 remx885 remainder 123e1 10 -> 0 remx886 remainder 123e1 1 -> 0 remx889 remainder 123e1 20000000000000000 -> 1230 remx890 remainder 123e1 2000000000000000 -> 1230 remx891 remainder 123e1 200000000000000 -> 1230 remx892 remainder 123e1 20000000000000 -> 1230 remx893 remainder 123e1 2000000000000 -> 1230 remx894 remainder 123e1 200000000000 -> 1230 remx895 remainder 123e1 20000000000 -> 1230 remx896 remainder 123e1 2000000000 -> 1230 remx897 remainder 123e1 200000000 -> 1230 remx899 remainder 123e1 20000000 -> 1230 remx900 remainder 123e1 2000000 -> 1230 remx901 remainder 123e1 200000 -> 1230 remx902 remainder 123e1 20000 -> 1230 remx903 remainder 123e1 2000 -> 1230 remx904 remainder 123e1 200 -> 30 remx905 remainder 123e1 20 -> 10 remx906 remainder 123e1 2 -> 0 remx909 remainder 123e1 50000000000000000 -> 1230 remx910 remainder 123e1 5000000000000000 -> 1230 remx911 remainder 123e1 500000000000000 -> 1230 remx912 remainder 123e1 50000000000000 -> 1230 remx913 remainder 123e1 5000000000000 -> 1230 remx914 remainder 123e1 500000000000 -> 1230 remx915 remainder 123e1 50000000000 -> 1230 remx916 remainder 123e1 5000000000 -> 1230 remx917 remainder 123e1 500000000 -> 1230 remx919 remainder 123e1 50000000 -> 1230 remx920 remainder 123e1 5000000 -> 1230 remx921 remainder 123e1 500000 -> 1230 remx922 remainder 123e1 50000 -> 1230 remx923 remainder 123e1 5000 -> 1230 remx924 remainder 123e1 500 -> 230 remx925 remainder 123e1 50 -> 30 remx926 remainder 123e1 5 -> 0 remx929 remainder 123e1 90000000000000000 -> 1230 remx930 remainder 123e1 9000000000000000 -> 1230 remx931 remainder 123e1 900000000000000 -> 1230 remx932 remainder 123e1 90000000000000 -> 1230 remx933 remainder 123e1 9000000000000 -> 1230 remx934 remainder 123e1 900000000000 -> 1230 remx935 remainder 123e1 90000000000 -> 1230 remx936 remainder 123e1 9000000000 -> 1230 remx937 remainder 123e1 900000000 -> 1230 remx939 remainder 123e1 90000000 -> 1230 remx940 remainder 123e1 9000000 -> 1230 remx941 remainder 123e1 900000 -> 1230 remx942 remainder 123e1 90000 -> 1230 remx943 remainder 123e1 9000 -> 1230 remx944 remainder 123e1 900 -> 330 remx945 remainder 123e1 90 -> 60 remx946 remainder 123e1 9 -> 6 remx950 remainder 123e1 10000000000000000 -> 1230 remx951 remainder 123e1 100000000000000000 -> 1230 remx952 remainder 123e1 1000000000000000000 -> 1230 remx953 remainder 123e1 10000000000000000000 -> 1230 remx954 remainder 123e1 100000000000000000000 -> 1230 remx955 remainder 123e1 1000000000000000000000 -> 1230 remx956 remainder 123e1 10000000000000000000000 -> 1230 remx957 remainder 123e1 100000000000000000000000 -> 1230 remx958 remainder 123e1 1000000000000000000000000 -> 1230 remx959 remainder 123e1 10000000000000000000000000 -> 1230 remx960 remainder 123e1 19999999999999999 -> 1230 remx961 remainder 123e1 199999999999999990 -> 1230 remx962 remainder 123e1 1999999999999999999 -> 1230 remx963 remainder 123e1 19999999999999999990 -> 1230 remx964 remainder 123e1 199999999999999999999 -> 1230 remx965 remainder 123e1 1999999999999999999990 -> 1230 remx966 remainder 123e1 19999999999999999999999 -> 1230 remx967 remainder 123e1 199999999999999999999990 -> 1230 remx968 remainder 123e1 1999999999999999999999999 -> 1230 remx969 remainder 123e1 19999999999999999999999990 -> 1230 remx970 remainder 1e1 10000000000000000 -> 10 remx971 remainder 1e1 100000000000000000 -> 10 remx972 remainder 1e1 1000000000000000000 -> 10 remx973 remainder 1e1 10000000000000000000 -> 10 remx974 remainder 1e1 100000000000000000000 -> 10 remx975 remainder 1e1 1000000000000000000000 -> 10 remx976 remainder 1e1 10000000000000000000000 -> 10 remx977 remainder 1e1 100000000000000000000000 -> 10 remx978 remainder 1e1 1000000000000000000000000 -> 10 remx979 remainder 1e1 10000000000000000000000000 -> 10 remx980 remainder 123e1 1000E999999 -> 1.23E+3 -- 123E+1 internally -- overflow and underflow tests [from divide] precision: 9 maxexponent: 999999999 minexponent: -999999999 remx990 remainder +1.23456789012345E-0 9E+999999999 -> 1.23456789 Inexact Rounded remx991 remainder 9E+999999999 +0.23456789012345E-0 -> NaN Division_impossible remx992 remainder +0.100 9E+999999999 -> 0.100 remx993 remainder 9E-999999999 +9.100 -> 9E-999999999 remx995 remainder -1.23456789012345E-0 9E+999999999 -> -1.23456789 Inexact Rounded remx996 remainder 9E+999999999 -0.83456789012345E-0 -> NaN Division_impossible remx997 remainder -0.100 9E+999999999 -> -0.100 remx998 remainder 9E-999999999 -9.100 -> 9E-999999999 -- Null tests remx1000 remainder 10 # -> NaN Invalid_operation remx1001 remainder # 10 -> NaN Invalid_operation --- NEW FILE: remainderNear.decTest --- ------------------------------------------------------------------------ -- remainderNear.decTest -- decimal remainder-near (IEEE remainder) -- -- Copyright (c) IBM Corporation, 1981, 2004. All rights reserved. -- ------------------------------------------------------------------------ -- Please see the document "General Decimal Arithmetic Testcases" -- -- at http://www2.hursley.ibm.com/decimal for the description of -- -- these testcases. -- -- -- -- These testcases are experimental ('beta' versions), and they -- -- may contain errors. They are offered on an as-is basis. In -- -- particular, achieving the same results as the tests here is not -- -- a guarantee that an implementation complies with any Standard -- -- or specification. The tests are not exhaustive. -- -- -- -- Please send comments, suggestions, and corrections to the author: -- -- Mike Cowlishaw, IBM Fellow -- -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ version: 2.38 extended: 1 precision: 9 rounding: half_up maxExponent: 384 minexponent: -383 rmnx001 remaindernear 1 1 -> 0 rmnx002 remaindernear 2 1 -> 0 rmnx003 remaindernear 1 2 -> 1 rmnx004 remaindernear 2 2 -> 0 rmnx005 remaindernear 0 1 -> 0 rmnx006 remaindernear 0 2 -> 0 rmnx007 remaindernear 1 3 -> 1 rmnx008 remaindernear 2 3 -> -1 rmnx009 remaindernear 3 3 -> 0 rmnx010 remaindernear 2.4 1 -> 0.4 rmnx011 remaindernear 2.4 -1 -> 0.4 rmnx012 remaindernear -2.4 1 -> -0.4 rmnx013 remaindernear -2.4 -1 -> -0.4 rmnx014 remaindernear 2.40 1 -> 0.40 rmnx015 remaindernear 2.400 1 -> 0.400 rmnx016 remaindernear 2.4 2 -> 0.4 rmnx017 remaindernear 2.400 2 -> 0.400 rmnx018 remaindernear 2. 2 -> 0 rmnx019 remaindernear 20 20 -> 0 rmnx020 remaindernear 187 187 -> 0 rmnx021 remaindernear 5 2 -> 1 rmnx022 remaindernear 5 2.0 -> 1.0 rmnx023 remaindernear 5 2.000 -> 1.000 rmnx024 remaindernear 5 0.200 -> 0.000 rmnx025 remaindernear 5 0.200 -> 0.000 rmnx030 remaindernear 1 2 -> 1 rmnx031 remaindernear 1 4 -> 1 rmnx032 remaindernear 1 8 -> 1 rmnx033 remaindernear 1 16 -> 1 rmnx034 remaindernear 1 32 -> 1 rmnx035 remaindernear 1 64 -> 1 rmnx040 remaindernear 1 -2 -> 1 rmnx041 remaindernear 1 -4 -> 1 rmnx042 remaindernear 1 -8 -> 1 rmnx043 remaindernear 1 -16 -> 1 rmnx044 remaindernear 1 -32 -> 1 rmnx045 remaindernear 1 -64 -> 1 rmnx050 remaindernear -1 2 -> -1 rmnx051 remaindernear -1 4 -> -1 rmnx052 remaindernear -1 8 -> -1 rmnx053 remaindernear -1 16 -> -1 rmnx054 remaindernear -1 32 -> -1 rmnx055 remaindernear -1 64 -> -1 rmnx060 remaindernear -1 -2 -> -1 rmnx061 remaindernear -1 -4 -> -1 rmnx062 remaindernear -1 -8 -> -1 rmnx063 remaindernear -1 -16 -> -1 rmnx064 remaindernear -1 -32 -> -1 rmnx065 remaindernear -1 -64 -> -1 rmnx066 remaindernear 999999997 1 -> 0 rmnx067 remaindernear 999999997.4 1 -> 0.4 rmnx068 remaindernear 999999997.5 1 -> -0.5 rmnx069 remaindernear 999999997.9 1 -> -0.1 rmnx070 remaindernear 999999997.999 1 -> -0.001 rmnx071 remaindernear 999999998 1 -> 0 rmnx072 remaindernear 999999998.4 1 -> 0.4 rmnx073 remaindernear 999999998.5 1 -> 0.5 rmnx074 remaindernear 999999998.9 1 -> -0.1 rmnx075 remaindernear 999999998.999 1 -> -0.001 rmnx076 remaindernear 999999999 1 -> 0 rmnx077 remaindernear 999999999.4 1 -> 0.4 rmnx078 remaindernear 999999999.5 1 -> NaN Division_impossible rmnx079 remaindernear 999999999.9 1 -> NaN Division_impossible rmnx080 remaindernear 999999999.999 1 -> NaN Division_impossible precision: 6 rmnx081 remaindernear 999999999 1 -> NaN Division_impossible rmnx082 remaindernear 99999999 1 -> NaN Division_impossible rmnx083 remaindernear 9999999 1 -> NaN Division_impossible rmnx084 remaindernear 999999 1 -> 0 rmnx085 remaindernear 99999 1 -> 0 rmnx086 remaindernear 9999 1 -> 0 rmnx087 remaindernear 999 1 -> 0 rmnx088 remaindernear 99 1 -> 0 rmnx089 remaindernear 9 1 -> 0 precision: 9 rmnx090 remaindernear 0. 1 -> 0 rmnx091 remaindernear .0 1 -> 0.0 rmnx092 remaindernear 0.00 1 -> 0.00 rmnx093 remaindernear 0.00E+9 1 -> 0 rmnx094 remaindernear 0.0000E-50 1 -> 0E-54 -- Various flavours of remaindernear by 0 precision: 9 maxexponent: 999999999 minexponent: -999999999 rmnx101 remaindernear 0 0 -> NaN Division_undefined rmnx102 remaindernear 0 -0 -> NaN Division_undefined rmnx103 remaindernear -0 0 -> NaN Division_undefined rmnx104 remaindernear -0 -0 -> NaN Division_undefined rmnx105 remaindernear 0.0E5 0 -> NaN Division_undefined rmnx106 remaindernear 0.000 0 -> NaN Division_undefined -- [Some think this next group should be Division_by_zero exception, -- but IEEE 854 is explicit that it is Invalid operation .. for -- remaindernear-near, anyway] rmnx107 remaindernear 0.0001 0 -> NaN Invalid_operation rmnx108 remaindernear 0.01 0 -> NaN Invalid_operation rmnx109 remaindernear 0.1 0 -> NaN Invalid_operation rmnx110 remaindernear 1 0 -> NaN Invalid_operation rmnx111 remaindernear 1 0.0 -> NaN Invalid_operation rmnx112 remaindernear 10 0.0 -> NaN Invalid_operation rmnx113 remaindernear 1E+100 0.0 -> NaN Invalid_operation rmnx114 remaindernear 1E+1000 0 -> NaN Invalid_operation rmnx115 remaindernear 0.0001 -0 -> NaN Invalid_operation rmnx116 remaindernear 0.01 -0 -> NaN Invalid_operation rmnx119 remaindernear 0.1 -0 -> NaN Invalid_operation rmnx120 remaindernear 1 -0 -> NaN Invalid_operation rmnx121 remaindernear 1 -0.0 -> NaN Invalid_operation rmnx122 remaindernear 10 -0.0 -> NaN Invalid_operation rmnx123 remaindernear 1E+100 -0.0 -> NaN Invalid_operation rmnx124 remaindernear 1E+1000 -0 -> NaN Invalid_operation -- and zeros on left rmnx130 remaindernear 0 1 -> 0 rmnx131 remaindernear 0 -1 -> 0 rmnx132 remaindernear 0.0 1 -> 0.0 rmnx133 remaindernear 0.0 -1 -> 0.0 rmnx134 remaindernear -0 1 -> -0 rmnx135 remaindernear -0 -1 -> -0 rmnx136 remaindernear -0.0 1 -> -0.0 rmnx137 remaindernear -0.0 -1 -> -0.0 -- 0.5ers rmmx143 remaindernear 0.5 2 -> 0.5 rmmx144 remaindernear 0.5 2.1 -> 0.5 rmmx145 remaindernear 0.5 2.01 -> 0.50 rmmx146 remaindernear 0.5 2.001 -> 0.500 rmmx147 remaindernear 0.50 2 -> 0.50 rmmx148 remaindernear 0.50 2.01 -> 0.50 rmmx149 remaindernear 0.50 2.001 -> 0.500 -- some differences from remainder rmnx150 remaindernear 0.4 1.020 -> 0.400 rmnx151 remaindernear 0.50 1.020 -> 0.500 rmnx152 remaindernear 0.51 1.020 -> 0.510 rmnx153 remaindernear 0.52 1.020 -> -0.500 rmnx154 remaindernear 0.6 1.020 -> -0.420 rmnx155 remaindernear 0.49 1 -> 0.49 rmnx156 remaindernear 0.50 1 -> 0.50 rmnx157 remaindernear 1.50 1 -> -0.50 rmnx158 remaindernear 2.50 1 -> 0.50 rmnx159 remaindernear 9.50 1 -> -0.50 rmnx160 remaindernear 0.51 1 -> -0.49 -- the nasty division-by-1 cases rmnx161 remaindernear 0.4 1 -> 0.4 rmnx162 remaindernear 0.45 1 -> 0.45 rmnx163 remaindernear 0.455 1 -> 0.455 rmnx164 remaindernear 0.4555 1 -> 0.4555 rmnx165 remaindernear 0.45555 1 -> 0.45555 rmnx166 remaindernear 0.455555 1 -> 0.455555 rmnx167 remaindernear 0.4555555 1 -> 0.4555555 rmnx168 remaindernear 0.45555555 1 -> 0.45555555 rmnx169 remaindernear 0.455555555 1 -> 0.455555555 -- with spill... rmnx171 remaindernear 0.5 1 -> 0.5 rmnx172 remaindernear 0.55 1 -> -0.45 rmnx173 remaindernear 0.555 1 -> -0.445 rmnx174 remaindernear 0.5555 1 -> -0.4445 rmnx175 remaindernear 0.55555 1 -> -0.44445 rmnx176 remaindernear 0.555555 1 -> -0.444445 rmnx177 remaindernear 0.5555555 1 -> -0.4444445 rmnx178 remaindernear 0.55555555 1 -> -0.44444445 rmnx179 remaindernear 0.555555555 1 -> -0.444444445 -- progression rmnx180 remaindernear 1 1 -> 0 rmnx181 remaindernear 1 2 -> 1 rmnx182 remaindernear 1 3 -> 1 rmnx183 remaindernear 1 4 -> 1 rmnx184 remaindernear 1 5 -> 1 rmnx185 remaindernear 1 6 -> 1 rmnx186 remaindernear 1 7 -> 1 rmnx187 remaindernear 1 8 -> 1 rmnx188 remaindernear 1 9 -> 1 rmnx189 remaindernear 1 10 -> 1 rmnx190 remaindernear 1 1 -> 0 rmnx191 remaindernear 2 1 -> 0 rmnx192 remaindernear 3 1 -> 0 rmnx193 remaindernear 4 1 -> 0 rmnx194 remaindernear 5 1 -> 0 rmnx195 remaindernear 6 1 -> 0 rmnx196 remaindernear 7 1 -> 0 rmnx197 remaindernear 8 1 -> 0 rmnx198 remaindernear 9 1 -> 0 rmnx199 remaindernear 10 1 -> 0 -- Various flavours of remaindernear by 0 maxexponent: 999999999 minexponent: -999999999 rmnx201 remaindernear 0 0 -> NaN Division_undefined rmnx202 remaindernear 0.0E5 0 -> NaN Division_undefined rmnx203 remaindernear 0.000 0 -> NaN Division_undefined rmnx204 remaindernear 0.0001 0 -> NaN Invalid_operation rmnx205 remaindernear 0.01 0 -> NaN Invalid_operation rmnx206 remaindernear 0.1 0 -> NaN Invalid_operation rmnx207 remaindernear 1 0 -> NaN Invalid_operation rmnx208 remaindernear 1 0.0 -> NaN Invalid_operation rmnx209 remaindernear 10 0.0 -> NaN Invalid_operation rmnx210 remaindernear 1E+100 0.0 -> NaN Invalid_operation rmnx211 remaindernear 1E+1000 0 -> NaN Invalid_operation -- tests from the extended specification rmnx221 remaindernear 2.1 3 -> -0.9 rmnx222 remaindernear 10 6 -> -2 rmnx223 remaindernear 10 3 -> 1 rmnx224 remaindernear -10 3 -> -1 rmnx225 remaindernear 10.2 1 -> 0.2 rmnx226 remaindernear 10 0.3 -> 0.1 rmnx227 remaindernear 3.6 1.3 -> -0.3 -- some differences from remainder rmnx231 remaindernear 0.4 1.020 -> 0.400 rmnx232 remaindernear 0.50 1.020 -> 0.500 rmnx233 remaindernear 0.51 1.020 -> 0.510 rmnx234 remaindernear 0.52 1.020 -> -0.500 rmnx235 remaindernear 0.6 1.020 -> -0.420 -- test some cases that are close to exponent overflow maxexponent: 999999999 minexponent: -999999999 rmnx270 remaindernear 1 1e999999999 -> 1 rmnx271 remaindernear 1 0.9e999999999 -> 1 rmnx272 remaindernear 1 0.99e999999999 -> 1 rmnx273 remaindernear 1 0.999999999e999999999 -> 1 rmnx274 remaindernear 9e999999999 1 -> NaN Division_impossible rmnx275 remaindernear 9.9e999999999 1 -> NaN Division_impossible rmnx276 remaindernear 9.99e999999999 1 -> NaN Division_impossible rmnx277 remaindernear 9.99999999e999999999 1 -> NaN Division_impossible rmnx280 remaindernear 0.1 9e-999999999 -> NaN Division_impossible rmnx281 remaindernear 0.1 99e-999999999 -> NaN Division_impossible rmnx282 remaindernear 0.1 999e-999999999 -> NaN Division_impossible rmnx283 remaindernear 0.1 9e-999999998 -> NaN Division_impossible rmnx284 remaindernear 0.1 99e-999999998 -> NaN Division_impossible rmnx285 remaindernear 0.1 999e-999999998 -> NaN Division_impossible rmnx286 remaindernear 0.1 999e-999999997 -> NaN Division_impossible rmnx287 remaindernear 0.1 9999e-999999997 -> NaN Division_impossible rmnx288 remaindernear 0.1 99999e-999999997 -> NaN Division_impossible -- rmnx3xx are from DiagBigDecimal rmnx301 remaindernear 1 3 -> 1 rmnx302 remaindernear 5 5 -> 0 rmnx303 remaindernear 13 10 -> 3 rmnx304 remaindernear 13 50 -> 13 rmnx305 remaindernear 13 100 -> 13 rmnx306 remaindernear 13 1000 -> 13 rmnx307 remaindernear .13 1 -> 0.13 rmnx308 remaindernear 0.133 1 -> 0.133 rmnx309 remaindernear 0.1033 1 -> 0.1033 rmnx310 remaindernear 1.033 1 -> 0.033 rmnx311 remaindernear 10.33 1 -> 0.33 rmnx312 remaindernear 10.33 10 -> 0.33 rmnx313 remaindernear 103.3 1 -> 0.3 rmnx314 remaindernear 133 10 -> 3 rmnx315 remaindernear 1033 10 -> 3 rmnx316 remaindernear 1033 50 -> -17 rmnx317 remaindernear 101.0 3 -> -1.0 rmnx318 remaindernear 102.0 3 -> 0.0 rmnx319 remaindernear 103.0 3 -> 1.0 rmnx320 remaindernear 2.40 1 -> 0.40 rmnx321 remaindernear 2.400 1 -> 0.400 rmnx322 remaindernear 2.4 1 -> 0.4 rmnx323 remaindernear 2.4 2 -> 0.4 rmnx324 remaindernear 2.400 2 -> 0.400 rmnx325 remaindernear 1 0.3 -> 0.1 rmnx326 remaindernear 1 0.30 -> 0.10 rmnx327 remaindernear 1 0.300 -> 0.100 rmnx328 remaindernear 1 0.3000 -> 0.1000 rmnx329 remaindernear 1.0 0.3 -> 0.1 rmnx330 remaindernear 1.00 0.3 -> 0.10 rmnx331 remaindernear 1.000 0.3 -> 0.100 rmnx332 remaindernear 1.0000 0.3 -> 0.1000 rmnx333 remaindernear 0.5 2 -> 0.5 rmnx334 remaindernear 0.5 2.1 -> 0.5 rmnx335 remaindernear 0.5 2.01 -> 0.50 rmnx336 remaindernear 0.5 2.001 -> 0.500 rmnx337 remaindernear 0.50 2 -> 0.50 rmnx338 remaindernear 0.50 2.01 -> 0.50 rmnx339 remaindernear 0.50 2.001 -> 0.500 rmnx340 remaindernear 0.5 0.5000001 -> -1E-7 rmnx341 remaindernear 0.5 0.50000001 -> -1E-8 rmnx342 remaindernear 0.5 0.500000001 -> -1E-9 rmnx343 remaindernear 0.5 0.5000000001 -> -1E-10 rmnx344 remaindernear 0.5 0.50000000001 -> -1E-11 rmnx345 remaindernear 0.5 0.4999999 -> 1E-7 rmnx346 remaindernear 0.5 0.49999999 -> 1E-8 rmnx347 remaindernear 0.5 0.499999999 -> 1E-9 rmnx348 remaindernear 0.5 0.4999999999 -> 1E-10 rmnx349 remaindernear 0.5 0.49999999999 -> 1E-11 rmnx350 remaindernear 0.03 7 -> 0.03 rmnx351 remaindernear 5 2 -> 1 rmnx352 remaindernear 4.1 2 -> 0.1 rmnx353 remaindernear 4.01 2 -> 0.01 rmnx354 remaindernear 4.001 2 -> 0.001 rmnx355 remaindernear 4.0001 2 -> 0.0001 rmnx356 remaindernear 4.00001 2 -> 0.00001 rmnx357 remaindernear 4.000001 2 -> 0.000001 rmnx358 remaindernear 4.0000001 2 -> 1E-7 rmnx360 remaindernear 1.2 0.7345 -> -0.2690 rmnx361 remaindernear 0.8 12 -> 0.8 rmnx362 remaindernear 0.8 0.2 -> 0.0 rmnx363 remaindernear 0.8 0.3 -> -0.1 rmnx364 remaindernear 0.800 12 -> 0.800 rmnx365 remaindernear 0.800 1.7 -> 0.800 rmnx366 remaindernear 2.400 2 -> 0.400 precision: 6 rmnx371 remaindernear 2.400 2 -> 0.400 precision: 3 rmnx372 remaindernear 12345678900000 12e+12 -> 3.46E+11 Inexact Rounded precision: 5 rmnx381 remaindernear 12345 1 -> 0 rmnx382 remaindernear 12345 1.0001 -> -0.2344 rmnx383 remaindernear 12345 1.001 -> -0.333 rmnx384 remaindernear 12345 1.01 -> -0.23 rmnx385 remaindernear 12345 1.1 -> -0.3 rmnx386 remaindernear 12355 4 -> -1 rmnx387 remaindernear 12345 4 -> 1 rmnx388 remaindernear 12355 4.0001 -> -1.3089 rmnx389 remaindernear 12345 4.0001 -> 0.6914 rmnx390 remaindernear 12345 4.9 -> 1.9 rmnx391 remaindernear 12345 4.99 -> -0.26 rmnx392 remaindernear 12345 4.999 -> 2.469 rmnx393 remaindernear 12345 4.9999 -> 0.2469 rmnx394 remaindernear 12345 5 -> 0 rmnx395 remaindernear 12345 5.0001 -> -0.2469 rmnx396 remaindernear 12345 5.001 -> -2.469 rmnx397 remaindernear 12345 5.01 -> 0.36 rmnx398 remaindernear 12345 5.1 -> -2.1 precision: 9 -- some nasty division-by-1 cases [some similar above] rmnx401 remaindernear 0.4 1 -> 0.4 rmnx402 remaindernear 0.45 1 -> 0.45 rmnx403 remaindernear 0.455 1 -> 0.455 rmnx404 remaindernear 0.4555 1 -> 0.4555 rmnx405 remaindernear 0.45555 1 -> 0.45555 rmnx406 remaindernear 0.455555 1 -> 0.455555 rmnx407 remaindernear 0.4555555 1 -> 0.4555555 rmnx408 remaindernear 0.45555555 1 -> 0.45555555 rmnx409 remaindernear 0.455555555 1 -> 0.455555555 -- some tricky LHSs rmnx420 remaindernear 99999999.999999999 1E+8 -> -1E-9 rmnx421 remaindernear 999999999.999999999 1E+9 -> -1E-9 precision: 9 rmnx430 remaindernear 0.455555555 1 -> 0.455555555 precision: 8 rmnx431 remaindernear 0.455555555 1 -> 0.45555556 Inexact Rounded precision: 7 rmnx432 remaindernear 0.455555555 1 -> 0.4555556 Inexact Rounded precision: 6 rmnx433 remaindernear 0.455555555 1 -> 0.455556 Inexact Rounded precision: 5 rmnx434 remaindernear 0.455555555 1 -> 0.45556 Inexact Rounded precision: 4 rmnx435 remaindernear 0.455555555 1 -> 0.4556 Inexact Rounded precision: 3 rmnx436 remaindernear 0.455555555 1 -> 0.456 Inexact Rounded precision: 2 rmnx437 remaindernear 0.455555555 1 -> 0.46 Inexact Rounded precision: 1 rmnx438 remaindernear 0.455555555 1 -> 0.5 Inexact Rounded -- early tests; from text descriptions precision: 9 rmnx601 remaindernear 10 6 -> -2 rmnx602 remaindernear -10 6 -> 2 rmnx603 remaindernear 11 3 -> -1 rmnx604 remaindernear 11 5 -> 1 rmnx605 remaindernear 7.7 8 -> -0.3 rmnx606 remaindernear 31.5 3 -> 1.5 -- i=10 rmnx607 remaindernear 34.5 3 -> -1.5 -- i=11 -- Specials rmnx680 remaindernear Inf -Inf -> NaN Invalid_operation rmnx681 remaindernear Inf -1000 -> NaN Invalid_operation rmnx682 remaindernear Inf -1 -> NaN Invalid_operation rmnx683 remaindernear Inf 0 -> NaN Invalid_operation rmnx684 remaindernear Inf -0 -> NaN Invalid_operation rmnx685 remaindernear Inf 1 -> NaN Invalid_operation rmnx686 remaindernear Inf 1000 -> NaN Invalid_operation rmnx687 remaindernear Inf Inf -> NaN Invalid_operation rmnx688 remaindernear -1000 Inf -> -1000 rmnx689 remaindernear -Inf Inf -> NaN Invalid_operation rmnx691 remaindernear -1 Inf -> -1 rmnx692 remaindernear 0 Inf -> 0 rmnx693 remaindernear -0 Inf -> -0 rmnx694 remaindernear 1 Inf -> 1 rmnx695 remaindernear 1000 Inf -> 1000 rmnx696 remaindernear Inf Inf -> NaN Invalid_operation rmnx700 remaindernear -Inf -Inf -> NaN Invalid_operation rmnx701 remaindernear -Inf -1000 -> NaN Invalid_operation rmnx702 remaindernear -Inf -1 -> NaN Invalid_operation rmnx703 remaindernear -Inf -0 -> NaN Invalid_operation rmnx704 remaindernear -Inf 0 -> NaN Invalid_operation rmnx705 remaindernear -Inf 1 -> NaN Invalid_operation rmnx706 remaindernear -Inf 1000 -> NaN Invalid_operation rmnx707 remaindernear -Inf Inf -> NaN Invalid_operation rmnx708 remaindernear -Inf -Inf -> NaN Invalid_operation rmnx709 remaindernear -1000 Inf -> -1000 rmnx710 remaindernear -1 -Inf -> -1 rmnx711 remaindernear -0 -Inf -> -0 rmnx712 remaindernear 0 -Inf -> 0 rmnx713 remaindernear 1 -Inf -> 1 rmnx714 remaindernear 1000 -Inf -> 1000 rmnx715 remaindernear Inf -Inf -> NaN Invalid_operation rmnx721 remaindernear NaN -Inf -> NaN rmnx722 remaindernear NaN -1000 -> NaN rmnx723 remaindernear NaN -1 -> NaN rmnx724 remaindernear NaN -0 -> NaN rmnx725 remaindernear NaN 0 -> NaN rmnx726 remaindernear NaN 1 -> NaN rmnx727 remaindernear NaN 1000 -> NaN rmnx728 remaindernear NaN Inf -> NaN rmnx729 remaindernear NaN NaN -> NaN rmnx730 remaindernear -Inf NaN -> NaN rmnx731 remaindernear -1000 NaN -> NaN rmnx732 remaindernear -1 -NaN -> -NaN rmnx733 remaindernear -0 NaN -> NaN rmnx734 remaindernear 0 NaN -> NaN rmnx735 remaindernear 1 NaN -> NaN rmnx736 remaindernear 1000 NaN -> NaN rmnx737 remaindernear Inf NaN -> NaN rmnx741 remaindernear sNaN -Inf -> NaN Invalid_operation rmnx742 remaindernear sNaN -1000 -> NaN Invalid_operation rmnx743 remaindernear -sNaN -1 -> -NaN Invalid_operation rmnx744 remaindernear sNaN -0 -> NaN Invalid_operation rmnx745 remaindernear sNaN 0 -> NaN Invalid_operation rmnx746 remaindernear sNaN 1 -> NaN Invalid_operation rmnx747 remaindernear sNaN 1000 -> NaN Invalid_operation rmnx749 remaindernear sNaN NaN -> NaN Invalid_operation rmnx750 remaindernear sNaN sNaN -> NaN Invalid_operation rmnx751 remaindernear NaN sNaN -> NaN Invalid_operation rmnx752 remaindernear -Inf sNaN -> NaN Invalid_operation rmnx753 remaindernear -1000 sNaN -> NaN Invalid_operation rmnx754 remaindernear -1 sNaN -> NaN Invalid_operation rmnx755 remaindernear -0 -sNaN -> -NaN Invalid_operation rmnx756 remaindernear 0 sNaN -> NaN Invalid_operation rmnx757 remaindernear 1 sNaN -> NaN Invalid_operation rmnx758 remaindernear 1000 sNaN -> NaN Invalid_operation rmnx759 remaindernear Inf sNaN -> NaN Invalid_operation rmnx760 remaindernear NaN sNaN -> NaN Invalid_operation -- propaging NaNs rmnx761 remaindernear NaN1 NaN7 -> NaN1 rmnx762 remaindernear sNaN2 NaN8 -> NaN2 Invalid_operation rmnx763 remaindernear NaN3 -sNaN9 -> -NaN9 Invalid_operation rmnx764 remaindernear sNaN4 sNaN10 -> NaN4 Invalid_operation rmnx765 remaindernear 15 NaN11 -> NaN11 rmnx766 remaindernear NaN6 NaN12 -> NaN6 rmnx767 remaindernear Inf -NaN13 -> -NaN13 rmnx768 remaindernear NaN14 -Inf -> NaN14 rmnx769 remaindernear 0 NaN15 -> NaN15 rmnx770 remaindernear -NaN16 -0 -> -NaN16 -- test some cases that are close to exponent overflow maxexponent: 999999999 minexponent: -999999999 rmnx780 remaindernear 1 1e999999999 -> 1 rmnx781 remaindernear 1 0.9e999999999 -> 1 rmnx782 remaindernear 1 0.99e999999999 -> 1 rmnx783 remaindernear 1 0.999999999e999999999 -> 1 rmnx784 remaindernear 9e999999999 1 -> NaN Division_impossible rmnx785 remaindernear 9.9e999999999 1 -> NaN Division_impossible rmnx786 remaindernear 9.99e999999999 1 -> NaN Division_impossible rmnx787 remaindernear 9.99999999e999999999 1 -> NaN Division_impossible -- overflow and underflow tests [from divide] precision: 9 maxexponent: 999999999 minexponent: -999999999 rmnx790 remaindernear +1.23456789012345E-0 9E+999999999 -> 1.23456789 Inexact Rounded rmnx791 remaindernear 9E+999999999 +0.23456789012345E-0 -> NaN Division_impossible rmnx792 remaindernear +0.100 9E+999999999 -> 0.100 rmnx793 remaindernear 9E-999999999 +9.100 -> 9E-999999999 rmnx795 remaindernear -1.23456789012345E-0 9E+999999999 -> -1.23456789 Inexact Rounded rmnx796 remaindernear 9E+999999999 -0.83456789012345E-0 -> NaN Division_impossible rmnx797 remaindernear -0.100 9E+999999999 -> -0.100 rmnx798 remaindernear 9E-999999999 -9.100 -> 9E-999999999 -- long operands checks maxexponent: 999 minexponent: -999 precision: 9 rmnx801 remaindernear 12345678000 100 -> 0 rmnx802 remaindernear 1 12345678000 -> 1 rmnx803 remaindernear 1234567800 10 -> 0 rmnx804 remaindernear 1 1234567800 -> 1 rmnx805 remaindernear 1234567890 10 -> 0 rmnx806 remaindernear 1 1234567890 -> 1 rmnx807 remaindernear 1234567891 10 -> 1 rmnx808 remaindernear 1 1234567891 -> 1 rmnx809 remaindernear 12345678901 100 -> 1 rmnx810 remaindernear 1 12345678901 -> 1 rmnx811 remaindernear 1234567896 10 -> -4 rmnx812 remaindernear 1 1234567896 -> 1 precision: 15 rmnx841 remaindernear 12345678000 100 -> 0 rmnx842 remaindernear 1 12345678000 -> 1 rmnx843 remaindernear 1234567800 10 -> 0 rmnx844 remaindernear 1 1234567800 -> 1 rmnx845 remaindernear 1234567890 10 -> 0 rmnx846 remaindernear 1 1234567890 -> 1 rmnx847 remaindernear 1234567891 10 -> 1 rmnx848 remaindernear 1 1234567891 -> 1 rmnx849 remaindernear 12345678901 100 -> 1 rmnx850 remaindernear 1 12345678901 -> 1 rmnx851 remaindernear 1234567896 10 -> -4 rmnx852 remaindernear 1 1234567896 -> 1 -- Null tests rmnx900 remaindernear 10 # -> NaN Invalid_operation rmnx901 remaindernear # 10 -> NaN Invalid_operation --- NEW FILE: rescale.decTest --- ------------------------------------------------------------------------ -- rescale.decTest -- decimal rescale operation -- -- Copyright (c) IBM Corporation, 1981, 2003. All rights reserved. -- ------------------------------------------------------------------------ -- Please see the document "General Decimal Arithmetic Testcases" -- -- at http://www2.hursley.ibm.com/decimal for the description of -- -- these testcases. -- -- -- -- These testcases are experimental ('beta' versions), and they -- -- may contain errors. They are offered on an as-is basis. In -- -- particular, achieving the same results as the tests here is not -- -- a guarantee that an implementation complies with any Standard -- -- or specification. The tests are not exhaustive. -- -- -- -- Please send comments, suggestions, and corrections to the author: -- -- Mike Cowlishaw, IBM Fellow -- -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ version: 2.35 -- [obsolete] Quantize.decTest has the improved version extended: 1 precision: 9 rounding: half_up maxExponent: 999 minexponent: -999 -- sanity checks resx001 rescale 0 0 -> 0 resx002 rescale 1 0 -> 1 resx003 rescale 0.1 +2 -> 0E+2 Inexact Rounded resx005 rescale 0.1 +1 -> 0E+1 Inexact Rounded resx006 rescale 0.1 0 -> 0 Inexact Rounded resx007 rescale 0.1 -1 -> 0.1 resx008 rescale 0.1 -2 -> 0.10 resx009 rescale 0.1 -3 -> 0.100 resx010 rescale 0.9 +2 -> 0E+2 Inexact Rounded resx011 rescale 0.9 +1 -> 0E+1 Inexact Rounded resx012 rescale 0.9 +0 -> 1 Inexact Rounded resx013 rescale 0.9 -1 -> 0.9 resx014 rescale 0.9 -2 -> 0.90 resx015 rescale 0.9 -3 -> 0.900 -- negatives resx021 rescale -0 0 -> -0 resx022 rescale -1 0 -> -1 resx023 rescale -0.1 +2 -> -0E+2 Inexact Rounded resx025 rescale -0.1 +1 -> -0E+1 Inexact Rounded resx026 rescale -0.1 0 -> -0 Inexact Rounded resx027 rescale -0.1 -1 -> -0.1 resx028 rescale -0.1 -2 -> -0.10 resx029 rescale -0.1 -3 -> -0.100 resx030 rescale -0.9 +2 -> -0E+2 Inexact Rounded resx031 rescale -0.9 +1 -> -0E+1 Inexact Rounded resx032 rescale -0.9 +0 -> -1 Inexact Rounded resx033 rescale -0.9 -1 -> -0.9 resx034 rescale -0.9 -2 -> -0.90 resx035 rescale -0.9 -3 -> -0.900 resx036 rescale -0.5 +2 -> -0E+2 Inexact Rounded resx037 rescale -0.5 +1 -> -0E+1 Inexact Rounded resx038 rescale -0.5 +0 -> -1 Inexact Rounded resx039 rescale -0.5 -1 -> -0.5 resx040 rescale -0.5 -2 -> -0.50 resx041 rescale -0.5 -3 -> -0.500 resx042 rescale -0.9 +2 -> -0E+2 Inexact Rounded resx043 rescale -0.9 +1 -> -0E+1 Inexact Rounded resx044 rescale -0.9 +0 -> -1 Inexact Rounded resx045 rescale -0.9 -1 -> -0.9 resx046 rescale -0.9 -2 -> -0.90 resx047 rescale -0.9 -3 -> -0.900 -- examples from Specification resx060 rescale 2.17 -3 -> 2.170 resx061 rescale 2.17 -2 -> 2.17 resx062 rescale 2.17 -1 -> 2.2 Inexact Rounded resx063 rescale 2.17 0 -> 2 Inexact Rounded resx064 rescale 2.17 +1 -> 0E+1 Inexact Rounded resx065 rescale 2 Inf -> NaN Invalid_operation resx066 rescale -0.1 0 -> -0 Inexact Rounded resx067 rescale -0 5 -> -0E+5 resx068 rescale +35236450.6 -2 -> NaN Invalid_operation resx069 rescale -35236450.6 -2 -> NaN Invalid_operation resx070 rescale 217 -1 -> 217.0 resx071 rescale 217 0 -> 217 resx072 rescale 217 +1 -> 2.2E+2 Inexact Rounded resx073 rescale 217 +2 -> 2E+2 Inexact Rounded -- general tests .. resx089 rescale 12 +4 -> 0E+4 Inexact Rounded resx090 rescale 12 +3 -> 0E+3 Inexact Rounded resx091 rescale 12 +2 -> 0E+2 Inexact Rounded resx092 rescale 12 +1 -> 1E+1 Inexact Rounded resx093 rescale 1.2345 -2 -> 1.23 Inexact Rounded resx094 rescale 1.2355 -2 -> 1.24 Inexact Rounded resx095 rescale 1.2345 -6 -> 1.234500 resx096 rescale 9.9999 -2 -> 10.00 Inexact Rounded resx097 rescale 0.0001 -2 -> 0.00 Inexact Rounded resx098 rescale 0.001 -2 -> 0.00 Inexact Rounded resx099 rescale 0.009 -2 -> 0.01 Inexact Rounded resx100 rescale 92 +2 -> 1E+2 Inexact Rounded resx101 rescale -1 0 -> -1 resx102 rescale -1 -1 -> -1.0 resx103 rescale -1 -2 -> -1.00 resx104 rescale 0 0 -> 0 resx105 rescale 0 -1 -> 0.0 resx106 rescale 0 -2 -> 0.00 resx107 rescale 0.00 0 -> 0 resx108 rescale 0 +1 -> 0E+1 resx109 rescale 0 +2 -> 0E+2 resx110 rescale +1 0 -> 1 resx111 rescale +1 -1 -> 1.0 resx112 rescale +1 -2 -> 1.00 resx120 rescale 1.04 -3 -> 1.040 resx121 rescale 1.04 -2 -> 1.04 resx122 rescale 1.04 -1 -> 1.0 Inexact Rounded resx123 rescale 1.04 0 -> 1 Inexact Rounded resx124 rescale 1.05 -3 -> 1.050 resx125 rescale 1.05 -2 -> 1.05 resx126 rescale 1.05 -1 -> 1.1 Inexact Rounded resx127 rescale 1.05 0 -> 1 Inexact Rounded resx128 rescale 1.05 -3 -> 1.050 resx129 rescale 1.05 -2 -> 1.05 resx130 rescale 1.05 -1 -> 1.1 Inexact Rounded resx131 rescale 1.05 0 -> 1 Inexact Rounded resx132 rescale 1.06 -3 -> 1.060 resx133 rescale 1.06 -2 -> 1.06 resx134 rescale 1.06 -1 -> 1.1 Inexact Rounded resx135 rescale 1.06 0 -> 1 Inexact Rounded resx140 rescale -10 -2 -> -10.00 resx141 rescale +1 -2 -> 1.00 resx142 rescale +10 -2 -> 10.00 resx143 rescale 1E+10 -2 -> NaN Invalid_operation resx144 rescale 1E-10 -2 -> 0.00 Inexact Rounded resx145 rescale 1E-3 -2 -> 0.00 Inexact Rounded resx146 rescale 1E-2 -2 -> 0.01 resx147 rescale 1E-1 -2 -> 0.10 resx148 rescale 0E-10 -2 -> 0.00 resx150 rescale 1.0600 -5 -> 1.06000 resx151 rescale 1.0600 -4 -> 1.0600 resx152 rescale 1.0600 -3 -> 1.060 Rounded resx153 rescale 1.0600 -2 -> 1.06 Rounded resx154 rescale 1.0600 -1 -> 1.1 Inexact Rounded resx155 rescale 1.0600 0 -> 1 Inexact Rounded -- +ve exponents .. resx201 rescale -1 +0 -> -1 resx202 rescale -1 +1 -> -0E+1 Inexact Rounded resx203 rescale -1 +2 -> -0E+2 Inexact Rounded resx204 rescale 0 +0 -> 0 resx205 rescale 0 +1 -> 0E+1 resx206 rescale 0 +2 -> 0E+2 resx207 rescale +1 +0 -> 1 resx208 rescale +1 +1 -> 0E+1 Inexact Rounded resx209 rescale +1 +2 -> 0E+2 Inexact Rounded resx220 rescale 1.04 +3 -> 0E+3 Inexact Rounded resx221 rescale 1.04 +2 -> 0E+2 Inexact Rounded resx222 rescale 1.04 +1 -> 0E+1 Inexact Rounded resx223 rescale 1.04 +0 -> 1 Inexact Rounded resx224 rescale 1.05 +3 -> 0E+3 Inexact Rounded resx225 rescale 1.05 +2 -> 0E+2 Inexact Rounded resx226 rescale 1.05 +1 -> 0E+1 Inexact Rounded resx227 rescale 1.05 +0 -> 1 Inexact Rounded resx228 rescale 1.05 +3 -> 0E+3 Inexact Rounded resx229 rescale 1.05 +2 -> 0E+2 Inexact Rounded resx230 rescale 1.05 +1 -> 0E+1 Inexact Rounded resx231 rescale 1.05 +0 -> 1 Inexact Rounded resx232 rescale 1.06 +3 -> 0E+3 Inexact Rounded resx233 rescale 1.06 +2 -> 0E+2 Inexact Rounded resx234 rescale 1.06 +1 -> 0E+1 Inexact Rounded resx235 rescale 1.06 +0 -> 1 Inexact Rounded resx240 rescale -10 +1 -> -1E+1 Rounded resx241 rescale +1 +1 -> 0E+1 Inexact Rounded resx242 rescale +10 +1 -> 1E+1 Rounded resx243 rescale 1E+1 +1 -> 1E+1 -- underneath this is E+1 resx244 rescale 1E+2 +1 -> 1.0E+2 -- underneath this is E+1 resx245 rescale 1E+3 +1 -> 1.00E+3 -- underneath this is E+1 resx246 rescale 1E+4 +1 -> 1.000E+4 -- underneath this is E+1 resx247 rescale 1E+5 +1 -> 1.0000E+5 -- underneath this is E+1 resx248 rescale 1E+6 +1 -> 1.00000E+6 -- underneath this is E+1 resx249 rescale 1E+7 +1 -> 1.000000E+7 -- underneath this is E+1 resx250 rescale 1E+8 +1 -> 1.0000000E+8 -- underneath this is E+1 resx251 rescale 1E+9 +1 -> 1.00000000E+9 -- underneath this is E+1 -- next one tries to add 9 zeros resx252 rescale 1E+10 +1 -> NaN Invalid_operation resx253 rescale 1E-10 +1 -> 0E+1 Inexact Rounded resx254 rescale 1E-2 +1 -> 0E+1 Inexact Rounded resx255 rescale 0E-10 +1 -> 0E+1 resx256 rescale -0E-10 +1 -> -0E+1 resx257 rescale -0E-1 +1 -> -0E+1 resx258 rescale -0 +1 -> -0E+1 resx259 rescale -0E+1 +1 -> -0E+1 resx260 rescale -10 +2 -> -0E+2 Inexact Rounded resx261 rescale +1 +2 -> 0E+2 Inexact Rounded resx262 rescale +10 +2 -> 0E+2 Inexact Rounded resx263 rescale 1E+1 +2 -> 0E+2 Inexact Rounded resx264 rescale 1E+2 +2 -> 1E+2 resx265 rescale 1E+3 +2 -> 1.0E+3 resx266 rescale 1E+4 +2 -> 1.00E+4 resx267 rescale 1E+5 +2 -> 1.000E+5 resx268 rescale 1E+6 +2 -> 1.0000E+6 resx269 rescale 1E+7 +2 -> 1.00000E+7 resx270 rescale 1E+8 +2 -> 1.000000E+8 resx271 rescale 1E+9 +2 -> 1.0000000E+9 resx272 rescale 1E+10 +2 -> 1.00000000E+10 resx273 rescale 1E-10 +2 -> 0E+2 Inexact Rounded resx274 rescale 1E-2 +2 -> 0E+2 Inexact Rounded resx275 rescale 0E-10 +2 -> 0E+2 resx280 rescale -10 +3 -> -0E+3 Inexact Rounded resx281 rescale +1 +3 -> 0E+3 Inexact Rounded resx282 rescale +10 +3 -> 0E+3 Inexact Rounded resx283 rescale 1E+1 +3 -> 0E+3 Inexact Rounded resx284 rescale 1E+2 +3 -> 0E+3 Inexact Rounded resx285 rescale 1E+3 +3 -> 1E+3 resx286 rescale 1E+4 +3 -> 1.0E+4 resx287 rescale 1E+5 +3 -> 1.00E+5 resx288 rescale 1E+6 +3 -> 1.000E+6 resx289 rescale 1E+7 +3 -> 1.0000E+7 resx290 rescale 1E+8 +3 -> 1.00000E+8 resx291 rescale 1E+9 +3 -> 1.000000E+9 resx292 rescale 1E+10 +3 -> 1.0000000E+10 resx293 rescale 1E-10 +3 -> 0E+3 Inexact Rounded resx294 rescale 1E-2 +3 -> 0E+3 Inexact Rounded resx295 rescale 0E-10 +3 -> 0E+3 -- round up from below [sign wrong in JIT compiler once] resx300 rescale 0.0078 -5 -> 0.00780 resx301 rescale 0.0078 -4 -> 0.0078 resx302 rescale 0.0078 -3 -> 0.008 Inexact Rounded resx303 rescale 0.0078 -2 -> 0.01 Inexact Rounded resx304 rescale 0.0078 -1 -> 0.0 Inexact Rounded resx305 rescale 0.0078 0 -> 0 Inexact Rounded resx306 rescale 0.0078 +1 -> 0E+1 Inexact Rounded resx307 rescale 0.0078 +2 -> 0E+2 Inexact Rounded resx310 rescale -0.0078 -5 -> -0.00780 resx311 rescale -0.0078 -4 -> -0.0078 resx312 rescale -0.0078 -3 -> -0.008 Inexact Rounded resx313 rescale -0.0078 -2 -> -0.01 Inexact Rounded resx314 rescale -0.0078 -1 -> -0.0 Inexact Rounded resx315 rescale -0.0078 0 -> -0 Inexact Rounded resx316 rescale -0.0078 +1 -> -0E+1 Inexact Rounded resx317 rescale -0.0078 +2 -> -0E+2 Inexact Rounded resx320 rescale 0.078 -5 -> 0.07800 resx321 rescale 0.078 -4 -> 0.0780 resx322 rescale 0.078 -3 -> 0.078 resx323 rescale 0.078 -2 -> 0.08 Inexact Rounded resx324 rescale 0.078 -1 -> 0.1 Inexact Rounded resx325 rescale 0.078 0 -> 0 Inexact Rounded resx326 rescale 0.078 +1 -> 0E+1 Inexact Rounded resx327 rescale 0.078 +2 -> 0E+2 Inexact Rounded resx330 rescale -0.078 -5 -> -0.07800 resx331 rescale -0.078 -4 -> -0.0780 resx332 rescale -0.078 -3 -> -0.078 resx333 rescale -0.078 -2 -> -0.08 Inexact Rounded resx334 rescale -0.078 -1 -> -0.1 Inexact Rounded resx335 rescale -0.078 0 -> -0 Inexact Rounded resx336 rescale -0.078 +1 -> -0E+1 Inexact Rounded resx337 rescale -0.078 +2 -> -0E+2 Inexact Rounded resx340 rescale 0.78 -5 -> 0.78000 resx341 rescale 0.78 -4 -> 0.7800 resx342 rescale 0.78 -3 -> 0.780 resx343 rescale 0.78 -2 -> 0.78 resx344 rescale 0.78 -1 -> 0.8 Inexact Rounded resx345 rescale 0.78 0 -> 1 Inexact Rounded resx346 rescale 0.78 +1 -> 0E+1 Inexact Rounded resx347 rescale 0.78 +2 -> 0E+2 Inexact Rounded resx350 rescale -0.78 -5 -> -0.78000 resx351 rescale -0.78 -4 -> -0.7800 resx352 rescale -0.78 -3 -> -0.780 resx353 rescale -0.78 -2 -> -0.78 resx354 rescale -0.78 -1 -> -0.8 Inexact Rounded resx355 rescale -0.78 0 -> -1 Inexact Rounded resx356 rescale -0.78 +1 -> -0E+1 Inexact Rounded resx357 rescale -0.78 +2 -> -0E+2 Inexact Rounded resx360 rescale 7.8 -5 -> 7.80000 resx361 rescale 7.8 -4 -> 7.8000 resx362 rescale 7.8 -3 -> 7.800 resx363 rescale 7.8 -2 -> 7.80 resx364 rescale 7.8 -1 -> 7.8 resx365 rescale 7.8 0 -> 8 Inexact Rounded resx366 rescale 7.8 +1 -> 1E+1 Inexact Rounded resx367 rescale 7.8 +2 -> 0E+2 Inexact Rounded resx368 rescale 7.8 +3 -> 0E+3 Inexact Rounded resx370 rescale -7.8 -5 -> -7.80000 resx371 rescale -7.8 -4 -> -7.8000 resx372 rescale -7.8 -3 -> -7.800 resx373 rescale -7.8 -2 -> -7.80 resx374 rescale -7.8 -1 -> -7.8 resx375 rescale -7.8 0 -> -8 Inexact Rounded resx376 rescale -7.8 +1 -> -1E+1 Inexact Rounded resx377 rescale -7.8 +2 -> -0E+2 Inexact Rounded resx378 rescale -7.8 +3 -> -0E+3 Inexact Rounded -- some individuals precision: 9 resx380 rescale 352364.506 -2 -> 352364.51 Inexact Rounded resx381 rescale 3523645.06 -2 -> 3523645.06 resx382 rescale 35236450.6 -2 -> NaN Invalid_operation resx383 rescale 352364506 -2 -> NaN Invalid_operation resx384 rescale -352364.506 -2 -> -352364.51 Inexact Rounded resx385 rescale -3523645.06 -2 -> -3523645.06 resx386 rescale -35236450.6 -2 -> NaN Invalid_operation resx387 rescale -352364506 -2 -> NaN Invalid_operation rounding: down resx389 rescale 35236450.6 -2 -> NaN Invalid_operation -- ? should that one instead have been: -- resx389 rescale 35236450.6 -2 -> NaN Invalid_operation rounding: half_up -- and a few more from e-mail discussions precision: 7 resx391 rescale 12.34567 -3 -> 12.346 Inexact Rounded resx392 rescale 123.4567 -3 -> 123.457 Inexact Rounded resx393 rescale 1234.567 -3 -> 1234.567 resx394 rescale 12345.67 -3 -> NaN Invalid_operation resx395 rescale 123456.7 -3 -> NaN Invalid_operation resx396 rescale 1234567. -3 -> NaN Invalid_operation -- some 9999 round-up cases precision: 9 resx400 rescale 9.999 -5 -> 9.99900 resx401 rescale 9.999 -4 -> 9.9990 resx402 rescale 9.999 -3 -> 9.999 resx403 rescale 9.999 -2 -> 10.00 Inexact Rounded resx404 rescale 9.999 -1 -> 10.0 Inexact Rounded resx405 rescale 9.999 0 -> 10 Inexact Rounded resx406 rescale 9.999 1 -> 1E+1 Inexact Rounded resx407 rescale 9.999 2 -> 0E+2 Inexact Rounded resx410 rescale 0.999 -5 -> 0.99900 resx411 rescale 0.999 -4 -> 0.9990 resx412 rescale 0.999 -3 -> 0.999 resx413 rescale 0.999 -2 -> 1.00 Inexact Rounded resx414 rescale 0.999 -1 -> 1.0 Inexact Rounded resx415 rescale 0.999 0 -> 1 Inexact Rounded resx416 rescale 0.999 1 -> 0E+1 Inexact Rounded resx420 rescale 0.0999 -5 -> 0.09990 resx421 rescale 0.0999 -4 -> 0.0999 resx422 rescale 0.0999 -3 -> 0.100 Inexact Rounded resx423 rescale 0.0999 -2 -> 0.10 Inexact Rounded resx424 rescale 0.0999 -1 -> 0.1 Inexact Rounded resx425 rescale 0.0999 0 -> 0 Inexact Rounded resx426 rescale 0.0999 1 -> 0E+1 Inexact Rounded resx430 rescale 0.00999 -5 -> 0.00999 resx431 rescale 0.00999 -4 -> 0.0100 Inexact Rounded resx432 rescale 0.00999 -3 -> 0.010 Inexact Rounded resx433 rescale 0.00999 -2 -> 0.01 Inexact Rounded resx434 rescale 0.00999 -1 -> 0.0 Inexact Rounded resx435 rescale 0.00999 0 -> 0 Inexact Rounded resx436 rescale 0.00999 1 -> 0E+1 Inexact Rounded resx440 rescale 0.000999 -5 -> 0.00100 Inexact Rounded resx441 rescale 0.000999 -4 -> 0.0010 Inexact Rounded resx442 rescale 0.000999 -3 -> 0.001 Inexact Rounded resx443 rescale 0.000999 -2 -> 0.00 Inexact Rounded resx444 rescale 0.000999 -1 -> 0.0 Inexact Rounded resx445 rescale 0.000999 0 -> 0 Inexact Rounded resx446 rescale 0.000999 1 -> 0E+1 Inexact Rounded precision: 8 resx449 rescale 9.999E-15 -23 -> NaN Invalid_operation resx450 rescale 9.999E-15 -22 -> 9.9990000E-15 resx451 rescale 9.999E-15 -21 -> 9.999000E-15 resx452 rescale 9.999E-15 -20 -> 9.99900E-15 resx453 rescale 9.999E-15 -19 -> 9.9990E-15 resx454 rescale 9.999E-15 -18 -> 9.999E-15 resx455 rescale 9.999E-15 -17 -> 1.000E-14 Inexact Rounded resx456 rescale 9.999E-15 -16 -> 1.00E-14 Inexact Rounded resx457 rescale 9.999E-15 -15 -> 1.0E-14 Inexact Rounded resx458 rescale 9.999E-15 -14 -> 1E-14 Inexact Rounded resx459 rescale 9.999E-15 -13 -> 0E-13 Inexact Rounded resx460 rescale 9.999E-15 -12 -> 0E-12 Inexact Rounded resx461 rescale 9.999E-15 -11 -> 0E-11 Inexact Rounded resx462 rescale 9.999E-15 -10 -> 0E-10 Inexact Rounded resx463 rescale 9.999E-15 -9 -> 0E-9 Inexact Rounded resx464 rescale 9.999E-15 -8 -> 0E-8 Inexact Rounded resx465 rescale 9.999E-15 -7 -> 0E-7 Inexact Rounded resx466 rescale 9.999E-15 -6 -> 0.000000 Inexact Rounded resx467 rescale 9.999E-15 -5 -> 0.00000 Inexact Rounded resx468 rescale 9.999E-15 -4 -> 0.0000 Inexact Rounded resx469 rescale 9.999E-15 -3 -> 0.000 Inexact Rounded resx470 rescale 9.999E-15 -2 -> 0.00 Inexact Rounded resx471 rescale 9.999E-15 -1 -> 0.0 Inexact Rounded resx472 rescale 9.999E-15 0 -> 0 Inexact Rounded resx473 rescale 9.999E-15 1 -> 0E+1 Inexact Rounded -- long operand checks [rhs checks removed] maxexponent: 999 minexponent: -999 precision: 9 resx481 rescale 12345678000 +3 -> 1.2345678E+10 Rounded resx482 rescale 1234567800 +1 -> 1.23456780E+9 Rounded resx483 rescale 1234567890 +1 -> 1.23456789E+9 Rounded resx484 rescale 1234567891 +1 -> 1.23456789E+9 Inexact Rounded resx485 rescale 12345678901 +2 -> 1.23456789E+10 Inexact Rounded resx486 rescale 1234567896 +1 -> 1.23456790E+9 Inexact Rounded -- a potential double-round resx487 rescale 1234.987643 -4 -> 1234.9876 Inexact Rounded resx488 rescale 1234.987647 -4 -> 1234.9876 Inexact Rounded precision: 15 resx491 rescale 12345678000 +3 -> 1.2345678E+10 Rounded resx492 rescale 1234567800 +1 -> 1.23456780E+9 Rounded resx493 rescale 1234567890 +1 -> 1.23456789E+9 Rounded resx494 rescale 1234567891 +1 -> 1.23456789E+9 Inexact Rounded resx495 rescale 12345678901 +2 -> 1.23456789E+10 Inexact Rounded resx496 rescale 1234567896 +1 -> 1.23456790E+9 Inexact Rounded resx497 rescale 1234.987643 -4 -> 1234.9876 Inexact Rounded resx498 rescale 1234.987647 -4 -> 1234.9876 Inexact Rounded -- Zeros resx500 rescale 0 1 -> 0E+1 resx501 rescale 0 0 -> 0 resx502 rescale 0 -1 -> 0.0 resx503 rescale 0.0 -1 -> 0.0 resx504 rescale 0.0 0 -> 0 resx505 rescale 0.0 +1 -> 0E+1 resx506 rescale 0E+1 -1 -> 0.0 resx507 rescale 0E+1 0 -> 0 resx508 rescale 0E+1 +1 -> 0E+1 resx509 rescale -0 1 -> -0E+1 resx510 rescale -0 0 -> -0 resx511 rescale -0 -1 -> -0.0 resx512 rescale -0.0 -1 -> -0.0 resx513 rescale -0.0 0 -> -0 resx514 rescale -0.0 +1 -> -0E+1 resx515 rescale -0E+1 -1 -> -0.0 resx516 rescale -0E+1 0 -> -0 resx517 rescale -0E+1 +1 -> -0E+1 -- Suspicious RHS values maxexponent: 999999999 minexponent: -999999999 precision: 15 resx520 rescale 1.234 999999E+3 -> 0E+999999000 Inexact Rounded resx521 rescale 123.456 999999E+3 -> 0E+999999000 Inexact Rounded resx522 rescale 1.234 999999999 -> 0E+999999999 Inexact Rounded resx523 rescale 123.456 999999999 -> 0E+999999999 Inexact Rounded resx524 rescale 123.456 1000000000 -> NaN Invalid_operation resx525 rescale 123.456 12345678903 -> NaN Invalid_operation -- next four are "won't fit" overflows resx526 rescale 1.234 -999999E+3 -> NaN Invalid_operation resx527 rescale 123.456 -999999E+3 -> NaN Invalid_operation resx528 rescale 1.234 -999999999 -> NaN Invalid_operation resx529 rescale 123.456 -999999999 -> NaN Invalid_operation resx530 rescale 123.456 -1000000014 -> NaN Invalid_operation resx531 rescale 123.456 -12345678903 -> NaN Invalid_operation maxexponent: 999 minexponent: -999 precision: 15 resx532 rescale 1.234E+999 999 -> 1E+999 Inexact Rounded resx533 rescale 1.234E+998 999 -> 0E+999 Inexact Rounded resx534 rescale 1.234 999 -> 0E+999 Inexact Rounded resx535 rescale 1.234 1000 -> NaN Invalid_operation resx536 rescale 1.234 5000 -> NaN Invalid_operation resx537 rescale 0 -999 -> 0E-999 -- next two are "won't fit" overflows resx538 rescale 1.234 -999 -> NaN Invalid_operation resx539 rescale 1.234 -1000 -> NaN Invalid_operation resx540 rescale 1.234 -5000 -> NaN Invalid_operation -- [more below] -- check bounds (lhs maybe out of range for destination, etc.) precision: 7 resx541 rescale 1E+999 +999 -> 1E+999 resx542 rescale 1E+1000 +999 -> NaN Invalid_operation resx543 rescale 1E+999 +1000 -> NaN Invalid_operation resx544 rescale 1E-999 -999 -> 1E-999 resx545 rescale 1E-1000 -999 -> 0E-999 Inexact Rounded resx546 rescale 1E-999 -1000 -> 1.0E-999 resx547 rescale 1E-1005 -999 -> 0E-999 Inexact Rounded resx548 rescale 1E-1006 -999 -> 0E-999 Inexact Rounded resx549 rescale 1E-1007 -999 -> 0E-999 Inexact Rounded resx550 rescale 1E-998 -1005 -> NaN Invalid_operation -- won't fit resx551 rescale 1E-999 -1005 -> 1.000000E-999 resx552 rescale 1E-1000 -1005 -> 1.00000E-1000 Subnormal resx553 rescale 1E-999 -1006 -> NaN Invalid_operation resx554 rescale 1E-999 -1007 -> NaN Invalid_operation -- related subnormal rounding resx555 rescale 1.666666E-999 -1005 -> 1.666666E-999 resx556 rescale 1.666666E-1000 -1005 -> 1.66667E-1000 Underflow Subnormal Inexact Rounded resx557 rescale 1.666666E-1001 -1005 -> 1.6667E-1001 Underflow Subnormal Inexact Rounded resx558 rescale 1.666666E-1002 -1005 -> 1.667E-1002 Underflow Subnormal Inexact Rounded resx559 rescale 1.666666E-1003 -1005 -> 1.67E-1003 Underflow Subnormal Inexact Rounded resx560 rescale 1.666666E-1004 -1005 -> 1.7E-1004 Underflow Subnormal Inexact Rounded resx561 rescale 1.666666E-1005 -1005 -> 2E-1005 Underflow Subnormal Inexact Rounded resx562 rescale 1.666666E-1006 -1005 -> 0E-1005 Inexact Rounded resx563 rescale 1.666666E-1007 -1005 -> 0E-1005 Inexact Rounded -- fractional RHS, some good and some bad precision: 9 resx564 rescale 222 +2.0 -> 2E+2 Inexact Rounded resx565 rescale 222 +2.00000000 -> 2E+2 Inexact Rounded resx566 rescale 222 +2.00100000000 -> NaN Invalid_operation resx567 rescale 222 +2.000001 -> NaN Invalid_operation resx568 rescale 222 +2.000000001 -> NaN Invalid_operation resx569 rescale 222 +2.0000000001 -> NaN Invalid_operation resx570 rescale 222 +2.00000000001 -> NaN Invalid_operation resx571 rescale 222 +2.99999999999 -> NaN Invalid_operation resx572 rescale 222 -2.00000000 -> 222.00 resx573 rescale 222 -2.00100000000 -> NaN Invalid_operation resx574 rescale 222 -2.0000001000 -> NaN Invalid_operation resx575 rescale 222 -2.00000000001 -> NaN Invalid_operation resx576 rescale 222 -2.99999999999 -> NaN Invalid_operation -- Specials resx580 rescale Inf -Inf -> Infinity resx581 rescale Inf -1000 -> NaN Invalid_operation resx582 rescale Inf -1 -> NaN Invalid_operation resx583 rescale Inf 0 -> NaN Invalid_operation resx584 rescale Inf 1 -> NaN Invalid_operation resx585 rescale Inf 1000 -> NaN Invalid_operation resx586 rescale Inf Inf -> Infinity resx587 rescale -1000 Inf -> NaN Invalid_operation resx588 rescale -Inf Inf -> -Infinity resx589 rescale -1 Inf -> NaN Invalid_operation resx590 rescale 0 Inf -> NaN Invalid_operation resx591 rescale 1 Inf -> NaN Invalid_operation resx592 rescale 1000 Inf -> NaN Invalid_operation resx593 rescale Inf Inf -> Infinity resx594 rescale Inf -0 -> NaN Invalid_operation resx595 rescale -0 Inf -> NaN Invalid_operation resx600 rescale -Inf -Inf -> -Infinity resx601 rescale -Inf -1000 -> NaN Invalid_operation resx602 rescale -Inf -1 -> NaN Invalid_operation resx603 rescale -Inf 0 -> NaN Invalid_operation resx604 rescale -Inf 1 -> NaN Invalid_operation resx605 rescale -Inf 1000 -> NaN Invalid_operation resx606 rescale -Inf Inf -> -Infinity resx607 rescale -1000 Inf -> NaN Invalid_operation resx608 rescale -Inf -Inf -> -Infinity resx609 rescale -1 -Inf -> NaN Invalid_operation resx610 rescale 0 -Inf -> NaN Invalid_operation resx611 rescale 1 -Inf -> NaN Invalid_operation resx612 rescale 1000 -Inf -> NaN Invalid_operation resx613 rescale Inf -Inf -> Infinity resx614 rescale -Inf -0 -> NaN Invalid_operation resx615 rescale -0 -Inf -> NaN Invalid_operation resx621 rescale NaN -Inf -> NaN resx622 rescale NaN -1000 -> NaN resx623 rescale NaN -1 -> NaN resx624 rescale NaN 0 -> NaN resx625 rescale NaN 1 -> NaN resx626 rescale NaN 1000 -> NaN resx627 rescale NaN Inf -> NaN resx628 rescale NaN NaN -> NaN resx629 rescale -Inf NaN -> NaN resx630 rescale -1000 NaN -> NaN resx631 rescale -1 NaN -> NaN resx632 rescale 0 NaN -> NaN resx633 rescale 1 -NaN -> -NaN resx634 rescale 1000 NaN -> NaN resx635 rescale Inf NaN -> NaN resx636 rescale NaN -0 -> NaN resx637 rescale -0 NaN -> NaN resx641 rescale sNaN -Inf -> NaN Invalid_operation resx642 rescale sNaN -1000 -> NaN Invalid_operation resx643 rescale sNaN -1 -> NaN Invalid_operation resx644 rescale sNaN 0 -> NaN Invalid_operation resx645 rescale sNaN 1 -> NaN Invalid_operation resx646 rescale sNaN 1000 -> NaN Invalid_operation resx647 rescale -sNaN NaN -> -NaN Invalid_operation resx648 rescale sNaN -sNaN -> NaN Invalid_operation resx649 rescale NaN sNaN -> NaN Invalid_operation resx650 rescale -Inf sNaN -> NaN Invalid_operation resx651 rescale -1000 sNaN -> NaN Invalid_operation resx652 rescale -1 sNaN -> NaN Invalid_operation resx653 rescale 0 sNaN -> NaN Invalid_operation resx654 rescale 1 -sNaN -> -NaN Invalid_operation resx655 rescale 1000 sNaN -> NaN Invalid_operation resx656 rescale Inf sNaN -> NaN Invalid_operation resx657 rescale NaN sNaN -> NaN Invalid_operation resx658 rescale sNaN -0 -> NaN Invalid_operation resx659 rescale -0 sNaN -> NaN Invalid_operation -- propagating NaNs resx661 rescale NaN9 -Inf -> NaN9 resx662 rescale NaN81 919 -> NaN81 resx663 rescale NaN72 Inf -> NaN72 resx664 rescale -NaN66 NaN5 -> -NaN66 resx665 rescale -Inf NaN4 -> NaN4 resx666 rescale -919 NaN32 -> NaN32 resx667 rescale Inf NaN2 -> NaN2 resx671 rescale sNaN99 -Inf -> NaN99 Invalid_operation resx672 rescale -sNaN98 -11 -> -NaN98 Invalid_operation resx673 rescale sNaN97 NaN -> NaN97 Invalid_operation resx674 rescale sNaN16 sNaN94 -> NaN16 Invalid_operation resx675 rescale NaN95 sNaN93 -> NaN93 Invalid_operation resx676 rescale -Inf sNaN92 -> NaN92 Invalid_operation resx677 rescale 088 -sNaN91 -> -NaN91 Invalid_operation resx678 rescale Inf -sNaN90 -> -NaN90 Invalid_operation resx679 rescale NaN sNaN87 -> NaN87 Invalid_operation -- subnormals and underflow precision: 4 maxexponent: 999 minexponent: -999 resx710 rescale 1.00E-999 -999 -> 1E-999 Rounded resx711 rescale 0.1E-999 -1000 -> 1E-1000 Subnormal resx712 rescale 0.10E-999 -1000 -> 1E-1000 Subnormal Rounded resx713 rescale 0.100E-999 -1000 -> 1E-1000 Subnormal Rounded resx714 rescale 0.01E-999 -1001 -> 1E-1001 Subnormal -- next is rounded to Emin resx715 rescale 0.999E-999 -999 -> 1E-999 Inexact Rounded resx716 rescale 0.099E-999 -1000 -> 1E-1000 Inexact Rounded Subnormal Underflow resx717 rescale 0.009E-999 -1001 -> 1E-1001 Inexact Rounded Subnormal Underflow resx718 rescale 0.001E-999 -1001 -> 0E-1001 Inexact Rounded resx719 rescale 0.0009E-999 -1001 -> 0E-1001 Inexact Rounded resx720 rescale 0.0001E-999 -1001 -> 0E-1001 Inexact Rounded resx730 rescale -1.00E-999 -999 -> -1E-999 Rounded resx731 rescale -0.1E-999 -999 -> -0E-999 Rounded Inexact resx732 rescale -0.10E-999 -999 -> -0E-999 Rounded Inexact resx733 rescale -0.100E-999 -999 -> -0E-999 Rounded Inexact resx734 rescale -0.01E-999 -999 -> -0E-999 Inexact Rounded -- next is rounded to Emin resx735 rescale -0.999E-999 -999 -> -1E-999 Inexact Rounded resx736 rescale -0.099E-999 -999 -> -0E-999 Inexact Rounded resx737 rescale -0.009E-999 -999 -> -0E-999 Inexact Rounded resx738 rescale -0.001E-999 -999 -> -0E-999 Inexact Rounded resx739 rescale -0.0001E-999 -999 -> -0E-999 Inexact Rounded resx740 rescale -1.00E-999 -1000 -> -1.0E-999 Rounded resx741 rescale -0.1E-999 -1000 -> -1E-1000 Subnormal resx742 rescale -0.10E-999 -1000 -> -1E-1000 Subnormal Rounded resx743 rescale -0.100E-999 -1000 -> -1E-1000 Subnormal Rounded resx744 rescale -0.01E-999 -1000 -> -0E-1000 Inexact Rounded -- next is rounded to Emin resx745 rescale -0.999E-999 -1000 -> -1.0E-999 Inexact Rounded resx746 rescale -0.099E-999 -1000 -> -1E-1000 Inexact Rounded Subnormal Underflow resx747 rescale -0.009E-999 -1000 -> -0E-1000 Inexact Rounded resx748 rescale -0.001E-999 -1000 -> -0E-1000 Inexact Rounded resx749 rescale -0.0001E-999 -1000 -> -0E-1000 Inexact Rounded resx750 rescale -1.00E-999 -1001 -> -1.00E-999 resx751 rescale -0.1E-999 -1001 -> -1.0E-1000 Subnormal resx752 rescale -0.10E-999 -1001 -> -1.0E-1000 Subnormal resx753 rescale -0.100E-999 -1001 -> -1.0E-1000 Subnormal Rounded resx754 rescale -0.01E-999 -1001 -> -1E-1001 Subnormal -- next is rounded to Emin resx755 rescale -0.999E-999 -1001 -> -1.00E-999 Inexact Rounded resx756 rescale -0.099E-999 -1001 -> -1.0E-1000 Inexact Rounded Subnormal Underflow resx757 rescale -0.009E-999 -1001 -> -1E-1001 Inexact Rounded Subnormal Underflow resx758 rescale -0.001E-999 -1001 -> -0E-1001 Inexact Rounded resx759 rescale -0.0001E-999 -1001 -> -0E-1001 Inexact Rounded resx760 rescale -1.00E-999 -1002 -> -1.000E-999 resx761 rescale -0.1E-999 -1002 -> -1.00E-1000 Subnormal resx762 rescale -0.10E-999 -1002 -> -1.00E-1000 Subnormal resx763 rescale -0.100E-999 -1002 -> -1.00E-1000 Subnormal resx764 rescale -0.01E-999 -1002 -> -1.0E-1001 Subnormal resx765 rescale -0.999E-999 -1002 -> -9.99E-1000 Subnormal resx766 rescale -0.099E-999 -1002 -> -9.9E-1001 Subnormal resx767 rescale -0.009E-999 -1002 -> -9E-1002 Subnormal resx768 rescale -0.001E-999 -1002 -> -1E-1002 Subnormal resx769 rescale -0.0001E-999 -1002 -> -0E-1002 Inexact Rounded -- rhs must be no less than Etiny resx770 rescale -1.00E-999 -1003 -> NaN Invalid_operation resx771 rescale -0.1E-999 -1003 -> NaN Invalid_operation resx772 rescale -0.10E-999 -1003 -> NaN Invalid_operation resx773 rescale -0.100E-999 -1003 -> NaN Invalid_operation resx774 rescale -0.01E-999 -1003 -> NaN Invalid_operation resx775 rescale -0.999E-999 -1003 -> NaN Invalid_operation resx776 rescale -0.099E-999 -1003 -> NaN Invalid_operation resx777 rescale -0.009E-999 -1003 -> NaN Invalid_operation resx778 rescale -0.001E-999 -1003 -> NaN Invalid_operation resx779 rescale -0.0001E-999 -1003 -> NaN Invalid_operation precision: 9 maxExponent: 999999999 minexponent: -999999999 -- getInt worries resx801 rescale 0 1000000000 -> NaN Invalid_operation resx802 rescale 0 -1000000000 -> 0E-1000000000 resx803 rescale 0 2000000000 -> NaN Invalid_operation resx804 rescale 0 -2000000000 -> NaN Invalid_operation resx805 rescale 0 3000000000 -> NaN Invalid_operation resx806 rescale 0 -3000000000 -> NaN Invalid_operation resx807 rescale 0 4000000000 -> NaN Invalid_operation resx808 rescale 0 -4000000000 -> NaN Invalid_operation resx809 rescale 0 5000000000 -> NaN Invalid_operation resx810 rescale 0 -5000000000 -> NaN Invalid_operation resx811 rescale 0 6000000000 -> NaN Invalid_operation resx812 rescale 0 -6000000000 -> NaN Invalid_operation resx813 rescale 0 7000000000 -> NaN Invalid_operation resx814 rescale 0 -7000000000 -> NaN Invalid_operation resx815 rescale 0 8000000000 -> NaN Invalid_operation resx816 rescale 0 -8000000000 -> NaN Invalid_operation resx817 rescale 0 9000000000 -> NaN Invalid_operation resx818 rescale 0 -9000000000 -> NaN Invalid_operation resx819 rescale 0 9999999999 -> NaN Invalid_operation resx820 rescale 0 -9999999999 -> NaN Invalid_operation resx821 rescale 0 10000000000 -> NaN Invalid_operation resx822 rescale 0 -10000000000 -> NaN Invalid_operation resx831 rescale 1 0E-1 -> 1 resx832 rescale 1 0E-2 -> 1 resx833 rescale 1 0E-3 -> 1 resx834 rescale 1 0E-4 -> 1 resx835 rescale 1 0E-100 -> 1 resx836 rescale 1 0E-100000 -> 1 resx837 rescale 1 0E+100 -> 1 resx838 rescale 1 0E+100000 -> 1 resx841 rescale 0 5E-1000000 -> NaN Invalid_operation resx842 rescale 0 5E-1000000 -> NaN Invalid_operation resx843 rescale 0 999999999 -> 0E+999999999 resx844 rescale 0 1000000000 -> NaN Invalid_operation resx845 rescale 0 -999999999 -> 0E-999999999 resx846 rescale 0 -1000000000 -> 0E-1000000000 resx847 rescale 0 -1000000001 -> 0E-1000000001 resx848 rescale 0 -1000000002 -> 0E-1000000002 resx849 rescale 0 -1000000003 -> 0E-1000000003 resx850 rescale 0 -1000000004 -> 0E-1000000004 resx851 rescale 0 -1000000005 -> 0E-1000000005 resx852 rescale 0 -1000000006 -> 0E-1000000006 resx853 rescale 0 -1000000007 -> 0E-1000000007 resx854 rescale 0 -1000000008 -> NaN Invalid_operation resx861 rescale 1 +2147483649 -> NaN Invalid_operation resx862 rescale 1 +2147483648 -> NaN Invalid_operation resx863 rescale 1 +2147483647 -> NaN Invalid_operation resx864 rescale 1 -2147483647 -> NaN Invalid_operation resx865 rescale 1 -2147483648 -> NaN Invalid_operation resx866 rescale 1 -2147483649 -> NaN Invalid_operation -- Null tests res900 rescale 10 # -> NaN Invalid_operation res901 rescale # 10 -> NaN Invalid_operation --- NEW FILE: rounding.decTest --- ------------------------------------------------------------------------ -- rounding.decTest -- decimal rounding modes testcases -- -- Copyright (c) IBM Corporation, 1981, 2003. All rights reserved. -- ------------------------------------------------------------------------ -- Please see the document "General Decimal Arithmetic Testcases" -- -- at http://www2.hursley.ibm.com/decimal for the description of -- -- these testcases. -- -- -- -- These testcases are experimental ('beta' versions), and they -- -- may contain errors. They are offered on an as-is basis. In -- -- particular, achieving the same results as the tests here is not -- -- a guarantee that an implementation complies with any Standard -- -- or specification. The tests are not exhaustive. -- -- -- -- Please send comments, suggestions, and corrections to the author: -- -- Mike Cowlishaw, IBM Fellow -- -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ [...1040 lines suppressed...] rmex401 multiply 9.999E+999999999 10 -> Infinity Overflow Inexact Rounded rounding: half_down rmex402 multiply -9.999E+999999999 10 -> -Infinity Overflow Inexact Rounded rmex403 multiply 9.999E+999999999 10 -> Infinity Overflow Inexact Rounded rounding: half_even rmex404 multiply -9.999E+999999999 10 -> -Infinity Overflow Inexact Rounded rmex405 multiply 9.999E+999999999 10 -> Infinity Overflow Inexact Rounded rounding: floor rmex406 multiply -9.999E+999999999 10 -> -Infinity Overflow Inexact Rounded rmex407 multiply 9.999E+999999999 10 -> 9.99999999E+999999999 Overflow Inexact Rounded rounding: ceiling rmex408 multiply -9.999E+999999999 10 -> -9.99999999E+999999999 Overflow Inexact Rounded rmex409 multiply 9.999E+999999999 10 -> Infinity Overflow Inexact Rounded rounding: up rmex410 multiply -9.999E+999999999 10 -> -Infinity Overflow Inexact Rounded rmex411 multiply 9.999E+999999999 10 -> Infinity Overflow Inexact Rounded rounding: down rmex412 multiply -9.999E+999999999 10 -> -9.99999999E+999999999 Overflow Inexact Rounded rmex413 multiply 9.999E+999999999 10 -> 9.99999999E+999999999 Overflow Inexact Rounded --- NEW FILE: samequantum.decTest --- ------------------------------------------------------------------------ -- samequantum.decTest -- check quantums match -- -- Copyright (c) IBM Corporation, 2001, 2003. All rights reserved. -- ------------------------------------------------------------------------ -- Please see the document "General Decimal Arithmetic Testcases" -- -- at http://www2.hursley.ibm.com/decimal for the description of -- -- these testcases. -- -- -- -- These testcases are experimental ('beta' versions), and they -- -- may contain errors. They are offered on an as-is basis. In -- -- particular, achieving the same results as the tests here is not -- -- a guarantee that an implementation complies with any Standard -- -- or specification. The tests are not exhaustive. -- -- -- -- Please send comments, suggestions, and corrections to the author: -- -- Mike Cowlishaw, IBM Fellow -- -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ version: 2.38 extended: 1 precision: 9 rounding: half_up maxExponent: 999 minExponent: -999 samq001 samequantum 0 0 -> 1 samq002 samequantum 0 1 -> 1 samq003 samequantum 1 0 -> 1 samq004 samequantum 1 1 -> 1 samq011 samequantum 10 1E+1 -> 0 samq012 samequantum 10E+1 10E+1 -> 1 samq013 samequantum 100 10E+1 -> 0 samq014 samequantum 100 1E+2 -> 0 samq015 samequantum 0.1 1E-2 -> 0 samq016 samequantum 0.1 1E-1 -> 1 samq017 samequantum 0.1 1E-0 -> 0 samq018 samequantum 999 999 -> 1 samq019 samequantum 999E-1 99.9 -> 1 samq020 samequantum 111E-1 22.2 -> 1 samq021 samequantum 111E-1 1234.2 -> 1 -- zeros samq030 samequantum 0.0 1.1 -> 1 samq031 samequantum 0.0 1.11 -> 0 samq032 samequantum 0.0 0 -> 0 samq033 samequantum 0.0 0.0 -> 1 samq034 samequantum 0.0 0.00 -> 0 samq035 samequantum 0E+1 0E+0 -> 0 samq036 samequantum 0E+1 0E+1 -> 1 samq037 samequantum 0E+1 0E+2 -> 0 samq038 samequantum 0E-17 0E-16 -> 0 samq039 samequantum 0E-17 0E-17 -> 1 samq040 samequantum 0E-17 0E-18 -> 0 samq041 samequantum 0E-17 0.0E-15 -> 0 samq042 samequantum 0E-17 0.0E-16 -> 1 samq043 samequantum 0E-17 0.0E-17 -> 0 samq044 samequantum -0E-17 0.0E-16 -> 1 samq045 samequantum 0E-17 -0.0E-17 -> 0 samq046 samequantum 0E-17 -0.0E-16 -> 1 samq047 samequantum -0E-17 0.0E-17 -> 0 samq048 samequantum -0E-17 -0.0E-16 -> 1 samq049 samequantum -0E-17 -0.0E-17 -> 0 -- specials & combinations samq0110 samequantum -Inf -Inf -> 1 samq0111 samequantum -Inf Inf -> 1 samq0112 samequantum -Inf NaN -> 0 samq0113 samequantum -Inf -7E+3 -> 0 samq0114 samequantum -Inf -7 -> 0 samq0115 samequantum -Inf -7E-3 -> 0 samq0116 samequantum -Inf -0E-3 -> 0 samq0117 samequantum -Inf -0 -> 0 samq0118 samequantum -Inf -0E+3 -> 0 samq0119 samequantum -Inf 0E-3 -> 0 samq0120 samequantum -Inf 0 -> 0 samq0121 samequantum -Inf 0E+3 -> 0 samq0122 samequantum -Inf 7E-3 -> 0 samq0123 samequantum -Inf 7 -> 0 samq0124 samequantum -Inf 7E+3 -> 0 samq0125 samequantum -Inf sNaN -> 0 samq0210 samequantum Inf -Inf -> 1 samq0211 samequantum Inf Inf -> 1 samq0212 samequantum Inf NaN -> 0 samq0213 samequantum Inf -7E+3 -> 0 samq0214 samequantum Inf -7 -> 0 samq0215 samequantum Inf -7E-3 -> 0 samq0216 samequantum Inf -0E-3 -> 0 samq0217 samequantum Inf -0 -> 0 samq0218 samequantum Inf -0E+3 -> 0 samq0219 samequantum Inf 0E-3 -> 0 samq0220 samequantum Inf 0 -> 0 samq0221 samequantum Inf 0E+3 -> 0 samq0222 samequantum Inf 7E-3 -> 0 samq0223 samequantum Inf 7 -> 0 samq0224 samequantum Inf 7E+3 -> 0 samq0225 samequantum Inf sNaN -> 0 samq0310 samequantum NaN -Inf -> 0 samq0311 samequantum NaN Inf -> 0 samq0312 samequantum NaN NaN -> 1 samq0313 samequantum NaN -7E+3 -> 0 samq0314 samequantum NaN -7 -> 0 samq0315 samequantum NaN -7E-3 -> 0 samq0316 samequantum NaN -0E-3 -> 0 samq0317 samequantum NaN -0 -> 0 samq0318 samequantum NaN -0E+3 -> 0 samq0319 samequantum NaN 0E-3 -> 0 samq0320 samequantum NaN 0 -> 0 samq0321 samequantum NaN 0E+3 -> 0 samq0322 samequantum NaN 7E-3 -> 0 samq0323 samequantum NaN 7 -> 0 samq0324 samequantum NaN 7E+3 -> 0 samq0325 samequantum NaN sNaN -> 1 samq0410 samequantum -7E+3 -Inf -> 0 samq0411 samequantum -7E+3 Inf -> 0 samq0412 samequantum -7E+3 NaN -> 0 samq0413 samequantum -7E+3 -7E+3 -> 1 samq0414 samequantum -7E+3 -7 -> 0 samq0415 samequantum -7E+3 -7E-3 -> 0 samq0416 samequantum -7E+3 -0E-3 -> 0 samq0417 samequantum -7E+3 -0 -> 0 samq0418 samequantum -7E+3 -0E+3 -> 1 samq0419 samequantum -7E+3 0E-3 -> 0 samq0420 samequantum -7E+3 0 -> 0 samq0421 samequantum -7E+3 0E+3 -> 1 samq0422 samequantum -7E+3 7E-3 -> 0 samq0423 samequantum -7E+3 7 -> 0 samq0424 samequantum -7E+3 7E+3 -> 1 samq0425 samequantum -7E+3 sNaN -> 0 samq0510 samequantum -7 -Inf -> 0 samq0511 samequantum -7 Inf -> 0 samq0512 samequantum -7 NaN -> 0 samq0513 samequantum -7 -7E+3 -> 0 samq0514 samequantum -7 -7 -> 1 samq0515 samequantum -7 -7E-3 -> 0 samq0516 samequantum -7 -0E-3 -> 0 samq0517 samequantum -7 -0 -> 1 samq0518 samequantum -7 -0E+3 -> 0 samq0519 samequantum -7 0E-3 -> 0 samq0520 samequantum -7 0 -> 1 samq0521 samequantum -7 0E+3 -> 0 samq0522 samequantum -7 7E-3 -> 0 samq0523 samequantum -7 7 -> 1 samq0524 samequantum -7 7E+3 -> 0 samq0525 samequantum -7 sNaN -> 0 samq0610 samequantum -7E-3 -Inf -> 0 samq0611 samequantum -7E-3 Inf -> 0 samq0612 samequantum -7E-3 NaN -> 0 samq0613 samequantum -7E-3 -7E+3 -> 0 samq0614 samequantum -7E-3 -7 -> 0 samq0615 samequantum -7E-3 -7E-3 -> 1 samq0616 samequantum -7E-3 -0E-3 -> 1 samq0617 samequantum -7E-3 -0 -> 0 samq0618 samequantum -7E-3 -0E+3 -> 0 samq0619 samequantum -7E-3 0E-3 -> 1 samq0620 samequantum -7E-3 0 -> 0 samq0621 samequantum -7E-3 0E+3 -> 0 samq0622 samequantum -7E-3 7E-3 -> 1 samq0623 samequantum -7E-3 7 -> 0 samq0624 samequantum -7E-3 7E+3 -> 0 samq0625 samequantum -7E-3 sNaN -> 0 samq0710 samequantum -0E-3 -Inf -> 0 samq0711 samequantum -0E-3 Inf -> 0 samq0712 samequantum -0E-3 NaN -> 0 samq0713 samequantum -0E-3 -7E+3 -> 0 samq0714 samequantum -0E-3 -7 -> 0 samq0715 samequantum -0E-3 -7E-3 -> 1 samq0716 samequantum -0E-3 -0E-3 -> 1 samq0717 samequantum -0E-3 -0 -> 0 samq0718 samequantum -0E-3 -0E+3 -> 0 samq0719 samequantum -0E-3 0E-3 -> 1 samq0720 samequantum -0E-3 0 -> 0 samq0721 samequantum -0E-3 0E+3 -> 0 samq0722 samequantum -0E-3 7E-3 -> 1 samq0723 samequantum -0E-3 7 -> 0 samq0724 samequantum -0E-3 7E+3 -> 0 samq0725 samequantum -0E-3 sNaN -> 0 samq0810 samequantum -0 -Inf -> 0 samq0811 samequantum -0 Inf -> 0 samq0812 samequantum -0 NaN -> 0 samq0813 samequantum -0 -7E+3 -> 0 samq0814 samequantum -0 -7 -> 1 samq0815 samequantum -0 -7E-3 -> 0 samq0816 samequantum -0 -0E-3 -> 0 samq0817 samequantum -0 -0 -> 1 samq0818 samequantum -0 -0E+3 -> 0 samq0819 samequantum -0 0E-3 -> 0 samq0820 samequantum -0 0 -> 1 samq0821 samequantum -0 0E+3 -> 0 samq0822 samequantum -0 7E-3 -> 0 samq0823 samequantum -0 7 -> 1 samq0824 samequantum -0 7E+3 -> 0 samq0825 samequantum -0 sNaN -> 0 samq0910 samequantum -0E+3 -Inf -> 0 samq0911 samequantum -0E+3 Inf -> 0 samq0912 samequantum -0E+3 NaN -> 0 samq0913 samequantum -0E+3 -7E+3 -> 1 samq0914 samequantum -0E+3 -7 -> 0 samq0915 samequantum -0E+3 -7E-3 -> 0 samq0916 samequantum -0E+3 -0E-3 -> 0 samq0917 samequantum -0E+3 -0 -> 0 samq0918 samequantum -0E+3 -0E+3 -> 1 samq0919 samequantum -0E+3 0E-3 -> 0 samq0920 samequantum -0E+3 0 -> 0 samq0921 samequantum -0E+3 0E+3 -> 1 samq0922 samequantum -0E+3 7E-3 -> 0 samq0923 samequantum -0E+3 7 -> 0 samq0924 samequantum -0E+3 7E+3 -> 1 samq0925 samequantum -0E+3 sNaN -> 0 samq1110 samequantum 0E-3 -Inf -> 0 samq1111 samequantum 0E-3 Inf -> 0 samq1112 samequantum 0E-3 NaN -> 0 samq1113 samequantum 0E-3 -7E+3 -> 0 samq1114 samequantum 0E-3 -7 -> 0 samq1115 samequantum 0E-3 -7E-3 -> 1 samq1116 samequantum 0E-3 -0E-3 -> 1 samq1117 samequantum 0E-3 -0 -> 0 samq1118 samequantum 0E-3 -0E+3 -> 0 samq1119 samequantum 0E-3 0E-3 -> 1 samq1120 samequantum 0E-3 0 -> 0 samq1121 samequantum 0E-3 0E+3 -> 0 samq1122 samequantum 0E-3 7E-3 -> 1 samq1123 samequantum 0E-3 7 -> 0 samq1124 samequantum 0E-3 7E+3 -> 0 samq1125 samequantum 0E-3 sNaN -> 0 samq1210 samequantum 0 -Inf -> 0 samq1211 samequantum 0 Inf -> 0 samq1212 samequantum 0 NaN -> 0 samq1213 samequantum 0 -7E+3 -> 0 samq1214 samequantum 0 -7 -> 1 samq1215 samequantum 0 -7E-3 -> 0 samq1216 samequantum 0 -0E-3 -> 0 samq1217 samequantum 0 -0 -> 1 samq1218 samequantum 0 -0E+3 -> 0 samq1219 samequantum 0 0E-3 -> 0 samq1220 samequantum 0 0 -> 1 samq1221 samequantum 0 0E+3 -> 0 samq1222 samequantum 0 7E-3 -> 0 samq1223 samequantum 0 7 -> 1 samq1224 samequantum 0 7E+3 -> 0 samq1225 samequantum 0 sNaN -> 0 samq1310 samequantum 0E+3 -Inf -> 0 samq1311 samequantum 0E+3 Inf -> 0 samq1312 samequantum 0E+3 NaN -> 0 samq1313 samequantum 0E+3 -7E+3 -> 1 samq1314 samequantum 0E+3 -7 -> 0 samq1315 samequantum 0E+3 -7E-3 -> 0 samq1316 samequantum 0E+3 -0E-3 -> 0 samq1317 samequantum 0E+3 -0 -> 0 samq1318 samequantum 0E+3 -0E+3 -> 1 samq1319 samequantum 0E+3 0E-3 -> 0 samq1320 samequantum 0E+3 0 -> 0 samq1321 samequantum 0E+3 0E+3 -> 1 samq1322 samequantum 0E+3 7E-3 -> 0 samq1323 samequantum 0E+3 7 -> 0 samq1324 samequantum 0E+3 7E+3 -> 1 samq1325 samequantum 0E+3 sNaN -> 0 samq1410 samequantum 7E-3 -Inf -> 0 samq1411 samequantum 7E-3 Inf -> 0 samq1412 samequantum 7E-3 NaN -> 0 samq1413 samequantum 7E-3 -7E+3 -> 0 samq1414 samequantum 7E-3 -7 -> 0 samq1415 samequantum 7E-3 -7E-3 -> 1 samq1416 samequantum 7E-3 -0E-3 -> 1 samq1417 samequantum 7E-3 -0 -> 0 samq1418 samequantum 7E-3 -0E+3 -> 0 samq1419 samequantum 7E-3 0E-3 -> 1 samq1420 samequantum 7E-3 0 -> 0 samq1421 samequantum 7E-3 0E+3 -> 0 samq1422 samequantum 7E-3 7E-3 -> 1 samq1423 samequantum 7E-3 7 -> 0 samq1424 samequantum 7E-3 7E+3 -> 0 samq1425 samequantum 7E-3 sNaN -> 0 samq1510 samequantum 7 -Inf -> 0 samq1511 samequantum 7 Inf -> 0 samq1512 samequantum 7 NaN -> 0 samq1513 samequantum 7 -7E+3 -> 0 samq1514 samequantum 7 -7 -> 1 samq1515 samequantum 7 -7E-3 -> 0 samq1516 samequantum 7 -0E-3 -> 0 samq1517 samequantum 7 -0 -> 1 samq1518 samequantum 7 -0E+3 -> 0 samq1519 samequantum 7 0E-3 -> 0 samq1520 samequantum 7 0 -> 1 samq1521 samequantum 7 0E+3 -> 0 samq1522 samequantum 7 7E-3 -> 0 samq1523 samequantum 7 7 -> 1 samq1524 samequantum 7 7E+3 -> 0 samq1525 samequantum 7 sNaN -> 0 samq1610 samequantum 7E+3 -Inf -> 0 samq1611 samequantum 7E+3 Inf -> 0 samq1612 samequantum 7E+3 NaN -> 0 samq1613 samequantum 7E+3 -7E+3 -> 1 samq1614 samequantum 7E+3 -7 -> 0 samq1615 samequantum 7E+3 -7E-3 -> 0 samq1616 samequantum 7E+3 -0E-3 -> 0 samq1617 samequantum 7E+3 -0 -> 0 samq1618 samequantum 7E+3 -0E+3 -> 1 samq1619 samequantum 7E+3 0E-3 -> 0 samq1620 samequantum 7E+3 0 -> 0 samq1621 samequantum 7E+3 0E+3 -> 1 samq1622 samequantum 7E+3 7E-3 -> 0 samq1623 samequantum 7E+3 7 -> 0 samq1624 samequantum 7E+3 7E+3 -> 1 samq1625 samequantum 7E+3 sNaN -> 0 samq1710 samequantum sNaN -Inf -> 0 samq1711 samequantum sNaN Inf -> 0 samq1712 samequantum sNaN NaN -> 1 samq1713 samequantum sNaN -7E+3 -> 0 samq1714 samequantum sNaN -7 -> 0 samq1715 samequantum sNaN -7E-3 -> 0 samq1716 samequantum sNaN -0E-3 -> 0 samq1717 samequantum sNaN -0 -> 0 samq1718 samequantum sNaN -0E+3 -> 0 samq1719 samequantum sNaN 0E-3 -> 0 samq1720 samequantum sNaN 0 -> 0 samq1721 samequantum sNaN 0E+3 -> 0 samq1722 samequantum sNaN 7E-3 -> 0 samq1723 samequantum sNaN 7 -> 0 samq1724 samequantum sNaN 7E+3 -> 0 samq1725 samequantum sNaN sNaN -> 1 -- noisy NaNs samq1730 samequantum sNaN3 sNaN3 -> 1 samq1731 samequantum sNaN3 sNaN4 -> 1 samq1732 samequantum NaN3 NaN3 -> 1 samq1733 samequantum NaN3 NaN4 -> 1 samq1734 samequantum sNaN3 3 -> 0 samq1735 samequantum NaN3 3 -> 0 samq1736 samequantum 4 sNaN4 -> 0 samq1737 samequantum 3 NaN3 -> 0 samq1738 samequantum Inf sNaN4 -> 0 samq1739 samequantum -Inf NaN3 -> 0 --- NEW FILE: squareroot.decTest --- ------------------------------------------------------------------------ -- squareroot.decTest -- decimal square root -- -- Copyright (c) IBM Corporation, 2004. All rights reserved. -- ------------------------------------------------------------------------ -- Please see the document "General Decimal Arithmetic Testcases" -- -- at http://www2.hursley.ibm.com/decimal for the description of -- -- these testcases. -- -- -- -- These testcases are experimental ('beta' versions), and they -- -- may contain errors. They are offered on an as-is basis. In -- -- particular, achieving the same results as the tests here is not -- -- a guarantee that an implementation complies with any Standard -- -- or specification. The tests are not exhaustive. -- -- -- -- Please send comments, suggestions, and corrections to the author: -- -- Mike Cowlishaw, IBM Fellow -- -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ [...2919 lines suppressed...] sqtx811 squareroot 10E-22 -> 3.16227766017E-11 Underflow Subnormal Inexact Rounded sqtx812 squareroot 1E-22 -> 1E-11 Subnormal -- Exact Subnormal case -- special values maxexponent: 999 minexponent: -999 sqtx820 squareroot Inf -> Infinity sqtx821 squareroot -Inf -> NaN Invalid_operation sqtx822 squareroot NaN -> NaN sqtx823 squareroot sNaN -> NaN Invalid_operation -- propagating NaNs sqtx824 squareroot sNaN123 -> NaN123 Invalid_operation sqtx825 squareroot -sNaN321 -> -NaN321 Invalid_operation sqtx826 squareroot NaN456 -> NaN456 sqtx827 squareroot -NaN654 -> -NaN654 sqtx828 squareroot NaN1 -> NaN1 -- Null test sqtx900 squareroot # -> NaN Invalid_operation --- NEW FILE: subtract.decTest --- ------------------------------------------------------------------------ -- subtract.decTest -- decimal subtraction -- -- Copyright (c) IBM Corporation, 1981, 2004. All rights reserved. -- ------------------------------------------------------------------------ -- Please see the document "General Decimal Arithmetic Testcases" -- -- at http://www2.hursley.ibm.com/decimal for the description of -- -- these testcases. -- -- -- -- These testcases are experimental ('beta' versions), and they -- -- may contain errors. They are offered on an as-is basis. In -- -- particular, achieving the same results as the tests here is not -- -- a guarantee that an implementation complies with any Standard -- -- or specification. The tests are not exhaustive. -- -- -- -- Please send comments, suggestions, and corrections to the author: -- -- Mike Cowlishaw, IBM Fellow -- -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ version: 2.38 extended: 1 precision: 9 rounding: half_up maxExponent: 384 minexponent: -383 -- [first group are 'quick confidence check'] subx001 subtract 0 0 -> '0' subx002 subtract 1 1 -> '0' subx003 subtract 1 2 -> '-1' subx004 subtract 2 1 -> '1' subx005 subtract 2 2 -> '0' subx006 subtract 3 2 -> '1' subx007 subtract 2 3 -> '-1' subx011 subtract -0 0 -> '-0' subx012 subtract -1 1 -> '-2' subx013 subtract -1 2 -> '-3' subx014 subtract -2 1 -> '-3' subx015 subtract -2 2 -> '-4' subx016 subtract -3 2 -> '-5' subx017 subtract -2 3 -> '-5' subx021 subtract 0 -0 -> '0' subx022 subtract 1 -1 -> '2' subx023 subtract 1 -2 -> '3' subx024 subtract 2 -1 -> '3' subx025 subtract 2 -2 -> '4' subx026 subtract 3 -2 -> '5' subx027 subtract 2 -3 -> '5' subx030 subtract 11 1 -> 10 subx031 subtract 10 1 -> 9 subx032 subtract 9 1 -> 8 subx033 subtract 1 1 -> 0 subx034 subtract 0 1 -> -1 subx035 subtract -1 1 -> -2 subx036 subtract -9 1 -> -10 subx037 subtract -10 1 -> -11 subx038 subtract -11 1 -> -12 subx040 subtract '5.75' '3.3' -> '2.45' subx041 subtract '5' '-3' -> '8' subx042 subtract '-5' '-3' -> '-2' subx043 subtract '-7' '2.5' -> '-9.5' subx044 subtract '0.7' '0.3' -> '0.4' subx045 subtract '1.3' '0.3' -> '1.0' subx046 subtract '1.25' '1.25' -> '0.00' subx050 subtract '1.23456789' '1.00000000' -> '0.23456789' subx051 subtract '1.23456789' '1.00000089' -> '0.23456700' subx052 subtract '0.5555555559' '0.0000000001' -> '0.555555556' Inexact Rounded subx053 subtract '0.5555555559' '0.0000000005' -> '0.555555555' Inexact Rounded subx054 subtract '0.4444444444' '0.1111111111' -> '0.333333333' Inexact Rounded subx055 subtract '1.0000000000' '0.00000001' -> '0.999999990' Rounded subx056 subtract '0.4444444444999' '0' -> '0.444444444' Inexact Rounded subx057 subtract '0.4444444445000' '0' -> '0.444444445' Inexact Rounded subx060 subtract '70' '10000e+9' -> '-1.00000000E+13' Inexact Rounded subx061 subtract '700' '10000e+9' -> '-1.00000000E+13' Inexact Rounded subx062 subtract '7000' '10000e+9' -> '-9.99999999E+12' Inexact Rounded subx063 subtract '70000' '10000e+9' -> '-9.99999993E+12' Rounded subx064 subtract '700000' '10000e+9' -> '-9.99999930E+12' Rounded -- symmetry: subx065 subtract '10000e+9' '70' -> '1.00000000E+13' Inexact Rounded subx066 subtract '10000e+9' '700' -> '1.00000000E+13' Inexact Rounded subx067 subtract '10000e+9' '7000' -> '9.99999999E+12' Inexact Rounded subx068 subtract '10000e+9' '70000' -> '9.99999993E+12' Rounded subx069 subtract '10000e+9' '700000' -> '9.99999930E+12' Rounded -- change precision subx080 subtract '10000e+9' '70000' -> '9.99999993E+12' Rounded precision: 6 subx081 subtract '10000e+9' '70000' -> '1.00000E+13' Inexact Rounded precision: 9 -- some of the next group are really constructor tests subx090 subtract '00.0' '0.0' -> '0.0' subx091 subtract '00.0' '0.00' -> '0.00' subx092 subtract '0.00' '00.0' -> '0.00' subx093 subtract '00.0' '0.00' -> '0.00' subx094 subtract '0.00' '00.0' -> '0.00' subx095 subtract '3' '.3' -> '2.7' subx096 subtract '3.' '.3' -> '2.7' subx097 subtract '3.0' '.3' -> '2.7' subx098 subtract '3.00' '.3' -> '2.70' subx099 subtract '3' '3' -> '0' subx100 subtract '3' '+3' -> '0' subx101 subtract '3' '-3' -> '6' subx102 subtract '3' '0.3' -> '2.7' subx103 subtract '3.' '0.3' -> '2.7' subx104 subtract '3.0' '0.3' -> '2.7' subx105 subtract '3.00' '0.3' -> '2.70' subx106 subtract '3' '3.0' -> '0.0' subx107 subtract '3' '+3.0' -> '0.0' subx108 subtract '3' '-3.0' -> '6.0' -- the above all from add; massaged and extended. Now some new ones... -- [particularly important for comparisons] -- NB: -xE-8 below were non-exponents pre-ANSI X3-274, and -1E-7 or 0E-7 -- with input rounding. subx120 subtract '10.23456784' '10.23456789' -> '-5E-8' subx121 subtract '10.23456785' '10.23456789' -> '-4E-8' subx122 subtract '10.23456786' '10.23456789' -> '-3E-8' subx123 subtract '10.23456787' '10.23456789' -> '-2E-8' subx124 subtract '10.23456788' '10.23456789' -> '-1E-8' subx125 subtract '10.23456789' '10.23456789' -> '0E-8' subx126 subtract '10.23456790' '10.23456789' -> '1E-8' subx127 subtract '10.23456791' '10.23456789' -> '2E-8' subx128 subtract '10.23456792' '10.23456789' -> '3E-8' subx129 subtract '10.23456793' '10.23456789' -> '4E-8' subx130 subtract '10.23456794' '10.23456789' -> '5E-8' subx131 subtract '10.23456781' '10.23456786' -> '-5E-8' subx132 subtract '10.23456782' '10.23456786' -> '-4E-8' subx133 subtract '10.23456783' '10.23456786' -> '-3E-8' subx134 subtract '10.23456784' '10.23456786' -> '-2E-8' subx135 subtract '10.23456785' '10.23456786' -> '-1E-8' subx136 subtract '10.23456786' '10.23456786' -> '0E-8' subx137 subtract '10.23456787' '10.23456786' -> '1E-8' subx138 subtract '10.23456788' '10.23456786' -> '2E-8' subx139 subtract '10.23456789' '10.23456786' -> '3E-8' subx140 subtract '10.23456790' '10.23456786' -> '4E-8' subx141 subtract '10.23456791' '10.23456786' -> '5E-8' subx142 subtract '1' '0.999999999' -> '1E-9' subx143 subtract '0.999999999' '1' -> '-1E-9' subx144 subtract '-10.23456780' '-10.23456786' -> '6E-8' subx145 subtract '-10.23456790' '-10.23456786' -> '-4E-8' subx146 subtract '-10.23456791' '-10.23456786' -> '-5E-8' precision: 3 subx150 subtract '12345678900000' '9999999999999' -> 2.35E+12 Inexact Rounded subx151 subtract '9999999999999' '12345678900000' -> -2.35E+12 Inexact Rounded precision: 6 subx152 subtract '12345678900000' '9999999999999' -> 2.34568E+12 Inexact Rounded subx153 subtract '9999999999999' '12345678900000' -> -2.34568E+12 Inexact Rounded precision: 9 subx154 subtract '12345678900000' '9999999999999' -> 2.34567890E+12 Inexact Rounded subx155 subtract '9999999999999' '12345678900000' -> -2.34567890E+12 Inexact Rounded precision: 12 subx156 subtract '12345678900000' '9999999999999' -> 2.34567890000E+12 Inexact Rounded subx157 subtract '9999999999999' '12345678900000' -> -2.34567890000E+12 Inexact Rounded precision: 15 subx158 subtract '12345678900000' '9999999999999' -> 2345678900001 subx159 subtract '9999999999999' '12345678900000' -> -2345678900001 precision: 9 -- additional scaled arithmetic tests [0.97 problem] subx160 subtract '0' '.1' -> '-0.1' subx161 subtract '00' '.97983' -> '-0.97983' subx162 subtract '0' '.9' -> '-0.9' subx163 subtract '0' '0.102' -> '-0.102' subx164 subtract '0' '.4' -> '-0.4' subx165 subtract '0' '.307' -> '-0.307' subx166 subtract '0' '.43822' -> '-0.43822' subx167 subtract '0' '.911' -> '-0.911' subx168 subtract '.0' '.02' -> '-0.02' subx169 subtract '00' '.392' -> '-0.392' subx170 subtract '0' '.26' -> '-0.26' subx171 subtract '0' '0.51' -> '-0.51' subx172 subtract '0' '.2234' -> '-0.2234' subx173 subtract '0' '.2' -> '-0.2' subx174 subtract '.0' '.0008' -> '-0.0008' -- 0. on left subx180 subtract '0.0' '-.1' -> '0.1' subx181 subtract '0.00' '-.97983' -> '0.97983' subx182 subtract '0.0' '-.9' -> '0.9' subx183 subtract '0.0' '-0.102' -> '0.102' subx184 subtract '0.0' '-.4' -> '0.4' subx185 subtract '0.0' '-.307' -> '0.307' subx186 subtract '0.0' '-.43822' -> '0.43822' subx187 subtract '0.0' '-.911' -> '0.911' subx188 subtract '0.0' '-.02' -> '0.02' subx189 subtract '0.00' '-.392' -> '0.392' subx190 subtract '0.0' '-.26' -> '0.26' subx191 subtract '0.0' '-0.51' -> '0.51' subx192 subtract '0.0' '-.2234' -> '0.2234' subx193 subtract '0.0' '-.2' -> '0.2' subx194 subtract '0.0' '-.0008' -> '0.0008' -- negatives of same subx200 subtract '0' '-.1' -> '0.1' subx201 subtract '00' '-.97983' -> '0.97983' subx202 subtract '0' '-.9' -> '0.9' subx203 subtract '0' '-0.102' -> '0.102' subx204 subtract '0' '-.4' -> '0.4' subx205 subtract '0' '-.307' -> '0.307' subx206 subtract '0' '-.43822' -> '0.43822' subx207 subtract '0' '-.911' -> '0.911' subx208 subtract '.0' '-.02' -> '0.02' subx209 subtract '00' '-.392' -> '0.392' subx210 subtract '0' '-.26' -> '0.26' subx211 subtract '0' '-0.51' -> '0.51' subx212 subtract '0' '-.2234' -> '0.2234' subx213 subtract '0' '-.2' -> '0.2' subx214 subtract '.0' '-.0008' -> '0.0008' -- more fixed, LHS swaps [really the same as testcases under add] subx220 subtract '-56267E-12' 0 -> '-5.6267E-8' subx221 subtract '-56267E-11' 0 -> '-5.6267E-7' subx222 subtract '-56267E-10' 0 -> '-0.0000056267' subx223 subtract '-56267E-9' 0 -> '-0.000056267' subx224 subtract '-56267E-8' 0 -> '-0.00056267' subx225 subtract '-56267E-7' 0 -> '-0.0056267' subx226 subtract '-56267E-6' 0 -> '-0.056267' subx227 subtract '-56267E-5' 0 -> '-0.56267' subx228 subtract '-56267E-2' 0 -> '-562.67' subx229 subtract '-56267E-1' 0 -> '-5626.7' subx230 subtract '-56267E-0' 0 -> '-56267' -- symmetry ... subx240 subtract 0 '-56267E-12' -> '5.6267E-8' subx241 subtract 0 '-56267E-11' -> '5.6267E-7' subx242 subtract 0 '-56267E-10' -> '0.0000056267' subx243 subtract 0 '-56267E-9' -> '0.000056267' subx244 subtract 0 '-56267E-8' -> '0.00056267' subx245 subtract 0 '-56267E-7' -> '0.0056267' subx246 subtract 0 '-56267E-6' -> '0.056267' subx247 subtract 0 '-56267E-5' -> '0.56267' subx248 subtract 0 '-56267E-2' -> '562.67' subx249 subtract 0 '-56267E-1' -> '5626.7' subx250 subtract 0 '-56267E-0' -> '56267' -- now some more from the 'new' add precision: 9 subx301 subtract '1.23456789' '1.00000000' -> '0.23456789' subx302 subtract '1.23456789' '1.00000011' -> '0.23456778' subx311 subtract '0.4444444444' '0.5555555555' -> '-0.111111111' Inexact Rounded subx312 subtract '0.4444444440' '0.5555555555' -> '-0.111111112' Inexact Rounded subx313 subtract '0.4444444444' '0.5555555550' -> '-0.111111111' Inexact Rounded subx314 subtract '0.44444444449' '0' -> '0.444444444' Inexact Rounded subx315 subtract '0.444444444499' '0' -> '0.444444444' Inexact Rounded subx316 subtract '0.4444444444999' '0' -> '0.444444444' Inexact Rounded subx317 subtract '0.4444444445000' '0' -> '0.444444445' Inexact Rounded subx318 subtract '0.4444444445001' '0' -> '0.444444445' Inexact Rounded subx319 subtract '0.444444444501' '0' -> '0.444444445' Inexact Rounded subx320 subtract '0.44444444451' '0' -> '0.444444445' Inexact Rounded -- some carrying effects subx321 subtract '0.9998' '0.0000' -> '0.9998' subx322 subtract '0.9998' '0.0001' -> '0.9997' subx323 subtract '0.9998' '0.0002' -> '0.9996' subx324 subtract '0.9998' '0.0003' -> '0.9995' subx325 subtract '0.9998' '-0.0000' -> '0.9998' subx326 subtract '0.9998' '-0.0001' -> '0.9999' subx327 subtract '0.9998' '-0.0002' -> '1.0000' subx328 subtract '0.9998' '-0.0003' -> '1.0001' subx330 subtract '70' '10000e+9' -> '-1.00000000E+13' Inexact Rounded subx331 subtract '700' '10000e+9' -> '-1.00000000E+13' Inexact Rounded subx332 subtract '7000' '10000e+9' -> '-9.99999999E+12' Inexact Rounded subx333 subtract '70000' '10000e+9' -> '-9.99999993E+12' Rounded subx334 subtract '700000' '10000e+9' -> '-9.99999930E+12' Rounded subx335 subtract '7000000' '10000e+9' -> '-9.99999300E+12' Rounded -- symmetry: subx340 subtract '10000e+9' '70' -> '1.00000000E+13' Inexact Rounded subx341 subtract '10000e+9' '700' -> '1.00000000E+13' Inexact Rounded subx342 subtract '10000e+9' '7000' -> '9.99999999E+12' Inexact Rounded subx343 subtract '10000e+9' '70000' -> '9.99999993E+12' Rounded subx344 subtract '10000e+9' '700000' -> '9.99999930E+12' Rounded subx345 subtract '10000e+9' '7000000' -> '9.99999300E+12' Rounded -- same, higher precision precision: 15 subx346 subtract '10000e+9' '7' -> '9999999999993' subx347 subtract '10000e+9' '70' -> '9999999999930' subx348 subtract '10000e+9' '700' -> '9999999999300' subx349 subtract '10000e+9' '7000' -> '9999999993000' subx350 subtract '10000e+9' '70000' -> '9999999930000' subx351 subtract '10000e+9' '700000' -> '9999999300000' subx352 subtract '7' '10000e+9' -> '-9999999999993' subx353 subtract '70' '10000e+9' -> '-9999999999930' subx354 subtract '700' '10000e+9' -> '-9999999999300' subx355 subtract '7000' '10000e+9' -> '-9999999993000' subx356 subtract '70000' '10000e+9' -> '-9999999930000' subx357 subtract '700000' '10000e+9' -> '-9999999300000' -- zero preservation precision: 6 subx360 subtract '10000e+9' '70000' -> '1.00000E+13' Inexact Rounded subx361 subtract 1 '0.0001' -> '0.9999' subx362 subtract 1 '0.00001' -> '0.99999' subx363 subtract 1 '0.000001' -> '0.999999' subx364 subtract 1 '0.0000001' -> '1.00000' Inexact Rounded subx365 subtract 1 '0.00000001' -> '1.00000' Inexact Rounded -- some funny zeros [in case of bad signum] subx370 subtract 1 0 -> 1 subx371 subtract 1 0. -> 1 subx372 subtract 1 .0 -> 1.0 subx373 subtract 1 0.0 -> 1.0 subx374 subtract 0 1 -> -1 subx375 subtract 0. 1 -> -1 subx376 subtract .0 1 -> -1.0 subx377 subtract 0.0 1 -> -1.0 precision: 9 -- leading 0 digit before round subx910 subtract -103519362 -51897955.3 -> -51621406.7 subx911 subtract 159579.444 89827.5229 -> 69751.9211 subx920 subtract 333.123456 33.1234566 -> 299.999999 Inexact Rounded subx921 subtract 333.123456 33.1234565 -> 300.000000 Inexact Rounded subx922 subtract 133.123456 33.1234565 -> 99.9999995 subx923 subtract 133.123456 33.1234564 -> 99.9999996 subx924 subtract 133.123456 33.1234540 -> 100.000002 Rounded subx925 subtract 133.123456 43.1234560 -> 90.0000000 subx926 subtract 133.123456 43.1234561 -> 89.9999999 subx927 subtract 133.123456 43.1234566 -> 89.9999994 subx928 subtract 101.123456 91.1234566 -> 9.9999994 subx929 subtract 101.123456 99.1234566 -> 1.9999994 -- more of the same; probe for cluster boundary problems precision: 1 subx930 subtract 11 2 -> 9 precision: 2 subx932 subtract 101 2 -> 99 precision: 3 subx934 subtract 101 2.1 -> 98.9 subx935 subtract 101 92.01 -> 8.99 precision: 4 subx936 subtract 101 2.01 -> 98.99 subx937 subtract 101 92.01 -> 8.99 subx938 subtract 101 92.006 -> 8.994 precision: 5 subx939 subtract 101 2.001 -> 98.999 subx940 subtract 101 92.001 -> 8.999 subx941 subtract 101 92.0006 -> 8.9994 precision: 6 subx942 subtract 101 2.0001 -> 98.9999 subx943 subtract 101 92.0001 -> 8.9999 subx944 subtract 101 92.00006 -> 8.99994 precision: 7 subx945 subtract 101 2.00001 -> 98.99999 subx946 subtract 101 92.00001 -> 8.99999 subx947 subtract 101 92.000006 -> 8.999994 precision: 8 subx948 subtract 101 2.000001 -> 98.999999 subx949 subtract 101 92.000001 -> 8.999999 subx950 subtract 101 92.0000006 -> 8.9999994 precision: 9 subx951 subtract 101 2.0000001 -> 98.9999999 subx952 subtract 101 92.0000001 -> 8.9999999 subx953 subtract 101 92.00000006 -> 8.99999994 precision: 9 -- more LHS swaps [were fixed] subx390 subtract '-56267E-10' 0 -> '-0.0000056267' subx391 subtract '-56267E-6' 0 -> '-0.056267' subx392 subtract '-56267E-5' 0 -> '-0.56267' subx393 subtract '-56267E-4' 0 -> '-5.6267' subx394 subtract '-56267E-3' 0 -> '-56.267' subx395 subtract '-56267E-2' 0 -> '-562.67' subx396 subtract '-56267E-1' 0 -> '-5626.7' subx397 subtract '-56267E-0' 0 -> '-56267' subx398 subtract '-5E-10' 0 -> '-5E-10' subx399 subtract '-5E-7' 0 -> '-5E-7' subx400 subtract '-5E-6' 0 -> '-0.000005' subx401 subtract '-5E-5' 0 -> '-0.00005' subx402 subtract '-5E-4' 0 -> '-0.0005' subx403 subtract '-5E-1' 0 -> '-0.5' subx404 subtract '-5E0' 0 -> '-5' subx405 subtract '-5E1' 0 -> '-50' subx406 subtract '-5E5' 0 -> '-500000' subx407 subtract '-5E8' 0 -> '-500000000' subx408 subtract '-5E9' 0 -> '-5.00000000E+9' Rounded subx409 subtract '-5E10' 0 -> '-5.00000000E+10' Rounded subx410 subtract '-5E11' 0 -> '-5.00000000E+11' Rounded subx411 subtract '-5E100' 0 -> '-5.00000000E+100' Rounded -- more RHS swaps [were fixed] subx420 subtract 0 '-56267E-10' -> '0.0000056267' subx421 subtract 0 '-56267E-6' -> '0.056267' subx422 subtract 0 '-56267E-5' -> '0.56267' subx423 subtract 0 '-56267E-4' -> '5.6267' subx424 subtract 0 '-56267E-3' -> '56.267' subx425 subtract 0 '-56267E-2' -> '562.67' subx426 subtract 0 '-56267E-1' -> '5626.7' subx427 subtract 0 '-56267E-0' -> '56267' subx428 subtract 0 '-5E-10' -> '5E-10' subx429 subtract 0 '-5E-7' -> '5E-7' subx430 subtract 0 '-5E-6' -> '0.000005' subx431 subtract 0 '-5E-5' -> '0.00005' subx432 subtract 0 '-5E-4' -> '0.0005' subx433 subtract 0 '-5E-1' -> '0.5' subx434 subtract 0 '-5E0' -> '5' subx435 subtract 0 '-5E1' -> '50' subx436 subtract 0 '-5E5' -> '500000' subx437 subtract 0 '-5E8' -> '500000000' subx438 subtract 0 '-5E9' -> '5.00000000E+9' Rounded subx439 subtract 0 '-5E10' -> '5.00000000E+10' Rounded subx440 subtract 0 '-5E11' -> '5.00000000E+11' Rounded subx441 subtract 0 '-5E100' -> '5.00000000E+100' Rounded -- try borderline precision, with carries, etc. precision: 15 subx461 subtract '1E+12' '1' -> '999999999999' subx462 subtract '1E+12' '-1.11' -> '1000000000001.11' subx463 subtract '1.11' '-1E+12' -> '1000000000001.11' subx464 subtract '-1' '-1E+12' -> '999999999999' subx465 subtract '7E+12' '1' -> '6999999999999' subx466 subtract '7E+12' '-1.11' -> '7000000000001.11' subx467 subtract '1.11' '-7E+12' -> '7000000000001.11' subx468 subtract '-1' '-7E+12' -> '6999999999999' -- 123456789012345 123456789012345 1 23456789012345 subx470 subtract '0.444444444444444' '-0.555555555555563' -> '1.00000000000001' Inexact Rounded subx471 subtract '0.444444444444444' '-0.555555555555562' -> '1.00000000000001' Inexact Rounded subx472 subtract '0.444444444444444' '-0.555555555555561' -> '1.00000000000001' Inexact Rounded subx473 subtract '0.444444444444444' '-0.555555555555560' -> '1.00000000000000' Inexact Rounded subx474 subtract '0.444444444444444' '-0.555555555555559' -> '1.00000000000000' Inexact Rounded subx475 subtract '0.444444444444444' '-0.555555555555558' -> '1.00000000000000' Inexact Rounded subx476 subtract '0.444444444444444' '-0.555555555555557' -> '1.00000000000000' Inexact Rounded subx477 subtract '0.444444444444444' '-0.555555555555556' -> '1.00000000000000' Rounded subx478 subtract '0.444444444444444' '-0.555555555555555' -> '0.999999999999999' subx479 subtract '0.444444444444444' '-0.555555555555554' -> '0.999999999999998' subx480 subtract '0.444444444444444' '-0.555555555555553' -> '0.999999999999997' subx481 subtract '0.444444444444444' '-0.555555555555552' -> '0.999999999999996' subx482 subtract '0.444444444444444' '-0.555555555555551' -> '0.999999999999995' subx483 subtract '0.444444444444444' '-0.555555555555550' -> '0.999999999999994' -- and some more, including residue effects and different roundings precision: 9 rounding: half_up subx500 subtract '123456789' 0 -> '123456789' subx501 subtract '123456789' 0.000000001 -> '123456789' Inexact Rounded subx502 subtract '123456789' 0.000001 -> '123456789' Inexact Rounded subx503 subtract '123456789' 0.1 -> '123456789' Inexact Rounded subx504 subtract '123456789' 0.4 -> '123456789' Inexact Rounded subx505 subtract '123456789' 0.49 -> '123456789' Inexact Rounded subx506 subtract '123456789' 0.499999 -> '123456789' Inexact Rounded subx507 subtract '123456789' 0.499999999 -> '123456789' Inexact Rounded subx508 subtract '123456789' 0.5 -> '123456789' Inexact Rounded subx509 subtract '123456789' 0.500000001 -> '123456788' Inexact Rounded subx510 subtract '123456789' 0.500001 -> '123456788' Inexact Rounded subx511 subtract '123456789' 0.51 -> '123456788' Inexact Rounded subx512 subtract '123456789' 0.6 -> '123456788' Inexact Rounded subx513 subtract '123456789' 0.9 -> '123456788' Inexact Rounded subx514 subtract '123456789' 0.99999 -> '123456788' Inexact Rounded subx515 subtract '123456789' 0.999999999 -> '123456788' Inexact Rounded subx516 subtract '123456789' 1 -> '123456788' subx517 subtract '123456789' 1.000000001 -> '123456788' Inexact Rounded subx518 subtract '123456789' 1.00001 -> '123456788' Inexact Rounded subx519 subtract '123456789' 1.1 -> '123456788' Inexact Rounded rounding: half_even subx520 subtract '123456789' 0 -> '123456789' subx521 subtract '123456789' 0.000000001 -> '123456789' Inexact Rounded subx522 subtract '123456789' 0.000001 -> '123456789' Inexact Rounded subx523 subtract '123456789' 0.1 -> '123456789' Inexact Rounded subx524 subtract '123456789' 0.4 -> '123456789' Inexact Rounded subx525 subtract '123456789' 0.49 -> '123456789' Inexact Rounded subx526 subtract '123456789' 0.499999 -> '123456789' Inexact Rounded subx527 subtract '123456789' 0.499999999 -> '123456789' Inexact Rounded subx528 subtract '123456789' 0.5 -> '123456788' Inexact Rounded subx529 subtract '123456789' 0.500000001 -> '123456788' Inexact Rounded subx530 subtract '123456789' 0.500001 -> '123456788' Inexact Rounded subx531 subtract '123456789' 0.51 -> '123456788' Inexact Rounded subx532 subtract '123456789' 0.6 -> '123456788' Inexact Rounded subx533 subtract '123456789' 0.9 -> '123456788' Inexact Rounded subx534 subtract '123456789' 0.99999 -> '123456788' Inexact Rounded subx535 subtract '123456789' 0.999999999 -> '123456788' Inexact Rounded subx536 subtract '123456789' 1 -> '123456788' subx537 subtract '123456789' 1.00000001 -> '123456788' Inexact Rounded subx538 subtract '123456789' 1.00001 -> '123456788' Inexact Rounded subx539 subtract '123456789' 1.1 -> '123456788' Inexact Rounded -- critical few with even bottom digit... subx540 subtract '123456788' 0.499999999 -> '123456788' Inexact Rounded subx541 subtract '123456788' 0.5 -> '123456788' Inexact Rounded subx542 subtract '123456788' 0.500000001 -> '123456787' Inexact Rounded rounding: down subx550 subtract '123456789' 0 -> '123456789' subx551 subtract '123456789' 0.000000001 -> '123456788' Inexact Rounded subx552 subtract '123456789' 0.000001 -> '123456788' Inexact Rounded subx553 subtract '123456789' 0.1 -> '123456788' Inexact Rounded subx554 subtract '123456789' 0.4 -> '123456788' Inexact Rounded subx555 subtract '123456789' 0.49 -> '123456788' Inexact Rounded subx556 subtract '123456789' 0.499999 -> '123456788' Inexact Rounded subx557 subtract '123456789' 0.499999999 -> '123456788' Inexact Rounded subx558 subtract '123456789' 0.5 -> '123456788' Inexact Rounded subx559 subtract '123456789' 0.500000001 -> '123456788' Inexact Rounded subx560 subtract '123456789' 0.500001 -> '123456788' Inexact Rounded subx561 subtract '123456789' 0.51 -> '123456788' Inexact Rounded subx562 subtract '123456789' 0.6 -> '123456788' Inexact Rounded subx563 subtract '123456789' 0.9 -> '123456788' Inexact Rounded subx564 subtract '123456789' 0.99999 -> '123456788' Inexact Rounded subx565 subtract '123456789' 0.999999999 -> '123456788' Inexact Rounded subx566 subtract '123456789' 1 -> '123456788' subx567 subtract '123456789' 1.00000001 -> '123456787' Inexact Rounded subx568 subtract '123456789' 1.00001 -> '123456787' Inexact Rounded subx569 subtract '123456789' 1.1 -> '123456787' Inexact Rounded -- symmetry... rounding: half_up subx600 subtract 0 '123456789' -> '-123456789' subx601 subtract 0.000000001 '123456789' -> '-123456789' Inexact Rounded subx602 subtract 0.000001 '123456789' -> '-123456789' Inexact Rounded subx603 subtract 0.1 '123456789' -> '-123456789' Inexact Rounded subx604 subtract 0.4 '123456789' -> '-123456789' Inexact Rounded subx605 subtract 0.49 '123456789' -> '-123456789' Inexact Rounded subx606 subtract 0.499999 '123456789' -> '-123456789' Inexact Rounded subx607 subtract 0.499999999 '123456789' -> '-123456789' Inexact Rounded subx608 subtract 0.5 '123456789' -> '-123456789' Inexact Rounded subx609 subtract 0.500000001 '123456789' -> '-123456788' Inexact Rounded subx610 subtract 0.500001 '123456789' -> '-123456788' Inexact Rounded subx611 subtract 0.51 '123456789' -> '-123456788' Inexact Rounded subx612 subtract 0.6 '123456789' -> '-123456788' Inexact Rounded subx613 subtract 0.9 '123456789' -> '-123456788' Inexact Rounded subx614 subtract 0.99999 '123456789' -> '-123456788' Inexact Rounded subx615 subtract 0.999999999 '123456789' -> '-123456788' Inexact Rounded subx616 subtract 1 '123456789' -> '-123456788' subx617 subtract 1.000000001 '123456789' -> '-123456788' Inexact Rounded subx618 subtract 1.00001 '123456789' -> '-123456788' Inexact Rounded subx619 subtract 1.1 '123456789' -> '-123456788' Inexact Rounded rounding: half_even subx620 subtract 0 '123456789' -> '-123456789' subx621 subtract 0.000000001 '123456789' -> '-123456789' Inexact Rounded subx622 subtract 0.000001 '123456789' -> '-123456789' Inexact Rounded subx623 subtract 0.1 '123456789' -> '-123456789' Inexact Rounded subx624 subtract 0.4 '123456789' -> '-123456789' Inexact Rounded subx625 subtract 0.49 '123456789' -> '-123456789' Inexact Rounded subx626 subtract 0.499999 '123456789' -> '-123456789' Inexact Rounded subx627 subtract 0.499999999 '123456789' -> '-123456789' Inexact Rounded subx628 subtract 0.5 '123456789' -> '-123456788' Inexact Rounded subx629 subtract 0.500000001 '123456789' -> '-123456788' Inexact Rounded subx630 subtract 0.500001 '123456789' -> '-123456788' Inexact Rounded subx631 subtract 0.51 '123456789' -> '-123456788' Inexact Rounded subx632 subtract 0.6 '123456789' -> '-123456788' Inexact Rounded subx633 subtract 0.9 '123456789' -> '-123456788' Inexact Rounded subx634 subtract 0.99999 '123456789' -> '-123456788' Inexact Rounded subx635 subtract 0.999999999 '123456789' -> '-123456788' Inexact Rounded subx636 subtract 1 '123456789' -> '-123456788' subx637 subtract 1.00000001 '123456789' -> '-123456788' Inexact Rounded subx638 subtract 1.00001 '123456789' -> '-123456788' Inexact Rounded subx639 subtract 1.1 '123456789' -> '-123456788' Inexact Rounded -- critical few with even bottom digit... subx640 subtract 0.499999999 '123456788' -> '-123456788' Inexact Rounded subx641 subtract 0.5 '123456788' -> '-123456788' Inexact Rounded subx642 subtract 0.500000001 '123456788' -> '-123456787' Inexact Rounded rounding: down subx650 subtract 0 '123456789' -> '-123456789' subx651 subtract 0.000000001 '123456789' -> '-123456788' Inexact Rounded subx652 subtract 0.000001 '123456789' -> '-123456788' Inexact Rounded subx653 subtract 0.1 '123456789' -> '-123456788' Inexact Rounded subx654 subtract 0.4 '123456789' -> '-123456788' Inexact Rounded subx655 subtract 0.49 '123456789' -> '-123456788' Inexact Rounded subx656 subtract 0.499999 '123456789' -> '-123456788' Inexact Rounded subx657 subtract 0.499999999 '123456789' -> '-123456788' Inexact Rounded subx658 subtract 0.5 '123456789' -> '-123456788' Inexact Rounded subx659 subtract 0.500000001 '123456789' -> '-123456788' Inexact Rounded subx660 subtract 0.500001 '123456789' -> '-123456788' Inexact Rounded subx661 subtract 0.51 '123456789' -> '-123456788' Inexact Rounded subx662 subtract 0.6 '123456789' -> '-123456788' Inexact Rounded subx663 subtract 0.9 '123456789' -> '-123456788' Inexact Rounded subx664 subtract 0.99999 '123456789' -> '-123456788' Inexact Rounded subx665 subtract 0.999999999 '123456789' -> '-123456788' Inexact Rounded subx666 subtract 1 '123456789' -> '-123456788' subx667 subtract 1.00000001 '123456789' -> '-123456787' Inexact Rounded subx668 subtract 1.00001 '123456789' -> '-123456787' Inexact Rounded subx669 subtract 1.1 '123456789' -> '-123456787' Inexact Rounded -- lots of leading zeros in intermediate result, and showing effects of -- input rounding would have affected the following precision: 9 rounding: half_up subx670 subtract '123456789' '123456788.1' -> 0.9 subx671 subtract '123456789' '123456788.9' -> 0.1 subx672 subtract '123456789' '123456789.1' -> -0.1 subx673 subtract '123456789' '123456789.5' -> -0.5 subx674 subtract '123456789' '123456789.9' -> -0.9 rounding: half_even subx680 subtract '123456789' '123456788.1' -> 0.9 subx681 subtract '123456789' '123456788.9' -> 0.1 subx682 subtract '123456789' '123456789.1' -> -0.1 subx683 subtract '123456789' '123456789.5' -> -0.5 subx684 subtract '123456789' '123456789.9' -> -0.9 subx685 subtract '123456788' '123456787.1' -> 0.9 subx686 subtract '123456788' '123456787.9' -> 0.1 subx687 subtract '123456788' '123456788.1' -> -0.1 subx688 subtract '123456788' '123456788.5' -> -0.5 subx689 subtract '123456788' '123456788.9' -> -0.9 rounding: down subx690 subtract '123456789' '123456788.1' -> 0.9 subx691 subtract '123456789' '123456788.9' -> 0.1 subx692 subtract '123456789' '123456789.1' -> -0.1 subx693 subtract '123456789' '123456789.5' -> -0.5 subx694 subtract '123456789' '123456789.9' -> -0.9 -- input preparation tests rounding: half_up precision: 3 subx700 subtract '12345678900000' -9999999999999 -> '2.23E+13' Inexact Rounded subx701 subtract '9999999999999' -12345678900000 -> '2.23E+13' Inexact Rounded subx702 subtract '12E+3' '-3456' -> '1.55E+4' Inexact Rounded subx703 subtract '12E+3' '-3446' -> '1.54E+4' Inexact Rounded subx704 subtract '12E+3' '-3454' -> '1.55E+4' Inexact Rounded subx705 subtract '12E+3' '-3444' -> '1.54E+4' Inexact Rounded subx706 subtract '3456' '-12E+3' -> '1.55E+4' Inexact Rounded subx707 subtract '3446' '-12E+3' -> '1.54E+4' Inexact Rounded subx708 subtract '3454' '-12E+3' -> '1.55E+4' Inexact Rounded subx709 subtract '3444' '-12E+3' -> '1.54E+4' Inexact Rounded -- overflow and underflow tests [subnormals now possible] maxexponent: 999999999 minexponent: -999999999 precision: 9 rounding: down subx710 subtract 1E+999999999 -9E+999999999 -> 9.99999999E+999999999 Overflow Inexact Rounded subx711 subtract 9E+999999999 -1E+999999999 -> 9.99999999E+999999999 Overflow Inexact Rounded rounding: half_up subx712 subtract 1E+999999999 -9E+999999999 -> Infinity Overflow Inexact Rounded subx713 subtract 9E+999999999 -1E+999999999 -> Infinity Overflow Inexact Rounded subx714 subtract -1.1E-999999999 -1E-999999999 -> -1E-1000000000 Subnormal subx715 subtract 1E-999999999 +1.1e-999999999 -> -1E-1000000000 Subnormal subx716 subtract -1E+999999999 +9E+999999999 -> -Infinity Overflow Inexact Rounded subx717 subtract -9E+999999999 +1E+999999999 -> -Infinity Overflow Inexact Rounded subx718 subtract +1.1E-999999999 +1E-999999999 -> 1E-1000000000 Subnormal subx719 subtract -1E-999999999 -1.1e-999999999 -> 1E-1000000000 Subnormal precision: 3 subx720 subtract 1 9.999E+999999999 -> -Infinity Inexact Overflow Rounded subx721 subtract 1 -9.999E+999999999 -> Infinity Inexact Overflow Rounded subx722 subtract 9.999E+999999999 1 -> Infinity Inexact Overflow Rounded subx723 subtract -9.999E+999999999 1 -> -Infinity Inexact Overflow Rounded subx724 subtract 1 9.999E+999999999 -> -Infinity Inexact Overflow Rounded subx725 subtract 1 -9.999E+999999999 -> Infinity Inexact Overflow Rounded subx726 subtract 9.999E+999999999 1 -> Infinity Inexact Overflow Rounded subx727 subtract -9.999E+999999999 1 -> -Infinity Inexact Overflow Rounded -- [more below] -- long operand checks maxexponent: 999 minexponent: -999 precision: 9 sub731 subtract 12345678000 0 -> 1.23456780E+10 Rounded sub732 subtract 0 12345678000 -> -1.23456780E+10 Rounded sub733 subtract 1234567800 0 -> 1.23456780E+9 Rounded sub734 subtract 0 1234567800 -> -1.23456780E+9 Rounded sub735 subtract 1234567890 0 -> 1.23456789E+9 Rounded sub736 subtract 0 1234567890 -> -1.23456789E+9 Rounded sub737 subtract 1234567891 0 -> 1.23456789E+9 Inexact Rounded sub738 subtract 0 1234567891 -> -1.23456789E+9 Inexact Rounded sub739 subtract 12345678901 0 -> 1.23456789E+10 Inexact Rounded sub740 subtract 0 12345678901 -> -1.23456789E+10 Inexact Rounded sub741 subtract 1234567896 0 -> 1.23456790E+9 Inexact Rounded sub742 subtract 0 1234567896 -> -1.23456790E+9 Inexact Rounded precision: 15 sub751 subtract 12345678000 0 -> 12345678000 sub752 subtract 0 12345678000 -> -12345678000 sub753 subtract 1234567800 0 -> 1234567800 sub754 subtract 0 1234567800 -> -1234567800 sub755 subtract 1234567890 0 -> 1234567890 sub756 subtract 0 1234567890 -> -1234567890 sub757 subtract 1234567891 0 -> 1234567891 sub758 subtract 0 1234567891 -> -1234567891 sub759 subtract 12345678901 0 -> 12345678901 sub760 subtract 0 12345678901 -> -12345678901 sub761 subtract 1234567896 0 -> 1234567896 sub762 subtract 0 1234567896 -> -1234567896 -- Specials subx780 subtract -Inf Inf -> -Infinity subx781 subtract -Inf 1000 -> -Infinity subx782 subtract -Inf 1 -> -Infinity subx783 subtract -Inf -0 -> -Infinity subx784 subtract -Inf -1 -> -Infinity subx785 subtract -Inf -1000 -> -Infinity subx787 subtract -1000 Inf -> -Infinity subx788 subtract -Inf Inf -> -Infinity subx789 subtract -1 Inf -> -Infinity subx790 subtract 0 Inf -> -Infinity subx791 subtract 1 Inf -> -Infinity subx792 subtract 1000 Inf -> -Infinity subx800 subtract Inf Inf -> NaN Invalid_operation subx801 subtract Inf 1000 -> Infinity subx802 subtract Inf 1 -> Infinity subx803 subtract Inf 0 -> Infinity subx804 subtract Inf -0 -> Infinity subx805 subtract Inf -1 -> Infinity subx806 subtract Inf -1000 -> Infinity subx807 subtract Inf -Inf -> Infinity subx808 subtract -1000 -Inf -> Infinity subx809 subtract -Inf -Inf -> NaN Invalid_operation subx810 subtract -1 -Inf -> Infinity subx811 subtract -0 -Inf -> Infinity subx812 subtract 0 -Inf -> Infinity subx813 subtract 1 -Inf -> Infinity subx814 subtract 1000 -Inf -> Infinity subx815 subtract Inf -Inf -> Infinity subx821 subtract NaN Inf -> NaN subx822 subtract -NaN 1000 -> -NaN subx823 subtract NaN 1 -> NaN subx824 subtract NaN 0 -> NaN subx825 subtract NaN -0 -> NaN subx826 subtract NaN -1 -> NaN subx827 subtract NaN -1000 -> NaN subx828 subtract NaN -Inf -> NaN subx829 subtract -NaN NaN -> -NaN subx830 subtract -Inf NaN -> NaN subx831 subtract -1000 NaN -> NaN subx832 subtract -1 NaN -> NaN subx833 subtract -0 NaN -> NaN subx834 subtract 0 NaN -> NaN subx835 subtract 1 NaN -> NaN subx836 subtract 1000 -NaN -> -NaN subx837 subtract Inf NaN -> NaN subx841 subtract sNaN Inf -> NaN Invalid_operation subx842 subtract -sNaN 1000 -> -NaN Invalid_operation subx843 subtract sNaN 1 -> NaN Invalid_operation subx844 subtract sNaN 0 -> NaN Invalid_operation subx845 subtract sNaN -0 -> NaN Invalid_operation subx846 subtract sNaN -1 -> NaN Invalid_operation subx847 subtract sNaN -1000 -> NaN Invalid_operation subx848 subtract sNaN NaN -> NaN Invalid_operation subx849 subtract sNaN sNaN -> NaN Invalid_operation subx850 subtract NaN sNaN -> NaN Invalid_operation subx851 subtract -Inf -sNaN -> -NaN Invalid_operation subx852 subtract -1000 sNaN -> NaN Invalid_operation subx853 subtract -1 sNaN -> NaN Invalid_operation subx854 subtract -0 sNaN -> NaN Invalid_operation subx855 subtract 0 sNaN -> NaN Invalid_operation subx856 subtract 1 sNaN -> NaN Invalid_operation subx857 subtract 1000 sNaN -> NaN Invalid_operation subx858 subtract Inf sNaN -> NaN Invalid_operation subx859 subtract NaN sNaN -> NaN Invalid_operation -- propagating NaNs subx861 subtract NaN01 -Inf -> NaN1 subx862 subtract -NaN02 -1000 -> -NaN2 subx863 subtract NaN03 1000 -> NaN3 subx864 subtract NaN04 Inf -> NaN4 subx865 subtract NaN05 NaN61 -> NaN5 subx866 subtract -Inf -NaN71 -> -NaN71 subx867 subtract -1000 NaN81 -> NaN81 subx868 subtract 1000 NaN91 -> NaN91 subx869 subtract Inf NaN101 -> NaN101 subx871 subtract sNaN011 -Inf -> NaN11 Invalid_operation subx872 subtract sNaN012 -1000 -> NaN12 Invalid_operation subx873 subtract -sNaN013 1000 -> -NaN13 Invalid_operation subx874 subtract sNaN014 NaN171 -> NaN14 Invalid_operation subx875 subtract sNaN015 sNaN181 -> NaN15 Invalid_operation subx876 subtract NaN016 sNaN191 -> NaN191 Invalid_operation subx877 subtract -Inf sNaN201 -> NaN201 Invalid_operation subx878 subtract -1000 sNaN211 -> NaN211 Invalid_operation subx879 subtract 1000 -sNaN221 -> -NaN221 Invalid_operation subx880 subtract Inf sNaN231 -> NaN231 Invalid_operation subx881 subtract NaN025 sNaN241 -> NaN241 Invalid_operation -- edge case spills subx901 subtract 2.E-3 1.002 -> -1.000 subx902 subtract 2.0E-3 1.002 -> -1.0000 subx903 subtract 2.00E-3 1.0020 -> -1.00000 subx904 subtract 2.000E-3 1.00200 -> -1.000000 subx905 subtract 2.0000E-3 1.002000 -> -1.0000000 subx906 subtract 2.00000E-3 1.0020000 -> -1.00000000 subx907 subtract 2.000000E-3 1.00200000 -> -1.000000000 subx908 subtract 2.0000000E-3 1.002000000 -> -1.0000000000 -- subnormals and underflows precision: 3 maxexponent: 999 minexponent: -999 subx1010 subtract 0 1.00E-999 -> -1.00E-999 subx1011 subtract 0 0.1E-999 -> -1E-1000 Subnormal subx1012 subtract 0 0.10E-999 -> -1.0E-1000 Subnormal subx1013 subtract 0 0.100E-999 -> -1.0E-1000 Subnormal Rounded subx1014 subtract 0 0.01E-999 -> -1E-1001 Subnormal -- next is rounded to Emin subx1015 subtract 0 0.999E-999 -> -1.00E-999 Inexact Rounded Subnormal Underflow subx1016 subtract 0 0.099E-999 -> -1.0E-1000 Inexact Rounded Subnormal Underflow subx1017 subtract 0 0.009E-999 -> -1E-1001 Inexact Rounded Subnormal Underflow subx1018 subtract 0 0.001E-999 -> -0E-1001 Inexact Rounded Subnormal Underflow subx1019 subtract 0 0.0009E-999 -> -0E-1001 Inexact Rounded Subnormal Underflow subx1020 subtract 0 0.0001E-999 -> -0E-1001 Inexact Rounded Subnormal Underflow subx1030 subtract 0 -1.00E-999 -> 1.00E-999 subx1031 subtract 0 -0.1E-999 -> 1E-1000 Subnormal subx1032 subtract 0 -0.10E-999 -> 1.0E-1000 Subnormal subx1033 subtract 0 -0.100E-999 -> 1.0E-1000 Subnormal Rounded subx1034 subtract 0 -0.01E-999 -> 1E-1001 Subnormal -- next is rounded to Emin subx1035 subtract 0 -0.999E-999 -> 1.00E-999 Inexact Rounded Subnormal Underflow subx1036 subtract 0 -0.099E-999 -> 1.0E-1000 Inexact Rounded Subnormal Underflow subx1037 subtract 0 -0.009E-999 -> 1E-1001 Inexact Rounded Subnormal Underflow subx1038 subtract 0 -0.001E-999 -> 0E-1001 Inexact Rounded Subnormal Underflow subx1039 subtract 0 -0.0009E-999 -> 0E-1001 Inexact Rounded Subnormal Underflow subx1040 subtract 0 -0.0001E-999 -> 0E-1001 Inexact Rounded Subnormal Underflow -- some non-zero subnormal subtracts -- subx1056 is a tricky case rounding: half_up subx1050 subtract 1.00E-999 0.1E-999 -> 9.0E-1000 Subnormal subx1051 subtract 0.1E-999 0.1E-999 -> 0E-1000 subx1052 subtract 0.10E-999 0.1E-999 -> 0E-1001 subx1053 subtract 0.100E-999 0.1E-999 -> 0E-1001 Clamped subx1054 subtract 0.01E-999 0.1E-999 -> -9E-1001 Subnormal subx1055 subtract 0.999E-999 0.1E-999 -> 9.0E-1000 Inexact Rounded Subnormal Underflow subx1056 subtract 0.099E-999 0.1E-999 -> -0E-1001 Inexact Rounded Subnormal Underflow subx1057 subtract 0.009E-999 0.1E-999 -> -9E-1001 Inexact Rounded Subnormal Underflow subx1058 subtract 0.001E-999 0.1E-999 -> -1.0E-1000 Inexact Rounded Subnormal Underflow subx1059 subtract 0.0009E-999 0.1E-999 -> -1.0E-1000 Inexact Rounded Subnormal Underflow subx1060 subtract 0.0001E-999 0.1E-999 -> -1.0E-1000 Inexact Rounded Subnormal Underflow -- check for double-rounded subnormals precision: 5 maxexponent: 79 minexponent: -79 subx1101 subtract 0 1.52444E-80 -> -1.524E-80 Inexact Rounded Subnormal Underflow subx1102 subtract 0 1.52445E-80 -> -1.524E-80 Inexact Rounded Subnormal Underflow subx1103 subtract 0 1.52446E-80 -> -1.524E-80 Inexact Rounded Subnormal Underflow subx1104 subtract 1.52444E-80 0 -> 1.524E-80 Inexact Rounded Subnormal Underflow subx1105 subtract 1.52445E-80 0 -> 1.524E-80 Inexact Rounded Subnormal Underflow subx1106 subtract 1.52446E-80 0 -> 1.524E-80 Inexact Rounded Subnormal Underflow subx1111 subtract 1.2345678E-80 1.2345671E-80 -> 0E-83 Inexact Rounded Subnormal Underflow subx1112 subtract 1.2345678E-80 1.2345618E-80 -> 0E-83 Inexact Rounded Subnormal Underflow subx1113 subtract 1.2345678E-80 1.2345178E-80 -> 0E-83 Inexact Rounded Subnormal Underflow subx1114 subtract 1.2345678E-80 1.2341678E-80 -> 0E-83 Inexact Rounded Subnormal Underflow subx1115 subtract 1.2345678E-80 1.2315678E-80 -> 3E-83 Rounded Subnormal subx1116 subtract 1.2345678E-80 1.2145678E-80 -> 2.0E-82 Rounded Subnormal subx1117 subtract 1.2345678E-80 1.1345678E-80 -> 1.00E-81 Rounded Subnormal subx1118 subtract 1.2345678E-80 0.2345678E-80 -> 1.000E-80 Rounded Subnormal -- Null tests subx9990 subtract 10 # -> NaN Invalid_operation subx9991 subtract # 10 -> NaN Invalid_operation --- NEW FILE: testall.decTest --- ------------------------------------------------------------------------ -- testall.decTest -- run all general decimal arithmetic testcases -- -- Copyright (c) IBM Corporation, 1981, 2003. All rights reserved. -- ------------------------------------------------------------------------ -- Please see the document "General Decimal Arithmetic Testcases" -- -- at http://www2.hursley.ibm.com/decimal for the description of -- -- these testcases. -- -- -- -- These testcases are experimental ('beta' versions), and they -- -- may contain errors. They are offered on an as-is basis. In -- -- particular, achieving the same results as the tests here is not -- -- a guarantee that an implementation complies with any Standard -- -- or specification. The tests are not exhaustive. -- -- -- -- Please send comments, suggestions, and corrections to the author: -- -- Mike Cowlishaw, IBM Fellow -- -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ version: 2.35 -- core tests (using Extended: 1) -------------------------------------- dectest: base dectest: abs dectest: add dectest: clamp dectest: compare dectest: divide dectest: divideint dectest: inexact dectest: max dectest: min dectest: minus dectest: multiply dectest: normalize dectest: plus dectest: power dectest: quantize dectest: randoms dectest: remainder dectest: remaindernear dectest: rescale -- [obsolete] dectest: rounding dectest: samequantum dectest: squareroot dectest: subtract dectest: tointegral dectest: trim -- The next are for the Strawman 4d concrete representations dectest: decimal32 dectest: decimal64 dectest: decimal128 -- General 31->33-digit boundary tests dectest: randomBound32 --- NEW FILE: tointegral.decTest --- ------------------------------------------------------------------------ -- tointegral.decTest -- round decimal to integral value -- -- Copyright (c) IBM Corporation, 2001, 2003. All rights reserved. -- ------------------------------------------------------------------------ -- Please see the document "General Decimal Arithmetic Testcases" -- -- at http://www2.hursley.ibm.com/decimal for the description of -- -- these testcases. -- -- -- -- These testcases are experimental ('beta' versions), and they -- -- may contain errors. They are offered on an as-is basis. In -- -- particular, achieving the same results as the tests here is not -- -- a guarantee that an implementation complies with any Standard -- -- or specification. The tests are not exhaustive. -- -- -- -- Please send comments, suggestions, and corrections to the author: -- -- Mike Cowlishaw, IBM Fellow -- -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ version: 2.38 -- This set of tests tests the extended specification 'round-to-integral -- value' operation (from IEEE 854, later modified in 754r). -- All non-zero results are defined as being those from either copy or -- quantize, so those are assumed to have been tested. -- Note that 754r requires that Inexact not be set, and we similarly -- assume Rounded is not set. extended: 1 precision: 9 rounding: half_up maxExponent: 999 minExponent: -999 intx001 tointegral 0 -> 0 intx002 tointegral 0.0 -> 0 intx003 tointegral 0.1 -> 0 intx004 tointegral 0.2 -> 0 intx005 tointegral 0.3 -> 0 intx006 tointegral 0.4 -> 0 intx007 tointegral 0.5 -> 1 intx008 tointegral 0.6 -> 1 intx009 tointegral 0.7 -> 1 intx010 tointegral 0.8 -> 1 intx011 tointegral 0.9 -> 1 intx012 tointegral 1 -> 1 intx013 tointegral 1.0 -> 1 intx014 tointegral 1.1 -> 1 intx015 tointegral 1.2 -> 1 intx016 tointegral 1.3 -> 1 intx017 tointegral 1.4 -> 1 intx018 tointegral 1.5 -> 2 intx019 tointegral 1.6 -> 2 intx020 tointegral 1.7 -> 2 intx021 tointegral 1.8 -> 2 intx022 tointegral 1.9 -> 2 -- negatives intx031 tointegral -0 -> -0 intx032 tointegral -0.0 -> -0 intx033 tointegral -0.1 -> -0 intx034 tointegral -0.2 -> -0 intx035 tointegral -0.3 -> -0 intx036 tointegral -0.4 -> -0 intx037 tointegral -0.5 -> -1 intx038 tointegral -0.6 -> -1 intx039 tointegral -0.7 -> -1 intx040 tointegral -0.8 -> -1 intx041 tointegral -0.9 -> -1 intx042 tointegral -1 -> -1 intx043 tointegral -1.0 -> -1 intx044 tointegral -1.1 -> -1 intx045 tointegral -1.2 -> -1 intx046 tointegral -1.3 -> -1 intx047 tointegral -1.4 -> -1 intx048 tointegral -1.5 -> -2 intx049 tointegral -1.6 -> -2 intx050 tointegral -1.7 -> -2 intx051 tointegral -1.8 -> -2 intx052 tointegral -1.9 -> -2 -- next two would be NaN using quantize(x, 0) intx053 tointegral 10E+30 -> 1.0E+31 intx054 tointegral -10E+30 -> -1.0E+31 -- numbers around precision precision: 9 intx060 tointegral '56267E-10' -> '0' intx061 tointegral '56267E-5' -> '1' intx062 tointegral '56267E-2' -> '563' intx063 tointegral '56267E-1' -> '5627' intx065 tointegral '56267E-0' -> '56267' intx066 tointegral '56267E+0' -> '56267' intx067 tointegral '56267E+1' -> '5.6267E+5' intx068 tointegral '56267E+2' -> '5.6267E+6' intx069 tointegral '56267E+3' -> '5.6267E+7' intx070 tointegral '56267E+4' -> '5.6267E+8' intx071 tointegral '56267E+5' -> '5.6267E+9' intx072 tointegral '56267E+6' -> '5.6267E+10' intx073 tointegral '1.23E+96' -> '1.23E+96' intx074 tointegral '1.23E+384' -> '1.23E+384' intx075 tointegral '1.23E+999' -> '1.23E+999' intx080 tointegral '-56267E-10' -> '-0' intx081 tointegral '-56267E-5' -> '-1' intx082 tointegral '-56267E-2' -> '-563' intx083 tointegral '-56267E-1' -> '-5627' intx085 tointegral '-56267E-0' -> '-56267' intx086 tointegral '-56267E+0' -> '-56267' intx087 tointegral '-56267E+1' -> '-5.6267E+5' intx088 tointegral '-56267E+2' -> '-5.6267E+6' intx089 tointegral '-56267E+3' -> '-5.6267E+7' intx090 tointegral '-56267E+4' -> '-5.6267E+8' intx091 tointegral '-56267E+5' -> '-5.6267E+9' intx092 tointegral '-56267E+6' -> '-5.6267E+10' intx093 tointegral '-1.23E+96' -> '-1.23E+96' intx094 tointegral '-1.23E+384' -> '-1.23E+384' intx095 tointegral '-1.23E+999' -> '-1.23E+999' -- subnormal inputs intx100 tointegral 1E-999 -> 0 intx101 tointegral 0.1E-999 -> 0 intx102 tointegral 0.01E-999 -> 0 intx103 tointegral 0E-999 -> 0 -- specials and zeros intx120 tointegral 'Inf' -> Infinity intx121 tointegral '-Inf' -> -Infinity intx122 tointegral NaN -> NaN intx123 tointegral sNaN -> NaN Invalid_operation intx124 tointegral 0 -> 0 intx125 tointegral -0 -> -0 intx126 tointegral 0.000 -> 0 intx127 tointegral 0.00 -> 0 intx128 tointegral 0.0 -> 0 intx129 tointegral 0 -> 0 intx130 tointegral 0E-3 -> 0 intx131 tointegral 0E-2 -> 0 intx132 tointegral 0E-1 -> 0 intx133 tointegral 0E-0 -> 0 intx134 tointegral 0E+1 -> 0E+1 intx135 tointegral 0E+2 -> 0E+2 intx136 tointegral 0E+3 -> 0E+3 intx137 tointegral 0E+4 -> 0E+4 intx138 tointegral 0E+5 -> 0E+5 intx139 tointegral -0.000 -> -0 intx140 tointegral -0.00 -> -0 intx141 tointegral -0.0 -> -0 intx142 tointegral -0 -> -0 intx143 tointegral -0E-3 -> -0 intx144 tointegral -0E-2 -> -0 intx145 tointegral -0E-1 -> -0 intx146 tointegral -0E-0 -> -0 intx147 tointegral -0E+1 -> -0E+1 intx148 tointegral -0E+2 -> -0E+2 intx149 tointegral -0E+3 -> -0E+3 intx150 tointegral -0E+4 -> -0E+4 intx151 tointegral -0E+5 -> -0E+5 -- propagating NaNs intx152 tointegral NaN808 -> NaN808 intx153 tointegral sNaN080 -> NaN80 Invalid_operation intx154 tointegral -NaN808 -> -NaN808 intx155 tointegral -sNaN080 -> -NaN80 Invalid_operation intx156 tointegral -NaN -> -NaN intx157 tointegral -sNaN -> -NaN Invalid_operation -- examples rounding: half_up precision: 9 intx200 tointegral 2.1 -> 2 intx201 tointegral 100 -> 100 intx202 tointegral 100.0 -> 100 intx203 tointegral 101.5 -> 102 intx204 tointegral -101.5 -> -102 intx205 tointegral 10E+5 -> 1.0E+6 intx206 tointegral 7.89E+77 -> 7.89E+77 intx207 tointegral -Inf -> -Infinity --- NEW FILE: trim.decTest --- ------------------------------------------------------------------------ -- trim.decTest -- remove insignificant trailing zeros -- -- Copyright (c) IBM Corporation, 2003. All rights reserved. -- ------------------------------------------------------------------------ -- Please see the document "General Decimal Arithmetic Testcases" -- -- at http://www2.hursley.ibm.com/decimal for the description of -- -- these testcases. -- -- -- -- These testcases are experimental ('beta' versions), and they -- -- may contain errors. They are offered on an as-is basis. In -- -- particular, achieving the same results as the tests here is not -- -- a guarantee that an implementation complies with any Standard -- -- or specification. The tests are not exhaustive. -- -- -- -- Please send comments, suggestions, and corrections to the author: -- -- Mike Cowlishaw, IBM Fellow -- -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ version: 2.35 extended: 1 precision: 9 rounding: half_up maxExponent: 999 minexponent: -999 trmx001 trim '1' -> '1' trmx002 trim '-1' -> '-1' trmx003 trim '1.00' -> '1' trmx004 trim '-1.00' -> '-1' trmx005 trim '0' -> '0' trmx006 trim '0.00' -> '0' trmx007 trim '00.0' -> '0' trmx008 trim '00.00' -> '0' trmx009 trim '00' -> '0' trmx010 trim '-2' -> '-2' trmx011 trim '2' -> '2' trmx012 trim '-2.00' -> '-2' trmx013 trim '2.00' -> '2' trmx014 trim '-0' -> '-0' trmx015 trim '-0.00' -> '-0' trmx016 trim '-00.0' -> '-0' trmx017 trim '-00.00' -> '-0' trmx018 trim '-00' -> '-0' trmx019 trim '0E+5' -> '0' trmx020 trim '-0E+1' -> '-0' trmx030 trim '+0.1' -> '0.1' trmx031 trim '-0.1' -> '-0.1' trmx032 trim '+0.01' -> '0.01' trmx033 trim '-0.01' -> '-0.01' trmx034 trim '+0.001' -> '0.001' trmx035 trim '-0.001' -> '-0.001' trmx036 trim '+0.000001' -> '0.000001' trmx037 trim '-0.000001' -> '-0.000001' trmx038 trim '+0.000000000001' -> '1E-12' trmx039 trim '-0.000000000001' -> '-1E-12' trmx041 trim 1.1 -> 1.1 trmx042 trim 1.10 -> 1.1 trmx043 trim 1.100 -> 1.1 trmx044 trim 1.110 -> 1.11 trmx045 trim -1.1 -> -1.1 trmx046 trim -1.10 -> -1.1 trmx047 trim -1.100 -> -1.1 trmx048 trim -1.110 -> -1.11 trmx049 trim 9.9 -> 9.9 trmx050 trim 9.90 -> 9.9 trmx051 trim 9.900 -> 9.9 trmx052 trim 9.990 -> 9.99 trmx053 trim -9.9 -> -9.9 trmx054 trim -9.90 -> -9.9 trmx055 trim -9.900 -> -9.9 trmx056 trim -9.990 -> -9.99 -- some insignificant trailing fractional zeros trmx060 trim 10.0 -> 10 trmx061 trim 10.00 -> 10 trmx062 trim 100.0 -> 100 trmx063 trim 100.00 -> 100 trmx064 trim 1.1000E+3 -> 1100 trmx065 trim 1.10000E+3 -> 1100 trmx066 trim -10.0 -> -10 trmx067 trim -10.00 -> -10 trmx068 trim -100.0 -> -100 trmx069 trim -100.00 -> -100 trmx070 trim -1.1000E+3 -> -1100 trmx071 trim -1.10000E+3 -> -1100 -- some insignificant trailing zeros with positive exponent trmx080 trim 10E+1 -> 1E+2 trmx081 trim 100E+1 -> 1E+3 trmx082 trim 1.0E+2 -> 1E+2 trmx083 trim 1.0E+3 -> 1E+3 trmx084 trim 1.1E+3 -> 1.1E+3 trmx085 trim 1.00E+3 -> 1E+3 trmx086 trim 1.10E+3 -> 1.1E+3 trmx087 trim -10E+1 -> -1E+2 trmx088 trim -100E+1 -> -1E+3 trmx089 trim -1.0E+2 -> -1E+2 trmx090 trim -1.0E+3 -> -1E+3 trmx091 trim -1.1E+3 -> -1.1E+3 trmx092 trim -1.00E+3 -> -1E+3 trmx093 trim -1.10E+3 -> -1.1E+3 -- some significant trailing zeros trmx100 trim 11 -> 11 trmx101 trim 10 -> 10 trmx102 trim 10. -> 10 trmx103 trim 1.1E+1 -> 11 trmx104 trim 1.0E+1 -> 10 trmx105 trim 1.10E+2 -> 110 trmx106 trim 1.00E+2 -> 100 trmx107 trim 1.100E+3 -> 1100 trmx108 trim 1.000E+3 -> 1000 trmx109 trim 1.000000E+6 -> 1000000 trmx110 trim -11 -> -11 trmx111 trim -10 -> -10 trmx112 trim -10. -> -10 trmx113 trim -1.1E+1 -> -11 trmx114 trim -1.0E+1 -> -10 trmx115 trim -1.10E+2 -> -110 trmx116 trim -1.00E+2 -> -100 trmx117 trim -1.100E+3 -> -1100 trmx118 trim -1.000E+3 -> -1000 trmx119 trim -1.00000E+5 -> -100000 trmx120 trim -1.000000E+6 -> -1000000 -- examples from decArith trmx140 trim '2.1' -> '2.1' trmx141 trim '-2.0' -> '-2' trmx142 trim '1.200' -> '1.2' trmx143 trim '-120' -> '-120' trmx144 trim '120.00' -> '120' trmx145 trim '0.00' -> '0' -- utilities pass through specials without raising exceptions trmx320 trim 'Inf' -> 'Infinity' trmx321 trim '-Inf' -> '-Infinity' trmx322 trim NaN -> NaN trmx323 trim sNaN -> sNaN trmx324 trim NaN999 -> NaN999 trmx325 trim sNaN777 -> sNaN777 trmx326 trim -NaN -> -NaN trmx327 trim -sNaN -> -sNaN trmx328 trim -NaN999 -> -NaN999 trmx329 trim -sNaN777 -> -sNaN777 -- Null test trmx900 trim # -> NaN Invalid_operation From rhettinger at users.sourceforge.net Thu Jul 1 07:02:04 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Thu Jul 1 07:02:06 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1016,1.1017 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26988/Misc Modified Files: NEWS Log Message: Move Decimal from the sandbox into production. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1016 retrieving revision 1.1017 diff -C2 -d -r1.1016 -r1.1017 *** NEWS 30 Jun 2004 09:09:38 -0000 1.1016 --- NEWS 1 Jul 2004 11:01:27 -0000 1.1017 *************** *** 351,354 **** --- 351,356 ---- ------- + - Added Decimal.py per PEP 327. + - Bug #981299: rsync is now a recognized protocol in urlparse that uses a "netloc" portion of a URL. From rhettinger at users.sourceforge.net Thu Jul 1 07:02:05 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Thu Jul 1 07:02:10 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_decimal.py, NONE, 1.1 regrtest.py, 1.153, 1.154 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26988/Lib/test Modified Files: regrtest.py Added Files: test_decimal.py Log Message: Move Decimal from the sandbox into production. --- NEW FILE: test_decimal.py --- # Copyright (c) 2004 Python Software Foundation. # All rights reserved. # Written by Eric Price # and Facundo Batista # and Raymond Hettinger # and Aahz (aahz at pobox.com) # and Tim Peters """ These are the test cases for the Decimal module. There are two groups of tests, Arithmetic and Behaviour. The former test the Decimal arithmetic using the tests provided by Mike Cowlishaw. The latter test the pythonic behaviour according to PEP 327. Cowlishaw's tests can be downloaded from: www2.hursley.ibm.com/decimal/dectest.zip [...1043 lines suppressed...] if arith or is_resource_enabled('decimal'): test_classes.extend([DecimalTest]) run_unittest(*test_classes) import decimal as DecimalModule run_doctest(DecimalModule, verbose) return if __name__ == '__main__': # Calling with no arguments runs all tests. # Calling with "Skip" will skipover the arithmetic tests. if len(sys.argv) == 1: test_main(arith=True, verbose=True) elif len(sys.argv) == 2: arith = sys.argv[1].lower() != 'skip' test_main(arith=arith, verbose=True) else: raise ValueError("test called with wrong arguments, use test_Decimal [Skip]") Index: regrtest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/regrtest.py,v retrieving revision 1.153 retrieving revision 1.154 diff -C2 -d -r1.153 -r1.154 *** regrtest.py 6 Jun 2004 15:53:18 -0000 1.153 --- regrtest.py 1 Jul 2004 11:01:31 -0000 1.154 *************** *** 72,75 **** --- 72,78 ---- a long time to complete. + decimal - Test the decimal module against a large suite that + verifies compliance with standards. + To enable all resources except one, use '-uall,-'. For example, to run all the tests except for the bsddb tests, give the *************** *** 113,117 **** from test import test_support ! RESOURCE_NAMES = ('audio', 'curses', 'largefile', 'network', 'bsddb') --- 116,121 ---- from test import test_support ! RESOURCE_NAMES = ('audio', 'curses', 'largefile', 'network', 'bsddb', ! 'decimal') From rhettinger at users.sourceforge.net Thu Jul 1 07:15:42 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Thu Jul 1 07:15:45 2004 Subject: [Python-checkins] python/dist/src/Lib/test test___all__.py, 1.38, 1.39 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29984 Modified Files: test___all__.py Log Message: Move Decimal from the sandbox into production. Index: test___all__.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test___all__.py,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** test___all__.py 13 Jun 2004 05:46:14 -0000 1.38 --- test___all__.py 1 Jul 2004 11:15:39 -0000 1.39 *************** *** 83,86 **** --- 83,87 ---- self.check_all("csv") self.check_all("dbhash") + self.check_all("decimal") self.check_all("difflib") self.check_all("dircache") From rhettinger at users.sourceforge.net Thu Jul 1 07:52:17 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Thu Jul 1 07:52:21 2004 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew24.tex, 1.55, 1.56 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5372 Modified Files: whatsnew24.tex Log Message: Move Decimal from the sandbox into production. Index: whatsnew24.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew24.tex,v retrieving revision 1.55 retrieving revision 1.56 diff -C2 -d -r1.55 -r1.56 *** whatsnew24.tex 10 Jun 2004 05:03:16 -0000 1.55 --- whatsnew24.tex 1 Jul 2004 11:52:15 -0000 1.56 *************** *** 202,205 **** --- 202,267 ---- %====================================================================== + \section{PEP 327: Decimal Data Type} + + A new module, \module{decimal}, offers a \class{Decimal} data type for + decimal floating point arithmetic. Compared to the built-in \class{float} + type implemented with binary floating point, the new class is especially + useful for financial applications and other uses which require exact + decimal representation, control over precision, control over rounding + to meet legal or regulatory requirements, tracking of significant + decimal places, or for applications where the user expects the results + to match hand calculations done the way they were taught in school. + + For example, calculating a 5% tax on a 70 cent phone charge gives + different results in decimal floating point and binary floating point + with the difference being significant when rounding to the nearest + cent: + + \begin{verbatim} + >>> from decimal import * + >>> Decimal('0.70') * Decimal('1.05') + Decimal("0.7350") + >>> .70 * 1.05 + 0.73499999999999999 + \end{verbatim} + + Note that the \class{Decimal} result keeps a trailing zero, automatically + inferring four place significance from two digit mulitiplicands. A key + goal is to reproduce the mathematics we do by hand and avoid the tricky + issues that arise when decimal numbers cannot be represented exactly in + binary floating point. + + Exact representation enables the \class{Decimal} class to perform + modulo calculations and equality tests that would fail in binary + floating point: + + \begin{verbatim} + >>> Decimal('1.00') % Decimal('.10') + Decimal("0.00") + >>> 1.00 % 0.10 + 0.09999999999999995 + + >>> sum([Decimal('0.1')]*10) == Decimal('1.0') + True + >>> sum([0.1]*10) == 1.0 + False + \end{verbatim} + + The \module{decimal} module also allows arbitrarily large precisions to be + set for calculation: + + \begin{verbatim} + >>> getcontext().prec = 24 + >>> Decimal(1) / Decimal(7) + Decimal("0.142857142857142857142857") + \end{verbatim} + + \begin{seealso} + \seepep{327}{Decimal Data Type}{Written by Facundo Batista and implemented + by Eric Price, Facundo Bastista, Raymond Hettinger, Aahz, and Tim Peters.} + \end{seealso} + + + %====================================================================== \section{Other Language Changes} From amk at amk.ca Thu Jul 1 07:58:09 2004 From: amk at amk.ca (A.M. Kuchling) Date: Thu Jul 1 07:58:27 2004 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew24.tex, 1.55, 1.56 In-Reply-To: References: Message-ID: <20040701115809.GA22778@rogue.amk.ca> On Thu, Jul 01, 2004 at 04:52:17AM -0700, rhettinger@users.sourceforge.net wrote: > Modified Files: > whatsnew24.tex > Log Message: > Move Decimal from the sandbox into production. Um, I'd really like to write my own text for this document. Please don't go to the effort of writing "What's New" sections. --amk From rhettinger at users.sourceforge.net Thu Jul 1 08:42:34 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Thu Jul 1 08:42:39 2004 Subject: [Python-checkins] python/nondist/peps pep-0320.txt,1.13,1.14 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15449 Modified Files: pep-0320.txt Log Message: Move two entries from 'planned' to 'done' Index: pep-0320.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0320.txt,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** pep-0320.txt 2 Jun 2004 14:48:16 -0000 1.13 --- pep-0320.txt 1 Jul 2004 12:42:30 -0000 1.14 *************** *** 44,47 **** --- 44,49 ---- PEP 322 Reverse Iteration. + PEP 327: A Decimal package for fixed precision arithmetic. + Encapsulate the decorate-sort-undecorate pattern in a keyword for list.sort(). *************** *** 53,56 **** --- 55,62 ---- Add a collections module with a deque() object. + Add two statistical/reduction functions, nlargest() and nsmallest() + to the heapq module. + + Planned features for 2.4 *************** *** 59,64 **** PEP 318: Function/method decorator syntax - PEP 327: A Decimal package for fixed precision arithmetic. - PEP 328: Imports: Multi-line and Absolute/Relative. (Still quite controversial.) --- 65,68 ---- *************** *** 68,78 **** Remove support for platforms as described in PEP 11. - - Add a module for statistical and reduction functions: - stddev, average, nlargest, nsmallest, product, etc. - (There is a tested implementation in the sandbox but it - may be held-off until Py2.5 because there doesn't not - appear to be any user demand and the author is concerned - that the module may not offer a sufficiently rich API). Finish implementing the Distutils bdist_dpkg command. (AMK) --- 72,75 ---- From rhettinger at users.sourceforge.net Thu Jul 1 08:56:57 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Thu Jul 1 08:57:01 2004 Subject: [Python-checkins] python/dist/src/Doc/tut tut.tex,1.234,1.235 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/tut In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17562 Modified Files: tut.tex Log Message: * Fix typos. * Format an example so that the identation is more obvious. * Add a section on the decimal module to the Brief Tour Part II. Index: tut.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/tut/tut.tex,v retrieving revision 1.234 retrieving revision 1.235 diff -C2 -d -r1.234 -r1.235 *** tut.tex 3 Jun 2004 17:19:25 -0000 1.234 --- tut.tex 1 Jul 2004 12:56:54 -0000 1.235 *************** *** 4339,4343 **** \begin{verbatim} ! >>> class Reverse: "Iterator for looping over a sequence backwards" def __init__(self, data): --- 4339,4343 ---- \begin{verbatim} ! class Reverse: "Iterator for looping over a sequence backwards" def __init__(self, data): *************** *** 4353,4358 **** >>> for char in Reverse('spam'): ! print char ! m a --- 4353,4358 ---- >>> for char in Reverse('spam'): ! ... print char ! ... m a *************** *** 4372,4382 **** \begin{verbatim} ! >>> def reverse(data): ! for index in range(len(data)-1, -1, -1): ! yield data[index] ! >>> for char in reverse('golf'): ! print char ! f l --- 4372,4382 ---- \begin{verbatim} ! def reverse(data): ! for index in range(len(data)-1, -1, -1): ! yield data[index] ! >>> for char in reverse('golf'): ! ... print char ! ... f l *************** *** 4895,4899 **** \end{verbatim} ! The principal challenge of multi-thread applications is coordinating threads that share data or other resources. To that end, the threading module provides a number of synchronization primitives including locks, --- 4895,4899 ---- \end{verbatim} ! The principal challenge of multi-threaded applications is coordinating threads that share data or other resources. To that end, the threading module provides a number of synchronization primitives including locks, *************** *** 4936,4940 **** output is sent to standard error. Other output options include routing messages through email, datagrams, sockets, or to an HTTP Server. New ! filters select different routing based on message priority: DEBUG, INFO, WARNING, ERROR, and CRITICAL. --- 4936,4940 ---- output is sent to standard error. Other output options include routing messages through email, datagrams, sockets, or to an HTTP Server. New ! filters can select different routing based on message priority: DEBUG, INFO, WARNING, ERROR, and CRITICAL. *************** *** 4968,4977 **** ... return str(self.value) ... ! >>> a = A(10) # create a reference >>> d = weakref.WeakValueDictionary() >>> d['primary'] = a # does not create a reference ! >>> d['primary'] # fetch the object if it is still alive 10 ! >>> del a # remove the one reference >>> gc.collect() # run garbage collection right away 0 --- 4968,4977 ---- ... return str(self.value) ... ! >>> a = A(10) # create a reference >>> d = weakref.WeakValueDictionary() >>> d['primary'] = a # does not create a reference ! >>> d['primary'] # fetch the object if it is still alive 10 ! >>> del a # remove the one reference >>> gc.collect() # run garbage collection right away 0 *************** *** 5057,5060 **** --- 5057,5116 ---- + \section{Tools for Working with Decimal Floating Point\label{decimal-fp}} + + The \module{decimal} module, offers a \class{Decimal} data type for + decimal floating point arithmetic. Compared to the built-in \class{float} + type implemented with binary floating point, the new class is especially + useful for financial applications and other uses which require exact + decimal representation, control over precision, control over rounding + to meet legal or regulatory requirements, tracking of significant + decimal places, or for applications where the user expects the results + to match hand calculations done as taught in school. + + For example, calculating a 5% tax on a 70 cent phone charge gives + different results in decimal floating point and binary floating point + with the difference being significant when rounding to the nearest + cent: + + \begin{verbatim} + >>> from decimal import * + >>> Decimal('0.70') * Decimal('1.05') + Decimal("0.7350") + >>> .70 * 1.05 + 0.73499999999999999 + \end{verbatim} + + Note that the \class{Decimal} result keeps a trailing zero, automatically + inferring four place significance from two digit mulitiplicands. Decimal + reproduces mathematics as done by hand and avoids issues that can arise + when binary floating point cannot exactly represent decimal quantities. + + Exact representation enables the \class{Decimal} class to perform + modulo calculations and equality tests that are unsuitable for binary + floating point: + + \begin{verbatim} + >>> Decimal('1.00') % Decimal('.10') + Decimal("0.00") + >>> 1.00 % 0.10 + 0.09999999999999995 + + >>> sum([Decimal('0.1')]*10) == Decimal('1.0') + True + >>> sum([0.1]*10) == 1.0 + False + \end{verbatim} + + The \module{decimal} module also allows arbitrarily large precisions to be + set for calculation: + + \begin{verbatim} + >>> getcontext().prec = 36 + >>> Decimal(1) / Decimal(7) + Decimal("0.142857142857142857142857142857142857") + \end{verbatim} + + + \chapter{What Now? \label{whatNow}} From fdrake at users.sourceforge.net Thu Jul 1 10:26:44 2004 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Thu Jul 1 10:26:49 2004 Subject: [Python-checkins] python/dist/src/Doc/tut tut.tex,1.235,1.236 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/tut In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3701/tut Modified Files: tut.tex Log Message: add omitted markup Index: tut.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/tut/tut.tex,v retrieving revision 1.235 retrieving revision 1.236 diff -C2 -d -r1.235 -r1.236 *** tut.tex 1 Jul 2004 12:56:54 -0000 1.235 --- tut.tex 1 Jul 2004 14:26:31 -0000 1.236 *************** *** 4936,4941 **** output is sent to standard error. Other output options include routing messages through email, datagrams, sockets, or to an HTTP Server. New ! filters can select different routing based on message priority: DEBUG, ! INFO, WARNING, ERROR, and CRITICAL. The logging system can be configured directly from Python or can be --- 4936,4942 ---- output is sent to standard error. Other output options include routing messages through email, datagrams, sockets, or to an HTTP Server. New ! filters can select different routing based on message priority: ! \constant{DEBUG}, \constant{INFO}, \constant{WARNING}, \constant{ERROR}, ! and \constant{CRITICAL}. The logging system can be configured directly from Python or can be From fdrake at users.sourceforge.net Thu Jul 1 10:28:38 2004 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Thu Jul 1 10:28:47 2004 Subject: [Python-checkins] python/dist/src/Lib decimal.py,1.1,1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3972 Modified Files: decimal.py Log Message: fix small consistency nit Index: decimal.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/decimal.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** decimal.py 1 Jul 2004 11:01:31 -0000 1.1 --- decimal.py 1 Jul 2004 14:28:36 -0000 1.2 *************** *** 5,9 **** # and Facundo Batista # and Raymond Hettinger ! # and Aahz (aahz at pobox.com) # and Tim Peters --- 5,9 ---- # and Facundo Batista # and Raymond Hettinger ! # and Aahz # and Tim Peters From mwh at users.sourceforge.net Thu Jul 1 10:52:13 2004 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Thu Jul 1 10:52:17 2004 Subject: [Python-checkins] python/dist/src/Lib cmd.py,1.37,1.38 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7724 Modified Files: cmd.py Log Message: Fix [ 924301 ] A leak case with cmd.py & readline & exception by ensuring that the readline completion function is always reset even in the case of an exception being raised. As a bonus, this makes the documentation for pre & postloop accurate again. Index: cmd.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/cmd.py,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** cmd.py 22 Oct 2003 14:38:54 -0000 1.37 --- cmd.py 1 Jul 2004 14:52:10 -0000 1.38 *************** *** 108,137 **** self.preloop() ! if intro is not None: ! self.intro = intro ! if self.intro: ! self.stdout.write(str(self.intro)+"\n") ! stop = None ! while not stop: ! if self.cmdqueue: ! line = self.cmdqueue.pop(0) ! else: ! if self.use_rawinput: ! try: ! line = raw_input(self.prompt) ! except EOFError: ! line = 'EOF' else: ! self.stdout.write(self.prompt) ! self.stdout.flush() ! line = self.stdin.readline() ! if not len(line): ! line = 'EOF' else: ! line = line[:-1] # chop \n ! line = self.precmd(line) ! stop = self.onecmd(line) ! stop = self.postcmd(stop, line) ! self.postloop() def precmd(self, line): --- 108,154 ---- self.preloop() ! if self.use_rawinput and self.completekey: ! try: ! import readline ! self.old_completer = readline.get_completer() ! readline.set_completer(self.complete) ! readline.parse_and_bind(self.completekey+": complete") ! except ImportError: ! pass ! try: ! if intro is not None: ! self.intro = intro ! if self.intro: ! self.stdout.write(str(self.intro)+"\n") ! stop = None ! while not stop: ! if self.cmdqueue: ! line = self.cmdqueue.pop(0) else: ! if self.use_rawinput: ! try: ! line = raw_input(self.prompt) ! except EOFError: ! line = 'EOF' else: ! self.stdout.write(self.prompt) ! self.stdout.flush() ! line = self.stdin.readline() ! if not len(line): ! line = 'EOF' ! else: ! line = line[:-1] # chop \n ! line = self.precmd(line) ! stop = self.onecmd(line) ! stop = self.postcmd(stop, line) ! self.postloop() ! finally: ! if self.use_rawinput and self.completekey: ! try: ! import readline ! readline.set_completer(self.old_completer) ! except ImportError: ! pass ! def precmd(self, line): *************** *** 148,159 **** def preloop(self): """Hook method executed once when the cmdloop() method is called.""" ! if self.completekey: ! try: ! import readline ! self.old_completer = readline.get_completer() ! readline.set_completer(self.complete) ! readline.parse_and_bind(self.completekey+": complete") ! except ImportError: ! pass def postloop(self): --- 165,169 ---- def preloop(self): """Hook method executed once when the cmdloop() method is called.""" ! pass def postloop(self): *************** *** 162,172 **** """ ! if self.completekey: ! try: ! import readline ! readline.set_completer(self.old_completer) ! except ImportError: ! pass ! def parseline(self, line): """Parse the line into a command name and a string containing --- 172,177 ---- """ ! pass ! def parseline(self, line): """Parse the line into a command name and a string containing From montanaro at users.sourceforge.net Thu Jul 1 15:26:24 2004 From: montanaro at users.sourceforge.net (montanaro@users.sourceforge.net) Date: Thu Jul 1 15:26:31 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libcodecs.tex, 1.28, 1.29 libstdtypes.tex, 1.155, 1.156 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31380 Modified Files: libcodecs.tex libstdtypes.tex Log Message: link to the codecs page from the "".encode() description. Index: libcodecs.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libcodecs.tex,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** libcodecs.tex 19 Mar 2004 08:06:00 -0000 1.28 --- libcodecs.tex 1 Jul 2004 19:26:04 -0000 1.29 *************** *** 514,518 **** all other methods and attribute from the underlying stream. ! \subsection{Standard Encodings} Python comes with a number of codecs builtin, either implemented as C --- 514,518 ---- all other methods and attribute from the underlying stream. ! \subsection{Standard Encodings\label{standard-encodings}} Python comes with a number of codecs builtin, either implemented as C Index: libstdtypes.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libstdtypes.tex,v retrieving revision 1.155 retrieving revision 1.156 diff -C2 -d -r1.155 -r1.156 *** libstdtypes.tex 3 Jun 2004 09:47:01 -0000 1.155 --- libstdtypes.tex 1 Jul 2004 19:26:04 -0000 1.156 *************** *** 579,583 **** \code{'strict'}, meaning that encoding errors raise a \exception{ValueError}. Other possible values are \code{'ignore'} and ! \code{'replace'}. \versionadded{2.0} \end{methoddesc} --- 579,584 ---- \code{'strict'}, meaning that encoding errors raise a \exception{ValueError}. Other possible values are \code{'ignore'} and ! \code{'replace'}. For a list of possible encodings, see ! section~\ref{standard-encodings}. \versionadded{2.0} \end{methoddesc} From doerwalter at users.sourceforge.net Thu Jul 1 15:58:50 2004 From: doerwalter at users.sourceforge.net (doerwalter@users.sourceforge.net) Date: Thu Jul 1 15:58:54 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libstdtypes.tex, 1.156, 1.157 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5364 Modified Files: libstdtypes.tex Log Message: Document that encode() and decode() raise UnicodeError instead of ValueError. Add a note about error handling schemes added by PEP 293. Index: libstdtypes.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libstdtypes.tex,v retrieving revision 1.156 retrieving revision 1.157 diff -C2 -d -r1.156 -r1.157 *** libstdtypes.tex 1 Jul 2004 19:26:04 -0000 1.156 --- libstdtypes.tex 1 Jul 2004 19:58:47 -0000 1.157 *************** *** 568,574 **** may be given to set a different error handling scheme. The default is \code{'strict'}, meaning that encoding errors raise ! \exception{ValueError}. Other possible values are \code{'ignore'} and ! \code{'replace'}. \versionadded{2.2} \end{methoddesc} --- 568,576 ---- may be given to set a different error handling scheme. The default is \code{'strict'}, meaning that encoding errors raise ! \exception{UnicodeError}. Other possible values are \code{'ignore'}, ! \code{'replace'} and any other name registered via ! \function{codecs.register_error}. \versionadded{2.2} + \versionchanged[Support for other error handling schemes added]{2.3} \end{methoddesc} *************** *** 578,585 **** error handling scheme. The default for \var{errors} is \code{'strict'}, meaning that encoding errors raise a ! \exception{ValueError}. Other possible values are \code{'ignore'} and ! \code{'replace'}. For a list of possible encodings, see ! section~\ref{standard-encodings}. \versionadded{2.0} \end{methoddesc} --- 580,590 ---- error handling scheme. The default for \var{errors} is \code{'strict'}, meaning that encoding errors raise a ! \exception{UnicodeError}. Other possible values are \code{'ignore'}, ! \code{'replace'}, \code{'xmlcharrefreplace'}, \code{'backslashreplace'} ! and any other name registered via \function{codecs.register_error}. ! For a list of possible encodings, see section~\ref{standard-encodings}. \versionadded{2.0} + \versionchanged[Support for \code{'xmlcharrefreplace'} and + \code{'backslashreplace'} and other error handling schemes added]{2.3} \end{methoddesc} From fdrake at users.sourceforge.net Thu Jul 1 16:28:50 2004 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Thu Jul 1 16:28:54 2004 Subject: [Python-checkins] python/dist/src/Lib repr.py,1.19,1.20 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11534 Modified Files: repr.py Log Message: Committing Tim's patch for SF bug #983585: test_repr() fails with id() values that appear negative Index: repr.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/repr.py,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** repr.py 22 May 2004 19:37:21 -0000 1.19 --- repr.py 1 Jul 2004 20:28:47 -0000 1.20 *************** *** 112,117 **** # exceptions -- then make up something except: ! return '<' + x.__class__.__name__ + ' instance at ' + \ ! hex(id(x))[2:] + '>' if len(s) > self.maxstring: i = max(0, (self.maxstring-3)//2) --- 112,116 ---- # exceptions -- then make up something except: ! return '<%s instance at %x>' % (x.__class__.__name__, id(x)) if len(s) > self.maxstring: i = max(0, (self.maxstring-3)//2) From bcannon at users.sourceforge.net Thu Jul 1 16:55:45 2004 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Thu Jul 1 16:55:51 2004 Subject: [Python-checkins] python/dist/src/Doc/api utilities.tex,1.14,1.15 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/api In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16682/Doc/api Modified Files: utilities.tex Log Message: Change signatures for arguments to "s" and friends to be the proper ``const char *`` instead of just ``char *``. Also added the mentioning of "const" in some places where it was left out even when the signature already stated the fact. Closes bug #980925. Index: utilities.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/utilities.tex,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** utilities.tex 27 Jun 2004 16:51:45 -0000 1.14 --- utilities.tex 1 Jul 2004 20:55:42 -0000 1.15 *************** *** 385,389 **** \begin{description} ! \item[\samp{s} (string or Unicode object) {[char *]}] Convert a Python string or Unicode object to a C pointer to a character string. You must not provide storage for the string --- 385,389 ---- \begin{description} ! \item[\samp{s} (string or Unicode object) {[const char *]}] Convert a Python string or Unicode object to a C pointer to a character string. You must not provide storage for the string *************** *** 397,401 **** \item[\samp{s\#} (string, Unicode or any read buffer compatible object) ! {[char *, int]}] This variant on \samp{s} stores into two C variables, the first one a pointer to a character string, the second one its length. In this --- 397,401 ---- \item[\samp{s\#} (string, Unicode or any read buffer compatible object) ! {[const char *, int]}] This variant on \samp{s} stores into two C variables, the first one a pointer to a character string, the second one its length. In this *************** *** 406,415 **** representation. ! \item[\samp{z} (string or \code{None}) {[char *]}] Like \samp{s}, but the Python object may also be \code{None}, in which case the C pointer is set to \NULL. \item[\samp{z\#} (string or \code{None} or any read buffer ! compatible object) {[char *, int]}] This is to \samp{s\#} as \samp{z} is to \samp{s}. --- 406,415 ---- representation. ! \item[\samp{z} (string or \code{None}) {[const char *]}] Like \samp{s}, but the Python object may also be \code{None}, in which case the C pointer is set to \NULL. \item[\samp{z\#} (string or \code{None} or any read buffer ! compatible object) {[const char *, int]}] This is to \samp{s\#} as \samp{z} is to \samp{s}. *************** *** 434,438 **** This format requires two arguments. The first is only used as ! input, and must be a \ctype{char*} which points to the name of an encoding as a NUL-terminated string, or \NULL, in which case the default encoding is used. An exception is raised if the named --- 434,438 ---- This format requires two arguments. The first is only used as ! input, and must be a \ctype{const char*} which points to the name of an encoding as a NUL-terminated string, or \NULL, in which case the default encoding is used. An exception is raised if the named *************** *** 462,466 **** It requires three arguments. The first is only used as input, and ! must be a \ctype{char*} which points to the name of an encoding as a NUL-terminated string, or \NULL, in which case the default encoding is used. An exception is raised if the named encoding is not known --- 462,466 ---- It requires three arguments. The first is only used as input, and ! must be a \ctype{const char*} which points to the name of an encoding as a NUL-terminated string, or \NULL, in which case the default encoding is used. An exception is raised if the named encoding is not known From montanaro at users.sourceforge.net Thu Jul 1 22:14:37 2004 From: montanaro at users.sourceforge.net (montanaro@users.sourceforge.net) Date: Thu Jul 1 22:14:40 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libcodecs.tex,1.29,1.30 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12915 Modified Files: libcodecs.tex Log Message: add cp866 row Index: libcodecs.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libcodecs.tex,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** libcodecs.tex 1 Jul 2004 19:26:04 -0000 1.29 --- libcodecs.tex 2 Jul 2004 02:14:34 -0000 1.30 *************** *** 617,620 **** --- 617,624 ---- {Danish, Norwegian} + \lineiii{cp866} + {866, IBM866} + {Russian} + \lineiii{cp869} {869, CP-GR, IBM869} From rhettinger at users.sourceforge.net Fri Jul 2 02:41:08 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Fri Jul 2 02:41:13 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1017,1.1018 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18086/Misc Modified Files: NEWS Log Message: SF Bug #215126: Over restricted type checking on eval() function The builtin eval() function now accepts any mapping for the locals argument. Time sensitive steps guarded by PyDict_CheckExact() to keep from slowing down the normal case. My timings so no measurable impact. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1017 retrieving revision 1.1018 diff -C2 -d -r1.1017 -r1.1018 *** NEWS 1 Jul 2004 11:01:27 -0000 1.1017 --- NEWS 2 Jul 2004 06:41:05 -0000 1.1018 *************** *** 13,16 **** --- 13,18 ---- ----------------- + - Bug #215126. The locals argument to eval() now accepts any mapping type. + - marshal now shares interned strings. This change introduces a new .pyc magic. From rhettinger at users.sourceforge.net Fri Jul 2 02:41:09 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Fri Jul 2 02:41:15 2004 Subject: [Python-checkins] python/dist/src/Objects frameobject.c, 2.78, 2.79 object.c, 2.217, 2.218 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18086/Objects Modified Files: frameobject.c object.c Log Message: SF Bug #215126: Over restricted type checking on eval() function The builtin eval() function now accepts any mapping for the locals argument. Time sensitive steps guarded by PyDict_CheckExact() to keep from slowing down the normal case. My timings so no measurable impact. Index: frameobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/frameobject.c,v retrieving revision 2.78 retrieving revision 2.79 diff -C2 -d -r2.78 -r2.79 *** frameobject.c 20 Mar 2004 21:10:27 -0000 2.78 --- frameobject.c 2 Jul 2004 06:41:06 -0000 2.79 *************** *** 545,549 **** #ifdef Py_DEBUG if (code == NULL || globals == NULL || !PyDict_Check(globals) || ! (locals != NULL && !PyDict_Check(locals))) { PyErr_BadInternalCall(); return NULL; --- 545,549 ---- #ifdef Py_DEBUG if (code == NULL || globals == NULL || !PyDict_Check(globals) || ! (locals != NULL && !PyMapping_Check(locals))) { PyErr_BadInternalCall(); return NULL; *************** *** 689,697 **** value = PyCell_GET(value); if (value == NULL) { ! if (PyDict_DelItem(dict, key) != 0) PyErr_Clear(); } else { ! if (PyDict_SetItem(dict, key, value) != 0) PyErr_Clear(); } --- 689,697 ---- value = PyCell_GET(value); if (value == NULL) { ! if (PyObject_DelItem(dict, key) != 0) PyErr_Clear(); } else { ! if (PyObject_SetItem(dict, key, value) != 0) PyErr_Clear(); } *************** *** 706,710 **** for (j = nmap; --j >= 0; ) { PyObject *key = PyTuple_GET_ITEM(map, j); ! PyObject *value = PyDict_GetItem(dict, key); if (deref) { if (value || clear) { --- 706,712 ---- for (j = nmap; --j >= 0; ) { PyObject *key = PyTuple_GET_ITEM(map, j); ! PyObject *value = PyObject_GetItem(dict, key); ! if (value == NULL) ! PyErr_Clear(); if (deref) { if (value || clear) { *************** *** 721,724 **** --- 723,727 ---- } } + Py_XDECREF(value); } } *************** *** 743,747 **** } map = f->f_code->co_varnames; ! if (!PyDict_Check(locals) || !PyTuple_Check(map)) return; PyErr_Fetch(&error_type, &error_value, &error_traceback); --- 746,750 ---- } map = f->f_code->co_varnames; ! if (!PyTuple_Check(map)) return; PyErr_Fetch(&error_type, &error_value, &error_traceback); *************** *** 781,785 **** if (locals == NULL) return; ! if (!PyDict_Check(locals) || !PyTuple_Check(map)) return; PyErr_Fetch(&error_type, &error_value, &error_traceback); --- 784,788 ---- if (locals == NULL) return; ! if (!PyTuple_Check(map)) return; PyErr_Fetch(&error_type, &error_value, &error_traceback); Index: object.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/object.c,v retrieving revision 2.217 retrieving revision 2.218 diff -C2 -d -r2.217 -r2.218 *** object.c 22 Apr 2004 17:23:49 -0000 2.217 --- object.c 2 Jul 2004 06:41:06 -0000 2.218 *************** *** 1622,1626 **** if (locals == NULL) goto error; ! result = PyDict_Keys(locals); if (result == NULL) goto error; --- 1622,1626 ---- if (locals == NULL) goto error; ! result = PyMapping_Keys(locals); if (result == NULL) goto error; From rhettinger at users.sourceforge.net Fri Jul 2 02:41:10 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Fri Jul 2 02:41:17 2004 Subject: [Python-checkins] python/dist/src/Python bltinmodule.c, 2.309, 2.310 ceval.c, 2.407, 2.408 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18086/Python Modified Files: bltinmodule.c ceval.c Log Message: SF Bug #215126: Over restricted type checking on eval() function The builtin eval() function now accepts any mapping for the locals argument. Time sensitive steps guarded by PyDict_CheckExact() to keep from slowing down the normal case. My timings so no measurable impact. Index: bltinmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/bltinmodule.c,v retrieving revision 2.309 retrieving revision 2.310 diff -C2 -d -r2.309 -r2.310 *** bltinmodule.c 29 Mar 2004 11:50:55 -0000 2.309 --- bltinmodule.c 2 Jul 2004 06:41:07 -0000 2.310 *************** *** 456,464 **** PyCompilerFlags cf; ! if (!PyArg_ParseTuple(args, "O|O!O!:eval", ! &cmd, ! &PyDict_Type, &globals, ! &PyDict_Type, &locals)) return NULL; if (globals == Py_None) { globals = PyEval_GetGlobals(); --- 456,470 ---- PyCompilerFlags cf; ! if (!PyArg_UnpackTuple(args, "eval", 1, 3, &cmd, &globals, &locals)) return NULL; + if (locals != Py_None && !PyMapping_Check(locals)) { + PyErr_SetString(PyExc_TypeError, "locals must be a mapping"); + return NULL; + } + if (globals != Py_None && !PyDict_Check(globals)) { + PyErr_SetString(PyExc_TypeError, PyMapping_Check(globals) ? + "globals must be a real dict; try eval(expr, {}, mapping)" + : "globals must be a dict"); + } if (globals == Py_None) { globals = PyEval_GetGlobals(); *************** *** 518,523 **** The source may be a string representing a Python expression\n\ or a code object as returned by compile().\n\ ! The globals and locals are dictionaries, defaulting to the current\n\ ! globals and locals. If only globals is given, locals defaults to it."); --- 524,530 ---- The source may be a string representing a Python expression\n\ or a code object as returned by compile().\n\ ! The globals must be a dictionary and locals can be any mappping,\n\ ! defaulting to the current globals and locals.\n\ ! If only globals is given, locals defaults to it.\n"); Index: ceval.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/ceval.c,v retrieving revision 2.407 retrieving revision 2.408 diff -C2 -d -r2.407 -r2.408 *** ceval.c 27 Jun 2004 15:43:12 -0000 2.407 --- ceval.c 2 Jul 2004 06:41:07 -0000 2.408 *************** *** 1644,1648 **** v = POP(); if ((x = f->f_locals) != NULL) { ! err = PyDict_SetItem(x, w, v); Py_DECREF(v); if (err == 0) continue; --- 1644,1651 ---- v = POP(); if ((x = f->f_locals) != NULL) { ! if (PyDict_CheckExact(v)) ! err = PyDict_SetItem(x, w, v); ! else ! err = PyObject_SetItem(x, w, v); Py_DECREF(v); if (err == 0) continue; *************** *** 1657,1661 **** w = GETITEM(names, oparg); if ((x = f->f_locals) != NULL) { ! if ((err = PyDict_DelItem(x, w)) != 0) format_exc_check_arg(PyExc_NameError, NAME_ERROR_MSG ,w); --- 1660,1664 ---- w = GETITEM(names, oparg); if ((x = f->f_locals) != NULL) { ! if ((err = PyObject_DelItem(x, w)) != 0) format_exc_check_arg(PyExc_NameError, NAME_ERROR_MSG ,w); *************** *** 1734,1738 **** case LOAD_NAME: w = GETITEM(names, oparg); ! if ((x = f->f_locals) == NULL) { PyErr_Format(PyExc_SystemError, "no locals when loading %s", --- 1737,1741 ---- case LOAD_NAME: w = GETITEM(names, oparg); ! if ((v = f->f_locals) == NULL) { PyErr_Format(PyExc_SystemError, "no locals when loading %s", *************** *** 1740,1744 **** break; } ! x = PyDict_GetItem(x, w); if (x == NULL) { x = PyDict_GetItem(f->f_globals, w); --- 1743,1756 ---- break; } ! if (PyDict_CheckExact(v)) ! x = PyDict_GetItem(v, w); ! else { ! x = PyObject_GetItem(v, w); ! if (x == NULL && PyErr_Occurred()) { ! if (!PyErr_ExceptionMatches(PyExc_KeyError)) ! break; ! PyErr_Clear(); ! } ! } if (x == NULL) { x = PyDict_GetItem(f->f_globals, w); From rhettinger at users.sourceforge.net Fri Jul 2 02:41:37 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Fri Jul 2 02:41:41 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libfuncs.tex,1.165,1.166 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18086/Doc/lib Modified Files: libfuncs.tex Log Message: SF Bug #215126: Over restricted type checking on eval() function The builtin eval() function now accepts any mapping for the locals argument. Time sensitive steps guarded by PyDict_CheckExact() to keep from slowing down the normal case. My timings so no measurable impact. Index: libfuncs.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libfuncs.tex,v retrieving revision 1.165 retrieving revision 1.166 diff -C2 -d -r1.165 -r1.166 *** libfuncs.tex 5 May 2004 16:49:11 -0000 1.165 --- libfuncs.tex 2 Jul 2004 06:41:04 -0000 1.166 *************** *** 292,297 **** \begin{funcdesc}{eval}{expression\optional{, globals\optional{, locals}}} ! The arguments are a string and two optional dictionaries. The ! \var{expression} argument is parsed and evaluated as a Python expression (technically speaking, a condition list) using the \var{globals} and \var{locals} dictionaries as global and local name --- 292,301 ---- \begin{funcdesc}{eval}{expression\optional{, globals\optional{, locals}}} ! The arguments are a string and optional globals and locals. If provided, ! \var{globals} must be a dictionary. If provided, \var{locals} can be ! any mapping object. \versionchanged[formerly \var{locals} was required ! to be a dictionary]{2.4} ! ! The \var{expression} argument is parsed and evaluated as a Python expression (technically speaking, a condition list) using the \var{globals} and \var{locals} dictionaries as global and local name From rhettinger at users.sourceforge.net Fri Jul 2 02:41:37 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Fri Jul 2 02:41:42 2004 Subject: [Python-checkins] python/dist/src/Include frameobject.h,2.37,2.38 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18086/Include Modified Files: frameobject.h Log Message: SF Bug #215126: Over restricted type checking on eval() function The builtin eval() function now accepts any mapping for the locals argument. Time sensitive steps guarded by PyDict_CheckExact() to keep from slowing down the normal case. My timings so no measurable impact. Index: frameobject.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/frameobject.h,v retrieving revision 2.37 retrieving revision 2.38 diff -C2 -d -r2.37 -r2.38 *** frameobject.h 11 Sep 2002 15:36:31 -0000 2.37 --- frameobject.h 2 Jul 2004 06:41:04 -0000 2.38 *************** *** 20,24 **** PyObject *f_builtins; /* builtin symbol table (PyDictObject) */ PyObject *f_globals; /* global symbol table (PyDictObject) */ ! PyObject *f_locals; /* local symbol table (PyDictObject) */ PyObject **f_valuestack; /* points after the last local */ /* Next free slot in f_valuestack. Frame creation sets to f_valuestack. --- 20,24 ---- PyObject *f_builtins; /* builtin symbol table (PyDictObject) */ PyObject *f_globals; /* global symbol table (PyDictObject) */ ! PyObject *f_locals; /* local symbol table (any mapping) */ PyObject **f_valuestack; /* points after the last local */ /* Next free slot in f_valuestack. Frame creation sets to f_valuestack. From rhettinger at users.sourceforge.net Fri Jul 2 02:41:38 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Fri Jul 2 02:41:47 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_builtin.py, 1.29, 1.30 test_descrtut.py, 1.19, 1.20 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18086/Lib/test Modified Files: test_builtin.py test_descrtut.py Log Message: SF Bug #215126: Over restricted type checking on eval() function The builtin eval() function now accepts any mapping for the locals argument. Time sensitive steps guarded by PyDict_CheckExact() to keep from slowing down the normal case. My timings so no measurable impact. Index: test_builtin.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_builtin.py,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** test_builtin.py 12 Feb 2004 17:35:11 -0000 1.29 --- test_builtin.py 2 Jul 2004 06:41:05 -0000 1.30 *************** *** 4,8 **** from test.test_support import fcmp, have_unicode, TESTFN, unlink ! import sys, warnings, cStringIO, random warnings.filterwarnings("ignore", "hex../oct.. of negative int", FutureWarning, __name__) --- 4,8 ---- from test.test_support import fcmp, have_unicode, TESTFN, unlink ! import sys, warnings, cStringIO, random, UserDict warnings.filterwarnings("ignore", "hex../oct.. of negative int", FutureWarning, __name__) *************** *** 263,266 **** --- 263,320 ---- self.assertRaises(TypeError, eval, ()) + def test_general_eval(self): + # Tests that general mappings can be used for the locals argument + + class M: + "Test mapping interface versus possible calls from eval()." + def __getitem__(self, key): + if key == 'a': + return 12 + raise KeyError + def keys(self): + return list('xyz') + + m = M() + g = globals() + self.assertEqual(eval('a', g, m), 12) + self.assertRaises(NameError, eval, 'b', g, m) + self.assertEqual(eval('dir()', g, m), list('xyz')) + self.assertEqual(eval('globals()', g, m), g) + self.assertEqual(eval('locals()', g, m), m) + + # Verify that dict subclasses work as well + class D(dict): + def __getitem__(self, key): + if key == 'a': + return 12 + return dict.__getitem__(self, key) + def keys(self): + return list('xyz') + + d = D() + self.assertEqual(eval('a', g, d), 12) + self.assertRaises(NameError, eval, 'b', g, d) + self.assertEqual(eval('dir()', g, d), list('xyz')) + self.assertEqual(eval('globals()', g, d), g) + self.assertEqual(eval('locals()', g, d), d) + + # Verify locals stores (used by list comps) + eval('[locals() for i in (2,3)]', g, d) + eval('[locals() for i in (2,3)]', g, UserDict.UserDict()) + + class SpreadSheet: + "Sample application showing nested, calculated lookups." + _cells = {} + def __setitem__(self, key, formula): + self._cells[key] = formula + def __getitem__(self, key ): + return eval(self._cells[key], globals(), self) + + ss = SpreadSheet() + ss['a1'] = '5' + ss['a2'] = 'a1*6' + ss['a3'] = 'a2*7' + self.assertEqual(ss['a3'], 210) + # Done outside of the method test_z to get the correct scope z = 0 Index: test_descrtut.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_descrtut.py,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** test_descrtut.py 17 Dec 2003 20:43:32 -0000 1.19 --- test_descrtut.py 2 Jul 2004 06:41:05 -0000 1.20 *************** *** 79,92 **** >>> - However, our __getitem__() method is not used for variable access by the - interpreter: - - >>> exec "print foo" in a - Traceback (most recent call last): - File "", line 1, in ? - File "", line 1, in ? - NameError: name 'foo' is not defined - >>> - Now I'll show that defaultdict instances have dynamic instance variables, just like classic classes: --- 79,82 ---- From theller at users.sourceforge.net Fri Jul 2 03:54:24 2004 From: theller at users.sourceforge.net (theller@users.sourceforge.net) Date: Fri Jul 2 03:54:29 2004 Subject: [Python-checkins] python/dist/src/Lib/distutils/command wininst.exe, 1.1.16.2, 1.1.16.3 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils/command In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30999 Modified Files: Tag: release23-maint wininst.exe Log Message: Fix for SF 982215: bdist_wininst - Next button not greyed out during file copy. Patch from Mark Hammond. Recompiled binary. Index: wininst.exe =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/Attic/wininst.exe,v retrieving revision 1.1.16.2 retrieving revision 1.1.16.3 diff -C2 -d -r1.1.16.2 -r1.1.16.3 Binary files /tmp/cvs5eckkL and /tmp/cvsccJiCP differ From theller at users.sourceforge.net Fri Jul 2 03:54:33 2004 From: theller at users.sourceforge.net (theller@users.sourceforge.net) Date: Fri Jul 2 03:54:36 2004 Subject: [Python-checkins] python/dist/src/PC/bdist_wininst install.c, 1.1.14.1, 1.1.14.2 Message-ID: Update of /cvsroot/python/python/dist/src/PC/bdist_wininst In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31021 Modified Files: Tag: release23-maint install.c Log Message: Fix for SF 982215: bdist_wininst - Next button not greyed out during file copy. Patch from Mark Hammond. Recompiled binary. Index: install.c =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/bdist_wininst/install.c,v retrieving revision 1.1.14.1 retrieving revision 1.1.14.2 diff -C2 -d -r1.1.14.1 -r1.1.14.2 *** install.c 15 Apr 2004 17:50:42 -0000 1.1.14.1 --- install.c 2 Jul 2004 07:54:30 -0000 1.1.14.2 *************** *** 1590,1593 **** --- 1590,1601 ---- hDialog = hwnd; + /* Disable the buttons while we work. Sending CANCELTOCLOSE has + the effect of disabling the cancel button, which is a) as we + do everything synchronously we can't cancel, and b) the next + step is 'finished', when it is too late to cancel anyway. + The next step being 'Finished' means we also don't need to + restore the button state back */ + PropSheet_SetWizButtons(GetParent(hwnd), 0); + SendMessage(GetParent(hwnd), PSM_CANCELTOCLOSE, 0, 0); /* Make sure the installation directory name ends in a */ /* backslash */ From theller at users.sourceforge.net Fri Jul 2 04:02:34 2004 From: theller at users.sourceforge.net (theller@users.sourceforge.net) Date: Fri Jul 2 04:02:37 2004 Subject: [Python-checkins] python/dist/src/Lib/distutils/command wininst-7.1.exe, 1.2, 1.3 wininst-6.exe, 1.2, 1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils/command In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32602 Modified Files: wininst-7.1.exe wininst-6.exe Log Message: Fix for SF 982215: bdist_wininst - Next button not greyed out during file copy. Patch from Mark Hammond. Recompiled binary. Already packported to the 2.3 branch. Index: wininst-7.1.exe =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/wininst-7.1.exe,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 Binary files /tmp/cvs7kozMZ and /tmp/cvsheQlj4 differ Index: wininst-6.exe =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/wininst-6.exe,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 Binary files /tmp/cvsNm2oU6 and /tmp/cvsBSZQub differ From theller at users.sourceforge.net Fri Jul 2 04:02:43 2004 From: theller at users.sourceforge.net (theller@users.sourceforge.net) Date: Fri Jul 2 04:02:47 2004 Subject: [Python-checkins] python/dist/src/PC/bdist_wininst install.c, 1.4, 1.5 Message-ID: Update of /cvsroot/python/python/dist/src/PC/bdist_wininst In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32663 Modified Files: install.c Log Message: Fix for SF 982215: bdist_wininst - Next button not greyed out during file copy. Patch from Mark Hammond. Recompiled binary. Already packported to the 2.3 branch. Index: install.c =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/bdist_wininst/install.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** install.c 18 Jun 2004 17:03:38 -0000 1.4 --- install.c 2 Jul 2004 08:02:40 -0000 1.5 *************** *** 1709,1712 **** --- 1709,1720 ---- success = TRUE; + /* Disable the buttons while we work. Sending CANCELTOCLOSE has + the effect of disabling the cancel button, which is a) as we + do everything synchronously we can't cancel, and b) the next + step is 'finished', when it is too late to cancel anyway. + The next step being 'Finished' means we also don't need to + restore the button state back */ + PropSheet_SetWizButtons(GetParent(hwnd), 0); + SendMessage(GetParent(hwnd), PSM_CANCELTOCLOSE, 0, 0); /* Make sure the installation directory name ends in a */ /* backslash */ From theller at users.sourceforge.net Fri Jul 2 04:09:29 2004 From: theller at users.sourceforge.net (theller@users.sourceforge.net) Date: Fri Jul 2 04:09:32 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS, 1.831.4.125, 1.831.4.126 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1432 Modified Files: Tag: release23-maint NEWS Log Message: SF #982215 is fixed. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.831.4.125 retrieving revision 1.831.4.126 diff -C2 -d -r1.831.4.125 -r1.831.4.126 *** NEWS 29 Jun 2004 04:05:57 -0000 1.831.4.125 --- NEWS 2 Jul 2004 08:09:12 -0000 1.831.4.126 *************** *** 38,41 **** --- 38,44 ---- ------- + - Bug #982215: The Back and Next buttons in bdist_wininst installers are now + disabled during file copy operations. + - Bug #981299: rsync is now a recognized protocol in urlparse that uses a "netloc" portion of a URL. From theller at users.sourceforge.net Fri Jul 2 04:37:38 2004 From: theller at users.sourceforge.net (theller@users.sourceforge.net) Date: Fri Jul 2 04:37:42 2004 Subject: [Python-checkins] python/dist/src/Python dynload_win.c, 2.12, 2.12.14.1 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7473 Modified Files: Tag: release23-maint dynload_win.c Log Message: When importing an extension on Windows, the code reads the PE 'import table' of the dll, to make sure that the dll really was build for the correct Python version. It does this by looking for an entry 'pythonXY.dll' (X.Y is the Python version number). The code now checks the size of the dll's import table before reading entries from it. Before this patch, the code crashed trying to read the import table when the size was zero (as in Win2k's wmi.dll, for example). Look for imports of 'pythonXY_d.dll' in a debug build instead of 'pythonXY.dll'. Fixes SF 951851: Crash when reading "import table" of certain windows dlls. Index: dynload_win.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/dynload_win.c,v retrieving revision 2.12 retrieving revision 2.12.14.1 diff -C2 -d -r2.12 -r2.12.14.1 *** dynload_win.c 26 Aug 2002 21:20:30 -0000 2.12 --- dynload_win.c 2 Jul 2004 08:37:35 -0000 2.12.14.1 *************** *** 117,120 **** --- 117,124 ---- if (DWORD_AT(dllbase + opt_offset + num_dict_off) >= 2) { + /* We have at least 2 tables - the import table is the second + one. But still it may be that the table size is zero */ + if (0 == DWORD_AT(dllbase + opt_offset + import_off + sizeof(DWORD))) + return NULL; import_data = dllbase + DWORD_AT(dllbase + opt_offset + *************** *** 129,133 **** --- 133,141 ---- by numbers to the end of the basename */ pch = import_name + 6; + #ifdef _DEBUG + while (*pch && pch[0] != '_' && pch[1] != 'd' && pch[2] != '.') { + #else while (*pch && *pch != '.') { + #endif if (*pch >= '0' && *pch <= '9') { pch++; *************** *** 222,226 **** --- 230,238 ---- char buffer[256]; + #ifdef _DEBUG + PyOS_snprintf(buffer, sizeof(buffer), "python%d%d_d.dll", + #else PyOS_snprintf(buffer, sizeof(buffer), "python%d%d.dll", + #endif PY_MAJOR_VERSION,PY_MINOR_VERSION); import_python = GetPythonImport(hDLL); From theller at users.sourceforge.net Fri Jul 2 04:40:31 2004 From: theller at users.sourceforge.net (theller@users.sourceforge.net) Date: Fri Jul 2 04:40:35 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS, 1.831.4.126, 1.831.4.127 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7951 Modified Files: Tag: release23-maint NEWS Log Message: SF #951851 is fixed. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.831.4.126 retrieving revision 1.831.4.127 diff -C2 -d -r1.831.4.126 -r1.831.4.127 *** NEWS 2 Jul 2004 08:09:12 -0000 1.831.4.126 --- NEWS 2 Jul 2004 08:40:28 -0000 1.831.4.127 *************** *** 13,16 **** --- 13,19 ---- ----------------- + - Bug #951851: Python crashed when reading import table of certain + Windows DLLs + - Bug #966623. classes created with type() in an exec(, {}) don't have a __module__, but code in typeobject assumed it would always From theller at users.sourceforge.net Fri Jul 2 04:54:00 2004 From: theller at users.sourceforge.net (theller@users.sourceforge.net) Date: Fri Jul 2 04:54:03 2004 Subject: [Python-checkins] python/dist/src/Python dynload_win.c,2.12,2.13 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9904 Modified Files: dynload_win.c Log Message: When importing an extension on Windows, the code reads the PE 'import table' of the dll, to make sure that the dll really was build for the correct Python version. It does this by looking for an entry 'pythonXY.dll' (X.Y is the Python version number). The code now checks the size of the dll's import table before reading entries from it. Before this patch, the code crashed trying to read the import table when the size was zero (as in Win2k's wmi.dll, for example). Look for imports of 'pythonXY_d.dll' in a debug build instead of 'pythonXY.dll'. Fixes SF 951851: Crash when reading "import table" of certain windows dlls. Already backported to the 2.3 branch. Index: dynload_win.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/dynload_win.c,v retrieving revision 2.12 retrieving revision 2.13 diff -C2 -d -r2.12 -r2.13 *** dynload_win.c 26 Aug 2002 21:20:30 -0000 2.12 --- dynload_win.c 2 Jul 2004 08:53:57 -0000 2.13 *************** *** 117,120 **** --- 117,124 ---- if (DWORD_AT(dllbase + opt_offset + num_dict_off) >= 2) { + /* We have at least 2 tables - the import table is the second + one. But still it may be that the table size is zero */ + if (0 == DWORD_AT(dllbase + opt_offset + import_off + sizeof(DWORD))) + return NULL; import_data = dllbase + DWORD_AT(dllbase + opt_offset + *************** *** 129,133 **** --- 133,141 ---- by numbers to the end of the basename */ pch = import_name + 6; + #ifdef _DEBUG + while (*pch && pch[0] != '_' && pch[1] != 'd' && pch[2] != '.') { + #else while (*pch && *pch != '.') { + #endif if (*pch >= '0' && *pch <= '9') { pch++; *************** *** 222,226 **** --- 230,238 ---- char buffer[256]; + #ifdef _DEBUG + PyOS_snprintf(buffer, sizeof(buffer), "python%d%d_d.dll", + #else PyOS_snprintf(buffer, sizeof(buffer), "python%d%d.dll", + #endif PY_MAJOR_VERSION,PY_MINOR_VERSION); import_python = GetPythonImport(hDLL); From theller at users.sourceforge.net Fri Jul 2 04:56:23 2004 From: theller at users.sourceforge.net (theller@users.sourceforge.net) Date: Fri Jul 2 04:56:28 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1018,1.1019 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10448 Modified Files: NEWS Log Message: SF #951851 fixed. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1018 retrieving revision 1.1019 diff -C2 -d -r1.1018 -r1.1019 *** NEWS 2 Jul 2004 06:41:05 -0000 1.1018 --- NEWS 2 Jul 2004 08:56:20 -0000 1.1019 *************** *** 13,16 **** --- 13,19 ---- ----------------- + - Bug #951851: Python crashed when reading import table of certain + Windows DLLs. + - Bug #215126. The locals argument to eval() now accepts any mapping type. From theller at users.sourceforge.net Fri Jul 2 04:58:49 2004 From: theller at users.sourceforge.net (theller@users.sourceforge.net) Date: Fri Jul 2 04:58:51 2004 Subject: [Python-checkins] python/dist/src/PCbuild readme.txt,1.53,1.54 Message-ID: Update of /cvsroot/python/python/dist/src/PCbuild In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10792 Modified Files: readme.txt Log Message: Update info about the windows build. Index: readme.txt =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/readme.txt,v retrieving revision 1.53 retrieving revision 1.54 diff -C2 -d -r1.53 -r1.54 *** readme.txt 11 Apr 2004 19:02:59 -0000 1.53 --- readme.txt 2 Jul 2004 08:58:46 -0000 1.54 *************** *** 171,176 **** With or without strong cryptography? You can choose either with or without strong cryptography, as per the instructions below. By ! default, Python is built and distributed WITHOUT strong crypto ! XXX - is the above correct? Unpack into the dist\. directory, ensuring you expand with folder names. --- 171,175 ---- With or without strong cryptography? You can choose either with or without strong cryptography, as per the instructions below. By ! default, Python is built and distributed WITHOUT strong crypto. Unpack into the dist\. directory, ensuring you expand with folder names. *************** *** 265,269 **** Unpack into the "dist" directory, retaining the folder name from the archive - for example, the latest stable OpenSSL will install as ! dist/openssl-0.9.6g You can (theoretically) use any version of OpenSSL you like - the --- 264,268 ---- Unpack into the "dist" directory, retaining the folder name from the archive - for example, the latest stable OpenSSL will install as ! dist/openssl-0.9.7d You can (theoretically) use any version of OpenSSL you like - the From fdrake at users.sourceforge.net Fri Jul 2 14:57:46 2004 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Fri Jul 2 14:57:51 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1019,1.1020 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8493/Misc Modified Files: NEWS Log Message: Make weak references subclassable: - weakref.ref and weakref.ReferenceType will become aliases for each other - weakref.ref will be a modern, new-style class with proper __new__ and __init__ methods - weakref.WeakValueDictionary will have a lighter memory footprint, using a new weakref.ref subclass to associate the key with the value, allowing us to have only a single object of overhead for each dictionary entry (currently, there are 3 objects of overhead per entry: a weakref to the value, a weakref to the dictionary, and a function object used as a weakref callback; the weakref to the dictionary could be avoided without this change) - a new macro, PyWeakref_CheckRefExact(), will be added - PyWeakref_CheckRef() will check for subclasses of weakref.ref This closes SF patch #983019. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1019 retrieving revision 1.1020 diff -C2 -d -r1.1019 -r1.1020 *** NEWS 2 Jul 2004 08:56:20 -0000 1.1019 --- NEWS 2 Jul 2004 18:57:42 -0000 1.1020 *************** *** 13,16 **** --- 13,21 ---- ----------------- + - weakref.ref is now the type object also known as + weakref.ReferenceType; it can be subclassed like any other new-style + class. There's less per-entry overhead in WeakValueDictionary + objects now (one object instead of three). + - Bug #951851: Python crashed when reading import table of certain Windows DLLs. From fdrake at users.sourceforge.net Fri Jul 2 14:57:46 2004 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Fri Jul 2 14:57:54 2004 Subject: [Python-checkins] python/dist/src/Modules _weakref.c,1.18,1.19 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8493/Modules Modified Files: _weakref.c Log Message: Make weak references subclassable: - weakref.ref and weakref.ReferenceType will become aliases for each other - weakref.ref will be a modern, new-style class with proper __new__ and __init__ methods - weakref.WeakValueDictionary will have a lighter memory footprint, using a new weakref.ref subclass to associate the key with the value, allowing us to have only a single object of overhead for each dictionary entry (currently, there are 3 objects of overhead per entry: a weakref to the value, a weakref to the dictionary, and a function object used as a weakref callback; the weakref to the dictionary could be avoided without this change) - a new macro, PyWeakref_CheckRefExact(), will be added - PyWeakref_CheckRef() will check for subclasses of weakref.ref This closes SF patch #983019. Index: _weakref.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_weakref.c,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** _weakref.c 2 Aug 2002 20:23:40 -0000 1.18 --- _weakref.c 2 Jul 2004 18:57:43 -0000 1.19 *************** *** 58,81 **** - PyDoc_STRVAR(weakref_ref__doc__, - "ref(object[, callback]) -- create a weak reference to 'object';\n" - "when 'object' is finalized, 'callback' will be called and passed\n" - "a reference to the weak reference object when 'object' is about\n" - "to be finalized."); - - static PyObject * - weakref_ref(PyObject *self, PyObject *args) - { - PyObject *object; - PyObject *callback = NULL; - PyObject *result = NULL; - - if (PyArg_UnpackTuple(args, "ref", 1, 2, &object, &callback)) { - result = PyWeakref_NewRef(object, callback); - } - return result; - } - - PyDoc_STRVAR(weakref_proxy__doc__, "proxy(object[, callback]) -- create a proxy object that weakly\n" --- 58,61 ---- *************** *** 105,110 **** {"proxy", weakref_proxy, METH_VARARGS, weakref_proxy__doc__}, - {"ref", weakref_ref, METH_VARARGS, - weakref_ref__doc__}, {NULL, NULL, 0, NULL} }; --- 85,88 ---- *************** *** 120,123 **** --- 98,104 ---- if (m != NULL) { Py_INCREF(&_PyWeakref_RefType); + PyModule_AddObject(m, "ref", + (PyObject *) &_PyWeakref_RefType); + Py_INCREF(&_PyWeakref_RefType); PyModule_AddObject(m, "ReferenceType", (PyObject *) &_PyWeakref_RefType); From fdrake at users.sourceforge.net Fri Jul 2 14:57:47 2004 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Fri Jul 2 14:57:58 2004 Subject: [Python-checkins] python/dist/src/Objects object.c, 2.218, 2.219 weakrefobject.c, 1.16, 1.17 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8493/Objects Modified Files: object.c weakrefobject.c Log Message: Make weak references subclassable: - weakref.ref and weakref.ReferenceType will become aliases for each other - weakref.ref will be a modern, new-style class with proper __new__ and __init__ methods - weakref.WeakValueDictionary will have a lighter memory footprint, using a new weakref.ref subclass to associate the key with the value, allowing us to have only a single object of overhead for each dictionary entry (currently, there are 3 objects of overhead per entry: a weakref to the value, a weakref to the dictionary, and a function object used as a weakref callback; the weakref to the dictionary could be avoided without this change) - a new macro, PyWeakref_CheckRefExact(), will be added - PyWeakref_CheckRef() will check for subclasses of weakref.ref This closes SF patch #983019. Index: object.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/object.c,v retrieving revision 2.218 retrieving revision 2.219 diff -C2 -d -r2.218 -r2.219 *** object.c 2 Jul 2004 06:41:06 -0000 2.218 --- object.c 2 Jul 2004 18:57:44 -0000 2.219 *************** *** 1803,1806 **** --- 1803,1809 ---- Py_FatalError("Can't initialize 'type'"); + if (PyType_Ready(&_PyWeakref_RefType) < 0) + Py_FatalError("Can't initialize 'weakref'"); + if (PyType_Ready(&PyBool_Type) < 0) Py_FatalError("Can't initialize 'bool'"); Index: weakrefobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/weakrefobject.c,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** weakrefobject.c 4 Feb 2004 23:14:14 -0000 1.16 --- weakrefobject.c 2 Jul 2004 18:57:45 -0000 1.17 *************** *** 20,23 **** --- 20,32 ---- + static void + init_weakref(PyWeakReference *self, PyObject *ob, PyObject *callback) + { + self->hash = -1; + self->wr_object = ob; + Py_XINCREF(callback); + self->wr_callback = callback; + } + static PyWeakReference * new_weakref(PyObject *ob, PyObject *callback) *************** *** 27,34 **** result = PyObject_GC_New(PyWeakReference, &_PyWeakref_RefType); if (result) { ! result->hash = -1; ! result->wr_object = ob; ! Py_XINCREF(callback); ! result->wr_callback = callback; PyObject_GC_Track(result); } --- 36,40 ---- result = PyObject_GC_New(PyWeakReference, &_PyWeakref_RefType); if (result) { ! init_weakref(result, ob, callback); PyObject_GC_Track(result); } *************** *** 93,101 **** static void ! weakref_dealloc(PyWeakReference *self) { ! PyObject_GC_UnTrack((PyObject *)self); ! clear_weakref(self); ! PyObject_GC_Del(self); } --- 99,107 ---- static void ! weakref_dealloc(PyObject *self) { ! PyObject_GC_UnTrack(self); ! clear_weakref((PyWeakReference *) self); ! self->ob_type->tp_free(self); } *************** *** 194,197 **** --- 200,331 ---- } + /* Given the head of an object's list of weak references, extract the + * two callback-less refs (ref and proxy). Used to determine if the + * shared references exist and to determine the back link for newly + * inserted references. + */ + static void + get_basic_refs(PyWeakReference *head, + PyWeakReference **refp, PyWeakReference **proxyp) + { + *refp = NULL; + *proxyp = NULL; + + if (head != NULL && head->wr_callback == NULL) { + /* We need to be careful that the "basic refs" aren't + subclasses of the main types. That complicates this a + little. */ + if (PyWeakref_CheckRefExact(head)) { + *refp = head; + head = head->wr_next; + } + if (head != NULL + && head->wr_callback == NULL + && PyWeakref_CheckProxy(head)) { + *proxyp = head; + /* head = head->wr_next; */ + } + } + } + + /* Insert 'newref' in the list after 'prev'. Both must be non-NULL. */ + static void + insert_after(PyWeakReference *newref, PyWeakReference *prev) + { + newref->wr_prev = prev; + newref->wr_next = prev->wr_next; + if (prev->wr_next != NULL) + prev->wr_next->wr_prev = newref; + prev->wr_next = newref; + } + + /* Insert 'newref' at the head of the list; 'list' points to the variable + * that stores the head. + */ + static void + insert_head(PyWeakReference *newref, PyWeakReference **list) + { + PyWeakReference *next = *list; + + newref->wr_prev = NULL; + newref->wr_next = next; + if (next != NULL) + next->wr_prev = newref; + *list = newref; + } + + static int + parse_weakref_init_args(char *funcname, PyObject *args, PyObject *kwargs, + PyObject **obp, PyObject **callbackp) + { + /* XXX Should check that kwargs == NULL or is empty. */ + return PyArg_UnpackTuple(args, funcname, 1, 2, obp, callbackp); + } + + static PyObject * + weakref___new__(PyTypeObject *type, PyObject *args, PyObject *kwargs) + { + PyWeakReference *self = NULL; + PyObject *ob, *callback = NULL; + + if (parse_weakref_init_args("__new__", args, kwargs, &ob, &callback)) { + PyWeakReference *ref, *proxy; + PyWeakReference **list; + + if (!PyType_SUPPORTS_WEAKREFS(ob->ob_type)) { + PyErr_Format(PyExc_TypeError, + "cannot create weak reference to '%s' object", + ob->ob_type->tp_name); + return NULL; + } + if (callback == Py_None) + callback = NULL; + list = GET_WEAKREFS_LISTPTR(ob); + get_basic_refs(*list, &ref, &proxy); + if (callback == NULL && type == &_PyWeakref_RefType) { + if (ref != NULL) { + /* We can re-use an existing reference. */ + Py_INCREF(ref); + return (PyObject *)ref; + } + } + /* We have to create a new reference. */ + /* Note: the tp_alloc() can trigger cyclic GC, so the weakref + list on ob can be mutated. This means that the ref and + proxy pointers we got back earlier may have been collected, + so we need to compute these values again before we use + them. */ + self = (PyWeakReference *) (type->tp_alloc(type, 0)); + if (self != NULL) { + init_weakref(self, ob, callback); + if (callback == NULL && type == &_PyWeakref_RefType) { + insert_head(self, list); + } + else { + PyWeakReference *prev; + + get_basic_refs(*list, &ref, &proxy); + prev = (proxy == NULL) ? ref : proxy; + if (prev == NULL) + insert_head(self, list); + else + insert_after(self, prev); + } + } + } + return (PyObject *)self; + } + + static int + weakref___init__(PyObject *self, PyObject *args, PyObject *kwargs) + { + PyObject *tmp; + + if (parse_weakref_init_args("__init__", args, kwargs, &tmp, &tmp)) + return 0; + else + return 1; + } + PyTypeObject *************** *** 202,206 **** sizeof(PyWeakReference), 0, ! (destructor)weakref_dealloc,/*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ --- 336,340 ---- sizeof(PyWeakReference), 0, ! weakref_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ *************** *** 211,215 **** 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ ! (hashfunc)weakref_hash, /*tp_hash*/ (ternaryfunc)weakref_call, /*tp_call*/ 0, /*tp_str*/ --- 345,349 ---- 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ ! (hashfunc)weakref_hash, /*tp_hash*/ (ternaryfunc)weakref_call, /*tp_call*/ 0, /*tp_str*/ *************** *** 217,226 **** 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ ! Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_HAVE_RICHCOMPARE, 0, /*tp_doc*/ (traverseproc)gc_traverse, /*tp_traverse*/ (inquiry)gc_clear, /*tp_clear*/ (richcmpfunc)weakref_richcompare, /*tp_richcompare*/ ! 0, /*tp_weaklistoffset*/ }; --- 351,375 ---- 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ ! Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_HAVE_RICHCOMPARE ! | Py_TPFLAGS_BASETYPE, /*tp_flags*/ 0, /*tp_doc*/ (traverseproc)gc_traverse, /*tp_traverse*/ (inquiry)gc_clear, /*tp_clear*/ (richcmpfunc)weakref_richcompare, /*tp_richcompare*/ ! 0, /*tp_weaklistoffset*/ ! 0, /*tp_iter*/ ! 0, /*tp_iternext*/ ! 0, /*tp_methods*/ ! 0, /*tp_members*/ ! 0, /*tp_getset*/ ! 0, /*tp_base*/ ! 0, /*tp_dict*/ ! 0, /*tp_descr_get*/ ! 0, /*tp_descr_set*/ ! 0, /*tp_dictoffset*/ ! (initproc)weakref___init__, /*tp_init*/ ! PyType_GenericAlloc, /*tp_alloc*/ ! weakref___new__, /*tp_new*/ ! PyObject_GC_Del, /*tp_free*/ }; *************** *** 364,367 **** --- 513,525 ---- } + static void + proxy_dealloc(PyWeakReference *self) + { + if (self->wr_callback != NULL) + PyObject_GC_UnTrack((PyObject *)self); + clear_weakref(self); + PyObject_GC_Del(self); + } + /* sequence slots */ *************** *** 497,501 **** 0, /* methods */ ! (destructor)weakref_dealloc, /* tp_dealloc */ 0, /* tp_print */ 0, /* tp_getattr */ --- 655,659 ---- 0, /* methods */ ! (destructor)proxy_dealloc, /* tp_dealloc */ 0, /* tp_print */ 0, /* tp_getattr */ *************** *** 532,536 **** 0, /* methods */ ! (destructor)weakref_dealloc, /* tp_dealloc */ 0, /* tp_print */ 0, /* tp_getattr */ --- 690,694 ---- 0, /* methods */ ! (destructor)proxy_dealloc, /* tp_dealloc */ 0, /* tp_print */ 0, /* tp_getattr */ *************** *** 559,612 **** - /* Given the head of an object's list of weak references, extract the - * two callback-less refs (ref and proxy). Used to determine if the - * shared references exist and to determine the back link for newly - * inserted references. - */ - static void - get_basic_refs(PyWeakReference *head, - PyWeakReference **refp, PyWeakReference **proxyp) - { - *refp = NULL; - *proxyp = NULL; - - if (head != NULL && head->wr_callback == NULL) { - if (head->ob_type == &_PyWeakref_RefType) { - *refp = head; - head = head->wr_next; - } - if (head != NULL && head->wr_callback == NULL) { - *proxyp = head; - head = head->wr_next; - } - } - } - - /* Insert 'newref' in the list after 'prev'. Both must be non-NULL. */ - static void - insert_after(PyWeakReference *newref, PyWeakReference *prev) - { - newref->wr_prev = prev; - newref->wr_next = prev->wr_next; - if (prev->wr_next != NULL) - prev->wr_next->wr_prev = newref; - prev->wr_next = newref; - } - - /* Insert 'newref' at the head of the list; 'list' points to the variable - * that stores the head. - */ - static void - insert_head(PyWeakReference *newref, PyWeakReference **list) - { - PyWeakReference *next = *list; - - newref->wr_prev = NULL; - newref->wr_next = next; - if (next != NULL) - next->wr_prev = newref; - *list = newref; - } - PyObject * --- 717,720 ---- *************** *** 770,775 **** current->wr_callback = NULL; clear_weakref(current); ! handle_callback(current, callback); ! Py_DECREF(callback); } else { --- 878,885 ---- current->wr_callback = NULL; clear_weakref(current); ! if (callback != NULL) { ! handle_callback(current, callback); ! Py_DECREF(callback); ! } } else { *************** *** 788,795 **** } for (i = 0; i < count; ++i) { - PyObject *current = PyTuple_GET_ITEM(tuple, i * 2); PyObject *callback = PyTuple_GET_ITEM(tuple, i * 2 + 1); ! handle_callback((PyWeakReference *)current, callback); } Py_DECREF(tuple); --- 898,907 ---- } for (i = 0; i < count; ++i) { PyObject *callback = PyTuple_GET_ITEM(tuple, i * 2 + 1); ! if (callback != NULL) { ! PyObject *current = PyTuple_GET_ITEM(tuple, i * 2); ! handle_callback((PyWeakReference *)current, callback); ! } } Py_DECREF(tuple); From fdrake at users.sourceforge.net Fri Jul 2 14:58:19 2004 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Fri Jul 2 14:58:23 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_weakref.py, 1.40, 1.41 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8493/Lib/test Modified Files: test_weakref.py Log Message: Make weak references subclassable: - weakref.ref and weakref.ReferenceType will become aliases for each other - weakref.ref will be a modern, new-style class with proper __new__ and __init__ methods - weakref.WeakValueDictionary will have a lighter memory footprint, using a new weakref.ref subclass to associate the key with the value, allowing us to have only a single object of overhead for each dictionary entry (currently, there are 3 objects of overhead per entry: a weakref to the value, a weakref to the dictionary, and a function object used as a weakref callback; the weakref to the dictionary could be avoided without this change) - a new macro, PyWeakref_CheckRefExact(), will be added - PyWeakref_CheckRef() will check for subclasses of weakref.ref This closes SF patch #983019. Index: test_weakref.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_weakref.py,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -d -r1.40 -r1.41 *** test_weakref.py 2 Jun 2004 18:42:25 -0000 1.40 --- test_weakref.py 2 Jul 2004 18:57:42 -0000 1.41 *************** *** 624,627 **** --- 624,693 ---- gc.set_threshold(*thresholds) + + class SubclassableWeakrefTestCase(unittest.TestCase): + + def test_subclass_refs(self): + class MyRef(weakref.ref): + def __init__(self, ob, callback=None, value=42): + self.value = value + super(MyRef, self).__init__(ob, callback) + def __call__(self): + self.called = True + return super(MyRef, self).__call__() + o = Object("foo") + mr = MyRef(o, value=24) + self.assert_(mr() is o) + self.assert_(mr.called) + self.assertEqual(mr.value, 24) + del o + self.assert_(mr() is None) + self.assert_(mr.called) + + def test_subclass_refs_dont_replace_standard_refs(self): + class MyRef(weakref.ref): + pass + o = Object(42) + r1 = MyRef(o) + r2 = weakref.ref(o) + self.assert_(r1 is not r2) + self.assertEqual(weakref.getweakrefs(o), [r2, r1]) + self.assertEqual(weakref.getweakrefcount(o), 2) + r3 = MyRef(o) + self.assertEqual(weakref.getweakrefcount(o), 3) + refs = weakref.getweakrefs(o) + self.assertEqual(len(refs), 3) + self.assert_(r2 is refs[0]) + self.assert_(r1 in refs[1:]) + self.assert_(r3 in refs[1:]) + + def test_subclass_refs_dont_conflate_callbacks(self): + class MyRef(weakref.ref): + pass + o = Object(42) + r1 = MyRef(o, id) + r2 = MyRef(o, str) + self.assert_(r1 is not r2) + refs = weakref.getweakrefs(o) + self.assert_(r1 in refs) + self.assert_(r2 in refs) + + def test_subclass_refs_with_slots(self): + class MyRef(weakref.ref): + __slots__ = "slot1", "slot2" + def __new__(type, ob, callback, slot1, slot2): + return weakref.ref.__new__(type, ob, callback) + def __init__(self, ob, callback, slot1, slot2): + self.slot1 = slot1 + self.slot2 = slot2 + def meth(self): + return self.slot1 + self.slot2 + o = Object(42) + r = MyRef(o, None, "abc", "def") + self.assertEqual(r.slot1, "abc") + self.assertEqual(r.slot2, "def") + self.assertEqual(r.meth(), "abcdef") + self.failIf(hasattr(r, "__dict__")) + + class Object: def __init__(self, arg): From fdrake at users.sourceforge.net Fri Jul 2 14:58:19 2004 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Fri Jul 2 14:58:26 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libweakref.tex,1.26,1.27 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8493/Doc/lib Modified Files: libweakref.tex Log Message: Make weak references subclassable: - weakref.ref and weakref.ReferenceType will become aliases for each other - weakref.ref will be a modern, new-style class with proper __new__ and __init__ methods - weakref.WeakValueDictionary will have a lighter memory footprint, using a new weakref.ref subclass to associate the key with the value, allowing us to have only a single object of overhead for each dictionary entry (currently, there are 3 objects of overhead per entry: a weakref to the value, a weakref to the dictionary, and a function object used as a weakref callback; the weakref to the dictionary could be avoided without this change) - a new macro, PyWeakref_CheckRefExact(), will be added - PyWeakref_CheckRef() will check for subclasses of weakref.ref This closes SF patch #983019. Index: libweakref.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libweakref.tex,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** libweakref.tex 12 Jun 2004 06:56:44 -0000 1.26 --- libweakref.tex 2 Jul 2004 18:57:41 -0000 1.27 *************** *** 69,73 **** ! \begin{funcdesc}{ref}{object\optional{, callback}} Return a weak reference to \var{object}. The original object can be retrieved by calling the reference object if the referent is still --- 69,73 ---- ! \begin{classdesc}{ref}{object\optional{, callback}} Return a weak reference to \var{object}. The original object can be retrieved by calling the reference object if the referent is still *************** *** 101,105 **** references are equal only if the reference objects are the same object. ! \end{funcdesc} \begin{funcdesc}{proxy}{object\optional{, callback}} --- 101,109 ---- references are equal only if the reference objects are the same object. ! ! \versionchanged[This is now a subclassable type rather than a ! factory function; it derives from \class{object}] ! {2.4} ! \end{classdesc} \begin{funcdesc}{proxy}{object\optional{, callback}} *************** *** 237,240 **** --- 241,279 ---- single-threaded applications. + Specialized versions of \class{ref} objects can be created through + subclassing. This is used in the implementation of the + \class{WeakValueDictionary} to reduce the memory overhead for each + entry in the mapping. This may be most useful to associate additional + information with a reference, but could also be used to insert + additional processing on calls to retrieve the referent. + + This example shows how a subclass of \class{ref} can be used to store + additional information about an object and affect the value that's + returned when the referent is accessed: + + \begin{verbatim} + import weakref + + class ExtendedRef(weakref.ref): + def __new__(cls, ob, callback=None, **annotations): + weakref.ref.__new__(cls, ob, callback) + self.__counter = 0 + + def __init__(self, ob, callback=None, **annotations): + super(ExtendedRef, self).__init__(ob, callback) + for k, v in annotations: + setattr(self, k, v) + + def __call__(self): + """Return a pair containing the referent and the number of + times the reference has been called. + """ + ob = super(ExtendedRef, self)() + if ob is not None: + self.__counter += 1 + ob = (ob, self.__counter) + return ob + \end{verbatim} + \subsection{Example \label{weakref-example}} From fdrake at users.sourceforge.net Fri Jul 2 14:58:19 2004 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Fri Jul 2 14:58:28 2004 Subject: [Python-checkins] python/dist/src/Include weakrefobject.h,1.4,1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8493/Include Modified Files: weakrefobject.h Log Message: Make weak references subclassable: - weakref.ref and weakref.ReferenceType will become aliases for each other - weakref.ref will be a modern, new-style class with proper __new__ and __init__ methods - weakref.WeakValueDictionary will have a lighter memory footprint, using a new weakref.ref subclass to associate the key with the value, allowing us to have only a single object of overhead for each dictionary entry (currently, there are 3 objects of overhead per entry: a weakref to the value, a weakref to the dictionary, and a function object used as a weakref callback; the weakref to the dictionary could be avoided without this change) - a new macro, PyWeakref_CheckRefExact(), will be added - PyWeakref_CheckRef() will check for subclasses of weakref.ref This closes SF patch #983019. Index: weakrefobject.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/weakrefobject.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** weakrefobject.h 20 Nov 2003 21:21:45 -0000 1.4 --- weakrefobject.h 2 Jul 2004 18:57:42 -0000 1.5 *************** *** 23,31 **** PyAPI_DATA(PyTypeObject) _PyWeakref_CallableProxyType; ! #define PyWeakref_CheckRef(op) \ ((op)->ob_type == &_PyWeakref_RefType) #define PyWeakref_CheckProxy(op) \ (((op)->ob_type == &_PyWeakref_ProxyType) || \ ((op)->ob_type == &_PyWeakref_CallableProxyType)) #define PyWeakref_Check(op) \ (PyWeakref_CheckRef(op) || PyWeakref_CheckProxy(op)) --- 23,36 ---- PyAPI_DATA(PyTypeObject) _PyWeakref_CallableProxyType; ! #define PyWeakref_CheckRef(op) PyObject_TypeCheck(op, &_PyWeakref_RefType) ! #define PyWeakref_CheckRefExact(op) \ ((op)->ob_type == &_PyWeakref_RefType) #define PyWeakref_CheckProxy(op) \ (((op)->ob_type == &_PyWeakref_ProxyType) || \ ((op)->ob_type == &_PyWeakref_CallableProxyType)) + + /* This macro calls PyWeakref_CheckRef() last since that can involve a + function call; this makes it more likely that the function call + will be avoided. */ #define PyWeakref_Check(op) \ (PyWeakref_CheckRef(op) || PyWeakref_CheckProxy(op)) From fdrake at users.sourceforge.net Fri Jul 2 14:58:19 2004 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Fri Jul 2 14:58:30 2004 Subject: [Python-checkins] python/dist/src/Lib weakref.py,1.22,1.23 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8493/Lib Modified Files: weakref.py Log Message: Make weak references subclassable: - weakref.ref and weakref.ReferenceType will become aliases for each other - weakref.ref will be a modern, new-style class with proper __new__ and __init__ methods - weakref.WeakValueDictionary will have a lighter memory footprint, using a new weakref.ref subclass to associate the key with the value, allowing us to have only a single object of overhead for each dictionary entry (currently, there are 3 objects of overhead per entry: a weakref to the value, a weakref to the dictionary, and a function object used as a weakref callback; the weakref to the dictionary could be avoided without this change) - a new macro, PyWeakref_CheckRefExact(), will be added - PyWeakref_CheckRef() will check for subclasses of weakref.ref This closes SF patch #983019. Index: weakref.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/weakref.py,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** weakref.py 27 May 2004 18:16:25 -0000 1.22 --- weakref.py 2 Jul 2004 18:57:42 -0000 1.23 *************** *** 43,46 **** --- 43,54 ---- # way in). + def __init__(self, *args, **kw): + UserDict.UserDict.__init__(self, *args, **kw) + def remove(wr, selfref=ref(self)): + self = selfref() + if self is not None: + del self.data[wr.key] + self._remove = remove + def __getitem__(self, key): o = self.data[key]() *************** *** 54,58 **** def __setitem__(self, key, value): ! self.data[key] = ref(value, self.__makeremove(key)) def copy(self): --- 62,66 ---- def __setitem__(self, key, value): ! self.data[key] = KeyedRef(value, self._remove, key) def copy(self): *************** *** 118,122 **** wr = self.data[key] except KeyError: ! self.data[key] = ref(default, self.__makeremove(key)) return default else: --- 126,130 ---- wr = self.data[key] except KeyError: ! self.data[key] = KeyedRef(default, self._remove, key) return default else: *************** *** 129,133 **** dict = type({})(dict) for key, o in dict.items(): ! d[key] = ref(o, self.__makeremove(key)) if len(kwargs): self.update(kwargs) --- 137,141 ---- dict = type({})(dict) for key, o in dict.items(): ! d[key] = KeyedRef(o, self._remove, key) if len(kwargs): self.update(kwargs) *************** *** 141,150 **** return L ! def __makeremove(self, key): ! def remove(o, selfref=ref(self), key=key): ! self = selfref() ! if self is not None: ! del self.data[key] ! return remove --- 149,172 ---- return L ! ! class KeyedRef(ref): ! """Specialized reference that includes a key corresponding to the value. ! ! This is used in the WeakValueDictionary to avoid having to create ! a function object for each key stored in the mapping. A shared ! callback object can use the 'key' attribute of a KeyedRef instead ! of getting a reference to the key from an enclosing scope. ! ! """ ! ! __slots__ = "key", ! ! def __new__(type, ob, callback, key): ! self = ref.__new__(type, ob, callback) ! self.key = key ! return self ! ! def __init__(self, ob, callback, key): ! super(KeyedRef, self).__init__(ob, callback) *************** *** 299,312 **** class WeakValuedItemIterator(BaseIter): def __init__(self, weakdict): ! self._next = weakdict.data.iteritems().next def next(self): while 1: ! key, wr = self._next() value = wr() if value is not None: ! return key, value ! ! ! # no longer needed ! del UserDict --- 321,330 ---- class WeakValuedItemIterator(BaseIter): def __init__(self, weakdict): ! self._next = weakdict.data.itervalues().next def next(self): while 1: ! wr = self._next() value = wr() if value is not None: ! return wr.key, value From doerwalter at users.sourceforge.net Fri Jul 2 15:00:23 2004 From: doerwalter at users.sourceforge.net (doerwalter@users.sourceforge.net) Date: Fri Jul 2 15:00:26 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_calendar.py, 1.5, 1.6 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8958/Lib/test Modified Files: test_calendar.py Log Message: Add tests that check the result of calendar.monthcalendar() for a set of corner cases. Index: test_calendar.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_calendar.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** test_calendar.py 1 May 2003 17:45:34 -0000 1.5 --- test_calendar.py 2 Jul 2004 19:00:09 -0000 1.6 *************** *** 55,60 **** self.assertEqual(len(d), 13) def test_main(): ! test_support.run_unittest(CalendarTestCase) if __name__ == "__main__": --- 55,138 ---- self.assertEqual(len(d), 13) + + class MonthCalendarTestCase(unittest.TestCase): + def setUp(self): + self.oldfirstweekday = calendar.firstweekday() + calendar.setfirstweekday(self.firstweekday) + + def tearDown(self): + calendar.setfirstweekday(self.oldfirstweekday) + + def check_weeks(self, year, month, weeks): + cal = calendar.monthcalendar(year, month) + self.assertEqual(len(cal), len(weeks)) + for i in xrange(len(weeks)): + self.assertEqual(weeks[i], sum(day != 0 for day in cal[i])) + + + class MondayTestCase(MonthCalendarTestCase): + firstweekday = calendar.MONDAY + + def test_february(self): + # A 28-day february starting of monday (7+7+7+7 days) + self.check_weeks(1999, 2, (7, 7, 7, 7)) + + # A 28-day february starting of tuesday (6+7+7+7+1 days) + self.check_weeks(2005, 2, (6, 7, 7, 7, 1)) + + # A 28-day february starting of sunday (1+7+7+7+6 days) + self.check_weeks(1987, 2, (1, 7, 7, 7, 6)) + + # A 29-day february starting of monday (7+7+7+7+1 days) + self.check_weeks(1988, 2, (7, 7, 7, 7, 1)) + + # A 29-day february starting of tuesday (6+7+7+7+2 days) + self.check_weeks(1972, 2, (6, 7, 7, 7, 2)) + + # A 29-day february starting of sunday (1+7+7+7+7 days) + self.check_weeks(2004, 2, (1, 7, 7, 7, 7)) + + def test_april(self): + # A 30-day april starting of monday (7+7+7+7+2 days) + self.check_weeks(1935, 4, (7, 7, 7, 7, 2)) + + # A 30-day april starting of tuesday (6+7+7+7+3 days) + self.check_weeks(1975, 4, (6, 7, 7, 7, 3)) + + # A 30-day april starting of sunday (1+7+7+7+7+1 days) + self.check_weeks(1945, 4, (1, 7, 7, 7, 7, 1)) + + # A 30-day april starting of saturday (2+7+7+7+7 days) + self.check_weeks(1995, 4, (2, 7, 7, 7, 7)) + + # A 30-day april starting of friday (3+7+7+7+6 days) + self.check_weeks(1994, 4, (3, 7, 7, 7, 6)) + + def test_december(self): + # A 31-day december starting of monday (7+7+7+7+3 days) + self.check_weeks(1980, 12, (7, 7, 7, 7, 3)) + + # A 31-day december starting of tuesday (6+7+7+7+4 days) + self.check_weeks(1987, 12, (6, 7, 7, 7, 4)) + + # A 31-day december starting of sunday (1+7+7+7+7+2 days) + self.check_weeks(1968, 12, (1, 7, 7, 7, 7, 2)) + + # A 31-day december starting of thursday (4+7+7+7+6 days) + self.check_weeks(1988, 12, (4, 7, 7, 7, 6)) + + # A 31-day december starting of friday (3+7+7+7+7 days) + self.check_weeks(2017, 12, (3, 7, 7, 7, 7)) + + # A 31-day december starting of saturday (2+7+7+7+7+1 days) + self.check_weeks(2068, 12, (2, 7, 7, 7, 7, 1)) + + def test_main(): ! test_support.run_unittest( ! CalendarTestCase, ! MondayTestCase ! ) ! if __name__ == "__main__": From mhammond at users.sourceforge.net Fri Jul 2 19:53:19 2004 From: mhammond at users.sourceforge.net (mhammond@users.sourceforge.net) Date: Fri Jul 2 19:53:24 2004 Subject: [Python-checkins] python/dist/src/PC/bdist_wininst install.c, 1.5, 1.6 Message-ID: Update of /cvsroot/python/python/dist/src/PC/bdist_wininst In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29805 Modified Files: install.c Log Message: Patch [ 983775 ] Allow bdist_wininst to install for non-admin users to address bugs: [ 555812 ] installing extension w/o admin rights [ 555810 ] removing extensions without admin rights * When enumerating the Python versions found, also remember the HKEY they were found under. * When installing, if Python was installed under HKCU, we will too. If Python was installed under HKLM, we check the permissions of the current user, and install where we can. * The "root" key we use is a global variable - all registry setting and delete functions use this global rather than a hardcoded HKLM. * A new entry is written to the install log, indicating the key we used. Uninstallation is based on this key. * 'tempnam()' is used rather than 'tmpnam()' - 'tmpnam' creates a temp file on the root of the current drive, and if this is readonly would explain the 'freopen' errors occasionally reported. 'tempnam' creates the temp file in the %TEMP% directory. Index: install.c =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/bdist_wininst/install.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** install.c 2 Jul 2004 08:02:40 -0000 1.5 --- install.c 2 Jul 2004 23:53:16 -0000 1.6 *************** *** 129,132 **** --- 129,135 ---- char pythondll[MAX_PATH]; BOOL pyc_compile, pyo_compile; + /* Either HKLM or HKCU, depending on where Python itself is registered, and + the permissions of the current user. */ + HKEY hkey_root = (HKEY)-1; BOOL success; /* Installation successfull? */ *************** *** 581,589 **** --- 584,600 ---- } + static PyObject *GetRootHKey(PyObject *self) + { + return g_Py_BuildValue("l", hkey_root); + } + #define METH_VARARGS 0x0001 + #define METH_NOARGS 0x0004 + typedef PyObject *(*PyCFunction)(PyObject *, PyObject *); PyMethodDef meth[] = { {"create_shortcut", CreateShortcut, METH_VARARGS, NULL}, {"get_special_folder_path", GetSpecialFolderPath, METH_VARARGS, NULL}, + {"get_root_hkey", (PyCFunction)GetRootHKey, METH_NOARGS, NULL}, {"file_created", FileCreated, METH_VARARGS, NULL}, {"directory_created", DirectoryCreated, METH_VARARGS, NULL}, *************** *** 728,732 **** char *tempname; HINSTANCE hPython; ! tempname = tmpnam(NULL); freopen(tempname, "a", stderr); freopen(tempname, "a", stdout); --- 739,743 ---- char *tempname; HINSTANCE hPython; ! tempname = tempnam(NULL, NULL); freopen(tempname, "a", stderr); freopen(tempname, "a", stdout); *************** *** 1321,1324 **** --- 1332,1340 ---- #endif /* USE_OTHER_PYTHON_VERSIONS */ + typedef struct _InstalledVersionInfo { + char prefix[MAX_PATH+1]; // sys.prefix directory. + HKEY hkey; // Is this Python in HKCU or HKLM? + } InstalledVersionInfo; + /* *************** *** 1343,1347 **** core_version, &bufsize, NULL, NULL, NULL, NULL)) { ! char subkey_name[80], vers_name[80], prefix_buf[MAX_PATH+1]; int itemindex; DWORD value_size; --- 1359,1363 ---- core_version, &bufsize, NULL, NULL, NULL, NULL)) { ! char subkey_name[80], vers_name[80]; int itemindex; DWORD value_size; *************** *** 1358,1369 **** "Software\\Python\\PythonCore\\%s\\InstallPath", core_version); - value_size = sizeof(subkey_name); if (ERROR_SUCCESS == RegOpenKeyEx(hkRoot, subkey_name, 0, KEY_READ, &hk)) { ! if (ERROR_SUCCESS == RegQueryValueEx(hk, NULL, NULL, NULL, prefix_buf, ! &value_size)) { itemindex = SendMessage(hwnd, LB_ADDSTRING, 0, ! (LPARAM)(LPSTR)vers_name); SendMessage(hwnd, LB_SETITEMDATA, itemindex, ! (LPARAM)(LPSTR)strdup(prefix_buf)); } RegCloseKey(hk); --- 1374,1389 ---- "Software\\Python\\PythonCore\\%s\\InstallPath", core_version); if (ERROR_SUCCESS == RegOpenKeyEx(hkRoot, subkey_name, 0, KEY_READ, &hk)) { ! InstalledVersionInfo *ivi = ! (InstalledVersionInfo *)malloc(sizeof(InstalledVersionInfo)); ! value_size = sizeof(ivi->prefix); ! if (ivi && ! ERROR_SUCCESS == RegQueryValueEx(hk, NULL, NULL, NULL, ! ivi->prefix, &value_size)) { itemindex = SendMessage(hwnd, LB_ADDSTRING, 0, ! (LPARAM)(LPSTR)vers_name); ! ivi->hkey = hkRoot; SendMessage(hwnd, LB_SETITEMDATA, itemindex, ! (LPARAM)(LPSTR)ivi); } RegCloseKey(hk); *************** *** 1374,1377 **** --- 1394,1441 ---- } + /* Determine if the current user can write to HKEY_LOCAL_MACHINE */ + BOOL HasLocalMachinePrivs() + { + HKEY hKey; + DWORD result; + static char KeyName[] = + "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall"; + + result = RegOpenKeyEx(HKEY_LOCAL_MACHINE, + KeyName, + 0, + KEY_CREATE_SUB_KEY, + &hKey); + if (result==0) + RegCloseKey(hKey); + return result==0; + } + + // Check the root registry key to use - either HKLM or HKCU. + // If Python is installed in HKCU, then our extension also must be installed + // in HKCU - as Python won't be available for other users, we shouldn't either + // (and will fail if we are!) + // If Python is installed in HKLM, then we will also prefer to use HKLM, but + // this may not be possible - so we silently fall back to HKCU. + // + // We assume hkey_root is already set to where Python itself is installed. + void CheckRootKey(HWND hwnd) + { + if (hkey_root==HKEY_CURRENT_USER) { + ; // as above, always install ourself in HKCU too. + } else if (hkey_root==HKEY_LOCAL_MACHINE) { + // Python in HKLM, but we may or may not have permissions there. + // Open the uninstall key with 'create' permissions - if this fails, + // we don't have permission. + if (!HasLocalMachinePrivs()) + hkey_root = HKEY_CURRENT_USER; + } else { + MessageBox(hwnd, "Don't know Python's installation type", + "Strange", MB_OK | MB_ICONSTOP); + /* Default to wherever they can, but preferring HKLM */ + hkey_root = HasLocalMachinePrivs() ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; + } + } + /* Return the installation scheme depending on Python version number */ SCHEME *GetScheme(int major, int minor) *************** *** 1448,1452 **** switch (HIWORD(wParam)) { int id; - char *cp; case LBN_SELCHANGE: UpdateInstallDir: --- 1512,1515 ---- *************** *** 1465,1477 **** char *pbuf; int result; PropSheet_SetWizButtons(GetParent(hwnd), PSWIZB_BACK | PSWIZB_NEXT); /* Get the python directory */ ! cp = (LPSTR)SendDlgItemMessage(hwnd, IDC_VERSIONS_LIST, LB_GETITEMDATA, id, 0); ! strcpy(python_dir, cp); SetDlgItemText(hwnd, IDC_PATH, python_dir); /* retrieve the python version and pythondll to use */ --- 1528,1543 ---- char *pbuf; int result; + InstalledVersionInfo *ivi; PropSheet_SetWizButtons(GetParent(hwnd), PSWIZB_BACK | PSWIZB_NEXT); /* Get the python directory */ ! ivi = (InstalledVersionInfo *) ! SendDlgItemMessage(hwnd, IDC_VERSIONS_LIST, LB_GETITEMDATA, id, 0); ! hkey_root = ivi->hkey; ! strcpy(python_dir, ivi->prefix); SetDlgItemText(hwnd, IDC_PATH, python_dir); /* retrieve the python version and pythondll to use */ *************** *** 1556,1568 **** static char KeyName[] = "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall"; DWORD disposition; ! result = RegOpenKeyEx(HKEY_LOCAL_MACHINE, KeyName, ! 0, ! KEY_CREATE_SUB_KEY, ! &hKey); if (result != ERROR_SUCCESS) { if (result == ERROR_ACCESS_DENIED) { MessageBox(GetFocus(), "You do not seem to have sufficient access rights\n" --- 1622,1647 ---- static char KeyName[] = "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall"; + const char *root_name = (hkey_root==HKEY_LOCAL_MACHINE ? + "HKEY_LOCAL_MACHINE" : "HKEY_CURRENT_USER"); DWORD disposition; ! /* Use Create, as the Uninstall subkey may not exist under HKCU. ! Use CreateKeyEx, so we can specify a SAM specifying write access ! */ ! result = RegCreateKeyEx(hkey_root, KeyName, ! 0, /* reserved */ ! NULL, /* class */ ! 0, /* options */ ! KEY_CREATE_SUB_KEY, /* sam */ ! NULL, /* security */ ! &hKey, /* result key */ ! NULL); /* disposition */ if (result != ERROR_SUCCESS) { if (result == ERROR_ACCESS_DENIED) { + /* This should no longer be able to happen - we have already + checked if they have permissions in HKLM, and all users + should have write access to HKCU. + */ MessageBox(GetFocus(), "You do not seem to have sufficient access rights\n" *************** *** 1586,1589 **** --- 1665,1671 ---- fprintf(logfile, "Source: %s\n", modulename); + /* Root key must be first entry processed by uninstaller. */ + fprintf(logfile, "999 Root Key: %s\n", root_name); + sprintf(subkey_name, "%s-py%d.%d", meta_name, py_major, py_minor); *************** *** 1723,1726 **** --- 1805,1810 ---- /* Strip the trailing backslash again */ python_dir[strlen(python_dir)-1] = '\0'; + + CheckRootKey(hwnd); if (!OpenLogfile(python_dir)) *************** *** 1851,1855 **** fprintf(logfile, "300 Run Script: [%s]%s\n", pythondll, fname); ! tempname = tmpnam(NULL); if (!freopen(tempname, "a", stderr)) --- 1935,1939 ---- fprintf(logfile, "300 Run Script: [%s]%s\n", pythondll, fname); ! tempname = tempnam(NULL, NULL); if (!freopen(tempname, "a", stderr)) *************** *** 2101,2105 **** *delim = '\0'; ! result = RegOpenKeyEx(HKEY_LOCAL_MACHINE, keyname, 0, --- 2185,2189 ---- *delim = '\0'; ! result = RegOpenKeyEx(hkey_root, keyname, 0, *************** *** 2144,2148 **** *value++ = '\0'; ! result = RegOpenKeyEx(HKEY_LOCAL_MACHINE, keyname, 0, --- 2228,2232 ---- *value++ = '\0'; ! result = RegOpenKeyEx(hkey_root, keyname, 0, *************** *** 2210,2214 **** argv[0] = scriptname; ! tempname = tmpnam(NULL); if (!freopen(tempname, "a", stderr)) --- 2294,2298 ---- argv[0] = scriptname; ! tempname = tempnam(NULL, NULL); if (!freopen(tempname, "a", stderr)) *************** *** 2269,2294 **** } - { - DWORD result; - HKEY hKey; - static char KeyName[] = - "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall"; - - result = RegOpenKeyEx(HKEY_LOCAL_MACHINE, - KeyName, - 0, - KEY_CREATE_SUB_KEY, - &hKey); - if (result == ERROR_ACCESS_DENIED) { - MessageBox(GetFocus(), - "You do not seem to have sufficient access rights\n" - "on this machine to uninstall this software", - NULL, - MB_OK | MB_ICONSTOP); - return 1; /* Error */ - } - RegCloseKey(hKey); - } - logfile = fopen(argv[2], "r"); if (!logfile) { --- 2353,2356 ---- *************** *** 2333,2336 **** --- 2395,2399 ---- return 0; + hkey_root = HKEY_LOCAL_MACHINE; cp = ""; for (i = 0; i < nLines; ++i) { *************** *** 2340,2344 **** cp = lines[i]; /* Parse the lines */ ! if (2 == sscanf(cp, "%d Made Dir: %s", &ign, &buffer)) { if (MyRemoveDirectory(cp)) ++nDirs; --- 2403,2421 ---- cp = lines[i]; /* Parse the lines */ ! if (2 == sscanf(cp, "%d Root Key: %s", &ign, &buffer)) { ! if (strcmp(buffer, "HKEY_CURRENT_USER")==0) ! hkey_root = HKEY_CURRENT_USER; ! else { ! // HKLM - check they have permissions. ! if (!HasLocalMachinePrivs()) { ! MessageBox(GetFocus(), ! "You do not seem to have sufficient access rights\n" ! "on this machine to uninstall this software", ! NULL, ! MB_OK | MB_ICONSTOP); ! return 1; /* Error */ ! } ! } ! } else if (2 == sscanf(cp, "%d Made Dir: %s", &ign, &buffer)) { if (MyRemoveDirectory(cp)) ++nDirs; From bcannon at users.sourceforge.net Fri Jul 2 23:52:38 2004 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Fri Jul 2 23:52:41 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1020,1.1021 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30134/Misc Modified Files: NEWS Log Message: threading.Thread objects will now print a traceback for an exception raised during interpreter shutdown instead of masking it with another traceback about accessing a NoneType when trying to print the exception out in the first place. Closes bug #754449 (using patch #954922). Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1020 retrieving revision 1.1021 diff -C2 -d -r1.1020 -r1.1021 *** NEWS 2 Jul 2004 18:57:42 -0000 1.1020 --- NEWS 3 Jul 2004 03:52:35 -0000 1.1021 *************** *** 361,364 **** --- 361,367 ---- ------- + - Bug #754449: threading.Thread objects will now print out a traceback even + when an exception is raised in a thread during interpreter shutdown. + - Added Decimal.py per PEP 327. From bcannon at users.sourceforge.net Fri Jul 2 23:52:37 2004 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Fri Jul 2 23:52:43 2004 Subject: [Python-checkins] python/dist/src/Lib threading.py,1.41,1.42 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30134/Lib Modified Files: threading.py Log Message: threading.Thread objects will now print a traceback for an exception raised during interpreter shutdown instead of masking it with another traceback about accessing a NoneType when trying to print the exception out in the first place. Closes bug #754449 (using patch #954922). Index: threading.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/threading.py,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** threading.py 8 Mar 2004 22:18:57 -0000 1.41 --- threading.py 3 Jul 2004 03:52:35 -0000 1.42 *************** *** 368,371 **** --- 368,376 ---- __initialized = False + # Need to store a reference to sys.exc_info for printing + # out exceptions when a thread tries to use a global var. during interp. + # shutdown and thus raises an exception about trying to perform some + # operation on/with a NoneType + __exc_info = _sys.exc_info def __init__(self, group=None, target=None, name=None, *************** *** 382,385 **** --- 387,393 ---- self.__block = Condition(Lock()) self.__initialized = True + # sys.stderr is not stored in the class like + # sys.exc_info since it can be changed between instances + self.__stderr = _sys.stderr def _set_daemon(self): *************** *** 439,444 **** if __debug__: self._note("%s.__bootstrap(): unhandled exception", self) ! _sys.stderr.write("Exception in thread %s:\n%s\n" % ! (self.getName(), _format_exc())) else: if __debug__: --- 447,480 ---- if __debug__: self._note("%s.__bootstrap(): unhandled exception", self) ! # If sys.stderr is no more (most likely from interpreter ! # shutdown) use self.__stderr. Otherwise still use sys (as in ! # _sys) in case sys.stderr was redefined since the creation of ! # self. ! if _sys: ! _sys.stderr.write("Exception in thread %s:\n%s\n" % ! (self.getName(), _format_exc())) ! else: ! # Do the best job possible w/o a huge amt. of code to ! # approximate a traceback (code ideas from ! # Lib/traceback.py) ! exc_type, exc_value, exc_tb = self.__exc_info() ! try: ! print>>self.__stderr, ( ! "Exception in thread " + self.getName() + ! " (most likely raised during interpreter shutdown):") ! print>>self.__stderr, ( ! "Traceback (most recent call last):") ! while exc_tb: ! print>>self.__stderr, ( ! ' File "%s", line %s, in %s' % ! (exc_tb.tb_frame.f_code.co_filename, ! exc_tb.tb_lineno, ! exc_tb.tb_frame.f_code.co_name)) ! exc_tb = exc_tb.tb_next ! print>>self.__stderr, ("%s: %s" % (exc_type, exc_value)) ! # Make sure that exc_tb gets deleted since it is a memory ! # hog; deleting everything else is just for thoroughness ! finally: ! del exc_type, exc_value, exc_tb else: if __debug__: From bcannon at users.sourceforge.net Fri Jul 2 23:54:56 2004 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Fri Jul 2 23:55:00 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1021,1.1022 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30727/Misc Modified Files: NEWS Log Message: Clarify last added comment (bug #754449). Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1021 retrieving revision 1.1022 diff -C2 -d -r1.1021 -r1.1022 *** NEWS 3 Jul 2004 03:52:35 -0000 1.1021 --- NEWS 3 Jul 2004 03:54:54 -0000 1.1022 *************** *** 361,366 **** ------- ! - Bug #754449: threading.Thread objects will now print out a traceback even ! when an exception is raised in a thread during interpreter shutdown. - Added Decimal.py per PEP 327. --- 361,367 ---- ------- ! - Bug #754449: threading.Thread objects no longer mask exceptions raised during ! interpreter shutdown with another exception from attempting to handle the ! original exception. - Added Decimal.py per PEP 327. From rhettinger at users.sourceforge.net Sat Jul 3 06:02:30 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Jul 3 06:02:35 2004 Subject: [Python-checkins] python/dist/src/Lib decimal.py,1.2,1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11112 Modified Files: decimal.py Log Message: Work through several open todos: * Added test for pickling contexts * Renamed ExceptionList to Signals (to match wording in the spec) * Simplified Context constructor by allowing flags=None to automatically generate a zeroed-out flags dictionary. * inlined _convertString() which was used only once * _rounding_decision is private, so excluded its contants from __all__. * added an XXX comment with concerns about subclassing signals results in a deviation from the spec (maybe important, maybe not). * Taught the test_suite to determine its own directory (modeled after code in regrtest.py). Enables it to be run when the current directory is not the test directory. * Added a clear_flags() method to the Context API to make it easier to do a common operation with flags. * Fixed the trap_enablers defaults in BasicDefaultContext to match the spec. Index: decimal.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/decimal.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** decimal.py 1 Jul 2004 14:28:36 -0000 1.2 --- decimal.py 3 Jul 2004 10:02:27 -0000 1.3 *************** *** 10,20 **** # Todo: - # Add deepcopy and pickle support for contexts - # Consider having a SimpleDecimal subclass implementing X3.274 semantics - # Improve the Context API - # Especially with respect to setting flags and traps - # Consider adding a clear_flags() method to Context # Provide a clean way of attaching monetary format representations ! # Review all exposed constants for utility vs. namespace clutter --- 10,15 ---- # Todo: # Provide a clean way of attaching monetary format representations ! # Make tests independent of DefaultContext.prec == 9 *************** *** 140,145 **** 'ROUND_DOWN', 'ROUND_HALF_UP', 'ROUND_HALF_EVEN', 'ROUND_CEILING', 'ROUND_FLOOR', 'ROUND_UP', 'ROUND_HALF_DOWN', ! 'NEVER_ROUND', 'ALWAYS_ROUND', ! 'ExceptionList', # <-- Used for building trap/flag dictionaries # Functions for manipulating contexts --- 135,139 ---- 'ROUND_DOWN', 'ROUND_HALF_UP', 'ROUND_HALF_EVEN', 'ROUND_CEILING', 'ROUND_FLOOR', 'ROUND_UP', 'ROUND_HALF_DOWN', ! 'Signals', # <-- Used for building trap/flag dictionaries # Functions for manipulating contexts *************** *** 245,248 **** --- 239,248 ---- return NaN + # XXX Is there a logic error in subclassing InvalidOperation? + # Setting the InvalidOperation trap to zero does not preclude ConversionSyntax. + # Also, incrementing Conversion syntax flag will not increment InvalidOperation. + # Both of these issues interfere with cross-language portability because + # code following the spec would not know about the Python subclasses. + class ConversionSyntax(InvalidOperation): """Trying to convert badly formed string. *************** *** 411,416 **** return False ! #ExceptionList holds the exceptions ! ExceptionList = filter(_filterfunc, globals().values()) del _filterfunc --- 411,416 ---- return False ! #Signals holds the exceptions ! Signals = filter(_filterfunc, globals().values()) del _filterfunc *************** *** 493,497 **** self._int = tuple(map(int, diag)) #Diagnostic info return ! self._convertString(value, context) return --- 493,500 ---- self._int = tuple(map(int, diag)) #Diagnostic info return ! try: ! self._sign, self._int, self._exp = _string2exact(value) ! except ValueError: ! self._sign, self._int, self._exp = context._raise_error(ConversionSyntax) return *************** *** 595,611 **** return 0 - def _convertString(self, value, context=None): - """Changes self's value to that in a string. - - A bad string causes a ConversionSyntax error. - """ - if context is None: - context = getcontext() - try: - self._sign, self._int, self._exp = _string2exact(value) - except ValueError: - self._sign, self._int, self._exp = context._raise_error(ConversionSyntax) - return - def __nonzero__(self): """Is the number non-zero? --- 598,601 ---- *************** *** 1434,1439 **** def __int__(self): """Converts self to a int, truncating if necessary.""" - # XXX This should be implemented in terms of tested - # functions in the standard if self._isnan(): context = getcontext() --- 1424,1427 ---- *************** *** 2116,2119 **** --- 2104,2109 ---- return self.__class__(str(self)) + ##### Context class ########################################### + # get rounding method function: *************** *** 2153,2156 **** --- 2143,2148 ---- capitals=1, _clamp=0, _ignored_flags=[]): + if flags is None: + flags = dict.fromkeys(Signals, 0) DefaultLock.acquire() for name, val in locals().items(): *************** *** 2162,2165 **** --- 2154,2162 ---- del self.self + def clear_flags(self): + """Reset all flags to zero""" + for flag in self.flags: + self.flag = 0 + def copy(self): """Returns a copy from self.""" *************** *** 2168,2172 **** self.capitals, self._clamp, self._ignored_flags) return nc - __copy__ = copy def _raise_error(self, error, explanation = None, *args): --- 2165,2168 ---- *************** *** 2193,2197 **** def _ignore_all_flags(self): """Ignore all flags, if they are raised""" ! return self._ignore_flags(*ExceptionList) def _ignore_flags(self, *flags): --- 2189,2193 ---- def _ignore_all_flags(self): """Ignore all flags, if they are raised""" ! return self._ignore_flags(*Signals) def _ignore_flags(self, *flags): *************** *** 2960,2969 **** ##### Setup Specific Contexts ################################ ! def _zero_exceptions(): ! "Helper function mapping all exceptions to zero." ! d = {} ! for exception in ExceptionList: ! d[exception] = 0 ! return d # The default context prototype used by Context() --- 2956,2961 ---- ##### Setup Specific Contexts ################################ ! _basic_traps = dict.fromkeys(Signals, 1) ! _basic_traps.update({Inexact:0, Rounded:0, Subnormal:0}) # The default context prototype used by Context() *************** *** 2972,2977 **** DefaultContext = Context( prec=SINGLE_PRECISION, rounding=ROUND_HALF_EVEN, ! trap_enablers=_zero_exceptions(), ! flags=_zero_exceptions(), _rounding_decision=ALWAYS_ROUND, ) --- 2964,2969 ---- DefaultContext = Context( prec=SINGLE_PRECISION, rounding=ROUND_HALF_EVEN, ! trap_enablers=dict.fromkeys(Signals, 0), ! flags=None, _rounding_decision=ALWAYS_ROUND, ) *************** *** 2982,2992 **** # of the spec. - _basic_traps = _zero_exceptions() - _basic_traps.update({Inexact:1, Rounded:1, Subnormal:1}) - BasicDefaultContext = Context( prec=9, rounding=ROUND_HALF_UP, trap_enablers=_basic_traps, ! flags=_zero_exceptions(), _rounding_decision=ALWAYS_ROUND, ) --- 2974,2981 ---- # of the spec. BasicDefaultContext = Context( prec=9, rounding=ROUND_HALF_UP, trap_enablers=_basic_traps, ! flags=None, _rounding_decision=ALWAYS_ROUND, ) *************** *** 2994,3004 **** ExtendedDefaultContext = Context( prec=SINGLE_PRECISION, rounding=ROUND_HALF_EVEN, ! trap_enablers=_zero_exceptions(), ! flags=_zero_exceptions(), _rounding_decision=ALWAYS_ROUND, ) ! ##### Useful Constants (internal use only###################### #Reusable defaults --- 2983,2993 ---- ExtendedDefaultContext = Context( prec=SINGLE_PRECISION, rounding=ROUND_HALF_EVEN, ! trap_enablers=dict.fromkeys(Signals, 0), ! flags=None, _rounding_decision=ALWAYS_ROUND, ) ! ##### Useful Constants (internal use only) #################### #Reusable defaults From rhettinger at users.sourceforge.net Sat Jul 3 06:02:30 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Jul 3 06:02:37 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_decimal.py,1.1,1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11112/test Modified Files: test_decimal.py Log Message: Work through several open todos: * Added test for pickling contexts * Renamed ExceptionList to Signals (to match wording in the spec) * Simplified Context constructor by allowing flags=None to automatically generate a zeroed-out flags dictionary. * inlined _convertString() which was used only once * _rounding_decision is private, so excluded its contants from __all__. * added an XXX comment with concerns about subclassing signals results in a deviation from the spec (maybe important, maybe not). * Taught the test_suite to determine its own directory (modeled after code in regrtest.py). Enables it to be run when the current directory is not the test directory. * Added a clear_flags() method to the Context API to make it easier to do a common operation with flags. * Fixed the trap_enablers defaults in BasicDefaultContext to match the spec. Index: test_decimal.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_decimal.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** test_decimal.py 1 Jul 2004 11:01:32 -0000 1.1 --- test_decimal.py 3 Jul 2004 10:02:28 -0000 1.2 *************** *** 36,40 **** TESTDATADIR = 'decimaltestdata' ! dir = os.curdir + os.sep + TESTDATADIR + os.sep skip_expected = not os.path.isdir(dir) --- 36,45 ---- TESTDATADIR = 'decimaltestdata' ! if __name__ == '__main__': ! file = sys.argv[0] ! else: ! file = __file__ ! testdir = os.path.dirname(file) or os.curdir ! dir = testdir + os.sep + TESTDATADIR + os.sep skip_expected = not os.path.isdir(dir) *************** *** 191,195 **** theirexceptions = [ErrorNames[x.lower()] for x in exceptions] ! for exception in ExceptionList: self.context.trap_enablers[exception] = 1 #Catch these bugs... for exception in theirexceptions: --- 196,200 ---- theirexceptions = [ErrorNames[x.lower()] for x in exceptions] ! for exception in Signals: self.context.trap_enablers[exception] = 1 #Catch these bugs... for exception in theirexceptions: *************** *** 213,217 **** except error: pass ! except ExceptionList, e: self.fail("Raised %s in %s when %s disabled" % \ (e, s, error)) --- 218,222 ---- except error: pass ! except Signals, e: self.fail("Raised %s in %s when %s disabled" % \ (e, s, error)) *************** *** 233,237 **** except error: pass ! except ExceptionList, e: self.fail("Raised %s in %s when %s disabled" % \ (e, s, error)) --- 238,242 ---- except error: pass ! except Signals, e: self.fail("Raised %s in %s when %s disabled" % \ (e, s, error)) *************** *** 243,247 **** if fname == 'same_quantum': result = str(int(eval(result))) # 'True', 'False' -> '1', '0' ! except ExceptionList, error: self.fail("Raised %s in %s" % (error, s)) except: #Catch any error long enough to state the test case. --- 248,252 ---- if fname == 'same_quantum': result = str(int(eval(result))) # 'True', 'False' -> '1', '0' ! except Signals, error: self.fail("Raised %s in %s" % (error, s)) except: #Catch any error long enough to state the test case. *************** *** 264,268 **** def getexceptions(self): L = [] ! for exception in ExceptionList: if self.context.flags[exception]: L.append(exception) --- 269,273 ---- def getexceptions(self): L = [] ! for exception in Signals: if self.context.flags[exception]: L.append(exception) *************** *** 270,274 **** def resetflags(self): ! for exception in ExceptionList: self.context.flags[exception] = 0 --- 275,279 ---- def resetflags(self): ! for exception in Signals: self.context.flags[exception] = 0 *************** *** 1047,1050 **** --- 1052,1065 ---- self.assertEqual(d, e) + class ContextAPItests(unittest.TestCase): + + def test_pickle(self): + c = Context() + e = pickle.loads(pickle.dumps(c)) + for k in vars(c): + v1 = vars(c)[k] + v2 = vars(e)[k] + self.assertEqual(v1, v2) + def test_main(arith=False, verbose=None): """ Execute the tests. *************** *** 1060,1063 **** --- 1075,1079 ---- DecimalUsabilityTest, DecimalPythonAPItests, + ContextAPItests, ] From vsajip at users.sourceforge.net Sat Jul 3 07:45:55 2004 From: vsajip at users.sourceforge.net (vsajip@users.sourceforge.net) Date: Sat Jul 3 07:45:59 2004 Subject: [Python-checkins] python/dist/src/Doc/lib liblogging.tex,1.18,1.19 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27326 Modified Files: liblogging.tex Log Message: Moved example section up to just after the section on Logger objects, and changed it to use the new basicConfig() API Index: liblogging.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/liblogging.tex,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** liblogging.tex 15 Apr 2004 06:18:48 -0000 1.18 --- liblogging.tex 3 Jul 2004 11:45:53 -0000 1.19 *************** *** 201,206 **** then you get the corresponding string. If you have associated levels with names using \function{addLevelName()} then the name you have associated ! with \var{lvl} is returned. Otherwise, the string "Level \%s" \% lvl is ! returned. \end{funcdesc} --- 201,207 ---- then you get the corresponding string. If you have associated levels with names using \function{addLevelName()} then the name you have associated ! with \var{lvl} is returned. If a numeric value corresponding to one of the ! defined levels is passed in, the corresponding string representation is ! returned. Otherwise, the string "Level \%s" \% lvl is returned. \end{funcdesc} *************** *** 244,249 **** {This is the original source for the \module{logging} package. The version of the package available from this ! site is suitable for use with Python 2.1.x and 2.2.x, which ! do not include the \module{logging} package in the standard library.} \end{seealso} --- 245,250 ---- {This is the original source for the \module{logging} package. The version of the package available from this ! site is suitable for use with Python 1.5.2, 2.1.x and 2.2.x, ! which do not include the \module{logging} package in the standard library.} \end{seealso} *************** *** 364,367 **** --- 365,474 ---- \end{methoddesc} + \subsection{Basic example \label{minimal-example}} + + The \module{logging} package provides a lot of flexibility, and its + configuration can appear daunting. This section demonstrates that simple + use of the logging package is possible. + + The simplest example shows logging to the console: + + \begin{verbatim} + import logging + + logging.debug('A debug message') + logging.info('Some information') + logging.warning('A shot across the bows') + \end{verbatim} + + If you run the above script, you'll see this: + \begin{verbatim} + WARNING:root:A shot across the bows + \end{verbatim} + + Because no particular logger was specified, the system used the root logger. + The debug and info messages didn't appear because by default, the root + logger is configured to only handle messages with a severity of WARNING + or above. The message format is also a configuration default, as is the output + destination of the messages - \code{sys.stderr}. The severity level, + the message format and destination can be easily changed, as shown in + the example below: + + \begin{verbatim} + import logging + + logging.basicConfig(level=logging.DEBUG, + format='%(asctime)s %(levelname)s %(message)s', + filename='/tmp/myapp.log', + filemode='w') + logging.debug('A debug message') + logging.info('Some information') + logging.warning('A shot across the bows') + \end{verbatim} + + The \method{basicConfig()} method is used to change the configuration + defaults, which results in output (written to \code{/tmp/myapp.log}) + which should look something like the following: + + \begin{verbatim} + 2004-07-02 13:00:08,743 DEBUG A debug message + 2004-07-02 13:00:08,743 INFO Some information + 2004-07-02 13:00:08,743 WARNING A shot across the bows + \end{verbatim} + + This time, all messages with a severity of DEBUG or above were handled, + and the format of the messages was also changed, and output went to the + specified file rather than the console. + + Formatting uses standard Python string formatting - see section + \ref{typesseq-strings}. The format string takes the following + common specifiers. For a complete list of specifiers, consult the + \class{Formatter} documentation. + + \begin{tableii}{l|l}{code}{Format}{Description} + \lineii{\%(name)s} {Name of the logger (logging channel).} + \lineii{\%(levelname)s}{Text logging level for the message + (\code{'DEBUG'}, \code{'INFO'}, + \code{'WARNING'}, \code{'ERROR'}, + \code{'CRITICAL'}).} + \lineii{\%(asctime)s} {Human-readable time when the \class{LogRecord} + was created. By default this is of the form + ``2003-07-08 16:49:45,896'' (the numbers after the + comma are millisecond portion of the time).} + \lineii{\%(message)s} {The logged message.} + \end{tableii} + + To change the date/time format, you can pass an additional keyword parameter, + \var{datefmt}, as in the following: + + \begin{verbatim} + import logging + + logging.basicConfig(level=logging.DEBUG, + format='%(asctime)s %(levelname)-8s %(message)s', + datefmt='%a, %d %b %Y %H:%M:%S', + filename='/temp/myapp.log', + filemode='w') + logging.debug('A debug message') + logging.info('Some information') + logging.warning('A shot across the bows') + \end{verbatim} + + which would result in output like + + \begin{verbatim} + Fri, 02 Jul 2004 13:06:18 DEBUG A debug message + Fri, 02 Jul 2004 13:06:18 INFO Some information + Fri, 02 Jul 2004 13:06:18 WARNING A shot across the bows + \end{verbatim} + + The date format string follows the requirements of \function{strftime()} - + see the documentation for the \refmodule{time} module. + + If, instead of sending logging output to the console or a file, you'd rather + use a file-like object which you have created separately, you can pass it + to \function{basicConfig()} using the \var{stream} keyword argument. Note + that if both \var{stream} and \var{filename} keyword arguments are passed, + the \var{stream} argument is ignored. + \subsection{Handler Objects} *************** *** 430,441 **** \end{methoddesc} ! \begin{methoddesc}{handleError}{} This method should be called from handlers when an exception is ! encountered during an emit() call. By default it does nothing, which means that exceptions get silently ignored. This is what is mostly wanted for a logging system - most users will not care about errors in the logging system, they are more interested in application errors. You could, however, replace this with a custom ! handler if you wish. \end{methoddesc} --- 537,549 ---- \end{methoddesc} ! \begin{methoddesc}{handleError}{record} This method should be called from handlers when an exception is ! encountered during an \method{emit()} call. By default it does nothing, which means that exceptions get silently ignored. This is what is mostly wanted for a logging system - most users will not care about errors in the logging system, they are more interested in application errors. You could, however, replace this with a custom ! handler if you wish. The specified record is the one which was being ! processed when the exception occurred. \end{methoddesc} *************** *** 507,511 **** specified file is opened and used as the stream for logging. If \var{mode} is not specified, \code{'a'} is used. By default, the ! file grows indefinitely. You can use the \var{maxBytes} and --- 615,619 ---- specified file is opened and used as the stream for logging. If \var{mode} is not specified, \code{'a'} is used. By default, the ! file grows indefinitely. You can use the \var{maxBytes} and *************** *** 523,527 **** closed and renamed to \file{app.log.1}, and if files \file{app.log.1}, \file{app.log.2}, etc. exist, then they are renamed to \file{app.log.2}, ! \file{app.log.3} etc. respectively. \end{classdesc} --- 631,635 ---- closed and renamed to \file{app.log.1}, and if files \file{app.log.1}, \file{app.log.2}, etc. exist, then they are renamed to \file{app.log.2}, ! \file{app.log.3} etc. respectively. \end{classdesc} *************** *** 1052,1056 **** messages are \strong{not} propagated to handlers up the hierarchy. The \code{qualname} entry is the hierarchical channel name of the logger, ! for example, the name used by the application to get the logger. Sections which specify handler configuration are exemplified by the --- 1160,1164 ---- messages are \strong{not} propagated to handlers up the hierarchy. The \code{qualname} entry is the hierarchical channel name of the logger, ! that is to say the name used by the application to get the logger. Sections which specify handler configuration are exemplified by the *************** *** 1148,1191 **** result of using the above format string, with a comma separator. An example time in ISO8601 format is \code{2003-01-23 00:29:50,411}. - - \subsection{Using the logging package} - - \subsubsection{Basic example - log to a file} - - Here's a simple logging example that just logs to a file. In order, - it creates a \class{Logger} instance, then a \class{FileHandler} - and a \class{Formatter}. It attaches the \class{Formatter} to the - \class{FileHandler}, then the \class{FileHandler} to the \class{Logger}. - Finally, it sets a debug level for the logger. - - \begin{verbatim} - import logging - logger = logging.getLogger('myapp') - hdlr = logging.FileHandler('/var/tmp/myapp.log') - formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s') - hdlr.setFormatter(formatter) - logger.addHandler(hdlr) - logger.setLevel(logging.WARNING) - \end{verbatim} - - We can use this logger object now to write entries to the log file: - - \begin{verbatim} - logger.error('We have a problem') - logger.info('While this is just chatty') - \end{verbatim} - - If we look in the file that was created, we'll see something like this: - \begin{verbatim} - 2003-07-08 16:49:45,896 ERROR We have a problem - \end{verbatim} - - The info message was not written to the file: we called the - \method{setLevel()} method to say we only wanted \constant{WARNING} or - worse, so the info message is discarded. - - The timestamp is of the form - ``year-month-day hour:minutes:seconds,milliseconds.'' - Note that despite the three digits of precision in the milliseconds field, - not all systems provide time with this much precision. - --- 1256,1257 ---- From vsajip at users.sourceforge.net Sat Jul 3 07:47:29 2004 From: vsajip at users.sourceforge.net (vsajip@users.sourceforge.net) Date: Sat Jul 3 07:47:32 2004 Subject: [Python-checkins] python/dist/src/Lib/logging __init__.py, 1.14, 1.15 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/logging In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27566 Modified Files: __init__.py Log Message: Changed basicConfig() to add keyword arguments. Changes are backward-compatible. Added error checking to log() to check that level is an integer, and raise a TypeError if not (as long as raiseExceptions is set). Minor documentation corrections. Index: __init__.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/logging/__init__.py,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** __init__.py 28 Feb 2004 16:03:58 -0000 1.14 --- __init__.py 3 Jul 2004 11:47:26 -0000 1.15 *************** *** 37,42 **** __author__ = "Vinay Sajip " __status__ = "beta" ! __version__ = "0.4.9.2" ! __date__ = "28 February 2004" #--------------------------------------------------------------------------- --- 37,42 ---- __author__ = "Vinay Sajip " __status__ = "beta" ! __version__ = "0.4.9.3" ! __date__ = "03 July 2004" #--------------------------------------------------------------------------- *************** *** 114,119 **** INFO, DEBUG) then you get the corresponding string. If you have associated levels with names using addLevelName then the name you have ! associated with 'level' is returned. Otherwise, the string ! "Level %s" % level is returned. """ return _levelNames.get(level, ("Level %s" % level)) --- 114,123 ---- INFO, DEBUG) then you get the corresponding string. If you have associated levels with names using addLevelName then the name you have ! associated with 'level' is returned. ! ! If a numeric value corresponding to one of the defined levels is passed ! in, the corresponding string representation is returned. ! ! Otherwise, the string "Level %s" % level is returned. """ return _levelNames.get(level, ("Level %s" % level)) *************** *** 969,972 **** --- 973,981 ---- logger.log(level, "We have a %s", "mysterious problem", exc_info=1) """ + if type(level) != types.IntType: + if raiseExceptions: + raise TypeError, "level must be an integer" + else: + return if self.manager.disable >= level: return *************** *** 1107,1121 **** BASIC_FORMAT = "%(levelname)s:%(name)s:%(message)s" ! def basicConfig(): """ ! Do basic configuration for the logging system by creating a ! StreamHandler with a default Formatter and adding it to the ! root logger. """ if len(root.handlers) == 0: ! hdlr = StreamHandler() ! fmt = Formatter(BASIC_FORMAT) hdlr.setFormatter(fmt) root.addHandler(hdlr) #--------------------------------------------------------------------------- --- 1116,1167 ---- BASIC_FORMAT = "%(levelname)s:%(name)s:%(message)s" ! def basicConfig(**kwargs): """ ! Do basic configuration for the logging system. ! ! This function does nothing if the root logger already has handlers ! configured. It is a convenience method intended for use by simple scripts ! to do one-shot configuration of the logging package. ! ! The default behaviour is to create a StreamHandler which writes to ! sys.stderr, set a formatter using the BASIC_FORMAT format string, and ! add the handler to the root logger. ! ! A number of optional keyword arguments may be specified, which can alter ! the default behaviour. ! ! filename Specifies that a FileHandler be created, using the specified ! filename, rather than a StreamHandler. ! filemode Specifies the mode to open the file, if filename is specified ! (if filemode is unspecified, it defaults to "a"). ! format Use the specified format string for the handler. ! datefmt Use the specified date/time format. ! level Set the root logger level to the specified level. ! stream Use the specified stream to initialize the StreamHandler. Note ! that this argument is incompatible with 'filename' - if both ! are present, 'stream' is ignored. ! ! Note that you could specify a stream created using open(filename, mode) ! rather than passing the filename and mode in. However, it should be ! remembered that StreamHandler does not close its stream (since it may be ! using sys.stdout or sys.stderr), whereas FileHandler closes its stream ! when the handler is closed. """ if len(root.handlers) == 0: ! filename = kwargs.get("filename") ! if filename: ! mode = kwargs.get("filemode", "a") ! hdlr = FileHandler(filename, mode) ! else: ! stream = kwargs.get("stream") ! hdlr = StreamHandler(stream) ! fs = kwargs.get("format", BASIC_FORMAT) ! dfs = kwargs.get("datefmt", None) ! fmt = Formatter(fs, dfs) hdlr.setFormatter(fmt) root.addHandler(hdlr) + level = kwargs.get("level") + if level: + root.setLevel(level) #--------------------------------------------------------------------------- From vsajip at users.sourceforge.net Sat Jul 3 07:48:37 2004 From: vsajip at users.sourceforge.net (vsajip@users.sourceforge.net) Date: Sat Jul 3 07:48:41 2004 Subject: [Python-checkins] python/dist/src/Lib/logging handlers.py, 1.12, 1.13 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/logging In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27656 Modified Files: handlers.py Log Message: Refactored RotatingFileHandler to create a base class for rotating handlers. Added TimedRotatingFileHandler. Index: handlers.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/logging/handlers.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** handlers.py 8 Mar 2004 16:57:19 -0000 1.12 --- handlers.py 3 Jul 2004 11:48:34 -0000 1.13 *************** *** 28,32 **** """ ! import sys, logging, socket, types, os, string, cPickle, struct, time # --- 28,32 ---- """ ! import sys, logging, socket, types, os, string, cPickle, struct, time, glob # *************** *** 40,45 **** SYSLOG_UDP_PORT = 514 ! class RotatingFileHandler(logging.FileHandler): def __init__(self, filename, mode="a", maxBytes=0, backupCount=0): """ --- 40,71 ---- SYSLOG_UDP_PORT = 514 + class BaseRotatingHandler(logging.FileHandler): + """ + Base class for handlers that rotate log files at a certain point. + Not meant to be instantiated directly. Instead, use RotatingFileHandler + or TimedRotatingFileHandler. + """ + def __init__(self, filename, mode): + """ + Use the specified filename for streamed logging + """ + logging.FileHandler.__init__(self, filename, mode) ! def emit(self, record): ! """ ! Emit a record. ! ! Output the record to the file, catering for rollover as described ! in doRollover(). ! """ ! if self.shouldRollover(record): ! self.doRollover() ! logging.FileHandler.emit(self, record) ! ! class RotatingFileHandler(BaseRotatingHandler): ! """ ! Handler for logging to a set of files, which switches from one file ! to the next when the current file reaches a certain size. ! """ def __init__(self, filename, mode="a", maxBytes=0, backupCount=0): """ *************** *** 63,71 **** If maxBytes is zero, rollover never occurs. """ ! logging.FileHandler.__init__(self, filename, mode) self.maxBytes = maxBytes self.backupCount = backupCount - if maxBytes > 0: - self.mode = "a" def doRollover(self): --- 89,98 ---- If maxBytes is zero, rollover never occurs. """ ! self.mode = mode ! if maxBytes > 0: ! self.mode = "a" # doesn't make sense otherwise! ! BaseRotatingHandler.__init__(self, filename, self.mode) self.maxBytes = maxBytes self.backupCount = backupCount def doRollover(self): *************** *** 91,100 **** self.stream = open(self.baseFilename, "w") ! def emit(self, record): """ ! Emit a record. ! Output the record to the file, catering for rollover as described ! in doRollover(). """ if self.maxBytes > 0: # are we rolling over? --- 118,127 ---- self.stream = open(self.baseFilename, "w") ! def shouldRollover(self, record): """ ! Determine if rollover should occur. ! Basically, see if the supplied record would cause the file to exceed ! the size limit we have. """ if self.maxBytes > 0: # are we rolling over? *************** *** 102,108 **** self.stream.seek(0, 2) #due to non-posix-compliant Windows feature if self.stream.tell() + len(msg) >= self.maxBytes: ! self.doRollover() ! logging.FileHandler.emit(self, record) class SocketHandler(logging.Handler): --- 129,264 ---- self.stream.seek(0, 2) #due to non-posix-compliant Windows feature if self.stream.tell() + len(msg) >= self.maxBytes: ! return 1 ! return 0 ! ! class TimedRotatingFileHandler(BaseRotatingHandler): ! """ ! Handler for logging to a file, rotating the log file at certain timed ! intervals. ! ! If backupCount is > 0, when rollover is done, no more than backupCount ! files are kept - the oldest ones are deleted. ! """ ! def __init__(self, filename, when='h', interval=1, backupCount=0): ! BaseRotatingHandler.__init__(self, filename, 'a') ! self.when = string.upper(when) ! self.backupCount = backupCount ! # Calculate the real rollover interval, which is just the number of ! # seconds between rollovers. Also set the filename suffix used when ! # a rollover occurs. Current 'when' events supported: ! # S - Seconds ! # M - Minutes ! # H - Hours ! # D - Days ! # midnight - roll over at midnight ! # W{0-6} - roll over on a certain day; 0 - Monday ! # ! # Case of the 'when' specifier is not important; lower or upper case ! # will work. ! currentTime = int(time.time()) ! if self.when == 'S': ! self.interval = 1 # one second ! self.suffix = "%Y-%m-%d_%H-%M-%S" ! elif self.when == 'M': ! self.interval = 60 # one minute ! self.suffix = "%Y-%m-%d_%H-%M" ! elif self.when == 'H': ! self.interval = 60 * 60 # one hour ! self.suffix = "%Y-%m-%d_%H" ! elif self.when == 'D' or self.when == 'MIDNIGHT': ! self.interval = 60 * 60 * 24 # one day ! self.suffix = "%Y-%m-%d" ! elif self.when.startswith('W'): ! self.interval = 60 * 60 * 24 * 7 # one week ! if len(self.when) != 2: ! raise ValueError("You must specify a day for weekly rollover from 0 to 6 (0 is Monday): %s" % self.when) ! if self.when[1] < '0' or self.when[1] > '6': ! raise ValueError("Invalid day specified for weekly rollover: %s" % self.when) ! self.dayOfWeek = int(self.when[1]) ! self.suffix = "%Y-%m-%d" ! else: ! raise ValueError("Invalid rollover interval specified: %s" % self.when) ! ! self.interval *= interval # multiply by units requested ! self.rolloverAt = currentTime + self.interval + # If we are rolling over at midnight or weekly, then the interval is already known. + # What we need to figure out is WHEN the next interval is. In other words, + # if you are rolling over at midnight, then your base interval is 1 day, + # but you want to start that one day clock at midnight, not now. So, we + # have to fudge the rolloverAt value in order to trigger the first rollover + # at the right time. After that, the regular interval will take care of + # the rest. Note that this code doesn't care about leap seconds. :) + if self.when == 'MIDNIGHT' or self.when.startswith('W'): + # This could be done with less code, but I wanted it to be clear + t = time.localtime(currentTime) + currentHour = t[3] + currentMinute = t[4] + currentSecond = t[5] + # r is the number of seconds left between now and midnight + r = (24 - currentHour) * 60 * 60 # number of hours in seconds + r += (59 - currentMinute) * 60 # plus the number of minutes (in secs) + r += (59 - currentSecond) # plus the number of seconds + self.rolloverAt = currentTime + r + # If we are rolling over on a certain day, add in the number of days until + # the next rollover, but offset by 1 since we just calculated the time + # until the next day starts. There are three cases: + # Case 1) The day to rollover is today; in this case, do nothing + # Case 2) The day to rollover is further in the interval (i.e., today is + # day 2 (Wednesday) and rollover is on day 6 (Sunday). Days to + # next rollover is simply 6 - 2 - 1, or 3. + # Case 3) The day to rollover is behind us in the interval (i.e., today + # is day 5 (Saturday) and rollover is on day 3 (Thursday). + # Days to rollover is 6 - 5 + 3, or 4. In this case, it's the + # number of days left in the current week (1) plus the number + # of days in the next week until the rollover day (3). + if when.startswith('W'): + day = t[6] # 0 is Monday + if day > self.dayOfWeek: + daysToWait = (day - self.dayOfWeek) - 1 + self.rolloverAt += (daysToWait * (60 * 60 * 24)) + if day < self.dayOfWeek: + daysToWait = (6 - self.dayOfWeek) + day + self.rolloverAt += (daysToWait * (60 * 60 * 24)) + + print "Will rollover at %d, %d seconds from now" % (self.rolloverAt, self.rolloverAt - currentTime) + + def shouldRollover(self, record): + """ + Determine if rollover should occur + + record is not used, as we are just comparing times, but it is needed so + the method siguratures are the same + """ + t = int(time.time()) + if t >= self.rolloverAt: + return 1 + print "No need to rollover: %d, %d" % (t, self.rolloverAt) + return 0 + + def doRollover(self): + """ + do a rollover; in this case, a date/time stamp is appended to the filename + when the rollover happens. However, you want the file to be named for the + start of the interval, not the current time. If there is a backup count, + then we have to get a list of matching filenames, sort them and remove + the one with the oldest suffix. + """ + self.stream.close() + # get the time that this sequence started at and make it a TimeTuple + t = self.rolloverAt - self.interval + timeTuple = time.localtime(t) + dfn = self.baseFilename + "." + time.strftime(self.suffix, timeTuple) + if os.path.exists(dfn): + os.remove(dfn) + os.rename(self.baseFilename, dfn) + if self.backupCount > 0: + # find the oldest log file and delete it + s = glob.glob(self.baseFilename + ".20*") + if len(s) > self.backupCount: + os.remove(s[0]) + print "%s -> %s" % (self.baseFilename, dfn) + self.stream = open(self.baseFilename, "w") + self.rolloverAt = int(time.time()) + self.interval class SocketHandler(logging.Handler): From rhettinger at users.sourceforge.net Sat Jul 3 08:26:24 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Jul 3 08:26:29 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_decimal.py,1.2,1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv519/test Modified Files: test_decimal.py Log Message: * Make the tests independent of the default precision. * Change the default precision to 28 (to match VB's decimal type). Index: test_decimal.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_decimal.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** test_decimal.py 3 Jul 2004 10:02:28 -0000 1.2 --- test_decimal.py 3 Jul 2004 12:26:21 -0000 1.3 *************** *** 35,38 **** --- 35,45 ---- import threading + # Tests are built around these assumed context defaults + DefaultContext.prec=9 + DefaultContext.rounding=ROUND_HALF_EVEN + DefaultContext.trap_enablers=dict.fromkeys(Signals, 0) + setcontext(DefaultContext) + + TESTDATADIR = 'decimaltestdata' if __name__ == '__main__': From rhettinger at users.sourceforge.net Sat Jul 3 08:26:24 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Jul 3 08:26:31 2004 Subject: [Python-checkins] python/dist/src/Lib decimal.py,1.3,1.4 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv519 Modified Files: decimal.py Log Message: * Make the tests independent of the default precision. * Change the default precision to 28 (to match VB's decimal type). Index: decimal.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/decimal.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** decimal.py 3 Jul 2004 10:02:27 -0000 1.3 --- decimal.py 3 Jul 2004 12:26:21 -0000 1.4 *************** *** 11,15 **** # Todo: # Provide a clean way of attaching monetary format representations - # Make tests independent of DefaultContext.prec == 9 --- 11,14 ---- *************** *** 42,45 **** --- 41,45 ---- >>> from decimal import * + >>> getcontext().prec=9 >>> Decimal(0) Decimal("0") *************** *** 130,134 **** # Module parameters ! 'SINGLE_PRECISION', 'DEFAULT_MAX_EXPONENT', 'DEFAULT_MIN_EXPONENT', # Constants for use in setting up contexts --- 130,134 ---- # Module parameters ! 'DEFAULT_MAX_EXPONENT', 'DEFAULT_MIN_EXPONENT', # Constants for use in setting up contexts *************** *** 150,156 **** xor = operator.xor - #Precision - SINGLE_PRECISION = 9 - #Exponent Range DEFAULT_MAX_EXPONENT = 999999999 --- 150,153 ---- *************** *** 426,429 **** --- 423,428 ---- def setcontext(context): """Set this thread's context to context.""" + if context == DefaultContext: + context = Context() threading.currentThread().__decimal_context__ = context *************** *** 2266,2276 **** the plus operation on the operand. ! >>> DefaultContext.abs(Decimal('2.1')) Decimal("2.1") ! >>> DefaultContext.abs(Decimal('-100')) Decimal("100") ! >>> DefaultContext.abs(Decimal('101.5')) Decimal("101.5") ! >>> DefaultContext.abs(Decimal('-101.5')) Decimal("101.5") """ --- 2265,2275 ---- the plus operation on the operand. ! >>> ExtendedDefaultContext.abs(Decimal('2.1')) Decimal("2.1") ! >>> ExtendedDefaultContext.abs(Decimal('-100')) Decimal("100") ! >>> ExtendedDefaultContext.abs(Decimal('101.5')) Decimal("101.5") ! >>> ExtendedDefaultContext.abs(Decimal('-101.5')) Decimal("101.5") """ *************** *** 2280,2286 **** """Return the sum of the two operands. ! >>> DefaultContext.add(Decimal('12'), Decimal('7.00')) Decimal("19.00") ! >>> DefaultContext.add(Decimal('1E+2'), Decimal('1.01E+4')) Decimal("1.02E+4") """ --- 2279,2285 ---- """Return the sum of the two operands. ! >>> ExtendedDefaultContext.add(Decimal('12'), Decimal('7.00')) Decimal("19.00") ! >>> ExtendedDefaultContext.add(Decimal('1E+2'), Decimal('1.01E+4')) Decimal("1.02E+4") """ *************** *** 2304,2318 **** zero or negative zero, or '1' if the result is greater than zero. ! >>> DefaultContext.compare(Decimal('2.1'), Decimal('3')) Decimal("-1") ! >>> DefaultContext.compare(Decimal('2.1'), Decimal('2.1')) Decimal("0") ! >>> DefaultContext.compare(Decimal('2.1'), Decimal('2.10')) Decimal("0") ! >>> DefaultContext.compare(Decimal('3'), Decimal('2.1')) Decimal("1") ! >>> DefaultContext.compare(Decimal('2.1'), Decimal('-3')) Decimal("1") ! >>> DefaultContext.compare(Decimal('-3'), Decimal('2.1')) Decimal("-1") """ --- 2303,2317 ---- zero or negative zero, or '1' if the result is greater than zero. ! >>> ExtendedDefaultContext.compare(Decimal('2.1'), Decimal('3')) Decimal("-1") ! >>> ExtendedDefaultContext.compare(Decimal('2.1'), Decimal('2.1')) Decimal("0") ! >>> ExtendedDefaultContext.compare(Decimal('2.1'), Decimal('2.10')) Decimal("0") ! >>> ExtendedDefaultContext.compare(Decimal('3'), Decimal('2.1')) Decimal("1") ! >>> ExtendedDefaultContext.compare(Decimal('2.1'), Decimal('-3')) Decimal("1") ! >>> ExtendedDefaultContext.compare(Decimal('-3'), Decimal('2.1')) Decimal("-1") """ *************** *** 2322,2344 **** """Decimal division in a specified context. ! >>> DefaultContext.divide(Decimal('1'), Decimal('3')) Decimal("0.333333333") ! >>> DefaultContext.divide(Decimal('2'), Decimal('3')) Decimal("0.666666667") ! >>> DefaultContext.divide(Decimal('5'), Decimal('2')) Decimal("2.5") ! >>> DefaultContext.divide(Decimal('1'), Decimal('10')) Decimal("0.1") ! >>> DefaultContext.divide(Decimal('12'), Decimal('12')) Decimal("1") ! >>> DefaultContext.divide(Decimal('8.00'), Decimal('2')) Decimal("4.00") ! >>> DefaultContext.divide(Decimal('2.400'), Decimal('2.0')) Decimal("1.20") ! >>> DefaultContext.divide(Decimal('1000'), Decimal('100')) Decimal("10") ! >>> DefaultContext.divide(Decimal('1000'), Decimal('1')) Decimal("1000") ! >>> DefaultContext.divide(Decimal('2.40E+6'), Decimal('2')) Decimal("1.20E+6") """ --- 2321,2343 ---- """Decimal division in a specified context. ! >>> ExtendedDefaultContext.divide(Decimal('1'), Decimal('3')) Decimal("0.333333333") ! >>> ExtendedDefaultContext.divide(Decimal('2'), Decimal('3')) Decimal("0.666666667") ! >>> ExtendedDefaultContext.divide(Decimal('5'), Decimal('2')) Decimal("2.5") ! >>> ExtendedDefaultContext.divide(Decimal('1'), Decimal('10')) Decimal("0.1") ! >>> ExtendedDefaultContext.divide(Decimal('12'), Decimal('12')) Decimal("1") ! >>> ExtendedDefaultContext.divide(Decimal('8.00'), Decimal('2')) Decimal("4.00") ! >>> ExtendedDefaultContext.divide(Decimal('2.400'), Decimal('2.0')) Decimal("1.20") ! >>> ExtendedDefaultContext.divide(Decimal('1000'), Decimal('100')) Decimal("10") ! >>> ExtendedDefaultContext.divide(Decimal('1000'), Decimal('1')) Decimal("1000") ! >>> ExtendedDefaultContext.divide(Decimal('2.40E+6'), Decimal('2')) Decimal("1.20E+6") """ *************** *** 2348,2356 **** """Divides two numbers and returns the integer part of the result. ! >>> DefaultContext.divide_int(Decimal('2'), Decimal('3')) Decimal("0") ! >>> DefaultContext.divide_int(Decimal('10'), Decimal('3')) Decimal("3") ! >>> DefaultContext.divide_int(Decimal('1'), Decimal('0.3')) Decimal("3") """ --- 2347,2355 ---- """Divides two numbers and returns the integer part of the result. ! >>> ExtendedDefaultContext.divide_int(Decimal('2'), Decimal('3')) Decimal("0") ! >>> ExtendedDefaultContext.divide_int(Decimal('10'), Decimal('3')) Decimal("3") ! >>> ExtendedDefaultContext.divide_int(Decimal('1'), Decimal('0.3')) Decimal("3") """ *************** *** 2369,2377 **** infinity) of the two operands is chosen as the result. ! >>> DefaultContext.max(Decimal('3'), Decimal('2')) Decimal("3") ! >>> DefaultContext.max(Decimal('-10'), Decimal('3')) Decimal("3") ! >>> DefaultContext.max(Decimal('1.0'), Decimal('1')) Decimal("1.0") """ --- 2368,2376 ---- infinity) of the two operands is chosen as the result. ! >>> ExtendedDefaultContext.max(Decimal('3'), Decimal('2')) Decimal("3") ! >>> ExtendedDefaultContext.max(Decimal('-10'), Decimal('3')) Decimal("3") ! >>> ExtendedDefaultContext.max(Decimal('1.0'), Decimal('1')) Decimal("1.0") """ *************** *** 2387,2395 **** infinity) of the two operands is chosen as the result. ! >>> DefaultContext.min(Decimal('3'), Decimal('2')) Decimal("2") ! >>> DefaultContext.min(Decimal('-10'), Decimal('3')) Decimal("-10") ! >>> DefaultContext.min(Decimal('1.0'), Decimal('1')) Decimal("1.0") """ --- 2386,2394 ---- infinity) of the two operands is chosen as the result. ! >>> ExtendedDefaultContext.min(Decimal('3'), Decimal('2')) Decimal("2") ! >>> ExtendedDefaultContext.min(Decimal('-10'), Decimal('3')) Decimal("-10") ! >>> ExtendedDefaultContext.min(Decimal('1.0'), Decimal('1')) Decimal("1.0") """ *************** *** 2403,2409 **** has the same exponent as the operand. ! >>> DefaultContext.minus(Decimal('1.3')) Decimal("-1.3") ! >>> DefaultContext.minus(Decimal('-1.3')) Decimal("1.3") """ --- 2402,2408 ---- has the same exponent as the operand. ! >>> ExtendedDefaultContext.minus(Decimal('1.3')) Decimal("-1.3") ! >>> ExtendedDefaultContext.minus(Decimal('-1.3')) Decimal("1.3") """ *************** *** 2418,2430 **** of the two operands. ! >>> DefaultContext.multiply(Decimal('1.20'), Decimal('3')) Decimal("3.60") ! >>> DefaultContext.multiply(Decimal('7'), Decimal('3')) Decimal("21") ! >>> DefaultContext.multiply(Decimal('0.9'), Decimal('0.8')) Decimal("0.72") ! >>> DefaultContext.multiply(Decimal('0.9'), Decimal('-0')) Decimal("-0.0") ! >>> DefaultContext.multiply(Decimal('654321'), Decimal('654321')) Decimal("4.28135971E+11") """ --- 2417,2429 ---- of the two operands. ! >>> ExtendedDefaultContext.multiply(Decimal('1.20'), Decimal('3')) Decimal("3.60") ! >>> ExtendedDefaultContext.multiply(Decimal('7'), Decimal('3')) Decimal("21") ! >>> ExtendedDefaultContext.multiply(Decimal('0.9'), Decimal('0.8')) Decimal("0.72") ! >>> ExtendedDefaultContext.multiply(Decimal('0.9'), Decimal('-0')) Decimal("-0.0") ! >>> ExtendedDefaultContext.multiply(Decimal('654321'), Decimal('654321')) Decimal("4.28135971E+11") """ *************** *** 2437,2451 **** result. ! >>> DefaultContext.normalize(Decimal('2.1')) Decimal("2.1") ! >>> DefaultContext.normalize(Decimal('-2.0')) Decimal("-2") ! >>> DefaultContext.normalize(Decimal('1.200')) Decimal("1.2") ! >>> DefaultContext.normalize(Decimal('-120')) Decimal("-1.2E+2") ! >>> DefaultContext.normalize(Decimal('120.00')) Decimal("1.2E+2") ! >>> DefaultContext.normalize(Decimal('0.00')) Decimal("0") """ --- 2436,2450 ---- result. ! >>> ExtendedDefaultContext.normalize(Decimal('2.1')) Decimal("2.1") ! >>> ExtendedDefaultContext.normalize(Decimal('-2.0')) Decimal("-2") ! >>> ExtendedDefaultContext.normalize(Decimal('1.200')) Decimal("1.2") ! >>> ExtendedDefaultContext.normalize(Decimal('-120')) Decimal("-1.2E+2") ! >>> ExtendedDefaultContext.normalize(Decimal('120.00')) Decimal("1.2E+2") ! >>> ExtendedDefaultContext.normalize(Decimal('0.00')) Decimal("0") """ *************** *** 2459,2465 **** has the same exponent as the operand. ! >>> DefaultContext.plus(Decimal('1.3')) Decimal("1.3") ! >>> DefaultContext.plus(Decimal('-1.3')) Decimal("-1.3") """ --- 2458,2464 ---- has the same exponent as the operand. ! >>> ExtendedDefaultContext.plus(Decimal('1.3')) Decimal("1.3") ! >>> ExtendedDefaultContext.plus(Decimal('-1.3')) Decimal("-1.3") """ *************** *** 2484,2514 **** continues. ! >>> DefaultContext.power(Decimal('2'), Decimal('3')) Decimal("8") ! >>> DefaultContext.power(Decimal('2'), Decimal('-3')) Decimal("0.125") ! >>> DefaultContext.power(Decimal('1.7'), Decimal('8')) Decimal("69.7575744") ! >>> DefaultContext.power(Decimal('Infinity'), Decimal('-2')) Decimal("0") ! >>> DefaultContext.power(Decimal('Infinity'), Decimal('-1')) Decimal("0") ! >>> DefaultContext.power(Decimal('Infinity'), Decimal('0')) Decimal("1") ! >>> DefaultContext.power(Decimal('Infinity'), Decimal('1')) Decimal("Infinity") ! >>> DefaultContext.power(Decimal('Infinity'), Decimal('2')) Decimal("Infinity") ! >>> DefaultContext.power(Decimal('-Infinity'), Decimal('-2')) Decimal("0") ! >>> DefaultContext.power(Decimal('-Infinity'), Decimal('-1')) Decimal("-0") ! >>> DefaultContext.power(Decimal('-Infinity'), Decimal('0')) Decimal("1") ! >>> DefaultContext.power(Decimal('-Infinity'), Decimal('1')) Decimal("-Infinity") ! >>> DefaultContext.power(Decimal('-Infinity'), Decimal('2')) Decimal("Infinity") ! >>> DefaultContext.power(Decimal('0'), Decimal('0')) Decimal("NaN") """ --- 2483,2513 ---- continues. ! >>> ExtendedDefaultContext.power(Decimal('2'), Decimal('3')) Decimal("8") ! >>> ExtendedDefaultContext.power(Decimal('2'), Decimal('-3')) Decimal("0.125") ! >>> ExtendedDefaultContext.power(Decimal('1.7'), Decimal('8')) Decimal("69.7575744") ! >>> ExtendedDefaultContext.power(Decimal('Infinity'), Decimal('-2')) Decimal("0") ! >>> ExtendedDefaultContext.power(Decimal('Infinity'), Decimal('-1')) Decimal("0") ! >>> ExtendedDefaultContext.power(Decimal('Infinity'), Decimal('0')) Decimal("1") ! >>> ExtendedDefaultContext.power(Decimal('Infinity'), Decimal('1')) Decimal("Infinity") ! >>> ExtendedDefaultContext.power(Decimal('Infinity'), Decimal('2')) Decimal("Infinity") ! >>> ExtendedDefaultContext.power(Decimal('-Infinity'), Decimal('-2')) Decimal("0") ! >>> ExtendedDefaultContext.power(Decimal('-Infinity'), Decimal('-1')) Decimal("-0") ! >>> ExtendedDefaultContext.power(Decimal('-Infinity'), Decimal('0')) Decimal("1") ! >>> ExtendedDefaultContext.power(Decimal('-Infinity'), Decimal('1')) Decimal("-Infinity") ! >>> ExtendedDefaultContext.power(Decimal('-Infinity'), Decimal('2')) Decimal("Infinity") ! >>> ExtendedDefaultContext.power(Decimal('0'), Decimal('0')) Decimal("NaN") """ *************** *** 2533,2565 **** if the result is subnormal and inexact. ! >>> DefaultContext.quantize(Decimal('2.17'), Decimal('0.001')) Decimal("2.170") ! >>> DefaultContext.quantize(Decimal('2.17'), Decimal('0.01')) Decimal("2.17") ! >>> DefaultContext.quantize(Decimal('2.17'), Decimal('0.1')) Decimal("2.2") ! >>> DefaultContext.quantize(Decimal('2.17'), Decimal('1e+0')) Decimal("2") ! >>> DefaultContext.quantize(Decimal('2.17'), Decimal('1e+1')) Decimal("0E+1") ! >>> DefaultContext.quantize(Decimal('-Inf'), Decimal('Infinity')) Decimal("-Infinity") ! >>> DefaultContext.quantize(Decimal('2'), Decimal('Infinity')) Decimal("NaN") ! >>> DefaultContext.quantize(Decimal('-0.1'), Decimal('1')) Decimal("-0") ! >>> DefaultContext.quantize(Decimal('-0'), Decimal('1e+5')) Decimal("-0E+5") ! >>> DefaultContext.quantize(Decimal('+35236450.6'), Decimal('1e-2')) Decimal("NaN") ! >>> DefaultContext.quantize(Decimal('-35236450.6'), Decimal('1e-2')) Decimal("NaN") ! >>> DefaultContext.quantize(Decimal('217'), Decimal('1e-1')) Decimal("217.0") ! >>> DefaultContext.quantize(Decimal('217'), Decimal('1e-0')) Decimal("217") ! >>> DefaultContext.quantize(Decimal('217'), Decimal('1e+1')) Decimal("2.2E+2") ! >>> DefaultContext.quantize(Decimal('217'), Decimal('1e+2')) Decimal("2E+2") """ --- 2532,2564 ---- if the result is subnormal and inexact. ! >>> ExtendedDefaultContext.quantize(Decimal('2.17'), Decimal('0.001')) Decimal("2.170") ! >>> ExtendedDefaultContext.quantize(Decimal('2.17'), Decimal('0.01')) Decimal("2.17") ! >>> ExtendedDefaultContext.quantize(Decimal('2.17'), Decimal('0.1')) Decimal("2.2") ! >>> ExtendedDefaultContext.quantize(Decimal('2.17'), Decimal('1e+0')) Decimal("2") ! >>> ExtendedDefaultContext.quantize(Decimal('2.17'), Decimal('1e+1')) Decimal("0E+1") ! >>> ExtendedDefaultContext.quantize(Decimal('-Inf'), Decimal('Infinity')) Decimal("-Infinity") ! >>> ExtendedDefaultContext.quantize(Decimal('2'), Decimal('Infinity')) Decimal("NaN") ! >>> ExtendedDefaultContext.quantize(Decimal('-0.1'), Decimal('1')) Decimal("-0") ! >>> ExtendedDefaultContext.quantize(Decimal('-0'), Decimal('1e+5')) Decimal("-0E+5") ! >>> ExtendedDefaultContext.quantize(Decimal('+35236450.6'), Decimal('1e-2')) Decimal("NaN") ! >>> ExtendedDefaultContext.quantize(Decimal('-35236450.6'), Decimal('1e-2')) Decimal("NaN") ! >>> ExtendedDefaultContext.quantize(Decimal('217'), Decimal('1e-1')) Decimal("217.0") ! >>> ExtendedDefaultContext.quantize(Decimal('217'), Decimal('1e-0')) Decimal("217") ! >>> ExtendedDefaultContext.quantize(Decimal('217'), Decimal('1e+1')) Decimal("2.2E+2") ! >>> ExtendedDefaultContext.quantize(Decimal('217'), Decimal('1e+2')) Decimal("2E+2") """ *************** *** 2578,2592 **** remainder cannot be calculated). ! >>> DefaultContext.remainder(Decimal('2.1'), Decimal('3')) Decimal("2.1") ! >>> DefaultContext.remainder(Decimal('10'), Decimal('3')) Decimal("1") ! >>> DefaultContext.remainder(Decimal('-10'), Decimal('3')) Decimal("-1") ! >>> DefaultContext.remainder(Decimal('10.2'), Decimal('1')) Decimal("0.2") ! >>> DefaultContext.remainder(Decimal('10'), Decimal('0.3')) Decimal("0.1") ! >>> DefaultContext.remainder(Decimal('3.6'), Decimal('1.3')) Decimal("1.0") """ --- 2577,2591 ---- remainder cannot be calculated). ! >>> ExtendedDefaultContext.remainder(Decimal('2.1'), Decimal('3')) Decimal("2.1") ! >>> ExtendedDefaultContext.remainder(Decimal('10'), Decimal('3')) Decimal("1") ! >>> ExtendedDefaultContext.remainder(Decimal('-10'), Decimal('3')) Decimal("-1") ! >>> ExtendedDefaultContext.remainder(Decimal('10.2'), Decimal('1')) Decimal("0.2") ! >>> ExtendedDefaultContext.remainder(Decimal('10'), Decimal('0.3')) Decimal("0.1") ! >>> ExtendedDefaultContext.remainder(Decimal('3.6'), Decimal('1.3')) Decimal("1.0") """ *************** *** 2603,2619 **** remainder cannot be calculated). ! >>> DefaultContext.remainder_near(Decimal('2.1'), Decimal('3')) Decimal("-0.9") ! >>> DefaultContext.remainder_near(Decimal('10'), Decimal('6')) Decimal("-2") ! >>> DefaultContext.remainder_near(Decimal('10'), Decimal('3')) Decimal("1") ! >>> DefaultContext.remainder_near(Decimal('-10'), Decimal('3')) Decimal("-1") ! >>> DefaultContext.remainder_near(Decimal('10.2'), Decimal('1')) Decimal("0.2") ! >>> DefaultContext.remainder_near(Decimal('10'), Decimal('0.3')) Decimal("0.1") ! >>> DefaultContext.remainder_near(Decimal('3.6'), Decimal('1.3')) Decimal("-0.3") """ --- 2602,2618 ---- remainder cannot be calculated). ! >>> ExtendedDefaultContext.remainder_near(Decimal('2.1'), Decimal('3')) Decimal("-0.9") ! >>> ExtendedDefaultContext.remainder_near(Decimal('10'), Decimal('6')) Decimal("-2") ! >>> ExtendedDefaultContext.remainder_near(Decimal('10'), Decimal('3')) Decimal("1") ! >>> ExtendedDefaultContext.remainder_near(Decimal('-10'), Decimal('3')) Decimal("-1") ! >>> ExtendedDefaultContext.remainder_near(Decimal('10.2'), Decimal('1')) Decimal("0.2") ! >>> ExtendedDefaultContext.remainder_near(Decimal('10'), Decimal('0.3')) Decimal("0.1") ! >>> ExtendedDefaultContext.remainder_near(Decimal('3.6'), Decimal('1.3')) Decimal("-0.3") """ *************** *** 2626,2636 **** either operand. ! >>> DefaultContext.same_quantum(Decimal('2.17'), Decimal('0.001')) False ! >>> DefaultContext.same_quantum(Decimal('2.17'), Decimal('0.01')) True ! >>> DefaultContext.same_quantum(Decimal('2.17'), Decimal('1')) False ! >>> DefaultContext.same_quantum(Decimal('Inf'), Decimal('-Inf')) True """ --- 2625,2635 ---- either operand. ! >>> ExtendedDefaultContext.same_quantum(Decimal('2.17'), Decimal('0.001')) False ! >>> ExtendedDefaultContext.same_quantum(Decimal('2.17'), Decimal('0.01')) True ! >>> ExtendedDefaultContext.same_quantum(Decimal('2.17'), Decimal('1')) False ! >>> ExtendedDefaultContext.same_quantum(Decimal('Inf'), Decimal('-Inf')) True """ *************** *** 2643,2664 **** algorithm. ! >>> DefaultContext.sqrt(Decimal('0')) Decimal("0") ! >>> DefaultContext.sqrt(Decimal('-0')) Decimal("-0") ! >>> DefaultContext.sqrt(Decimal('0.39')) Decimal("0.624499800") ! >>> DefaultContext.sqrt(Decimal('100')) Decimal("10") ! >>> DefaultContext.sqrt(Decimal('1')) Decimal("1") ! >>> DefaultContext.sqrt(Decimal('1.0')) Decimal("1.0") ! >>> DefaultContext.sqrt(Decimal('1.00')) Decimal("1.0") ! >>> DefaultContext.sqrt(Decimal('7')) Decimal("2.64575131") ! >>> DefaultContext.sqrt(Decimal('10')) Decimal("3.16227766") """ return a.sqrt(context=self) --- 2642,2665 ---- algorithm. ! >>> ExtendedDefaultContext.sqrt(Decimal('0')) Decimal("0") ! >>> ExtendedDefaultContext.sqrt(Decimal('-0')) Decimal("-0") ! >>> ExtendedDefaultContext.sqrt(Decimal('0.39')) Decimal("0.624499800") ! >>> ExtendedDefaultContext.sqrt(Decimal('100')) Decimal("10") ! >>> ExtendedDefaultContext.sqrt(Decimal('1')) Decimal("1") ! >>> ExtendedDefaultContext.sqrt(Decimal('1.0')) Decimal("1.0") ! >>> ExtendedDefaultContext.sqrt(Decimal('1.00')) Decimal("1.0") ! >>> ExtendedDefaultContext.sqrt(Decimal('7')) Decimal("2.64575131") ! >>> ExtendedDefaultContext.sqrt(Decimal('10')) Decimal("3.16227766") + >>> ExtendedDefaultContext.prec + 9 """ return a.sqrt(context=self) *************** *** 2667,2675 **** """Return the sum of the two operands. ! >>> DefaultContext.subtract(Decimal('1.3'), Decimal('1.07')) Decimal("0.23") ! >>> DefaultContext.subtract(Decimal('1.3'), Decimal('1.30')) Decimal("0.00") ! >>> DefaultContext.subtract(Decimal('1.3'), Decimal('2.07')) Decimal("-0.77") """ --- 2668,2676 ---- """Return the sum of the two operands. ! >>> ExtendedDefaultContext.subtract(Decimal('1.3'), Decimal('1.07')) Decimal("0.23") ! >>> ExtendedDefaultContext.subtract(Decimal('1.3'), Decimal('1.30')) Decimal("0.00") ! >>> ExtendedDefaultContext.subtract(Decimal('1.3'), Decimal('2.07')) Decimal("-0.77") """ *************** *** 2699,2717 **** be set. The rounding mode is taken from the context. ! >>> DefaultContext.to_integral(Decimal('2.1')) Decimal("2") ! >>> DefaultContext.to_integral(Decimal('100')) Decimal("100") ! >>> DefaultContext.to_integral(Decimal('100.0')) Decimal("100") ! >>> DefaultContext.to_integral(Decimal('101.5')) Decimal("102") ! >>> DefaultContext.to_integral(Decimal('-101.5')) Decimal("-102") ! >>> DefaultContext.to_integral(Decimal('10E+5')) Decimal("1.0E+6") ! >>> DefaultContext.to_integral(Decimal('7.89E+77')) Decimal("7.89E+77") ! >>> DefaultContext.to_integral(Decimal('-Inf')) Decimal("-Infinity") """ --- 2700,2718 ---- be set. The rounding mode is taken from the context. ! >>> ExtendedDefaultContext.to_integral(Decimal('2.1')) Decimal("2") ! >>> ExtendedDefaultContext.to_integral(Decimal('100')) Decimal("100") ! >>> ExtendedDefaultContext.to_integral(Decimal('100.0')) Decimal("100") ! >>> ExtendedDefaultContext.to_integral(Decimal('101.5')) Decimal("102") ! >>> ExtendedDefaultContext.to_integral(Decimal('-101.5')) Decimal("-102") ! >>> ExtendedDefaultContext.to_integral(Decimal('10E+5')) Decimal("1.0E+6") ! >>> ExtendedDefaultContext.to_integral(Decimal('7.89E+77')) Decimal("7.89E+77") ! >>> ExtendedDefaultContext.to_integral(Decimal('-Inf')) Decimal("-Infinity") """ *************** *** 2963,2967 **** DefaultContext = Context( ! prec=SINGLE_PRECISION, rounding=ROUND_HALF_EVEN, trap_enablers=dict.fromkeys(Signals, 0), flags=None, --- 2964,2968 ---- DefaultContext = Context( ! prec=28, rounding=ROUND_HALF_EVEN, trap_enablers=dict.fromkeys(Signals, 0), flags=None, *************** *** 2982,2986 **** ExtendedDefaultContext = Context( ! prec=SINGLE_PRECISION, rounding=ROUND_HALF_EVEN, trap_enablers=dict.fromkeys(Signals, 0), flags=None, --- 2983,2987 ---- ExtendedDefaultContext = Context( ! prec=9, rounding=ROUND_HALF_EVEN, trap_enablers=dict.fromkeys(Signals, 0), flags=None, From rhettinger at users.sourceforge.net Sat Jul 3 09:49:05 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Jul 3 09:49:09 2004 Subject: [Python-checkins] python/dist/src/Lib decimal.py,1.4,1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13623 Modified Files: decimal.py Log Message: Namespace cleanups: * delete temporary globals immediately after use * move a global into a class variable * Rename BasicDefaultContext and ExtendedDefaultContext to BasicContext and ExtendedContext. Index: decimal.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/decimal.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** decimal.py 3 Jul 2004 12:26:21 -0000 1.4 --- decimal.py 3 Jul 2004 13:48:56 -0000 1.5 *************** *** 121,125 **** # Contexts ! 'DefaultContext', 'BasicDefaultContext', 'ExtendedDefaultContext', # Exceptions --- 121,125 ---- # Contexts ! 'DefaultContext', 'BasicContext', 'ExtendedContext', # Exceptions *************** *** 148,152 **** import math import operator - xor = operator.xor #Exponent Range --- 148,151 ---- *************** *** 163,167 **** ROUND_HALF_DOWN = 'half_down' ! #Rounding decision NEVER_ROUND = 'never' # Round in division (non-divmod), sqrt ONLY ALWAYS_ROUND = 'always' # Every operation rounds at end. --- 162,166 ---- ROUND_HALF_DOWN = 'half_down' ! #Rounding decision (not part of the public API) NEVER_ROUND = 'never' # Round in division (non-divmod), sqrt ONLY ALWAYS_ROUND = 'always' # Every operation rounds at end. *************** *** 1051,1055 **** return ans ! resultsign = xor(self._sign, other._sign) if self._isinfinity(): if not other: --- 1050,1054 ---- return ans ! resultsign = operator.xor(self._sign, other._sign) if self._isinfinity(): if not other: *************** *** 1145,1149 **** return ans ! sign = xor(self._sign, other._sign) if not self and not other: if divmod: --- 1144,1148 ---- return ans ! sign = operator.xor(self._sign, other._sign) if not self and not other: if divmod: *************** *** 2114,2118 **** Decimal._pick_rounding_function[val] = name ! DefaultLock = threading.Lock() class Context(object): --- 2113,2117 ---- Decimal._pick_rounding_function[val] = name ! del name, val, globalname, rounding_functions class Context(object): *************** *** 2136,2139 **** --- 2135,2141 ---- clamp - If 1, change exponents if too high (Default 0) """ + + DefaultLock = threading.Lock() + def __init__(self, prec=None, rounding=None, trap_enablers=None, flags=None, *************** *** 2144,2148 **** if flags is None: flags = dict.fromkeys(Signals, 0) ! DefaultLock.acquire() for name, val in locals().items(): if val is None: --- 2146,2150 ---- if flags is None: flags = dict.fromkeys(Signals, 0) ! self.DefaultLock.acquire() for name, val in locals().items(): if val is None: *************** *** 2150,2154 **** else: setattr(self, name, val) ! DefaultLock.release() del self.self --- 2152,2156 ---- else: setattr(self, name, val) ! self.DefaultLock.release() del self.self *************** *** 2164,2167 **** --- 2166,2170 ---- self.capitals, self._clamp, self._ignored_flags) return nc + __copy__ = copy def _raise_error(self, error, explanation = None, *args): *************** *** 2265,2275 **** the plus operation on the operand. ! >>> ExtendedDefaultContext.abs(Decimal('2.1')) Decimal("2.1") ! >>> ExtendedDefaultContext.abs(Decimal('-100')) Decimal("100") ! >>> ExtendedDefaultContext.abs(Decimal('101.5')) Decimal("101.5") ! >>> ExtendedDefaultContext.abs(Decimal('-101.5')) Decimal("101.5") """ --- 2268,2278 ---- the plus operation on the operand. ! >>> ExtendedContext.abs(Decimal('2.1')) Decimal("2.1") ! >>> ExtendedContext.abs(Decimal('-100')) Decimal("100") ! >>> ExtendedContext.abs(Decimal('101.5')) Decimal("101.5") ! >>> ExtendedContext.abs(Decimal('-101.5')) Decimal("101.5") """ *************** *** 2279,2285 **** """Return the sum of the two operands. ! >>> ExtendedDefaultContext.add(Decimal('12'), Decimal('7.00')) Decimal("19.00") ! >>> ExtendedDefaultContext.add(Decimal('1E+2'), Decimal('1.01E+4')) Decimal("1.02E+4") """ --- 2282,2288 ---- """Return the sum of the two operands. ! >>> ExtendedContext.add(Decimal('12'), Decimal('7.00')) Decimal("19.00") ! >>> ExtendedContext.add(Decimal('1E+2'), Decimal('1.01E+4')) Decimal("1.02E+4") """ *************** *** 2303,2317 **** zero or negative zero, or '1' if the result is greater than zero. ! >>> ExtendedDefaultContext.compare(Decimal('2.1'), Decimal('3')) Decimal("-1") ! >>> ExtendedDefaultContext.compare(Decimal('2.1'), Decimal('2.1')) Decimal("0") ! >>> ExtendedDefaultContext.compare(Decimal('2.1'), Decimal('2.10')) Decimal("0") ! >>> ExtendedDefaultContext.compare(Decimal('3'), Decimal('2.1')) Decimal("1") ! >>> ExtendedDefaultContext.compare(Decimal('2.1'), Decimal('-3')) Decimal("1") ! >>> ExtendedDefaultContext.compare(Decimal('-3'), Decimal('2.1')) Decimal("-1") """ --- 2306,2320 ---- zero or negative zero, or '1' if the result is greater than zero. ! >>> ExtendedContext.compare(Decimal('2.1'), Decimal('3')) Decimal("-1") ! >>> ExtendedContext.compare(Decimal('2.1'), Decimal('2.1')) Decimal("0") ! >>> ExtendedContext.compare(Decimal('2.1'), Decimal('2.10')) Decimal("0") ! >>> ExtendedContext.compare(Decimal('3'), Decimal('2.1')) Decimal("1") ! >>> ExtendedContext.compare(Decimal('2.1'), Decimal('-3')) Decimal("1") ! >>> ExtendedContext.compare(Decimal('-3'), Decimal('2.1')) Decimal("-1") """ *************** *** 2321,2343 **** """Decimal division in a specified context. ! >>> ExtendedDefaultContext.divide(Decimal('1'), Decimal('3')) Decimal("0.333333333") ! >>> ExtendedDefaultContext.divide(Decimal('2'), Decimal('3')) Decimal("0.666666667") ! >>> ExtendedDefaultContext.divide(Decimal('5'), Decimal('2')) Decimal("2.5") ! >>> ExtendedDefaultContext.divide(Decimal('1'), Decimal('10')) Decimal("0.1") ! >>> ExtendedDefaultContext.divide(Decimal('12'), Decimal('12')) Decimal("1") ! >>> ExtendedDefaultContext.divide(Decimal('8.00'), Decimal('2')) Decimal("4.00") ! >>> ExtendedDefaultContext.divide(Decimal('2.400'), Decimal('2.0')) Decimal("1.20") ! >>> ExtendedDefaultContext.divide(Decimal('1000'), Decimal('100')) Decimal("10") ! >>> ExtendedDefaultContext.divide(Decimal('1000'), Decimal('1')) Decimal("1000") ! >>> ExtendedDefaultContext.divide(Decimal('2.40E+6'), Decimal('2')) Decimal("1.20E+6") """ --- 2324,2346 ---- """Decimal division in a specified context. ! >>> ExtendedContext.divide(Decimal('1'), Decimal('3')) Decimal("0.333333333") ! >>> ExtendedContext.divide(Decimal('2'), Decimal('3')) Decimal("0.666666667") ! >>> ExtendedContext.divide(Decimal('5'), Decimal('2')) Decimal("2.5") ! >>> ExtendedContext.divide(Decimal('1'), Decimal('10')) Decimal("0.1") ! >>> ExtendedContext.divide(Decimal('12'), Decimal('12')) Decimal("1") ! >>> ExtendedContext.divide(Decimal('8.00'), Decimal('2')) Decimal("4.00") ! >>> ExtendedContext.divide(Decimal('2.400'), Decimal('2.0')) Decimal("1.20") ! >>> ExtendedContext.divide(Decimal('1000'), Decimal('100')) Decimal("10") ! >>> ExtendedContext.divide(Decimal('1000'), Decimal('1')) Decimal("1000") ! >>> ExtendedContext.divide(Decimal('2.40E+6'), Decimal('2')) Decimal("1.20E+6") """ *************** *** 2347,2355 **** """Divides two numbers and returns the integer part of the result. ! >>> ExtendedDefaultContext.divide_int(Decimal('2'), Decimal('3')) Decimal("0") ! >>> ExtendedDefaultContext.divide_int(Decimal('10'), Decimal('3')) Decimal("3") ! >>> ExtendedDefaultContext.divide_int(Decimal('1'), Decimal('0.3')) Decimal("3") """ --- 2350,2358 ---- """Divides two numbers and returns the integer part of the result. ! >>> ExtendedContext.divide_int(Decimal('2'), Decimal('3')) Decimal("0") ! >>> ExtendedContext.divide_int(Decimal('10'), Decimal('3')) Decimal("3") ! >>> ExtendedContext.divide_int(Decimal('1'), Decimal('0.3')) Decimal("3") """ *************** *** 2368,2376 **** infinity) of the two operands is chosen as the result. ! >>> ExtendedDefaultContext.max(Decimal('3'), Decimal('2')) Decimal("3") ! >>> ExtendedDefaultContext.max(Decimal('-10'), Decimal('3')) Decimal("3") ! >>> ExtendedDefaultContext.max(Decimal('1.0'), Decimal('1')) Decimal("1.0") """ --- 2371,2379 ---- infinity) of the two operands is chosen as the result. ! >>> ExtendedContext.max(Decimal('3'), Decimal('2')) Decimal("3") ! >>> ExtendedContext.max(Decimal('-10'), Decimal('3')) Decimal("3") ! >>> ExtendedContext.max(Decimal('1.0'), Decimal('1')) Decimal("1.0") """ *************** *** 2386,2394 **** infinity) of the two operands is chosen as the result. ! >>> ExtendedDefaultContext.min(Decimal('3'), Decimal('2')) Decimal("2") ! >>> ExtendedDefaultContext.min(Decimal('-10'), Decimal('3')) Decimal("-10") ! >>> ExtendedDefaultContext.min(Decimal('1.0'), Decimal('1')) Decimal("1.0") """ --- 2389,2397 ---- infinity) of the two operands is chosen as the result. ! >>> ExtendedContext.min(Decimal('3'), Decimal('2')) Decimal("2") ! >>> ExtendedContext.min(Decimal('-10'), Decimal('3')) Decimal("-10") ! >>> ExtendedContext.min(Decimal('1.0'), Decimal('1')) Decimal("1.0") """ *************** *** 2402,2408 **** has the same exponent as the operand. ! >>> ExtendedDefaultContext.minus(Decimal('1.3')) Decimal("-1.3") ! >>> ExtendedDefaultContext.minus(Decimal('-1.3')) Decimal("1.3") """ --- 2405,2411 ---- has the same exponent as the operand. ! >>> ExtendedContext.minus(Decimal('1.3')) Decimal("-1.3") ! >>> ExtendedContext.minus(Decimal('-1.3')) Decimal("1.3") """ *************** *** 2417,2429 **** of the two operands. ! >>> ExtendedDefaultContext.multiply(Decimal('1.20'), Decimal('3')) Decimal("3.60") ! >>> ExtendedDefaultContext.multiply(Decimal('7'), Decimal('3')) Decimal("21") ! >>> ExtendedDefaultContext.multiply(Decimal('0.9'), Decimal('0.8')) Decimal("0.72") ! >>> ExtendedDefaultContext.multiply(Decimal('0.9'), Decimal('-0')) Decimal("-0.0") ! >>> ExtendedDefaultContext.multiply(Decimal('654321'), Decimal('654321')) Decimal("4.28135971E+11") """ --- 2420,2432 ---- of the two operands. ! >>> ExtendedContext.multiply(Decimal('1.20'), Decimal('3')) Decimal("3.60") ! >>> ExtendedContext.multiply(Decimal('7'), Decimal('3')) Decimal("21") ! >>> ExtendedContext.multiply(Decimal('0.9'), Decimal('0.8')) Decimal("0.72") ! >>> ExtendedContext.multiply(Decimal('0.9'), Decimal('-0')) Decimal("-0.0") ! >>> ExtendedContext.multiply(Decimal('654321'), Decimal('654321')) Decimal("4.28135971E+11") """ *************** *** 2436,2450 **** result. ! >>> ExtendedDefaultContext.normalize(Decimal('2.1')) Decimal("2.1") ! >>> ExtendedDefaultContext.normalize(Decimal('-2.0')) Decimal("-2") ! >>> ExtendedDefaultContext.normalize(Decimal('1.200')) Decimal("1.2") ! >>> ExtendedDefaultContext.normalize(Decimal('-120')) Decimal("-1.2E+2") ! >>> ExtendedDefaultContext.normalize(Decimal('120.00')) Decimal("1.2E+2") ! >>> ExtendedDefaultContext.normalize(Decimal('0.00')) Decimal("0") """ --- 2439,2453 ---- result. ! >>> ExtendedContext.normalize(Decimal('2.1')) Decimal("2.1") ! >>> ExtendedContext.normalize(Decimal('-2.0')) Decimal("-2") ! >>> ExtendedContext.normalize(Decimal('1.200')) Decimal("1.2") ! >>> ExtendedContext.normalize(Decimal('-120')) Decimal("-1.2E+2") ! >>> ExtendedContext.normalize(Decimal('120.00')) Decimal("1.2E+2") ! >>> ExtendedContext.normalize(Decimal('0.00')) Decimal("0") """ *************** *** 2458,2464 **** has the same exponent as the operand. ! >>> ExtendedDefaultContext.plus(Decimal('1.3')) Decimal("1.3") ! >>> ExtendedDefaultContext.plus(Decimal('-1.3')) Decimal("-1.3") """ --- 2461,2467 ---- has the same exponent as the operand. ! >>> ExtendedContext.plus(Decimal('1.3')) Decimal("1.3") ! >>> ExtendedContext.plus(Decimal('-1.3')) Decimal("-1.3") """ *************** *** 2483,2513 **** continues. ! >>> ExtendedDefaultContext.power(Decimal('2'), Decimal('3')) Decimal("8") ! >>> ExtendedDefaultContext.power(Decimal('2'), Decimal('-3')) Decimal("0.125") ! >>> ExtendedDefaultContext.power(Decimal('1.7'), Decimal('8')) Decimal("69.7575744") ! >>> ExtendedDefaultContext.power(Decimal('Infinity'), Decimal('-2')) Decimal("0") ! >>> ExtendedDefaultContext.power(Decimal('Infinity'), Decimal('-1')) Decimal("0") ! >>> ExtendedDefaultContext.power(Decimal('Infinity'), Decimal('0')) Decimal("1") ! >>> ExtendedDefaultContext.power(Decimal('Infinity'), Decimal('1')) Decimal("Infinity") ! >>> ExtendedDefaultContext.power(Decimal('Infinity'), Decimal('2')) Decimal("Infinity") ! >>> ExtendedDefaultContext.power(Decimal('-Infinity'), Decimal('-2')) Decimal("0") ! >>> ExtendedDefaultContext.power(Decimal('-Infinity'), Decimal('-1')) Decimal("-0") ! >>> ExtendedDefaultContext.power(Decimal('-Infinity'), Decimal('0')) Decimal("1") ! >>> ExtendedDefaultContext.power(Decimal('-Infinity'), Decimal('1')) Decimal("-Infinity") ! >>> ExtendedDefaultContext.power(Decimal('-Infinity'), Decimal('2')) Decimal("Infinity") ! >>> ExtendedDefaultContext.power(Decimal('0'), Decimal('0')) Decimal("NaN") """ --- 2486,2516 ---- continues. ! >>> ExtendedContext.power(Decimal('2'), Decimal('3')) Decimal("8") ! >>> ExtendedContext.power(Decimal('2'), Decimal('-3')) Decimal("0.125") ! >>> ExtendedContext.power(Decimal('1.7'), Decimal('8')) Decimal("69.7575744") ! >>> ExtendedContext.power(Decimal('Infinity'), Decimal('-2')) Decimal("0") ! >>> ExtendedContext.power(Decimal('Infinity'), Decimal('-1')) Decimal("0") ! >>> ExtendedContext.power(Decimal('Infinity'), Decimal('0')) Decimal("1") ! >>> ExtendedContext.power(Decimal('Infinity'), Decimal('1')) Decimal("Infinity") ! >>> ExtendedContext.power(Decimal('Infinity'), Decimal('2')) Decimal("Infinity") ! >>> ExtendedContext.power(Decimal('-Infinity'), Decimal('-2')) Decimal("0") ! >>> ExtendedContext.power(Decimal('-Infinity'), Decimal('-1')) Decimal("-0") ! >>> ExtendedContext.power(Decimal('-Infinity'), Decimal('0')) Decimal("1") ! >>> ExtendedContext.power(Decimal('-Infinity'), Decimal('1')) Decimal("-Infinity") ! >>> ExtendedContext.power(Decimal('-Infinity'), Decimal('2')) Decimal("Infinity") ! >>> ExtendedContext.power(Decimal('0'), Decimal('0')) Decimal("NaN") """ *************** *** 2532,2564 **** if the result is subnormal and inexact. ! >>> ExtendedDefaultContext.quantize(Decimal('2.17'), Decimal('0.001')) Decimal("2.170") ! >>> ExtendedDefaultContext.quantize(Decimal('2.17'), Decimal('0.01')) Decimal("2.17") ! >>> ExtendedDefaultContext.quantize(Decimal('2.17'), Decimal('0.1')) Decimal("2.2") ! >>> ExtendedDefaultContext.quantize(Decimal('2.17'), Decimal('1e+0')) Decimal("2") ! >>> ExtendedDefaultContext.quantize(Decimal('2.17'), Decimal('1e+1')) Decimal("0E+1") ! >>> ExtendedDefaultContext.quantize(Decimal('-Inf'), Decimal('Infinity')) Decimal("-Infinity") ! >>> ExtendedDefaultContext.quantize(Decimal('2'), Decimal('Infinity')) Decimal("NaN") ! >>> ExtendedDefaultContext.quantize(Decimal('-0.1'), Decimal('1')) Decimal("-0") ! >>> ExtendedDefaultContext.quantize(Decimal('-0'), Decimal('1e+5')) Decimal("-0E+5") ! >>> ExtendedDefaultContext.quantize(Decimal('+35236450.6'), Decimal('1e-2')) Decimal("NaN") ! >>> ExtendedDefaultContext.quantize(Decimal('-35236450.6'), Decimal('1e-2')) Decimal("NaN") ! >>> ExtendedDefaultContext.quantize(Decimal('217'), Decimal('1e-1')) Decimal("217.0") ! >>> ExtendedDefaultContext.quantize(Decimal('217'), Decimal('1e-0')) Decimal("217") ! >>> ExtendedDefaultContext.quantize(Decimal('217'), Decimal('1e+1')) Decimal("2.2E+2") ! >>> ExtendedDefaultContext.quantize(Decimal('217'), Decimal('1e+2')) Decimal("2E+2") """ --- 2535,2567 ---- if the result is subnormal and inexact. ! >>> ExtendedContext.quantize(Decimal('2.17'), Decimal('0.001')) Decimal("2.170") ! >>> ExtendedContext.quantize(Decimal('2.17'), Decimal('0.01')) Decimal("2.17") ! >>> ExtendedContext.quantize(Decimal('2.17'), Decimal('0.1')) Decimal("2.2") ! >>> ExtendedContext.quantize(Decimal('2.17'), Decimal('1e+0')) Decimal("2") ! >>> ExtendedContext.quantize(Decimal('2.17'), Decimal('1e+1')) Decimal("0E+1") ! >>> ExtendedContext.quantize(Decimal('-Inf'), Decimal('Infinity')) Decimal("-Infinity") ! >>> ExtendedContext.quantize(Decimal('2'), Decimal('Infinity')) Decimal("NaN") ! >>> ExtendedContext.quantize(Decimal('-0.1'), Decimal('1')) Decimal("-0") ! >>> ExtendedContext.quantize(Decimal('-0'), Decimal('1e+5')) Decimal("-0E+5") ! >>> ExtendedContext.quantize(Decimal('+35236450.6'), Decimal('1e-2')) Decimal("NaN") ! >>> ExtendedContext.quantize(Decimal('-35236450.6'), Decimal('1e-2')) Decimal("NaN") ! >>> ExtendedContext.quantize(Decimal('217'), Decimal('1e-1')) Decimal("217.0") ! >>> ExtendedContext.quantize(Decimal('217'), Decimal('1e-0')) Decimal("217") ! >>> ExtendedContext.quantize(Decimal('217'), Decimal('1e+1')) Decimal("2.2E+2") ! >>> ExtendedContext.quantize(Decimal('217'), Decimal('1e+2')) Decimal("2E+2") """ *************** *** 2577,2591 **** remainder cannot be calculated). ! >>> ExtendedDefaultContext.remainder(Decimal('2.1'), Decimal('3')) Decimal("2.1") ! >>> ExtendedDefaultContext.remainder(Decimal('10'), Decimal('3')) Decimal("1") ! >>> ExtendedDefaultContext.remainder(Decimal('-10'), Decimal('3')) Decimal("-1") ! >>> ExtendedDefaultContext.remainder(Decimal('10.2'), Decimal('1')) Decimal("0.2") ! >>> ExtendedDefaultContext.remainder(Decimal('10'), Decimal('0.3')) Decimal("0.1") ! >>> ExtendedDefaultContext.remainder(Decimal('3.6'), Decimal('1.3')) Decimal("1.0") """ --- 2580,2594 ---- remainder cannot be calculated). ! >>> ExtendedContext.remainder(Decimal('2.1'), Decimal('3')) Decimal("2.1") ! >>> ExtendedContext.remainder(Decimal('10'), Decimal('3')) Decimal("1") ! >>> ExtendedContext.remainder(Decimal('-10'), Decimal('3')) Decimal("-1") ! >>> ExtendedContext.remainder(Decimal('10.2'), Decimal('1')) Decimal("0.2") ! >>> ExtendedContext.remainder(Decimal('10'), Decimal('0.3')) Decimal("0.1") ! >>> ExtendedContext.remainder(Decimal('3.6'), Decimal('1.3')) Decimal("1.0") """ *************** *** 2602,2618 **** remainder cannot be calculated). ! >>> ExtendedDefaultContext.remainder_near(Decimal('2.1'), Decimal('3')) Decimal("-0.9") ! >>> ExtendedDefaultContext.remainder_near(Decimal('10'), Decimal('6')) Decimal("-2") ! >>> ExtendedDefaultContext.remainder_near(Decimal('10'), Decimal('3')) Decimal("1") ! >>> ExtendedDefaultContext.remainder_near(Decimal('-10'), Decimal('3')) Decimal("-1") ! >>> ExtendedDefaultContext.remainder_near(Decimal('10.2'), Decimal('1')) Decimal("0.2") ! >>> ExtendedDefaultContext.remainder_near(Decimal('10'), Decimal('0.3')) Decimal("0.1") ! >>> ExtendedDefaultContext.remainder_near(Decimal('3.6'), Decimal('1.3')) Decimal("-0.3") """ --- 2605,2621 ---- remainder cannot be calculated). ! >>> ExtendedContext.remainder_near(Decimal('2.1'), Decimal('3')) Decimal("-0.9") ! >>> ExtendedContext.remainder_near(Decimal('10'), Decimal('6')) Decimal("-2") ! >>> ExtendedContext.remainder_near(Decimal('10'), Decimal('3')) Decimal("1") ! >>> ExtendedContext.remainder_near(Decimal('-10'), Decimal('3')) Decimal("-1") ! >>> ExtendedContext.remainder_near(Decimal('10.2'), Decimal('1')) Decimal("0.2") ! >>> ExtendedContext.remainder_near(Decimal('10'), Decimal('0.3')) Decimal("0.1") ! >>> ExtendedContext.remainder_near(Decimal('3.6'), Decimal('1.3')) Decimal("-0.3") """ *************** *** 2625,2635 **** either operand. ! >>> ExtendedDefaultContext.same_quantum(Decimal('2.17'), Decimal('0.001')) False ! >>> ExtendedDefaultContext.same_quantum(Decimal('2.17'), Decimal('0.01')) True ! >>> ExtendedDefaultContext.same_quantum(Decimal('2.17'), Decimal('1')) False ! >>> ExtendedDefaultContext.same_quantum(Decimal('Inf'), Decimal('-Inf')) True """ --- 2628,2638 ---- either operand. ! >>> ExtendedContext.same_quantum(Decimal('2.17'), Decimal('0.001')) False ! >>> ExtendedContext.same_quantum(Decimal('2.17'), Decimal('0.01')) True ! >>> ExtendedContext.same_quantum(Decimal('2.17'), Decimal('1')) False ! >>> ExtendedContext.same_quantum(Decimal('Inf'), Decimal('-Inf')) True """ *************** *** 2642,2664 **** algorithm. ! >>> ExtendedDefaultContext.sqrt(Decimal('0')) Decimal("0") ! >>> ExtendedDefaultContext.sqrt(Decimal('-0')) Decimal("-0") ! >>> ExtendedDefaultContext.sqrt(Decimal('0.39')) Decimal("0.624499800") ! >>> ExtendedDefaultContext.sqrt(Decimal('100')) Decimal("10") ! >>> ExtendedDefaultContext.sqrt(Decimal('1')) Decimal("1") ! >>> ExtendedDefaultContext.sqrt(Decimal('1.0')) Decimal("1.0") ! >>> ExtendedDefaultContext.sqrt(Decimal('1.00')) Decimal("1.0") ! >>> ExtendedDefaultContext.sqrt(Decimal('7')) Decimal("2.64575131") ! >>> ExtendedDefaultContext.sqrt(Decimal('10')) Decimal("3.16227766") ! >>> ExtendedDefaultContext.prec 9 """ --- 2645,2667 ---- algorithm. ! >>> ExtendedContext.sqrt(Decimal('0')) Decimal("0") ! >>> ExtendedContext.sqrt(Decimal('-0')) Decimal("-0") ! >>> ExtendedContext.sqrt(Decimal('0.39')) Decimal("0.624499800") ! >>> ExtendedContext.sqrt(Decimal('100')) Decimal("10") ! >>> ExtendedContext.sqrt(Decimal('1')) Decimal("1") ! >>> ExtendedContext.sqrt(Decimal('1.0')) Decimal("1.0") ! >>> ExtendedContext.sqrt(Decimal('1.00')) Decimal("1.0") ! >>> ExtendedContext.sqrt(Decimal('7')) Decimal("2.64575131") ! >>> ExtendedContext.sqrt(Decimal('10')) Decimal("3.16227766") ! >>> ExtendedContext.prec 9 """ *************** *** 2668,2676 **** """Return the sum of the two operands. ! >>> ExtendedDefaultContext.subtract(Decimal('1.3'), Decimal('1.07')) Decimal("0.23") ! >>> ExtendedDefaultContext.subtract(Decimal('1.3'), Decimal('1.30')) Decimal("0.00") ! >>> ExtendedDefaultContext.subtract(Decimal('1.3'), Decimal('2.07')) Decimal("-0.77") """ --- 2671,2679 ---- """Return the sum of the two operands. ! >>> ExtendedContext.subtract(Decimal('1.3'), Decimal('1.07')) Decimal("0.23") ! >>> ExtendedContext.subtract(Decimal('1.3'), Decimal('1.30')) Decimal("0.00") ! >>> ExtendedContext.subtract(Decimal('1.3'), Decimal('2.07')) Decimal("-0.77") """ *************** *** 2700,2718 **** be set. The rounding mode is taken from the context. ! >>> ExtendedDefaultContext.to_integral(Decimal('2.1')) Decimal("2") ! >>> ExtendedDefaultContext.to_integral(Decimal('100')) Decimal("100") ! >>> ExtendedDefaultContext.to_integral(Decimal('100.0')) Decimal("100") ! >>> ExtendedDefaultContext.to_integral(Decimal('101.5')) Decimal("102") ! >>> ExtendedDefaultContext.to_integral(Decimal('-101.5')) Decimal("-102") ! >>> ExtendedDefaultContext.to_integral(Decimal('10E+5')) Decimal("1.0E+6") ! >>> ExtendedDefaultContext.to_integral(Decimal('7.89E+77')) Decimal("7.89E+77") ! >>> ExtendedDefaultContext.to_integral(Decimal('-Inf')) Decimal("-Infinity") """ --- 2703,2721 ---- be set. The rounding mode is taken from the context. ! >>> ExtendedContext.to_integral(Decimal('2.1')) Decimal("2") ! >>> ExtendedContext.to_integral(Decimal('100')) Decimal("100") ! >>> ExtendedContext.to_integral(Decimal('100.0')) Decimal("100") ! >>> ExtendedContext.to_integral(Decimal('101.5')) Decimal("102") ! >>> ExtendedContext.to_integral(Decimal('-101.5')) Decimal("-102") ! >>> ExtendedContext.to_integral(Decimal('10E+5')) Decimal("1.0E+6") ! >>> ExtendedContext.to_integral(Decimal('7.89E+77')) Decimal("7.89E+77") ! >>> ExtendedContext.to_integral(Decimal('-Inf')) Decimal("-Infinity") """ *************** *** 2975,2979 **** # of the spec. ! BasicDefaultContext = Context( prec=9, rounding=ROUND_HALF_UP, trap_enablers=_basic_traps, --- 2978,2982 ---- # of the spec. ! BasicContext = Context( prec=9, rounding=ROUND_HALF_UP, trap_enablers=_basic_traps, *************** *** 2982,2986 **** ) ! ExtendedDefaultContext = Context( prec=9, rounding=ROUND_HALF_EVEN, trap_enablers=dict.fromkeys(Signals, 0), --- 2985,2989 ---- ) ! ExtendedContext = Context( prec=9, rounding=ROUND_HALF_EVEN, trap_enablers=dict.fromkeys(Signals, 0), From haleythieleck at phat.co.nz Sun Jul 4 02:52:29 2004 From: haleythieleck at phat.co.nz (Israel Huddleston) Date: Sat Jul 3 10:53:24 2004 Subject: [Python-checkins] ch.ea.pest prices, no pre.scri.ption In-Reply-To: <20040330185343.081B3965@msn.com> Message-ID: Skipped content of type multipart/alternative-------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: image/gif Size: 5978 bytes Desc: not available Url : http://mail.python.org/pipermail/python-checkins/attachments/20040703/bc858e0b/attachment-0001.gif From bcannon at users.sourceforge.net Sat Jul 3 15:59:00 2004 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Sat Jul 3 15:59:04 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS, 1.831.4.127, 1.831.4.128 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6118/Misc Modified Files: Tag: release23-maint NEWS Log Message: threading.Thread used to raise an exception about attempting to execute a NoneType if an exception in a thread was raised during interpreter shutdown. This led to a masking of the initial exception (not good). All fixed (good). Closes bug #754449 (using both patch #954922 and a backport of rev. 1.41 from HEAD). Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.831.4.127 retrieving revision 1.831.4.128 diff -C2 -d -r1.831.4.127 -r1.831.4.128 *** NEWS 2 Jul 2004 08:40:28 -0000 1.831.4.127 --- NEWS 3 Jul 2004 19:58:58 -0000 1.831.4.128 *************** *** 41,44 **** --- 41,49 ---- ------- + - Bug #754449: threading.Thread will no longer mask exceptions raised during + interpreter shutdown with another exception caused by attempting to output + the initial exception. This fix also includes a backport of rev. 1.41 from + HEAD. + - Bug #982215: The Back and Next buttons in bdist_wininst installers are now disabled during file copy operations. From bcannon at users.sourceforge.net Sat Jul 3 15:59:00 2004 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Sat Jul 3 15:59:07 2004 Subject: [Python-checkins] python/dist/src/Lib threading.py,1.38,1.38.6.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6118/Lib Modified Files: Tag: release23-maint threading.py Log Message: threading.Thread used to raise an exception about attempting to execute a NoneType if an exception in a thread was raised during interpreter shutdown. This led to a masking of the initial exception (not good). All fixed (good). Closes bug #754449 (using both patch #954922 and a backport of rev. 1.41 from HEAD). Index: threading.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/threading.py,v retrieving revision 1.38 retrieving revision 1.38.6.1 diff -C2 -d -r1.38 -r1.38.6.1 *** threading.py 1 Jul 2003 20:01:55 -0000 1.38 --- threading.py 3 Jul 2004 19:58:57 -0000 1.38.6.1 *************** *** 194,198 **** def wait(self, timeout=None): - currentThread() # for side-effect assert self._is_owned(), "wait() of un-acquire()d lock" waiter = _allocate_lock() --- 194,197 ---- *************** *** 236,240 **** def notify(self, n=1): - currentThread() # for side-effect assert self._is_owned(), "notify() of un-acquire()d lock" __waiters = self.__waiters --- 235,238 ---- *************** *** 370,373 **** --- 368,376 ---- __initialized = False + # Need to store a reference to sys.exc_info for printing + # out exceptions when a thread tries to accept a global during interp. + # shutdown and thus raises an exception about trying to perform some + # operation on/with a NoneType + __exc_info = _sys.exc_info def __init__(self, group=None, target=None, name=None, *************** *** 384,387 **** --- 387,393 ---- self.__block = Condition(Lock()) self.__initialized = True + # sys.stderr is not stored in the class like + # sys.exc_info since it can be changed during execution + self.__stderr = _sys.stderr def _set_daemon(self): *************** *** 441,448 **** if __debug__: self._note("%s.__bootstrap(): unhandled exception", self) ! s = _StringIO() ! _print_exc(file=s) ! _sys.stderr.write("Exception in thread %s:\n%s\n" % ! (self.getName(), s.getvalue())) else: if __debug__: --- 447,478 ---- if __debug__: self._note("%s.__bootstrap(): unhandled exception", self) ! # If sys.stderr is no more (most likely from interpreter ! # shutdown) use self.__stderr. Otherwise still use sys (as in ! # _sys) in case sys.stderr was redefined. ! if _sys: ! _sys.stderr.write("Exception in thread %s:\n%s\n" % ! (self.getName(), _format_exc())) ! else: ! # Do the best job possible w/o a huge amt. of code to ! # approx. a traceback stack trace ! exc_type, exc_value, exc_tb = self.__exc_info() ! try: ! print>>self.__stderr, ( ! "Exception in thread " + self.getName() + ! " (most likely raised during interpreter shutdown):") ! print>>self.__stderr, ( ! "Traceback (most recent call last):") ! while exc_tb: ! print>>self.__stderr, ( ! ' File "%s", line %s, in %s' % ! (exc_tb.tb_frame.f_code.co_filename, ! exc_tb.tb_lineno, ! exc_tb.tb_frame.f_code.co_name)) ! exc_tb = exc_tb.tb_next ! print>>self.__stderr, ("%s: %s" % (exc_type, exc_value)) ! # Make sure that exc_tb gets deleted since it is a memory ! # hog; deleting everything else is just for thoroughness ! finally: ! del exc_type, exc_value, exc_tb else: if __debug__: From lilbooboo164 at aol.com Sat Jul 3 17:59:38 2004 From: lilbooboo164 at aol.com (lilbooboo164@aol.com) Date: Sat Jul 3 17:59:37 2004 Subject: [Python-checkins] =?iso-8859-1?q?=DFdo0=DFi4grjj40j09gjijgp=FCd?= =?iso-8859-1?q?=E9?= Message-ID: 9u049u89gh89fsdpokofkdpbm3?4i -------------- next part -------------- A non-text attachment was scrubbed... Name: id43342.zip Type: application/octet-stream Size: 29840 bytes Desc: not available Url : http://mail.python.org/pipermail/python-checkins/attachments/20040703/fd59e732/id43342.obj From akuchling at users.sourceforge.net Sat Jul 3 18:26:44 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sat Jul 3 18:26:47 2004 Subject: [Python-checkins] python/nondist/peps pep-0289.txt,1.13,1.14 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30692 Modified Files: pep-0289.txt Log Message: Typo fixes Index: pep-0289.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0289.txt,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** pep-0289.txt 20 May 2004 22:57:01 -0000 1.13 --- pep-0289.txt 3 Jul 2004 22:26:41 -0000 1.14 *************** *** 34,38 **** sum([x*x for x in range(10)]) ! Memory is conserved by using an generator expession instead:: sum(x*x for x in range(10)) --- 34,38 ---- sum([x*x for x in range(10)]) ! Memory is conserved by using a generator expession instead:: sum(x*x for x in range(10)) *************** *** 163,167 **** 3. The loop variable (if it is a simple variable or a tuple of simple variables) is not exposed to the surrounding function. This ! facilates the implementation and makes typical use cases more reliable. In some future version of Python, list comprehensions will also hide the induction variable from the surrounding code --- 163,167 ---- 3. The loop variable (if it is a simple variable or a tuple of simple variables) is not exposed to the surrounding function. This ! facilitates the implementation and makes typical use cases more reliable. In some future version of Python, list comprehensions will also hide the induction variable from the surrounding code From kbk at users.sourceforge.net Sat Jul 3 21:25:59 2004 From: kbk at users.sourceforge.net (kbk@users.sourceforge.net) Date: Sat Jul 3 21:26:02 2004 Subject: [Python-checkins] python/dist/src/Lib/idlelib NEWS.txt, 1.35, 1.36 PyShell.py, 1.88, 1.89 ScriptBinding.py, 1.27, 1.28 run.py, 1.28, 1.29 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/idlelib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22465 Modified Files: NEWS.txt PyShell.py ScriptBinding.py run.py Log Message: Redirect the warning stream to the shell during the ScriptBinding check of user code and format the warning similarly to an exception for both that check and for warnings raised in the subprocess. M NEWS.txt M Pyshell.py M ScriptBinding.py M run.py Index: NEWS.txt =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/NEWS.txt,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** NEWS.txt 6 Jun 2004 01:29:21 -0000 1.35 --- NEWS.txt 4 Jul 2004 01:25:56 -0000 1.36 *************** *** 4,7 **** --- 4,11 ---- *Release date: XX-XXX-2004* + - Redirect the warning stream to the shell during the ScriptBinding check of + user code and format the warning similarly to an exception for both that + check and for runtime warnings raised in the subprocess. + - CodeContext hint pane visibility state is now persistent across sessions. The pane no longer appears in the shell window. Added capability to limit Index: PyShell.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/PyShell.py,v retrieving revision 1.88 retrieving revision 1.89 diff -C2 -d -r1.88 -r1.89 *** PyShell.py 6 Jun 2004 01:29:21 -0000 1.88 --- PyShell.py 4 Jul 2004 01:25:56 -0000 1.89 *************** *** 45,49 **** SIGTERM = 15 ! # Change warnings module to write to sys.__stderr__ try: import warnings --- 45,54 ---- SIGTERM = 15 ! # Override warnings module to write to warning_stream. Initialize to send IDLE ! # internal warnings to the console. ScriptBinding.check_syntax() will ! # temporarily redirect the stream to the shell window to display warnings when ! # checking user's code. ! global warning_stream ! warning_stream = sys.__stderr__ try: import warnings *************** *** 52,58 **** else: def idle_showwarning(message, category, filename, lineno): ! file = sys.__stderr__ ! file.write(warnings.formatwarning(message, category, filename, lineno)) warnings.showwarning = idle_showwarning def extended_linecache_checkcache(orig_checkcache=linecache.checkcache): --- 57,76 ---- else: def idle_showwarning(message, category, filename, lineno): ! file = warning_stream ! try: ! file.write(warnings.formatwarning(message, category, filename, lineno)) ! except IOError: ! pass ## file (probably __stderr__) is invalid, warning dropped. warnings.showwarning = idle_showwarning + def idle_formatwarning(message, category, filename, lineno): + """Format warnings the IDLE way""" + s = "\nWarning (from warnings module):\n" + s += ' File \"%s\", line %s\n' % (filename, lineno) + line = linecache.getline(filename, lineno).strip() + if line: + s += " %s\n" % line + s += "%s: %s\n>>> " % (category.__name__, message) + return s + warnings.formatwarning = idle_formatwarning def extended_linecache_checkcache(orig_checkcache=linecache.checkcache): *************** *** 816,819 **** --- 834,844 ---- closing = False + def set_warning_stream(self, stream): + global warning_stream + warning_stream = stream + + def get_warning_stream(self): + return warning_stream + def toggle_debugger(self, event=None): if self.executing: Index: ScriptBinding.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/ScriptBinding.py,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** ScriptBinding.py 12 Feb 2004 17:35:09 -0000 1.27 --- ScriptBinding.py 4 Jul 2004 01:25:56 -0000 1.28 *************** *** 83,86 **** --- 83,89 ---- def checksyntax(self, filename): + self.shell = shell = self.flist.open_shell() + saved_stream = shell.get_warning_stream() + shell.set_warning_stream(shell.stderr) f = open(filename, 'r') source = f.read() *************** *** 93,110 **** text.tag_remove("ERROR", "1.0", "end") try: - # If successful, return the compiled code - return compile(source, filename, "exec") - except (SyntaxError, OverflowError), err: try: ! msg, (errorfilename, lineno, offset, line) = err ! if not errorfilename: ! err.args = msg, (filename, lineno, offset, line) ! err.filename = filename ! self.colorize_syntax_error(msg, lineno, offset) ! except: ! msg = "*** " + str(err) ! self.errorbox("Syntax error", ! "There's an error in your program:\n" + msg) ! return False def colorize_syntax_error(self, msg, lineno, offset): --- 96,116 ---- text.tag_remove("ERROR", "1.0", "end") try: try: ! # If successful, return the compiled code ! return compile(source, filename, "exec") ! except (SyntaxError, OverflowError), err: ! try: ! msg, (errorfilename, lineno, offset, line) = err ! if not errorfilename: ! err.args = msg, (filename, lineno, offset, line) ! err.filename = filename ! self.colorize_syntax_error(msg, lineno, offset) ! except: ! msg = "*** " + str(err) ! self.errorbox("Syntax error", ! "There's an error in your program:\n" + msg) ! return False ! finally: ! shell.set_warning_stream(saved_stream) def colorize_syntax_error(self, msg, lineno, offset): *************** *** 136,143 **** if not code: return ! flist = self.editwin.flist ! shell = flist.open_shell() ! if not shell: ! return # couldn't open the shell interp = shell.interp if PyShell.use_subprocess: --- 142,146 ---- if not code: return ! shell = self.shell interp = shell.interp if PyShell.use_subprocess: *************** *** 157,160 **** --- 160,166 ---- \n""" % (filename, dirname)) interp.prepend_syspath(filename) + # XXX KBK 03Jul04 When run w/o subprocess, runtime warnings still + # go to __stderr__. With subprocess, they go to the shell. + # Need to change streams in PyShell.ModifiedInterpreter. interp.runcode(code) Index: run.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/run.py,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** run.py 21 Jan 2004 18:54:30 -0000 1.28 --- run.py 4 Jul 2004 01:25:56 -0000 1.29 *************** *** 1,4 **** --- 1,5 ---- import sys import os + import linecache import time import socket *************** *** 18,21 **** --- 19,38 ---- LOCALHOST = '127.0.0.1' + try: + import warnings + except ImportError: + pass + else: + def idle_formatwarning_subproc(message, category, filename, lineno): + """Format warnings the IDLE way""" + s = "\nWarning (from warnings module):\n" + s += ' File \"%s\", line %s\n' % (filename, lineno) + line = linecache.getline(filename, lineno).strip() + if line: + s += " %s\n" % line + s += "%s: %s\n" % (category.__name__, message) + return s + warnings.formatwarning = idle_formatwarning_subproc + # Thread shared globals: Establish a queue between a subthread (which handles # the socket) and the main thread (which runs user code), plus global From akuchling at users.sourceforge.net Sat Jul 3 21:26:44 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sat Jul 3 21:26:48 2004 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew24.tex, 1.56, 1.57 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22881 Modified Files: whatsnew24.tex Log Message: Rewrite two sections Index: whatsnew24.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew24.tex,v retrieving revision 1.56 retrieving revision 1.57 diff -C2 -d -r1.56 -r1.57 *** whatsnew24.tex 1 Jul 2004 11:52:15 -0000 1.56 --- whatsnew24.tex 4 Jul 2004 01:26:42 -0000 1.57 *************** *** 3,6 **** --- 3,10 ---- % $Id$ + % Don't write extensive text for new sections; I'll do that. + % Feel free to add commented-out reminders of things that need + % to be covered. --amk + \title{What's New in Python 2.4} \release{0.0} *************** *** 90,160 **** %====================================================================== ! \section{PEP 229: Generator Expressions} ! Now, simple generators can be coded succinctly as expressions using a syntax ! like list comprehensions but with parentheses instead of brackets. These ! expressions are designed for situations where the generator is used right ! away by an enclosing function. Generator expressions are more compact but ! less versatile than full generator definitions and they tend to be more memory ! friendly than equivalent list comprehensions. ! ! \begin{verbatim} ! g = (tgtexp for var1 in exp1 for var2 in exp2 if exp3) ! \end{verbatim} ! ! is equivalent to: \begin{verbatim} ! def __gen(exp): ! for var1 in exp: ! for var2 in exp2: ! if exp3: ! yield tgtexp ! g = __gen(iter(exp1)) ! del __gen \end{verbatim} ! The advantage over full generator definitions is in economy of ! expression. Their advantage over list comprehensions is in saving ! memory by creating data only when it is needed rather than forming ! a whole list is memory all at once. Applications using memory ! friendly generator expressions may scale-up to high volumes of data ! more readily than with list comprehensions. ! ! Generator expressions are best used in functions that consume their ! data all at once and would not benefit from having a full list instead ! of a generator as an input: \begin{verbatim} ! >>> sum(i*i for i in range(10)) ! 285 ! ! >>> sorted(set(i*i for i in xrange(-20, 20) if i%2==1)) # odd squares ! [1, 9, 25, 49, 81, 121, 169, 225, 289, 361] ! >>> from itertools import izip ! >>> xvec = [10, 20, 30] ! >>> yvec = [7, 5, 3] ! >>> sum(x*y for x,y in izip(xvec, yvec)) # dot product ! 260 ! >>> from math import pi, sin ! >>> sine_table = dict((x, sin(x*pi/180)) for x in xrange(0, 91)) ! >>> unique_words = set(word for line in page for word in line.split()) ! >>> valedictorian = max((student.gpa, student.name) for student in graduates) ! \end{verbatim} ! For more complex uses of generators, it is strongly recommended that ! the traditional full generator definitions be used instead. In a ! generator expression, the first for-loop expression is evaluated ! as soon as the expression is defined while the other expressions do ! not get evaluated until the generator is run. This nuance is never ! an issue when the generator is used immediately; however, if it is not ! used right away, a full generator definition would be much more clear ! about when the sub-expressions are evaluated and would be more obvious ! about the visibility and lifetime of the variables. \begin{seealso} --- 94,152 ---- %====================================================================== ! \section{PEP 289: Generator Expressions} ! The iterator feature introduced in Python 2.2 makes it easier to write ! programs that loop through large data sets without having the entire ! data set in memory at one time. Programmers can use iterators and the ! \module{itertools} module to write code in a fairly functional style. ! ! The fly in the ointment has been list comprehensions, because they ! produce a Python list object containing all of the items, unavoidably ! pulling them all into memory. When trying to write a program using the functional approach, it would be natural to write something like: \begin{verbatim} ! links = [link for link in get_all_links() if not link.followed] ! for link in links: ! ... \end{verbatim} ! instead of \begin{verbatim} ! for link in get_all_links(): ! if link.followed: ! continue ! ... ! \end{verbatim} ! The first form is more concise and perhaps more readable, but if ! you're dealing with a large number of link objects the second form ! would have to be used. ! Generator expressions work similarly to list comprehensions but don't ! materialize the entire list; instead they create a generator that will ! return elements one by one. The above example could be written as: ! \begin{verbatim} ! links = (link for link in get_all_links() if not link.followed) ! for link in links: ! ... ! \end{verbatim} ! Generator expressions always have to be written inside parentheses, as ! in the above example. The parentheses signalling a function call also ! count, so if you want to create a iterator that will be immediately ! passed to a function you could write: ! \begin{verbatim} ! print sum(obj.count for obj in list_all_objects()) ! \end{verbatim} ! There are some small differences from list comprehensions. Most ! notably, the loop variable (\var{obj} in the above example) is not ! accessible outside of the generator expression. List comprehensions ! leave the variable assigned to its last value; future versions of ! Python will change this, making list comprehensions match generator ! expressions in this respect. \begin{seealso} *************** *** 204,263 **** \section{PEP 327: Decimal Data Type} ! A new module, \module{decimal}, offers a \class{Decimal} data type for ! decimal floating point arithmetic. Compared to the built-in \class{float} ! type implemented with binary floating point, the new class is especially ! useful for financial applications and other uses which require exact ! decimal representation, control over precision, control over rounding ! to meet legal or regulatory requirements, tracking of significant ! decimal places, or for applications where the user expects the results ! to match hand calculations done the way they were taught in school. ! For example, calculating a 5% tax on a 70 cent phone charge gives ! different results in decimal floating point and binary floating point ! with the difference being significant when rounding to the nearest ! cent: \begin{verbatim} ! >>> from decimal import * ! >>> Decimal('0.70') * Decimal('1.05') ! Decimal("0.7350") ! >>> .70 * 1.05 ! 0.73499999999999999 \end{verbatim} ! Note that the \class{Decimal} result keeps a trailing zero, automatically ! inferring four place significance from two digit mulitiplicands. A key ! goal is to reproduce the mathematics we do by hand and avoid the tricky ! issues that arise when decimal numbers cannot be represented exactly in ! binary floating point. ! Exact representation enables the \class{Decimal} class to perform ! modulo calculations and equality tests that would fail in binary ! floating point: \begin{verbatim} ! >>> Decimal('1.00') % Decimal('.10') ! Decimal("0.00") ! >>> 1.00 % 0.10 ! 0.09999999999999995 ! ! >>> sum([Decimal('0.1')]*10) == Decimal('1.0') ! True ! >>> sum([0.1]*10) == 1.0 ! False \end{verbatim} ! The \module{decimal} module also allows arbitrarily large precisions to be ! set for calculation: \begin{verbatim} ! >>> getcontext().prec = 24 ! >>> Decimal(1) / Decimal(7) ! Decimal("0.142857142857142857142857") \end{verbatim} \begin{seealso} \seepep{327}{Decimal Data Type}{Written by Facundo Batista and implemented ! by Eric Price, Facundo Bastista, Raymond Hettinger, Aahz, and Tim Peters.} \end{seealso} --- 196,415 ---- \section{PEP 327: Decimal Data Type} ! Python has always supported floating-point (FP) numbers as a data ! type, based on the underlying C \ctype{double} type. However, while ! most programming languages provide a floating-point type, most people ! (even programmers) are unaware that computing with floating-point ! numbers entails certain unavoidable inaccuracies. The new decimal ! type provides a way to avoid these inaccuracies. ! \subsection{Why is Decimal needed?} + The limitations arise from the representation used for floating-point numbers. + FP numbers are made up of three components: + + \begin{itemize} + \item The sign, which is -1 or +1. + \item The mantissa, which is a single-digit binary number + followed by a fractional part. For example, \code{1.01} in base-2 notation + is \code{1 + 0/2 + 1/4}, or 1.25 in decimal notation. + \item The exponent, which tells where the decimal point is located in the number represented. + \end{itemize} + + For example, the number 1.25 has sign +1, mantissa 1.01 (in binary), + and exponent of 0 (the decimal point doesn't need to be shifted). The + number 5 has the same sign and mantissa, but the exponent is 2 + because the mantissa is multiplied by 4 (2 to the power of the exponent 2). + + Modern systems usually provide floating-point support that conforms to + a relevant standard called IEEE 754. C's \ctype{double} type is + usually implemented as a 64-bit IEEE 754 number, which uses 52 bits of + space for the mantissa. This means that numbers can only be specified + to 52 bits of precision. If you're trying to represent numbers whose + expansion repeats endlessly, the expansion is cut off after 52 bits. + Unfortunately, most software needs to produce output in base 10, and + base 10 often gives rise to such repeating decimals. For example, 1.1 + decimal is binary \code{1.0001100110011 ...}; .1 = 1/16 + 1/32 + 1/256 + plus an infinite number of additional terms. IEEE 754 has to chop off + that infinitely repeated decimal after 52 digits, so the + representation is slightly inaccurate. + + Sometimes you can see this inaccuracy when the number is printed: \begin{verbatim} ! >>> 1.1 ! 1.1000000000000001 \end{verbatim} ! The inaccuracy isn't always visible when you print the number because ! the FP-to-decimal-string conversion is provided by the C library, and ! most C libraries try to produce sensible output, but the inaccuracy is ! still there and subsequent operations can magnify the error. ! For many applications this doesn't matter. If I'm plotting points and ! displaying them on my monitor, the difference between 1.1 and ! 1.1000000000000001 is too small to be visible. Reports often limit ! output to a certain number of decimal places, and if you round the ! number to two or three or even eight decimal places, the error is ! never apparent. However, for applications where it does matter, ! it's a lot of work to implement your own custom arithmetic routines. ! ! \subsection{The \class{Decimal} type} ! ! A new module, \module{decimal}, was added to Python's standard library. ! It contains two classes, \class{Decimal} and \class{Context}. ! \class{Decimal} instances represent numbers, and ! \class{Context} instances are used to wrap up various settings such as the precision and default rounding mode. ! ! \class{Decimal} instances, like regular Python integers and FP numbers, are immutable; once they've been created, you can't change the value it represents. ! \class{Decimal} instances can be created from integers or strings: \begin{verbatim} ! >>> import decimal ! >>> decimal.Decimal(1972) ! Decimal("1972") ! >>> decimal.Decimal("1.1") ! Decimal("1.1") \end{verbatim} ! You can also provide tuples containing the sign, mantissa represented ! as a tuple of decimal digits, and exponent: \begin{verbatim} ! >>> decimal.Decimal((1, (1, 4, 7, 5), -2)) ! Decimal("-14.75") ! \end{verbatim} ! ! Cautionary note: the sign bit is a Boolean value, so 0 is positive and 1 is negative. ! ! Floating-point numbers posed a bit of a problem: should the FP number ! representing 1.1 turn into the decimal number for exactly 1.1, or for ! 1.1 plus whatever inaccuracies are introduced? The decision was to ! leave such a conversion out of the API. Instead, you should convert ! the floating-point number into a string using the desired precision and ! pass the string to the \class{Decimal} constructor: ! ! \begin{verbatim} ! >>> f = 1.1 ! >>> decimal.Decimal(str(f)) ! Decimal("1.1") ! >>> decimal.Decimal(repr(f)) ! Decimal("1.1000000000000001") ! \end{verbatim} ! ! Once you have \class{Decimal} instances, you can perform the usual ! mathematical operations on them. One limitation: exponentiation ! requires an integer exponent: ! ! \begin{verbatim} ! >>> a = decimal.Decimal('35.72') ! >>> b = decimal.Decimal('1.73') ! >>> a+b ! Decimal("37.45") ! >>> a-b ! Decimal("33.99") ! >>> a*b ! Decimal("61.7956") ! >>> a/b ! Decimal("20.6473988") ! >>> a ** 2 ! Decimal("1275.9184") ! >>> a ** b ! Decimal("NaN") ! \end{verbatim} ! ! You can combine \class{Decimal} instances with integers, but not with ! floating-point numbers: ! ! \begin{verbatim} ! >>> a + 4 ! Decimal("39.72") ! >>> a + 4.5 ! Traceback (most recent call last): ! ... ! TypeError: You can interact Decimal only with int, long or Decimal data types. ! >>> ! \end{verbatim} ! ! \class{Decimal} numbers can be used with the \module{math} and ! \module{cmath} modules, though you'll get back a regular ! floating-point number and not a \class{Decimal}. Instances also have a \method{sqrt()} method: ! ! \begin{verbatim} ! >>> import math, cmath ! >>> d = decimal.Decimal('123456789012.345') ! >>> math.sqrt(d) ! 351364.18288201344 ! >>> cmath.sqrt(-d) ! 351364.18288201344j ! >>> d.sqrt() ! Decimal(``351364.1828820134592177245001'') \end{verbatim} + + + \subsection{The \class{Context} type} + + Instances of the \class{Context} class encapsulate several settings for + decimal operations: + + \begin{itemize} + \item \member{prec} is the precision, the number of decimal places. + \item \member{rounding} specifies the rounding mode. The \module{decimal} + module has constants for the various possibilities: + \constant{ROUND_DOWN}, \constant{ROUND_CEILING}, \constant{ROUND_HALF_EVEN}, and various others. + \item \member{trap_enablers} is a dictionary specifying what happens on + encountering certain error conditions: either an exception is raised or + a value is returned. Some examples of error conditions are + division by zero, loss of precision, and overflow. + \end{itemize} + + There's a thread-local default context available by calling + \function{getcontext()}; you can change the properties of this context + to alter the default precision, rounding, or trap handling. + + \begin{verbatim} + >>> decimal.getcontext().prec + 28 + >>> decimal.Decimal(1) / decimal.Decimal(7) + Decimal(``0.1428571428571428571428571429'') + >>> decimal.getcontext().prec = 9 + >>> decimal.Decimal(1) / decimal.Decimal(7) + Decimal(``0.142857143'') + \end{verbatim} + + The default action for error conditions is to return a special value + such as infinity or not-a-number, but you can request that exceptions + be raised: + + \begin{verbatim} + >>> decimal.Decimal(1) / decimal.Decimal(0) + Decimal(``Infinity'') + >>> decimal.getcontext().trap_enablers[decimal.DivisionByZero] = True + >>> decimal.Decimal(1) / decimal.Decimal(0) + Traceback (most recent call last): + ... + decimal.DivisionByZero: x / 0 + >>> + \end{verbatim} + + The \class{Context} instance also has various methods for formatting + numbers such as \method{to_eng_string()} and \method{to_sci_string()}. + \begin{seealso} \seepep{327}{Decimal Data Type}{Written by Facundo Batista and implemented ! by Facundo Batista, Eric Price, Raymond Hettinger, Aahz, and Tim Peters.} ! ! \seeurl{http://research.microsoft.com/~hollasch/cgindex/coding/ieeefloat.html} ! {A more detailed overview of the IEEE-754 representation.} ! ! \seeurl{http://www.lahey.com/float.htm} ! {The article uses Fortran code to illustrate many of the problems ! that floating-point inaccuracy can cause.} ! ! \seeurl{http://www2.hursley.ibm.com/decimal/} ! {A description of a decimal-based representation. This representation ! is being proposed as a standard, and underlies the new Python decimal ! type. Much of this material was written by Mike Cowlishaw, designer of the ! REXX language.} ! \end{seealso} From akuchling at users.sourceforge.net Sat Jul 3 21:44:07 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sat Jul 3 21:44:09 2004 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew24.tex, 1.57, 1.58 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25119 Modified Files: whatsnew24.tex Log Message: Write another section Index: whatsnew24.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew24.tex,v retrieving revision 1.57 retrieving revision 1.58 diff -C2 -d -r1.57 -r1.58 *** whatsnew24.tex 4 Jul 2004 01:26:42 -0000 1.57 --- whatsnew24.tex 4 Jul 2004 01:44:04 -0000 1.58 *************** *** 91,95 **** \section{PEP 237: Unifying Long Integers and Integers} ! XXX write this. %====================================================================== --- 91,113 ---- \section{PEP 237: Unifying Long Integers and Integers} ! The lengthy transition process for the PEP, begun with Python 2.2, ! takes another step forward in Python 2.4. In 2.3, certain integer ! operations that would behave differently after int/long unification ! triggered \exception{FutureWarning} warnings and returned values ! limited to 32 or 64 bits. In 2.4, these expressions no longer produce ! a warning, but they now produce a different value that's a long ! integer. ! ! The problematic expressions are primarily left shifts and lengthy ! hexadecimal and octal constants. For example, \code{2 << 32} is one ! expression that results in a warning in 2.3, evaluating to 0 on 32-bit ! platforms. In Python 2.4, this expression now returns 8589934592. ! ! ! \begin{seealso} ! \seepep{237}{Unifying Long Integers and Integers}{Original PEP ! written by Moshe Zadka and Gvr. The changes for 2.4 were implemented by ! Kalle Svensson.} ! \end{seealso} %====================================================================== From rhettinger at users.sourceforge.net Sat Jul 3 21:55:56 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Jul 3 21:56:00 2004 Subject: [Python-checkins] python/dist/src/Lib decimal.py,1.5,1.6 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26705 Modified Files: decimal.py Log Message: Fix clear_flags(). Make a readable (not evalable) Context repr. Index: decimal.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/decimal.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** decimal.py 3 Jul 2004 13:48:56 -0000 1.5 --- decimal.py 4 Jul 2004 01:55:39 -0000 1.6 *************** *** 2155,2162 **** del self.self def clear_flags(self): """Reset all flags to zero""" for flag in self.flags: ! self.flag = 0 def copy(self): --- 2155,2170 ---- del self.self + def __repr__(self): + """Show the current context in readable form, not in a form for eval().""" + s = [] + s.append('Context(prec=%(prec)d, rounding=%(rounding)s, Emin=%(Emin)d, Emax=%(Emax)d' % vars(self)) + s.append('setflags=%r' % [f.__name__ for f, v in self.flags.items() if v]) + s.append('settraps=%r' % [t.__name__ for t, v in self.trap_enablers.items() if v]) + return ', '.join(s) + ')' + def clear_flags(self): """Reset all flags to zero""" for flag in self.flags: ! self.flags[flag] = 0 def copy(self): From mondragon at users.sourceforge.net Sun Jul 4 00:47:43 2004 From: mondragon at users.sourceforge.net (mondragon@users.sourceforge.net) Date: Sun Jul 4 00:47:49 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libpdb.tex,1.39,1.40 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16281/lib Modified Files: libpdb.tex Log Message: Textual change to make the doc reflect reality Index: libpdb.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libpdb.tex,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** libpdb.tex 24 Mar 2004 21:57:08 -0000 1.39 --- libpdb.tex 4 Jul 2004 04:47:40 -0000 1.40 *************** *** 394,398 **** \item[\code{'c_call'}] A C function is about to be called. This may be an extension function ! or a builtin. \var{arg} is the C function name. \item[\code{'c_return'}] --- 394,398 ---- \item[\code{'c_call'}] A C function is about to be called. This may be an extension function ! or a builtin. \var{arg} is the C function object. \item[\code{'c_return'}] From rhettinger at users.sourceforge.net Sun Jul 4 02:27:07 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sun Jul 4 02:27:11 2004 Subject: [Python-checkins] python/nondist/sandbox/decimal libdecimal.tex, NONE, 1.1 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/decimal In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27178 Added Files: libdecimal.tex Log Message: Module documentation. Part I --- NEW FILE: libdecimal.tex --- \section{\module{decimal} --- Decimal floating point arithmetic} \declaremodule{standard}{decimal} \modulesynopsis{Implementation of the General Decimal Arithmetic Specification.} \moduleauthor{Eric Price}{eprice at tjhsst.edu} \moduleauthor{Facundo Batista}{facundo at taniquetil.com.ar} \moduleauthor{Raymond Hettinger}{python at rcn.com} \moduleauthor{Aahz}{aahz at pobox.com} \moduleauthor{Tim Peters}{guido@python.org} \sectionauthor{Raymond D. Hettinger}{python at rcn.com} Eric Price # and Facundo Batista # and Raymond Hettinger # and Aahz # and Tim Peters \versionadded{2.4} The decimal \module{module} provides support for decimal floating point arithmetic. It offers several advantages over the \class{float()} data type. Decimal numbers can be represented exactly. In contrast, numbers like \constant{1.1} do not have an exact reprentations in binary floating point. End users typically wound not expect \constant{1.1} to display as \constant{1.1000000000000001} as it does with binary floating point. The exactness carries over to arithmetic. In decimal floating point, \code{0.1 + 0.1 + 0.1 - 0.3} is exactly equal to zero. In binary floating point, result is \constant{5.5511151231257827e-017}. While near to zero, the differences prevent reliable equality testing and differences can accumulate. For this reason, decimal would be preferred in accounting applications which have strict equality invariants. The decimal module incorporates notion signficant places so that \code{1.30 + 1.20} is \constant{2.50}. The trailing zero is kept to indicate significance. This is a customary presentation for monetary applications. For multiplication, a ``schoolbook'' approach uses all the figures in the multiplicands. For instance, \code{1.3 * 1.2} gives \constant{1.56} while \code{1.30 * 1.20} gives \constant{1.5600}. * Unlike hardware based binary floating point, the decimal module has a user settable precision (defaulting to 28 places) which can as large as needed for a given problem: \begin{verbatim} >>> Decimal(1) / Decimal(7) Decimal("0.142857") >>> getcontext().prec = 28 >>> Decimal(1) / Decimal(7) Decimal("0.1428571428571428571428571429") \end{verbatim} * Both binary and decimal floating point are implemented in terms of published standards. The builtin float type exposes only a modest portion of its capabilities. In contrast, the decimal module exposes all required parts of the standard. When needed, the programmer has full control over rounding and handling signals from the underlying implementation. The module design is centered around three concepts: the decimal number, the context for arithmetic, and signals. A decimal number is immutable. It has a sign, coefficient digits, and an exponent. To preserve significance, the coefficient digits do not truncate trailings zeros. Decimals also include special values such as \constant{Infinity} (the result of \code{1 / 0}), \constant{-Infinity}, (the result of \code{-1 / 0}), and \constant{NaN} (the result of \code{0 / 0}). The context for arithmetic is an environment specifying precision, rounding rules, limits on exponents, flags the indicate the results of operations, and trap enablers which determine whether signals are to be treated as exceptions. Rounding options include \constant{ROUND_CEILING}, \constant{ROUND_DOWN}, \constant{ROUND_FLOOR}, \constant{ROUND_HALF_DOWN}, \constant{ROUND_HALF_EVEN}, \constant{ROUND_HALF_UP}, and \constant{ROUND_UP}. Signals are types of information that arise during the course of a computation. Depending on the needs of the application, some signals may be ignored, considered as informational, or treated as exceptions. The signals in the decimal module are: \constant{Clamped}, \constant{InvalidOperation}, \constant{ConversionSyntax}, \constant{DivisionByZero}, \constant{DivisionImpossible}, \constant{DivisionUndefined}, \constant{Inexact}, \constant{InvalidContext}, \constant{Rounded}, \constant{Subnormal}, \constant{Overflow}, \constant{Underflow}. For each there is a flag and a trap enabler. When a signal is encountered, its flag incremented from zero and, then, if the trap enabler is set to one, then the signal will raise an exception. \begin{seealso} \seetext{IBM's General Decimal Arithmetic Specification, \citetitle[http://www2.hursley.ibm.com/decimal/decarith.html] {The General Decimal Arithmetic Specification}.} \seetext{IEEE standard 854-1987, \citetitle[http://www.cs.berkeley.edu/~ejr/projects/754/private/drafts/854-1987/dir.html] {Unofficial IEEE 854 Text}.} \end{seealso} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \subsection{Quick-start Tutorial \label{decimal-tutorial}} \begin{verbatim} >>> getcontext() Context(prec=28, rounding=ROUND_HALF_EVEN, Emin=-999999999, Emax=999999999, setflags=[], settraps=[]) >>> Decimal(5) / Decimal(0) Decimal("Infinity") >>> getcontext() Context(prec=28, rounding=ROUND_HALF_EVEN, Emin=-999999999, Emax=999999999, setflags=['DivisionByZero'], settraps=[]) \end{verbatim} The division by zero, set a flag indicating that the signal occurred. Since no trap was set, the computation continued without raising an exception. \begin{verbatim} >>> getcontext().clear_flags() >>> getcontext() >>> getcontext().trap_enablers[DivisionByZero] = 1 >>> Decimal(5) / Decimal(0) Traceback (most recent call last): File "", line 1, in -toplevel- Decimal(5) / Decimal(0) DivisionByZero: x / 0 \end{verbatim} This time, with the DivisionByZero trap enabled, the computation raises an exception. The trap enablers and flags provide the programmer with fine control over what is considered to be an exception, what is information, and what can be ignored. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \subsection{Decimal objects \label{decimal-decimal}} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \subsection{Context objects \label{decimal-decimal}} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \subsection{Signals \label{decimal-signals}} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \subsection{Working with threads \label{decimal-threads}} From t-meyer at ihug.co.nz Sun Jul 4 02:35:42 2004 From: t-meyer at ihug.co.nz (Tony Meyer) Date: Sun Jul 4 02:35:52 2004 Subject: [Python-checkins] python/nondist/sandbox/decimal libdecimal.tex, NONE, 1.1 In-Reply-To: <1ED4ECF91CDED24C8D012BCF2B034F1306FA0895@its-xchg4.massey.ac.nz> Message-ID: <1ED4ECF91CDED24C8D012BCF2B034F130467807B@its-xchg4.massey.ac.nz> [...] > \moduleauthor{Tim Peters}{guido@python.org} [...] Is this correct? (I guess it could be, but it does look odd). =Tony Meyer From rhettinger at users.sourceforge.net Sun Jul 4 02:52:05 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sun Jul 4 02:52:09 2004 Subject: [Python-checkins] python/nondist/sandbox/decimal libdecimal.tex, 1.1, 1.2 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/decimal In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30142 Modified Files: libdecimal.tex Log Message: Fix nits. Index: libdecimal.tex =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/decimal/libdecimal.tex,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** libdecimal.tex 4 Jul 2004 06:27:04 -0000 1.1 --- libdecimal.tex 4 Jul 2004 06:52:03 -0000 1.2 *************** *** 10,14 **** \moduleauthor{Raymond Hettinger}{python at rcn.com} \moduleauthor{Aahz}{aahz at pobox.com} ! \moduleauthor{Tim Peters}{guido@python.org} \sectionauthor{Raymond D. Hettinger}{python at rcn.com} --- 10,14 ---- \moduleauthor{Raymond Hettinger}{python at rcn.com} \moduleauthor{Aahz}{aahz at pobox.com} ! \moduleauthor{Tim Peters}{tim.one at comcast.net} \sectionauthor{Raymond D. Hettinger}{python at rcn.com} *************** *** 24,35 **** The decimal \module{module} provides support for decimal floating point ! arithmetic. It offers several advantages over the \class{float()} data type. ! Decimal numbers can be represented exactly. In contrast, numbers like ! \constant{1.1} do not have an exact reprentations in binary floating point. End users typically wound not expect \constant{1.1} to display as \constant{1.1000000000000001} as it does with binary floating point. ! The exactness carries over to arithmetic. In decimal floating point, \code{0.1 + 0.1 + 0.1 - 0.3} is exactly equal to zero. In binary floating point, result is \constant{5.5511151231257827e-017}. While near to zero, the --- 24,37 ---- The decimal \module{module} provides support for decimal floating point ! arithmetic. It offers several advantages over the \class{float()} data type: ! \begin{itemize} ! ! \item Decimal numbers can be represented exactly. In contrast, numbers like ! \constant{1.1} do not have an exact representations in binary floating point. End users typically wound not expect \constant{1.1} to display as \constant{1.1000000000000001} as it does with binary floating point. ! \item The exactness carries over to arithmetic. In decimal floating point, \code{0.1 + 0.1 + 0.1 - 0.3} is exactly equal to zero. In binary floating point, result is \constant{5.5511151231257827e-017}. While near to zero, the *************** *** 38,50 **** have strict equality invariants. ! The decimal module incorporates notion signficant places so that \code{1.30 + 1.20} is \constant{2.50}. The trailing zero is kept to indicate significance. This is a customary presentation for monetary applications. For ! multiplication, a ``schoolbook'' approach uses all the figures in the multiplicands. For instance, \code{1.3 * 1.2} gives \constant{1.56} while \code{1.30 * 1.20} gives \constant{1.5600}. ! * Unlike hardware based binary floating point, the decimal module has a user ! settable precision (defaulting to 28 places) which can as large as needed for a given problem: --- 40,52 ---- have strict equality invariants. ! \item The decimal module incorporates notion of significant places so that \code{1.30 + 1.20} is \constant{2.50}. The trailing zero is kept to indicate significance. This is a customary presentation for monetary applications. For ! multiplication, the ``schoolbook'' approach uses all the figures in the multiplicands. For instance, \code{1.3 * 1.2} gives \constant{1.56} while \code{1.30 * 1.20} gives \constant{1.5600}. ! \item Unlike hardware based binary floating point, the decimal module has a user ! settable precision (defaulting to 28 places) which can be as large as needed for a given problem: *************** *** 57,65 **** \end{verbatim} ! * Both binary and decimal floating point are implemented in terms of published ! standards. The builtin float type exposes only a modest portion of its ! capabilities. In contrast, the decimal module exposes all required parts of ! the standard. When needed, the programmer has full control over rounding and ! handling signals from the underlying implementation. The module design is centered around three concepts: the decimal number, the --- 59,69 ---- \end{verbatim} ! \item Both binary and decimal floating point are implemented in terms of published ! standards. While the built-in float type exposes only a modest portion of its ! capabilities, the decimal module exposes all required parts of the standard. ! When needed, the programmer has full control over rounding and signal handling. ! ! \end{itemize} ! The module design is centered around three concepts: the decimal number, the *************** *** 68,78 **** A decimal number is immutable. It has a sign, coefficient digits, and an exponent. To preserve significance, the coefficient digits do not truncate ! trailings zeros. Decimals also include special values such as \constant{Infinity} (the result of \code{1 / 0}), \constant{-Infinity}, (the result of \code{-1 / 0}), and \constant{NaN} (the result of ! \code{0 / 0}). The context for arithmetic is an environment specifying precision, rounding ! rules, limits on exponents, flags the indicate the results of operations, and trap enablers which determine whether signals are to be treated as exceptions. Rounding options include \constant{ROUND_CEILING}, --- 72,83 ---- A decimal number is immutable. It has a sign, coefficient digits, and an exponent. To preserve significance, the coefficient digits do not truncate ! trailing zeroes. Decimals also include special values such as \constant{Infinity} (the result of \code{1 / 0}), \constant{-Infinity}, (the result of \code{-1 / 0}), and \constant{NaN} (the result of ! \code{0 / 0}). The standard also differentiates \constant{-0} from ! \constant{+0}. The context for arithmetic is an environment specifying precision, rounding ! rules, limits on exponents, flags that indicate the results of operations, and trap enablers which determine whether signals are to be treated as exceptions. Rounding options include \constant{ROUND_CEILING}, *************** *** 87,95 **** \constant{DivisionImpossible}, \constant{DivisionUndefined}, \constant{Inexact}, \constant{InvalidContext}, \constant{Rounded}, ! \constant{Subnormal}, \constant{Overflow}, \constant{Underflow}. ! For each there is a flag and a trap enabler. When a signal is encountered, ! its flag incremented from zero and, then, if the trap enabler is set to ! one, then the signal will raise an exception. --- 92,100 ---- \constant{DivisionImpossible}, \constant{DivisionUndefined}, \constant{Inexact}, \constant{InvalidContext}, \constant{Rounded}, ! \constant{Subnormal}, \constant{Overflow}, and \constant{Underflow}. ! For each signal there is a flag and a trap enabler. When a signal is ! encountered, its flag incremented from zero and, then, if the trap enabler ! is set to one, an exception is raised. From rhettinger at users.sourceforge.net Sun Jul 4 03:42:45 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sun Jul 4 03:42:50 2004 Subject: [Python-checkins] python/nondist/sandbox/decimal libdecimal.tex, 1.2, 1.3 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/decimal In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4871 Modified Files: libdecimal.tex Log Message: Add the threading section Index: libdecimal.tex =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/decimal/libdecimal.tex,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** libdecimal.tex 4 Jul 2004 06:52:03 -0000 1.2 --- libdecimal.tex 4 Jul 2004 07:42:41 -0000 1.3 *************** *** 157,158 **** --- 157,198 ---- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \subsection{Working with threads \label{decimal-threads}} + + The \function{getcontext()} function accesses a different \class{Context} + object for each thread. Having separate contexts means that threads may make + changes (such as \code{getcontext.prec=10}) without interfering with other + threads and without needing mutexes. + + Likewise, the \function{setcontext()} function automatically assigns its target + to the current thread. + + If \function{setcontext()} has not been called before \function{getcontext()}, + then \function{getcontext()} will automatically create a new context for use + in the current thread. + + The new context is copied from a prototype context called \var{DefaultContext}. + To control the defaults so that each thread will use the same values + throughout the application, directly modify the \var{DefaultContext} object. + This should be done \emph{before} any threads are started so that there won't + be a race condition with threads calling \function{getcontext()}. For example: + + \begin{verbatim} + # Set application wide defaults for all threads about to be launched + DefaultContext.prec=12 + DefaultContext.rounding=ROUND_DOWN + DefaultContext.trap_enablers=dict.fromkeys(Signals, 0) + setcontext(DefaultContext) + + # Now start all of the threads + t1.start() + t2.start() + t3.start() + . . . + \end{verbatim} + + + + + + + + From rhettinger at users.sourceforge.net Sun Jul 4 04:55:47 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sun Jul 4 04:55:53 2004 Subject: [Python-checkins] python/nondist/sandbox/decimal libdecimal.tex, 1.3, 1.4 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/decimal In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14446 Modified Files: libdecimal.tex Log Message: Add the signals section Index: libdecimal.tex =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/decimal/libdecimal.tex,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** libdecimal.tex 4 Jul 2004 07:42:41 -0000 1.3 --- libdecimal.tex 4 Jul 2004 08:55:42 -0000 1.4 *************** *** 155,158 **** --- 155,296 ---- \subsection{Signals \label{decimal-signals}} + Signals represent conditions that arise during computation. + Each corresponds to one context flag and one context trap enabler. + + The context flag is incremented whenever the condition is encountered. + After the computation, flags may be checked for informational + purposed (for instance, to determine whether a computation was exact). + After checking the flags, be sure to clear all flags before starting + the next computation. + + If the context's trap enable is set for the signal, then the condition + causes a Python exception to be raised. For example, if the + \class{DivisionByZero} trap is set, the a \exception{DivisionByZero} + exception is raised upon encountering the condition. + + + + \begin{classdesc*}{Clamped} + Altered an exponent to fit representation constraints. + + Typically, clamping occurs when an exponent falls outside the context's + \member{Emin} and \member{Emax} limits. If possible, the exponent is + reduced to fit by adding zeroes to the coefficient. + \end{classdesc*} + + + \begin{classdesc*}{ConversionSyntax} + Trying to convert a mal-formed string such as: \code{Decimal('jump')}. + + Decimal converts only strings conforming to the numeric string + syntax. If this signal is not trapped, returns \constant{NaN}. + \end{classdesc*} + + + \begin{classdesc*}{DecimalException} + Base class for other signals. + \end{classdesc*} + + + \begin{classdesc*}{DivisionByZero} + Signals the division of a non-infinite number by zero. + + Can occur with division, modulo division, or when raising a number to + a negative power. If this signal is not trapped, return + \constant{Infinity} or \constant{-Infinity} with sign determined by + the inputs to the calculation. + \end{classdesc*} + + + \begin{classdesc*}{DivisionImpossible} + Error performing a division operation. Caused when an intermediate result + has more digits that the allowed by the current precision. If not trapped, + returns \constant{NaN}. + \end{classdesc*} + + + \begin{classdesc*}{DivisionUndefined} + This is a subclass of \class{DivisionByZero}. + + It occurs only in the context of division operations. + \end{classdesc*} + + + \begin{classdesc*}{Inexact} + Indicates that rounding occurred and the result is not exact. + + Signals whenever non-zero digits were discarded during rounding. + The rounded result is returned. The signal flag or trap is used + to detect when results are inexact. + \end{classdesc*} + + + \begin{classdesc*}{InvalidContext} + This is a subclass of \class{InvalidOperation}. + + Indicates an error within the Context object such as an unknown + rounding operation. If not trapped, returns \constant{NaN}. + \end{classdesc*} + + + \begin{classdesc*}{InvalidOperation} + An invalid operation was performed. + + Indicates that an operation was requested that does not make sense. + If not trapped, returns \constant{NaN}. Possible causes include: + + \begin{verbatim} + Infinity - Infinity + 0 * Infinity + Infinity / Infinity + x % 0 + Infinity % x + x._rescale( non-integer ) + sqrt(-x) and x > 0 + 0 ** 0 + x ** (non-integer) + x ** Infinity + \end{verbatim} + \end{classdesc*} + + + \begin{classdesc*}{Overflow} + Numerical overflow. + + Indicates the exponent is larger than \member{Emax} after rounding has + occurred. If not trapped, the result depends on the rounding mode, either + pulling inward to the largest representable finite number or rounding + outward to \constant{Infinity}. In either case, \class{Inexact} and + \class{Rounded} are also signaled. + \end{classdesc*} + + + \begin{classdesc*}{Rounded} + Rounding occurred though possibly not information was lost. + + Signaled whenever rounding discards digits; even if those digits are + zero (such as rounding \constant{5.00} to \constant{5.0}). If not + trapped, returns the result unchanged. This signal is used to detect + loss of significant digits. + \end{classdesc*} + + + \begin{classdesc*}{Subnormal} + Exponent was lower than \member{Emin} prior to rounding. + + Occurs when an operation result is subnormal (the exponent is too small). + If not trapped, returns the result unchanged. + \end{classdesc*} + + + \begin{classdesc*}{Underflow} + Numerical underflow with result rounded to zero. + + Occurs when a subnormal result is pushed to zero by rounding. + \class{Inexact} and \class{Subnormal} are also signaled. + \end{classdesc*} + + + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \subsection{Working with threads \label{decimal-threads}} From rhettinger at users.sourceforge.net Sun Jul 4 06:52:19 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sun Jul 4 06:52:23 2004 Subject: [Python-checkins] python/nondist/sandbox/decimal libdecimal.tex, 1.4, 1.5 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/decimal In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29793 Modified Files: libdecimal.tex Log Message: Add the tutorial section Index: libdecimal.tex =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/decimal/libdecimal.tex,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** libdecimal.tex 4 Jul 2004 08:55:42 -0000 1.4 --- libdecimal.tex 4 Jul 2004 10:52:14 -0000 1.5 *************** *** 34,38 **** \item The exactness carries over to arithmetic. In decimal floating point, ! \code{0.1 + 0.1 + 0.1 - 0.3} is exactly equal to zero. In binary floating point, result is \constant{5.5511151231257827e-017}. While near to zero, the differences prevent reliable equality testing and differences can accumulate. --- 34,38 ---- \item The exactness carries over to arithmetic. In decimal floating point, ! \samp{0.1 + 0.1 + 0.1 - 0.3} is exactly equal to zero. In binary floating point, result is \constant{5.5511151231257827e-017}. While near to zero, the differences prevent reliable equality testing and differences can accumulate. *************** *** 41,49 **** \item The decimal module incorporates notion of significant places so that ! \code{1.30 + 1.20} is \constant{2.50}. The trailing zero is kept to indicate significance. This is a customary presentation for monetary applications. For multiplication, the ``schoolbook'' approach uses all the figures in the ! multiplicands. For instance, \code{1.3 * 1.2} gives \constant{1.56} while ! \code{1.30 * 1.20} gives \constant{1.5600}. \item Unlike hardware based binary floating point, the decimal module has a user --- 41,49 ---- \item The decimal module incorporates notion of significant places so that ! \samp{1.30 + 1.20} is \constant{2.50}. The trailing zero is kept to indicate significance. This is a customary presentation for monetary applications. For multiplication, the ``schoolbook'' approach uses all the figures in the ! multiplicands. For instance, \samp{1.3 * 1.2} gives \constant{1.56} while ! \samp{1.30 * 1.20} gives \constant{1.5600}. \item Unlike hardware based binary floating point, the decimal module has a user *************** *** 73,79 **** exponent. To preserve significance, the coefficient digits do not truncate trailing zeroes. Decimals also include special values such as ! \constant{Infinity} (the result of \code{1 / 0}), \constant{-Infinity}, ! (the result of \code{-1 / 0}), and \constant{NaN} (the result of ! \code{0 / 0}). The standard also differentiates \constant{-0} from \constant{+0}. --- 73,79 ---- exponent. To preserve significance, the coefficient digits do not truncate trailing zeroes. Decimals also include special values such as ! \constant{Infinity} (the result of \samp{1 / 0}), \constant{-Infinity}, ! (the result of \samp{-1 / 0}), and \constant{NaN} (the result of ! \samp{0 / 0}). The standard also differentiates \constant{-0} from \constant{+0}. *************** *** 114,147 **** \subsection{Quick-start Tutorial \label{decimal-tutorial}} \begin{verbatim} >>> getcontext() Context(prec=28, rounding=ROUND_HALF_EVEN, Emin=-999999999, Emax=999999999, setflags=[], settraps=[]) ! >>> Decimal(5) / Decimal(0) Decimal("Infinity") ! >>> getcontext() ! Context(prec=28, rounding=ROUND_HALF_EVEN, Emin=-999999999, Emax=999999999, ! setflags=['DivisionByZero'], settraps=[]) \end{verbatim} ! The division by zero, set a flag indicating that the signal occurred. Since ! no trap was set, the computation continued without raising an exception. \begin{verbatim} >>> getcontext().clear_flags() >>> getcontext() >>> getcontext().trap_enablers[DivisionByZero] = 1 ! >>> Decimal(5) / Decimal(0) Traceback (most recent call last): ! File "", line 1, in -toplevel- ! Decimal(5) / Decimal(0) DivisionByZero: x / 0 \end{verbatim} ! This time, with the DivisionByZero trap enabled, the computation raises an ! exception. The trap enablers and flags provide the programmer with fine ! control over what is considered to be an exception, what is information, ! and what can be ignored. --- 114,293 ---- \subsection{Quick-start Tutorial \label{decimal-tutorial}} + The normal start to using decimals is to import the module, and then use + \function{getcontext()} to view the context and, if necessary, set the context + precision, rounding, or trap enablers: + \begin{verbatim} + >>> from decimal import * >>> getcontext() Context(prec=28, rounding=ROUND_HALF_EVEN, Emin=-999999999, Emax=999999999, setflags=[], settraps=[]) ! ! >>> getcontext().prec = 7 ! \end{verbatim} ! ! Decimal instances can be constructed from integers or strings. To create a ! Decimal from a \class{float}, first convert it to a string. This serves as an ! explicit reminder of the details of the conversion (including representation ! error). Malformed strings signal \constant{ConversionSyntax} and return a ! special kind of Decimal called a \constant{NaN} which stands for ``Not a ! number''. Positive and negative \constant{Infinity} is yet another special ! kind of Decimal. ! ! \begin{verbatim} ! >>> Decimal(10) ! Decimal("10") ! >>> Decimal('3.14') ! Decimal("3.14") ! >>> Decimal(str(2.0 ** 0.5)) ! Decimal("1.41421356237") ! >>> Decimal('Mickey Mouse') ! Decimal("NaN") ! >>> Decimal('-Infinity') ! Decimal("-Infinity") ! \end{verbatim} ! ! Creating decimals is unaffected by context precision. Their level of ! significance is completely determined by the number of digits input. It is ! the arithmetic operations that are governed by the context. ! ! \begin{verbatim} ! >>> getcontext().prec = 6 ! >>> Decimal('3.0000') ! Decimal("3.0000") ! >>> Decimal('3.0') ! Decimal("3.0") ! >>> Decimal('3.1415926535') ! Decimal("3.1415926535") ! >>> Decimal('3.1415926535') + Decimal('2.7182818285') ! Decimal("5.85987") ! >>> getcontext().rounding = ROUND_UP ! >>> Decimal('3.1415926535') + Decimal('2.7182818285') ! Decimal("5.85988") ! \end{verbatim} ! ! Decimals interact well with much of the rest of python. Here is a small ! flying circus of work with decimal floating point: ! ! \begin{verbatim} ! >>> data = map(Decimal, '1.34 1.87 3.45 2.35 1.00 0.03 9.25'.split()) ! >>> max(data) ! Decimal("9.25") ! >>> min(data) ! Decimal("0.03") ! >>> sorted(data) ! [Decimal("0.03"), Decimal("1.00"), Decimal("1.34"), Decimal("1.87"), ! Decimal("2.35"), Decimal("3.45"), Decimal("9.25")] ! >>> sum(data) ! Decimal("19.29") ! >>> a,b,c = data[:3] ! >>> str(a) ! '1.34' ! >>> float(a) ! 1.3400000000000001 ! >>> round(a, 1) ! 1.3 ! >>> int(a) ! 1 ! >>> a * 5 ! Decimal("6.70") ! >>> a * b ! Decimal("2.5058") ! >>> c % a ! Decimal("0.77") ! \end{verbatim} ! ! The \function{getcontext()} function accesses the current context. This one ! context is sufficient for many applications; however, for more advanced work, ! multiple contexts can be created using the Context() constructor. To make a ! new context active, use the \function{setcontext()} function. ! ! In accordance with the standard, the \module{Decimal} module provides two ! ready to use standard contexts, \constant{BasicContext} and ! \constant{ExtendedContext}. The former is especially useful for debugging ! because many of the traps are enabled: ! ! \begin{verbatim} ! >>> myothercontext = Context(prec=60, rounding=ROUND_HALF_DOWN) ! >>> myothercontext ! Context(prec=60, rounding=ROUND_HALF_DOWN, Emin=-999999999, Emax=999999999, ! setflags=[], settraps=[]) ! >>> ExtendedContext ! Context(prec=9, rounding=ROUND_HALF_EVEN, Emin=-999999999, Emax=999999999, ! setflags=[], settraps=[]) ! >>> setcontext(myothercontext) ! >>> Decimal(1) / Decimal(7) ! Decimal("0.142857142857142857142857142857142857142857142857142857142857") ! >>> setcontext(ExtendedContext) ! >>> Decimal(1) / Decimal(7) ! Decimal("0.142857143") ! >>> Decimal(42) / Decimal(0) Decimal("Infinity") ! >>> setcontext(BasicContext) ! >>> Decimal(42) / Decimal(0) ! Traceback (most recent call last): ! File "", line 1, in -toplevel- ! Decimal(42) / Decimal(0) ! DivisionByZero: x / 0 \end{verbatim} ! Besides using contexts to control precision, rounding, and trapping signals, ! they can be used to monitor flags which give information collected during ! computation. The flags remain set until explicitly cleared, so it is best to ! clear the flags before each set of monitored computations by using the ! \method{clear_flags()} method. \begin{verbatim} + >>> setcontext(ExtendedContext) >>> getcontext().clear_flags() + >>> Decimal(355) / Decimal(113) + Decimal("3.14159292") >>> getcontext() + Context(prec=9, rounding=ROUND_HALF_EVEN, Emin=-999999999, Emax=999999999, + setflags=['Inexact', 'Rounded'], settraps=[]) + \end{verbatim} + + The \var{setflags} entry shows that the rational approximation to + \constant{Pi} was rounded (digits beyond the context precision were thrown + away) and that the result is inexact (some of the discarded digits were + non-zero). + + Individual traps are set using the dictionary in the \member{trap_enablers} + field of a context: + + \begin{verbatim} + >>> Decimal(1) / Decimal(0) + Decimal("Infinity") >>> getcontext().trap_enablers[DivisionByZero] = 1 ! >>> Decimal(1) / Decimal(0) Traceback (most recent call last): ! File "", line 1, in -toplevel- ! Decimal(1) / Decimal(0) DivisionByZero: x / 0 \end{verbatim} ! To turn all the traps on or off all at once, use a loop. Also, the ! \method{dict.update()} method is useful for changing a few particular values. ! ! \begin{verbatim} ! >>> getcontext.clear_flags() ! >>> for sig in getcontext().trap_enablers: ! ... getcontext().trap_enablers[sig] = 1 ! ! >>> getcontext().trap_enablers.update({Rounded:0, Inexact:0, Subnormal:0}) ! >>> getcontext() ! Context(prec=9, rounding=ROUND_HALF_EVEN, Emin=-999999999, Emax=999999999, ! setflags=[], settraps=['Underflow', 'DecimalException', 'Clamped', ! 'InvalidContext', 'InvalidOperation', 'ConversionSyntax', ! 'DivisionByZero', 'DivisionImpossible', 'DivisionUndefined', ! 'Overflow']) ! \end{verbatim} ! ! Applications typically set the context once at the beginning of a program ! and no further changes are needed. For many applications, the data resides ! in a resource external to the program and is converted to \class{Decimal} with ! a single cast inside a loop. Afterwards, decimals are as easily manipulated ! as other Python numeric types. From rhettinger at users.sourceforge.net Sun Jul 4 09:53:36 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sun Jul 4 09:53:41 2004 Subject: [Python-checkins] python/dist/src/Lib decimal.py,1.6,1.7 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30580 Modified Files: decimal.py Log Message: Changed the rounding constant values to match their variable names. This serves to made the context representation more useful (the names in match the names out). Removed the link to ReXX. That document did not shed add anything to information already in the spec. Further tighten the public API to improve usability: * Emax and Emin are set through Context(). Their defaults are set in the DefaultContext, so there is no need to expose DEFAULT_MAX_EXPONENT and DEFAULT_MIN_EXPONENT. * The string functions isnan() and isinfinity() were only used internal to the module and were not among the test cases. External use cases are served by the Decimal constructor. So, made these private. Index: decimal.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/decimal.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** decimal.py 4 Jul 2004 01:55:39 -0000 1.6 --- decimal.py 4 Jul 2004 13:53:24 -0000 1.7 *************** *** 19,31 **** www2.hursley.ibm.com/decimal/decarith.html ! IEEE standard 854-1987: www.cs.berkeley.edu/~ejr/projects/754/private/drafts/854-1987/dir.html - and ANSI standard X3.274-1996: - - www.rexxla.org/Standards/ansi.html - - Decimal floating point has finite precision with arbitrarily large bounds. --- 19,26 ---- www2.hursley.ibm.com/decimal/decarith.html ! and IEEE standard 854-1987: www.cs.berkeley.edu/~ejr/projects/754/private/drafts/854-1987/dir.html Decimal floating point has finite precision with arbitrarily large bounds. *************** *** 129,135 **** 'Underflow', - # Module parameters - 'DEFAULT_MAX_EXPONENT', 'DEFAULT_MIN_EXPONENT', - # Constants for use in setting up contexts 'ROUND_DOWN', 'ROUND_HALF_UP', 'ROUND_HALF_EVEN', 'ROUND_CEILING', --- 124,127 ---- *************** *** 138,145 **** # Functions for manipulating contexts ! 'setcontext', 'getcontext', ! ! # Functions for working with decimals ! 'isinfinity', 'isnan', ] --- 130,134 ---- # Functions for manipulating contexts ! 'setcontext', 'getcontext' ] *************** *** 154,168 **** #Rounding ! ROUND_DOWN = 'down' ! ROUND_HALF_UP = 'half_up' ! ROUND_HALF_EVEN = 'half_even' ! ROUND_CEILING = 'ceiling' ! ROUND_FLOOR = 'floor' ! ROUND_UP = 'up' ! ROUND_HALF_DOWN = 'half_down' #Rounding decision (not part of the public API) ! NEVER_ROUND = 'never' # Round in division (non-divmod), sqrt ONLY ! ALWAYS_ROUND = 'always' # Every operation rounds at end. #Errors --- 143,157 ---- #Rounding ! ROUND_DOWN = 'ROUND_DOWN' ! ROUND_HALF_UP = 'ROUND_HALF_UP' ! ROUND_HALF_EVEN = 'ROUND_HALF_EVEN' ! ROUND_CEILING = 'ROUND_CEILING' ! ROUND_FLOOR = 'ROUND_FLOOR' ! ROUND_UP = 'ROUND_UP' ! ROUND_HALF_DOWN = 'ROUND_HALF_DOWN' #Rounding decision (not part of the public API) ! NEVER_ROUND = 'NEVER_ROUND' # Round in division (non-divmod), sqrt ONLY ! ALWAYS_ROUND = 'ALWAYS_ROUND' # Every operation rounds at end. #Errors *************** *** 469,476 **** # REs insist on real strings, so we can too. if isinstance(value, basestring): ! if isinfinity(value): self._exp = 'F' self._int = (0,) ! sign = isinfinity(value) if sign == 1: self._sign = 0 --- 458,465 ---- # REs insist on real strings, so we can too. if isinstance(value, basestring): ! if _isinfinity(value): self._exp = 'F' self._int = (0,) ! sign = _isinfinity(value) if sign == 1: self._sign = 0 *************** *** 478,483 **** self._sign = 1 return ! if isnan(value): ! sig, sign, diag = isnan(value) if len(diag) > context.prec: #Diagnostic info too long self._sign, self._int, self._exp = \ --- 467,472 ---- self._sign = 1 return ! if _isnan(value): ! sig, sign, diag = _isnan(value) if len(diag) > context.prec: #Diagnostic info too long self._sign, self._int, self._exp = \ *************** *** 2128,2133 **** (Whether or not the trap_enabler is set) Should be reset by user of Decimal instance. ! Emin - Minimum exponent (defaults to -999999999) ! Emax - Maximum exponent (defaults to 999999999) capitals - If 1, 1*10^1 is printed as 1E+1. If 0, printed as 1e1 --- 2117,2122 ---- (Whether or not the trap_enabler is set) Should be reset by user of Decimal instance. ! Emin - Minimum exponent ! Emax - Maximum exponent capitals - If 1, 1*10^1 is printed as 1E+1. If 0, printed as 1e1 *************** *** 2141,2145 **** trap_enablers=None, flags=None, _rounding_decision=None, ! Emin=DEFAULT_MIN_EXPONENT, Emax=DEFAULT_MAX_EXPONENT, capitals=1, _clamp=0, _ignored_flags=[]): --- 2130,2134 ---- trap_enablers=None, flags=None, _rounding_decision=None, ! Emin=None, Emax=None, capitals=1, _clamp=0, _ignored_flags=[]): *************** *** 2928,2940 **** } ! def isinfinity(num): """Determines whether a string or float is infinity. ! +1 for positive infinity; 0 for finite ; +1 for positive infinity """ num = str(num).lower() return _infinity_map.get(num, 0) ! def isnan(num): """Determines whether a string or float is NaN --- 2917,2929 ---- } ! def _isinfinity(num): """Determines whether a string or float is infinity. ! +1 for negative infinity; 0 for finite ; +1 for positive infinity """ num = str(num).lower() return _infinity_map.get(num, 0) ! def _isnan(num): """Determines whether a string or float is NaN *************** *** 2979,2982 **** --- 2968,2973 ---- flags=None, _rounding_decision=ALWAYS_ROUND, + Emax=DEFAULT_MAX_EXPONENT, + Emin=DEFAULT_MIN_EXPONENT ) From rhettinger at users.sourceforge.net Sun Jul 4 10:04:08 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sun Jul 4 10:04:12 2004 Subject: [Python-checkins] python/nondist/sandbox/decimal libdecimal.tex, 1.5, 1.6 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/decimal In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv308 Modified Files: libdecimal.tex Log Message: Add the section for Decimal objects. Index: libdecimal.tex =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/decimal/libdecimal.tex,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** libdecimal.tex 4 Jul 2004 10:52:14 -0000 1.5 --- libdecimal.tex 4 Jul 2004 14:03:59 -0000 1.6 *************** *** 1,3 **** ! \section{\module{decimal} --- Decimal floating point arithmetic} --- 1,3 ---- ! \section{\module{decimal} --- Decimal floating point arithmetic} *************** *** 295,301 **** --- 295,434 ---- \subsection{Decimal objects \label{decimal-decimal}} + \begin{classdesc}{Decimal}{\optional{value \optional{, context}}} + Constructs a new \class{Decimal} object based from the \var{value}. + + \var{value} can be an integer, string, or another \class{Decimal} object. + If no \var{value} is given, returns \code{Decimal("0")}. If \var{value} is + a string, it should conform to the decimal numeric string syntax: + + \begin{verbatim} + sign ::= ’+’ | ’-’ + digit ::= ’0’ | ’1’ | ’2’ | ’3’ | ’4’ | ’5’ | ’6’ | ’7’ | ’8’ | ’9’ + indicator ::= ’e’ | ’E’ + digits ::= digit [digit]... + decimal-part ::= digits ’.’ [digits] | [’.’] digits + exponent-part ::= indicator [sign] digits + infinity ::= ’Infinity’ | ’Inf’ + nan ::= ’NaN’ [digits] | ’sNaN’ [digits] + numeric-value ::= decimal-part [exponent-part] | infinity + numeric-string ::= [sign] numeric-value | [sign] nan + \end{verbatim} + + The supplied \var{context} or, if not specified, the current context + governs only the handling of mal-formed strings not conforming to the + numeric string syntax. If the context traps \constant{ConversionSyntax}, + an exception is raised; otherwise, the constructor returns a new Decimal + with the value of \constant{NaN}. + + The context serves no other purpose. The number of significant digits + recorded is determined solely by the \var{value} and the var{context} + precision is not a factor. For example, \samp{Decimal("3.0000")} records + all four zeroes even if the context precision is only three. + + Once constructed, \class{Decimal} objects are immutable. + \end{classdesc} + + Decimal floating point objects share many properties with the other builtin + numeric types such as \class{float} and \class{int}. All of the usual + math operations and special methods apply. Likewise, decimal objects can + be copied, pickled, printed, used as dictionary keys, used as set elements, + compared, sorted, or coerced to another type (such as \class{float} + or \class{long}). + + In addition to the standard numeric properties, decimal floating point objects + have a number of more specialized methods: + + \begin{methoddesc}{adjusted}{} + Return the number's adjusted exponent that results from shifting out the + coefficients rightmost digits until only the lead digit remains: + \code{Decimal("321e+5").adjusted()} returns seven. Used for determining + the place value of the most significant digit. + \end{methoddesc} + + \begin{methoddesc}{as_tuple}{} + Returns a tuple representation of the number: + \samp{(sign, digittuple, exponent)}. + \end{methoddesc} + + \begin{methoddesc}{compare}{other\optional{, context}} + Compares like \method{__cmp__()} but returns a decimal instance: + \begin{verbatim} + a or b is a NaN ==> Decimal("NaN") + a < b ==> Decimal("-1") + a == b ==> Decimal("0") + a > b ==> Decimal("1") + \end{verbatim} + \end{methoddesc} + + \begin{methoddesc}{max}{other\optional{, context}} + Like \samp{max(self, other)} but returns \constant{NaN} if either is a + \constant{NaN}. Applies the context rounding rule before returning. + \end{methoddesc} + + \begin{methoddesc}{min}{other\optional{, context}} + Like \samp{min(self, other)} but returns \constant{NaN} if either is a + \constant{NaN}. Applies the context rounding rule before returning. + \end{methoddesc} + + \begin{methoddesc}{normalize}{\optional{context}} + Normalize the number by striping the rightmost trailing zeroes and + converting any result equal to \constant{Decimal("0")} to Decimal("0e0"). + Used for producing a canonical value for members of an equivalence class. + For example, \code{Decimal("32.100")} and \code{Decimal("0.321000e+2")} + both normalize to the equivalent value \code{Decimal("32.1")} + \end{methoddesc} + + \begin{methoddesc}{quantize} + {\optional{exp \optional{, rounding\optional{, context\optional{, watchexp}}}}} + Quantize to make the exponent the same as \var{exp}. Searches for a + rounding method in \var{rounding}, then in \var{context}, and then + in the current context. + + Of \var{watchexp} is set (default), then an error is returned if + the resulting exponent is greater than \member{Emax} or less than + \member{Etiny}. + \end{methoddesc} + + \begin{methoddesc}{remainder_near}{other\optional{, context}} + Computed the modulo as either a positive or negative value depending + on which is closest to zero. For instance, + \samp{Decimal(10).remainder_near(6)} returns \code{Decimal("-2")} + which is closer to zero than \code{Decimal("4")}. + + If both are equally close, the one chosen will have the same sign + as \var{self}. + \end{methoddesc} + + \begin{methoddesc}{same_quantum{other\optional{, context}}} + Test whether self and other have the same exponent or whether both + are \constant{NaN}. + \end{methoddesc} + + \begin{methoddesc}{sqrt}{\optional{context}} + Return the square root to full precision. + \end{methoddesc} + + \begin{methoddesc}{to_eng_string}{\optional{context}} + Convert to engineering-type string. + + Engineering notation has an exponent which is a multiple of 3, so there + are up to 3 digits left of the decimal place. For example, converts + \code{Decimal('123E+1')} to \code{Decimal("1.23E+3")} + \end{methoddesc} + + \begin{methoddesc}{to_integral}{\optional{rounding\optional{, context}}} + Rounds to the nearest integer, without signaling \constant{Inexact} + or \constant{Rounded}. If given, applies \var{rounding}; otherwise, + uses the rounding method in either the supplied \var{context} or the + current context. + \end{methoddesc} + + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \subsection{Context objects \label{decimal-decimal}} + + + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \subsection{Signals \label{decimal-signals}} *************** *** 310,314 **** the next computation. ! If the context's trap enable is set for the signal, then the condition causes a Python exception to be raised. For example, if the \class{DivisionByZero} trap is set, the a \exception{DivisionByZero} --- 443,447 ---- the next computation. ! If the context's trap enabler is set for the signal, then the condition causes a Python exception to be raised. For example, if the \class{DivisionByZero} trap is set, the a \exception{DivisionByZero} *************** *** 316,320 **** - \begin{classdesc*}{Clamped} Altered an exponent to fit representation constraints. --- 449,452 ---- *************** *** 438,441 **** --- 570,591 ---- + The following table summarizes the hierarchy of signals: + + \begin{verbatim} + exceptions.ArithmeticError(exceptions.StandardError) + DecimalException + Clamped + DivisionByZero(DecimalException, exceptions.ZeroDivisionError) + Inexact + Overflow(Inexact, Rounded) + Underflow(Inexact, Rounded, Subnormal) + InvalidOperation + ConversionSyntax + DivisionImpossible + DivisionUndefined(InvalidOperation, exceptions.ZeroDivisionError) + InvalidContext + Rounded + Subnormal + \end{verbatim} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% From rhettinger at users.sourceforge.net Sun Jul 4 10:11:42 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sun Jul 4 10:11:49 2004 Subject: [Python-checkins] python/nondist/sandbox/decimal libdecimal.tex, 1.6, 1.7 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/decimal In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1346 Modified Files: libdecimal.tex Log Message: Fix non-ascii single quotes Index: libdecimal.tex =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/decimal/libdecimal.tex,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** libdecimal.tex 4 Jul 2004 14:03:59 -0000 1.6 --- libdecimal.tex 4 Jul 2004 14:11:30 -0000 1.7 *************** *** 1,3 **** ! \section{\module{decimal} --- Decimal floating point arithmetic} --- 1,3 ---- ! \section{\module{decimal} --- Decimal floating point arithmetic} *************** *** 303,314 **** \begin{verbatim} ! sign ::= ’+’ | ’-’ ! digit ::= ’0’ | ’1’ | ’2’ | ’3’ | ’4’ | ’5’ | ’6’ | ’7’ | ’8’ | ’9’ ! indicator ::= ’e’ | ’E’ digits ::= digit [digit]... ! decimal-part ::= digits ’.’ [digits] | [’.’] digits exponent-part ::= indicator [sign] digits ! infinity ::= ’Infinity’ | ’Inf’ ! nan ::= ’NaN’ [digits] | ’sNaN’ [digits] numeric-value ::= decimal-part [exponent-part] | infinity numeric-string ::= [sign] numeric-value | [sign] nan --- 303,314 ---- \begin{verbatim} ! sign ::= '+' | '-' ! digit ::= '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' ! indicator ::= 'e' | 'E' digits ::= digit [digit]... ! decimal-part ::= digits '.' [digits] | ['.'] digits exponent-part ::= indicator [sign] digits ! infinity ::= 'Infinity' | 'Inf' ! nan ::= 'NaN' [digits] | 'sNaN' [digits] numeric-value ::= decimal-part [exponent-part] | infinity numeric-string ::= [sign] numeric-value | [sign] nan From akuchling at users.sourceforge.net Sun Jul 4 11:35:35 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sun Jul 4 11:35:45 2004 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew24.tex, 1.58, 1.59 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14023 Modified Files: whatsnew24.tex Log Message: More additions Index: whatsnew24.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew24.tex,v retrieving revision 1.58 retrieving revision 1.59 diff -C2 -d -r1.58 -r1.59 *** whatsnew24.tex 4 Jul 2004 01:44:04 -0000 1.58 --- whatsnew24.tex 4 Jul 2004 15:35:00 -0000 1.59 *************** *** 7,10 **** --- 7,13 ---- % to be covered. --amk + % XXX pydoc can display links to module docs -- but when? + % + \title{What's New in Python 2.4} \release{0.0} *************** *** 443,447 **** \item The \method{dict.update()} method now accepts the same argument forms as the \class{dict} constructor. This includes any ! mapping, any iterable of key/value pairs, and/or keyword arguments. \item The string methods, \method{ljust()}, \method{rjust()}, and --- 446,450 ---- \item The \method{dict.update()} method now accepts the same argument forms as the \class{dict} constructor. This includes any ! mapping, any iterable of key/value pairs, and keyword arguments. \item The string methods, \method{ljust()}, \method{rjust()}, and *************** *** 548,551 **** --- 551,558 ---- \end{verbatim} + \item The \function{eval(\var{expr}, \var{globals}, \var{locals})} + function now accepts any mapping type for the \var{locals} argument. + Previously this had to be a regular Python dictionary. + \item The \function{zip()} built-in function and \function{itertools.izip()} now return an empty list instead of raising a \exception{TypeError} *************** *** 625,628 **** --- 632,640 ---- \begin{itemize} + \item The \module{asyncore} module's \function{loop()} now has a + \var{count} parameter that lets you perform a limited number + of passes through the polling loop. The default is still to loop + forever. + \item The \module{curses} modules now supports the ncurses extension \function{use_default_colors()}. On platforms where the terminal *************** *** 684,688 **** high volumes of data. In addition, the module has two new functions \function{nlargest()} and \function{nsmallest()} that use heaps to ! find the largest or smallest n values in a dataset without the expense of a full sort. --- 696,700 ---- high volumes of data. In addition, the module has two new functions \function{nlargest()} and \function{nsmallest()} that use heaps to ! find the N largest or smallest values in a dataset without the expense of a full sort. *************** *** 761,768 **** bookmarking, windowing, or lookahead iterators. - \item A new \function{getsid()} function was added to the - \module{posix} module that underlies the \module{os} module. - (Contributed by J. Raynor.) - \item The \module{operator} module gained two new functions, \function{attrgetter(\var{attr})} and \function{itemgetter(\var{index})}. --- 773,776 ---- *************** *** 782,785 **** --- 790,802 ---- \end{verbatim} + \item A new \function{getsid()} function was added to the + \module{posix} module that underlies the \module{os} module. + (Contributed by J. Raynor.) + + \item The \module{poplib} module now supports POP over SSL. + + \item The \module{profile} module can now profile C extension functions. + % XXX more to say about this? + \item The \module{random} module has a new method called \method{getrandbits(N)} which returns an N-bit long integer. This method supports the existing *************** *** 798,801 **** --- 815,821 ---- including Python functions, class instances, sets, frozensets, deques, arrays, files, sockets, and regular expression pattern objects. + + \item The \module{xmlrpclib} module now supports a multi-call extension for + tranmitting multiple XML-RPC calls in a single HTTP operation. \end{itemize} *************** *** 847,851 **** defined in slots to co-exist with a PyCFunction having the same name. This can halve the access to time to a method such as ! \method{set.__contains__()} \end{itemize} --- 867,880 ---- defined in slots to co-exist with a PyCFunction having the same name. This can halve the access to time to a method such as ! \method{set.__contains__()}. ! ! \item Python can now be built with additional profiling for the interpreter ! itself, useful if you're working on the Python core. ! Providing \longprogramopt{--enable-profiling} to the ! \program{configure} script will let you profile the interpreter with ! \program{gprof}, and providing the \longprogramopt{--with-tsc} switch ! enables profiling using the Pentium's Time-Stamp-Counter. ! ! \item The \ctype{tracebackobject} type has been renamed to \ctype{PyTracebackObject}. \end{itemize} From akuchling at users.sourceforge.net Sun Jul 4 11:42:29 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sun Jul 4 11:42:36 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1022,1.1023 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14840 Modified Files: NEWS Log Message: Typo fixes Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1022 retrieving revision 1.1023 diff -C2 -d -r1.1022 -r1.1023 *** NEWS 3 Jul 2004 03:54:54 -0000 1.1022 --- NEWS 4 Jul 2004 15:41:59 -0000 1.1023 *************** *** 50,54 **** - Enabled the profiling of C extension functions (and builtins) - check ! new documentation and modified profiler and bdb modules for more details - Set file.name to the object passed to open (instead of a new string) --- 50,54 ---- - Enabled the profiling of C extension functions (and builtins) - check ! new documentation and modified profile and bdb modules for more details - Set file.name to the object passed to open (instead of a new string) *************** *** 222,226 **** will now just hit the recursion limit. See SF patch 825639. ! - str and unicode builtin types now have rsplit() method that is same as split() except that it scans the string from the end working towards the beginning. See SF feature request 801847. --- 222,226 ---- will now just hit the recursion limit. See SF patch 825639. ! - str and unicode builtin types now have an rsplit() method that is same as split() except that it scans the string from the end working towards the beginning. See SF feature request 801847. *************** *** 266,274 **** socket.error to the socket module's C API. ! - Bug #920575: A problem that _locale module segfaults on nl_langinfo(ERA) caused by GNU libc's illegal NULL return is fixed. - array objects now support the copy module. Also, their resizing ! scheme has been updated the same as for list objects. The improves the performance (speed and memory usage) of append() operations. Also, array.extend() now accepts any iterable argument for repeated --- 266,274 ---- socket.error to the socket module's C API. ! - Bug #920575: A problem where the _locale module segfaults on nl_langinfo(ERA) caused by GNU libc's illegal NULL return is fixed. - array objects now support the copy module. Also, their resizing ! scheme has been updated to match that used for list objects. This improves the performance (speed and memory usage) of append() operations. Also, array.extend() now accepts any iterable argument for repeated *************** *** 349,353 **** the Unix uniq filter. ! - itertools now has a new function, tee() which produces two independent iterators from a single iterable. --- 349,353 ---- the Unix uniq filter. ! - itertools now has a new tee() function which produces two independent iterators from a single iterable. *************** *** 433,437 **** - Support non-anonymous ftp URLs in urllib2. ! - The encodings package will now applies codec name aliases first before starting to try the import of the codec module. This simplifies overriding built-in codecs with external --- 433,437 ---- - Support non-anonymous ftp URLs in urllib2. ! - The encodings package will now apply codec name aliases first before starting to try the import of the codec module. This simplifies overriding built-in codecs with external From akuchling at users.sourceforge.net Sun Jul 4 12:39:57 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sun Jul 4 12:40:01 2004 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew24.tex, 1.59, 1.60 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23572 Modified Files: whatsnew24.tex Log Message: Bump version #; write introductory para Index: whatsnew24.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew24.tex,v retrieving revision 1.59 retrieving revision 1.60 diff -C2 -d -r1.59 -r1.60 *** whatsnew24.tex 4 Jul 2004 15:35:00 -0000 1.59 --- whatsnew24.tex 4 Jul 2004 16:39:40 -0000 1.60 *************** *** 11,15 **** \title{What's New in Python 2.4} ! \release{0.0} \author{A.M.\ Kuchling} \authoraddress{ --- 11,15 ---- \title{What's New in Python 2.4} ! \release{0.1} \author{A.M.\ Kuchling} \authoraddress{ *************** *** 22,39 **** \tableofcontents ! This article explains the new features in Python 2.4. The release ! date is expected to be around September 2004. ! While Python 2.3 was primarily a library development release, Python ! 2.4 may extend the core language and interpreter in ! as-yet-undetermined ways. This article doesn't attempt to provide a complete specification of ! the new features, but instead provides a convenient overview. For ! full details, you should refer to the documentation for Python 2.4, ! such as the \citetitle[../lib/lib.html]{Python Library Reference} and ! the \citetitle[../ref/ref.html]{Python Reference Manual}. ! If you want to understand the complete implementation and design ! rationale, refer to the PEP for a particular new feature. --- 22,42 ---- \tableofcontents ! This article explains the new features in Python 2.4 alpha1, to be released in early July 2004 The final version of Python 2.4 ! is expected to be around September 2004. ! Python 2.4 is a middle-sized release. It doesn't introduce as many ! changes as the radical Python 2.2, but introduces more features than ! the conservative 2.3 release did. The most significant new language ! feature (as of this writing) is the addition of generator expressions; ! most of the changes are to the standard library. This article doesn't attempt to provide a complete specification of ! every single new feature, but instead provides a convenient overview. ! For full details, you should refer to the documentation for Python ! 2.4, such as the \citetitle[../lib/lib.html]{Python Library Reference} ! and the \citetitle[../ref/ref.html]{Python Reference Manual}. If you ! want to understand the complete implementation and design rationale, ! refer to the PEP for a particular new feature or to the module ! documentation. From bcannon at users.sourceforge.net Sun Jul 4 14:36:45 2004 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Sun Jul 4 14:36:53 2004 Subject: [Python-checkins] python/dist/src/Lib threading.py, 1.38.6.1, 1.38.6.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9557/Lib Modified Files: Tag: release23-maint threading.py Log Message: Fix bug introduced by previous backport. Index: threading.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/threading.py,v retrieving revision 1.38.6.1 retrieving revision 1.38.6.2 diff -C2 -d -r1.38.6.1 -r1.38.6.2 *** threading.py 3 Jul 2004 19:58:57 -0000 1.38.6.1 --- threading.py 4 Jul 2004 18:35:56 -0000 1.38.6.2 *************** *** 451,456 **** # _sys) in case sys.stderr was redefined. if _sys: ! _sys.stderr.write("Exception in thread %s:\n%s\n" % ! (self.getName(), _format_exc())) else: # Do the best job possible w/o a huge amt. of code to --- 451,457 ---- # _sys) in case sys.stderr was redefined. if _sys: ! _sys.stderr.write("Exception in thread %s:" % ! self.getName()) ! _print_exc(file=_sys.stderr) else: # Do the best job possible w/o a huge amt. of code to From akuchling at users.sourceforge.net Sun Jul 4 21:37:18 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sun Jul 4 21:37:23 2004 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew24.tex, 1.60, 1.61 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8107 Modified Files: whatsnew24.tex Log Message: Various edits Index: whatsnew24.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew24.tex,v retrieving revision 1.60 retrieving revision 1.61 diff -C2 -d -r1.60 -r1.61 *** whatsnew24.tex 4 Jul 2004 16:39:40 -0000 1.60 --- whatsnew24.tex 5 Jul 2004 01:37:07 -0000 1.61 *************** *** 22,33 **** \tableofcontents ! This article explains the new features in Python 2.4 alpha1, to be released in early July 2004 The final version of Python 2.4 ! is expected to be around September 2004. ! Python 2.4 is a middle-sized release. It doesn't introduce as many changes as the radical Python 2.2, but introduces more features than the conservative 2.3 release did. The most significant new language feature (as of this writing) is the addition of generator expressions; ! most of the changes are to the standard library. This article doesn't attempt to provide a complete specification of --- 22,34 ---- \tableofcontents ! This article explains the new features in Python 2.4 alpha1, scheduled ! for release in early July 2004. The final version of Python 2.4 is ! expected to be released around September 2004. ! Python 2.4 is a medium-sized release. It doesn't introduce as many changes as the radical Python 2.2, but introduces more features than the conservative 2.3 release did. The most significant new language feature (as of this writing) is the addition of generator expressions; ! most other changes are to the standard library. This article doesn't attempt to provide a complete specification of *************** *** 44,52 **** \section{PEP 218: Built-In Set Objects} ! Two new built-in types, \function{set(\var{iterable})} and ! \function{frozenset(\var{iterable})} provide high speed data types for ! membership testing, for eliminating duplicates from sequences, and ! for mathematical operations like unions, intersections, differences, ! and symmetric differences. \begin{verbatim} --- 45,55 ---- \section{PEP 218: Built-In Set Objects} ! Python 2.3 introduced the \module{sets} module. C implementations of ! set data types have now been added to the Python core as two new ! built-in types, \function{set(\var{iterable})} and ! \function{frozenset(\var{iterable})}. They provide high speed ! operations for membership testing, for eliminating duplicates from ! sequences, and for mathematical operations like unions, intersections, ! differences, and symmetric differences. \begin{verbatim} *************** *** 78,91 **** \end{verbatim} ! The type \function{frozenset()} is an immutable version of \function{set()}. Since it is immutable and hashable, it may be used as a dictionary key or ! as a member of another set. Accordingly, it does not have methods ! like \method{add()} and \method{remove()} which could alter its contents. ! % XXX what happens to the sets module? ! % The current thinking is that the sets module will be left alone. ! % That way, existing code will continue to run without alteration. ! % Also, the module provides an autoconversion feature not supported by set() ! % and frozenset(). \begin{seealso} --- 81,91 ---- \end{verbatim} ! The \function{frozenset} type is an immutable version of \function{set}. Since it is immutable and hashable, it may be used as a dictionary key or ! as a member of another set. ! The \module{sets} module remains in the standard library, and may be ! useful if you wish to subclass the \class{Set} or \class{ImmutableSet} ! classes. There are currently no plans to deprecate the module. \begin{seealso} *************** *** 97,117 **** \section{PEP 237: Unifying Long Integers and Integers} ! The lengthy transition process for the PEP, begun with Python 2.2, takes another step forward in Python 2.4. In 2.3, certain integer operations that would behave differently after int/long unification triggered \exception{FutureWarning} warnings and returned values ! limited to 32 or 64 bits. In 2.4, these expressions no longer produce ! a warning, but they now produce a different value that's a long ! integer. The problematic expressions are primarily left shifts and lengthy ! hexadecimal and octal constants. For example, \code{2 << 32} is one ! expression that results in a warning in 2.3, evaluating to 0 on 32-bit ! platforms. In Python 2.4, this expression now returns 8589934592. ! \begin{seealso} \seepep{237}{Unifying Long Integers and Integers}{Original PEP ! written by Moshe Zadka and Gvr. The changes for 2.4 were implemented by Kalle Svensson.} \end{seealso} --- 97,116 ---- \section{PEP 237: Unifying Long Integers and Integers} ! The lengthy transition process for this PEP, begun in Python 2.2, takes another step forward in Python 2.4. In 2.3, certain integer operations that would behave differently after int/long unification triggered \exception{FutureWarning} warnings and returned values ! limited to 32 or 64 bits (depending on your platform). In 2.4, these ! expressions no longer produce a warning and instead produce a ! different result that's usually a long integer. The problematic expressions are primarily left shifts and lengthy ! hexadecimal and octal constants. For example, \code{2 << 32} results ! in a warning in 2.3, evaluating to 0 on 32-bit platforms. In Python ! 2.4, this expression now returns the correct answer, 8589934592. \begin{seealso} \seepep{237}{Unifying Long Integers and Integers}{Original PEP ! written by Moshe Zadka and GvR. The changes for 2.4 were implemented by Kalle Svensson.} \end{seealso} *************** *** 125,131 **** \module{itertools} module to write code in a fairly functional style. ! The fly in the ointment has been list comprehensions, because they produce a Python list object containing all of the items, unavoidably ! pulling them all into memory. When trying to write a program using the functional approach, it would be natural to write something like: \begin{verbatim} --- 124,133 ---- \module{itertools} module to write code in a fairly functional style. ! % XXX avoid metaphor ! List comprehensions have been the fly in the ointment because they produce a Python list object containing all of the items, unavoidably ! pulling them all into memory. When trying to write a ! functionally-styled program, it would be natural to write something ! like: \begin{verbatim} *************** *** 167,176 **** \end{verbatim} ! There are some small differences from list comprehensions. Most ! notably, the loop variable (\var{obj} in the above example) is not ! accessible outside of the generator expression. List comprehensions ! leave the variable assigned to its last value; future versions of ! Python will change this, making list comprehensions match generator ! expressions in this respect. \begin{seealso} --- 169,178 ---- \end{verbatim} ! Generator expressions differ from list comprehensions in various small ! ways. Most notably, the loop variable (\var{obj} in the above ! example) is not accessible outside of the generator expression. List ! comprehensions leave the variable assigned to its last value; future ! versions of Python will change this, making list comprehensions match ! generator expressions in this respect. \begin{seealso} *************** *** 183,187 **** A new built-in function, \function{reversed(\var{seq})}, takes a sequence ! and returns an iterator that returns the elements of the sequence in reverse order. --- 185,189 ---- A new built-in function, \function{reversed(\var{seq})}, takes a sequence ! and returns an iterator that loops over the elements of the sequence in reverse order. *************** *** 195,200 **** \end{verbatim} ! Compared to extended slicing, \code{range(1,4)[::-1]}, \function{reversed()} ! is easier to read, runs faster, and uses substantially less memory. Note that \function{reversed()} only accepts sequences, not arbitrary --- 197,203 ---- \end{verbatim} ! Compared to extended slicing, such as \code{range(1,4)[::-1]}, ! \function{reversed()} is easier to read, runs faster, and uses ! substantially less memory. Note that \function{reversed()} only accepts sequences, not arbitrary *************** *** 451,455 **** mapping, any iterable of key/value pairs, and keyword arguments. ! \item The string methods, \method{ljust()}, \method{rjust()}, and \method{center()} now take an optional argument for specifying a fill character other than a space. --- 454,458 ---- mapping, any iterable of key/value pairs, and keyword arguments. ! \item The string methods \method{ljust()}, \method{rjust()}, and \method{center()} now take an optional argument for specifying a fill character other than a space. *************** *** 467,471 **** \item The \method{sort()} method of lists gained three keyword ! arguments, \var{cmp}, \var{key}, and \var{reverse}. These arguments make some common usages of \method{sort()} simpler. All are optional. --- 470,474 ---- \item The \method{sort()} method of lists gained three keyword ! arguments: \var{cmp}, \var{key}, and \var{reverse}. These arguments make some common usages of \method{sort()} simpler. All are optional. *************** *** 497,501 **** using a \var{key} parameter. Using \var{key} results in calling the \method{lower()} method once for each element in the list while using ! \var{cmp} will call the method twice for each comparison. For simple key functions and comparison functions, it is often --- 500,504 ---- using a \var{key} parameter. Using \var{key} results in calling the \method{lower()} method once for each element in the list while using ! \var{cmp} will call it twice for each comparison. For simple key functions and comparison functions, it is often *************** *** 510,517 **** \end{verbatim} ! The \var{reverse} parameter should have a Boolean value. If the value is ! \constant{True}, the list will be sorted into reverse order. Instead ! of \code{L.sort(lambda x,y: cmp(y.score, x.score))}, you can now write: ! \code{L.sort(key = lambda x: x.score, reverse=True)}. The results of sorting are now guaranteed to be stable. This means --- 513,521 ---- \end{verbatim} ! The \var{reverse} parameter should have a Boolean value. If the value ! is \constant{True}, the list will be sorted into reverse order. ! Instead of \code{L.sort(lambda x,y: cmp(x.score, y.score)) ; ! L.reverse()}, you can now write: \code{L.sort(key = lambda x: x.score, ! reverse=True)}. The results of sorting are now guaranteed to be stable. This means *************** *** 523,527 **** \item There is a new built-in function \function{sorted(\var{iterable})} that works like the in-place ! \method{list.sort()} method but has been made suitable for use in expressions. The differences are: \begin{itemize} --- 527,531 ---- \item There is a new built-in function \function{sorted(\var{iterable})} that works like the in-place ! \method{list.sort()} method but can be used in expressions. The differences are: \begin{itemize} *************** *** 551,555 **** red 1 yellow 5 - \end{verbatim} --- 555,558 ---- *************** *** 559,564 **** \item The \function{zip()} built-in function and \function{itertools.izip()} ! now return an empty list instead of raising a \exception{TypeError} ! exception if called with no arguments. This makes them more suitable for use with variable length argument lists: --- 562,568 ---- \item The \function{zip()} built-in function and \function{itertools.izip()} ! now return an empty list if called with no arguments. ! Previously they raised a \exception{TypeError} ! exception. This makes them more suitable for use with variable length argument lists: *************** *** 581,606 **** \begin{itemize} ! \item The inner loops for \class{list} and \class{tuple} slicing were optimized and now run about one-third faster. The inner ! loops were also optimized for \class{dict} with performance boosts to \method{keys()}, \method{values()}, \method{items()}, \method{iterkeys()}, \method{itervalues()}, and \method{iteritems()}. ! \item The machinery for growing and shrinking lists was optimized ! for speed and for space efficiency. Small lists (under eight elements) ! never over-allocate by more than three elements. Large lists do not ! over-allocate by more than 1/8th. Appending and popping from lists ! now runs faster due to more efficient code paths and less frequent ! use of the underlying system realloc(). List comprehensions also ! benefit. The amount of improvement varies between systems and shows ! the greatest improvement on systems with poor realloc() implementations. ! \method{list.extend()} was also optimized and no longer converts its ! argument into a temporary list prior to extending the base list. \item \function{list()}, \function{tuple()}, \function{map()}, \function{filter()}, and \function{zip()} now run several times faster with non-sequence arguments that supply a \method{__len__()} ! method. Previously, the pre-sizing optimization only applied to ! sequence arguments. \item The methods \method{list.__getitem__()}, --- 585,606 ---- \begin{itemize} ! \item The inner loops for list and tupleslicing were optimized and now run about one-third faster. The inner ! loops were also optimized for dictionaries with performance boosts to \method{keys()}, \method{values()}, \method{items()}, \method{iterkeys()}, \method{itervalues()}, and \method{iteritems()}. ! \item The machinery for growing and shrinking lists was optimized for ! speed and for space efficiency. Appending and popping from lists now ! runs faster due to more efficient code paths and less frequent use of ! the underlying system \cfunction{realloc()}. List comprehensions ! also benefit. \method{list.extend()} was also optimized and no ! longer converts its argument into a temporary list before extending ! the base list. \item \function{list()}, \function{tuple()}, \function{map()}, \function{filter()}, and \function{zip()} now run several times faster with non-sequence arguments that supply a \method{__len__()} ! method. \item The methods \method{list.__getitem__()}, *************** *** 686,691 **** Several modules now take advantage of \class{collections.deque} for ! improved performance: \module{Queue}, \module{mutex}, \module{shlex} ! \module{threading}, and \module{pydoc}. \item The \module{ConfigParser} classes have been enhanced slightly. --- 686,691 ---- Several modules now take advantage of \class{collections.deque} for ! improved performance, such as the \module{Queue} and ! \module{threading} modules. \item The \module{ConfigParser} classes have been enhanced slightly. *************** *** 706,711 **** \item The \module{itertools} module gained a ! \function{groupby(\var{iterable}\optional{, \var{func}})} function, ! inspired by the GROUP BY clause from SQL. \var{iterable} returns a succession of elements, and the optional \var{func} is a function that takes an element and returns a key --- 706,710 ---- \item The \module{itertools} module gained a ! \function{groupby(\var{iterable}\optional{, \var{func}})} function. \var{iterable} returns a succession of elements, and the optional \var{func} is a function that takes an element and returns a key *************** *** 733,740 **** \end{verbatim} ! Like its SQL counterpart, \function{groupby()} is typically used with ! sorted input. The logic for \function{groupby()} is similar to the ! \UNIX{} \code{uniq} filter which makes it handy for eliminating, ! counting, or identifying duplicate elements: \begin{verbatim} --- 732,739 ---- \end{verbatim} ! \function{groupby()} is typically used with sorted input. The logic ! for \function{groupby()} is similar to the \UNIX{} \code{uniq} filter ! which makes it handy for eliminating, counting, or identifying ! duplicate elements: \begin{verbatim} *************** *** 743,752 **** >>> letters ['a', 'a', 'a', 'a', 'a', 'b', 'b', 'c', 'd', 'r', 'r'] ! >>> [k for k, g in groupby(letters)] # List unique letters ['a', 'b', 'c', 'd', 'r'] ! >>> [(k, len(list(g))) for k, g in groupby(letters)] # Count letter occurences [('a', 5), ('b', 2), ('c', 1), ('d', 1), ('r', 2)] - >>> [k for k, g in groupby(letters) if len(list(g)) > 1] # List duplicated letters - ['a', 'b', 'r'] \end{verbatim} --- 742,759 ---- >>> letters ['a', 'a', 'a', 'a', 'a', 'b', 'b', 'c', 'd', 'r', 'r'] ! >>> for k, g in itertools.groupby(letters): ! ... print k, list(g) ! ... ! a ['a', 'a', 'a', 'a', 'a'] ! b ['b', 'b'] ! c ['c'] ! d ['d'] ! r ['r', 'r'] ! >>> # List unique letters ! >>> [k for k, g in groupby(letters)] ['a', 'b', 'c', 'd', 'r'] ! >>> # Count letter occurences ! >>> [(k, len(list(g))) for k, g in groupby(letters)] [('a', 5), ('b', 2), ('c', 1), ('d', 1), ('r', 2)] \end{verbatim} *************** *** 771,775 **** This should therefore be used carefully if the leading iterator can run far ahead of the trailing iterator in a long stream of inputs. ! If the separation is large, then it becomes preferable to use \function{list()} instead. When the iterators track closely with one another, \function{tee()} is ideal. Possible applications include --- 778,782 ---- This should therefore be used carefully if the leading iterator can run far ahead of the trailing iterator in a long stream of inputs. ! If the separation is large, then you might as well use \function{list()} instead. When the iterators track closely with one another, \function{tee()} is ideal. Possible applications include From akuchling at users.sourceforge.net Sun Jul 4 21:40:35 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sun Jul 4 21:40:40 2004 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew24.tex, 1.61, 1.62 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8396 Modified Files: whatsnew24.tex Log Message: Various edits Index: whatsnew24.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew24.tex,v retrieving revision 1.61 retrieving revision 1.62 diff -C2 -d -r1.61 -r1.62 *** whatsnew24.tex 5 Jul 2004 01:37:07 -0000 1.61 --- whatsnew24.tex 5 Jul 2004 01:40:07 -0000 1.62 *************** *** 839,844 **** The \module{cookielib} library supports client-side handling for HTTP cookies, just as the \module{Cookie} provides server-side cookie ! support in CGI scripts. This library manages cookies in a way similar ! to web browsers. Cookies are stored in cookie jars; the library transparently stores cookies offered by the web server in the cookie jar, and fetches the cookie from the jar when connecting to the --- 839,843 ---- The \module{cookielib} library supports client-side handling for HTTP cookies, just as the \module{Cookie} provides server-side cookie ! support in CGI scripts. Cookies are stored in cookie jars; the library transparently stores cookies offered by the web server in the cookie jar, and fetches the cookie from the jar when connecting to the *************** *** 875,888 **** \item A new method flag, \constant{METH_COEXISTS}, allows a function ! defined in slots to co-exist with a PyCFunction having the same name. ! This can halve the access to time to a method such as \method{set.__contains__()}. \item Python can now be built with additional profiling for the interpreter ! itself, useful if you're working on the Python core. Providing \longprogramopt{--enable-profiling} to the \program{configure} script will let you profile the interpreter with \program{gprof}, and providing the \longprogramopt{--with-tsc} switch ! enables profiling using the Pentium's Time-Stamp-Counter. \item The \ctype{tracebackobject} type has been renamed to \ctype{PyTracebackObject}. --- 874,887 ---- \item A new method flag, \constant{METH_COEXISTS}, allows a function ! defined in slots to co-exist with a \ctype{PyCFunction} having the ! same name. This can halve the access time for a method such as \method{set.__contains__()}. \item Python can now be built with additional profiling for the interpreter ! itself. This is intended for people developing on the Python core. Providing \longprogramopt{--enable-profiling} to the \program{configure} script will let you profile the interpreter with \program{gprof}, and providing the \longprogramopt{--with-tsc} switch ! enables profiling using the Pentium's Time-Stamp-Counter register. \item The \ctype{tracebackobject} type has been renamed to \ctype{PyTracebackObject}. *************** *** 940,949 **** instead of returning empty lists. ! \item \function{LexicalHandler.startDTD()} used to receive public and ! system ID in the wrong order. This has been corrected; applications relying on the wrong order need to be fixed. ! \item \function{fcntl.ioctl} now warns if the mutate arg is omitted ! and relevant. \end{itemize} --- 939,948 ---- instead of returning empty lists. ! \item \function{LexicalHandler.startDTD()} used to receive the public and ! system IDs in the wrong order. This has been corrected; applications relying on the wrong order need to be fixed. ! \item \function{fcntl.ioctl} now warns if the \var{mutate} ! argument is omitted and relevant. \end{itemize} From rhettinger at users.sourceforge.net Mon Jul 5 01:03:26 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Mon Jul 5 01:03:34 2004 Subject: [Python-checkins] python/nondist/sandbox/decimal libdecimal.tex, 1.7, 1.8 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/decimal In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31513 Modified Files: libdecimal.tex Log Message: Add a Context object section. Index: libdecimal.tex =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/decimal/libdecimal.tex,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** libdecimal.tex 4 Jul 2004 14:11:30 -0000 1.7 --- libdecimal.tex 5 Jul 2004 05:02:58 -0000 1.8 *************** *** 381,385 **** \begin{methoddesc}{quantize} {\optional{exp \optional{, rounding\optional{, context\optional{, watchexp}}}}} ! Quantize to make the exponent the same as \var{exp}. Searches for a rounding method in \var{rounding}, then in \var{context}, and then in the current context. --- 381,385 ---- \begin{methoddesc}{quantize} {\optional{exp \optional{, rounding\optional{, context\optional{, watchexp}}}}} ! Quantize makes the exponent the same as \var{exp}. Searches for a rounding method in \var{rounding}, then in \var{context}, and then in the current context. *************** *** 428,431 **** --- 428,686 ---- \subsection{Context objects \label{decimal-decimal}} + Contexts are environments for arithmetic operations. They govern the precision, + rules for rounding, determine which signals are treated as exceptions, and set limits + on the range for exponents. + + Each thread has its own current context which is accessed or changed using + the \function{getcontext()} and \function{setcontext()} functions: + + \begin{funcdesc}{getcontext}{} + Return the current context for the active thread. + \end{funcdesc} + + \begin{funcdesc}{setcontext}{c} + Set the current context for the active thread to \var{c}. + \end{funcdesc} + + New contexts can formed using the \class{Context} constructor described below. + In addition, the module provides three pre-made contexts: + + + \begin{classdesc*}{BasicContext} + This is a standard context defined by the General Decimal Arithmetic + Specification. Precision is set to nine. Rounding is set to + \constant{ROUND_HALF_UP}. All flags are cleared. All traps are enabled + (treated as exceptions) except \constant{Inexact}, \constant{Rounded}, and + \constant{Subnormal}. + + Because many of the traps are enabled, this context is useful for debugging. + \end{classdesc*} + + \begin{classdesc*}{ExtendedContext} + This is a standard context defined by the General Decimal Arithmetic + Specification. Precision is set to nine. Rounding is set to + \constant{ROUND_HALF_EVEN}. All flags are cleared. No traps are enabled + (so that exceptions are not raised during computations). + \end{classdesc*} + + \begin{classdesc*}{DefaultContext} + This class is used by the \class{Context} constructor as a prototype for + new contexts. Changing a field (such a precision) has the effect of + changing the default for new contexts creating by the \class{Context} + constructor. + + This context is most useful in multi-threaded environments. Changing one of + the fields before threads are started has the effect of setting system-wide + defaults. Changing the fields after threads have started is not recommended + as it would require thread synchronization to prevent race conditions. + + In single threaded environments, it is preferable to not use this context + at all. Instead, simply create contexts explicitly. This is especially + important because the default values context may change between releases + (with initial release having precision=28, rounding=ROUND_HALF_EVEN, + cleared flags, and no traps enabled). + \end{classdesc*} + + + \begin{classdesc}{Context}{prec=None, rounding=None, trap_enablers=None, + flags=None, Emin=None, Emax=None, capitals=1} + Creates a new context. If a field is not specified or is \constant{None}, + the default values are copied from the \constant{DefaultContext}. If the + \var{flags} field is not specified or is \constant{None}, all flags are + cleared. + + The \var{prec} field in an positive integer that sets the precision for + arithmetic operations in the context. + + The \var{rounding} option is one of: \constant{ROUND_CEILING}, + \constant{ROUND_DOWN}, \constant{ROUND_FLOOR}, \constant{ROUND_HALF_DOWN}, + \constant{ROUND_HALF_EVEN}, \constant{ROUND_HALF_UP}, or + \constant{ROUND_UP}. + + The \var{trap_enablers} and \var{flags} fields are mappings from signals + to either \constant{0} or \constant{1}. + + The \var{Emin} and \var{Emax} fields are integers specifying the outer + limits allowable for exponents. + + The \var{capitals} field is either \constant{0} or \constant{1} (the + default). If set to \constant{1}, exponents are printed with a capital + \constant{E}; otherwise, lowercase is used: \constant{Decimal('6.02e+23')}. + \end{classdesc} + + The \class{Context} class defines several general methods as well as a + large number of methods for doing arithmetic directly from the context. + + \begin{methoddesc}{clear_flags}{} + Sets all of the flags to \constant{0}. + \end{methoddesc} + + \begin{methoddesc}{copy}{} + Returns a duplicate of the context. + \end{methoddesc} + + \begin{methoddesc}{create_decimal}{num} + Creates a new Decimal instance but using \var{self} as context. + Unlike the \class{Decimal} constructor, context precision, + rounding method, flags, and traps are applied to the conversion. + + This is useful because constants are often given to a greater + precision than is needed by the application. + \end{methoddesc} + + \begin{methoddesc}{Etiny}{} + Returns a value equal to \samp{Emin - prec + 1} which is the minimum + exponent value for subnormal results. When underflow occurs, the + exponont is set to \constant{Etiny}. + \end{methoddesc} + + The usual approach to working with decimals is to create Decimal + instances and then apply arithmetic operations which take place + within the current context for the active thread. An alternate + approach is to use a context method to perform a particular + computation within the given context rather than the current context. + + Those methods parallel those for the \class{Decimal} class and are + only briefed recounted here. + + + \begin{methoddesc}{abs}{x} + Returns the absolute value of \var{x}. + \end{methoddesc} + + \begin{methoddesc}{add}{x, y} + Return the sum of \var{x} and \var{y}. + \end{methoddesc} + + \begin{methoddesc}{compare}{x, y} + Compares values numerically. + + Like \method{__cmp__()} but returns a decimal instance: + \begin{verbatim} + a or b is a NaN ==> Decimal("NaN") + a < b ==> Decimal("-1") + a == b ==> Decimal("0") + a > b ==> Decimal("1") + \end{verbatim} + \end{methoddesc} + + \begin{methoddesc}{divide}{x, y} + Return \var{x} divided by \var{y}. + \end{methoddesc} + + \begin{methoddesc}{divide}{x, y} + Divides two numbers and returns the integer part of the result. + \end{methoddesc} + + \begin{methoddesc}{max}{x, y} + Compare two values numerically and returns the maximum. + + If they are numerically equal then the left-hand operand is chosen as the + result. + \end{methoddesc} + + \begin{methoddesc}{min}{x, y} + Compare two values numerically and returns the minimum. + + If they are numerically equal then the left-hand operand is chosen as the + result. + \end{methoddesc} + + \begin{methoddesc}{minus}{x} + Minus corresponds to unary prefix minus in Python. + \end{methoddesc} + + \begin{methoddesc}{multiply}{x, y} + Return the product of \var{x} and \var{y}. + \end{methoddesc} + + \begin{methoddesc}{normalize}{x} + Normalize reduces an operand to its simplest form. + + Essentially a plus operation with all trailing zeros removed from the + result. + \end{methoddesc} + + \begin{methoddesc}{plus}{x} + Minus corresponds to unary prefix plus in Python. + \end{methoddesc} + + \begin{methoddesc}{power}{x, y\optional{, modulo}} + Return \samp{x ** y} to the \var{modulo} if given. + + The right-hand operand must be a whole number whose integer part (after any + exponent has been applied) has no more than 9 digits and whose fractional + part (if any) is all zeros before any rounding. The operand may be positive, + negative, or zero; if negative, the absolute value of the power is used, and + the left-hand operand is inverted (divided into 1) before use. + + If the increased precision needed for the intermediate calculations exceeds + the capabilities of the implementation then an Invalid operation condition + is raised. + + If, when raising to a negative power, an underflow occurs during the + division into 1, the operation is not halted at that point but continues. + \end{methoddesc} + + \begin{methoddesc}{quantize}{x, y} + Returns a value equal to \var{x} after rounding and having the + exponent of v\var{y}. + + Unlike other operations, if the length of the coefficient after the quantize + operation would be greater than precision then an + \constant{InvalidOperation} is signaled. This guarantees that, unless there + is an error condition, the exponent of the result of a quantize is always + equal to that of the right-hand operand. + + Also unlike other operations, quantize never signals Underflow, even + if the result is subnormal and inexact. + \end{methoddesc} + + \begin{methoddesc}{remainder}{x, y} + Returns the remainder from integer division. + + The sign of the result, if non-zero, is the same as that of the original + dividend. + \end{methoddesc} + + \begin{methoddesc}{remainder_near}{x, y} + Computed the modulo as either a positive or negative value depending + on which is closest to zero. For instance, + \samp{Decimal(10).remainder_near(6)} returns \code{Decimal("-2")} + which is closer to zero than \code{Decimal("4")}. + + If both are equally close, the one chosen will have the same sign + as \var{self}. + \end{methoddesc} + + \begin{methoddesc}{same_quantum}{x, y} + Test whether \var{x} and \var{y} have the same exponent or whether both are + \constant{NaN}. + \end{methoddesc} + + \begin{methoddesc}{sqrt}{} + Return the square root to full precision. + \end{methoddesc} + + \begin{methoddesc}{substract}{x, y} + Return the difference of \var{x} and \var{y}. + \end{methoddesc} + + \begin{methoddesc}{to_eng_string}{} + Convert to engineering-type string. + + Engineering notation has an exponent which is a multiple of 3, so there + are up to 3 digits left of the decimal place. For example, converts + \code{Decimal('123E+1')} to \code{Decimal("1.23E+3")} + \end{methoddesc} + + \begin{methoddesc}{to_integral}{x} + Rounds to the nearest integer, without signaling \constant{Inexact} + or \constant{Rounded}. + \end{methoddesc} + + \begin{methoddesc}{to_sci_string}{} + Converts a number to a string, using scientific notation. + \end{methoddesc} From rhettinger at users.sourceforge.net Mon Jul 5 01:37:03 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Mon Jul 5 01:37:11 2004 Subject: [Python-checkins] python/dist/src/Lib decimal.py,1.7,1.8 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2545 Modified Files: decimal.py Log Message: * Fixup docstrings * Make capitals default part of DefaultContext Index: decimal.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/decimal.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** decimal.py 4 Jul 2004 13:53:24 -0000 1.7 --- decimal.py 5 Jul 2004 05:36:39 -0000 1.8 *************** *** 135,139 **** import threading import copy - import math import operator --- 135,138 ---- *************** *** 2121,2126 **** capitals - If 1, 1*10^1 is printed as 1E+1. If 0, printed as 1e1 ! (Defaults to 1) ! clamp - If 1, change exponents if too high (Default 0) """ --- 2120,2124 ---- capitals - If 1, 1*10^1 is printed as 1E+1. If 0, printed as 1e1 ! _clamp - If 1, change exponents if too high (Default 0) """ *************** *** 2131,2135 **** _rounding_decision=None, Emin=None, Emax=None, ! capitals=1, _clamp=0, _ignored_flags=[]): if flags is None: --- 2129,2133 ---- _rounding_decision=None, Emin=None, Emax=None, ! capitals=None, _clamp=0, _ignored_flags=[]): if flags is None: *************** *** 2209,2213 **** def Etop(self): ! """Returns maximum exponent (= Emin - prec + 1)""" return int(self.Emax - self.prec + 1) --- 2207,2211 ---- def Etop(self): ! """Returns maximum exponent (= Emax - prec + 1)""" return int(self.Emax - self.prec + 1) *************** *** 2431,2435 **** def normalize(self, a): ! """normalize reduces its operand to its simplest form. Essentially a plus operation with all trailing zeros removed from the --- 2429,2433 ---- def normalize(self, a): ! """normalize reduces an operand to its simplest form. Essentially a plus operation with all trailing zeros removed from the *************** *** 2969,2973 **** _rounding_decision=ALWAYS_ROUND, Emax=DEFAULT_MAX_EXPONENT, ! Emin=DEFAULT_MIN_EXPONENT ) --- 2967,2972 ---- _rounding_decision=ALWAYS_ROUND, Emax=DEFAULT_MAX_EXPONENT, ! Emin=DEFAULT_MIN_EXPONENT, ! capitals=1 ) From rhettinger at users.sourceforge.net Mon Jul 5 01:52:36 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Mon Jul 5 01:52:46 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libdecimal.tex, NONE, 1.1 lib.tex, 1.226, 1.227 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4688 Modified Files: lib.tex Added Files: libdecimal.tex Log Message: Add decimal docs to the core. --- NEW FILE: libdecimal.tex --- \section{\module{decimal} --- Decimal floating point arithmetic} \declaremodule{standard}{decimal} \modulesynopsis{Implementation of the General Decimal Arithmetic Specification.} \moduleauthor{Eric Price}{eprice at tjhsst.edu} \moduleauthor{Facundo Batista}{facundo at taniquetil.com.ar} \moduleauthor{Raymond Hettinger}{python at rcn.com} \moduleauthor{Aahz}{aahz at pobox.com} \moduleauthor{Tim Peters}{tim.one at comcast.net} \sectionauthor{Raymond D. Hettinger}{python at rcn.com} \versionadded{2.4} The decimal \module{module} provides support for decimal floating point arithmetic. It offers several advantages over the \class{float()} datatype: \begin{itemize} \item Decimal numbers can be represented exactly. In contrast, numbers like \constant{1.1} do not have an exact representations in binary floating point. End users typically wound not expect \constant{1.1} to display as \constant{1.1000000000000001} as it does with binary floating point. \item The exactness carries over into arithmetic. In decimal floating point, \samp{0.1 + 0.1 + 0.1 - 0.3} is exactly equal to zero. In binary floating point, result is \constant{5.5511151231257827e-017}. While near to zero, the differences prevent reliable equality testing and differences can accumulate. For this reason, decimal would be preferred in accounting applications which have strict equality invariants. \item The decimal module incorporates notion of significant places so that \samp{1.30 + 1.20} is \constant{2.50}. The trailing zero is kept to indicate significance. This is the customary presentation for monetary applications. For multiplication, the ``schoolbook'' approach uses all the figures in the multiplicands. For instance, \samp{1.3 * 1.2} gives \constant{1.56} while \samp{1.30 * 1.20} gives \constant{1.5600}. \item Unlike hardware based binary floating point, the decimal module has a user settable precision (defaulting to 28 places) which can be as large as needed for a given problem: \begin{verbatim} >>> getcontext().prec = 6 >>> Decimal(1) / Decimal(7) Decimal("0.142857") >>> getcontext().prec = 28 >>> Decimal(1) / Decimal(7) Decimal("0.1428571428571428571428571429") \end{verbatim} \item Both binary and decimal floating point are implemented in terms of published standards. While the built-in float type exposes only a modest portion of its capabilities, the decimal module exposes all required parts of the standard. When needed, the programmer has full control over rounding and signal handling. \end{itemize} The module design is centered around three concepts: the decimal number, the context for arithmetic, and signals. A decimal number is immutable. It has a sign, coefficient digits, and an exponent. To preserve significance, the coefficient digits do not truncate trailing zeroes. Decimals also include special values such as \constant{Infinity} (the result of \samp{1 / 0}), \constant{-Infinity}, (the result of \samp{-1 / 0}), and \constant{NaN} (the result of \samp{0 / 0}). The standard also differentiates \constant{-0} from \constant{+0}. The context for arithmetic is an environment specifying precision, rounding rules, limits on exponents, flags that indicate the results of operations, and trap enablers which determine whether signals are to be treated as exceptions. Rounding options include \constant{ROUND_CEILING}, \constant{ROUND_DOWN}, \constant{ROUND_FLOOR}, \constant{ROUND_HALF_DOWN}, \constant{ROUND_HALF_EVEN}, \constant{ROUND_HALF_UP}, and \constant{ROUND_UP}. Signals are types of information that arise during the course of a computation. Depending on the needs of the application, some signals may be ignored, considered as informational, or treated as exceptions. The signals in the decimal module are: \constant{Clamped}, \constant{InvalidOperation}, \constant{ConversionSyntax}, \constant{DivisionByZero}, \constant{DivisionImpossible}, \constant{DivisionUndefined}, \constant{Inexact}, \constant{InvalidContext}, \constant{Rounded}, \constant{Subnormal}, \constant{Overflow}, and \constant{Underflow}. For each signal there is a flag and a trap enabler. When a signal is encountered, its flag incremented from zero and, then, if the trap enabler is set to one, an exception is raised. \begin{seealso} \seetext{IBM's General Decimal Arithmetic Specification, \citetitle[http://www2.hursley.ibm.com/decimal/decarith.html] {The General Decimal Arithmetic Specification}.} \seetext{IEEE standard 854-1987, \citetitle[http://www.cs.berkeley.edu/~ejr/projects/754/private/drafts/854-1987/dir.html] {Unofficial IEEE 854 Text}.} \end{seealso} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \subsection{Quick-start Tutorial \label{decimal-tutorial}} The normal start to using decimals is to import the module, and then use \function{getcontext()} to view the context and, if necessary, set the context precision, rounding, or trap enablers: \begin{verbatim} >>> from decimal import * >>> getcontext() Context(prec=28, rounding=ROUND_HALF_EVEN, Emin=-999999999, Emax=999999999, setflags=[], settraps=[]) >>> getcontext().prec = 7 \end{verbatim} Decimal instances can be constructed from integers or strings. To create a Decimal from a \class{float}, first convert it to a string. This serves as an explicit reminder of the details of the conversion (including representation error). Malformed strings signal \constant{ConversionSyntax} and return a special kind of Decimal called a \constant{NaN} which stands for ``Not a number''. Positive and negative \constant{Infinity} is yet another special kind of Decimal. \begin{verbatim} >>> Decimal(10) Decimal("10") >>> Decimal('3.14') Decimal("3.14") >>> Decimal(str(2.0 ** 0.5)) Decimal("1.41421356237") >>> Decimal('Mickey Mouse') Decimal("NaN") >>> Decimal('-Infinity') Decimal("-Infinity") \end{verbatim} Creating decimals is unaffected by context precision. Their level of significance is completely determined by the number of digits input. It is the arithmetic operations that are governed by context. \begin{verbatim} >>> getcontext().prec = 6 >>> Decimal('3.0000') Decimal("3.0000") >>> Decimal('3.0') Decimal("3.0") >>> Decimal('3.1415926535') Decimal("3.1415926535") >>> Decimal('3.1415926535') + Decimal('2.7182818285') Decimal("5.85987") >>> getcontext().rounding = ROUND_UP >>> Decimal('3.1415926535') + Decimal('2.7182818285') Decimal("5.85988") \end{verbatim} Decimals interact well with much of the rest of python. Here is a small decimal floating point flying circus: \begin{verbatim} >>> data = map(Decimal, '1.34 1.87 3.45 2.35 1.00 0.03 9.25'.split()) >>> max(data) Decimal("9.25") >>> min(data) Decimal("0.03") >>> sorted(data) [Decimal("0.03"), Decimal("1.00"), Decimal("1.34"), Decimal("1.87"), Decimal("2.35"), Decimal("3.45"), Decimal("9.25")] >>> sum(data) Decimal("19.29") >>> a,b,c = data[:3] >>> str(a) '1.34' >>> float(a) 1.3400000000000001 >>> round(a, 1) 1.3 >>> int(a) 1 >>> a * 5 Decimal("6.70") >>> a * b Decimal("2.5058") >>> c % a Decimal("0.77") \end{verbatim} The \function{getcontext()} function accesses the current context. This one context is sufficient for many applications; however, for more advanced work, multiple contexts can be created using the Context() constructor. To make a new context active, use the \function{setcontext()} function. In accordance with the standard, the \module{Decimal} module provides two ready to use standard contexts, \constant{BasicContext} and \constant{ExtendedContext}. The former is especially useful for debugging because many of the traps are enabled: \begin{verbatim} >>> myothercontext = Context(prec=60, rounding=ROUND_HALF_DOWN) >>> myothercontext Context(prec=60, rounding=ROUND_HALF_DOWN, Emin=-999999999, Emax=999999999, setflags=[], settraps=[]) >>> ExtendedContext Context(prec=9, rounding=ROUND_HALF_EVEN, Emin=-999999999, Emax=999999999, setflags=[], settraps=[]) >>> setcontext(myothercontext) >>> Decimal(1) / Decimal(7) Decimal("0.142857142857142857142857142857142857142857142857142857142857") >>> setcontext(ExtendedContext) >>> Decimal(1) / Decimal(7) Decimal("0.142857143") >>> Decimal(42) / Decimal(0) Decimal("Infinity") >>> setcontext(BasicContext) >>> Decimal(42) / Decimal(0) Traceback (most recent call last): File "", line 1, in -toplevel- Decimal(42) / Decimal(0) DivisionByZero: x / 0 \end{verbatim} Besides using contexts to control precision, rounding, and trapping signals, they can be used to monitor flags which give information collected during computation. The flags remain set until explicitly cleared, so it is best to clear the flags before each set of monitored computations by using the \method{clear_flags()} method. \begin{verbatim} >>> setcontext(ExtendedContext) >>> getcontext().clear_flags() >>> Decimal(355) / Decimal(113) Decimal("3.14159292") >>> getcontext() Context(prec=9, rounding=ROUND_HALF_EVEN, Emin=-999999999, Emax=999999999, setflags=['Inexact', 'Rounded'], settraps=[]) \end{verbatim} The \var{setflags} entry shows that the rational approximation to \constant{Pi} was rounded (digits beyond the context precision were thrown away) and that the result is inexact (some of the discarded digits were non-zero). Individual traps are set using the dictionary in the \member{trap_enablers} field of a context: \begin{verbatim} >>> Decimal(1) / Decimal(0) Decimal("Infinity") >>> getcontext().trap_enablers[DivisionByZero] = 1 >>> Decimal(1) / Decimal(0) Traceback (most recent call last): File "", line 1, in -toplevel- Decimal(1) / Decimal(0) DivisionByZero: x / 0 \end{verbatim} To turn all the traps on or off all at once, use a loop. Also, the \method{dict.update()} method is useful for changing a handfull of values. \begin{verbatim} >>> getcontext.clear_flags() >>> for sig in getcontext().trap_enablers: ... getcontext().trap_enablers[sig] = 1 >>> getcontext().trap_enablers.update({Rounded:0, Inexact:0, Subnormal:0}) >>> getcontext() Context(prec=9, rounding=ROUND_HALF_EVEN, Emin=-999999999, Emax=999999999, setflags=[], settraps=['Underflow', 'DecimalException', 'Clamped', 'InvalidContext', 'InvalidOperation', 'ConversionSyntax', 'DivisionByZero', 'DivisionImpossible', 'DivisionUndefined', 'Overflow']) \end{verbatim} Applications typically set the context once at the beginning of a program and no further changes are needed. For many applications, the data resides in a resource external to the program and is converted to \class{Decimal} with a single cast inside a loop. Afterwards, decimals are as easily manipulated as other Python numeric types. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \subsection{Decimal objects \label{decimal-decimal}} \begin{classdesc}{Decimal}{\optional{value \optional{, context}}} Constructs a new \class{Decimal} object based from \var{value}. \var{value} can be an integer, string, or another \class{Decimal} object. If no \var{value} is given, returns \code{Decimal("0")}. If \var{value} is a string, it should conform to the decimal numeric string syntax: \begin{verbatim} sign ::= '+' | '-' digit ::= '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' indicator ::= 'e' | 'E' digits ::= digit [digit]... decimal-part ::= digits '.' [digits] | ['.'] digits exponent-part ::= indicator [sign] digits infinity ::= 'Infinity' | 'Inf' nan ::= 'NaN' [digits] | 'sNaN' [digits] numeric-value ::= decimal-part [exponent-part] | infinity numeric-string ::= [sign] numeric-value | [sign] nan \end{verbatim} The supplied \var{context} or, if not specified, the current context governs only the handling of mal-formed strings not conforming to the numeric string syntax. If the context traps \constant{ConversionSyntax}, an exception is raised; otherwise, the constructor returns a new Decimal with the value of \constant{NaN}. The context serves no other purpose. The number of significant digits recorded is determined solely by the \var{value} and the var{context} precision is not a factor. For example, \samp{Decimal("3.0000")} records all four zeroes even if the context precision is only three. Once constructed, \class{Decimal} objects are immutable. \end{classdesc} Decimal floating point objects share many properties with the other builtin numeric types such as \class{float} and \class{int}. All of the usual math operations and special methods apply. Likewise, decimal objects can be copied, pickled, printed, used as dictionary keys, used as set elements, compared, sorted, and coerced to another type (such as \class{float} or \class{long}). In addition to the standard numeric properties, decimal floating point objects have a number of more specialized methods: \begin{methoddesc}{adjusted}{} Return the number's adjusted exponent that results from shifting out the coefficients rightmost digits until only the lead digit remains: \code{Decimal("321e+5").adjusted()} returns seven. Used for determining the place value of the most significant digit. \end{methoddesc} \begin{methoddesc}{as_tuple}{} Returns a tuple representation of the number: \samp{(sign, digittuple, exponent)}. \end{methoddesc} \begin{methoddesc}{compare}{other\optional{, context}} Compares like \method{__cmp__()} but returns a decimal instance: \begin{verbatim} a or b is a NaN ==> Decimal("NaN") a < b ==> Decimal("-1") a == b ==> Decimal("0") a > b ==> Decimal("1") \end{verbatim} \end{methoddesc} \begin{methoddesc}{max}{other\optional{, context}} Like \samp{max(self, other)} but returns \constant{NaN} if either is a \constant{NaN}. Applies the context rounding rule before returning. \end{methoddesc} \begin{methoddesc}{min}{other\optional{, context}} Like \samp{min(self, other)} but returns \constant{NaN} if either is a \constant{NaN}. Applies the context rounding rule before returning. \end{methoddesc} \begin{methoddesc}{normalize}{\optional{context}} Normalize the number by striping the rightmost trailing zeroes and converting any result equal to \constant{Decimal("0")} to Decimal("0e0"). Used for producing a canonical value for members of an equivalence class. For example, \code{Decimal("32.100")} and \code{Decimal("0.321000e+2")} both normalize to the equivalent value \code{Decimal("32.1")} \end{methoddesc} \begin{methoddesc}{quantize} {\optional{exp \optional{, rounding\optional{, context\optional{, watchexp}}}}} Quantize makes the exponent the same as \var{exp}. Searches for a rounding method in \var{rounding}, then in \var{context}, and then in the current context. Of \var{watchexp} is set (default), then an error is returned if the resulting exponent is greater than \member{Emax} or less than \member{Etiny}. \end{methoddesc} \begin{methoddesc}{remainder_near}{other\optional{, context}} Computed the modulo as either a positive or negative value depending on which is closest to zero. For instance, \samp{Decimal(10).remainder_near(6)} returns \code{Decimal("-2")} which is closer to zero than \code{Decimal("4")}. If both are equally close, the one chosen will have the same sign as \var{self}. \end{methoddesc} \begin{methoddesc}{same_quantum{other\optional{, context}}} Test whether self and other have the same exponent or whether both are \constant{NaN}. \end{methoddesc} \begin{methoddesc}{sqrt}{\optional{context}} Return the square root to full precision. \end{methoddesc} \begin{methoddesc}{to_eng_string}{\optional{context}} Convert to engineering-type string. Engineering notation has an exponent which is a multiple of 3, so there are up to 3 digits left of the decimal place. For example, converts \code{Decimal('123E+1')} to \code{Decimal("1.23E+3")} \end{methoddesc} \begin{methoddesc}{to_integral}{\optional{rounding\optional{, context}}} Rounds to the nearest integer, without signaling \constant{Inexact} or \constant{Rounded}. If given, applies \var{rounding}; otherwise, uses the rounding method in either the supplied \var{context} or the current context. \end{methoddesc} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \subsection{Context objects \label{decimal-decimal}} Contexts are environments for arithmetic operations. They govern the precision, rules for rounding, determine which signals are treated as exceptions, and set limits on the range for exponents. Each thread has its own current context which is accessed or changed using the \function{getcontext()} and \function{setcontext()} functions: \begin{funcdesc}{getcontext}{} Return the current context for the active thread. \end{funcdesc} \begin{funcdesc}{setcontext}{c} Set the current context for the active thread to \var{c}. \end{funcdesc} New contexts can formed using the \class{Context} constructor described below. In addition, the module provides three pre-made contexts: \begin{classdesc*}{BasicContext} This is a standard context defined by the General Decimal Arithmetic Specification. Precision is set to nine. Rounding is set to \constant{ROUND_HALF_UP}. All flags are cleared. All traps are enabled (treated as exceptions) except \constant{Inexact}, \constant{Rounded}, and \constant{Subnormal}. Because many of the traps are enabled, this context is useful for debugging. \end{classdesc*} \begin{classdesc*}{ExtendedContext} This is a standard context defined by the General Decimal Arithmetic Specification. Precision is set to nine. Rounding is set to \constant{ROUND_HALF_EVEN}. All flags are cleared. No traps are enabled (so that exceptions are not raised during computations). \end{classdesc*} \begin{classdesc*}{DefaultContext} This class is used by the \class{Context} constructor as a prototype for new contexts. Changing a field (such a precision) has the effect of changing the default for new contexts creating by the \class{Context} constructor. This context is most useful in multi-threaded environments. Changing one of the fields before threads are started has the effect of setting system-wide defaults. Changing the fields after threads have started is not recommended as it would require thread synchronization to prevent race conditions. In single threaded environments, it is preferable to not use this context at all. Instead, simply create contexts explicitly. This is especially important because the default values context may change between releases (with initial release having precision=28, rounding=ROUND_HALF_EVEN, cleared flags, and no traps enabled). \end{classdesc*} \begin{classdesc}{Context}{prec=None, rounding=None, trap_enablers=None, flags=None, Emin=None, Emax=None, capitals=1} Creates a new context. If a field is not specified or is \constant{None}, the default values are copied from the \constant{DefaultContext}. If the \var{flags} field is not specified or is \constant{None}, all flags are cleared. The \var{prec} field in an positive integer that sets the precision for arithmetic operations in the context. The \var{rounding} option is one of: \constant{ROUND_CEILING}, \constant{ROUND_DOWN}, \constant{ROUND_FLOOR}, \constant{ROUND_HALF_DOWN}, \constant{ROUND_HALF_EVEN}, \constant{ROUND_HALF_UP}, or \constant{ROUND_UP}. The \var{trap_enablers} and \var{flags} fields are mappings from signals to either \constant{0} or \constant{1}. The \var{Emin} and \var{Emax} fields are integers specifying the outer limits allowable for exponents. The \var{capitals} field is either \constant{0} or \constant{1} (the default). If set to \constant{1}, exponents are printed with a capital \constant{E}; otherwise, lowercase is used: \constant{Decimal('6.02e+23')}. \end{classdesc} The \class{Context} class defines several general methods as well as a large number of methods for doing arithmetic directly from the context. \begin{methoddesc}{clear_flags}{} Sets all of the flags to \constant{0}. \end{methoddesc} \begin{methoddesc}{copy}{} Returns a duplicate of the context. \end{methoddesc} \begin{methoddesc}{create_decimal}{num} Creates a new Decimal instance but using \var{self} as context. Unlike the \class{Decimal} constructor, context precision, rounding method, flags, and traps are applied to the conversion. This is useful because constants are often given to a greater precision than is needed by the application. \end{methoddesc} \begin{methoddesc}{Etiny}{} Returns a value equal to \samp{Emin - prec + 1} which is the minimum exponent value for subnormal results. When underflow occurs, the exponont is set to \constant{Etiny}. \end{methoddesc} The usual approach to working with decimals is to create Decimal instances and then apply arithmetic operations which take place within the current context for the active thread. An alternate approach is to use a context method to perform a particular computation within the given context rather than the current context. Those methods parallel those for the \class{Decimal} class and are only briefed recounted here. \begin{methoddesc}{abs}{x} Returns the absolute value of \var{x}. \end{methoddesc} \begin{methoddesc}{add}{x, y} Return the sum of \var{x} and \var{y}. \end{methoddesc} \begin{methoddesc}{compare}{x, y} Compares values numerically. Like \method{__cmp__()} but returns a decimal instance: \begin{verbatim} a or b is a NaN ==> Decimal("NaN") a < b ==> Decimal("-1") a == b ==> Decimal("0") a > b ==> Decimal("1") \end{verbatim} \end{methoddesc} \begin{methoddesc}{divide}{x, y} Return \var{x} divided by \var{y}. \end{methoddesc} \begin{methoddesc}{divide}{x, y} Divides two numbers and returns the integer part of the result. \end{methoddesc} \begin{methoddesc}{max}{x, y} Compare two values numerically and returns the maximum. If they are numerically equal then the left-hand operand is chosen as the result. \end{methoddesc} \begin{methoddesc}{min}{x, y} Compare two values numerically and returns the minimum. If they are numerically equal then the left-hand operand is chosen as the result. \end{methoddesc} \begin{methoddesc}{minus}{x} Minus corresponds to unary prefix minus in Python. \end{methoddesc} \begin{methoddesc}{multiply}{x, y} Return the product of \var{x} and \var{y}. \end{methoddesc} \begin{methoddesc}{normalize}{x} Normalize reduces an operand to its simplest form. Essentially a plus operation with all trailing zeros removed from the result. \end{methoddesc} \begin{methoddesc}{plus}{x} Minus corresponds to unary prefix plus in Python. \end{methoddesc} \begin{methoddesc}{power}{x, y\optional{, modulo}} Return \samp{x ** y} to the \var{modulo} if given. The right-hand operand must be a whole number whose integer part (after any exponent has been applied) has no more than 9 digits and whose fractional part (if any) is all zeros before any rounding. The operand may be positive, negative, or zero; if negative, the absolute value of the power is used, and the left-hand operand is inverted (divided into 1) before use. If the increased precision needed for the intermediate calculations exceeds the capabilities of the implementation then an Invalid operation condition is raised. If, when raising to a negative power, an underflow occurs during the division into 1, the operation is not halted at that point but continues. \end{methoddesc} \begin{methoddesc}{quantize}{x, y} Returns a value equal to \var{x} after rounding and having the exponent of v\var{y}. Unlike other operations, if the length of the coefficient after the quantize operation would be greater than precision then an \constant{InvalidOperation} is signaled. This guarantees that, unless there is an error condition, the exponent of the result of a quantize is always equal to that of the right-hand operand. Also unlike other operations, quantize never signals Underflow, even if the result is subnormal and inexact. \end{methoddesc} \begin{methoddesc}{remainder}{x, y} Returns the remainder from integer division. The sign of the result, if non-zero, is the same as that of the original dividend. \end{methoddesc} \begin{methoddesc}{remainder_near}{x, y} Computed the modulo as either a positive or negative value depending on which is closest to zero. For instance, \samp{Decimal(10).remainder_near(6)} returns \code{Decimal("-2")} which is closer to zero than \code{Decimal("4")}. If both are equally close, the one chosen will have the same sign as \var{self}. \end{methoddesc} \begin{methoddesc}{same_quantum}{x, y} Test whether \var{x} and \var{y} have the same exponent or whether both are \constant{NaN}. \end{methoddesc} \begin{methoddesc}{sqrt}{} Return the square root to full precision. \end{methoddesc} \begin{methoddesc}{substract}{x, y} Return the difference of \var{x} and \var{y}. \end{methoddesc} \begin{methoddesc}{to_eng_string}{} Convert to engineering-type string. Engineering notation has an exponent which is a multiple of 3, so there are up to 3 digits left of the decimal place. For example, converts \code{Decimal('123E+1')} to \code{Decimal("1.23E+3")} \end{methoddesc} \begin{methoddesc}{to_integral}{x} Rounds to the nearest integer, without signaling \constant{Inexact} or \constant{Rounded}. \end{methoddesc} \begin{methoddesc}{to_sci_string}{} Converts a number to a string, using scientific notation. \end{methoddesc} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \subsection{Signals \label{decimal-signals}} Signals represent conditions that arise during computation. Each corresponds to one context flag and one context trap enabler. The context flag is incremented whenever the condition is encountered. After the computation, flags may be checked for informational purposed (for instance, to determine whether a computation was exact). After checking the flags, be sure to clear all flags before starting the next computation. If the context's trap enabler is set for the signal, then the condition causes a Python exception to be raised. For example, if the \class{DivisionByZero} trap is set, the a \exception{DivisionByZero} exception is raised upon encountering the condition. \begin{classdesc*}{Clamped} Altered an exponent to fit representation constraints. Typically, clamping occurs when an exponent falls outside the context's \member{Emin} and \member{Emax} limits. If possible, the exponent is reduced to fit by adding zeroes to the coefficient. \end{classdesc*} \begin{classdesc*}{ConversionSyntax} Trying to convert a mal-formed string such as: \code{Decimal('jump')}. Decimal converts only strings conforming to the numeric string syntax. If this signal is not trapped, returns \constant{NaN}. \end{classdesc*} \begin{classdesc*}{DecimalException} Base class for other signals. \end{classdesc*} \begin{classdesc*}{DivisionByZero} Signals the division of a non-infinite number by zero. Can occur with division, modulo division, or when raising a number to a negative power. If this signal is not trapped, return \constant{Infinity} or \constant{-Infinity} with sign determined by the inputs to the calculation. \end{classdesc*} \begin{classdesc*}{DivisionImpossible} Error performing a division operation. Caused when an intermediate result has more digits that the allowed by the current precision. If not trapped, returns \constant{NaN}. \end{classdesc*} \begin{classdesc*}{DivisionUndefined} This is a subclass of \class{DivisionByZero}. It occurs only in the context of division operations. \end{classdesc*} \begin{classdesc*}{Inexact} Indicates that rounding occurred and the result is not exact. Signals whenever non-zero digits were discarded during rounding. The rounded result is returned. The signal flag or trap is used to detect when results are inexact. \end{classdesc*} \begin{classdesc*}{InvalidContext} This is a subclass of \class{InvalidOperation}. Indicates an error within the Context object such as an unknown rounding operation. If not trapped, returns \constant{NaN}. \end{classdesc*} \begin{classdesc*}{InvalidOperation} An invalid operation was performed. Indicates that an operation was requested that does not make sense. If not trapped, returns \constant{NaN}. Possible causes include: \begin{verbatim} Infinity - Infinity 0 * Infinity Infinity / Infinity x % 0 Infinity % x x._rescale( non-integer ) sqrt(-x) and x > 0 0 ** 0 x ** (non-integer) x ** Infinity \end{verbatim} \end{classdesc*} \begin{classdesc*}{Overflow} Numerical overflow. Indicates the exponent is larger than \member{Emax} after rounding has occurred. If not trapped, the result depends on the rounding mode, either pulling inward to the largest representable finite number or rounding outward to \constant{Infinity}. In either case, \class{Inexact} and \class{Rounded} are also signaled. \end{classdesc*} \begin{classdesc*}{Rounded} Rounding occurred though possibly not information was lost. Signaled whenever rounding discards digits; even if those digits are zero (such as rounding \constant{5.00} to \constant{5.0}). If not trapped, returns the result unchanged. This signal is used to detect loss of significant digits. \end{classdesc*} \begin{classdesc*}{Subnormal} Exponent was lower than \member{Emin} prior to rounding. Occurs when an operation result is subnormal (the exponent is too small). If not trapped, returns the result unchanged. \end{classdesc*} \begin{classdesc*}{Underflow} Numerical underflow with result rounded to zero. Occurs when a subnormal result is pushed to zero by rounding. \class{Inexact} and \class{Subnormal} are also signaled. \end{classdesc*} The following table summarizes the hierarchy of signals: \begin{verbatim} exceptions.ArithmeticError(exceptions.StandardError) DecimalException Clamped DivisionByZero(DecimalException, exceptions.ZeroDivisionError) Inexact Overflow(Inexact, Rounded) Underflow(Inexact, Rounded, Subnormal) InvalidOperation ConversionSyntax DivisionImpossible DivisionUndefined(InvalidOperation, exceptions.ZeroDivisionError) InvalidContext Rounded Subnormal \end{verbatim} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \subsection{Working with threads \label{decimal-threads}} The \function{getcontext()} function accesses a different \class{Context} object for each thread. Having separate contexts means that threads may make changes (such as \code{getcontext.prec=10}) without interfering with other threads and without needing mutexes. Likewise, the \function{setcontext()} function automatically assigns its target to the current thread. If \function{setcontext()} has not been called before \function{getcontext()}, then \function{getcontext()} will automatically create a new context for use in the current thread. The new context is copied from a prototype context called \var{DefaultContext}. To control the defaults so that each thread will use the same values throughout the application, directly modify the \var{DefaultContext} object. This should be done \emph{before} any threads are started so that there won't be a race condition with threads calling \function{getcontext()}. For example: \begin{verbatim} # Set application wide defaults for all threads about to be launched DefaultContext.prec=12 DefaultContext.rounding=ROUND_DOWN DefaultContext.trap_enablers=dict.fromkeys(Signals, 0) setcontext(DefaultContext) # Now start all of the threads t1.start() t2.start() t3.start() . . . \end{verbatim} Index: lib.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/lib.tex,v retrieving revision 1.226 retrieving revision 1.227 diff -C2 -d -r1.226 -r1.227 *** lib.tex 31 May 2004 18:22:39 -0000 1.226 --- lib.tex 5 Jul 2004 05:52:03 -0000 1.227 *************** *** 121,124 **** --- 121,125 ---- \input{libunittest} \input{libtest} + \input{libdecimal} \input{libmath} \input{libcmath} From rhettinger at users.sourceforge.net Mon Jul 5 14:41:47 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Mon Jul 5 14:41:54 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libdecimal.tex,1.1,1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10274 Modified Files: libdecimal.tex Log Message: * Added missing info on construction from a tuple. * Added a recipe section. Index: libdecimal.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libdecimal.tex,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** libdecimal.tex 5 Jul 2004 05:52:03 -0000 1.1 --- libdecimal.tex 5 Jul 2004 18:41:42 -0000 1.2 *************** *** 293,299 **** Constructs a new \class{Decimal} object based from \var{value}. ! \var{value} can be an integer, string, or another \class{Decimal} object. ! If no \var{value} is given, returns \code{Decimal("0")}. If \var{value} is ! a string, it should conform to the decimal numeric string syntax: \begin{verbatim} --- 293,300 ---- Constructs a new \class{Decimal} object based from \var{value}. ! \var{value} can be an integer, string, tuple, or another \class{Decimal} ! object. If no \var{value} is given, returns \code{Decimal("0")}. If ! \var{value} is a string, it should conform to the decimal numeric string ! syntax: \begin{verbatim} *************** *** 310,313 **** --- 311,320 ---- \end{verbatim} + If \var{value} is a \class{tuple}, it should have three components, + a sign (\constant{0} for positive or \constant{1} for negative), + a \class{tuple} of digits, and an exponent represented as an integer. + For example, \samp{Decimal((0, (1, 4, 1, 4), -3))} returns + \samp{Decimal("1.414")}. + The supplied \var{context} or, if not specified, the current context governs only the handling of mal-formed strings not conforming to the *************** *** 707,711 **** \end{classdesc*} - \begin{classdesc*}{ConversionSyntax} Trying to convert a mal-formed string such as: \code{Decimal('jump')}. --- 714,717 ---- *************** *** 715,724 **** \end{classdesc*} - \begin{classdesc*}{DecimalException} Base class for other signals. \end{classdesc*} - \begin{classdesc*}{DivisionByZero} Signals the division of a non-infinite number by zero. --- 721,728 ---- *************** *** 730,734 **** \end{classdesc*} - \begin{classdesc*}{DivisionImpossible} Error performing a division operation. Caused when an intermediate result --- 734,737 ---- *************** *** 744,748 **** \end{classdesc*} - \begin{classdesc*}{Inexact} Indicates that rounding occurred and the result is not exact. --- 747,750 ---- *************** *** 761,765 **** \end{classdesc*} - \begin{classdesc*}{InvalidOperation} An invalid operation was performed. --- 763,766 ---- *************** *** 782,786 **** \end{classdesc*} - \begin{classdesc*}{Overflow} Numerical overflow. --- 783,786 ---- *************** *** 803,807 **** \end{classdesc*} - \begin{classdesc*}{Subnormal} Exponent was lower than \member{Emin} prior to rounding. --- 803,806 ---- *************** *** 811,815 **** \end{classdesc*} - \begin{classdesc*}{Underflow} Numerical underflow with result rounded to zero. --- 810,813 ---- *************** *** 819,823 **** \end{classdesc*} - The following table summarizes the hierarchy of signals: --- 817,820 ---- *************** *** 839,842 **** --- 836,841 ---- \end{verbatim} + + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \subsection{Working with threads \label{decimal-threads}} *************** *** 876,882 **** ! --- 875,1002 ---- + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + \subsection{Recipes \label{decimal-recipes}} + Here are some functions demonstrating ways to work with the + \class{Decimal} class: + \begin{verbatim} + from decimal import Decimal, getcontext + def moneyfmt(value, places=2, curr='$', sep=',', dp='.', pos='', neg='-'): + """Convert Decimal to a money formatted string. ! places: required number of places after the decimal point ! curr: optional currency symbol before the sign (may be blank) ! sep: optional grouping separator (comma, period, or blank) ! dp: decimal point indicator (comma or period) ! only set to blank if places is zero ! pos: optional sign for positive numbers ("+" or blank) ! neg: optional sign for negative numbers ("-" or blank) ! leave blank to separately add brackets or a trailing minus ! ! >>> d = Decimal('-1234567.8901') ! >>> moneyfmt(d) ! '-$1,234,567.89' ! >>> moneyfmt(d, places=0, curr='', sep='.', dp='') ! '-1.234.568' ! >>> '($%s)' % moneyfmt(d, curr='', neg='') ! '($1,234,567.89)' ! """ ! q = Decimal((0, (1,), -places)) # 2 places --> '0.01' ! sign, digits, exp = value.quantize(q).as_tuple() ! result = [] ! digits = map(str, digits) ! build, next = result.append, digits.pop ! for i in range(places): ! build(next()) ! build(dp) ! try: ! while 1: ! for i in range(3): ! build(next()) ! if digits: ! build(sep) ! except IndexError: ! pass ! build(curr) ! if sign: ! build(neg) ! else: ! build(pos) ! result.reverse() ! return ''.join(result) ! ! def pi(): ! "Compute Pi to the current precision" ! getcontext().prec += 9 # extra digits for intermediate steps ! one = Decimal(1) # substitute "one=1.0" for regular floats ! lastc, t, c, n, na, d, da = 0*one, 3*one, 3*one, 1, 0, 0, 24*one ! while c != lastc: ! lastc = c ! n, na = n+na, na+8 ! d, da = d+da, da+32 ! t = (t * n) / d ! c += t ! getcontext().prec -= 10 ! return c ! ! def exp(x): ! """Return e raised to the power of x. ! ! >>> print exp(Decimal(1)) ! 2.718281828459045235360287471352662498 ! >>> print exp(Decimal(2)) ! 7.389056098930650227230427460575007813 ! """ ! getcontext().prec += 9 # extra digits for intermediate steps ! one = Decimal(1) # substitute "one=1.0" for regular floats ! i, laste, e, fact, num = 0*one, 0*one, one, one, one ! while e != laste: ! laste = e ! i += 1 ! fact *= i ! num *= x ! e += num / fact ! getcontext().prec -= 9 ! return e ! ! def cos(x): ! """Return the cosine of x as measured in radians. ! ! >>> print cos(Decimal('0.5')) ! 0.8775825618903727161162815826038296521 ! """ ! getcontext().prec += 9 # extra digits for intermediate steps ! one = Decimal(1) # substitute "one=1.0" for regular floats ! i, laste, e, fact, num, sign = 0*one, 0*one, one, one, one, one ! while e != laste: ! laste = e ! i += 2 ! fact *= i * (i-1) ! num *= x * x ! sign *= -1 ! e += num / fact * sign ! getcontext().prec -= 9 ! return e ! ! def sin(x): ! """Return the cosine of x as measured in radians. ! ! >>> print sin(Decimal('0.5')) ! 0.4794255386042030002732879352155713880 ! """ ! getcontext().prec += 9 # extra digits for intermediate steps ! one = Decimal(1) # substitute "one=1.0" for regular floats ! i, laste, e, fact, num, sign = one, 0*one, x, one, x, one ! while e != laste: ! laste = e ! i += 2 ! fact *= i * (i-1) ! num *= x * x ! sign *= -1 ! e += num / fact * sign ! getcontext().prec -= 9 ! return e ! ! \end{verbatim} From rhettinger at users.sourceforge.net Mon Jul 5 14:48:25 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Mon Jul 5 14:48:28 2004 Subject: [Python-checkins] python/dist/src/Lib decimal.py,1.8,1.9 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11336 Modified Files: decimal.py Log Message: * Update the todo list. * Make ConversionSyntax signals get trapped by default. Index: decimal.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/decimal.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** decimal.py 5 Jul 2004 05:36:39 -0000 1.8 --- decimal.py 5 Jul 2004 18:48:22 -0000 1.9 *************** *** 10,14 **** # Todo: ! # Provide a clean way of attaching monetary format representations --- 10,14 ---- # Todo: ! # Add rich comparisons for equality testing with other types *************** *** 2970,2973 **** --- 2970,2974 ---- capitals=1 ) + DefaultContext.trap_enablers.update({ConversionSyntax : 1}) # Pre-made alternate contexts offered by the specification From rhettinger at users.sourceforge.net Mon Jul 5 14:49:41 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Mon Jul 5 14:49:45 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_decimal.py,1.3,1.4 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11608 Modified Files: test_decimal.py Log Message: Test the logic for int(d). Index: test_decimal.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_decimal.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** test_decimal.py 3 Jul 2004 12:26:21 -0000 1.3 --- test_decimal.py 5 Jul 2004 18:49:38 -0000 1.4 *************** *** 1059,1062 **** --- 1059,1072 ---- self.assertEqual(d, e) + def test_int(self): + data = '1.0 1.1 1.9 2.0 0.0 -1.0 -1.1 -1.9 -2.0'.split() + for s in data: + # should work the same as for floats + self.assertEqual(int(Decimal(s)), int(float(s))) + # should work the same as ROUND_DOWN + d = Decimal(s) + r = Context(prec=1, rounding=ROUND_DOWN).create_decimal(s) + self.assertEqual(Decimal(int(d)), r) + class ContextAPItests(unittest.TestCase): From rhettinger at users.sourceforge.net Mon Jul 5 14:56:05 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Mon Jul 5 14:56:07 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libdecimal.tex,1.2,1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12961 Modified Files: libdecimal.tex Log Message: Fix typo Index: libdecimal.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libdecimal.tex,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** libdecimal.tex 5 Jul 2004 18:41:42 -0000 1.2 --- libdecimal.tex 5 Jul 2004 18:56:03 -0000 1.3 *************** *** 939,943 **** t = (t * n) / d c += t ! getcontext().prec -= 10 return c --- 939,943 ---- t = (t * n) / d c += t ! getcontext().prec -= 9 return c From rhettinger at users.sourceforge.net Tue Jul 6 03:55:17 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Tue Jul 6 03:55:20 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libdecimal.tex,1.6,1.7 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22699 Modified Files: libdecimal.tex Log Message: Demonstrate how to round final result. Index: libdecimal.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libdecimal.tex,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** libdecimal.tex 5 Jul 2004 21:13:28 -0000 1.6 --- libdecimal.tex 6 Jul 2004 01:55:14 -0000 1.7 *************** *** 933,939 **** >>> print pi() ! 3.141592653589793238462643383279502887 """ ! getcontext().prec += 9 # extra digits for intermediate steps three = Decimal(3) # substitute "three=3.0" for regular floats lastc, t, c, n, na, d, da = 0, three, 3, 1, 0, 0, 24 --- 933,939 ---- >>> print pi() ! 3.141592653589793238462643383 """ ! getcontext().prec += 2 # extra digits for intermediate steps three = Decimal(3) # substitute "three=3.0" for regular floats lastc, t, c, n, na, d, da = 0, three, 3, 1, 0, 0, 24 *************** *** 944,949 **** t = (t * n) / d c += t ! getcontext().prec -= 9 ! return c def exp(x): --- 944,949 ---- t = (t * n) / d c += t ! getcontext().prec -= 2 ! return c + 0 def exp(x): *************** *** 951,957 **** >>> print exp(Decimal(1)) ! 2.718281828459045235360287471352662498 >>> print exp(Decimal(2)) ! 7.389056098930650227230427460575007813 >>> print exp(2.0) 7.38905609893 --- 951,957 ---- >>> print exp(Decimal(1)) ! 2.718281828459045235360287471 >>> print exp(Decimal(2)) ! 7.389056098930650227230427461 >>> print exp(2.0) 7.38905609893 *************** *** 959,963 **** (7.38905609893+0j) """ ! getcontext().prec += 9 # extra digits for intermediate steps i, laste, e, fact, num = 0, 0, 1, 1, 1 while e != laste: --- 959,963 ---- (7.38905609893+0j) """ ! getcontext().prec += 2 # extra digits for intermediate steps i, laste, e, fact, num = 0, 0, 1, 1, 1 while e != laste: *************** *** 967,972 **** num *= x e += num / fact ! getcontext().prec -= 9 ! return e def cos(x): --- 967,972 ---- num *= x e += num / fact ! getcontext().prec -= 2 ! return e + 0 def cos(x): *************** *** 974,978 **** >>> print cos(Decimal('0.5')) ! 0.8775825618903727161162815826038296521 >>> print cos(0.5) 0.87758256189 --- 974,978 ---- >>> print cos(Decimal('0.5')) ! 0.8775825618903727161162815826 >>> print cos(0.5) 0.87758256189 *************** *** 980,984 **** (0.87758256189+0j) """ ! getcontext().prec += 9 # extra digits for intermediate steps i, laste, e, fact, num, sign = 0, 0, 1, 1, 1, 1 while e != laste: --- 980,984 ---- (0.87758256189+0j) """ ! getcontext().prec += 2 # extra digits for intermediate steps i, laste, e, fact, num, sign = 0, 0, 1, 1, 1, 1 while e != laste: *************** *** 989,994 **** sign *= -1 e += num / fact * sign ! getcontext().prec -= 9 ! return e def sin(x): --- 989,994 ---- sign *= -1 e += num / fact * sign ! getcontext().prec -= 2 ! return e + 0 def sin(x): *************** *** 996,1000 **** >>> print sin(Decimal('0.5')) ! 0.4794255386042030002732879352155713880 >>> print sin(0.5) 0.479425538604 --- 996,1000 ---- >>> print sin(Decimal('0.5')) ! 0.4794255386042030002732879352 >>> print sin(0.5) 0.479425538604 *************** *** 1002,1006 **** (0.479425538604+0j) """ ! getcontext().prec += 9 # extra digits for intermediate steps i, laste, e, fact, num, sign = 1, 0, x, 1, x, 1 while e != laste: --- 1002,1006 ---- (0.479425538604+0j) """ ! getcontext().prec += 2 # extra digits for intermediate steps i, laste, e, fact, num, sign = 1, 0, x, 1, x, 1 while e != laste: *************** *** 1011,1016 **** sign *= -1 e += num / fact * sign ! getcontext().prec -= 9 ! return e \end{verbatim} --- 1011,1016 ---- sign *= -1 e += num / fact * sign ! getcontext().prec -= 2 ! return e + 0 \end{verbatim} From rhettinger at users.sourceforge.net Tue Jul 6 03:15:36 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Tue Jul 6 03:55:22 2004 Subject: [Python-checkins] python/nondist/peps pep-0000.txt, 1.273, 1.274 pep-0327.txt, 1.5, 1.6 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16890 Modified Files: pep-0000.txt pep-0327.txt Log Message: Mark PEP327 (decimal floating point) as approved and final. Index: pep-0000.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0000.txt,v retrieving revision 1.273 retrieving revision 1.274 diff -C2 -d -r1.273 -r1.274 *** pep-0000.txt 28 May 2004 01:45:32 -0000 1.273 --- pep-0000.txt 6 Jul 2004 01:15:33 -0000 1.274 *************** *** 122,126 **** S 324 popen5 - New POSIX process module Astrand S 325 Resource-Release Support for Generators Pedroni - S 327 Decimal Data Type Batista S 330 Python Bytecode Verification Pelletier S 754 IEEE 754 Floating Point Special Values Warnes --- 122,125 ---- *************** *** 166,169 **** --- 165,169 ---- SF 311 Simplified GIL Acquisition for Extensions Hammond SF 322 Reverse Iteration Hettinger + SF 327 Decimal Data Type Batista Empty PEPs (or containing only an abstract) *************** *** 350,354 **** S 325 Resource-Release Support for Generators Pedroni SR 326 A Case for Top and Bottom Values Carlson, Reedy ! S 327 Decimal Data Type Batista SA 328 Imports: Multi-Line and Absolute/Relative Aahz SR 329 Treating Builtins as Constants in the Standard Library Hettinger --- 350,354 ---- S 325 Resource-Release Support for Generators Pedroni SR 326 A Case for Top and Bottom Values Carlson, Reedy ! SF 327 Decimal Data Type Batista SA 328 Imports: Multi-Line and Absolute/Relative Aahz SR 329 Treating Builtins as Constants in the Standard Library Hettinger Index: pep-0327.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0327.txt,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** pep-0327.txt 30 Jun 2004 04:46:47 -0000 1.5 --- pep-0327.txt 6 Jul 2004 01:15:33 -0000 1.6 *************** *** 4,8 **** Last-Modified: $Date$ Author: Facundo Batista ! Status: Draft Type: Standards Track Content-Type: text/x-rst --- 4,8 ---- Last-Modified: $Date$ Author: Facundo Batista ! Status: Final Type: Standards Track Content-Type: text/x-rst From rhettinger at users.sourceforge.net Tue Jul 6 00:53:06 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Tue Jul 6 03:55:25 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_decimal.py,1.4,1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24143/test Modified Files: test_decimal.py Log Message: * Add __eq__ and __ne__ so that things like list.index() work properly for lists of mixed types. * Test that sort works. Index: test_decimal.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_decimal.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** test_decimal.py 5 Jul 2004 18:49:38 -0000 1.4 --- test_decimal.py 5 Jul 2004 22:53:03 -0000 1.5 *************** *** 34,37 **** --- 34,38 ---- from test.test_support import TestSkipped, run_unittest, run_doctest, is_resource_enabled import threading + import random # Tests are built around these assumed context defaults *************** *** 842,856 **** #a Decimal and uncomparable ! try: da == 'ugly' ! except TypeError: pass ! else: self.fail('Did not raised an error!') ! ! try: da == '32.7' ! except TypeError: pass ! else: self.fail('Did not raised an error!') ! try: da == object ! except TypeError: pass ! else: self.fail('Did not raised an error!') def test_copy_and_deepcopy_methods(self): --- 843,857 ---- #a Decimal and uncomparable ! self.assertNotEqual(da, 'ugly') ! self.assertNotEqual(da, 32.7) ! self.assertNotEqual(da, object()) ! self.assertNotEqual(da, object) ! # sortable ! a = map(Decimal, xrange(100)) ! b = a[:] ! random.shuffle(a) ! a.sort() ! self.assertEqual(a, b) def test_copy_and_deepcopy_methods(self): *************** *** 1079,1082 **** --- 1080,1087 ---- self.assertEqual(v1, v2) + def test_equality_with_other_types(self): + self.assert_(Decimal(10) in ['a', 1.0, Decimal(10), (1,2), {}]) + self.assert_(Decimal(10) not in ['a', 1.0, (1,2), {}]) + def test_main(arith=False, verbose=None): """ Execute the tests. From rhettinger at users.sourceforge.net Tue Jul 6 00:53:05 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Tue Jul 6 03:55:25 2004 Subject: [Python-checkins] python/dist/src/Lib decimal.py,1.9,1.10 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24143 Modified Files: decimal.py Log Message: * Add __eq__ and __ne__ so that things like list.index() work properly for lists of mixed types. * Test that sort works. Index: decimal.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/decimal.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** decimal.py 5 Jul 2004 18:48:22 -0000 1.9 --- decimal.py 5 Jul 2004 22:53:02 -0000 1.10 *************** *** 9,16 **** - # Todo: - # Add rich comparisons for equality testing with other types - - """ This is a Py2.3 implementation of decimal floating point arithmetic based on --- 9,12 ---- *************** *** 645,648 **** --- 641,654 ---- return 1 + def __eq__(self, other): + if not isinstance(other, (Decimal, int, long)): + return False + return self.__cmp__(other) == 0 + + def __ne__(self, other): + if not isinstance(other, (Decimal, int, long)): + return True + return self.__cmp__(other) != 0 + def compare(self, other, context=None): """Compares one to another. From rhettinger at users.sourceforge.net Mon Jul 5 23:13:31 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Tue Jul 6 03:55:26 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libdecimal.tex,1.5,1.6 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5645 Modified Files: libdecimal.tex Log Message: Expand examples to show polymorphism Index: libdecimal.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libdecimal.tex,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** libdecimal.tex 5 Jul 2004 20:27:53 -0000 1.5 --- libdecimal.tex 5 Jul 2004 21:13:28 -0000 1.6 *************** *** 936,940 **** """ getcontext().prec += 9 # extra digits for intermediate steps ! three = Decimal(3) # substitute "three=3.0" for regular floats lastc, t, c, n, na, d, da = 0, three, 3, 1, 0, 0, 24 while c != lastc: --- 936,940 ---- """ getcontext().prec += 9 # extra digits for intermediate steps ! three = Decimal(3) # substitute "three=3.0" for regular floats lastc, t, c, n, na, d, da = 0, three, 3, 1, 0, 0, 24 while c != lastc: *************** *** 948,952 **** def exp(x): ! """Return e raised to the power of x. >>> print exp(Decimal(1)) --- 948,952 ---- def exp(x): ! """Return e raised to the power of x. Result type matches input type. >>> print exp(Decimal(1)) *************** *** 954,957 **** --- 954,961 ---- >>> print exp(Decimal(2)) 7.389056098930650227230427460575007813 + >>> print exp(2.0) + 7.38905609893 + >>> print exp(2+0j) + (7.38905609893+0j) """ getcontext().prec += 9 # extra digits for intermediate steps *************** *** 971,974 **** --- 975,982 ---- >>> print cos(Decimal('0.5')) 0.8775825618903727161162815826038296521 + >>> print cos(0.5) + 0.87758256189 + >>> print cos(0.5+0j) + (0.87758256189+0j) """ getcontext().prec += 9 # extra digits for intermediate steps *************** *** 989,992 **** --- 997,1004 ---- >>> print sin(Decimal('0.5')) 0.4794255386042030002732879352155713880 + >>> print sin(0.5) + 0.479425538604 + >>> print sin(0.5+0j) + (0.479425538604+0j) """ getcontext().prec += 9 # extra digits for intermediate steps From rhettinger at users.sourceforge.net Mon Jul 5 22:27:55 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Tue Jul 6 03:55:29 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libdecimal.tex,1.4,1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29616 Modified Files: libdecimal.tex Log Message: Simplify examples. Index: libdecimal.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libdecimal.tex,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** libdecimal.tex 5 Jul 2004 20:17:13 -0000 1.4 --- libdecimal.tex 5 Jul 2004 20:27:53 -0000 1.5 *************** *** 936,941 **** """ getcontext().prec += 9 # extra digits for intermediate steps ! one = Decimal(1) # substitute "one=1.0" for regular floats ! lastc, t, c, n, na, d, da = 0*one, 3*one, 3*one, 1, 0, 0, 24*one while c != lastc: lastc = c --- 936,941 ---- """ getcontext().prec += 9 # extra digits for intermediate steps ! three = Decimal(3) # substitute "three=3.0" for regular floats ! lastc, t, c, n, na, d, da = 0, three, 3, 1, 0, 0, 24 while c != lastc: lastc = c *************** *** 956,960 **** """ getcontext().prec += 9 # extra digits for intermediate steps - one = Decimal(1) # substitute "one=1.0" for regular floats i, laste, e, fact, num = 0, 0, 1, 1, 1 while e != laste: --- 956,959 ---- *************** *** 974,978 **** """ getcontext().prec += 9 # extra digits for intermediate steps - one = Decimal(1) # substitute "one=1.0" for regular floats i, laste, e, fact, num, sign = 0, 0, 1, 1, 1, 1 while e != laste: --- 973,976 ---- *************** *** 993,997 **** """ getcontext().prec += 9 # extra digits for intermediate steps - one = Decimal(1) # substitute "one=1.0" for regular floats i, laste, e, fact, num, sign = 1, 0, x, 1, x, 1 while e != laste: --- 991,994 ---- From rhettinger at users.sourceforge.net Mon Jul 5 22:17:15 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Tue Jul 6 03:55:30 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libdecimal.tex,1.3,1.4 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27972 Modified Files: libdecimal.tex Log Message: Doc tested the recipes. Index: libdecimal.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libdecimal.tex,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** libdecimal.tex 5 Jul 2004 18:56:03 -0000 1.3 --- libdecimal.tex 5 Jul 2004 20:17:13 -0000 1.4 *************** *** 883,886 **** --- 883,887 ---- \begin{verbatim} from decimal import Decimal, getcontext + getcontext().prec = 28 def moneyfmt(value, places=2, curr='$', sep=',', dp='.', pos='', neg='-'): *************** *** 929,933 **** def pi(): ! "Compute Pi to the current precision" getcontext().prec += 9 # extra digits for intermediate steps one = Decimal(1) # substitute "one=1.0" for regular floats --- 930,938 ---- def pi(): ! """Compute Pi to the current precision. ! ! >>> print pi() ! 3.141592653589793238462643383279502887 ! """ getcontext().prec += 9 # extra digits for intermediate steps one = Decimal(1) # substitute "one=1.0" for regular floats *************** *** 952,956 **** getcontext().prec += 9 # extra digits for intermediate steps one = Decimal(1) # substitute "one=1.0" for regular floats ! i, laste, e, fact, num = 0*one, 0*one, one, one, one while e != laste: laste = e --- 957,961 ---- getcontext().prec += 9 # extra digits for intermediate steps one = Decimal(1) # substitute "one=1.0" for regular floats ! i, laste, e, fact, num = 0, 0, 1, 1, 1 while e != laste: laste = e *************** *** 970,974 **** getcontext().prec += 9 # extra digits for intermediate steps one = Decimal(1) # substitute "one=1.0" for regular floats ! i, laste, e, fact, num, sign = 0*one, 0*one, one, one, one, one while e != laste: laste = e --- 975,979 ---- getcontext().prec += 9 # extra digits for intermediate steps one = Decimal(1) # substitute "one=1.0" for regular floats ! i, laste, e, fact, num, sign = 0, 0, 1, 1, 1, 1 while e != laste: laste = e *************** *** 989,993 **** getcontext().prec += 9 # extra digits for intermediate steps one = Decimal(1) # substitute "one=1.0" for regular floats ! i, laste, e, fact, num, sign = one, 0*one, x, one, x, one while e != laste: laste = e --- 994,998 ---- getcontext().prec += 9 # extra digits for intermediate steps one = Decimal(1) # substitute "one=1.0" for regular floats ! i, laste, e, fact, num, sign = 1, 0, x, 1, x, 1 while e != laste: laste = e *************** *** 998,1002 **** e += num / fact * sign getcontext().prec -= 9 ! return e \end{verbatim} --- 1003,1007 ---- e += num / fact * sign getcontext().prec -= 9 ! return e \end{verbatim} From rhettinger at users.sourceforge.net Tue Jul 6 15:44:43 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Tue Jul 6 15:44:46 2004 Subject: [Python-checkins] python/dist/src/Python bltinmodule.c,2.310,2.311 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9136/Python Modified Files: bltinmodule.c Log Message: * Fix missing return after error message is set. * Add a test case that would have caught it. Index: bltinmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/bltinmodule.c,v retrieving revision 2.310 retrieving revision 2.311 diff -C2 -d -r2.310 -r2.311 *** bltinmodule.c 2 Jul 2004 06:41:07 -0000 2.310 --- bltinmodule.c 6 Jul 2004 13:44:40 -0000 2.311 *************** *** 460,464 **** if (locals != Py_None && !PyMapping_Check(locals)) { PyErr_SetString(PyExc_TypeError, "locals must be a mapping"); ! return NULL; } if (globals != Py_None && !PyDict_Check(globals)) { --- 460,464 ---- if (locals != Py_None && !PyMapping_Check(locals)) { PyErr_SetString(PyExc_TypeError, "locals must be a mapping"); ! return NULL; } if (globals != Py_None && !PyDict_Check(globals)) { *************** *** 466,469 **** --- 466,470 ---- "globals must be a real dict; try eval(expr, {}, mapping)" : "globals must be a dict"); + return NULL; } if (globals == Py_None) { From rhettinger at users.sourceforge.net Tue Jul 6 15:44:43 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Tue Jul 6 15:44:47 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_builtin.py, 1.30, 1.31 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9136/Lib/test Modified Files: test_builtin.py Log Message: * Fix missing return after error message is set. * Add a test case that would have caught it. Index: test_builtin.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_builtin.py,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** test_builtin.py 2 Jul 2004 06:41:05 -0000 1.30 --- test_builtin.py 6 Jul 2004 13:44:41 -0000 1.31 *************** *** 282,285 **** --- 282,286 ---- self.assertEqual(eval('globals()', g, m), g) self.assertEqual(eval('locals()', g, m), m) + self.assertRaises(TypeError, eval, 'a', m) # Verify that dict subclasses work as well From bwarsaw at users.sourceforge.net Tue Jul 6 18:48:27 2004 From: bwarsaw at users.sourceforge.net (bwarsaw@users.sourceforge.net) Date: Tue Jul 6 18:48:31 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_socket.py, 1.70, 1.71 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12991 Modified Files: test_socket.py Log Message: testGetServBy(): Use services that should be available both on *nix and Windows (XP at least ;). Test in this order: echo, daytime, domain. Index: test_socket.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_socket.py,v retrieving revision 1.70 retrieving revision 1.71 diff -C2 -d -r1.70 -r1.71 *** test_socket.py 28 Jun 2004 00:50:37 -0000 1.70 --- test_socket.py 6 Jul 2004 16:48:25 -0000 1.71 *************** *** 290,294 **** # I've ordered this by protocols that have both a tcp and udp # protocol, at least for modern Linuxes. ! for service in ('ssh', 'www', 'echo', 'imap2'): try: port = socket.getservbyname(service, 'tcp') --- 290,294 ---- # I've ordered this by protocols that have both a tcp and udp # protocol, at least for modern Linuxes. ! for service in ('echo', 'daytime', 'domain'): try: port = socket.getservbyname(service, 'tcp') From gvanrossum at users.sourceforge.net Tue Jul 6 19:52:36 2004 From: gvanrossum at users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Tue Jul 6 19:52:40 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1023,1.1024 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26264 Modified Files: NEWS Log Message: Add msg for bug #981530 (shutil.rmtree). Somehow that got missed in the checkin. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1023 retrieving revision 1.1024 diff -C2 -d -r1.1023 -r1.1024 *** NEWS 4 Jul 2004 15:41:59 -0000 1.1023 --- NEWS 6 Jul 2004 17:52:32 -0000 1.1024 *************** *** 360,363 **** --- 360,367 ---- Library ------- + + - Bug #981530: Fix UnboundLocalError in shutil.rmtree(). This affects + the documented behavior: the function passed to the onerror() + handler can now also be os.listdir. - Bug #754449: threading.Thread objects no longer mask exceptions raised during From gvanrossum at users.sourceforge.net Tue Jul 6 19:55:28 2004 From: gvanrossum at users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Tue Jul 6 19:55:31 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS, 1.831.4.128, 1.831.4.129 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26763 Modified Files: Tag: release23-maint NEWS Log Message: Add msg for bug #981530 (shutil.rmtree). Somehow that got missed in the checkin. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.831.4.128 retrieving revision 1.831.4.129 diff -C2 -d -r1.831.4.128 -r1.831.4.129 *** NEWS 3 Jul 2004 19:58:58 -0000 1.831.4.128 --- NEWS 6 Jul 2004 17:55:25 -0000 1.831.4.129 *************** *** 40,43 **** --- 40,47 ---- Library ------- + + - Bug #981530: Fix UnboundLocalError in shutil.rmtree(). This affects + the documented behavior: the function passed to the onerror() + handler can now also be os.listdir. - Bug #754449: threading.Thread will no longer mask exceptions raised during From theller at users.sourceforge.net Tue Jul 6 21:23:31 2004 From: theller at users.sourceforge.net (theller@users.sourceforge.net) Date: Tue Jul 6 21:23:38 2004 Subject: [Python-checkins] python/dist/src/Lib/distutils/command bdist_wininst.py, 1.48, 1.49 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils/command In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11947 Modified Files: bdist_wininst.py Log Message: Fix SF#983164. Patch from Mark Hammond: bdist_wininst attempts to use the correct MSVC runtime for the current version of Python. This doesn't work correctly when --target-version is set. In that case, bdist_wininst still uses the *current* sys.version (ie, 2.4) rather than the version specified as --target-version. Thus, the msvc7 runtime based executable stub is *always* used. This patch "hard-codes" knowledge of earlier Python versions, providing the correct result when Python 2.4 is used to build Python 2.3 and earlier distributions. Remove the short variant (-v) of the --target-version command line options, it conflicts with the --verbose/-v standard distutils switch. Index: bdist_wininst.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/bdist_wininst.py,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -d -r1.48 -r1.49 *** bdist_wininst.py 20 Feb 2004 19:38:50 -0000 1.48 --- bdist_wininst.py 6 Jul 2004 19:23:27 -0000 1.49 *************** *** 25,29 **** "keep the pseudo-installation tree around after " + "creating the distribution archive"), ! ('target-version=', 'v', "require a specific python version" + " on the target system"), --- 25,29 ---- "keep the pseudo-installation tree around after " + "creating the distribution archive"), ! ('target-version=', None, "require a specific python version" + " on the target system"), *************** *** 266,274 **** def get_exe_bytes (self): from distutils.msvccompiler import get_build_version # wininst-x.y.exe is in the same directory as this file directory = os.path.dirname(__file__) # we must use a wininst-x.y.exe built with the same C compiler # used for python. XXX What about mingw, borland, and so on? ! filename = os.path.join(directory, "wininst-%s.exe" % get_build_version()) return open(filename, "rb").read() # class bdist_wininst --- 266,298 ---- def get_exe_bytes (self): from distutils.msvccompiler import get_build_version + # If a target-version other than the current version has been + # specified, then using the MSVC version from *this* build is no good. + # Without actually finding and executing the target version and parsing + # its sys.version, we just hard-code our knowledge of old versions. + # NOTE: Possible alternative is to allow "--target-version" to + # specify a Python executable rather than a simple version string. + # We can then execute this program to obtain any info we need, such + # as the real sys.version string for the build. + cur_version = get_python_version() + if self.target_version and self.target_version != cur_version: + # If the target version is *later* than us, then we assume they + # use what we use + # string compares seem wrong, but are what sysconfig.py itself uses + if self.target_version > cur_version: + bv = get_build_version() + else: + if self.target_version < "2.4": + bv = "6" + else: + bv = "7.1" + else: + # for current version - use authoritative check. + bv = get_build_version() + # wininst-x.y.exe is in the same directory as this file directory = os.path.dirname(__file__) # we must use a wininst-x.y.exe built with the same C compiler # used for python. XXX What about mingw, borland, and so on? ! filename = os.path.join(directory, "wininst-%s.exe" % bv) return open(filename, "rb").read() # class bdist_wininst From montanaro at users.sourceforge.net Tue Jul 6 23:53:30 2004 From: montanaro at users.sourceforge.net (montanaro@users.sourceforge.net) Date: Tue Jul 6 23:53:33 2004 Subject: [Python-checkins] python/dist/src/Lib/idlelib PyShell.py,1.89,1.90 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/idlelib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9512 Modified Files: PyShell.py Log Message: whitespace normalization Index: PyShell.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/PyShell.py,v retrieving revision 1.89 retrieving revision 1.90 diff -C2 -d -r1.89 -r1.90 *** PyShell.py 4 Jul 2004 01:25:56 -0000 1.89 --- PyShell.py 6 Jul 2004 21:53:27 -0000 1.90 *************** *** 835,840 **** def set_warning_stream(self, stream): ! global warning_stream ! warning_stream = stream def get_warning_stream(self): --- 835,840 ---- def set_warning_stream(self, stream): ! global warning_stream ! warning_stream = stream def get_warning_stream(self): From tim_one at users.sourceforge.net Wed Jul 7 04:32:39 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Wed Jul 7 04:32:43 2004 Subject: [Python-checkins] python/dist/src/Doc/tut tut.tex,1.236,1.237 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/tut In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27357/Doc/tut Modified Files: tut.tex Log Message: Typo repair. Index: tut.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/tut/tut.tex,v retrieving revision 1.236 retrieving revision 1.237 diff -C2 -d -r1.236 -r1.237 *** tut.tex 1 Jul 2004 14:26:31 -0000 1.236 --- tut.tex 7 Jul 2004 02:32:36 -0000 1.237 *************** *** 5487,5491 **** if you simply round the display of your final results to the number of decimal digits you expect. \function{str()} usually suffices, and for ! finer control see the discussion of Pythons's \code{\%} format operator: the \code{\%g}, \code{\%f} and \code{\%e} format codes supply flexible and easy ways to round float results for display. --- 5487,5491 ---- if you simply round the display of your final results to the number of decimal digits you expect. \function{str()} usually suffices, and for ! finer control see the discussion of Python's \code{\%} format operator: the \code{\%g}, \code{\%f} and \code{\%e} format codes supply flexible and easy ways to round float results for display. From tim_one at users.sourceforge.net Wed Jul 7 04:46:05 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Wed Jul 7 04:46:09 2004 Subject: [Python-checkins] python/dist/src/Misc README.valgrind,1.1,1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28795/Misc Modified Files: README.valgrind Log Message: Made the explanation more accurate; trimmed trailing whitespace; fixed a typo. Index: README.valgrind =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/README.valgrind,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** README.valgrind 6 Jun 2004 19:58:40 -0000 1.1 --- README.valgrind 7 Jul 2004 02:46:03 -0000 1.2 *************** *** 1,23 **** This document describes some caveats about the use of Valgrind with ! Python. Valgrind is used periodically by Python developers to try to ensure there are no memory leaks or invalid memory reads/writes. If you don't want to read about the details of using Valgrind, there ! are still two things you must do to suppress the warnings. First, you must use a suppressions file. One is supplied in Misc/valgrind-python.supp. Second, you must do one of the following: * Uncomment Py_USING_MEMORY_DEBUGGER in Objects/obmalloc.c, ! then rebuild Python ! * Uncomment the lines in Misc/valgrind-python.supp that suppress the warnings for PyObject_Free and PyObject_Realloc Details: -------- ! Python uses its own allocation scheme on top of malloc called PyMalloc. ! Valgrind my show some unexpected results when PyMalloc is used. Starting with Python 2.3, PyMalloc is used by default. You can disable PyMalloc when configuring python by adding the --without-pymalloc option. ! If you disable PyMalloc, most of the information in this document and the supplied suppressions file will not be useful. --- 1,25 ---- This document describes some caveats about the use of Valgrind with ! Python. Valgrind is used periodically by Python developers to try to ensure there are no memory leaks or invalid memory reads/writes. If you don't want to read about the details of using Valgrind, there ! are still two things you must do to suppress the warnings. First, you must use a suppressions file. One is supplied in Misc/valgrind-python.supp. Second, you must do one of the following: * Uncomment Py_USING_MEMORY_DEBUGGER in Objects/obmalloc.c, ! then rebuild Python ! * Uncomment the lines in Misc/valgrind-python.supp that suppress the warnings for PyObject_Free and PyObject_Realloc Details: -------- ! Python uses its own small-object allocation scheme on top of malloc, ! called PyMalloc. ! ! Valgrind may show some unexpected results when PyMalloc is used. Starting with Python 2.3, PyMalloc is used by default. You can disable PyMalloc when configuring python by adding the --without-pymalloc option. ! If you disable PyMalloc, most of the information in this document and the supplied suppressions file will not be useful. *************** *** 33,37 **** PyMalloc needs to know whether an arbitrary address is one ! that's managed by it, or is managed by the system malloc. The current scheme allows this to be determined in constant time, regardless of how many memory areas are under pymalloc's --- 35,39 ---- PyMalloc needs to know whether an arbitrary address is one ! that's managed by it, or is managed by the system malloc. The current scheme allows this to be determined in constant time, regardless of how many memory areas are under pymalloc's *************** *** 39,48 **** The memory pymalloc manages itself is in one or more "arenas", ! each a large contiguous memory area obtained from malloc. ! The base address of each arena is saved by pymalloc ! in a vector, and a field at the start of each arena contains ! the index of that arena's base address in that vector. ! Given an arbitrary address, pymalloc computes the arena base address corresponding to it, then looks at "the index" stored near there. If the index read up is out of bounds for the --- 41,51 ---- The memory pymalloc manages itself is in one or more "arenas", ! each a large contiguous memory area obtained from malloc. ! The base address of each arena is saved by pymalloc ! in a vector. Each arena is carved into "pools", and a field at ! the start of each pool contains the index of that pool's arena's ! base address in that vector. ! Given an arbitrary address, pymalloc computes the pool base address corresponding to it, then looks at "the index" stored near there. If the index read up is out of bounds for the *************** *** 56,67 **** to ! the computed arena address ! pymalloc controls this arena if and only if they're equal. It doesn't matter whether the memory pymalloc reads up ("the index") is initialized. If it's not initialized, then whatever trash gets read up will lead pymalloc to conclude ! (correctly) that the address isn't controlled by it. This determination has to be made on every call to one of --- 59,73 ---- to ! the arbitrary address pymalloc is investigating ! pymalloc controls this arbitrary address if and only if it lies ! in the arena the address's pool's index claims it lies in. It doesn't matter whether the memory pymalloc reads up ("the index") is initialized. If it's not initialized, then whatever trash gets read up will lead pymalloc to conclude ! (correctly) that the address isn't controlled by it, either ! because the index is out of bounds, or the index is in bounds ! but the arena it represents doesn't contain the address. This determination has to be made on every call to one of From theller at users.sourceforge.net Wed Jul 7 09:34:42 2004 From: theller at users.sourceforge.net (theller@users.sourceforge.net) Date: Wed Jul 7 09:34:45 2004 Subject: [Python-checkins] python/dist/src/PC/bdist_wininst install.c, 1.6, 1.7 Message-ID: Update of /cvsroot/python/python/dist/src/PC/bdist_wininst In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3918 Modified Files: install.c Log Message: Remove the annoing and useless messagebox asking about overwriting files. Fixes SF #984290. Index: install.c =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/bdist_wininst/install.c,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** install.c 2 Jul 2004 23:53:16 -0000 1.6 --- install.c 7 Jul 2004 07:34:40 -0000 1.7 *************** *** 146,151 **** /* lParam: points to pathname */ - enum { UNSPECIFIED, ALWAYS, NEVER } allow_overwrite = UNSPECIFIED; - static BOOL notify(int code, char *fmt, ...); --- 146,149 ---- *************** *** 809,834 **** } - static BOOL AskOverwrite(char *filename) - { - int result; - again: - if (allow_overwrite == ALWAYS) - return TRUE; - if (allow_overwrite == NEVER) - return FALSE; - result = MessageBox(hDialog, - "Overwrite existing files?\n" - "\n" - "Press YES to ALWAYS overwrite existing files,\n" - "press NO to NEVER overwrite existing files.", - "Overwrite options", - MB_YESNO | MB_ICONQUESTION); - if (result == IDYES) - allow_overwrite = ALWAYS; - else if (result == IDNO) - allow_overwrite = NEVER; - goto again; - } - static BOOL notify (int code, char *fmt, ...) { --- 807,810 ---- *************** *** 845,849 **** /* Questions */ case CAN_OVERWRITE: - result = AskOverwrite(Buffer); break; --- 821,824 ---- From akuchling at users.sourceforge.net Wed Jul 7 14:23:56 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Wed Jul 7 14:23:59 2004 Subject: [Python-checkins] python/dist/src/Lib asyncore.py,1.53,1.54 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19653 Modified Files: asyncore.py Log Message: For readable() objects, the previous value of 'flags' was ignored. Rearrange code for writable() case to make the parallel logic clearer Index: asyncore.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/asyncore.py,v retrieving revision 1.53 retrieving revision 1.54 diff -C2 -d -r1.53 -r1.54 *** asyncore.py 30 Jun 2004 09:02:32 -0000 1.53 --- asyncore.py 7 Jul 2004 12:23:53 -0000 1.54 *************** *** 139,145 **** flags = select.POLLERR | select.POLLHUP | select.POLLNVAL if obj.readable(): ! flags = select.POLLIN | select.POLLPRI if obj.writable(): ! flags = flags | select.POLLOUT if flags: pollster.register(fd, flags) --- 139,145 ---- flags = select.POLLERR | select.POLLHUP | select.POLLNVAL if obj.readable(): ! flags |= select.POLLIN | select.POLLPRI if obj.writable(): ! flags |= select.POLLOUT if flags: pollster.register(fd, flags) From akuchling at users.sourceforge.net Wed Jul 7 15:01:58 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Wed Jul 7 15:02:02 2004 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew24.tex, 1.62, 1.63 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26017 Modified Files: whatsnew24.tex Log Message: Add logging changes Index: whatsnew24.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew24.tex,v retrieving revision 1.62 retrieving revision 1.63 diff -C2 -d -r1.62 -r1.63 *** whatsnew24.tex 5 Jul 2004 01:40:07 -0000 1.62 --- whatsnew24.tex 7 Jul 2004 13:01:53 -0000 1.63 *************** *** 783,792 **** bookmarking, windowing, or lookahead iterators. \item The \module{operator} module gained two new functions, \function{attrgetter(\var{attr})} and \function{itemgetter(\var{index})}. Both functions return callables that take a single argument and return the corresponding attribute or item; these callables make excellent ! data extractors when used with \function{map()} or \function{sorted()}. ! For example: \begin{verbatim} --- 783,813 ---- bookmarking, windowing, or lookahead iterators. + \item A \function{basicConfig} function was added to the + \module{logging} package to simplify log configuration. It defaults + to logging to standard error, but a + number of optional keyword arguments can be specified to + log to a particular file, change the logging format, or set the + logging level. For example: + + \begin{verbatim} + import logging + logging.basicConfig(filename = '/var/log/application.log', + level=0, # Log all messages, including debugging, + format='%(levelname):%(process):%(thread):%(message)') + \end{verbatim} + + Another addition to \module{logging} is a + \class{TimedRotatingFileHandler} class which rotates its log files at + a timed interval. The module already had \class{RotatingFileHandler}, + which rotated logs once the file exceeded a certain size. Both + classes derive from a new \class{BaseRotatingHandler} class that can + be used to implement other rotating handlers. + \item The \module{operator} module gained two new functions, \function{attrgetter(\var{attr})} and \function{itemgetter(\var{index})}. Both functions return callables that take a single argument and return the corresponding attribute or item; these callables make excellent ! data extractors when used with \function{map()} or ! \function{sorted()}. For example: \begin{verbatim} From akuchling at users.sourceforge.net Wed Jul 7 15:07:50 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Wed Jul 7 15:07:53 2004 Subject: [Python-checkins] python/dist/src/Doc/api abstract.tex,1.33,1.34 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/api In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27114 Modified Files: abstract.tex Log Message: [Bug #984017] Incorrect prototype, fixed by Timothy Stranex Index: abstract.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/abstract.tex,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** abstract.tex 5 Jun 2004 19:00:55 -0000 1.33 --- abstract.tex 7 Jul 2004 13:07:47 -0000 1.34 *************** *** 1000,1004 **** \begin{cfuncdesc}{int}{PyObject_AsReadBuffer}{PyObject *obj, ! const char **buffer, int *buffer_len} Returns a pointer to a read-only memory location containing --- 1000,1004 ---- \begin{cfuncdesc}{int}{PyObject_AsReadBuffer}{PyObject *obj, ! const void **buffer, int *buffer_len} Returns a pointer to a read-only memory location containing *************** *** 1018,1022 **** \begin{cfuncdesc}{int}{PyObject_AsWriteBuffer}{PyObject *obj, ! char **buffer, int *buffer_len} Returns a pointer to a writeable memory location. The \var{obj} --- 1018,1022 ---- \begin{cfuncdesc}{int}{PyObject_AsWriteBuffer}{PyObject *obj, ! void **buffer, int *buffer_len} Returns a pointer to a writeable memory location. The \var{obj} From akuchling at users.sourceforge.net Wed Jul 7 15:08:50 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Wed Jul 7 15:08:55 2004 Subject: [Python-checkins] python/dist/src/Doc/api abstract.tex, 1.26.12.6, 1.26.12.7 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/api In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27315 Modified Files: Tag: release23-maint abstract.tex Log Message: [Bug #984017] Incorrect prototype, fixed by Timothy Stranex Index: abstract.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/abstract.tex,v retrieving revision 1.26.12.6 retrieving revision 1.26.12.7 diff -C2 -d -r1.26.12.6 -r1.26.12.7 *** abstract.tex 5 Jun 2004 19:01:47 -0000 1.26.12.6 --- abstract.tex 7 Jul 2004 13:08:47 -0000 1.26.12.7 *************** *** 993,997 **** \begin{cfuncdesc}{int}{PyObject_AsReadBuffer}{PyObject *obj, ! const char **buffer, int *buffer_len} Returns a pointer to a read-only memory location containing --- 993,997 ---- \begin{cfuncdesc}{int}{PyObject_AsReadBuffer}{PyObject *obj, ! const void **buffer, int *buffer_len} Returns a pointer to a read-only memory location containing *************** *** 1011,1015 **** \begin{cfuncdesc}{int}{PyObject_AsWriteBuffer}{PyObject *obj, ! char **buffer, int *buffer_len} Returns a pointer to a writeable memory location. The \var{obj} --- 1011,1015 ---- \begin{cfuncdesc}{int}{PyObject_AsWriteBuffer}{PyObject *obj, ! void **buffer, int *buffer_len} Returns a pointer to a writeable memory location. The \var{obj} From aimacintyre at users.sourceforge.net Wed Jul 7 15:55:27 2004 From: aimacintyre at users.sourceforge.net (aimacintyre@users.sourceforge.net) Date: Wed Jul 7 15:55:32 2004 Subject: [Python-checkins] python/dist/src/PC/os2emx Makefile, 1.16, 1.17 config.c, 1.6, 1.7 Message-ID: Update of /cvsroot/python/python/dist/src/PC/os2emx In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5051 Modified Files: Makefile config.c Log Message: bring OS/2 EMX port build environment up to date Index: Makefile =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/os2emx/Makefile,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** Makefile 25 Dec 2003 13:25:20 -0000 1.16 --- Makefile 7 Jul 2004 13:55:24 -0000 1.17 *************** *** 1,15 **** #####################==================---------------- # ! # Top-Level Makefile for Building Python 2.3 for OS/2 using GCC/EMX # Originally written by Andrew Zabolotny, for Python 1.5.2 ! # Modified by Andrew MacIntyre, for Python 2.3 # # This makefile was developed for use with [P]GCC/EMX compiler any # version and GNU Make. # ! # The output of the build is a largish Python23.DLL containing the # essential modules of Python and a small Python.exe program to start # the interpreter. When embedding Python within another program, only ! # Python23.DLL is needed. We also build python_s.a static library (which # can be converted into OMF (.lib) format using emxomf tool) and both # python.a and python.lib import libraries. Then the optional --- 1,15 ---- #####################==================---------------- # ! # Top-Level Makefile for Building Python 2.4 for OS/2 using GCC/EMX # Originally written by Andrew Zabolotny, for Python 1.5.2 ! # Modified by Andrew MacIntyre, for Python 2.4 # # This makefile was developed for use with [P]GCC/EMX compiler any # version and GNU Make. # ! # The output of the build is a largish Python24.DLL containing the # essential modules of Python and a small Python.exe program to start # the interpreter. When embedding Python within another program, only ! # Python24.DLL is needed. We also build python_s.a static library (which # can be converted into OMF (.lib) format using emxomf tool) and both # python.a and python.lib import libraries. Then the optional *************** *** 65,69 **** # === install locations === # default value of PYTHONHOME ! LIB_DIR=C:/Python23 # default is to have everything in or under PYTHONHOME EXE_DIR=$(LIB_DIR) --- 65,69 ---- # === install locations === # default value of PYTHONHOME ! LIB_DIR=C:/Python24 # default is to have everything in or under PYTHONHOME EXE_DIR=$(LIB_DIR) *************** *** 221,226 **** # Output file names ! PYTHON_VER= 2.3 ! PYTHON_LIB= python23 PYTHON.LIB= $(PYTHON_LIB)_s$A PYTHON.IMPLIB= $(PYTHON_LIB)$A --- 221,226 ---- # Output file names ! PYTHON_VER= 2.4 ! PYTHON_LIB= python24 PYTHON.LIB= $(PYTHON_LIB)_s$A PYTHON.IMPLIB= $(PYTHON_LIB)$A *************** *** 273,276 **** --- 273,277 ---- Modules/cmathmodule.c \ Modules/_codecsmodule.c \ + Modules/collectionsmodule.c \ Modules/cPickle.c \ Modules/cStringIO.c \ *************** *** 280,283 **** --- 281,285 ---- Modules/errnomodule.c \ Modules/fcntlmodule.c \ + Modules/_heapqmodule.c \ Modules/imageop.c \ Modules/itertoolsmodule.c \ *************** *** 287,292 **** Modules/md5module.c \ Modules/operator.c \ - Modules/pcremodule.c \ - Modules/pypcre.c \ Modules/_randommodule.c \ Modules/regexmodule.c \ --- 289,292 ---- *************** *** 344,347 **** --- 344,348 ---- Python/pyfpe.c \ Python/pystate.c \ + Python/pystrtod.c \ Python/pythonrun.c \ Python/structmember.c \ *************** *** 367,370 **** --- 368,372 ---- Objects/frameobject.c \ Objects/funcobject.c \ + Objects/genobject.c \ Objects/intobject.c \ Objects/iterobject.c \ *************** *** 376,379 **** --- 378,382 ---- Objects/obmalloc.c \ Objects/rangeobject.c \ + Objects/setobject.c \ Objects/sliceobject.c \ Objects/stringobject.c \ *************** *** 492,496 **** rm -f $(OUT)* rm -f $(PYTHON.LIB) $(PYTHON.IMPLIB) $(PYTHON.EXEIMP) $(PYTHON.DLL) \ ! $(PYTHON.EXE) $(PYTHONPM.EXE) $(PGEN.EXE) *$(MODULE.EXT) find ../../Lib -name "*.py[co]" -exec rm {} ";" --- 495,499 ---- rm -f $(OUT)* rm -f $(PYTHON.LIB) $(PYTHON.IMPLIB) $(PYTHON.EXEIMP) $(PYTHON.DLL) \ ! $(PYTHON.EXE) $(PYTHONPM.EXE) $(PGEN.EXE) *$(MODULE.EXT) *.dll find ../../Lib -name "*.py[co]" -exec rm {} ";" Index: config.c =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/os2emx/config.c,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** config.c 9 Jun 2003 08:16:02 -0000 1.6 --- config.c 7 Jul 2004 13:55:25 -0000 1.7 *************** *** 53,56 **** --- 53,57 ---- extern void initcPickle(); extern void initcStringIO(); + extern void initcollections(); extern void initcmath(); extern void initdatetime(); *************** *** 58,61 **** --- 59,63 ---- extern void initerrno(); extern void initfcntl(); + extern void init_heapq(); extern void initimageop(); extern void inititertools(); *************** *** 63,67 **** extern void initmd5(); extern void initoperator(); - extern void initpcre(); extern void initregex(); extern void initrgbimg(); --- 65,68 ---- *************** *** 118,121 **** --- 119,123 ---- {"cPickle", initcPickle}, {"cStringIO", initcStringIO}, + {"collections", initcollections}, {"cmath", initcmath}, {"datetime", initdatetime}, *************** *** 123,126 **** --- 125,129 ---- {"errno", initerrno}, {"fcntl", initfcntl}, + {"_heapq", init_heapq}, {"imageop", initimageop}, {"itertools", inititertools}, *************** *** 128,132 **** {"md5", initmd5}, {"operator", initoperator}, - {"pcre", initpcre}, {"regex", initregex}, {"rgbimg", initrgbimg}, --- 131,134 ---- From aimacintyre at users.sourceforge.net Wed Jul 7 16:03:03 2004 From: aimacintyre at users.sourceforge.net (aimacintyre@users.sourceforge.net) Date: Wed Jul 7 16:03:06 2004 Subject: [Python-checkins] python/dist/src/Modules socketmodule.c, 1.292, 1.293 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6295 Modified Files: socketmodule.c Log Message: OS/2 EMX needs addrinfo.h for code included from getaddrinfo.c Index: socketmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/socketmodule.c,v retrieving revision 1.292 retrieving revision 1.293 diff -C2 -d -r1.292 -r1.293 *** socketmodule.c 28 Jun 2004 00:50:43 -0000 1.292 --- socketmodule.c 7 Jul 2004 14:02:59 -0000 1.293 *************** *** 280,283 **** --- 280,287 ---- #endif + #if defined(PYOS_OS2) && defined(PYCC_GCC) + #include "addrinfo.h" + #endif + #ifndef HAVE_INET_PTON int inet_pton(int af, const char *src, void *dst); From akuchling at users.sourceforge.net Wed Jul 7 16:09:24 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Wed Jul 7 16:09:27 2004 Subject: [Python-checkins] python/dist/src/Lib mailbox.py,1.41,1.42 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7754 Modified Files: mailbox.py Log Message: [Bug #925107] Make .readline() consider self.stop. This makes read() and readline() very similar, so they're refactored into _read. Patch by Johannes Gijsbers. 2.3 bugfix candidate. Index: mailbox.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/mailbox.py,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** mailbox.py 7 Feb 2004 02:16:24 -0000 1.41 --- mailbox.py 7 Jul 2004 14:09:21 -0000 1.42 *************** *** 44,69 **** self.pos = self.start ! def read(self, length = None): if self.pos >= self.stop: return '' remaining = self.stop - self.pos ! if length is None or length < 0: ! length = remaining ! elif length > remaining: length = remaining self.fp.seek(self.pos) ! data = self.fp.read(length) self.pos = self.fp.tell() return data def readline(self, length = None): ! if self.pos >= self.stop: ! return '' ! if length is None: ! length = self.stop - self.pos ! self.fp.seek(self.pos) ! data = self.fp.readline(length) ! self.pos = self.fp.tell() ! return data def readlines(self, sizehint = -1): --- 44,64 ---- self.pos = self.start ! ! def _read(self, length, read_function): if self.pos >= self.stop: return '' remaining = self.stop - self.pos ! if length is None or length < 0 or length > remaining: length = remaining self.fp.seek(self.pos) ! data = read_function(length) self.pos = self.fp.tell() return data + def read(self, length = None): + self._read(length, self.fp.read) + def readline(self, length = None): ! self._read(length, self.fp.readline) def readlines(self, sizehint = -1): From akuchling at users.sourceforge.net Wed Jul 7 16:19:12 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Wed Jul 7 16:19:15 2004 Subject: [Python-checkins] python/dist/src/Modules gdbmmodule.c,2.35,2.36 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9854 Modified Files: gdbmmodule.c Log Message: [Bug #982806] The default argument for opening GDBM files is bogus. Patch #984672 by James Lamanna Index: gdbmmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/gdbmmodule.c,v retrieving revision 2.35 retrieving revision 2.36 diff -C2 -d -r2.35 -r2.36 *** gdbmmodule.c 2 Aug 2002 02:27:13 -0000 2.35 --- gdbmmodule.c 7 Jul 2004 14:19:09 -0000 2.36 *************** *** 435,439 **** { char *name; ! char *flags = "r "; int iflags; int mode = 0666; --- 435,439 ---- { char *name; ! char *flags = "r"; int iflags; int mode = 0666; From akuchling at users.sourceforge.net Wed Jul 7 16:20:06 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Wed Jul 7 16:20:09 2004 Subject: [Python-checkins] python/dist/src/Modules gdbmmodule.c, 2.35, 2.35.14.1 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10067 Modified Files: Tag: release23-maint gdbmmodule.c Log Message: [Bug #982806] The default argument for opening GDBM files is bogus. Patch #984672 by James Lamanna Index: gdbmmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/gdbmmodule.c,v retrieving revision 2.35 retrieving revision 2.35.14.1 diff -C2 -d -r2.35 -r2.35.14.1 *** gdbmmodule.c 2 Aug 2002 02:27:13 -0000 2.35 --- gdbmmodule.c 7 Jul 2004 14:20:04 -0000 2.35.14.1 *************** *** 435,439 **** { char *name; ! char *flags = "r "; int iflags; int mode = 0666; --- 435,439 ---- { char *name; ! char *flags = "r"; int iflags; int mode = 0666; From vsajip at users.sourceforge.net Wed Jul 7 17:59:52 2004 From: vsajip at users.sourceforge.net (vsajip@users.sourceforge.net) Date: Wed Jul 7 17:59:56 2004 Subject: [Python-checkins] python/dist/src/Doc/lib liblogging.tex,1.19,1.20 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29400 Modified Files: liblogging.tex Log Message: Replaced some tabs with spaces in verbatim section. Index: liblogging.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/liblogging.tex,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** liblogging.tex 3 Jul 2004 11:45:53 -0000 1.19 --- liblogging.tex 7 Jul 2004 15:59:49 -0000 1.20 *************** *** 398,404 **** logging.basicConfig(level=logging.DEBUG, ! format='%(asctime)s %(levelname)s %(message)s', ! filename='/tmp/myapp.log', ! filemode='w') logging.debug('A debug message') logging.info('Some information') --- 398,404 ---- logging.basicConfig(level=logging.DEBUG, ! format='%(asctime)s %(levelname)s %(message)s', ! filename='/tmp/myapp.log', ! filemode='w') logging.debug('A debug message') logging.info('Some information') *************** *** 445,452 **** logging.basicConfig(level=logging.DEBUG, ! format='%(asctime)s %(levelname)-8s %(message)s', ! datefmt='%a, %d %b %Y %H:%M:%S', ! filename='/temp/myapp.log', ! filemode='w') logging.debug('A debug message') logging.info('Some information') --- 445,452 ---- logging.basicConfig(level=logging.DEBUG, ! format='%(asctime)s %(levelname)-8s %(message)s', ! datefmt='%a, %d %b %Y %H:%M:%S', ! filename='/temp/myapp.log', ! filemode='w') logging.debug('A debug message') logging.info('Some information') From mwh at users.sourceforge.net Wed Jul 7 19:44:13 2004 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Wed Jul 7 19:44:16 2004 Subject: [Python-checkins] python/dist/src/Misc ACKS,1.269,1.270 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18275/Misc Modified Files: ACKS Log Message: This closes patch: [ 960406 ] unblock signals in threads although the changes do not correspond exactly to any patch attached to that report. Non-main threads no longer have all signals masked. A different interface to readline is used. The handling of signals inside calls to PyOS_Readline is now rather different. These changes are all a bit scary! Review and cross-platform testing much appreciated. Index: ACKS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/ACKS,v retrieving revision 1.269 retrieving revision 1.270 diff -C2 -d -r1.269 -r1.270 *** ACKS 29 Jun 2004 14:03:04 -0000 1.269 --- ACKS 7 Jul 2004 17:44:10 -0000 1.270 *************** *** 328,331 **** --- 328,332 ---- Vladimir Kushnir Cameron Laird + Andrew Langmead Detlef Lannert Soren Larsen From mwh at users.sourceforge.net Wed Jul 7 19:44:13 2004 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Wed Jul 7 19:44:17 2004 Subject: [Python-checkins] python/dist/src/Modules readline.c,2.70,2.71 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18275/Modules Modified Files: readline.c Log Message: This closes patch: [ 960406 ] unblock signals in threads although the changes do not correspond exactly to any patch attached to that report. Non-main threads no longer have all signals masked. A different interface to readline is used. The handling of signals inside calls to PyOS_Readline is now rather different. These changes are all a bit scary! Review and cross-platform testing much appreciated. Index: readline.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/readline.c,v retrieving revision 2.70 retrieving revision 2.71 diff -C2 -d -r2.70 -r2.71 *** readline.c 24 May 2004 14:20:15 -0000 2.70 --- readline.c 7 Jul 2004 17:44:10 -0000 2.71 *************** *** 657,660 **** --- 657,720 ---- } + /* Wrapper around GNU readline that handles signals differently. */ + + + #if defined(HAVE_RL_CALLBACK) && defined(HAVE_SELECT) + + static char *completed_input_string; + static void + rlhandler(char *text) + { + completed_input_string = text; + rl_callback_handler_remove(); + } + + extern PyThreadState* _PyOS_ReadlineTState; + + static char * + readline_until_enter_or_signal(char *prompt, int *signal) + { + char * not_done_reading = ""; + fd_set selectset; + + *signal = 0; + #ifdef HAVE_RL_CATCH_SIGNAL + rl_catch_signals = 0; + #endif + + rl_callback_handler_install (prompt, rlhandler); + FD_ZERO(&selectset); + FD_SET(fileno(rl_instream), &selectset); + + completed_input_string = not_done_reading; + + while(completed_input_string == not_done_reading) { + int has_input; + + has_input = select(fileno(rl_instream) + 1, &selectset, + NULL, NULL, NULL); + if(has_input > 0) { + rl_callback_read_char(); + } + else if (errno == EINTR) { + int s; + PyEval_RestoreThread(_PyOS_ReadlineTState); + s = PyErr_CheckSignals(); + PyThreadState_Swap(NULL); + if (s < 0) { + rl_free_line_state(); + rl_cleanup_after_signal(); + rl_callback_handler_remove(); + *signal = 1; + completed_input_string = NULL; + } + } + } + + return completed_input_string; + } + + + #else /* Interrupt handler */ *************** *** 670,681 **** - /* Wrapper around GNU readline that handles signals differently. */ - static char * ! call_readline(FILE *sys_stdin, FILE *sys_stdout, char *prompt) { - size_t n; - char *p, *q; PyOS_sighandler_t old_inthandler; old_inthandler = PyOS_setsig(SIGINT, onintr); --- 730,740 ---- static char * ! readline_until_enter_or_signal(char *prompt, int *signal) { PyOS_sighandler_t old_inthandler; + char *p; + + *signal = 0; old_inthandler = PyOS_setsig(SIGINT, onintr); *************** *** 686,691 **** --- 745,766 ---- #endif PyOS_setsig(SIGINT, old_inthandler); + *signal = 1; return NULL; } + p = readline(prompt); + PyOS_setsig(SIGINT, old_inthandler); + + return p; + } + #endif /*defined(HAVE_RL_CALLBACK) && defined(HAVE_SELECT) */ + + + static char * + call_readline(FILE *sys_stdin, FILE *sys_stdout, char *prompt) + { + size_t n; + char *p, *q; + int signal; + rl_event_hook = PyOS_InputHook; *************** *** 698,705 **** } ! p = readline(prompt); ! PyOS_setsig(SIGINT, old_inthandler); ! /* We must return a buffer allocated with PyMem_Malloc. */ if (p == NULL) { p = PyMem_Malloc(1); --- 773,784 ---- } ! p = readline_until_enter_or_signal(prompt, &signal); ! ! /* we got an interrupt signal */ ! if(signal) { ! return NULL; ! } ! /* We got an EOF, return a empty string. */ if (p == NULL) { p = PyMem_Malloc(1); *************** *** 708,711 **** --- 787,792 ---- return p; } + + /* we have a valid line */ n = strlen(p); if (n > 0) { From mwh at users.sourceforge.net Wed Jul 7 19:44:13 2004 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Wed Jul 7 19:44:17 2004 Subject: [Python-checkins] python/dist/src configure, 1.449, 1.450 configure.in, 1.460, 1.461 pyconfig.h.in, 1.99, 1.100 Message-ID: Update of /cvsroot/python/python/dist/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18275 Modified Files: configure configure.in pyconfig.h.in Log Message: This closes patch: [ 960406 ] unblock signals in threads although the changes do not correspond exactly to any patch attached to that report. Non-main threads no longer have all signals masked. A different interface to readline is used. The handling of signals inside calls to PyOS_Readline is now rather different. These changes are all a bit scary! Review and cross-platform testing much appreciated. Index: configure =================================================================== RCS file: /cvsroot/python/python/dist/src/configure,v retrieving revision 1.449 retrieving revision 1.450 diff -C2 -d -r1.449 -r1.450 *** configure 25 Jun 2004 23:30:56 -0000 1.449 --- configure 7 Jul 2004 17:44:03 -0000 1.450 *************** *** 1,8 **** #! /bin/sh ! # From configure.in Revision: 1.459 . # Guess values for system-dependent variables and create Makefiles. ! # Generated by GNU Autoconf 2.59 for python 2.4. # ! # Copyright (C) 2003 Free Software Foundation, Inc. # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. --- 1,9 ---- #! /bin/sh [...12726 lines suppressed...] sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } *************** *** 21003,21010 **** as_dir=`(dirname "$as_dir") 2>/dev/null || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ ! X"$as_dir" : 'X\(//\)[^/]' \| \ ! X"$as_dir" : 'X\(//\)$' \| \ ! X"$as_dir" : 'X\(/\)' \| \ ! . : '\(.\)' 2>/dev/null || echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } --- 19354,19361 ---- as_dir=`(dirname "$as_dir") 2>/dev/null || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ ! X"$as_dir" : 'X\(//\)[^/]' \| \ ! X"$as_dir" : 'X\(//\)$' \| \ ! X"$as_dir" : 'X\(/\)' \| \ ! . : '\(.\)' 2>/dev/null || echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } Index: configure.in =================================================================== RCS file: /cvsroot/python/python/dist/src/configure.in,v retrieving revision 1.460 retrieving revision 1.461 diff -C2 -d -r1.460 -r1.461 *** configure.in 25 Jun 2004 23:31:05 -0000 1.460 --- configure.in 7 Jul 2004 17:44:09 -0000 1.461 *************** *** 2784,2787 **** --- 2784,2792 ---- fi + # check for readline 2.1 + AC_CHECK_LIB(readline, rl_callback_handler_install, + AC_DEFINE(HAVE_RL_CALLBACK, 1, + [Define if you have readline 2.1]), , -ltermcap) + # check for readline 2.2 AC_TRY_CPP([#include ], *************** *** 2805,2808 **** --- 2810,2824 ---- [Define if you have readline 4.2]), , -ltermcap) + # also in readline 4.2 + AC_TRY_CPP([#include ], + have_readline=yes, have_readline=no) + if test $have_readline = yes + then + AC_EGREP_HEADER([extern int rl_catch_signals;], + [readline/readline.h], + AC_DEFINE(HAVE_RL_CATCH_SIGNAL, 1, + [Define if you can turn off readline's signal handling.]), ) + fi + AC_MSG_CHECKING(for broken nice()) AC_CACHE_VAL(ac_cv_broken_nice, [ Index: pyconfig.h.in =================================================================== RCS file: /cvsroot/python/python/dist/src/pyconfig.h.in,v retrieving revision 1.99 retrieving revision 1.100 diff -C2 -d -r1.99 -r1.100 *** pyconfig.h.in 25 Jun 2004 23:31:05 -0000 1.99 --- pyconfig.h.in 7 Jul 2004 17:44:09 -0000 1.100 *************** *** 360,363 **** --- 360,369 ---- #undef HAVE_REALPATH + /* Define if you have readline 2.1 */ + #undef HAVE_RL_CALLBACK + + /* Define if you can turn off readline's signal handling. */ + #undef HAVE_RL_CATCH_SIGNAL + /* Define if you have readline 2.2 */ #undef HAVE_RL_COMPLETION_APPEND_CHARACTER From mwh at users.sourceforge.net Wed Jul 7 19:44:13 2004 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Wed Jul 7 19:44:18 2004 Subject: [Python-checkins] python/dist/src/Parser myreadline.c,2.30,2.31 Message-ID: Update of /cvsroot/python/python/dist/src/Parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18275/Parser Modified Files: myreadline.c Log Message: This closes patch: [ 960406 ] unblock signals in threads although the changes do not correspond exactly to any patch attached to that report. Non-main threads no longer have all signals masked. A different interface to readline is used. The handling of signals inside calls to PyOS_Readline is now rather different. These changes are all a bit scary! Review and cross-platform testing much appreciated. Index: myreadline.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Parser/myreadline.c,v retrieving revision 2.30 retrieving revision 2.31 diff -C2 -d -r2.30 -r2.31 *** myreadline.c 19 Nov 2003 15:24:46 -0000 2.30 --- myreadline.c 7 Jul 2004 17:44:10 -0000 2.31 *************** *** 20,23 **** --- 20,31 ---- #endif + + PyThreadState* _PyOS_ReadlineTState; + + #if WITH_THREAD + #include "pythread.h" + static PyThread_type_lock _PyOS_ReadlineLock = NULL; + #endif + int (*PyOS_InputHook)(void) = NULL; *************** *** 74,81 **** #ifdef EINTR if (errno == EINTR) { ! if (PyOS_InterruptOccurred()) { ! return 1; /* Interrupt */ } - continue; } #endif --- 82,92 ---- #ifdef EINTR if (errno == EINTR) { ! int s; ! PyEval_RestoreThread(_PyOS_ReadlineTState); ! s = PyErr_CheckSignals(); ! PyThreadState_Swap(NULL); ! if (s < 0) { ! return 1; } } #endif *************** *** 156,159 **** --- 167,177 ---- char *rv; + if (_PyOS_ReadlineTState == PyThreadState_GET()) { + PyErr_SetString(PyExc_RuntimeError, + "can't re-enter readline"); + return NULL; + } + + if (PyOS_ReadlineFunctionPointer == NULL) { #ifdef __VMS *************** *** 163,168 **** --- 181,196 ---- #endif } + + #if WITH_THREAD + if (_PyOS_ReadlineLock == NULL) { + _PyOS_ReadlineLock = PyThread_allocate_lock(); + } + #endif + _PyOS_ReadlineTState = PyThreadState_GET(); Py_BEGIN_ALLOW_THREADS + #if WITH_THREAD + PyThread_acquire_lock(_PyOS_ReadlineLock, 1); + #endif /* This is needed to handle the unlikely case that the *************** *** 177,180 **** --- 205,215 ---- prompt); Py_END_ALLOW_THREADS + + #if WITH_THREAD + PyThread_release_lock(_PyOS_ReadlineLock); + #endif + + _PyOS_ReadlineTState = NULL; + return rv; } From mwh at users.sourceforge.net Wed Jul 7 19:44:15 2004 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Wed Jul 7 19:44:20 2004 Subject: [Python-checkins] python/dist/src/Python bltinmodule.c, 2.311, 2.312 ceval.c, 2.408, 2.409 pythonrun.c, 2.205, 2.206 thread_pthread.h, 2.52, 2.53 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18275/Python Modified Files: bltinmodule.c ceval.c pythonrun.c thread_pthread.h Log Message: This closes patch: [ 960406 ] unblock signals in threads although the changes do not correspond exactly to any patch attached to that report. Non-main threads no longer have all signals masked. A different interface to readline is used. The handling of signals inside calls to PyOS_Readline is now rather different. These changes are all a bit scary! Review and cross-platform testing much appreciated. Index: bltinmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/bltinmodule.c,v retrieving revision 2.311 retrieving revision 2.312 diff -C2 -d -r2.311 -r2.312 *** bltinmodule.c 6 Jul 2004 13:44:40 -0000 2.311 --- bltinmodule.c 7 Jul 2004 17:44:11 -0000 2.312 *************** *** 1590,1594 **** Py_XDECREF(po); if (s == NULL) { ! PyErr_SetNone(PyExc_KeyboardInterrupt); return NULL; } --- 1590,1595 ---- Py_XDECREF(po); if (s == NULL) { ! if (!PyErr_Occurred()) ! PyErr_SetNone(PyExc_KeyboardInterrupt); return NULL; } Index: ceval.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/ceval.c,v retrieving revision 2.408 retrieving revision 2.409 diff -C2 -d -r2.408 -r2.409 *** ceval.c 2 Jul 2004 06:41:07 -0000 2.408 --- ceval.c 7 Jul 2004 17:44:11 -0000 2.409 *************** *** 319,323 **** Py_AddPendingCall(int (*func)(void *), void *arg) { ! static int busy = 0; int i, j; /* XXX Begin critical section */ --- 319,323 ---- Py_AddPendingCall(int (*func)(void *), void *arg) { ! static volatile int busy = 0; int i, j; /* XXX Begin critical section */ Index: pythonrun.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/pythonrun.c,v retrieving revision 2.205 retrieving revision 2.206 diff -C2 -d -r2.205 -r2.206 *** pythonrun.c 24 Mar 2004 22:22:12 -0000 2.205 --- pythonrun.c 7 Jul 2004 17:44:12 -0000 2.206 *************** *** 1436,1440 **** break; case E_INTR: ! PyErr_SetNone(PyExc_KeyboardInterrupt); Py_XDECREF(v); return; --- 1436,1441 ---- break; case E_INTR: ! if (!PyErr_Occurred()) ! PyErr_SetNone(PyExc_KeyboardInterrupt); Py_XDECREF(v); return; Index: thread_pthread.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/thread_pthread.h,v retrieving revision 2.52 retrieving revision 2.53 diff -C2 -d -r2.52 -r2.53 *** thread_pthread.h 4 Mar 2004 06:35:57 -0000 2.52 --- thread_pthread.h 7 Jul 2004 17:44:12 -0000 2.53 *************** *** 120,124 **** pthread_t th; int status; - sigset_t oldmask, newmask; #if defined(THREAD_STACK_SIZE) || defined(PTHREAD_SYSTEM_SCHED_SUPPORTED) pthread_attr_t attrs; --- 120,123 ---- *************** *** 138,148 **** #endif - /* Mask all signals in the current thread before creating the new - * thread. This causes the new thread to start with all signals - * blocked. - */ - sigfillset(&newmask); - SET_THREAD_SIGMASK(SIG_BLOCK, &newmask, &oldmask); - status = pthread_create(&th, #if defined(THREAD_STACK_SIZE) || defined(PTHREAD_SYSTEM_SCHED_SUPPORTED) --- 137,140 ---- *************** *** 155,161 **** ); - /* Restore signal mask for original thread */ - SET_THREAD_SIGMASK(SIG_SETMASK, &oldmask, NULL); - #if defined(THREAD_STACK_SIZE) || defined(PTHREAD_SYSTEM_SCHED_SUPPORTED) pthread_attr_destroy(&attrs); --- 147,150 ---- From tim_one at users.sourceforge.net Wed Jul 7 22:42:17 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Wed Jul 7 22:42:20 2004 Subject: [Python-checkins] python/dist/src/Parser myreadline.c,2.31,2.32 Message-ID: Update of /cvsroot/python/python/dist/src/Parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24618 Modified Files: myreadline.c Log Message: "#if WITH_THREAD" is incorrect; must be #ifdef instead; WITH_THREAD isn't always set to an integer value when it's defined. Index: myreadline.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Parser/myreadline.c,v retrieving revision 2.31 retrieving revision 2.32 diff -C2 -d -r2.31 -r2.32 *** myreadline.c 7 Jul 2004 17:44:10 -0000 2.31 --- myreadline.c 7 Jul 2004 20:42:07 -0000 2.32 *************** *** 23,27 **** PyThreadState* _PyOS_ReadlineTState; ! #if WITH_THREAD #include "pythread.h" static PyThread_type_lock _PyOS_ReadlineLock = NULL; --- 23,27 ---- PyThreadState* _PyOS_ReadlineTState; ! #ifdef WITH_THREAD #include "pythread.h" static PyThread_type_lock _PyOS_ReadlineLock = NULL; *************** *** 182,186 **** } ! #if WITH_THREAD if (_PyOS_ReadlineLock == NULL) { _PyOS_ReadlineLock = PyThread_allocate_lock(); --- 182,186 ---- } ! #ifdef WITH_THREAD if (_PyOS_ReadlineLock == NULL) { _PyOS_ReadlineLock = PyThread_allocate_lock(); *************** *** 190,194 **** _PyOS_ReadlineTState = PyThreadState_GET(); Py_BEGIN_ALLOW_THREADS ! #if WITH_THREAD PyThread_acquire_lock(_PyOS_ReadlineLock, 1); #endif --- 190,194 ---- _PyOS_ReadlineTState = PyThreadState_GET(); Py_BEGIN_ALLOW_THREADS ! #ifdef WITH_THREAD PyThread_acquire_lock(_PyOS_ReadlineLock, 1); #endif *************** *** 206,210 **** Py_END_ALLOW_THREADS ! #if WITH_THREAD PyThread_release_lock(_PyOS_ReadlineLock); #endif --- 206,210 ---- Py_END_ALLOW_THREADS ! #ifdef WITH_THREAD PyThread_release_lock(_PyOS_ReadlineLock); #endif From tim_one at users.sourceforge.net Wed Jul 7 22:54:49 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Wed Jul 7 22:54:53 2004 Subject: [Python-checkins] python/dist/src/Lib/compiler pycodegen.py, 1.67, 1.68 symbols.py, 1.14, 1.15 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/compiler In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28101/Lib/compiler Modified Files: pycodegen.py symbols.py Log Message: Whitespace normalization. Index: pycodegen.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/compiler/pycodegen.py,v retrieving revision 1.67 retrieving revision 1.68 diff -C2 -d -r1.67 -r1.68 *** pycodegen.py 19 May 2004 08:20:07 -0000 1.67 --- pycodegen.py 7 Jul 2004 20:54:46 -0000 1.68 *************** *** 672,676 **** start = self.newBlock() anchor = self.newBlock() ! if node.is_outmost: self.loadName('[outmost-iterable]') --- 672,676 ---- start = self.newBlock() anchor = self.newBlock() ! if node.is_outmost: self.loadName('[outmost-iterable]') Index: symbols.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/compiler/symbols.py,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** symbols.py 19 May 2004 08:20:08 -0000 1.14 --- symbols.py 7 Jul 2004 20:54:47 -0000 1.15 *************** *** 261,271 **** def visitGenExprIf(self, node, scope): self.visit(node.test, scope) ! def visitLambda(self, node, parent, assign=0): # Lambda is an expression, so it could appear in an expression # context where assign is passed. The transformer should catch # any code that has a lambda on the left-hand side. ! assert not assign ! for n in node.defaults: self.visit(n, parent) --- 261,271 ---- def visitGenExprIf(self, node, scope): self.visit(node.test, scope) ! def visitLambda(self, node, parent, assign=0): # Lambda is an expression, so it could appear in an expression # context where assign is passed. The transformer should catch # any code that has a lambda on the left-hand side. ! assert not assign ! for n in node.defaults: self.visit(n, parent) From tim_one at users.sourceforge.net Wed Jul 7 22:54:50 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Wed Jul 7 22:54:55 2004 Subject: [Python-checkins] python/dist/src/Lib/logging __init__.py, 1.15, 1.16 handlers.py, 1.13, 1.14 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/logging In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28101/Lib/logging Modified Files: __init__.py handlers.py Log Message: Whitespace normalization. Index: __init__.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/logging/__init__.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** __init__.py 3 Jul 2004 11:47:26 -0000 1.15 --- __init__.py 7 Jul 2004 20:54:47 -0000 1.16 *************** *** 1163,1167 **** level = kwargs.get("level") if level: ! root.setLevel(level) #--------------------------------------------------------------------------- --- 1163,1167 ---- level = kwargs.get("level") if level: ! root.setLevel(level) #--------------------------------------------------------------------------- Index: handlers.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/logging/handlers.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** handlers.py 3 Jul 2004 11:48:34 -0000 1.13 --- handlers.py 7 Jul 2004 20:54:48 -0000 1.14 *************** *** 316,322 **** # we've waited long enough. if self.retryTime is None: ! attempt = 1 else: ! attempt = (now >= self.retryTime) if attempt: try: --- 316,322 ---- # we've waited long enough. if self.retryTime is None: ! attempt = 1 else: ! attempt = (now >= self.retryTime) if attempt: try: *************** *** 367,375 **** ei = record.exc_info if ei: ! dummy = self.format(record) # just to get traceback text into record.exc_text ! record.exc_info = None # to avoid Unpickleable error s = cPickle.dumps(record.__dict__, 1) if ei: ! record.exc_info = ei # for next handler slen = struct.pack(">L", len(s)) return slen + s --- 367,375 ---- ei = record.exc_info if ei: ! dummy = self.format(record) # just to get traceback text into record.exc_text ! record.exc_info = None # to avoid Unpickleable error s = cPickle.dumps(record.__dict__, 1) if ei: ! record.exc_info = ei # for next handler slen = struct.pack(">L", len(s)) return slen + s From tim_one at users.sourceforge.net Wed Jul 7 22:54:52 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Wed Jul 7 22:54:56 2004 Subject: [Python-checkins] python/dist/src/Lib/encodings big5.py, 1.1, 1.2 cp932.py, 1.1, 1.2 cp949.py, 1.1, 1.2 cp950.py, 1.1, 1.2 euc_jisx0213.py, 1.1, 1.2 euc_jp.py, 1.1, 1.2 euc_kr.py, 1.1, 1.2 gb18030.py, 1.1, 1.2 gb2312.py, 1.1, 1.2 gbk.py, 1.1, 1.2 hz.py, 1.1, 1.2 iso2022_jp.py, 1.1, 1.2 iso2022_jp_1.py, 1.1, 1.2 iso2022_jp_2.py, 1.1, 1.2 iso2022_jp_3.py, 1.1, 1.2 iso2022_jp_ext.py, 1.1, 1.2 iso2022_kr.py, 1.1, 1.2 johab.py, 1.1, 1.2 ptcp154.py, 1.1, 1.2 shift_jis.py, 1.1, 1.2 shift_jisx0213.py, 1.1, 1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/encodings In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28101/Lib/encodings Modified Files: big5.py cp932.py cp949.py cp950.py euc_jisx0213.py euc_jp.py euc_kr.py gb18030.py gb2312.py gbk.py hz.py iso2022_jp.py iso2022_jp_1.py iso2022_jp_2.py iso2022_jp_3.py iso2022_jp_ext.py iso2022_kr.py johab.py ptcp154.py shift_jis.py shift_jisx0213.py Log Message: Whitespace normalization. Index: big5.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/encodings/big5.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** big5.py 17 Jan 2004 14:29:28 -0000 1.1 --- big5.py 7 Jul 2004 20:54:47 -0000 1.2 *************** *** 32,34 **** def getregentry(): return (Codec().encode,Codec().decode,StreamReader,StreamWriter) - --- 32,33 ---- Index: cp932.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/encodings/cp932.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** cp932.py 17 Jan 2004 14:29:28 -0000 1.1 --- cp932.py 7 Jul 2004 20:54:47 -0000 1.2 *************** *** 32,34 **** def getregentry(): return (Codec().encode,Codec().decode,StreamReader,StreamWriter) - --- 32,33 ---- Index: cp949.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/encodings/cp949.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** cp949.py 17 Jan 2004 14:29:28 -0000 1.1 --- cp949.py 7 Jul 2004 20:54:47 -0000 1.2 *************** *** 32,34 **** def getregentry(): return (Codec().encode,Codec().decode,StreamReader,StreamWriter) - --- 32,33 ---- Index: cp950.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/encodings/cp950.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** cp950.py 17 Jan 2004 14:29:28 -0000 1.1 --- cp950.py 7 Jul 2004 20:54:47 -0000 1.2 *************** *** 32,34 **** def getregentry(): return (Codec().encode,Codec().decode,StreamReader,StreamWriter) - --- 32,33 ---- Index: euc_jisx0213.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/encodings/euc_jisx0213.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** euc_jisx0213.py 17 Jan 2004 14:29:28 -0000 1.1 --- euc_jisx0213.py 7 Jul 2004 20:54:47 -0000 1.2 *************** *** 32,34 **** def getregentry(): return (Codec().encode,Codec().decode,StreamReader,StreamWriter) - --- 32,33 ---- Index: euc_jp.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/encodings/euc_jp.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** euc_jp.py 17 Jan 2004 14:29:28 -0000 1.1 --- euc_jp.py 7 Jul 2004 20:54:47 -0000 1.2 *************** *** 32,34 **** def getregentry(): return (Codec().encode,Codec().decode,StreamReader,StreamWriter) - --- 32,33 ---- Index: euc_kr.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/encodings/euc_kr.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** euc_kr.py 17 Jan 2004 14:29:28 -0000 1.1 --- euc_kr.py 7 Jul 2004 20:54:47 -0000 1.2 *************** *** 32,34 **** def getregentry(): return (Codec().encode,Codec().decode,StreamReader,StreamWriter) - --- 32,33 ---- Index: gb18030.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/encodings/gb18030.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** gb18030.py 17 Jan 2004 14:29:28 -0000 1.1 --- gb18030.py 7 Jul 2004 20:54:47 -0000 1.2 *************** *** 32,34 **** def getregentry(): return (Codec().encode,Codec().decode,StreamReader,StreamWriter) - --- 32,33 ---- Index: gb2312.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/encodings/gb2312.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** gb2312.py 17 Jan 2004 14:29:28 -0000 1.1 --- gb2312.py 7 Jul 2004 20:54:47 -0000 1.2 *************** *** 32,34 **** def getregentry(): return (Codec().encode,Codec().decode,StreamReader,StreamWriter) - --- 32,33 ---- Index: gbk.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/encodings/gbk.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** gbk.py 17 Jan 2004 14:29:28 -0000 1.1 --- gbk.py 7 Jul 2004 20:54:47 -0000 1.2 *************** *** 32,34 **** def getregentry(): return (Codec().encode,Codec().decode,StreamReader,StreamWriter) - --- 32,33 ---- Index: hz.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/encodings/hz.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** hz.py 17 Jan 2004 14:29:28 -0000 1.1 --- hz.py 7 Jul 2004 20:54:47 -0000 1.2 *************** *** 32,34 **** def getregentry(): return (Codec().encode,Codec().decode,StreamReader,StreamWriter) - --- 32,33 ---- Index: iso2022_jp.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/encodings/iso2022_jp.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** iso2022_jp.py 17 Jan 2004 14:29:28 -0000 1.1 --- iso2022_jp.py 7 Jul 2004 20:54:47 -0000 1.2 *************** *** 32,34 **** def getregentry(): return (Codec().encode,Codec().decode,StreamReader,StreamWriter) - --- 32,33 ---- Index: iso2022_jp_1.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/encodings/iso2022_jp_1.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** iso2022_jp_1.py 17 Jan 2004 14:29:28 -0000 1.1 --- iso2022_jp_1.py 7 Jul 2004 20:54:47 -0000 1.2 *************** *** 32,34 **** def getregentry(): return (Codec().encode,Codec().decode,StreamReader,StreamWriter) - --- 32,33 ---- Index: iso2022_jp_2.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/encodings/iso2022_jp_2.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** iso2022_jp_2.py 17 Jan 2004 14:29:28 -0000 1.1 --- iso2022_jp_2.py 7 Jul 2004 20:54:47 -0000 1.2 *************** *** 32,34 **** def getregentry(): return (Codec().encode,Codec().decode,StreamReader,StreamWriter) - --- 32,33 ---- Index: iso2022_jp_3.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/encodings/iso2022_jp_3.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** iso2022_jp_3.py 17 Jan 2004 14:29:28 -0000 1.1 --- iso2022_jp_3.py 7 Jul 2004 20:54:47 -0000 1.2 *************** *** 32,34 **** def getregentry(): return (Codec().encode,Codec().decode,StreamReader,StreamWriter) - --- 32,33 ---- Index: iso2022_jp_ext.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/encodings/iso2022_jp_ext.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** iso2022_jp_ext.py 17 Jan 2004 14:29:28 -0000 1.1 --- iso2022_jp_ext.py 7 Jul 2004 20:54:47 -0000 1.2 *************** *** 32,34 **** def getregentry(): return (Codec().encode,Codec().decode,StreamReader,StreamWriter) - --- 32,33 ---- Index: iso2022_kr.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/encodings/iso2022_kr.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** iso2022_kr.py 17 Jan 2004 14:29:28 -0000 1.1 --- iso2022_kr.py 7 Jul 2004 20:54:47 -0000 1.2 *************** *** 32,34 **** def getregentry(): return (Codec().encode,Codec().decode,StreamReader,StreamWriter) - --- 32,33 ---- Index: johab.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/encodings/johab.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** johab.py 17 Jan 2004 14:29:28 -0000 1.1 --- johab.py 7 Jul 2004 20:54:47 -0000 1.2 *************** *** 32,34 **** def getregentry(): return (Codec().encode,Codec().decode,StreamReader,StreamWriter) - --- 32,33 ---- Index: ptcp154.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/encodings/ptcp154.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ptcp154.py 19 Mar 2004 08:06:07 -0000 1.1 --- ptcp154.py 7 Jul 2004 20:54:47 -0000 1.2 *************** *** 38,159 **** decoding_map = codecs.make_identity_dict(range(256)) decoding_map.update({ ! 0x0080: 0x0496, # CYRILLIC CAPITAL LETTER ZHE WITH DESCENDER ! 0x0081: 0x0492, # CYRILLIC CAPITAL LETTER GHE WITH STROKE ! 0x0082: 0x04ee, # CYRILLIC CAPITAL LETTER U WITH MACRON ! 0x0083: 0x0493, # CYRILLIC SMALL LETTER GHE WITH STROKE ! 0x0084: 0x201e, # DOUBLE LOW-9 QUOTATION MARK ! 0x0085: 0x2026, # HORIZONTAL ELLIPSIS ! 0x0086: 0x04b6, # CYRILLIC CAPITAL LETTER CHE WITH DESCENDER ! 0x0087: 0x04ae, # CYRILLIC CAPITAL LETTER STRAIGHT U ! 0x0088: 0x04b2, # CYRILLIC CAPITAL LETTER HA WITH DESCENDER ! 0x0089: 0x04af, # CYRILLIC SMALL LETTER STRAIGHT U ! 0x008a: 0x04a0, # CYRILLIC CAPITAL LETTER BASHKIR KA ! 0x008b: 0x04e2, # CYRILLIC CAPITAL LETTER I WITH MACRON ! 0x008c: 0x04a2, # CYRILLIC CAPITAL LETTER EN WITH DESCENDER ! 0x008d: 0x049a, # CYRILLIC CAPITAL LETTER KA WITH DESCENDER ! 0x008e: 0x04ba, # CYRILLIC CAPITAL LETTER SHHA ! 0x008f: 0x04b8, # CYRILLIC CAPITAL LETTER CHE WITH VERTICAL STROKE ! 0x0090: 0x0497, # CYRILLIC SMALL LETTER ZHE WITH DESCENDER ! 0x0091: 0x2018, # LEFT SINGLE QUOTATION MARK ! 0x0092: 0x2019, # RIGHT SINGLE QUOTATION MARK ! 0x0093: 0x201c, # LEFT DOUBLE QUOTATION MARK ! 0x0094: 0x201d, # RIGHT DOUBLE QUOTATION MARK ! 0x0095: 0x2022, # BULLET ! 0x0096: 0x2013, # EN DASH ! 0x0097: 0x2014, # EM DASH ! 0x0098: 0x04b3, # CYRILLIC SMALL LETTER HA WITH DESCENDER ! 0x0099: 0x04b7, # CYRILLIC SMALL LETTER CHE WITH DESCENDER ! 0x009a: 0x04a1, # CYRILLIC SMALL LETTER BASHKIR KA ! 0x009b: 0x04e3, # CYRILLIC SMALL LETTER I WITH MACRON ! 0x009c: 0x04a3, # CYRILLIC SMALL LETTER EN WITH DESCENDER ! 0x009d: 0x049b, # CYRILLIC SMALL LETTER KA WITH DESCENDER ! 0x009e: 0x04bb, # CYRILLIC SMALL LETTER SHHA ! 0x009f: 0x04b9, # CYRILLIC SMALL LETTER CHE WITH VERTICAL STROKE ! 0x00a1: 0x040e, # CYRILLIC CAPITAL LETTER SHORT U (Byelorussian) ! 0x00a2: 0x045e, # CYRILLIC SMALL LETTER SHORT U (Byelorussian) ! 0x00a3: 0x0408, # CYRILLIC CAPITAL LETTER JE ! 0x00a4: 0x04e8, # CYRILLIC CAPITAL LETTER BARRED O ! 0x00a5: 0x0498, # CYRILLIC CAPITAL LETTER ZE WITH DESCENDER ! 0x00a6: 0x04b0, # CYRILLIC CAPITAL LETTER STRAIGHT U WITH STROKE ! 0x00a8: 0x0401, # CYRILLIC CAPITAL LETTER IO ! 0x00aa: 0x04d8, # CYRILLIC CAPITAL LETTER SCHWA ! 0x00ad: 0x04ef, # CYRILLIC SMALL LETTER U WITH MACRON ! 0x00af: 0x049c, # CYRILLIC CAPITAL LETTER KA WITH VERTICAL STROKE ! 0x00b1: 0x04b1, # CYRILLIC SMALL LETTER STRAIGHT U WITH STROKE ! 0x00b2: 0x0406, # CYRILLIC CAPITAL LETTER BYELORUSSIAN-UKRAINIAN I ! 0x00b3: 0x0456, # CYRILLIC SMALL LETTER BYELORUSSIAN-UKRAINIAN I ! 0x00b4: 0x0499, # CYRILLIC SMALL LETTER ZE WITH DESCENDER ! 0x00b5: 0x04e9, # CYRILLIC SMALL LETTER BARRED O ! 0x00b8: 0x0451, # CYRILLIC SMALL LETTER IO ! 0x00b9: 0x2116, # NUMERO SIGN ! 0x00ba: 0x04d9, # CYRILLIC SMALL LETTER SCHWA ! 0x00bc: 0x0458, # CYRILLIC SMALL LETTER JE ! 0x00bd: 0x04aa, # CYRILLIC CAPITAL LETTER ES WITH DESCENDER ! 0x00be: 0x04ab, # CYRILLIC SMALL LETTER ES WITH DESCENDER ! 0x00bf: 0x049d, # CYRILLIC SMALL LETTER KA WITH VERTICAL STROKE ! 0x00c0: 0x0410, # CYRILLIC CAPITAL LETTER A ! 0x00c1: 0x0411, # CYRILLIC CAPITAL LETTER BE ! 0x00c2: 0x0412, # CYRILLIC CAPITAL LETTER VE ! 0x00c3: 0x0413, # CYRILLIC CAPITAL LETTER GHE ! 0x00c4: 0x0414, # CYRILLIC CAPITAL LETTER DE ! 0x00c5: 0x0415, # CYRILLIC CAPITAL LETTER IE ! 0x00c6: 0x0416, # CYRILLIC CAPITAL LETTER ZHE ! 0x00c7: 0x0417, # CYRILLIC CAPITAL LETTER ZE ! 0x00c8: 0x0418, # CYRILLIC CAPITAL LETTER I ! 0x00c9: 0x0419, # CYRILLIC CAPITAL LETTER SHORT I ! 0x00ca: 0x041a, # CYRILLIC CAPITAL LETTER KA ! 0x00cb: 0x041b, # CYRILLIC CAPITAL LETTER EL ! 0x00cc: 0x041c, # CYRILLIC CAPITAL LETTER EM ! 0x00cd: 0x041d, # CYRILLIC CAPITAL LETTER EN ! 0x00ce: 0x041e, # CYRILLIC CAPITAL LETTER O ! 0x00cf: 0x041f, # CYRILLIC CAPITAL LETTER PE ! 0x00d0: 0x0420, # CYRILLIC CAPITAL LETTER ER ! 0x00d1: 0x0421, # CYRILLIC CAPITAL LETTER ES ! 0x00d2: 0x0422, # CYRILLIC CAPITAL LETTER TE ! 0x00d3: 0x0423, # CYRILLIC CAPITAL LETTER U ! 0x00d4: 0x0424, # CYRILLIC CAPITAL LETTER EF ! 0x00d5: 0x0425, # CYRILLIC CAPITAL LETTER HA ! 0x00d6: 0x0426, # CYRILLIC CAPITAL LETTER TSE ! 0x00d7: 0x0427, # CYRILLIC CAPITAL LETTER CHE ! 0x00d8: 0x0428, # CYRILLIC CAPITAL LETTER SHA ! 0x00d9: 0x0429, # CYRILLIC CAPITAL LETTER SHCHA ! 0x00da: 0x042a, # CYRILLIC CAPITAL LETTER HARD SIGN ! 0x00db: 0x042b, # CYRILLIC CAPITAL LETTER YERU ! 0x00dc: 0x042c, # CYRILLIC CAPITAL LETTER SOFT SIGN ! 0x00dd: 0x042d, # CYRILLIC CAPITAL LETTER E ! 0x00de: 0x042e, # CYRILLIC CAPITAL LETTER YU ! 0x00df: 0x042f, # CYRILLIC CAPITAL LETTER YA ! 0x00e0: 0x0430, # CYRILLIC SMALL LETTER A ! 0x00e1: 0x0431, # CYRILLIC SMALL LETTER BE ! 0x00e2: 0x0432, # CYRILLIC SMALL LETTER VE ! 0x00e3: 0x0433, # CYRILLIC SMALL LETTER GHE ! 0x00e4: 0x0434, # CYRILLIC SMALL LETTER DE ! 0x00e5: 0x0435, # CYRILLIC SMALL LETTER IE ! 0x00e6: 0x0436, # CYRILLIC SMALL LETTER ZHE ! 0x00e7: 0x0437, # CYRILLIC SMALL LETTER ZE ! 0x00e8: 0x0438, # CYRILLIC SMALL LETTER I ! 0x00e9: 0x0439, # CYRILLIC SMALL LETTER SHORT I ! 0x00ea: 0x043a, # CYRILLIC SMALL LETTER KA ! 0x00eb: 0x043b, # CYRILLIC SMALL LETTER EL ! 0x00ec: 0x043c, # CYRILLIC SMALL LETTER EM ! 0x00ed: 0x043d, # CYRILLIC SMALL LETTER EN ! 0x00ee: 0x043e, # CYRILLIC SMALL LETTER O ! 0x00ef: 0x043f, # CYRILLIC SMALL LETTER PE ! 0x00f0: 0x0440, # CYRILLIC SMALL LETTER ER ! 0x00f1: 0x0441, # CYRILLIC SMALL LETTER ES ! 0x00f2: 0x0442, # CYRILLIC SMALL LETTER TE ! 0x00f3: 0x0443, # CYRILLIC SMALL LETTER U ! 0x00f4: 0x0444, # CYRILLIC SMALL LETTER EF ! 0x00f5: 0x0445, # CYRILLIC SMALL LETTER HA ! 0x00f6: 0x0446, # CYRILLIC SMALL LETTER TSE ! 0x00f7: 0x0447, # CYRILLIC SMALL LETTER CHE ! 0x00f8: 0x0448, # CYRILLIC SMALL LETTER SHA ! 0x00f9: 0x0449, # CYRILLIC SMALL LETTER SHCHA ! 0x00fa: 0x044a, # CYRILLIC SMALL LETTER HARD SIGN ! 0x00fb: 0x044b, # CYRILLIC SMALL LETTER YERU ! 0x00fc: 0x044c, # CYRILLIC SMALL LETTER SOFT SIGN ! 0x00fd: 0x044d, # CYRILLIC SMALL LETTER E ! 0x00fe: 0x044e, # CYRILLIC SMALL LETTER YU ! 0x00ff: 0x044f, # CYRILLIC SMALL LETTER YA }) --- 38,159 ---- decoding_map = codecs.make_identity_dict(range(256)) decoding_map.update({ ! 0x0080: 0x0496, # CYRILLIC CAPITAL LETTER ZHE WITH DESCENDER ! 0x0081: 0x0492, # CYRILLIC CAPITAL LETTER GHE WITH STROKE ! 0x0082: 0x04ee, # CYRILLIC CAPITAL LETTER U WITH MACRON ! 0x0083: 0x0493, # CYRILLIC SMALL LETTER GHE WITH STROKE ! 0x0084: 0x201e, # DOUBLE LOW-9 QUOTATION MARK ! 0x0085: 0x2026, # HORIZONTAL ELLIPSIS ! 0x0086: 0x04b6, # CYRILLIC CAPITAL LETTER CHE WITH DESCENDER ! 0x0087: 0x04ae, # CYRILLIC CAPITAL LETTER STRAIGHT U ! 0x0088: 0x04b2, # CYRILLIC CAPITAL LETTER HA WITH DESCENDER ! 0x0089: 0x04af, # CYRILLIC SMALL LETTER STRAIGHT U ! 0x008a: 0x04a0, # CYRILLIC CAPITAL LETTER BASHKIR KA ! 0x008b: 0x04e2, # CYRILLIC CAPITAL LETTER I WITH MACRON ! 0x008c: 0x04a2, # CYRILLIC CAPITAL LETTER EN WITH DESCENDER ! 0x008d: 0x049a, # CYRILLIC CAPITAL LETTER KA WITH DESCENDER ! 0x008e: 0x04ba, # CYRILLIC CAPITAL LETTER SHHA ! 0x008f: 0x04b8, # CYRILLIC CAPITAL LETTER CHE WITH VERTICAL STROKE ! 0x0090: 0x0497, # CYRILLIC SMALL LETTER ZHE WITH DESCENDER ! 0x0091: 0x2018, # LEFT SINGLE QUOTATION MARK ! 0x0092: 0x2019, # RIGHT SINGLE QUOTATION MARK ! 0x0093: 0x201c, # LEFT DOUBLE QUOTATION MARK ! 0x0094: 0x201d, # RIGHT DOUBLE QUOTATION MARK ! 0x0095: 0x2022, # BULLET ! 0x0096: 0x2013, # EN DASH ! 0x0097: 0x2014, # EM DASH ! 0x0098: 0x04b3, # CYRILLIC SMALL LETTER HA WITH DESCENDER ! 0x0099: 0x04b7, # CYRILLIC SMALL LETTER CHE WITH DESCENDER ! 0x009a: 0x04a1, # CYRILLIC SMALL LETTER BASHKIR KA ! 0x009b: 0x04e3, # CYRILLIC SMALL LETTER I WITH MACRON ! 0x009c: 0x04a3, # CYRILLIC SMALL LETTER EN WITH DESCENDER ! 0x009d: 0x049b, # CYRILLIC SMALL LETTER KA WITH DESCENDER ! 0x009e: 0x04bb, # CYRILLIC SMALL LETTER SHHA ! 0x009f: 0x04b9, # CYRILLIC SMALL LETTER CHE WITH VERTICAL STROKE ! 0x00a1: 0x040e, # CYRILLIC CAPITAL LETTER SHORT U (Byelorussian) ! 0x00a2: 0x045e, # CYRILLIC SMALL LETTER SHORT U (Byelorussian) ! 0x00a3: 0x0408, # CYRILLIC CAPITAL LETTER JE ! 0x00a4: 0x04e8, # CYRILLIC CAPITAL LETTER BARRED O ! 0x00a5: 0x0498, # CYRILLIC CAPITAL LETTER ZE WITH DESCENDER ! 0x00a6: 0x04b0, # CYRILLIC CAPITAL LETTER STRAIGHT U WITH STROKE ! 0x00a8: 0x0401, # CYRILLIC CAPITAL LETTER IO ! 0x00aa: 0x04d8, # CYRILLIC CAPITAL LETTER SCHWA ! 0x00ad: 0x04ef, # CYRILLIC SMALL LETTER U WITH MACRON ! 0x00af: 0x049c, # CYRILLIC CAPITAL LETTER KA WITH VERTICAL STROKE ! 0x00b1: 0x04b1, # CYRILLIC SMALL LETTER STRAIGHT U WITH STROKE ! 0x00b2: 0x0406, # CYRILLIC CAPITAL LETTER BYELORUSSIAN-UKRAINIAN I ! 0x00b3: 0x0456, # CYRILLIC SMALL LETTER BYELORUSSIAN-UKRAINIAN I ! 0x00b4: 0x0499, # CYRILLIC SMALL LETTER ZE WITH DESCENDER ! 0x00b5: 0x04e9, # CYRILLIC SMALL LETTER BARRED O ! 0x00b8: 0x0451, # CYRILLIC SMALL LETTER IO ! 0x00b9: 0x2116, # NUMERO SIGN ! 0x00ba: 0x04d9, # CYRILLIC SMALL LETTER SCHWA ! 0x00bc: 0x0458, # CYRILLIC SMALL LETTER JE ! 0x00bd: 0x04aa, # CYRILLIC CAPITAL LETTER ES WITH DESCENDER ! 0x00be: 0x04ab, # CYRILLIC SMALL LETTER ES WITH DESCENDER ! 0x00bf: 0x049d, # CYRILLIC SMALL LETTER KA WITH VERTICAL STROKE ! 0x00c0: 0x0410, # CYRILLIC CAPITAL LETTER A ! 0x00c1: 0x0411, # CYRILLIC CAPITAL LETTER BE ! 0x00c2: 0x0412, # CYRILLIC CAPITAL LETTER VE ! 0x00c3: 0x0413, # CYRILLIC CAPITAL LETTER GHE ! 0x00c4: 0x0414, # CYRILLIC CAPITAL LETTER DE ! 0x00c5: 0x0415, # CYRILLIC CAPITAL LETTER IE ! 0x00c6: 0x0416, # CYRILLIC CAPITAL LETTER ZHE ! 0x00c7: 0x0417, # CYRILLIC CAPITAL LETTER ZE ! 0x00c8: 0x0418, # CYRILLIC CAPITAL LETTER I ! 0x00c9: 0x0419, # CYRILLIC CAPITAL LETTER SHORT I ! 0x00ca: 0x041a, # CYRILLIC CAPITAL LETTER KA ! 0x00cb: 0x041b, # CYRILLIC CAPITAL LETTER EL ! 0x00cc: 0x041c, # CYRILLIC CAPITAL LETTER EM ! 0x00cd: 0x041d, # CYRILLIC CAPITAL LETTER EN ! 0x00ce: 0x041e, # CYRILLIC CAPITAL LETTER O ! 0x00cf: 0x041f, # CYRILLIC CAPITAL LETTER PE ! 0x00d0: 0x0420, # CYRILLIC CAPITAL LETTER ER ! 0x00d1: 0x0421, # CYRILLIC CAPITAL LETTER ES ! 0x00d2: 0x0422, # CYRILLIC CAPITAL LETTER TE ! 0x00d3: 0x0423, # CYRILLIC CAPITAL LETTER U ! 0x00d4: 0x0424, # CYRILLIC CAPITAL LETTER EF ! 0x00d5: 0x0425, # CYRILLIC CAPITAL LETTER HA ! 0x00d6: 0x0426, # CYRILLIC CAPITAL LETTER TSE ! 0x00d7: 0x0427, # CYRILLIC CAPITAL LETTER CHE ! 0x00d8: 0x0428, # CYRILLIC CAPITAL LETTER SHA ! 0x00d9: 0x0429, # CYRILLIC CAPITAL LETTER SHCHA ! 0x00da: 0x042a, # CYRILLIC CAPITAL LETTER HARD SIGN ! 0x00db: 0x042b, # CYRILLIC CAPITAL LETTER YERU ! 0x00dc: 0x042c, # CYRILLIC CAPITAL LETTER SOFT SIGN ! 0x00dd: 0x042d, # CYRILLIC CAPITAL LETTER E ! 0x00de: 0x042e, # CYRILLIC CAPITAL LETTER YU ! 0x00df: 0x042f, # CYRILLIC CAPITAL LETTER YA ! 0x00e0: 0x0430, # CYRILLIC SMALL LETTER A ! 0x00e1: 0x0431, # CYRILLIC SMALL LETTER BE ! 0x00e2: 0x0432, # CYRILLIC SMALL LETTER VE ! 0x00e3: 0x0433, # CYRILLIC SMALL LETTER GHE ! 0x00e4: 0x0434, # CYRILLIC SMALL LETTER DE ! 0x00e5: 0x0435, # CYRILLIC SMALL LETTER IE ! 0x00e6: 0x0436, # CYRILLIC SMALL LETTER ZHE ! 0x00e7: 0x0437, # CYRILLIC SMALL LETTER ZE ! 0x00e8: 0x0438, # CYRILLIC SMALL LETTER I ! 0x00e9: 0x0439, # CYRILLIC SMALL LETTER SHORT I ! 0x00ea: 0x043a, # CYRILLIC SMALL LETTER KA ! 0x00eb: 0x043b, # CYRILLIC SMALL LETTER EL ! 0x00ec: 0x043c, # CYRILLIC SMALL LETTER EM ! 0x00ed: 0x043d, # CYRILLIC SMALL LETTER EN ! 0x00ee: 0x043e, # CYRILLIC SMALL LETTER O ! 0x00ef: 0x043f, # CYRILLIC SMALL LETTER PE ! 0x00f0: 0x0440, # CYRILLIC SMALL LETTER ER ! 0x00f1: 0x0441, # CYRILLIC SMALL LETTER ES ! 0x00f2: 0x0442, # CYRILLIC SMALL LETTER TE ! 0x00f3: 0x0443, # CYRILLIC SMALL LETTER U ! 0x00f4: 0x0444, # CYRILLIC SMALL LETTER EF ! 0x00f5: 0x0445, # CYRILLIC SMALL LETTER HA ! 0x00f6: 0x0446, # CYRILLIC SMALL LETTER TSE ! 0x00f7: 0x0447, # CYRILLIC SMALL LETTER CHE ! 0x00f8: 0x0448, # CYRILLIC SMALL LETTER SHA ! 0x00f9: 0x0449, # CYRILLIC SMALL LETTER SHCHA ! 0x00fa: 0x044a, # CYRILLIC SMALL LETTER HARD SIGN ! 0x00fb: 0x044b, # CYRILLIC SMALL LETTER YERU ! 0x00fc: 0x044c, # CYRILLIC SMALL LETTER SOFT SIGN ! 0x00fd: 0x044d, # CYRILLIC SMALL LETTER E ! 0x00fe: 0x044e, # CYRILLIC SMALL LETTER YU ! 0x00ff: 0x044f, # CYRILLIC SMALL LETTER YA }) Index: shift_jis.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/encodings/shift_jis.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** shift_jis.py 17 Jan 2004 14:29:28 -0000 1.1 --- shift_jis.py 7 Jul 2004 20:54:47 -0000 1.2 *************** *** 32,34 **** def getregentry(): return (Codec().encode,Codec().decode,StreamReader,StreamWriter) - --- 32,33 ---- Index: shift_jisx0213.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/encodings/shift_jisx0213.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** shift_jisx0213.py 17 Jan 2004 14:29:28 -0000 1.1 --- shift_jisx0213.py 7 Jul 2004 20:54:47 -0000 1.2 *************** *** 32,34 **** def getregentry(): return (Codec().encode,Codec().decode,StreamReader,StreamWriter) - --- 32,33 ---- From tim_one at users.sourceforge.net Wed Jul 7 22:55:34 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Wed Jul 7 22:55:37 2004 Subject: [Python-checkins] python/dist/src/Lib asyncore.py, 1.54, 1.55 cmd.py, 1.38, 1.39 decimal.py, 1.10, 1.11 doctest.py, 1.34, 1.35 profile.py, 1.55, 1.56 site.py, 1.61, 1.62 stringprep.py, 1.3, 1.4 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28101/Lib Modified Files: asyncore.py cmd.py decimal.py doctest.py profile.py site.py stringprep.py Log Message: Whitespace normalization. Index: asyncore.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/asyncore.py,v retrieving revision 1.54 retrieving revision 1.55 diff -C2 -d -r1.54 -r1.55 *** asyncore.py 7 Jul 2004 12:23:53 -0000 1.54 --- asyncore.py 7 Jul 2004 20:54:44 -0000 1.55 *************** *** 305,309 **** pass else: ! raise def send(self, data): --- 305,309 ---- pass else: ! raise def send(self, data): *************** *** 315,319 **** return 0 else: ! raise return 0 --- 315,319 ---- return 0 else: ! raise return 0 *************** *** 334,338 **** return '' else: ! raise def close(self): --- 334,338 ---- return '' else: ! raise def close(self): *************** *** 530,532 **** self.socket = file_wrapper(fd) self.add_channel() - --- 530,531 ---- Index: cmd.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/cmd.py,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** cmd.py 1 Jul 2004 14:52:10 -0000 1.38 --- cmd.py 7 Jul 2004 20:54:45 -0000 1.39 *************** *** 150,154 **** except ImportError: pass ! def precmd(self, line): --- 150,154 ---- except ImportError: pass ! def precmd(self, line): *************** *** 173,177 **** """ pass ! def parseline(self, line): """Parse the line into a command name and a string containing --- 173,177 ---- """ pass ! def parseline(self, line): """Parse the line into a command name and a string containing Index: decimal.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/decimal.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** decimal.py 5 Jul 2004 22:53:02 -0000 1.10 --- decimal.py 7 Jul 2004 20:54:45 -0000 1.11 *************** *** 510,517 **** if isinstance(value, Decimal): ! self._exp = value._exp ! self._sign = value._sign ! self._int = value._int ! return raise TypeError("Can't convert %r" % value) --- 510,517 ---- if isinstance(value, Decimal): ! self._exp = value._exp ! self._sign = value._sign ! self._int = value._int ! return raise TypeError("Can't convert %r" % value) *************** *** 2818,2822 **** selfint[x] += 10 else: ! carry = 0 if carry: selfint[x+1] -= 1 --- 2818,2822 ---- selfint[x] += 10 else: ! carry = 0 if carry: selfint[x+1] -= 1 Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** doctest.py 31 May 2004 19:01:00 -0000 1.34 --- doctest.py 7 Jul 2004 20:54:45 -0000 1.35 *************** *** 206,210 **** them: ! >>> def f(x): ... r'''Backslashes in a raw docstring: m\n''' >>> print f.__doc__ --- 206,210 ---- them: ! >>> def f(x): ... r'''Backslashes in a raw docstring: m\n''' >>> print f.__doc__ *************** *** 216,224 **** (and not use a raw string): ! >>> def f(x): ... '''Backslashes in a raw docstring: m\\n''' >>> print f.__doc__ Backslashes in a raw docstring: m\n ! The starting column doesn't matter: --- 216,224 ---- (and not use a raw string): ! >>> def f(x): ... '''Backslashes in a raw docstring: m\\n''' >>> print f.__doc__ Backslashes in a raw docstring: m\n ! The starting column doesn't matter: Index: profile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/profile.py,v retrieving revision 1.55 retrieving revision 1.56 diff -C2 -d -r1.55 -r1.56 *** profile.py 24 Mar 2004 21:57:08 -0000 1.55 --- profile.py 7 Jul 2004 20:54:45 -0000 1.56 *************** *** 599,603 **** parser = ProfileParser(usage) parser.allow_interspersed_args = False ! parser.add_option('-o', '--outfile', dest="outfile", help="Save stats to ", default=None) parser.add_option('-s', '--sort', dest="sort", --- 599,603 ---- parser = ProfileParser(usage) parser.allow_interspersed_args = False ! parser.add_option('-o', '--outfile', dest="outfile", help="Save stats to ", default=None) parser.add_option('-s', '--sort', dest="sort", *************** *** 606,610 **** (options, args) = parser.parse_args() sys.argv[:] = args ! if (len(sys.argv) > 0): sys.path.insert(0, os.path.dirname(sys.argv[0])) --- 606,610 ---- (options, args) = parser.parse_args() sys.argv[:] = args ! if (len(sys.argv) > 0): sys.path.insert(0, os.path.dirname(sys.argv[0])) Index: site.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/site.py,v retrieving revision 1.61 retrieving revision 1.62 diff -C2 -d -r1.61 -r1.62 *** site.py 5 Jun 2004 01:12:51 -0000 1.61 --- site.py 7 Jul 2004 20:54:45 -0000 1.62 *************** *** 211,215 **** during module import. Use BEGINLIBPATH so that these are at the start of the library search path. ! """ dllpath = os.path.join(sys.prefix, "Lib", "lib-dynload") --- 211,215 ---- during module import. Use BEGINLIBPATH so that these are at the start of the library search path. ! """ dllpath = os.path.join(sys.prefix, "Lib", "lib-dynload") Index: stringprep.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/stringprep.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** stringprep.py 19 May 2004 19:10:17 -0000 1.3 --- stringprep.py 7 Jul 2004 20:54:45 -0000 1.4 *************** *** 271,273 **** def in_table_d2(code): return unicodedata.bidirectional(code) == "L" - --- 271,272 ---- From rhettinger at users.sourceforge.net Thu Jul 8 02:49:21 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Thu Jul 8 02:49:25 2004 Subject: [Python-checkins] python/dist/src/Lib decimal.py,1.11,1.12 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31028 Modified Files: decimal.py Log Message: Tim gets his default traps. Index: decimal.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/decimal.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** decimal.py 7 Jul 2004 20:54:45 -0000 1.11 --- decimal.py 8 Jul 2004 00:49:18 -0000 1.12 *************** *** 32,36 **** >>> from decimal import * ! >>> getcontext().prec=9 >>> Decimal(0) Decimal("0") --- 32,36 ---- >>> from decimal import * ! >>> setcontext(ExtendedContext) >>> Decimal(0) Decimal("0") *************** *** 406,411 **** def setcontext(context): """Set this thread's context to context.""" ! if context == DefaultContext: ! context = Context() threading.currentThread().__decimal_context__ = context --- 406,411 ---- def setcontext(context): """Set this thread's context to context.""" ! if context in (DefaultContext, BasicContext, ExtendedContext): ! context = context.copy() threading.currentThread().__decimal_context__ = context *************** *** 2961,2973 **** ##### Setup Specific Contexts ################################ - _basic_traps = dict.fromkeys(Signals, 1) - _basic_traps.update({Inexact:0, Rounded:0, Subnormal:0}) - # The default context prototype used by Context() # Is mutable, so than new contexts can have different default values DefaultContext = Context( prec=28, rounding=ROUND_HALF_EVEN, ! trap_enablers=dict.fromkeys(Signals, 0), flags=None, _rounding_decision=ALWAYS_ROUND, --- 2961,2973 ---- ##### Setup Specific Contexts ################################ # The default context prototype used by Context() # Is mutable, so than new contexts can have different default values + _default_traps = dict.fromkeys(Signals, 0) + _default_traps.update({DivisionByZero:1, Overflow:1, InvalidOperation:1}) + DefaultContext = Context( prec=28, rounding=ROUND_HALF_EVEN, ! trap_enablers=_default_traps, flags=None, _rounding_decision=ALWAYS_ROUND, *************** *** 2976,2980 **** capitals=1 ) - DefaultContext.trap_enablers.update({ConversionSyntax : 1}) # Pre-made alternate contexts offered by the specification --- 2976,2979 ---- *************** *** 2983,2986 **** --- 2982,2988 ---- # of the spec. + _basic_traps = dict.fromkeys(Signals, 1) + _basic_traps.update({Inexact:0, Rounded:0, Subnormal:0}) + BasicContext = Context( prec=9, rounding=ROUND_HALF_UP, From nnorwitz at users.sourceforge.net Thu Jul 8 03:22:33 2004 From: nnorwitz at users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Thu Jul 8 03:22:37 2004 Subject: [Python-checkins] python/dist/src/Objects weakrefobject.c, 1.17, 1.18 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3815/Objects Modified Files: weakrefobject.c Log Message: SF bug #978308, Spurious errors taking bool of dead pro Need to return -1 on error. Needs backport. Index: weakrefobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/weakrefobject.c,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** weakrefobject.c 2 Jul 2004 18:57:45 -0000 1.17 --- weakrefobject.c 8 Jul 2004 01:22:31 -0000 1.18 *************** *** 505,509 **** PyObject *o = PyWeakref_GET_OBJECT(proxy); if (!proxy_checkref(proxy)) ! return 1; if (o->ob_type->tp_as_number && o->ob_type->tp_as_number->nb_nonzero) --- 505,509 ---- PyObject *o = PyWeakref_GET_OBJECT(proxy); if (!proxy_checkref(proxy)) ! return -1; if (o->ob_type->tp_as_number && o->ob_type->tp_as_number->nb_nonzero) From nnorwitz at users.sourceforge.net Thu Jul 8 03:22:34 2004 From: nnorwitz at users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Thu Jul 8 03:22:38 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_weakref.py, 1.41, 1.42 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3815/Lib/test Modified Files: test_weakref.py Log Message: SF bug #978308, Spurious errors taking bool of dead pro Need to return -1 on error. Needs backport. Index: test_weakref.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_weakref.py,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** test_weakref.py 2 Jul 2004 18:57:42 -0000 1.41 --- test_weakref.py 8 Jul 2004 01:22:31 -0000 1.42 *************** *** 105,108 **** --- 105,109 ---- self.assertRaises(weakref.ReferenceError, check, ref1) self.assertRaises(weakref.ReferenceError, check, ref2) + self.assertRaises(weakref.ReferenceError, bool, weakref.proxy(C())) self.assert_(self.cbcalled == 2) From nnorwitz at users.sourceforge.net Thu Jul 8 03:49:02 2004 From: nnorwitz at users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Thu Jul 8 03:49:07 2004 Subject: [Python-checkins] python/dist/src/Objects object.c, 2.219, 2.220 funcobject.c, 2.64, 2.65 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7983/Objects Modified Files: object.c funcobject.c Log Message: Remove unused macros in .c files Index: object.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/object.c,v retrieving revision 2.219 retrieving revision 2.220 diff -C2 -d -r2.219 -r2.220 *** object.c 2 Jul 2004 18:57:44 -0000 2.219 --- object.c 8 Jul 2004 01:48:59 -0000 2.220 *************** *** 705,710 **** } - #define CHECK_TYPES(o) PyType_HasFeature((o)->ob_type, Py_TPFLAGS_CHECKTYPES) - /* Do a 3-way comparison, by hook or by crook. Return: -2 for an exception (but see below); --- 705,708 ---- Index: funcobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/funcobject.c,v retrieving revision 2.64 retrieving revision 2.65 diff -C2 -d -r2.64 -r2.65 *** funcobject.c 23 Mar 2004 18:40:15 -0000 2.64 --- funcobject.c 8 Jul 2004 01:48:59 -0000 2.65 *************** *** 157,162 **** #define OFF(x) offsetof(PyFunctionObject, x) - #define RR () - static PyMemberDef func_memberlist[] = { {"func_closure", T_OBJECT, OFF(func_closure), --- 157,160 ---- From nnorwitz at users.sourceforge.net Thu Jul 8 03:49:03 2004 From: nnorwitz at users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Thu Jul 8 03:49:10 2004 Subject: [Python-checkins] python/dist/src/Python ceval.c, 2.409, 2.410 compile.c, 2.305, 2.306 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7983/Python Modified Files: ceval.c compile.c Log Message: Remove unused macros in .c files Index: ceval.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/ceval.c,v retrieving revision 2.409 retrieving revision 2.410 diff -C2 -d -r2.409 -r2.410 *** ceval.c 7 Jul 2004 17:44:11 -0000 2.409 --- ceval.c 8 Jul 2004 01:49:00 -0000 2.410 *************** *** 3805,3811 **** } - #define SLICE_ERROR_MSG \ - "standard sequence type does not support step size other than one" - /* Extract a slice index from a PyInt or PyLong, and store in *pi. Silently reduce values larger than INT_MAX to INT_MAX, and silently --- 3805,3808 ---- Index: compile.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/compile.c,v retrieving revision 2.305 retrieving revision 2.306 diff -C2 -d -r2.305 -r2.306 *** compile.c 24 Jun 2004 09:25:39 -0000 2.305 --- compile.c 8 Jul 2004 01:49:00 -0000 2.306 *************** *** 52,58 **** "duplicate argument '%s' in function definition" - #define ILLEGAL_DYNAMIC_SCOPE \ - "%.100s: exec or 'import *' makes names ambiguous in nested scope" - #define GLOBAL_AFTER_ASSIGN \ "name '%.400s' is assigned to before global declaration" --- 52,55 ---- *************** *** 846,851 **** } - #define DUMP(N) dump(N, 0, -1) - static int com_init(struct compiling *c, const char *filename) --- 843,846 ---- From nnorwitz at users.sourceforge.net Thu Jul 8 03:54:17 2004 From: nnorwitz at users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Thu Jul 8 03:54:21 2004 Subject: [Python-checkins] python/dist/src/Parser parsetok.c,2.35,2.36 Message-ID: Update of /cvsroot/python/python/dist/src/Parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8718/Parser Modified Files: parsetok.c Log Message: Pass the flags along, rather than ignoring them. Backport candidate Index: parsetok.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Parser/parsetok.c,v retrieving revision 2.35 retrieving revision 2.36 diff -C2 -d -r2.35 -r2.36 *** parsetok.c 13 Feb 2003 22:07:58 -0000 2.35 --- parsetok.c 8 Jul 2004 01:54:07 -0000 2.36 *************** *** 30,34 **** { return PyParser_ParseStringFlagsFilename(s, NULL, ! g, start, err_ret, 0); } --- 30,34 ---- { return PyParser_ParseStringFlagsFilename(s, NULL, ! g, start, err_ret, flags); } From nnorwitz at users.sourceforge.net Thu Jul 8 03:56:01 2004 From: nnorwitz at users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Thu Jul 8 03:56:04 2004 Subject: [Python-checkins] python/dist/src/Objects floatobject.c, 2.131, 2.132 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8997/Objects Modified Files: floatobject.c Log Message: Fix a couple of signed/unsigned comparison warnings Index: floatobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/floatobject.c,v retrieving revision 2.131 retrieving revision 2.132 diff -C2 -d -r2.131 -r2.132 *** floatobject.c 8 Jun 2004 18:52:53 -0000 2.131 --- floatobject.c 8 Jul 2004 01:55:58 -0000 2.132 *************** *** 885,889 **** PyFloatObject *p; PyFloatBlock *list, *next; ! int i; int bc, bf; /* block count, number of freed blocks */ int frem, fsum; /* remaining unfreed floats per block, total */ --- 885,889 ---- PyFloatObject *p; PyFloatBlock *list, *next; ! unsigned i; int bc, bf; /* block count, number of freed blocks */ int frem, fsum; /* remaining unfreed floats per block, total */ From nnorwitz at users.sourceforge.net Thu Jul 8 03:56:01 2004 From: nnorwitz at users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Thu Jul 8 03:56:09 2004 Subject: [Python-checkins] python/dist/src/Python codecs.c,2.23,2.24 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8997/Python Modified Files: codecs.c Log Message: Fix a couple of signed/unsigned comparison warnings Index: codecs.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/codecs.c,v retrieving revision 2.23 retrieving revision 2.24 diff -C2 -d -r2.23 -r2.24 *** codecs.c 24 Mar 2004 22:22:11 -0000 2.23 --- codecs.c 8 Jul 2004 01:55:58 -0000 2.24 *************** *** 805,809 **** PyInterpreterState *interp = PyThreadState_GET()->interp; PyObject *mod; ! int i; if (interp->codec_search_path != NULL) --- 805,809 ---- PyInterpreterState *interp = PyThreadState_GET()->interp; PyObject *mod; ! unsigned i; if (interp->codec_search_path != NULL) From nnorwitz at users.sourceforge.net Thu Jul 8 03:56:49 2004 From: nnorwitz at users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Thu Jul 8 03:56:51 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_heapq.py,1.12,1.13 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9134/Lib/test Modified Files: test_heapq.py Log Message: Exercise some error conditions Index: test_heapq.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_heapq.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** test_heapq.py 15 Jun 2004 23:53:35 -0000 1.12 --- test_heapq.py 8 Jul 2004 01:56:46 -0000 1.13 *************** *** 39,42 **** --- 39,46 ---- self.check_invariant(results) + self.assertRaises(TypeError, heappush, []) + self.assertRaises(TypeError, heappush, None, None) + self.assertRaises(TypeError, heappop, None) + def check_invariant(self, heap): # Check the heap invariant. *************** *** 52,55 **** --- 56,61 ---- self.check_invariant(heap) + self.assertRaises(TypeError, heapify, None) + def test_naive_nbest(self): data = [random.randrange(2000) for i in range(1000)] *************** *** 76,79 **** --- 82,89 ---- self.assertEqual(list(heapiter(heap)), sorted(data)[-10:]) + self.assertRaises(TypeError, heapreplace, None) + self.assertRaises(TypeError, heapreplace, None, None) + self.assertRaises(IndexError, heapreplace, [], None) + def test_heapsort(self): # Exercise everything with repeated heapsort checks From nnorwitz at users.sourceforge.net Thu Jul 8 03:59:57 2004 From: nnorwitz at users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Thu Jul 8 03:59:59 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_xrange.py,NONE,1.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9610/Lib/test Added Files: test_xrange.py Log Message: Exercise xrange a bit --- NEW FILE: test_xrange.py --- # Python test set -- built-in functions import test.test_support, unittest import sys import warnings warnings.filterwarnings("ignore", "integer argument expected", DeprecationWarning, "unittest") class XrangeTest(unittest.TestCase): def test_xrange(self): self.assertEqual(list(xrange(3)), [0, 1, 2]) self.assertEqual(list(xrange(1, 5)), [1, 2, 3, 4]) self.assertEqual(list(xrange(0)), []) self.assertEqual(list(xrange(-3)), []) self.assertEqual(list(xrange(1, 10, 3)), [1, 4, 7]) self.assertEqual(list(xrange(5, -5, -3)), [5, 2, -1, -4]) a = 10 b = 100 c = 50 self.assertEqual(list(xrange(a, a+2)), [a, a+1]) self.assertEqual(list(xrange(a+2, a, -1L)), [a+2, a+1]) self.assertEqual(list(xrange(a+4, a, -2)), [a+4, a+2]) seq = list(xrange(a, b, c)) self.assert_(a in seq) self.assert_(b not in seq) self.assertEqual(len(seq), 2) seq = list(xrange(b, a, -c)) self.assert_(b in seq) self.assert_(a not in seq) self.assertEqual(len(seq), 2) seq = list(xrange(-a, -b, -c)) self.assert_(-a in seq) self.assert_(-b not in seq) self.assertEqual(len(seq), 2) self.assertRaises(TypeError, xrange) self.assertRaises(TypeError, xrange, 1, 2, 3, 4) self.assertRaises(ValueError, xrange, 1, 2, 0) self.assertRaises(OverflowError, xrange, 1e100, 1e101, 1e101) self.assertRaises(TypeError, xrange, 0, "spam") self.assertRaises(TypeError, xrange, 0, 42, "spam") self.assertRaises(OverflowError, xrange, 0, sys.maxint, sys.maxint-1) self.assertRaises(OverflowError, xrange, -sys.maxint, sys.maxint) self.assertRaises(OverflowError, xrange, 0, 2*sys.maxint) def test_main(): test.test_support.run_unittest(XrangeTest) if __name__ == "__main__": test_main() From fdrake at users.sourceforge.net Thu Jul 8 05:56:14 2004 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Thu Jul 8 05:56:18 2004 Subject: [Python-checkins] python/dist/src/Doc/tools buildindex.py, 1.14, 1.15 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/tools In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25810 Modified Files: buildindex.py Log Message: Deal with macros that have to be replaced with simple text; only a couple of these are currently found in index data, but these should all be handled in the same way. Closes SF bug #952737. Index: buildindex.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/tools/buildindex.py,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** buildindex.py 25 Nov 2003 16:21:00 -0000 1.14 --- buildindex.py 8 Jul 2004 03:56:12 -0000 1.15 *************** *** 14,21 **** null_join = "".join class Node: - __rmjunk = re.compile("<#\d+#>") - continuation = 0 --- 14,31 ---- null_join = "".join + REPLACEMENTS = [ + # Hackish way to deal with macros replaced with simple text + (re.compile(r"\\ABC\b"), "ABC"), + (re.compile(r"\\ASCII\b"), "ASCII"), + (re.compile(r"\\Cpp\b"), "C++"), + (re.compile(r"\\EOF\b"), "EOF"), + (re.compile(r"\\NULL\b"), "NULL"), + (re.compile(r"\\POSIX\b"), "POSIX"), + (re.compile(r"\\UNIX\b"), "Unix"), + # deal with turds left over from LaTeX2HTML + (re.compile(r"<#\d+#>"), ""), + ] class Node: continuation = 0 *************** *** 23,28 **** self.links = [link] self.seqno = seqno ! # remove <#\d+#> left in by moving the data out of LaTeX2HTML ! str = self.__rmjunk.sub('', str) # build up the text self.text = split_entry_text(str) --- 33,38 ---- self.links = [link] self.seqno = seqno ! for pattern, replacement in REPLACEMENTS: ! str = pattern.sub(replacement, str) # build up the text self.text = split_entry_text(str) From fdrake at users.sourceforge.net Thu Jul 8 05:59:36 2004 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Thu Jul 8 05:59:38 2004 Subject: [Python-checkins] python/dist/src/Include patchlevel.h,2.75,2.76 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26189/Include Modified Files: patchlevel.h Log Message: bump the version number for 2.4a1 Index: patchlevel.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/patchlevel.h,v retrieving revision 2.75 retrieving revision 2.76 diff -C2 -d -r2.75 -r2.76 *** patchlevel.h 30 Jul 2003 05:37:39 -0000 2.75 --- patchlevel.h 8 Jul 2004 03:59:33 -0000 2.76 *************** *** 24,31 **** #define PY_MICRO_VERSION 0 #define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_ALPHA ! #define PY_RELEASE_SERIAL 0 /* Version as a string */ ! #define PY_VERSION "2.4a0" /* Version as a single 4-byte hex number, e.g. 0x010502B2 == 1.5.2b2. --- 24,31 ---- #define PY_MICRO_VERSION 0 #define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_ALPHA ! #define PY_RELEASE_SERIAL 1 /* Version as a string */ ! #define PY_VERSION "2.4a1" /* Version as a single 4-byte hex number, e.g. 0x010502B2 == 1.5.2b2. From tim_one at users.sourceforge.net Thu Jul 8 06:22:38 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Thu Jul 8 06:22:47 2004 Subject: [Python-checkins] python/dist/src/Tools/scripts diff.py, 1.1, 1.2 texcheck.py, 1.9, 1.10 Message-ID: Update of /cvsroot/python/python/dist/src/Tools/scripts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29480/Tools/scripts Modified Files: diff.py texcheck.py Log Message: Whitespace normalization. Index: diff.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/scripts/diff.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** diff.py 8 Jun 2003 23:04:17 -0000 1.1 --- diff.py 8 Jul 2004 04:22:20 -0000 1.2 *************** *** 39,41 **** sys.stdout.writelines(diff) - --- 39,40 ---- Index: texcheck.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/scripts/texcheck.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** texcheck.py 8 Sep 2003 18:41:18 -0000 1.9 --- texcheck.py 8 Jul 2004 04:22:35 -0000 1.10 *************** *** 231,233 **** if __name__ == '__main__': sys.exit(main()) - --- 231,232 ---- From tim_one at users.sourceforge.net Thu Jul 8 06:22:54 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Thu Jul 8 06:22:58 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_binascii.py, 1.17, 1.18 test_codecs.py, 1.10, 1.11 test_csv.py, 1.12, 1.13 test_genexps.py, 1.2, 1.3 test_heapq.py, 1.13, 1.14 test_htmlparser.py, 1.12, 1.13 test_isinstance.py, 1.8, 1.9 test_iterlen.py, 1.1, 1.2 test_multibytecodec_support.py, 1.3, 1.4 test_profile.py, 1.3, 1.4 test_tcl.py, 1.4, 1.5 test_textwrap.py, 1.26, 1.27 test_urllib2.py, 1.15, 1.16 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29480/Lib/test Modified Files: test_binascii.py test_codecs.py test_csv.py test_genexps.py test_heapq.py test_htmlparser.py test_isinstance.py test_iterlen.py test_multibytecodec_support.py test_profile.py test_tcl.py test_textwrap.py test_urllib2.py Log Message: Whitespace normalization. Index: test_binascii.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_binascii.py,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** test_binascii.py 15 Mar 2004 12:07:38 -0000 1.17 --- test_binascii.py 8 Jul 2004 04:22:19 -0000 1.18 *************** *** 102,106 **** self.assertRaises(binascii.Error, binascii.a2b_uu, "\xff\x00") self.assertRaises(binascii.Error, binascii.a2b_uu, "!!!!") ! self.assertRaises(binascii.Error, binascii.b2a_uu, 46*"!") --- 102,106 ---- self.assertRaises(binascii.Error, binascii.a2b_uu, "\xff\x00") self.assertRaises(binascii.Error, binascii.a2b_uu, "!!!!") ! self.assertRaises(binascii.Error, binascii.b2a_uu, 46*"!") Index: test_codecs.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_codecs.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** test_codecs.py 24 Mar 2004 16:48:24 -0000 1.10 --- test_codecs.py 8 Jul 2004 04:22:19 -0000 1.11 *************** *** 344,348 **** PunycodeTest, NameprepTest, ! CodecTest ) --- 344,348 ---- PunycodeTest, NameprepTest, ! CodecTest ) Index: test_csv.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_csv.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** test_csv.py 5 Jun 2004 17:03:20 -0000 1.12 --- test_csv.py 8 Jul 2004 04:22:19 -0000 1.13 *************** *** 134,138 **** fileobj.close() os.unlink(name) ! def _read_test(self, input, expect, **kwargs): reader = csv.reader(input, **kwargs) --- 134,138 ---- fileobj.close() os.unlink(name) ! def _read_test(self, input, expect, **kwargs): reader = csv.reader(input, **kwargs) *************** *** 227,231 **** fileobj.close() os.unlink(name) ! def test_dialect_apply(self): class testA(csv.excel): --- 227,231 ---- fileobj.close() os.unlink(name) ! def test_dialect_apply(self): class testA(csv.excel): *************** *** 248,252 **** fileobj.close() os.unlink(name) ! fd, name = tempfile.mkstemp() fileobj = os.fdopen(fd, "w+b") --- 248,252 ---- fileobj.close() os.unlink(name) ! fd, name = tempfile.mkstemp() fileobj = os.fdopen(fd, "w+b") Index: test_genexps.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_genexps.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** test_genexps.py 20 May 2004 23:04:13 -0000 1.2 --- test_genexps.py 8 Jul 2004 04:22:19 -0000 1.3 *************** *** 260,267 **** if __name__ == "__main__": test_main(verbose=True) - - - - - - --- 260,261 ---- Index: test_heapq.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_heapq.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** test_heapq.py 8 Jul 2004 01:56:46 -0000 1.13 --- test_heapq.py 8 Jul 2004 04:22:19 -0000 1.14 *************** *** 127,129 **** if __name__ == "__main__": test_main(verbose=True) - --- 127,128 ---- Index: test_htmlparser.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_htmlparser.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** test_htmlparser.py 5 Jun 2004 15:31:45 -0000 1.12 --- test_htmlparser.py 8 Jul 2004 04:22:19 -0000 1.13 *************** *** 205,209 **** ("starttag", "e", [("a", "rgb(1,2,3)")]), ]) ! # Regression test for SF bug #921657. self._run_check("", [ ("starttag", "a", [("href", "mailto:xyz@example.com")]), --- 205,209 ---- ("starttag", "e", [("a", "rgb(1,2,3)")]), ]) ! # Regression test for SF bug #921657. self._run_check("", [ ("starttag", "a", [("href", "mailto:xyz@example.com")]), Index: test_isinstance.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_isinstance.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** test_isinstance.py 20 Mar 2004 22:52:14 -0000 1.8 --- test_isinstance.py 8 Jul 2004 04:22:19 -0000 1.9 *************** *** 253,257 **** def test_isinstance_recursion_limit(self): # make sure that issubclass raises RuntimeError before the C stack is ! # blown self.assertRaises(RuntimeError, blowstack, isinstance, '', str) --- 253,257 ---- def test_isinstance_recursion_limit(self): # make sure that issubclass raises RuntimeError before the C stack is ! # blown self.assertRaises(RuntimeError, blowstack, isinstance, '', str) Index: test_iterlen.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_iterlen.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** test_iterlen.py 12 Apr 2004 18:10:01 -0000 1.1 --- test_iterlen.py 8 Jul 2004 04:22:19 -0000 1.2 *************** *** 53,63 **** def test_invariant(self): ! it = self.it ! for i in reversed(xrange(1, n+1)): ! self.assertEqual(len(it), i) ! it.next() ! self.assertEqual(len(it), 0) ! self.assertRaises(StopIteration, it.next) ! self.assertEqual(len(it), 0) class TestTemporarilyImmutable(TestInvariantWithoutMutations): --- 53,63 ---- def test_invariant(self): ! it = self.it ! for i in reversed(xrange(1, n+1)): ! self.assertEqual(len(it), i) ! it.next() ! self.assertEqual(len(it), 0) ! self.assertRaises(StopIteration, it.next) ! self.assertEqual(len(it), 0) class TestTemporarilyImmutable(TestInvariantWithoutMutations): Index: test_multibytecodec_support.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_multibytecodec_support.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** test_multibytecodec_support.py 6 Jun 2004 20:09:49 -0000 1.3 --- test_multibytecodec_support.py 8 Jul 2004 04:22:19 -0000 1.4 *************** *** 168,172 **** if not os.path.exists(parent): format = '%s not found, download from %s' ! raise test_support.TestSkipped(format % (self.mapfilename, self.mapfileurl)) else: --- 168,172 ---- if not os.path.exists(parent): format = '%s not found, download from %s' ! raise test_support.TestSkipped(format % (self.mapfilename, self.mapfileurl)) else: Index: test_profile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_profile.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** test_profile.py 22 Mar 2004 20:12:55 -0000 1.3 --- test_profile.py 8 Jul 2004 04:22:19 -0000 1.4 *************** *** 87,98 **** def test_2(): ! d = globals().copy() ! def testfunc(): ! global x ! x = 1 ! d['testfunc'] = testfunc ! profile.runctx("testfunc()", d, d, TESTFN) ! vereq (x, 1) ! os.unlink (TESTFN) if __name__ == "__main__": --- 87,98 ---- def test_2(): ! d = globals().copy() ! def testfunc(): ! global x ! x = 1 ! d['testfunc'] = testfunc ! profile.runctx("testfunc()", d, d, TESTFN) ! vereq (x, 1) ! os.unlink (TESTFN) if __name__ == "__main__": Index: test_tcl.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_tcl.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** test_tcl.py 26 Mar 2004 15:10:25 -0000 1.4 --- test_tcl.py 8 Jul 2004 04:22:19 -0000 1.5 *************** *** 86,90 **** tcl = self.interp self.assertRaises(TclError,tcl.unsetvar,'a') ! def testEvalFile(self): tcl = self.interp --- 86,90 ---- tcl = self.interp self.assertRaises(TclError,tcl.unsetvar,'a') ! def testEvalFile(self): tcl = self.interp Index: test_textwrap.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_textwrap.py,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** test_textwrap.py 3 Jun 2004 01:59:41 -0000 1.26 --- test_textwrap.py 8 Jul 2004 04:22:19 -0000 1.27 *************** *** 129,133 **** expect = ['And she said, "Go to hell!" Can you believe that?'] self.check(wrapper.wrap(text), expect) ! def test_wrap_short(self): # Wrapping to make short lines longer --- 129,133 ---- expect = ['And she said, "Go to hell!" Can you believe that?'] self.check(wrapper.wrap(text), expect) ! def test_wrap_short(self): # Wrapping to make short lines longer Index: test_urllib2.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_urllib2.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** test_urllib2.py 29 Jun 2004 13:17:29 -0000 1.15 --- test_urllib2.py 8 Jul 2004 04:22:19 -0000 1.16 *************** *** 679,683 **** self.assertEqual(len(data), 20) ! def test_main(verbose=None): --- 679,683 ---- self.assertEqual(len(data), 20) ! def test_main(verbose=None): From anthonybaxter at users.sourceforge.net Thu Jul 8 07:58:01 2004 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Thu Jul 8 07:58:05 2004 Subject: [Python-checkins] python/dist/src LICENSE,1.29,1.30 Message-ID: Update of /cvsroot/python/python/dist/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8769 Modified Files: LICENSE Log Message: license updates for 2.4 (cleared with tim, on behalf of the psf) Index: LICENSE =================================================================== RCS file: /cvsroot/python/python/dist/src/LICENSE,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** LICENSE 11 May 2004 18:13:09 -0000 1.29 --- LICENSE 8 Jul 2004 05:57:59 -0000 1.30 *************** *** 48,51 **** --- 48,52 ---- 2.3.3 2.3.2 2002-2003 PSF yes 2.3.4 2.3.3 2004 PSF yes + 2.4 2.3 2004 PSF yes Footnotes: *************** *** 69,78 **** =============================================================== ! PSF LICENSE AGREEMENT FOR PYTHON 2.3 ------------------------------------ 1. This LICENSE AGREEMENT is between the Python Software Foundation ("PSF"), and the Individual or Organization ("Licensee") accessing and ! otherwise using Python 2.3 software in source or binary form and its associated documentation. --- 70,79 ---- =============================================================== ! PSF LICENSE AGREEMENT FOR PYTHON 2.4 ------------------------------------ 1. This LICENSE AGREEMENT is between the Python Software Foundation ("PSF"), and the Individual or Organization ("Licensee") accessing and ! otherwise using Python 2.4 software in source or binary form and its associated documentation. *************** *** 80,106 **** hereby grants Licensee a nonexclusive, royalty-free, world-wide license to reproduce, analyze, test, perform and/or display publicly, ! prepare derivative works, distribute, and otherwise use Python 2.3 alone or in any derivative version, provided, however, that PSF's License Agreement and PSF's notice of copyright, i.e., "Copyright (c) 2001, 2002, 2003, 2004 Python Software Foundation; All Rights Reserved" ! are retained in Python 2.3 alone or in any derivative version prepared by Licensee. 3. In the event Licensee prepares a derivative work that is based on ! or incorporates Python 2.3 or any part thereof, and wants to make the derivative work available to others as provided herein, then Licensee hereby agrees to include in any such work a brief summary of ! the changes made to Python 2.3. ! 4. PSF is making Python 2.3 available to Licensee on an "AS IS" basis. PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS ! FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON 2.3 WILL NOT INFRINGE ANY THIRD PARTY RIGHTS. 5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON ! 2.3 FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS ! A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON 2.3, OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF. --- 81,107 ---- hereby grants Licensee a nonexclusive, royalty-free, world-wide license to reproduce, analyze, test, perform and/or display publicly, ! prepare derivative works, distribute, and otherwise use Python 2.4 alone or in any derivative version, provided, however, that PSF's License Agreement and PSF's notice of copyright, i.e., "Copyright (c) 2001, 2002, 2003, 2004 Python Software Foundation; All Rights Reserved" ! are retained in Python 2.4 alone or in any derivative version prepared by Licensee. 3. In the event Licensee prepares a derivative work that is based on ! or incorporates Python 2.4 or any part thereof, and wants to make the derivative work available to others as provided herein, then Licensee hereby agrees to include in any such work a brief summary of ! the changes made to Python 2.4. ! 4. PSF is making Python 2.4 available to Licensee on an "AS IS" basis. PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS ! FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON 2.4 WILL NOT INFRINGE ANY THIRD PARTY RIGHTS. 5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON ! 2.4 FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS ! A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON 2.4, OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF. *************** *** 114,118 **** products or services of Licensee, or any third party. ! 8. By copying, installing or otherwise using Python 2.3, Licensee agrees to be bound by the terms and conditions of this License Agreement. --- 115,119 ---- products or services of Licensee, or any third party. ! 8. By copying, installing or otherwise using Python 2.4, Licensee agrees to be bound by the terms and conditions of this License Agreement. From anthonybaxter at users.sourceforge.net Thu Jul 8 07:59:45 2004 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Thu Jul 8 07:59:48 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1024,1.1025 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8967/Misc Modified Files: NEWS Log Message: release dates Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1024 retrieving revision 1.1025 diff -C2 -d -r1.1024 -r1.1025 *** NEWS 6 Jul 2004 17:52:32 -0000 1.1024 --- NEWS 8 Jul 2004 05:59:43 -0000 1.1025 *************** *** 8,12 **** ================================= ! *Release date: DD-MMM-YYYY* Core and builtins --- 8,12 ---- ================================= ! *Release date: 08-JUL-2004* Core and builtins From anthonybaxter at users.sourceforge.net Thu Jul 8 07:59:45 2004 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Thu Jul 8 07:59:49 2004 Subject: [Python-checkins] python/dist/src/Lib/idlelib NEWS.txt,1.36,1.37 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/idlelib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8967/Lib/idlelib Modified Files: NEWS.txt Log Message: release dates Index: NEWS.txt =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/NEWS.txt,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** NEWS.txt 4 Jul 2004 01:25:56 -0000 1.36 --- NEWS.txt 8 Jul 2004 05:59:42 -0000 1.37 *************** *** 1,6 **** ! What's New in IDLE 1.1a0? ========================= ! *Release date: XX-XXX-2004* - Redirect the warning stream to the shell during the ScriptBinding check of --- 1,6 ---- ! What's New in IDLE 1.1a1? ========================= ! *Release date: 08-JUL-2004* - Redirect the warning stream to the shell during the ScriptBinding check of From anthonybaxter at users.sourceforge.net Thu Jul 8 08:01:45 2004 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Thu Jul 8 08:01:47 2004 Subject: [Python-checkins] python/dist/src/Misc/RPM python-2.4.spec,1.1,1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Misc/RPM In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9408 Modified Files: python-2.4.spec Log Message: 2.4a1 Index: python-2.4.spec =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/RPM/python-2.4.spec,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** python-2.4.spec 31 May 2004 19:40:57 -0000 1.1 --- python-2.4.spec 8 Jul 2004 06:01:42 -0000 1.2 *************** *** 31,35 **** %define name python ! %define version 2.4.0 %define libvers 2.4 %define release 1pydotorg --- 31,35 ---- %define name python ! %define version 2.4a1 %define libvers 2.4 %define release 1pydotorg From loewis at users.sourceforge.net Thu Jul 8 09:11:37 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Jul 8 09:11:40 2004 Subject: [Python-checkins] python/dist/src/PCbuild BUILDno.txt, 1.58, 1.59 pythoncore.vcproj, 1.11, 1.12 Message-ID: Update of /cvsroot/python/python/dist/src/PCbuild In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19315 Modified Files: BUILDno.txt pythoncore.vcproj Log Message: Bump build number to 54 for 2.4.0a1 Index: BUILDno.txt =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/BUILDno.txt,v retrieving revision 1.58 retrieving revision 1.59 diff -C2 -d -r1.58 -r1.59 *** BUILDno.txt 2 Jun 2004 13:21:41 -0000 1.58 --- BUILDno.txt 8 Jul 2004 07:11:33 -0000 1.59 *************** *** 34,37 **** --- 34,39 ---- Windows Python BUILD numbers ---------------------------- + 54 2.4.0a1 + 8-Jul-2004 53 2.3.4 (final) 27-May-2004 Index: pythoncore.vcproj =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/pythoncore.vcproj,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** pythoncore.vcproj 15 Jun 2004 18:18:19 -0000 1.11 --- pythoncore.vcproj 8 Jul 2004 07:11:33 -0000 1.12 *************** *** 1023,1027 **** Optimization="2" AdditionalIncludeDirectories="" ! PreprocessorDefinitions="BUILD=46"/> --- 1031,1035 ---- Optimization="0" AdditionalIncludeDirectories="" ! PreprocessorDefinitions="BUILD=54"/> From anthonybaxter at users.sourceforge.net Thu Jul 8 09:18:40 2004 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Thu Jul 8 09:18:43 2004 Subject: [Python-checkins] python/dist/src/PCbuild python20.wse,1.134,1.135 Message-ID: Update of /cvsroot/python/python/dist/src/PCbuild In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20345/PCbuild Modified Files: python20.wse Log Message: dont think it's still being used, but just in case Index: python20.wse =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/python20.wse,v retrieving revision 1.134 retrieving revision 1.135 diff -C2 -d -r1.134 -r1.135 *** python20.wse 20 Aug 2003 17:27:42 -0000 1.134 --- python20.wse 8 Jul 2004 07:18:34 -0000 1.135 *************** *** 2,6 **** item: Global Version=9.0 ! Title=Python 2.3 Flags=00010100 Languages=65 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 --- 2,6 ---- item: Global Version=9.0 ! Title=Python 2.4a1 Flags=00010100 Languages=65 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 *************** *** 21,29 **** MIF PDF Version=1.0 MIF SMS Version=2.0 ! EXE Filename=Python-2.3.exe Dialogs Version=8 ! Version File=2.3 Version Description=Python Programming Language ! Version Copyright=©2001-2003 Python Software Foundation Version Company=PythonLabs at Zope Corporation Crystal Format=10111100101100000010001001001001 --- 21,29 ---- MIF PDF Version=1.0 MIF SMS Version=2.0 ! EXE Filename=Python-2.4a1.exe Dialogs Version=8 ! Version File=2.4a1 Version Description=Python Programming Language ! Version Copyright=©2001-2004 Python Software Foundation Version Company=PythonLabs at Zope Corporation Crystal Format=10111100101100000010001001001001 From rhettinger at users.sourceforge.net Thu Jul 8 11:22:36 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Thu Jul 8 11:22:40 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libdecimal.tex,1.7,1.8 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9905 Modified Files: libdecimal.tex Log Message: Fix markup, typos, and nits. Index: libdecimal.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libdecimal.tex,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** libdecimal.tex 6 Jul 2004 01:55:14 -0000 1.7 --- libdecimal.tex 8 Jul 2004 09:22:33 -0000 1.8 *************** *** 99,103 **** \seetext{IEEE standard 854-1987, ! \citetitle[http://www.cs.berkeley.edu/~ejr/projects/754/private/drafts/854-1987/dir.html] {Unofficial IEEE 854 Text}.} \end{seealso} --- 99,103 ---- \seetext{IEEE standard 854-1987, ! \citetitle[http://www.cs.berkeley.edu/\textasciitilde ejr/projects/754/private/drafts/854-1987/dir.html] {Unofficial IEEE 854 Text}.} \end{seealso} *************** *** 121,142 **** \end{verbatim} ! Decimal instances can be constructed from integers or strings. To create a ! Decimal from a \class{float}, first convert it to a string. This serves as an ! explicit reminder of the details of the conversion (including representation ! error). Malformed strings signal \constant{ConversionSyntax} and return a ! special kind of Decimal called a \constant{NaN} which stands for ``Not a ! number''. Positive and negative \constant{Infinity} is yet another special ! kind of Decimal. \begin{verbatim} >>> Decimal(10) Decimal("10") ! >>> Decimal('3.14') Decimal("3.14") >>> Decimal(str(2.0 ** 0.5)) Decimal("1.41421356237") ! >>> Decimal('Mickey Mouse') Decimal("NaN") ! >>> Decimal('-Infinity') Decimal("-Infinity") \end{verbatim} --- 121,144 ---- \end{verbatim} ! Decimal instances can be constructed from integers, strings or tuples. To ! create a Decimal from a \class{float}, first convert it to a string. This ! serves as an explicit reminder of the details of the conversion (including ! representation error). Malformed strings signal \constant{ConversionSyntax} ! and return a special kind of Decimal called a \constant{NaN} which stands for ! ``Not a number''. Positive and negative \constant{Infinity} is yet another ! special kind of Decimal. \begin{verbatim} >>> Decimal(10) Decimal("10") ! >>> Decimal("3.14") ! Decimal("3.14") ! >>> Decimal((0, (3, 1, 4), -2)) Decimal("3.14") >>> Decimal(str(2.0 ** 0.5)) Decimal("1.41421356237") ! >>> Decimal("NaN") Decimal("NaN") ! >>> Decimal("-Infinity") Decimal("-Infinity") \end{verbatim} *************** *** 234,238 **** \begin{verbatim} >>> setcontext(ExtendedContext) - >>> getcontext().clear_flags() >>> Decimal(355) / Decimal(113) Decimal("3.14159292") --- 236,239 ---- *************** *** 315,322 **** a \class{tuple} of digits, and an exponent represented as an integer. For example, \samp{Decimal((0, (1, 4, 1, 4), -3))} returns ! \samp{Decimal("1.414")}. The supplied \var{context} or, if not specified, the current context ! governs only the handling of mal-formed strings not conforming to the numeric string syntax. If the context traps \constant{ConversionSyntax}, an exception is raised; otherwise, the constructor returns a new Decimal --- 316,323 ---- a \class{tuple} of digits, and an exponent represented as an integer. For example, \samp{Decimal((0, (1, 4, 1, 4), -3))} returns ! \code{Decimal("1.414")}. The supplied \var{context} or, if not specified, the current context ! governs only the handling of malformed strings not conforming to the numeric string syntax. If the context traps \constant{ConversionSyntax}, an exception is raised; otherwise, the constructor returns a new Decimal *************** *** 324,328 **** The context serves no other purpose. The number of significant digits ! recorded is determined solely by the \var{value} and the var{context} precision is not a factor. For example, \samp{Decimal("3.0000")} records all four zeroes even if the context precision is only three. --- 325,329 ---- The context serves no other purpose. The number of significant digits ! recorded is determined solely by the \var{value} and the \var{context} precision is not a factor. For example, \samp{Decimal("3.0000")} records all four zeroes even if the context precision is only three. *************** *** 342,349 **** \begin{methoddesc}{adjusted}{} ! Return the number's adjusted exponent that results from shifting out the ! coefficients rightmost digits until only the lead digit remains: ! \code{Decimal("321e+5").adjusted()} returns seven. Used for determining ! the place value of the most significant digit. \end{methoddesc} --- 343,350 ---- \begin{methoddesc}{adjusted}{} ! Return the adjusted exponent after shifting out the coefficient's rightmost ! digits until only the lead digit remains: \code{Decimal("321e+5").adjusted()} ! returns seven. Used for determining the place value of the most significant ! digit. \end{methoddesc} *************** *** 374,382 **** \begin{methoddesc}{normalize}{\optional{context}} ! Normalize the number by striping the rightmost trailing zeroes and ! converting any result equal to \constant{Decimal("0")} to Decimal("0e0"). ! Used for producing a canonical value for members of an equivalence class. ! For example, \code{Decimal("32.100")} and \code{Decimal("0.321000e+2")} ! both normalize to the equivalent value \code{Decimal("32.1")} \end{methoddesc} --- 375,384 ---- \begin{methoddesc}{normalize}{\optional{context}} ! Normalize the number by stripping the rightmost trailing zeroes and ! converting any result equal to \constant{Decimal("0")} to ! \constant{Decimal("0e0")}. Used for producing canonical values for members ! of an equivalence class. For example, \code{Decimal("32.100")} and ! \code{Decimal("0.321000e+2")} both normalize to the equivalent value ! \code{Decimal("32.1")}, \end{methoddesc} *************** *** 387,391 **** in the current context. ! Of \var{watchexp} is set (default), then an error is returned if the resulting exponent is greater than \member{Emax} or less than \member{Etiny}. --- 389,393 ---- in the current context. ! If \var{watchexp} is set (default), then an error is returned whenever the resulting exponent is greater than \member{Emax} or less than \member{Etiny}. *************** *** 402,406 **** \end{methoddesc} ! \begin{methoddesc}{same_quantum{other\optional{, context}}} Test whether self and other have the same exponent or whether both are \constant{NaN}. --- 404,408 ---- \end{methoddesc} ! \begin{methoddesc}{same_quantum}{other\optional{, context}} Test whether self and other have the same exponent or whether both are \constant{NaN}. *************** *** 412,416 **** \begin{methoddesc}{to_eng_string}{\optional{context}} ! Convert to engineering-type string. Engineering notation has an exponent which is a multiple of 3, so there --- 414,418 ---- \begin{methoddesc}{to_eng_string}{\optional{context}} ! Convert to an engineering-type string. Engineering notation has an exponent which is a multiple of 3, so there *************** *** 420,424 **** \begin{methoddesc}{to_integral}{\optional{rounding\optional{, context}}} ! Rounds to the nearest integer, without signaling \constant{Inexact} or \constant{Rounded}. If given, applies \var{rounding}; otherwise, uses the rounding method in either the supplied \var{context} or the --- 422,426 ---- \begin{methoddesc}{to_integral}{\optional{rounding\optional{, context}}} ! Rounds to the nearest integer without signaling \constant{Inexact} or \constant{Rounded}. If given, applies \var{rounding}; otherwise, uses the rounding method in either the supplied \var{context} or the *************** *** 464,467 **** --- 466,474 ---- \constant{ROUND_HALF_EVEN}. All flags are cleared. No traps are enabled (so that exceptions are not raised during computations). + + Because the trapped are disabled, this context is useful for applications + that prefer to have result value of \constant{NaN} or \constant{Infinity} + instead of raising exceptions. This allows an application to complete a + run in the presense of conditions that would otherwise halt the program. \end{classdesc*} *************** *** 483,487 **** cleared flags, and no traps enabled). \end{classdesc*} ! \begin{classdesc}{Context}{prec=None, rounding=None, trap_enablers=None, --- 490,497 ---- cleared flags, and no traps enabled). \end{classdesc*} ! ! ! In addition to the three supplied contexts, new contexts can be created ! with the \class{Context} constructor. \begin{classdesc}{Context}{prec=None, rounding=None, trap_enablers=None, *************** *** 492,502 **** cleared. ! The \var{prec} field in an positive integer that sets the precision for arithmetic operations in the context. The \var{rounding} option is one of: \constant{ROUND_CEILING}, ! \constant{ROUND_DOWN}, \constant{ROUND_FLOOR}, \constant{ROUND_HALF_DOWN}, ! \constant{ROUND_HALF_EVEN}, \constant{ROUND_HALF_UP}, or ! \constant{ROUND_UP}. The \var{trap_enablers} and \var{flags} fields are mappings from signals --- 502,512 ---- cleared. ! The \var{prec} field is a positive integer that sets the precision for arithmetic operations in the context. The \var{rounding} option is one of: \constant{ROUND_CEILING}, ! \constant{ROUND_DOWN}, \constant{ROUND_FLOOR}, \constant{ROUND_HALF_DOWN} ! (towards zero), \constant{ROUND_HALF_EVEN}, \constant{ROUND_HALF_UP}, or ! \constant{ROUND_UP} (away from zero). The \var{trap_enablers} and \var{flags} fields are mappings from signals *************** *** 537,549 **** \end{methoddesc} ! The usual approach to working with decimals is to create Decimal ! instances and then apply arithmetic operations which take place ! within the current context for the active thread. An alternate ! approach is to use a context method to perform a particular ! computation within the given context rather than the current context. - Those methods parallel those for the \class{Decimal} class and are - only briefed recounted here. \begin{methoddesc}{abs}{x} --- 547,561 ---- \end{methoddesc} ! \begin{methoddesc}{Etop}{} ! Returns a value equal to \samp{Emax - prec + 1}. ! \end{methoddesc} + The usual approach to working with decimals is to create \class{Decimal} + instances and then apply arithmetic operations which take place within the + current context for the active thread. An alternate approach is to use + context methods for calculating within s specific context. The methods are + similar to those for the \class{Decimal} class and are only briefly recounted + here. \begin{methoddesc}{abs}{x} *************** *** 571,575 **** \end{methoddesc} ! \begin{methoddesc}{divide}{x, y} Divides two numbers and returns the integer part of the result. \end{methoddesc} --- 583,587 ---- \end{methoddesc} ! \begin{methoddesc}{divmod}{x, y} Divides two numbers and returns the integer part of the result. \end{methoddesc} *************** *** 590,594 **** \begin{methoddesc}{minus}{x} ! Minus corresponds to unary prefix minus in Python. \end{methoddesc} --- 602,606 ---- \begin{methoddesc}{minus}{x} ! Minus corresponds to the unary prefix minus operator in Python. \end{methoddesc} *************** *** 605,609 **** \begin{methoddesc}{plus}{x} ! Minus corresponds to unary prefix plus in Python. \end{methoddesc} --- 617,621 ---- \begin{methoddesc}{plus}{x} ! Minus corresponds to the unary prefix plus operator in Python. \end{methoddesc} *************** *** 618,623 **** If the increased precision needed for the intermediate calculations exceeds ! the capabilities of the implementation then an Invalid operation condition ! is raised. If, when raising to a negative power, an underflow occurs during the --- 630,635 ---- If the increased precision needed for the intermediate calculations exceeds ! the capabilities of the implementation then an \constant{InvalidOperation} ! condition is signaled. If, when raising to a negative power, an underflow occurs during the *************** *** 666,670 **** \begin{methoddesc}{substract}{x, y} ! Return the difference of \var{x} and \var{y}. \end{methoddesc} --- 678,682 ---- \begin{methoddesc}{substract}{x, y} ! Return the difference between \var{x} and \var{y}. \end{methoddesc} *************** *** 678,687 **** \begin{methoddesc}{to_integral}{x} ! Rounds to the nearest integer, without signaling \constant{Inexact} or \constant{Rounded}. \end{methoddesc} \begin{methoddesc}{to_sci_string}{} ! Converts a number to a string, using scientific notation. \end{methoddesc} --- 690,699 ---- \begin{methoddesc}{to_integral}{x} ! Rounds to the nearest integer without signaling \constant{Inexact} or \constant{Rounded}. \end{methoddesc} \begin{methoddesc}{to_sci_string}{} ! Converts a number to a string using scientific notation. \end{methoddesc} *************** *** 696,700 **** The context flag is incremented whenever the condition is encountered. After the computation, flags may be checked for informational ! purposed (for instance, to determine whether a computation was exact). After checking the flags, be sure to clear all flags before starting the next computation. --- 708,712 ---- The context flag is incremented whenever the condition is encountered. After the computation, flags may be checked for informational ! purposes (for instance, to determine whether a computation was exact). After checking the flags, be sure to clear all flags before starting the next computation. *************** *** 715,719 **** \begin{classdesc*}{ConversionSyntax} ! Trying to convert a mal-formed string such as: \code{Decimal('jump')}. Decimal converts only strings conforming to the numeric string --- 727,731 ---- \begin{classdesc*}{ConversionSyntax} ! Trying to convert a malformed string such as: \code{Decimal('jump')}. Decimal converts only strings conforming to the numeric string *************** *** 795,799 **** \begin{classdesc*}{Rounded} ! Rounding occurred though possibly not information was lost. Signaled whenever rounding discards digits; even if those digits are --- 807,811 ---- \begin{classdesc*}{Rounded} ! Rounding occurred though possibly no information was lost. Signaled whenever rounding discards digits; even if those digits are *************** *** 842,848 **** The \function{getcontext()} function accesses a different \class{Context} ! object for each thread. Having separate contexts means that threads may make ! changes (such as \code{getcontext.prec=10}) without interfering with other ! threads and without needing mutexes. Likewise, the \function{setcontext()} function automatically assigns its target --- 854,860 ---- The \function{getcontext()} function accesses a different \class{Context} ! object for each thread. Having separate thread contexts means that threads ! may make changes (such as \code{getcontext.prec=10}) without interfering with ! other threads and without needing mutexes. Likewise, the \function{setcontext()} function automatically assigns its target *************** *** 860,864 **** \begin{verbatim} ! # Set application wide defaults for all threads about to be launched DefaultContext.prec=12 DefaultContext.rounding=ROUND_DOWN --- 872,876 ---- \begin{verbatim} ! # Set applicationwide defaults for all threads about to be launched DefaultContext.prec=12 DefaultContext.rounding=ROUND_DOWN *************** *** 945,949 **** c += t getcontext().prec -= 2 ! return c + 0 def exp(x): --- 957,961 ---- c += t getcontext().prec -= 2 ! return c + 0 # Adding zero causes rounding to the new precision def exp(x): From rhettinger at users.sourceforge.net Thu Jul 8 11:33:02 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Thu Jul 8 11:33:06 2004 Subject: [Python-checkins] python/dist/src/Doc/tut tut.tex,1.237,1.238 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/tut In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11587 Modified Files: tut.tex Log Message: Fix markup and nits. Index: tut.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/tut/tut.tex,v retrieving revision 1.237 retrieving revision 1.238 diff -C2 -d -r1.237 -r1.238 *** tut.tex 7 Jul 2004 02:32:36 -0000 1.237 --- tut.tex 8 Jul 2004 09:33:00 -0000 1.238 *************** *** 5058,5076 **** ! \section{Tools for Working with Decimal Floating Point\label{decimal-fp}} ! The \module{decimal} module, offers a \class{Decimal} data type for decimal floating point arithmetic. Compared to the built-in \class{float} ! type implemented with binary floating point, the new class is especially ! useful for financial applications and other uses which require exact decimal representation, control over precision, control over rounding to meet legal or regulatory requirements, tracking of significant decimal places, or for applications where the user expects the results ! to match hand calculations done as taught in school. ! For example, calculating a 5% tax on a 70 cent phone charge gives ! different results in decimal floating point and binary floating point ! with the difference being significant when rounding to the nearest ! cent: \begin{verbatim} --- 5058,5076 ---- ! \section{Decimal Floating Point Arithmetic\label{decimal-fp}} ! The \module{decimal} module offers a \class{Decimal} datatype for decimal floating point arithmetic. Compared to the built-in \class{float} ! implementation of binary floating point, the new class is especially ! helpful for financial applications and other uses which require exact decimal representation, control over precision, control over rounding to meet legal or regulatory requirements, tracking of significant decimal places, or for applications where the user expects the results ! to match hand calculations as taught in school. ! For example, calculating a 5\%{} tax on a 70 cent phone charge gives ! different results in decimal floating point and binary floating point. ! The difference becomes significant if the results are rounded to the ! nearest cent: \begin{verbatim} From loewis at users.sourceforge.net Thu Jul 8 11:36:46 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Jul 8 11:36:49 2004 Subject: [Python-checkins] python/nondist/sandbox/msi msi.py,1.9,1.10 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/msi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12247 Modified Files: msi.py Log Message: Restore unadvertised mode for menu items. Index: msi.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/msi/msi.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** msi.py 20 Feb 2004 20:01:37 -0000 1.9 --- msi.py 8 Jul 2004 09:36:32 -0000 1.10 *************** *** 818,830 **** [# Advertised shortcuts: targets are features, not files # The key file of the component is then entered as the real target ! ("IDLE", "MenuDir", "IDLE|IDLE (Python GUI)", "pythonw.exe", ! tcltk.id, r"[TARGETDIR]Lib\idlelib\idle.pyw", ! None, None, None, "py.ico", None, "TARGETDIR"), ! ("PyDoc", "MenuDir", "MODDOCS|Module Docs", "pythonw.exe", ! default_feature.id, r"[TARGETDIR]Tools\scripts\pydocgui.pyw", ! None, None, None, "py.ico", None, "TARGETDIR"), ! ("Python", "MenuDir", "PYTHON|Python (command line)", "python.exe", ! default_feature.id, None, ! None, None, None, "py.ico", None, "TARGETDIR"), ## Non-advertised features: must be associated with a registry component ("Manual", "MenuDir", "MANUAL|Python Manuals", "REGISTRY", --- 818,842 ---- [# Advertised shortcuts: targets are features, not files # The key file of the component is then entered as the real target ! # XXX, advertised shortcuts don't work, so make them unadvertised ! # for now ! #("IDLE", "MenuDir", "IDLE|IDLE (Python GUI)", "pythonw.exe", ! # tcltk.id, r"[TARGETDIR]Lib\idlelib\idle.pyw", ! # None, None, None, "py.ico", None, "TARGETDIR"), ! #("PyDoc", "MenuDir", "MODDOCS|Module Docs", "pythonw.exe", ! # default_feature.id, r"[TARGETDIR]Tools\scripts\pydocgui.pyw", ! # None, None, None, "py.ico", None, "TARGETDIR"), ! #("Python", "MenuDir", "PYTHON|Python (command line)", "python.exe", ! # default_feature.id, None, ! # None, None, None, "py.ico", None, "TARGETDIR"), ! ("IDLE", "MenuDir", "IDLE|IDLE (Python GUI)", "REGISTRY", ! r"[TARGETDIR]pythonw.exe", r"[TARGETDIR]Lib\idlelib\idle.pyw", ! None, None, None, None, None, "TARGETDIR"), ! ("PyDoc", "MenuDir", "MODDOCS|Module Docs", "REGISTRY", ! r"[TARGETDIR]pythonw.exe", r"[TARGETDIR]Tools\scripts\pydocgui.pyw", ! None, None, None, None, None, "TARGETDIR"), ! ("Python", "MenuDir", "PYTHON|Python (command line)", "REGISTRY", ! r"[TARGETDIR]python.exe", None, ! None, None, None, None, None, "TARGETDIR"), ! ## Non-advertised features: must be associated with a registry component ("Manual", "MenuDir", "MANUAL|Python Manuals", "REGISTRY", From vsajip at users.sourceforge.net Thu Jul 8 12:22:38 2004 From: vsajip at users.sourceforge.net (vsajip@users.sourceforge.net) Date: Thu Jul 8 12:22:41 2004 Subject: [Python-checkins] python/dist/src/Lib/logging __init__.py, 1.16, 1.17 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/logging In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19427 Modified Files: __init__.py Log Message: FileHandler now stores the basename as an absolute path (fix for SF #982049) Index: __init__.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/logging/__init__.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** __init__.py 7 Jul 2004 20:54:47 -0000 1.16 --- __init__.py 8 Jul 2004 10:22:35 -0000 1.17 *************** *** 38,42 **** __status__ = "beta" __version__ = "0.4.9.3" ! __date__ = "03 July 2004" #--------------------------------------------------------------------------- --- 38,42 ---- __status__ = "beta" __version__ = "0.4.9.3" ! __date__ = "08 July 2004" #--------------------------------------------------------------------------- *************** *** 710,714 **** """ StreamHandler.__init__(self, open(filename, mode)) ! self.baseFilename = filename self.mode = mode --- 710,716 ---- """ StreamHandler.__init__(self, open(filename, mode)) ! #keep the absolute path, otherwise derived classes which use this ! #may come a cropper when the current directory changes ! self.baseFilename = os.path.abspath(filename) self.mode = mode From vsajip at users.sourceforge.net Thu Jul 8 12:24:07 2004 From: vsajip at users.sourceforge.net (vsajip@users.sourceforge.net) Date: Thu Jul 8 12:24:09 2004 Subject: [Python-checkins] python/dist/src/Lib/logging handlers.py, 1.14, 1.15 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/logging In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19650 Modified Files: handlers.py Log Message: Add exception handling for BaseRotatingFileHandler (SF #979252) Index: handlers.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/logging/handlers.py,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** handlers.py 7 Jul 2004 20:54:48 -0000 1.14 --- handlers.py 8 Jul 2004 10:24:04 -0000 1.15 *************** *** 59,65 **** in doRollover(). """ ! if self.shouldRollover(record): ! self.doRollover() ! logging.FileHandler.emit(self, record) class RotatingFileHandler(BaseRotatingHandler): --- 59,68 ---- in doRollover(). """ ! try: ! if self.shouldRollover(record): ! self.doRollover() ! logging.FileHandler.emit(self, record) ! except: ! self.handleError(record) class RotatingFileHandler(BaseRotatingHandler): From mwh at users.sourceforge.net Thu Jul 8 17:28:30 2004 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Thu Jul 8 17:28:33 2004 Subject: [Python-checkins] python/dist/src/Parser myreadline.c,2.32,2.33 Message-ID: Update of /cvsroot/python/python/dist/src/Parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10986/Parser Modified Files: myreadline.c Log Message: PyThreadState_Swap(NULL) didn't do what I thought it did. Fixes [ 987287 ] Python 2.4a1, interpreter hanging on Keyboard Interrupt Index: myreadline.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Parser/myreadline.c,v retrieving revision 2.32 retrieving revision 2.33 diff -C2 -d -r2.32 -r2.33 *** myreadline.c 7 Jul 2004 20:42:07 -0000 2.32 --- myreadline.c 8 Jul 2004 15:28:26 -0000 2.33 *************** *** 85,89 **** PyEval_RestoreThread(_PyOS_ReadlineTState); s = PyErr_CheckSignals(); ! PyThreadState_Swap(NULL); if (s < 0) { return 1; --- 85,89 ---- PyEval_RestoreThread(_PyOS_ReadlineTState); s = PyErr_CheckSignals(); ! PyEval_SaveThread(); if (s < 0) { return 1; From mwh at users.sourceforge.net Thu Jul 8 17:28:30 2004 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Thu Jul 8 17:28:35 2004 Subject: [Python-checkins] python/dist/src/Modules readline.c,2.71,2.72 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10986/Modules Modified Files: readline.c Log Message: PyThreadState_Swap(NULL) didn't do what I thought it did. Fixes [ 987287 ] Python 2.4a1, interpreter hanging on Keyboard Interrupt Index: readline.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/readline.c,v retrieving revision 2.71 retrieving revision 2.72 diff -C2 -d -r2.71 -r2.72 *** readline.c 7 Jul 2004 17:44:10 -0000 2.71 --- readline.c 8 Jul 2004 15:28:18 -0000 2.72 *************** *** 701,705 **** PyEval_RestoreThread(_PyOS_ReadlineTState); s = PyErr_CheckSignals(); ! PyThreadState_Swap(NULL); if (s < 0) { rl_free_line_state(); --- 701,705 ---- PyEval_RestoreThread(_PyOS_ReadlineTState); s = PyErr_CheckSignals(); ! PyEval_SaveThread(); if (s < 0) { rl_free_line_state(); From doerwalter at users.sourceforge.net Thu Jul 8 19:14:20 2004 From: doerwalter at users.sourceforge.net (doerwalter@users.sourceforge.net) Date: Thu Jul 8 19:14:27 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_calendar.py, 1.6, 1.7 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2749/Lib/test Modified Files: test_calendar.py Log Message: Add another bunch of test cases for calendars with Sunday as the first day of the week. Index: test_calendar.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_calendar.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** test_calendar.py 2 Jul 2004 19:00:09 -0000 1.6 --- test_calendar.py 8 Jul 2004 17:14:17 -0000 1.7 *************** *** 129,136 **** def test_main(): test_support.run_unittest( CalendarTestCase, ! MondayTestCase ) --- 129,195 ---- + class SundayTestCase(MonthCalendarTestCase): + firstweekday = calendar.SUNDAY + + def test_february(self): + # A 28-day february starting of sunday (7+7+7+7 days) + self.check_weeks(2009, 2, (7, 7, 7, 7)) + + # A 28-day february starting of monday (6+7+7+7+1 days) + self.check_weeks(1999, 2, (6, 7, 7, 7, 1)) + + # A 28-day february starting of saturday (1+7+7+7+6 days) + self.check_weeks(1997, 2, (1, 7, 7, 7, 6)) + + # A 29-day february starting of sunday (7+7+7+7+1 days) + self.check_weeks(2004, 2, (7, 7, 7, 7, 1)) + + # A 29-day february starting of monday (6+7+7+7+2 days) + self.check_weeks(1960, 2, (6, 7, 7, 7, 2)) + + # A 29-day february starting of saturday (1+7+7+7+7 days) + self.check_weeks(1964, 2, (1, 7, 7, 7, 7)) + + def test_april(self): + # A 30-day april starting of sunday (7+7+7+7+2 days) + self.check_weeks(1923, 4, (7, 7, 7, 7, 2)) + + # A 30-day april starting of monday (6+7+7+7+3 days) + self.check_weeks(1918, 4, (6, 7, 7, 7, 3)) + + # A 30-day april starting of saturday (1+7+7+7+7+1 days) + self.check_weeks(1950, 4, (1, 7, 7, 7, 7, 1)) + + # A 30-day april starting of friday (2+7+7+7+7 days) + self.check_weeks(1960, 4, (2, 7, 7, 7, 7)) + + # A 30-day april starting of thursday (3+7+7+7+6 days) + self.check_weeks(1909, 4, (3, 7, 7, 7, 6)) + + def test_december(self): + # A 31-day december starting of sunday (7+7+7+7+3 days) + self.check_weeks(2080, 12, (7, 7, 7, 7, 3)) + + # A 31-day december starting of monday (6+7+7+7+4 days) + self.check_weeks(1941, 12, (6, 7, 7, 7, 4)) + + # A 31-day december starting of saturday (1+7+7+7+7+2 days) + self.check_weeks(1923, 12, (1, 7, 7, 7, 7, 2)) + + # A 31-day december starting of wednesday (4+7+7+7+6 days) + self.check_weeks(1948, 12, (4, 7, 7, 7, 6)) + + # A 31-day december starting of thursday (3+7+7+7+7 days) + self.check_weeks(1927, 12, (3, 7, 7, 7, 7)) + + # A 31-day december starting of friday (2+7+7+7+7+1 days) + self.check_weeks(1995, 12, (2, 7, 7, 7, 7, 1)) + + def test_main(): test_support.run_unittest( CalendarTestCase, ! MondayTestCase, ! SundayTestCase ) From lemburg at users.sourceforge.net Thu Jul 8 19:57:34 2004 From: lemburg at users.sourceforge.net (lemburg@users.sourceforge.net) Date: Thu Jul 8 19:57:37 2004 Subject: [Python-checkins] python/dist/src/Include unicodeobject.h, 2.43, 2.44 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10211/Include Modified Files: unicodeobject.h Log Message: Allow string and unicode return types from .encode()/.decode() methods on string and unicode objects. Added unicode.decode() which was missing for no apparent reason. Index: unicodeobject.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/unicodeobject.h,v retrieving revision 2.43 retrieving revision 2.44 diff -C2 -d -r2.43 -r2.44 *** unicodeobject.h 2 Jun 2004 16:49:08 -0000 2.43 --- unicodeobject.h 8 Jul 2004 17:57:30 -0000 2.44 *************** *** 142,145 **** --- 142,146 ---- # define PyUnicode_AsASCIIString PyUnicodeUCS2_AsASCIIString # define PyUnicode_AsCharmapString PyUnicodeUCS2_AsCharmapString + # define PyUnicode_AsEncodedObject PyUnicodeUCS2_AsEncodedObject # define PyUnicode_AsEncodedString PyUnicodeUCS2_AsEncodedString # define PyUnicode_AsLatin1String PyUnicodeUCS2_AsLatin1String *************** *** 216,219 **** --- 217,221 ---- # define PyUnicode_AsASCIIString PyUnicodeUCS4_AsASCIIString # define PyUnicode_AsCharmapString PyUnicodeUCS4_AsCharmapString + # define PyUnicode_AsEncodedObject PyUnicodeUCS4_AsEncodedObject # define PyUnicode_AsEncodedString PyUnicodeUCS4_AsEncodedString # define PyUnicode_AsLatin1String PyUnicodeUCS4_AsLatin1String *************** *** 627,630 **** --- 629,641 ---- ); + /* Encodes a Unicode object and returns the result as Python + object. */ + + PyAPI_FUNC(PyObject*) PyUnicode_AsEncodedObject( + PyObject *unicode, /* Unicode object */ + const char *encoding, /* encoding */ + const char *errors /* error handling */ + ); + /* Encodes a Unicode object and returns the result as Python string object. */ From lemburg at users.sourceforge.net Thu Jul 8 19:57:36 2004 From: lemburg at users.sourceforge.net (lemburg@users.sourceforge.net) Date: Thu Jul 8 19:57:40 2004 Subject: [Python-checkins] python/dist/src/Objects stringobject.c, 2.219, 2.220 unicodeobject.c, 2.213, 2.214 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10211/Objects Modified Files: stringobject.c unicodeobject.c Log Message: Allow string and unicode return types from .encode()/.decode() methods on string and unicode objects. Added unicode.decode() which was missing for no apparent reason. Index: stringobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/stringobject.c,v retrieving revision 2.219 retrieving revision 2.220 diff -C2 -d -r2.219 -r2.220 *** stringobject.c 27 Jun 2004 17:24:49 -0000 2.219 --- stringobject.c 8 Jul 2004 17:57:31 -0000 2.220 *************** *** 2674,2680 **** char *encoding = NULL; char *errors = NULL; if (!PyArg_ParseTuple(args, "|ss:encode", &encoding, &errors)) return NULL; ! return PyString_AsEncodedObject((PyObject *)self, encoding, errors); } --- 2674,2691 ---- char *encoding = NULL; char *errors = NULL; + PyObject *v; + if (!PyArg_ParseTuple(args, "|ss:encode", &encoding, &errors)) return NULL; ! v = PyString_AsEncodedObject((PyObject *)self, encoding, errors); ! if (!PyString_Check(v) && !PyUnicode_Check(v)) { ! PyErr_Format(PyExc_TypeError, ! "encoder did not return a string/unicode object " ! "(type=%.400s)", ! v->ob_type->tp_name); ! Py_DECREF(v); ! return NULL; ! } ! return v; } *************** *** 2695,2701 **** char *encoding = NULL; char *errors = NULL; if (!PyArg_ParseTuple(args, "|ss:decode", &encoding, &errors)) return NULL; ! return PyString_AsDecodedObject((PyObject *)self, encoding, errors); } --- 2706,2723 ---- char *encoding = NULL; char *errors = NULL; + PyObject *v; + if (!PyArg_ParseTuple(args, "|ss:decode", &encoding, &errors)) return NULL; ! v = PyString_AsDecodedObject((PyObject *)self, encoding, errors); ! if (!PyString_Check(v) && !PyUnicode_Check(v)) { ! PyErr_Format(PyExc_TypeError, ! "decoder did not return a string/unicode object " ! "(type=%.400s)", ! v->ob_type->tp_name); ! Py_DECREF(v); ! return NULL; ! } ! return v; } Index: unicodeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/unicodeobject.c,v retrieving revision 2.213 retrieving revision 2.214 diff -C2 -d -r2.213 -r2.214 *** unicodeobject.c 17 Jun 2004 18:27:17 -0000 2.213 --- unicodeobject.c 8 Jul 2004 17:57:32 -0000 2.214 *************** *** 562,565 **** --- 562,589 ---- } + PyObject *PyUnicode_AsDecodedObject(PyObject *unicode, + const char *encoding, + const char *errors) + { + PyObject *v; + + if (!PyUnicode_Check(unicode)) { + PyErr_BadArgument(); + goto onError; + } + + if (encoding == NULL) + encoding = PyUnicode_GetDefaultEncoding(); + + /* Decode via the codec registry */ + v = PyCodec_Decode(unicode, encoding, errors); + if (v == NULL) + goto onError; + return v; + + onError: + return NULL; + } + PyObject *PyUnicode_Encode(const Py_UNICODE *s, int size, *************** *** 577,580 **** --- 601,628 ---- } + PyObject *PyUnicode_AsEncodedObject(PyObject *unicode, + const char *encoding, + const char *errors) + { + PyObject *v; + + if (!PyUnicode_Check(unicode)) { + PyErr_BadArgument(); + goto onError; + } + + if (encoding == NULL) + encoding = PyUnicode_GetDefaultEncoding(); + + /* Encode via the codec registry */ + v = PyCodec_Encode(unicode, encoding, errors); + if (v == NULL) + goto onError; + return v; + + onError: + return NULL; + } + PyObject *PyUnicode_AsEncodedString(PyObject *unicode, const char *encoding, *************** *** 609,613 **** if (v == NULL) goto onError; - /* XXX Should we really enforce this ? */ if (!PyString_Check(v)) { PyErr_Format(PyExc_TypeError, --- 657,660 ---- *************** *** 4870,4877 **** PyDoc_STRVAR(encode__doc__, ! "S.encode([encoding[,errors]]) -> string\n\ \n\ ! Return an encoded string version of S. Default encoding is the current\n\ ! default string encoding. errors may be given to set a different error\n\ handling scheme. Default is 'strict' meaning that encoding errors raise\n\ a UnicodeEncodeError. Other possible values are 'ignore', 'replace' and\n\ --- 4917,4924 ---- PyDoc_STRVAR(encode__doc__, ! "S.encode([encoding[,errors]]) -> string or unicode\n\ \n\ ! Encodes S using the codec registered for encoding. encoding defaults\n\ ! to the default encoding. errors may be given to set a different error\n\ handling scheme. Default is 'strict' meaning that encoding errors raise\n\ a UnicodeEncodeError. Other possible values are 'ignore', 'replace' and\n\ *************** *** 4884,4890 **** char *encoding = NULL; char *errors = NULL; if (!PyArg_ParseTuple(args, "|ss:encode", &encoding, &errors)) return NULL; ! return PyUnicode_AsEncodedString((PyObject *)self, encoding, errors); } --- 4931,4979 ---- char *encoding = NULL; char *errors = NULL; + PyObject *v; + if (!PyArg_ParseTuple(args, "|ss:encode", &encoding, &errors)) return NULL; ! v = PyUnicode_AsEncodedObject((PyObject *)self, encoding, errors); ! if (!PyString_Check(v) && !PyUnicode_Check(v)) { ! PyErr_Format(PyExc_TypeError, ! "encoder did not return a string/unicode object " ! "(type=%.400s)", ! v->ob_type->tp_name); ! Py_DECREF(v); ! return NULL; ! } ! return v; ! } ! ! PyDoc_STRVAR(decode__doc__, ! "S.decode([encoding[,errors]]) -> string or unicode\n\ ! \n\ ! Decodes S using the codec registered for encoding. encoding defaults\n\ ! to the default encoding. errors may be given to set a different error\n\ ! handling scheme. Default is 'strict' meaning that encoding errors raise\n\ ! a UnicodeDecodeError. Other possible values are 'ignore' and 'replace'\n\ ! as well as any other name registerd with codecs.register_error that is\n\ ! able to handle UnicodeDecodeErrors."); ! ! static PyObject * ! unicode_decode(PyStringObject *self, PyObject *args) ! { ! char *encoding = NULL; ! char *errors = NULL; ! PyObject *v; ! ! if (!PyArg_ParseTuple(args, "|ss:decode", &encoding, &errors)) ! return NULL; ! v = PyUnicode_AsDecodedObject((PyObject *)self, encoding, errors); ! if (!PyString_Check(v) && !PyUnicode_Check(v)) { ! PyErr_Format(PyExc_TypeError, ! "decoder did not return a string/unicode object " ! "(type=%.400s)", ! v->ob_type->tp_name); ! Py_DECREF(v); ! return NULL; ! } ! return v; } *************** *** 6139,6142 **** --- 6228,6232 ---- {"lower", (PyCFunction) unicode_lower, METH_NOARGS, lower__doc__}, {"lstrip", (PyCFunction) unicode_lstrip, METH_VARARGS, lstrip__doc__}, + {"decode", (PyCFunction) unicode_decode, METH_VARARGS, decode__doc__}, /* {"maketrans", (PyCFunction) unicode_maketrans, METH_VARARGS, maketrans__doc__}, */ {"rfind", (PyCFunction) unicode_rfind, METH_VARARGS, rfind__doc__}, From walter at livinglogic.de Thu Jul 8 20:42:40 2004 From: walter at livinglogic.de (=?ISO-8859-1?Q?Walter_D=F6rwald?=) Date: Thu Jul 8 20:42:49 2004 Subject: [Python-checkins] python/dist/src/Objects stringobject.c, 2.219, 2.220 unicodeobject.c, 2.213, 2.214 In-Reply-To: References: Message-ID: <40ED95A0.4090905@livinglogic.de> lemburg@users.sourceforge.net wrote: > Modified Files: > stringobject.c unicodeobject.c > Log Message: > Allow string and unicode return types from .encode()/.decode() > methods on string and unicode objects. Added unicode.decode() > which was missing for no apparent reason. This seems to have broken test_codeccallbacks.py. I get: test_backslashescape (__main__.CodecCallbackTest) ... ok test_badandgoodbackslashreplaceexceptions (__main__.CodecCallbackTest) ... ok test_badandgoodignoreexceptions (__main__.CodecCallbackTest) ... ok test_badandgoodreplaceexceptions (__main__.CodecCallbackTest) ... ok test_badandgoodstrictexceptions (__main__.CodecCallbackTest) ... ok test_badandgoodxmlcharrefreplaceexceptions (__main__.CodecCallbackTest) ... ok Segmentation fault Rolling back the patch via: cvs up -j 2.44 -j 2.43 Include/unicodeobject.h cvs up -j 2.220 -j 2.219 Objects/stringobject.c cvs up -j 2.214 -j 2.213 Objects/unicodeobject.c gives a working test_codeccallbacks.py again. Bye, Walter D?rwald From mal at egenix.com Thu Jul 8 21:11:45 2004 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jul 8 21:11:50 2004 Subject: [Python-checkins] python/dist/src/Objects stringobject.c, 2.219, 2.220 unicodeobject.c, 2.213, 2.214 In-Reply-To: <40ED95A0.4090905@livinglogic.de> References: <40ED95A0.4090905@livinglogic.de> Message-ID: <40ED9C71.7090009@egenix.com> Walter D?rwald wrote: > lemburg@users.sourceforge.net wrote: > >> Modified Files: >> stringobject.c unicodeobject.c Log Message: >> Allow string and unicode return types from .encode()/.decode() >> methods on string and unicode objects. Added unicode.decode() >> which was missing for no apparent reason. > > > This seems to have broken test_codeccallbacks.py. I get: > test_backslashescape (__main__.CodecCallbackTest) ... ok > test_badandgoodbackslashreplaceexceptions (__main__.CodecCallbackTest) > ... ok > test_badandgoodignoreexceptions (__main__.CodecCallbackTest) ... ok > test_badandgoodreplaceexceptions (__main__.CodecCallbackTest) ... ok > test_badandgoodstrictexceptions (__main__.CodecCallbackTest) ... ok > test_badandgoodxmlcharrefreplaceexceptions (__main__.CodecCallbackTest) > ... ok > Segmentation fault > > Rolling back the patch via: > cvs up -j 2.44 -j 2.43 Include/unicodeobject.h > cvs up -j 2.220 -j 2.219 Objects/stringobject.c > cvs up -j 2.214 -j 2.213 Objects/unicodeobject.c > gives a working test_codeccallbacks.py again. Dang: I accidentally applied an older patch. Fix is coming. Sorry, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jul 08 2004) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From lemburg at users.sourceforge.net Thu Jul 8 21:14:15 2004 From: lemburg at users.sourceforge.net (lemburg@users.sourceforge.net) Date: Thu Jul 8 21:14:20 2004 Subject: [Python-checkins] python/dist/src/Objects unicodeobject.c, 2.214, 2.215 stringobject.c, 2.220, 2.221 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32170/Objects Modified Files: unicodeobject.c stringobject.c Log Message: .encode()/.decode() patch part 2. Index: unicodeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/unicodeobject.c,v retrieving revision 2.214 retrieving revision 2.215 diff -C2 -d -r2.214 -r2.215 *** unicodeobject.c 8 Jul 2004 17:57:32 -0000 2.214 --- unicodeobject.c 8 Jul 2004 19:13:54 -0000 2.215 *************** *** 4936,4939 **** --- 4936,4941 ---- return NULL; v = PyUnicode_AsEncodedObject((PyObject *)self, encoding, errors); + if (v == NULL) + goto onError; if (!PyString_Check(v) && !PyUnicode_Check(v)) { PyErr_Format(PyExc_TypeError, *************** *** 4945,4948 **** --- 4947,4953 ---- } return v; + + onError: + return NULL; } *************** *** 4967,4970 **** --- 4972,4977 ---- return NULL; v = PyUnicode_AsDecodedObject((PyObject *)self, encoding, errors); + if (v == NULL) + goto onError; if (!PyString_Check(v) && !PyUnicode_Check(v)) { PyErr_Format(PyExc_TypeError, *************** *** 4976,4979 **** --- 4983,4989 ---- } return v; + + onError: + return NULL; } Index: stringobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/stringobject.c,v retrieving revision 2.220 retrieving revision 2.221 diff -C2 -d -r2.220 -r2.221 *** stringobject.c 8 Jul 2004 17:57:31 -0000 2.220 --- stringobject.c 8 Jul 2004 19:13:55 -0000 2.221 *************** *** 2679,2682 **** --- 2679,2684 ---- return NULL; v = PyString_AsEncodedObject((PyObject *)self, encoding, errors); + if (v == NULL) + goto onError; if (!PyString_Check(v) && !PyUnicode_Check(v)) { PyErr_Format(PyExc_TypeError, *************** *** 2688,2691 **** --- 2690,2696 ---- } return v; + + onError: + return NULL; } *************** *** 2711,2714 **** --- 2716,2721 ---- return NULL; v = PyString_AsDecodedObject((PyObject *)self, encoding, errors); + if (v == NULL) + goto onError; if (!PyString_Check(v) && !PyUnicode_Check(v)) { PyErr_Format(PyExc_TypeError, *************** *** 2720,2723 **** --- 2727,2733 ---- } return v; + + onError: + return NULL; } From mal at egenix.com Thu Jul 8 21:17:08 2004 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jul 8 21:17:12 2004 Subject: [Python-checkins] python/dist/src/Objects stringobject.c, 2.219, 2.220 unicodeobject.c, 2.213, 2.214 In-Reply-To: <40ED9C71.7090009@egenix.com> References: <40ED95A0.4090905@livinglogic.de> <40ED9C71.7090009@egenix.com> Message-ID: <40ED9DB4.6060406@egenix.com> M.-A. Lemburg wrote: > Walter D?rwald wrote: > >> lemburg@users.sourceforge.net wrote: >> >>> Modified Files: >>> stringobject.c unicodeobject.c Log Message: >>> Allow string and unicode return types from .encode()/.decode() >>> methods on string and unicode objects. Added unicode.decode() >>> which was missing for no apparent reason. >> >> >> >> This seems to have broken test_codeccallbacks.py. I get: >> test_backslashescape (__main__.CodecCallbackTest) ... ok >> test_badandgoodbackslashreplaceexceptions (__main__.CodecCallbackTest) >> ... ok >> test_badandgoodignoreexceptions (__main__.CodecCallbackTest) ... ok >> test_badandgoodreplaceexceptions (__main__.CodecCallbackTest) ... ok >> test_badandgoodstrictexceptions (__main__.CodecCallbackTest) ... ok >> test_badandgoodxmlcharrefreplaceexceptions >> (__main__.CodecCallbackTest) ... ok >> Segmentation fault >> >> Rolling back the patch via: >> cvs up -j 2.44 -j 2.43 Include/unicodeobject.h >> cvs up -j 2.220 -j 2.219 Objects/stringobject.c >> cvs up -j 2.214 -j 2.213 Objects/unicodeobject.c >> gives a working test_codeccallbacks.py again. > > > Dang: I accidentally applied an older patch. > Fix is coming. Should work now. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jul 08 2004) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From walter at livinglogic.de Thu Jul 8 21:26:25 2004 From: walter at livinglogic.de (=?ISO-8859-1?Q?Walter_D=F6rwald?=) Date: Thu Jul 8 21:26:30 2004 Subject: [Python-Dev] Re: [Python-checkins] python/dist/src/Objects stringobject.c, 2.219, 2.220 unicodeobject.c, 2.213, 2.214 In-Reply-To: <40ED9DB4.6060406@egenix.com> References: <40ED95A0.4090905@livinglogic.de> <40ED9C71.7090009@egenix.com> <40ED9DB4.6060406@egenix.com> Message-ID: <40ED9FE1.3000209@livinglogic.de> M.-A. Lemburg wrote: > M.-A. Lemburg wrote: > > [...] > Should work now. Much better: $ ./python Lib/test/test_codeccallbacks.py test_backslashescape (__main__.CodecCallbackTest) ... ok [...] test_xmlcharrefvalues (__main__.CodecCallbackTest) ... ok ---------------------------------------------------------------------- Ran 26 tests in 0.144s Bye, Walter D?rwald From mal at egenix.com Thu Jul 8 21:27:36 2004 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jul 8 21:27:38 2004 Subject: [Python-Dev] Re: [Python-checkins] python/dist/src/Objects stringobject.c, 2.219, 2.220 unicodeobject.c, 2.213, 2.214 In-Reply-To: <40ED9FE1.3000209@livinglogic.de> References: <40ED95A0.4090905@livinglogic.de> <40ED9C71.7090009@egenix.com> <40ED9DB4.6060406@egenix.com> <40ED9FE1.3000209@livinglogic.de> Message-ID: <40EDA028.205@egenix.com> Walter D?rwald wrote: > M.-A. Lemburg wrote: > >> M.-A. Lemburg wrote: >> >> [...] >> Should work now. > > > Much better: > $ ./python Lib/test/test_codeccallbacks.py > test_backslashescape (__main__.CodecCallbackTest) ... ok > [...] > test_xmlcharrefvalues (__main__.CodecCallbackTest) ... ok > > ---------------------------------------------------------------------- > Ran 26 tests in 0.144s Good catch ! Thanks, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jul 08 2004) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From montanaro at users.sourceforge.net Thu Jul 8 21:49:13 2004 From: montanaro at users.sourceforge.net (montanaro@users.sourceforge.net) Date: Thu Jul 8 21:49:17 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libcsv.tex,1.14,1.15 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10934 Modified Files: libcsv.tex Log Message: show how easy it is to manipulate individual columns - from a request on c.l.py Index: libcsv.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libcsv.tex,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** libcsv.tex 16 Apr 2004 03:21:01 -0000 1.14 --- libcsv.tex 8 Jul 2004 19:49:10 -0000 1.15 *************** *** 320,323 **** --- 320,332 ---- \end{verbatim} + To print just the first and last columns of each row try + + \begin{verbatim} + import csv + reader = csv.reader(file("some.csv", "rb")) + for row in reader: + print row[0], row[-1] + \end{verbatim} + The corresponding simplest possible writing example is From goodger at users.sourceforge.net Fri Jul 9 00:09:51 2004 From: goodger at users.sourceforge.net (goodger@users.sourceforge.net) Date: Fri Jul 9 00:09:53 2004 Subject: [Python-checkins] python/nondist/peps pep-0327.txt,1.6,1.7 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18577 Modified Files: pep-0327.txt Log Message: update from Facundo Batista Index: pep-0327.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0327.txt,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** pep-0327.txt 6 Jul 2004 01:15:33 -0000 1.6 --- pep-0327.txt 8 Jul 2004 22:09:48 -0000 1.7 *************** *** 29,35 **** This work is based on code and test functions written by Eric Price, ! Aahz and Tim Peters. Actually I'll work on the Decimal.py code in the ! sandbox (at python/nondist/sandbox/decimal in the SourceForge CVS ! repository). Much of the explanation in this PEP is taken from Cowlishaw's work [2]_, comp.lang.python and python-dev. --- 29,36 ---- This work is based on code and test functions written by Eric Price, ! Aahz and Tim Peters. Just before Python 2.4a1, the decimal.py ! `reference implementation`_ was moved into the standard library; along ! with the documentation and the test suite, this was the work of ! Raymond Hettinger. Much of the explanation in this PEP is taken from Cowlishaw's work [2]_, comp.lang.python and python-dev. *************** *** 359,370 **** >>> d1 = Decimal("1e999999999") # at the exponent limit >>> d1 ! Decimal( (0, (1,), 999999999L) ) >>> d1 * 10 # exceed the limit, got infinity ! Decimal( (0, (0,), 'F') ) >>> getcontext().Emax = 1000000000 # increase the limit >>> d1 * 10 # does not exceed any more ! Decimal( (0, (1, 0), 999999999L) ) >>> d1 * 100 # exceed again ! Decimal( (0, (0,), 'F') ) --- 360,381 ---- >>> d1 = Decimal("1e999999999") # at the exponent limit >>> d1 ! Decimal("1E+999999999") >>> d1 * 10 # exceed the limit, got infinity ! Traceback (most recent call last): ! File "", line 1, in ? ! d1 * 10 ! ... ! ... ! Overflow: above Emax >>> getcontext().Emax = 1000000000 # increase the limit >>> d1 * 10 # does not exceed any more ! Decimal("1.0E+1000000000") >>> d1 * 100 # exceed again ! Traceback (most recent call last): ! File "", line 1, in ? ! d1 * 100 ! ... ! ... ! Overflow: above Emax *************** *** 690,701 **** >>> # create a standard decimal instance >>> Decimal("11.2233445566778899") ! Decimal( (0, (1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9), -16) ) >>> >>> # create a decimal instance using the thread context >>> thread_context = getcontext() >>> thread_context.prec ! 9 ! >>> thread_contex.create_decimal("11.2233445566778899") ! Decimal( (0, (1, 1, 2, 2, 3, 3, 4, 4, 6), -7L) ) >>> >>> # create a decimal instance using other context --- 701,712 ---- >>> # create a standard decimal instance >>> Decimal("11.2233445566778899") ! Decimal("11.2233445566778899") >>> >>> # create a decimal instance using the thread context >>> thread_context = getcontext() >>> thread_context.prec ! 28 ! >>> thread_context.create_decimal("11.2233445566778899") ! Decimal("11.2233445566778899") >>> >>> # create a decimal instance using other context *************** *** 703,707 **** >>> other_context.prec = 4 >>> other_context.create_decimal("11.2233445566778899") ! Decimal( (0, (1, 1, 2, 2), -2L) ) --- 714,718 ---- >>> other_context.prec = 4 >>> other_context.create_decimal("11.2233445566778899") ! Decimal("11.22") *************** *** 1169,1179 **** - power: ``power(d, n)`` ! The following methods are to support decimal functionality through ! Context: ! ! - ``divmod(d, n)`` ! - ``eq(d, d)`` ! - ``gt(d, d)`` ! - ``lt(d, d)`` These are methods that return useful information from the Context: --- 1180,1185 ---- - power: ``power(d, n)`` ! The ``divmod(d, n)`` method supports decimal functionality through ! Context. These are methods that return useful information from the Context: *************** *** 1199,1206 **** ======================== ! To be included later: ! - code ! - test code --- 1205,1216 ---- ======================== ! As of Python 2.4-alpha, the code has been checked into the standard ! library. The latest version is available from: ! http://cvs.sourceforge.net/viewcvs.py/python/python/dist/src/Lib/decimal.py ! ! The test cases are here: ! ! http://cvs.sourceforge.net/viewcvs.py/python/python/dist/src/Lib/test/test_decimal.py From heyU at mail-my-info.net Fri Jul 9 00:20:51 2004 From: heyU at mail-my-info.net (Hey, U! Magazine) Date: Fri Jul 9 00:20:39 2004 Subject: [Python-checkins] Preview the New Reality Magazine launching later this year. Message-ID: <20040708222037.4197E1E4004@bag.python.org> An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-checkins/attachments/20040708/32b9c14b/attachment.htm From rhettinger at users.sourceforge.net Fri Jul 9 06:10:23 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Fri Jul 9 06:10:25 2004 Subject: [Python-checkins] python/dist/src/Modules collectionsmodule.c, 1.18, 1.19 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16171/Modules Modified Files: collectionsmodule.c Log Message: * balance the left/right search for getitem. * use assertions instead of tests after internal calls that can't fail. * expand test coverage Index: collectionsmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/collectionsmodule.c,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** collectionsmodule.c 26 Jun 2004 04:42:06 -0000 1.18 --- collectionsmodule.c 9 Jul 2004 04:10:20 -0000 1.19 *************** *** 246,250 **** } Py_DECREF(it); ! if (PyErr_Occurred()) return NULL; Py_RETURN_NONE; --- 246,250 ---- } Py_DECREF(it); ! if (PyErr_Occurred()) return NULL; Py_RETURN_NONE; *************** *** 275,280 **** for (i=0 ; in ; i--) { item = deque_popleft(deque, NULL); ! if (item == NULL) ! return NULL; rv = deque_append(deque, item); Py_DECREF(item); --- 284,288 ---- for (i=0 ; i>n ; i--) { item = deque_popleft(deque, NULL); ! assert (item != NULL); rv = deque_append(deque, item); Py_DECREF(item); *************** *** 312,317 **** while (deque_len(deque)) { item = deque_pop(deque, NULL); ! if (item == NULL) ! return -1; Py_DECREF(item); } --- 310,314 ---- while (deque_len(deque)) { item = deque_pop(deque, NULL); ! assert (item != NULL); Py_DECREF(item); } *************** *** 389,394 **** item = deque_popleft(deque, NULL); ! if (item == NULL) ! goto fail; Py_DECREF(item); --- 386,390 ---- item = deque_popleft(deque, NULL); ! assert (item != NULL); Py_DECREF(item); *************** *** 410,416 **** PyObject *old_value; block *b; ! int n; ! if (i < 0 || i >= deque->len) { PyErr_SetString(PyExc_IndexError, "deque index out of range"); --- 406,412 ---- PyObject *old_value; block *b; ! int n, len=deque->len, halflen=(len+1)>>1, index=i; ! if (i < 0 || i >= len) { PyErr_SetString(PyExc_IndexError, "deque index out of range"); *************** *** 423,432 **** n = i / BLOCKLEN; i %= BLOCKLEN; ! if (i < (deque->len >> 1)) { b = deque->leftblock; while (n--) b = b->rightlink; } else { ! n = (deque->leftindex + deque->len - 1) / BLOCKLEN - n; b = deque->rightblock; while (n--) --- 419,428 ---- n = i / BLOCKLEN; i %= BLOCKLEN; ! if (index <= halflen) { b = deque->leftblock; while (n--) b = b->rightlink; } else { ! n = (deque->leftindex + len - 1) / BLOCKLEN - n; b = deque->rightblock; while (n--) *************** *** 443,448 **** deque_clearmethod(dequeobject *deque) { ! if (deque_clear(deque) == -1) ! return NULL; Py_RETURN_NONE; } --- 439,446 ---- deque_clearmethod(dequeobject *deque) { ! int rv; ! ! rv = deque_clear(deque); ! assert (rv != -1); Py_RETURN_NONE; } From rhettinger at users.sourceforge.net Fri Jul 9 06:10:23 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Fri Jul 9 06:10:30 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_deque.py,1.12,1.13 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16171/Lib/test Modified Files: test_deque.py Log Message: * balance the left/right search for getitem. * use assertions instead of tests after internal calls that can't fail. * expand test coverage Index: test_deque.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_deque.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** test_deque.py 30 May 2004 07:26:47 -0000 1.12 --- test_deque.py 9 Jul 2004 04:10:20 -0000 1.13 *************** *** 7,13 **** --- 7,18 ---- from cStringIO import StringIO import random + import os BIG = 100000 + def fail(): + raise SyntaxError + yield 1 + class TestBasic(unittest.TestCase): *************** *** 59,62 **** --- 64,71 ---- d.extendleft('bcd') self.assertEqual(list(d), list(reversed('abcd'))) + d = deque() + d.extendleft(range(1000)) + self.assertEqual(list(d), list(reversed(range(1000)))) + self.assertRaises(SyntaxError, d.extendleft, fail()) def test_getitem(self): *************** *** 152,155 **** --- 161,171 ---- self.assertEqual(tuple(d), tuple(e)) + self.assertRaises(TypeError, d.rotate, 'x') # Wrong arg type + self.assertRaises(TypeError, d.rotate, 1, 10) # Too many args + + d = deque() + d.rotate() # rotate an empty deque + self.assertEqual(d, deque()) + def test_len(self): d = deque('ab') *************** *** 179,182 **** --- 195,200 ---- self.assertEqual(len(d), 0) self.assertEqual(list(d), []) + d.clear() # clear an emtpy deque + self.assertEqual(list(d), []) def test_repr(self): *************** *** 190,197 **** d = deque(xrange(200)) d.append(d) ! f = StringIO() ! print >> f, d, ! self.assertEqual(f.getvalue(), repr(d)) ! f.close() def test_hash(self): --- 208,224 ---- d = deque(xrange(200)) d.append(d) ! try: ! fo = open(test_support.TESTFN, "wb") ! print >> fo, d, ! fo.close() ! fo = open(test_support.TESTFN, "rb") ! self.assertEqual(fo.read(), repr(d)) ! finally: ! fo.close() ! os.remove(test_support.TESTFN) ! ! def test_init(self): ! self.assertRaises(TypeError, deque, 'abc', 2); ! self.assertRaises(TypeError, deque, 1); def test_hash(self): From rhettinger at users.sourceforge.net Fri Jul 9 06:51:26 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Fri Jul 9 06:51:29 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_set.py,1.12,1.13 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26486 Modified Files: test_set.py Log Message: * fix the print test * add more __init__ tests Index: test_set.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_set.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** test_set.py 30 May 2004 07:26:47 -0000 1.12 --- test_set.py 9 Jul 2004 04:51:24 -0000 1.13 *************** *** 5,8 **** --- 5,9 ---- import copy import pickle + import os class PassThru(Exception): *************** *** 202,205 **** --- 203,208 ---- s.__init__(self.otherword) self.assertEqual(s, set(self.otherword)) + self.assertRaises(TypeError, s.__init__, s, 2); + self.assertRaises(TypeError, s.__init__, 1); def test_constructor_identity(self): *************** *** 437,440 **** --- 440,454 ---- self.assertEqual(repr(self.set), self.repr) + def test_print(self): + try: + fo = open(test_support.TESTFN, "wb") + print >> fo, self.set, + fo.close() + fo = open(test_support.TESTFN, "rb") + self.assertEqual(fo.read(), repr(self.set)) + finally: + fo.close() + os.remove(test_support.TESTFN) + def test_length(self): self.assertEqual(len(self.set), self.length) From rhettinger at users.sourceforge.net Fri Jul 9 08:00:41 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Fri Jul 9 08:00:45 2004 Subject: [Python-checkins] python/dist/src/Doc/tut tut.tex,1.238,1.239 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/tut In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11305 Modified Files: tut.tex Log Message: Add a link to the decimal module docs. Index: tut.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/tut/tut.tex,v retrieving revision 1.238 retrieving revision 1.239 diff -C2 -d -r1.238 -r1.239 *** tut.tex 8 Jul 2004 09:33:00 -0000 1.238 --- tut.tex 9 Jul 2004 06:00:32 -0000 1.239 *************** *** 5060,5071 **** \section{Decimal Floating Point Arithmetic\label{decimal-fp}} ! The \module{decimal} module offers a \class{Decimal} datatype for ! decimal floating point arithmetic. Compared to the built-in \class{float} ! implementation of binary floating point, the new class is especially ! helpful for financial applications and other uses which require exact ! decimal representation, control over precision, control over rounding ! to meet legal or regulatory requirements, tracking of significant ! decimal places, or for applications where the user expects the results ! to match hand calculations as taught in school. For example, calculating a 5\%{} tax on a 70 cent phone charge gives --- 5060,5071 ---- \section{Decimal Floating Point Arithmetic\label{decimal-fp}} ! The \ulink{\module{decimal}}{../lib/module-decimal.html} module offers a ! \class{Decimal} datatype for decimal floating point arithmetic. Compared to ! the built-in \class{float} implementation of binary floating point, the new ! class is especially helpful for financial applications and other uses which ! require exact decimal representation, control over precision, control over ! rounding to meet legal or regulatory requirements, tracking of significant ! decimal places, or for applications where the user expects the results to ! calculations done by hand. For example, calculating a 5\%{} tax on a 70 cent phone charge gives From rhettinger at users.sourceforge.net Fri Jul 9 08:13:15 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Fri Jul 9 08:13:18 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libdecimal.tex,1.8,1.9 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14194/doc/lib Modified Files: libdecimal.tex Log Message: Incorporate Facundo's suggestions. Index: libdecimal.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libdecimal.tex,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** libdecimal.tex 8 Jul 2004 09:22:33 -0000 1.8 --- libdecimal.tex 9 Jul 2004 06:13:12 -0000 1.9 *************** *** 16,20 **** \versionadded{2.4} ! The decimal \module{module} provides support for decimal floating point arithmetic. It offers several advantages over the \class{float()} datatype: --- 16,20 ---- \versionadded{2.4} ! The \module{decimal} module provides support for decimal floating point arithmetic. It offers several advantages over the \class{float()} datatype: *************** *** 90,94 **** For each signal there is a flag and a trap enabler. When a signal is encountered, its flag incremented from zero and, then, if the trap enabler ! is set to one, an exception is raised. --- 90,95 ---- For each signal there is a flag and a trap enabler. When a signal is encountered, its flag incremented from zero and, then, if the trap enabler ! is set to one, an exception is raised. Flags are sticky, so the user ! needs to reset them before monitoring a calculation. *************** *** 505,512 **** arithmetic operations in the context. ! The \var{rounding} option is one of: \constant{ROUND_CEILING}, ! \constant{ROUND_DOWN}, \constant{ROUND_FLOOR}, \constant{ROUND_HALF_DOWN} ! (towards zero), \constant{ROUND_HALF_EVEN}, \constant{ROUND_HALF_UP}, or ! \constant{ROUND_UP} (away from zero). The \var{trap_enablers} and \var{flags} fields are mappings from signals --- 506,517 ---- arithmetic operations in the context. ! The \var{rounding} option is one of: ! \constant{ROUND_CEILING} (towards \constant{Infinity}), ! \constant{ROUND_DOWN} (towards zero), ! \constant{ROUND_FLOOR} (towards \constant{-Infinity}), ! \constant{ROUND_HALF_DOWN} (towards zero), ! \constant{ROUND_HALF_EVEN}, ! \constant{ROUND_HALF_UP} (away from zero), or ! \constant{ROUND_UP} (away from zero). The \var{trap_enablers} and \var{flags} fields are mappings from signals From anthonybaxter at users.sourceforge.net Fri Jul 9 09:19:25 2004 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Fri Jul 9 09:19:28 2004 Subject: [Python-checkins] python/dist/src/Include patchlevel.h,2.76,2.77 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28504/Include Modified Files: patchlevel.h Log Message: post-release fun Index: patchlevel.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/patchlevel.h,v retrieving revision 2.76 retrieving revision 2.77 diff -C2 -d -r2.76 -r2.77 *** patchlevel.h 8 Jul 2004 03:59:33 -0000 2.76 --- patchlevel.h 9 Jul 2004 07:19:21 -0000 2.77 *************** *** 27,31 **** /* Version as a string */ ! #define PY_VERSION "2.4a1" /* Version as a single 4-byte hex number, e.g. 0x010502B2 == 1.5.2b2. --- 27,31 ---- /* Version as a string */ ! #define PY_VERSION "2.4a1+" /* Version as a single 4-byte hex number, e.g. 0x010502B2 == 1.5.2b2. From anthonybaxter at users.sourceforge.net Fri Jul 9 09:30:36 2004 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Fri Jul 9 09:30:38 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1025,1.1026 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30821/Misc Modified Files: NEWS Log Message: post-release fun Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1025 retrieving revision 1.1026 diff -C2 -d -r1.1025 -r1.1026 *** NEWS 8 Jul 2004 05:59:43 -0000 1.1025 --- NEWS 9 Jul 2004 07:30:10 -0000 1.1026 *************** *** 5,8 **** --- 5,53 ---- (editors: check NEWS.help for information about editing NEWS using ReST.) + What's New in Python 2.4 alpha 2? + ================================= + + *Release date: XX-XXX-2004* + + Core and builtins + ----------------- + + - Allow string and unicode return types from .encode()/.decode() + methods on string and unicode objects. Added unicode.decode() + which was missing for no apparent reason. + + - An attempt to fix the mess that is Python's behaviour with + signal handlers and threads, complicated by readline's behaviour. + It's quite possible that there are still bugs here. + + Extension modules + ----------------- + + Library + ------- + + Tools/Demos + ----------- + + Build + ----- + + C API + ----- + + New platforms + ------------- + + Tests + ----- + + Windows + ------- + + Mac + --- + + + What's New in Python 2.4 alpha 1? ================================= *************** *** 636,645 **** is equivalent to Py_BuildValue("(OOO)", a, b, c). - New platforms - ------------- - - Tests - ----- - Windows ------- --- 681,684 ---- *************** *** 654,660 **** the truncate() call was an input operation. SF bug 801631. - Mac - ---- - What's New in Python 2.3 final? --- 693,696 ---- From rhettinger at users.sourceforge.net Fri Jul 9 12:02:55 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Fri Jul 9 12:02:58 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_decimal.py,1.5,1.6 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28156/Lib/test Modified Files: test_decimal.py Log Message: Module and tests: * Map conditions to related signals. * Make contexts unhashable. * Eliminate used "default" attribute in exception definitions. * Eliminate the _filterfunc in favor of a straight list. Docs: * Eliminate documented references to conditions that are not signals. * Eliminate parenthetical notes such as "1/0 --> Inf" which are no longer true with the new defaults. Index: test_decimal.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_decimal.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** test_decimal.py 5 Jul 2004 22:53:03 -0000 1.5 --- test_decimal.py 9 Jul 2004 10:02:52 -0000 1.6 *************** *** 61,70 **** ErrorNames = {'clamped' : Clamped, ! 'conversion_syntax' : ConversionSyntax, 'division_by_zero' : DivisionByZero, ! 'division_impossible' : DivisionImpossible, ! 'division_undefined' : DivisionUndefined, 'inexact' : Inexact, ! 'invalid_context' : InvalidContext, 'invalid_operation' : InvalidOperation, 'overflow' : Overflow, --- 61,70 ---- ErrorNames = {'clamped' : Clamped, ! 'conversion_syntax' : InvalidOperation, 'division_by_zero' : DivisionByZero, ! 'division_impossible' : InvalidOperation, ! 'division_undefined' : InvalidOperation, 'inexact' : Inexact, ! 'invalid_context' : InvalidOperation, 'invalid_operation' : InvalidOperation, 'overflow' : Overflow, *************** *** 132,135 **** --- 132,136 ---- for line in open(file).xreadlines(): line = line.replace('\r\n', '').replace('\n', '') + #print line try: t = self.eval_line(line) *************** *** 649,653 **** def test_floor_division(self): - '''Test floor division in all its ways.''' d1 = Decimal('5') --- 650,653 ---- *************** *** 677,681 **** def test_powering(self): - '''Test powering in all its ways.''' d1 = Decimal('5') --- 677,680 ---- From rhettinger at users.sourceforge.net Fri Jul 9 12:02:55 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Fri Jul 9 12:02:59 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libdecimal.tex,1.9,1.10 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28156/Doc/lib Modified Files: libdecimal.tex Log Message: Module and tests: * Map conditions to related signals. * Make contexts unhashable. * Eliminate used "default" attribute in exception definitions. * Eliminate the _filterfunc in favor of a straight list. Docs: * Eliminate documented references to conditions that are not signals. * Eliminate parenthetical notes such as "1/0 --> Inf" which are no longer true with the new defaults. Index: libdecimal.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libdecimal.tex,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** libdecimal.tex 9 Jul 2004 06:13:12 -0000 1.9 --- libdecimal.tex 9 Jul 2004 10:02:52 -0000 1.10 *************** *** 67,74 **** exponent. To preserve significance, the coefficient digits do not truncate trailing zeroes. Decimals also include special values such as ! \constant{Infinity} (the result of \samp{1 / 0}), \constant{-Infinity}, ! (the result of \samp{-1 / 0}), and \constant{NaN} (the result of ! \samp{0 / 0}). The standard also differentiates \constant{-0} from ! \constant{+0}. The context for arithmetic is an environment specifying precision, rounding --- 67,72 ---- exponent. To preserve significance, the coefficient digits do not truncate trailing zeroes. Decimals also include special values such as ! \constant{Infinity}, \constant{-Infinity}, and \constant{NaN}. The standard ! also differentiates \constant{-0} from \constant{+0}. The context for arithmetic is an environment specifying precision, rounding *************** *** 83,89 **** ignored, considered as informational, or treated as exceptions. The signals in the decimal module are: \constant{Clamped}, \constant{InvalidOperation}, ! \constant{ConversionSyntax}, \constant{DivisionByZero}, ! \constant{DivisionImpossible}, \constant{DivisionUndefined}, ! \constant{Inexact}, \constant{InvalidContext}, \constant{Rounded}, \constant{Subnormal}, \constant{Overflow}, and \constant{Underflow}. --- 81,85 ---- ignored, considered as informational, or treated as exceptions. The signals in the decimal module are: \constant{Clamped}, \constant{InvalidOperation}, ! \constant{DivisionByZero}, \constant{Inexact}, \constant{Rounded}, \constant{Subnormal}, \constant{Overflow}, and \constant{Underflow}. *************** *** 125,129 **** create a Decimal from a \class{float}, first convert it to a string. This serves as an explicit reminder of the details of the conversion (including ! representation error). Malformed strings signal \constant{ConversionSyntax} and return a special kind of Decimal called a \constant{NaN} which stands for ``Not a number''. Positive and negative \constant{Infinity} is yet another --- 121,125 ---- create a Decimal from a \class{float}, first convert it to a string. This serves as an explicit reminder of the details of the conversion (including ! representation error). Malformed strings signal \constant{InvalidOperation} and return a special kind of Decimal called a \constant{NaN} which stands for ``Not a number''. Positive and negative \constant{Infinity} is yet another *************** *** 275,282 **** >>> getcontext() Context(prec=9, rounding=ROUND_HALF_EVEN, Emin=-999999999, Emax=999999999, ! setflags=[], settraps=['Underflow', 'DecimalException', 'Clamped', ! 'InvalidContext', 'InvalidOperation', 'ConversionSyntax', ! 'DivisionByZero', 'DivisionImpossible', 'DivisionUndefined', ! 'Overflow']) \end{verbatim} --- 271,276 ---- >>> getcontext() Context(prec=9, rounding=ROUND_HALF_EVEN, Emin=-999999999, Emax=999999999, ! setflags=[], settraps=['Clamped', 'Underflow', 'InvalidOperation', ! 'DivisionByZero', 'Overflow']) \end{verbatim} *************** *** 321,325 **** The supplied \var{context} or, if not specified, the current context governs only the handling of malformed strings not conforming to the ! numeric string syntax. If the context traps \constant{ConversionSyntax}, an exception is raised; otherwise, the constructor returns a new Decimal with the value of \constant{NaN}. --- 315,319 ---- The supplied \var{context} or, if not specified, the current context governs only the handling of malformed strings not conforming to the ! numeric string syntax. If the context traps \constant{InvalidOperation}, an exception is raised; otherwise, the constructor returns a new Decimal with the value of \constant{NaN}. *************** *** 731,741 **** \end{classdesc*} - \begin{classdesc*}{ConversionSyntax} - Trying to convert a malformed string such as: \code{Decimal('jump')}. - - Decimal converts only strings conforming to the numeric string - syntax. If this signal is not trapped, returns \constant{NaN}. - \end{classdesc*} - \begin{classdesc*}{DecimalException} Base class for other signals. --- 725,728 ---- *************** *** 751,767 **** \end{classdesc*} - \begin{classdesc*}{DivisionImpossible} - Error performing a division operation. Caused when an intermediate result - has more digits that the allowed by the current precision. If not trapped, - returns \constant{NaN}. - \end{classdesc*} - - - \begin{classdesc*}{DivisionUndefined} - This is a subclass of \class{DivisionByZero}. - - It occurs only in the context of division operations. - \end{classdesc*} - \begin{classdesc*}{Inexact} Indicates that rounding occurred and the result is not exact. --- 738,741 ---- *************** *** 772,783 **** \end{classdesc*} - - \begin{classdesc*}{InvalidContext} - This is a subclass of \class{InvalidOperation}. - - Indicates an error within the Context object such as an unknown - rounding operation. If not trapped, returns \constant{NaN}. - \end{classdesc*} - \begin{classdesc*}{InvalidOperation} An invalid operation was performed. --- 746,749 ---- *************** *** 810,814 **** \end{classdesc*} - \begin{classdesc*}{Rounded} Rounding occurred though possibly no information was lost. --- 776,779 ---- *************** *** 845,852 **** Underflow(Inexact, Rounded, Subnormal) InvalidOperation - ConversionSyntax - DivisionImpossible - DivisionUndefined(InvalidOperation, exceptions.ZeroDivisionError) - InvalidContext Rounded Subnormal --- 810,813 ---- *************** *** 854,858 **** - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \subsection{Working with threads \label{decimal-threads}} --- 815,818 ---- From rhettinger at users.sourceforge.net Fri Jul 9 12:02:57 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Fri Jul 9 12:03:01 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1026,1.1027 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28156/Misc Modified Files: NEWS Log Message: Module and tests: * Map conditions to related signals. * Make contexts unhashable. * Eliminate used "default" attribute in exception definitions. * Eliminate the _filterfunc in favor of a straight list. Docs: * Eliminate documented references to conditions that are not signals. * Eliminate parenthetical notes such as "1/0 --> Inf" which are no longer true with the new defaults. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1026 retrieving revision 1.1027 diff -C2 -d -r1.1026 -r1.1027 *** NEWS 9 Jul 2004 07:30:10 -0000 1.1026 --- NEWS 9 Jul 2004 10:02:53 -0000 1.1027 *************** *** 27,30 **** --- 27,33 ---- ------- + - decimal.py now only uses signals in the spec. The other conditions are + no longer part of the public API. + Tools/Demos ----------- From rhettinger at users.sourceforge.net Fri Jul 9 12:03:29 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Fri Jul 9 12:03:31 2004 Subject: [Python-checkins] python/dist/src/Lib decimal.py,1.12,1.13 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28156/Lib Modified Files: decimal.py Log Message: Module and tests: * Map conditions to related signals. * Make contexts unhashable. * Eliminate used "default" attribute in exception definitions. * Eliminate the _filterfunc in favor of a straight list. Docs: * Eliminate documented references to conditions that are not signals. * Eliminate parenthetical notes such as "1/0 --> Inf" which are no longer true with the new defaults. Index: decimal.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/decimal.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** decimal.py 8 Jul 2004 00:49:18 -0000 1.12 --- decimal.py 9 Jul 2004 10:02:51 -0000 1.13 *************** *** 79,92 **** DivisionByZero: x / 0 >>> c = Context() ! >>> c.trap_enablers[DivisionUndefined] = 0 ! >>> print c.flags[DivisionUndefined] 0 >>> c.divide(Decimal(0), Decimal(0)) Decimal("NaN") ! >>> c.trap_enablers[DivisionUndefined] = 1 ! >>> print c.flags[DivisionUndefined] 1 ! >>> c.flags[DivisionUndefined] = 0 ! >>> print c.flags[DivisionUndefined] 0 >>> print c.divide(Decimal(0), Decimal(0)) --- 79,92 ---- DivisionByZero: x / 0 >>> c = Context() ! >>> c.trap_enablers[InvalidOperation] = 0 ! >>> print c.flags[InvalidOperation] 0 >>> c.divide(Decimal(0), Decimal(0)) Decimal("NaN") ! >>> c.trap_enablers[InvalidOperation] = 1 ! >>> print c.flags[InvalidOperation] 1 ! >>> c.flags[InvalidOperation] = 0 ! >>> print c.flags[InvalidOperation] 0 >>> print c.divide(Decimal(0), Decimal(0)) *************** *** 95,106 **** ... ... ! DivisionUndefined: 0 / 0 ! >>> print c.flags[DivisionUndefined] 1 ! >>> c.flags[DivisionUndefined] = 0 ! >>> c.trap_enablers[DivisionUndefined] = False >>> print c.divide(Decimal(0), Decimal(0)) NaN ! >>> print c.flags[DivisionUndefined] 1 >>> --- 95,106 ---- ... ... ! InvalidOperation: 0 / 0 ! >>> print c.flags[InvalidOperation] 1 ! >>> c.flags[InvalidOperation] = 0 ! >>> c.trap_enablers[InvalidOperation] = 0 >>> print c.divide(Decimal(0), Decimal(0)) NaN ! >>> print c.flags[InvalidOperation] 1 >>> *************** *** 153,157 **** class DecimalException(ArithmeticError): ! """Base exception class, defines default things. Used exceptions derive from this. --- 153,157 ---- class DecimalException(ArithmeticError): ! """Base exception class. Used exceptions derive from this. *************** *** 161,170 **** anything, though. - Attributes: - - default -- If the context is basic, the trap_enablers are set to - this by default. Extended contexts start out with them set - to 0, regardless. - handle -- Called when context._raise_error is called and the trap_enabler is set. First argument is self, second is the --- 161,164 ---- *************** *** 177,181 **** from DecimalException. """ - default = 1 def handle(self, context, *args): pass --- 171,174 ---- *************** *** 289,293 **** operation (or sequence of operations) was inexact. """ ! default = 0 class InvalidContext(InvalidOperation): --- 282,286 ---- operation (or sequence of operations) was inexact. """ ! pass class InvalidContext(InvalidOperation): *************** *** 316,320 **** operation (or sequence of operations) caused a loss of precision. """ ! default = 0 class Subnormal(DecimalException): --- 309,313 ---- operation (or sequence of operations) caused a loss of precision. """ ! pass class Subnormal(DecimalException): *************** *** 383,399 **** """ ! def _filterfunc(obj): ! """Returns true if a subclass of DecimalException""" ! try: ! return issubclass(obj, DecimalException) ! except TypeError: ! return False ! ! #Signals holds the exceptions ! Signals = filter(_filterfunc, globals().values()) ! ! del _filterfunc ! ##### Context Functions ####################################### --- 376,388 ---- """ + # List of public traps and flags + Signals = [Clamped, DivisionByZero, Inexact, Overflow, Rounded, + Underflow, InvalidOperation, Subnormal] ! # Map conditions (per the spec) to signals ! _condition_map = {ConversionSyntax:InvalidOperation, ! DivisionImpossible:InvalidOperation, ! DivisionUndefined:InvalidOperation, ! InvalidContext:InvalidOperation} ##### Context Functions ####################################### *************** *** 2169,2173 **** __copy__ = copy ! def _raise_error(self, error, explanation = None, *args): """Handles an error --- 2158,2162 ---- __copy__ = copy ! def _raise_error(self, condition, explanation = None, *args): """Handles an error *************** *** 2177,2180 **** --- 2166,2170 ---- the default value after incrementing the flag. """ + error = _condition_map.get(condition, condition) if error in self._ignored_flags: #Don't touch the flag *************** *** 2184,2188 **** if not self.trap_enablers[error]: #The errors define how to handle themselves. ! return error().handle(self, *args) # Errors should only be risked on copies of the context --- 2174,2178 ---- if not self.trap_enablers[error]: #The errors define how to handle themselves. ! return condition().handle(self, *args) # Errors should only be risked on copies of the context *************** *** 2208,2211 **** --- 2198,2206 ---- self._ignored_flags.remove(flag) + def __hash__(self): + """A Context cannot be hashed.""" + # We inherit object.__hash__, so we must deny this explicitly + raise TypeError, "Cannot hash a Context." + def Etiny(self): """Returns Etiny (= Emin - prec + 1)""" From rhettinger at users.sourceforge.net Fri Jul 9 12:52:58 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Fri Jul 9 12:53:01 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_decimal.py,1.6,1.7 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2966/test Modified Files: test_decimal.py Log Message: * Update the test suite to reflect that ConversionSyntax was no longer public. * Removed the non-signal conditions from __all__. * Removed the XXX comment which was resolved. * Use ^ instead of operator.xor * Remove the threading lock which is no longer necessary. Index: test_decimal.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_decimal.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** test_decimal.py 9 Jul 2004 10:02:52 -0000 1.6 --- test_decimal.py 9 Jul 2004 10:52:54 -0000 1.7 *************** *** 135,139 **** try: t = self.eval_line(line) ! except ConversionSyntax: print 'Error in test cases:' print line --- 135,139 ---- try: t = self.eval_line(line) ! except InvalidOperation: print 'Error in test cases:' print line *************** *** 190,194 **** exceptions = L[1:] except (TypeError, AttributeError, IndexError): ! raise ConversionSyntax def FixQuotes(val): val = val.replace("''", 'SingleQuote').replace('""', 'DoubleQuote') --- 190,194 ---- exceptions = L[1:] except (TypeError, AttributeError, IndexError): ! raise InvalidOperation def FixQuotes(val): val = val.replace("''", 'SingleQuote').replace('""', 'DoubleQuote') From rhettinger at users.sourceforge.net Fri Jul 9 12:52:58 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Fri Jul 9 12:53:02 2004 Subject: [Python-checkins] python/dist/src/Lib decimal.py,1.13,1.14 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2966 Modified Files: decimal.py Log Message: * Update the test suite to reflect that ConversionSyntax was no longer public. * Removed the non-signal conditions from __all__. * Removed the XXX comment which was resolved. * Use ^ instead of operator.xor * Remove the threading lock which is no longer necessary. Index: decimal.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/decimal.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** decimal.py 9 Jul 2004 10:02:51 -0000 1.13 --- decimal.py 9 Jul 2004 10:52:54 -0000 1.14 *************** *** 115,122 **** # Exceptions ! 'DecimalException', 'Clamped', 'InvalidOperation', 'ConversionSyntax', ! 'DivisionByZero', 'DivisionImpossible', 'DivisionUndefined', ! 'Inexact', 'InvalidContext', 'Rounded', 'Subnormal', 'Overflow', ! 'Underflow', # Constants for use in setting up contexts --- 115,120 ---- # Exceptions ! 'DecimalException', 'Clamped', 'InvalidOperation', 'DivisionByZero', ! 'Inexact', 'Rounded', 'Subnormal', 'Overflow', 'Underflow', # Constants for use in setting up contexts *************** *** 212,221 **** return NaN - # XXX Is there a logic error in subclassing InvalidOperation? - # Setting the InvalidOperation trap to zero does not preclude ConversionSyntax. - # Also, incrementing Conversion syntax flag will not increment InvalidOperation. - # Both of these issues interfere with cross-language portability because - # code following the spec would not know about the Python subclasses. - class ConversionSyntax(InvalidOperation): """Trying to convert badly formed string. --- 210,213 ---- *************** *** 1033,1037 **** return ans ! resultsign = operator.xor(self._sign, other._sign) if self._isinfinity(): if not other: --- 1025,1029 ---- return ans ! resultsign = self._sign ^ other._sign if self._isinfinity(): if not other: *************** *** 1127,1131 **** return ans ! sign = operator.xor(self._sign, other._sign) if not self and not other: if divmod: --- 1119,1123 ---- return ans ! sign = self._sign ^ other._sign if not self and not other: if divmod: *************** *** 2118,2123 **** """ - DefaultLock = threading.Lock() - def __init__(self, prec=None, rounding=None, trap_enablers=None, flags=None, --- 2110,2113 ---- *************** *** 2128,2132 **** if flags is None: flags = dict.fromkeys(Signals, 0) - self.DefaultLock.acquire() for name, val in locals().items(): if val is None: --- 2118,2121 ---- *************** *** 2134,2138 **** else: setattr(self, name, val) - self.DefaultLock.release() del self.self --- 2123,2126 ---- From rhettinger at users.sourceforge.net Fri Jul 9 16:26:20 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Fri Jul 9 16:26:23 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_random.py, 1.16, 1.17 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9193 Modified Files: test_random.py Log Message: Add some tests for corner cases. Index: test_random.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_random.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** test_random.py 16 Nov 2003 16:17:48 -0000 1.16 --- test_random.py 9 Jul 2004 14:26:18 -0000 1.17 *************** *** 40,43 **** --- 40,45 ---- for arg in [range(3), dict(one=1)]: self.assertRaises(TypeError, self.gen.seed, arg) + self.assertRaises(TypeError, self.gen.seed, 1, 2) + self.assertRaises(TypeError, type(self.gen), []) def test_jumpahead(self): *************** *** 123,126 **** --- 125,131 ---- gen = random.WichmannHill() + def test_setstate_first_arg(self): + self.assertRaises(ValueError, self.gen.setstate, (2, None, None)) + def test_strong_jumpahead(self): # tests that jumpahead(n) semantics correspond to n calls to random() *************** *** 163,166 **** --- 168,184 ---- gen = random.Random() + def test_setstate_first_arg(self): + self.assertRaises(ValueError, self.gen.setstate, (1, None, None)) + + def test_setstate_middle_arg(self): + # Wrong type, s/b tuple + self.assertRaises(TypeError, self.gen.setstate, (2, None, None)) + # Wrong length, s/b 625 + self.assertRaises(ValueError, self.gen.setstate, (2, (1,2,3), None)) + # Wrong type, s/b tuple of 625 ints + self.assertRaises(TypeError, self.gen.setstate, (2, ('a',)*625, None)) + # Last element s/b an int also + self.assertRaises(TypeError, self.gen.setstate, (2, (0,)*624+('a',), None)) + def test_referenceImplementation(self): # Compare the python implementation with results from the original *************** *** 211,215 **** 0x02dad977c9e1feL, 0x191d96d4d334c6L] - self.gen.seed(61731L + (24903L<<32) + (614L<<64) + (42143L<<96)) actual = self.randomlist(2000)[-10:] --- 229,232 ---- *************** *** 275,278 **** --- 292,302 ---- self.assertEqual(cum, 2**span-1) + # Verify argument checking + self.assertRaises(TypeError, self.gen.getrandbits) + self.assertRaises(TypeError, self.gen.getrandbits, 'a') + self.assertRaises(TypeError, self.gen.getrandbits, 1, 2) + self.assertRaises(ValueError, self.gen.getrandbits, 0) + self.assertRaises(ValueError, self.gen.getrandbits, -1) + def test_randbelow_logic(self, _log=log, int=int): # check bitcount transition points: 2**i and 2**(i+1)-1 From anthonybaxter at users.sourceforge.net Fri Jul 9 18:16:49 2004 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Fri Jul 9 18:16:52 2004 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew24.tex, 1.63, 1.64 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32006 Modified Files: whatsnew24.tex Log Message: reminder for amk Index: whatsnew24.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew24.tex,v retrieving revision 1.63 retrieving revision 1.64 diff -C2 -d -r1.63 -r1.64 *** whatsnew24.tex 7 Jul 2004 13:01:53 -0000 1.63 --- whatsnew24.tex 9 Jul 2004 16:16:46 -0000 1.64 *************** *** 635,638 **** --- 635,640 ---- \begin{itemize} + % XXX new email parser + \item The \module{asyncore} module's \function{loop()} now has a \var{count} parameter that lets you perform a limited number From mcnos at yahoo.com Fri Jul 9 21:05:59 2004 From: mcnos at yahoo.com (Home improvement second mtg equity loans) Date: Fri Jul 9 20:06:09 2004 Subject: [Python-checkins] Consolidation information In-Reply-To: <20040330185343.752B3965@yahoo.com> Message-ID: Skipped content of type multipart/alternative-------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: image/gif Size: 2545 bytes Desc: not available Url : http://mail.python.org/pipermail/python-checkins/attachments/20040709/b76e1c08/attachment.gif From nnorwitz at users.sourceforge.net Sat Jul 10 01:31:01 2004 From: nnorwitz at users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Sat Jul 10 01:31:07 2004 Subject: [Python-checkins] python/dist/src/Modules _bsddb.c,1.35,1.36 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5334/Modules Modified Files: _bsddb.c Log Message: Cleanup support for older pythons (perhaps it should be removed?) Index: _bsddb.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_bsddb.c,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** _bsddb.c 28 Jun 2004 04:06:47 -0000 1.35 --- _bsddb.c 9 Jul 2004 23:30:57 -0000 1.36 *************** *** 202,205 **** --- 202,211 ---- #endif + #if PYTHON_API_VERSION <= 1007 + /* 1.5 compatibility */ + #define PyObject_New PyObject_NEW + #define PyObject_Del PyMem_DEL + #endif + struct behaviourFlags { /* What is the default behaviour when DB->get or DBCursor->get returns a *************** *** 698,708 **** int err; - #if PYTHON_API_VERSION <= 1007 - /* 1.5 compatibility */ - self = PyObject_NEW(DBObject, &DB_Type); - #else self = PyObject_New(DBObject, &DB_Type); - #endif - if (self == NULL) return NULL; --- 704,708 ---- *************** *** 789,797 **** } #endif - #if PYTHON_API_VERSION <= 1007 - PyMem_DEL(self); - #else PyObject_Del(self); - #endif } --- 789,793 ---- *************** *** 800,809 **** newDBCursorObject(DBC* dbc, DBObject* db) { ! DBCursorObject* self; ! #if PYTHON_API_VERSION <= 1007 ! self = PyObject_NEW(DBCursorObject, &DBCursor_Type); ! #else ! self = PyObject_New(DBCursorObject, &DBCursor_Type); ! #endif if (self == NULL) return NULL; --- 796,800 ---- newDBCursorObject(DBC* dbc, DBObject* db) { ! DBCursorObject* self = PyObject_New(DBCursorObject, &DBCursor_Type); if (self == NULL) return NULL; *************** *** 845,853 **** } Py_XDECREF( self->mydb ); - #if PYTHON_API_VERSION <= 1007 - PyMem_DEL(self); - #else PyObject_Del(self); - #endif } --- 836,840 ---- *************** *** 857,867 **** { int err; ! DBEnvObject* self; ! #if PYTHON_API_VERSION <= 1007 ! self = PyObject_NEW(DBEnvObject, &DBEnv_Type); ! #else ! self = PyObject_New(DBEnvObject, &DBEnv_Type); ! #endif ! if (self == NULL) return NULL; --- 844,848 ---- { int err; ! DBEnvObject* self = PyObject_New(DBEnvObject, &DBEnv_Type); if (self == NULL) return NULL; *************** *** 902,910 **** MYDB_END_ALLOW_THREADS; } - #if PYTHON_API_VERSION <= 1007 - PyMem_DEL(self); - #else PyObject_Del(self); - #endif } --- 883,887 ---- *************** *** 914,924 **** { int err; ! DBTxnObject* self; ! ! #if PYTHON_API_VERSION <= 1007 ! self = PyObject_NEW(DBTxnObject, &DBTxn_Type); ! #else ! self = PyObject_New(DBTxnObject, &DBTxn_Type); ! #endif if (self == NULL) return NULL; --- 891,895 ---- { int err; ! DBTxnObject* self = PyObject_New(DBTxnObject, &DBTxn_Type); if (self == NULL) return NULL; *************** *** 968,976 **** #endif - #if PYTHON_API_VERSION <= 1007 - PyMem_DEL(self); - #else PyObject_Del(self); - #endif } --- 939,943 ---- *************** *** 981,991 **** { int err; ! DBLockObject* self; ! ! #if PYTHON_API_VERSION <= 1007 ! self = PyObject_NEW(DBLockObject, &DBLock_Type); ! #else ! self = PyObject_New(DBLockObject, &DBLock_Type); ! #endif if (self == NULL) return NULL; --- 948,952 ---- { int err; ! DBLockObject* self = PyObject_New(DBLockObject, &DBLock_Type); if (self == NULL) return NULL; *************** *** 1020,1028 **** /* TODO: is this lock held? should we release it? */ - #if PYTHON_API_VERSION <= 1007 - PyMem_DEL(self); - #else PyObject_Del(self); - #endif } --- 981,985 ---- From nnorwitz at users.sourceforge.net Sat Jul 10 01:33:09 2004 From: nnorwitz at users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Sat Jul 10 01:33:16 2004 Subject: [Python-checkins] python/dist/src/Modules _bsddb.c,1.36,1.37 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5830/Modules Modified Files: _bsddb.c Log Message: Fix memory leak and bump the version per Greg Index: _bsddb.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_bsddb.c,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** _bsddb.c 9 Jul 2004 23:30:57 -0000 1.36 --- _bsddb.c 9 Jul 2004 23:33:06 -0000 1.37 *************** *** 98,102 **** #endif ! #define PY_BSDDB_VERSION "4.2.8" static char *rcs_id = "$Id$"; --- 98,102 ---- #endif ! #define PY_BSDDB_VERSION "4.2.9" static char *rcs_id = "$Id$"; *************** *** 878,882 **** #endif ! if (!self->closed) { MYDB_BEGIN_ALLOW_THREADS; self->db_env->close(self->db_env, 0); --- 878,882 ---- #endif ! if (self->db_env) { MYDB_BEGIN_ALLOW_THREADS; self->db_env->close(self->db_env, 0); From bcannon at users.sourceforge.net Sat Jul 10 01:38:20 2004 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Sat Jul 10 01:38:23 2004 Subject: [Python-checkins] python/dist/src/Lib site.py,1.62,1.63 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6580/Lib Modified Files: site.py Log Message: Change argument list for addsitedir() to not require a second argument and thus match old verion's argument list (overlooked since API of the file is undocumented). Index: site.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/site.py,v retrieving revision 1.62 retrieving revision 1.63 diff -C2 -d -r1.62 -r1.63 *** site.py 7 Jul 2004 20:54:45 -0000 1.62 --- site.py 9 Jul 2004 23:38:18 -0000 1.63 *************** *** 146,150 **** return known_paths ! def addsitedir(sitedir, known_paths): """Add 'sitedir' argument to sys.path if missing and handle .pth files in 'sitedir'""" --- 146,150 ---- return known_paths ! def addsitedir(sitedir, known_paths=None): """Add 'sitedir' argument to sys.path if missing and handle .pth files in 'sitedir'""" From fibicfnhvyzj at pobox.sk Sat Jul 10 03:39:39 2004 From: fibicfnhvyzj at pobox.sk (Online University ) Date: Sat Jul 10 02:45:58 2004 Subject: [Python-checkins] Improved Earning Strength -exploration foolproof Message-ID: According to the U.S. Census Bureau, with the following dgeres, here's how much you can expect to make in your lifetime: ------------------------------------------------------ Dgeree | Doller Earning High Shcool Dpiolma .....11,000,00 Bcaeholr's Dgeree .......21,000,00 Msaetr's Dgeere..........25,000,00 Dcootarte ...............44,000,00 If you are like most people you're more than qauilifed with your epxreeicne, but you are lacking that prestigious piece of paper known as a dpiolma that is often the passport to scuecss. Don't you think that it is time you were paid fair compensation for the level of work you are already doing? This is your chance to finally make the right move and receive your due benefits. If you want a better dgeere, we can help! --------------------------------------------------------- DIAL 1-707-221-7573 TODAY, AND GIVE YOUR LIFE A CHANCE! From bcannon at users.sourceforge.net Sat Jul 10 02:57:39 2004 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Sat Jul 10 02:57:42 2004 Subject: [Python-checkins] python/dist/src/Modules nismodule.c,2.24,2.25 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18274/Modules Modified Files: nismodule.c Log Message: Add an #ifdef __APPLE__ around typedef of foreachfunc to match Apple's incorrect declaration for ypall_callback in /usr/include/rpcsvc/ypcInt.h . Shouldn't hurt any code since the differences are unsigned long instead of int and void * instead of char *. Removes warning about improper function pointer assignment during compilation. Index: nismodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/nismodule.c,v retrieving revision 2.24 retrieving revision 2.25 diff -C2 -d -r2.24 -r2.25 *** nismodule.c 4 Nov 2002 23:21:09 -0000 2.24 --- nismodule.c 10 Jul 2004 00:57:37 -0000 2.25 *************** *** 69,73 **** --- 69,77 ---- } + #ifdef __APPLE__ + typedef int (*foreachfunc)(unsigned long, char *, int, char *, int, void *); + #else typedef int (*foreachfunc)(int, char *, int, char *, int, char *); + #endif struct ypcallback_data { From bcannon at users.sourceforge.net Sat Jul 10 04:10:48 2004 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Sat Jul 10 04:10:51 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_site.py,1.3,1.4 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29411/Lib/test Modified Files: test_site.py Log Message: Restructure testing of .pth files. Move previous functions into a class and create a testing method that can be called to make sure that the handling of the .pth file was correct. Index: test_site.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_site.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** test_site.py 27 Jun 2004 03:02:18 -0000 1.3 --- test_site.py 10 Jul 2004 02:10:45 -0000 1.4 *************** *** 6,10 **** """ import unittest ! from test.test_support import TestSkipped, run_unittest, TESTFN import __builtin__ import os --- 6,10 ---- """ import unittest ! from test.test_support import TestSkipped, TestFailed, run_unittest, TESTFN import __builtin__ import os *************** *** 59,107 **** def test_addpackage(self): # Make sure addpackage() imports if the line starts with 'import', ! # otherwise add a directory combined from sitedir and 'name'. ! # Must also skip comment lines. ! dir_path, file_name, new_dir = createpth() try: ! site.addpackage(dir_path, file_name, set()) ! self.failUnless(site.makepath(os.path.join(dir_path, new_dir))[0] in ! sys.path) finally: ! cleanuppth(dir_path, file_name, new_dir) def test_addsitedir(self): ! dir_path, file_name, new_dir = createpth() try: ! site.addsitedir(dir_path, set()) ! self.failUnless(site.makepath(os.path.join(dir_path, new_dir))[0] in ! sys.path) finally: ! cleanuppth(dir_path, file_name, new_dir) ! def createpth(): ! """Create a temporary .pth file at the returned location and return the ! directory where it was created, the pth file name, and the directory ! specified in the pth file. ! Make sure to delete the file when finished. ! """ ! pth_dirname = "__testdir__" ! file_name = TESTFN + ".pth" ! full_dirname = os.path.dirname(os.path.abspath(file_name)) ! FILE = file(os.path.join(full_dirname, file_name), 'w') ! try: ! print>>FILE, "#import @bad module name" ! print>>FILE, '' ! print>>FILE, "import os" ! print>>FILE, pth_dirname ! finally: ! FILE.close() ! os.mkdir(os.path.join(full_dirname, pth_dirname)) ! return full_dirname, file_name, pth_dirname - def cleanuppth(full_dirname, file_name, pth_dirname): - """Clean up what createpth() made""" - os.remove(os.path.join(full_dirname, file_name)) - os.rmdir(os.path.join(full_dirname, pth_dirname)) class ImportSideEffectTests(unittest.TestCase): --- 59,152 ---- def test_addpackage(self): # Make sure addpackage() imports if the line starts with 'import', ! # adds directories to sys.path for any line in the file that is not a ! # comment or import that is a valid directory name for where the .pth ! # file resides; invalid directories are not added ! pth_file = PthFile() ! pth_file.cleanup() # to make sure that nothing is pre-existing that ! # shouldn't be try: ! pth_file.create() ! site.addpackage(pth_file.base_dir, pth_file.filename, set()) ! unittest.FunctionTestCase(pth_file.test) finally: ! pth_file.cleanup() def test_addsitedir(self): ! # Same tests for test_addpackage since addsitedir() essentially just ! # calls addpackage() for every .pth file in the directory ! pth_file = PthFile() ! pth_file.cleanup() # Make sure that nothing is pre-existing that is ! # tested for try: ! site.addsitedir(pth_file.base_dir, set()) ! unittest.FunctionTestCase(pth_file.test) finally: ! pth_file.cleanup() ! class PthFile(object): ! """Helper class for handling testing of .pth files""" ! def __init__(self, filename_base=TESTFN, imported="time", ! good_dirname="__testdir__", bad_dirname="__bad"): ! """Initialize instance variables""" ! self.filename = filename_base + ".pth" ! self.base_dir = os.path.abspath('') ! self.file_path = os.path.join(self.base_dir, self.filename) ! self.imported = "time" ! self.good_dirname = good_dirname ! self.bad_dirname = bad_dirname ! self.good_dir_path = os.path.join(self.base_dir, self.good_dirname) ! self.bad_dir_path = os.path.join(self.base_dir, self.bad_dirname) ! def create(self): ! """Create a .pth file with a comment, blank lines, an ``import ! ``, a line with self.good_dirname, and a line with ! self.bad_dirname. ! ! Creation of the directory for self.good_dir_path (based off of ! self.good_dirname) is also performed. ! ! Make sure to call self.cleanup() to undo anything done by this method. ! ! """ ! FILE = open(self.file_path, 'wU') ! try: ! print>>FILE, "#import @bad module name" ! print>>FILE, "\n" ! print>>FILE, "import %s" % self.imported ! print>>FILE, self.good_dirname ! print>>FILE, self.bad_dirname ! finally: ! FILE.close() ! os.mkdir(self.good_dir_path) ! ! def cleanup(self): ! """Make sure that the .pth file is deleted, self.imported is not in ! sys.modules, and that both self.good_dirname and self.bad_dirname are ! not existing directories.""" ! try: ! os.remove(self.file_path) ! except OSError: ! pass ! try: ! del sys.modules[self.imported] ! except KeyError: ! pass ! try: ! os.rmdir(self.good_dir_path) ! except OSError: ! pass ! try: ! os.rmdir(self.bad_dir_path) ! except OSError: ! pass ! ! def test(self): ! """Test to make sure that was and was not supposed to be created by ! using the .pth file occurred""" ! assert site.makepath(self.good_dir_path)[0] in sys.path ! assert self.imported in sys.modules ! assert not os.path.exists(self.bad_dir_path) class ImportSideEffectTests(unittest.TestCase): From rhettinger at users.sourceforge.net Sat Jul 10 13:11:18 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Jul 10 13:11:24 2004 Subject: [Python-checkins] python/dist/src/Doc/inst inst.tex,1.54,1.55 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/inst In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1611 Modified Files: inst.tex Log Message: SF bug 988387: markup nits. Index: inst.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/inst/inst.tex,v retrieving revision 1.54 retrieving revision 1.55 diff -C2 -d -r1.54 -r1.55 *** inst.tex 25 Jun 2004 23:02:42 -0000 1.54 --- inst.tex 10 Jul 2004 11:11:15 -0000 1.55 *************** *** 322,326 **** \begin{verbatim} ! Python 1.5.2 (#1, Apr 18 1999, 16:03:16) [GCC pgcc-2.91.60 19981201 (egcs-1.1.1 on linux2 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import sys --- 322,326 ---- \begin{verbatim} ! Python 1.5.2 (#1, Apr 18 1999, 16:03:16) [GCC pgcc-2.91.60] on linux2 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import sys *************** *** 735,740 **** the directory containing the \file{.pth} file. Any directories added to the search path will be scanned in turn for \file{.pth} files. See ! \citetitle[http://www.python.org/dev/doc/devel/lib/module-site.html]{the ! documentation for the \module{site} module} for more information. A slightly less convenient way is to edit the \file{site.py} file in --- 735,740 ---- the directory containing the \file{.pth} file. Any directories added to the search path will be scanned in turn for \file{.pth} files. See ! \citetitle[http://www.python.org/dev/doc/devel/lib/module-site.html] ! {site module documentation} for more information. A slightly less convenient way is to edit the \file{site.py} file in *************** *** 927,931 **** \label{tweak-flags} ! Compiling a Python extension written in C or \Cpp will sometimes require specifying custom flags for the compiler and linker in order to use a particular library or produce a special kind of object code. --- 927,931 ---- \label{tweak-flags} ! Compiling a Python extension written in C or \Cpp{} will sometimes require specifying custom flags for the compiler and linker in order to use a particular library or produce a special kind of object code. From rhettinger at users.sourceforge.net Sat Jul 10 13:16:00 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Jul 10 13:16:03 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libcgi.tex,1.44,1.45 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2139 Modified Files: libcgi.tex Log Message: SF bug #987486: fix typo. Index: libcgi.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libcgi.tex,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** libcgi.tex 6 Jun 2004 23:28:23 -0000 1.44 --- libcgi.tex 10 Jul 2004 11:15:56 -0000 1.45 *************** *** 242,246 **** \begin{methoddesc}[FieldStorage]{getfirst}{name\optional{, default}} ! Thin method always returns only one value associated with form field \var{name}. The method returns only the first value in case that more values were posted under such name. Please note that the order --- 242,246 ---- \begin{methoddesc}[FieldStorage]{getfirst}{name\optional{, default}} ! This method always returns only one value associated with form field \var{name}. The method returns only the first value in case that more values were posted under such name. Please note that the order From lemburg at users.sourceforge.net Sat Jul 10 14:04:23 2004 From: lemburg at users.sourceforge.net (lemburg@users.sourceforge.net) Date: Sat Jul 10 14:04:26 2004 Subject: [Python-checkins] python/dist/src/Objects unicodeobject.c, 2.215, 2.216 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9304/Objects Modified Files: unicodeobject.c Log Message: Fix a copy&paste typo. Index: unicodeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/unicodeobject.c,v retrieving revision 2.215 retrieving revision 2.216 diff -C2 -d -r2.215 -r2.216 *** unicodeobject.c 8 Jul 2004 19:13:54 -0000 2.215 --- unicodeobject.c 10 Jul 2004 12:04:20 -0000 2.216 *************** *** 4963,4967 **** static PyObject * ! unicode_decode(PyStringObject *self, PyObject *args) { char *encoding = NULL; --- 4963,4967 ---- static PyObject * ! unicode_decode(PyUnicodeObject *self, PyObject *args) { char *encoding = NULL; From lemburg at users.sourceforge.net Sat Jul 10 14:06:13 2004 From: lemburg at users.sourceforge.net (lemburg@users.sourceforge.net) Date: Sat Jul 10 14:06:19 2004 Subject: [Python-checkins] python/dist/src/Modules _codecsmodule.c, 2.17, 2.18 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9544/Modules Modified Files: _codecsmodule.c Log Message: Add generic codecs.encode() and .decode() APIs that don't impose any restriction on the return type (like unicode.encode() et al. do). Index: _codecsmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_codecsmodule.c,v retrieving revision 2.17 retrieving revision 2.18 diff -C2 -d -r2.17 -r2.18 *** _codecsmodule.c 4 Feb 2003 19:35:03 -0000 2.17 --- _codecsmodule.c 10 Jul 2004 12:06:09 -0000 2.18 *************** *** 48,52 **** static ! PyObject *codecregister(PyObject *self, PyObject *args) { PyObject *search_function; --- 48,52 ---- static ! PyObject *codec_register(PyObject *self, PyObject *args) { PyObject *search_function; *************** *** 72,76 **** static ! PyObject *codeclookup(PyObject *self, PyObject *args) { char *encoding; --- 72,76 ---- static ! PyObject *codec_lookup(PyObject *self, PyObject *args) { char *encoding; *************** *** 85,88 **** --- 85,154 ---- } + PyDoc_STRVAR(encode__doc__, + "encode(obj, [encoding[,errors]]) -> object\n\ + \n\ + Encodes obj using the codec registered for encoding. encoding defaults\n\ + to the default encoding. errors may be given to set a different error\n\ + handling scheme. Default is 'strict' meaning that encoding errors raise\n\ + a ValueError. Other possible values are 'ignore', 'replace' and\n\ + 'xmlcharrefreplace' as well as any other name registered with\n\ + codecs.register_error that can handle ValueErrors."); + + static PyObject * + codec_encode(PyObject *self, PyObject *args) + { + char *encoding = NULL; + char *errors = NULL; + PyObject *v; + + if (!PyArg_ParseTuple(args, "O|ss:encode", &v, &encoding, &errors)) + return NULL; + + if (encoding == NULL) + encoding = PyUnicode_GetDefaultEncoding(); + + /* Encode via the codec registry */ + v = PyCodec_Encode(v, encoding, errors); + if (v == NULL) + goto onError; + return v; + + onError: + return NULL; + } + + PyDoc_STRVAR(decode__doc__, + "decode(obj, [encoding[,errors]]) -> object\n\ + \n\ + Decodes obj using the codec registered for encoding. encoding defaults\n\ + to the default encoding. errors may be given to set a different error\n\ + handling scheme. Default is 'strict' meaning that encoding errors raise\n\ + a ValueError. Other possible values are 'ignore' and 'replace'\n\ + as well as any other name registerd with codecs.register_error that is\n\ + able to handle ValueErrors."); + + static PyObject * + codec_decode(PyObject *self, PyObject *args) + { + char *encoding = NULL; + char *errors = NULL; + PyObject *v; + + if (!PyArg_ParseTuple(args, "O|ss:decode", &v, &encoding, &errors)) + return NULL; + + if (encoding == NULL) + encoding = PyUnicode_GetDefaultEncoding(); + + /* Decode via the codec registry */ + v = PyCodec_Decode(v, encoding, errors); + if (v == NULL) + goto onError; + return v; + + onError: + return NULL; + } + /* --- Helpers ------------------------------------------------------------ */ *************** *** 766,773 **** static PyMethodDef _codecs_functions[] = { ! {"register", codecregister, METH_VARARGS, register__doc__}, ! {"lookup", codeclookup, METH_VARARGS, lookup__doc__}, {"escape_encode", escape_encode, METH_VARARGS}, {"escape_decode", escape_decode, METH_VARARGS}, --- 832,841 ---- static PyMethodDef _codecs_functions[] = { ! {"register", codec_register, METH_VARARGS, register__doc__}, ! {"lookup", codec_lookup, METH_VARARGS, lookup__doc__}, + {"encode", codec_encode, METH_VARARGS}, + {"decode", codec_decode, METH_VARARGS}, {"escape_encode", escape_encode, METH_VARARGS}, {"escape_decode", escape_decode, METH_VARARGS}, From lemburg at users.sourceforge.net Sat Jul 10 14:06:13 2004 From: lemburg at users.sourceforge.net (lemburg@users.sourceforge.net) Date: Sat Jul 10 14:06:20 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_codecs.py, 1.11, 1.12 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9544/Lib/test Modified Files: test_codecs.py Log Message: Add generic codecs.encode() and .decode() APIs that don't impose any restriction on the return type (like unicode.encode() et al. do). Index: test_codecs.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_codecs.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** test_codecs.py 8 Jul 2004 04:22:19 -0000 1.11 --- test_codecs.py 10 Jul 2004 12:06:10 -0000 1.12 *************** *** 337,340 **** --- 337,349 ---- self.assertEquals(unicode("python.org", "idna"), u"python.org") + class CodecsModuleTest(unittest.TestCase): + + def test_decode(self): + self.assertEquals(codecs.decode('\xe4\xf6\xfc', 'latin-1'), + u'\xe4\xf6\xfc') + def test_encode(self): + self.assertEquals(codecs.encode(u'\xe4\xf6\xfc', 'latin-1'), + '\xe4\xf6\xfc') + def test_main(): test_support.run_unittest( *************** *** 344,348 **** PunycodeTest, NameprepTest, ! CodecTest ) --- 353,358 ---- PunycodeTest, NameprepTest, ! CodecTest, ! CodecsModuleTest ) From akuchling at users.sourceforge.net Sat Jul 10 15:31:20 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sat Jul 10 15:31:24 2004 Subject: [Python-checkins] python/dist/src/Doc/api init.tex,1.16,1.17 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/api In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22793 Modified Files: init.tex Log Message: [Bug #987835] Add documentation from PEP 311. (Untested TeX code.) Index: init.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/init.tex,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** init.tex 24 Mar 2004 21:57:07 -0000 1.16 --- init.tex 10 Jul 2004 13:31:18 -0000 1.17 *************** *** 700,703 **** --- 700,739 ---- \end{cfuncdesc} + \begin{cfuncdesc}{PyGILState_STATE}{PyGILState_Ensure}{} + Ensure that the current thread is ready to call the Python + C API regardless of the current state of Python, or of its + thread lock. This may be called as many times as desired + by a thread as long as each call is matched with a call to + \cfunction{PyGILState_Release()}. + In general, other thread-related APIs may + be used between \cfunction{PyGILState_Ensure()} and \cfunction{PyGILState_Release()} calls as long as the + thread state is restored to its previous state before the Release(). + For example, normal usage of the \csimplemacro{Py_BEGIN_ALLOW_THREADS} + and \csimplemacro{Py_END_ALLOW_THREADS} macros is acceptable. + + The return value is an opaque "handle" to the thread state when + \cfunction{PyGILState_Acquire()} was called, and must be passed to + \cfunction{PyGILState_Release()} to ensure Python is left in the same + state. Even though recursive calls are allowed, these handles + \emph{cannot} be shared - each unique call to + \cfunction{PyGILState_Ensure} must save the handle for its call to + \cfunction{PyGILState_Release}. + + When the function returns, the current thread will hold the GIL. + Failure is a fatal error. + \versionadded{2.3} + \end{cfuncdesc} + + \begin{cfuncdesc}{void}{PyGILState_Release}{PyGILState_STATE} + Release any resources previously acquired. After this call, Python's + state will be the same as it was prior to the corresponding + \cfunction{PyGILState_Ensure} call (but generally this state will be unknown to + the caller, hence the use of the GILState API.) + + Every call to \cfunction{PyGILState_Ensure()} must be matched by a call to + \cfunction{PyGILState_Release()} on the same thread. + \versionadded{2.3} + \end{cfuncdesc} + \section{Profiling and Tracing \label{profiling}} From akuchling at users.sourceforge.net Sat Jul 10 15:42:55 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sat Jul 10 15:42:57 2004 Subject: [Python-checkins] python/dist/src/Doc/api init.tex,1.17,1.18 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/api In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24379 Modified Files: init.tex Log Message: Replace example with simpler alternative using PyGILState_{Ensure,Require). Can someone please confirm this change is OK? Index: init.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/init.tex,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** init.tex 10 Jul 2004 13:31:18 -0000 1.17 --- init.tex 10 Jul 2004 13:42:52 -0000 1.18 *************** *** 471,480 **** \begin{verbatim} ! PyThreadState *tstate; ! PyObject *result; ! ! /* interp is your reference to an interpreter object. */ ! tstate = PyThreadState_New(interp); ! PyEval_AcquireThread(tstate); /* Perform Python actions here. */ --- 471,476 ---- \begin{verbatim} ! PyGILState_STATE gstate; ! gstate = PyGILState_Ensure(); /* Perform Python actions here. */ *************** *** 483,491 **** /* Release the thread. No Python API allowed beyond this point. */ ! PyEval_ReleaseThread(tstate); ! ! /* You can either delete the thread state, or save it ! until you need it the next time. */ ! PyThreadState_Delete(tstate); \end{verbatim} --- 479,483 ---- /* Release the thread. No Python API allowed beyond this point. */ ! PyGILState_Release(gstate); \end{verbatim} *************** *** 728,733 **** Release any resources previously acquired. After this call, Python's state will be the same as it was prior to the corresponding ! \cfunction{PyGILState_Ensure} call (but generally this state will be unknown to ! the caller, hence the use of the GILState API.) Every call to \cfunction{PyGILState_Ensure()} must be matched by a call to --- 720,725 ---- Release any resources previously acquired. After this call, Python's state will be the same as it was prior to the corresponding ! \cfunction{PyGILState_Ensure} call (but generally this state will be ! unknown to the caller, hence the use of the GILState API.) Every call to \cfunction{PyGILState_Ensure()} must be matched by a call to From akuchling at users.sourceforge.net Sat Jul 10 15:48:56 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sat Jul 10 15:48:59 2004 Subject: [Python-checkins] python/dist/src/Doc/api init.tex,1.18,1.19 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/api In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25244 Modified Files: init.tex Log Message: Remove a few elderly sentences Index: init.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/init.tex,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** init.tex 10 Jul 2004 13:42:52 -0000 1.18 --- init.tex 10 Jul 2004 13:48:54 -0000 1.19 *************** *** 358,370 **** The Python interpreter needs to keep some bookkeeping information separate per thread --- for this it uses a data structure called ! \ctype{PyThreadState}\ttindex{PyThreadState}. This is new in Python ! 1.5; in earlier versions, such state was stored in global variables, ! and switching threads could cause problems. In particular, exception ! handling is now thread safe, when the application uses ! \withsubitem{(in module sys)}{\ttindex{exc_info()}} ! \function{sys.exc_info()} to access the exception last raised in the ! current thread. ! ! There's one global variable left, however: the pointer to the current \ctype{PyThreadState}\ttindex{PyThreadState} structure. While most thread packages have a way to store ``per-thread global data,'' --- 358,363 ---- The Python interpreter needs to keep some bookkeeping information separate per thread --- for this it uses a data structure called ! \ctype{PyThreadState}\ttindex{PyThreadState}. There's one global ! variable, however: the pointer to the current \ctype{PyThreadState}\ttindex{PyThreadState} structure. While most thread packages have a way to store ``per-thread global data,'' From rhettinger at users.sourceforge.net Sat Jul 10 16:14:40 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Jul 10 16:14:42 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_decimal.py,1.7,1.8 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30067/Lib/test Modified Files: test_decimal.py Log Message: Improve Context construction and representation: * Rename "trap_enablers" to just "traps". * Simplify names of "settraps" and "setflags" to just "traps" and "flags". * Show "capitals" in the context representation * Simplify the Context constructor to match its repr form so that only the set flags and traps need to be listed. * Representation can now be run through eval(). Improve the error message when the Decimal constructor is given a float. The test suite no longer needs a duplicate reset_flags method. Index: test_decimal.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_decimal.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** test_decimal.py 9 Jul 2004 10:52:54 -0000 1.7 --- test_decimal.py 10 Jul 2004 14:14:37 -0000 1.8 *************** *** 39,43 **** DefaultContext.prec=9 DefaultContext.rounding=ROUND_HALF_EVEN ! DefaultContext.trap_enablers=dict.fromkeys(Signals, 0) setcontext(DefaultContext) --- 39,43 ---- DefaultContext.prec=9 DefaultContext.rounding=ROUND_HALF_EVEN ! DefaultContext.traps=dict.fromkeys(Signals, 0) setcontext(DefaultContext) *************** *** 106,111 **** global dir self.context = Context() ! for key in DefaultContext.trap_enablers.keys(): ! DefaultContext.trap_enablers[key] = 1 self.ignore_list = ['#'] # Basically, a # means return NaN InvalidOperation. --- 106,111 ---- global dir self.context = Context() ! for key in DefaultContext.traps.keys(): ! DefaultContext.traps[key] = 1 self.ignore_list = ['#'] # Basically, a # means return NaN InvalidOperation. *************** *** 121,126 **** """Cleaning up enviroment.""" # leaving context in original state ! for key in DefaultContext.trap_enablers.keys(): ! DefaultContext.trap_enablers[key] = 0 return --- 121,126 ---- """Cleaning up enviroment.""" # leaving context in original state ! for key in DefaultContext.traps.keys(): ! DefaultContext.traps[key] = 0 return *************** *** 206,212 **** for exception in Signals: ! self.context.trap_enablers[exception] = 1 #Catch these bugs... for exception in theirexceptions: ! self.context.trap_enablers[exception] = 0 for i, val in enumerate(valstemp): if val.count("'") % 2 == 1: --- 206,212 ---- for exception in Signals: ! self.context.traps[exception] = 1 #Catch these bugs... for exception in theirexceptions: ! self.context.traps[exception] = 0 for i, val in enumerate(valstemp): if val.count("'") % 2 == 1: *************** *** 222,226 **** if EXTENDEDERRORTEST: for error in theirexceptions: ! self.context.trap_enablers[error] = 1 try: funct(self.context.create_decimal(v)) --- 222,226 ---- if EXTENDEDERRORTEST: for error in theirexceptions: ! self.context.traps[error] = 1 try: funct(self.context.create_decimal(v)) *************** *** 232,236 **** else: self.fail("Did not raise %s in %s" % (error, s)) ! self.context.trap_enablers[error] = 0 v = self.context.create_decimal(v) else: --- 232,236 ---- else: self.fail("Did not raise %s in %s" % (error, s)) ! self.context.traps[error] = 0 v = self.context.create_decimal(v) else: *************** *** 242,246 **** if EXTENDEDERRORTEST and fname not in ('to_sci_string', 'to_eng_string'): for error in theirexceptions: ! self.context.trap_enablers[error] = 1 try: funct(*vals) --- 242,246 ---- if EXTENDEDERRORTEST and fname not in ('to_sci_string', 'to_eng_string'): for error in theirexceptions: ! self.context.traps[error] = 1 try: funct(*vals) *************** *** 252,256 **** else: self.fail("Did not raise %s in %s" % (error, s)) ! self.context.trap_enablers[error] = 0 try: result = str(funct(*vals)) --- 252,256 ---- else: self.fail("Did not raise %s in %s" % (error, s)) ! self.context.traps[error] = 0 try: result = str(funct(*vals)) *************** *** 264,268 **** myexceptions = self.getexceptions() ! self.resetflags() myexceptions.sort() --- 264,268 ---- myexceptions = self.getexceptions() ! self.context.clear_flags() myexceptions.sort() *************** *** 283,290 **** return L - def resetflags(self): - for exception in Signals: - self.context.flags[exception] = 0 - def change_precision(self, prec): self.context.prec = prec --- 283,286 ---- From rhettinger at users.sourceforge.net Sat Jul 10 16:14:39 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Jul 10 16:14:43 2004 Subject: [Python-checkins] python/dist/src/Lib decimal.py,1.14,1.15 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30067/Lib Modified Files: decimal.py Log Message: Improve Context construction and representation: * Rename "trap_enablers" to just "traps". * Simplify names of "settraps" and "setflags" to just "traps" and "flags". * Show "capitals" in the context representation * Simplify the Context constructor to match its repr form so that only the set flags and traps need to be listed. * Representation can now be run through eval(). Improve the error message when the Decimal constructor is given a float. The test suite no longer needs a duplicate reset_flags method. Index: decimal.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/decimal.py,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** decimal.py 9 Jul 2004 10:52:54 -0000 1.14 --- decimal.py 10 Jul 2004 14:14:37 -0000 1.15 *************** *** 71,75 **** >>> print dig / 0 Infinity ! >>> getcontext().trap_enablers[DivisionByZero] = 1 >>> print dig / 0 Traceback (most recent call last): --- 71,75 ---- >>> print dig / 0 Infinity ! >>> getcontext().traps[DivisionByZero] = 1 >>> print dig / 0 Traceback (most recent call last): *************** *** 79,88 **** DivisionByZero: x / 0 >>> c = Context() ! >>> c.trap_enablers[InvalidOperation] = 0 >>> print c.flags[InvalidOperation] 0 >>> c.divide(Decimal(0), Decimal(0)) Decimal("NaN") ! >>> c.trap_enablers[InvalidOperation] = 1 >>> print c.flags[InvalidOperation] 1 --- 79,88 ---- DivisionByZero: x / 0 >>> c = Context() ! >>> c.traps[InvalidOperation] = 0 >>> print c.flags[InvalidOperation] 0 >>> c.divide(Decimal(0), Decimal(0)) Decimal("NaN") ! >>> c.traps[InvalidOperation] = 1 >>> print c.flags[InvalidOperation] 1 *************** *** 99,103 **** 1 >>> c.flags[InvalidOperation] = 0 ! >>> c.trap_enablers[InvalidOperation] = 0 >>> print c.divide(Decimal(0), Decimal(0)) NaN --- 99,103 ---- 1 >>> c.flags[InvalidOperation] = 0 ! >>> c.traps[InvalidOperation] = 0 >>> print c.divide(Decimal(0), Decimal(0)) NaN *************** *** 496,500 **** return ! raise TypeError("Can't convert %r" % value) def _convert_other(self, other): --- 496,504 ---- return ! if isinstance(value, float): ! raise TypeError("Cannot convert float to Decimal. " + ! "First convert the float to a string") ! ! raise TypeError("Cannot convert %r" % value) def _convert_other(self, other): *************** *** 2097,2101 **** rounding - rounding type. (how you round) _rounding_decision - ALWAYS_ROUND, NEVER_ROUND -- do you round? ! trap_enablers - If trap_enablers[exception] = 1, then the exception is raised when it is caused. Otherwise, a value is substituted in. --- 2101,2105 ---- rounding - rounding type. (how you round) _rounding_decision - ALWAYS_ROUND, NEVER_ROUND -- do you round? ! traps - If traps[exception] = 1, then the exception is raised when it is caused. Otherwise, a value is substituted in. *************** *** 2111,2121 **** def __init__(self, prec=None, rounding=None, ! trap_enablers=None, flags=None, _rounding_decision=None, Emin=None, Emax=None, capitals=None, _clamp=0, _ignored_flags=[]): ! if flags is None: ! flags = dict.fromkeys(Signals, 0) for name, val in locals().items(): if val is None: --- 2115,2127 ---- def __init__(self, prec=None, rounding=None, ! traps=None, flags=[], _rounding_decision=None, Emin=None, Emax=None, capitals=None, _clamp=0, _ignored_flags=[]): ! if not isinstance(flags, dict): ! flags = dict([(s,s in flags) for s in Signals]) ! if traps is not None and not isinstance(traps, dict): ! traps = dict([(s,s in traps) for s in Signals]) for name, val in locals().items(): if val is None: *************** *** 2126,2134 **** def __repr__(self): ! """Show the current context in readable form, not in a form for eval().""" s = [] ! s.append('Context(prec=%(prec)d, rounding=%(rounding)s, Emin=%(Emin)d, Emax=%(Emax)d' % vars(self)) ! s.append('setflags=%r' % [f.__name__ for f, v in self.flags.items() if v]) ! s.append('settraps=%r' % [t.__name__ for t, v in self.trap_enablers.items() if v]) return ', '.join(s) + ')' --- 2132,2140 ---- def __repr__(self): ! """Show the current context.""" s = [] ! s.append('Context(prec=%(prec)d, rounding=%(rounding)s, Emin=%(Emin)d, Emax=%(Emax)d, capitals=%(capitals)d' % vars(self)) ! s.append('flags=[' + ', '.join([f.__name__ for f, v in self.flags.items() if v]) + ']') ! s.append('traps=[' + ', '.join([t.__name__ for t, v in self.traps.items() if v]) + ']') return ', '.join(s) + ')' *************** *** 2140,2144 **** def copy(self): """Returns a copy from self.""" ! nc = Context(self.prec, self.rounding, self.trap_enablers, self.flags, self._rounding_decision, self.Emin, self.Emax, self.capitals, self._clamp, self._ignored_flags) --- 2146,2150 ---- def copy(self): """Returns a copy from self.""" ! nc = Context(self.prec, self.rounding, self.traps, self.flags, self._rounding_decision, self.Emin, self.Emax, self.capitals, self._clamp, self._ignored_flags) *************** *** 2160,2164 **** self.flags[error] += 1 ! if not self.trap_enablers[error]: #The errors define how to handle themselves. return condition().handle(self, *args) --- 2166,2170 ---- self.flags[error] += 1 ! if not self.traps[error]: #The errors define how to handle themselves. return condition().handle(self, *args) *************** *** 2947,2957 **** # Is mutable, so than new contexts can have different default values - _default_traps = dict.fromkeys(Signals, 0) - _default_traps.update({DivisionByZero:1, Overflow:1, InvalidOperation:1}) - DefaultContext = Context( prec=28, rounding=ROUND_HALF_EVEN, ! trap_enablers=_default_traps, ! flags=None, _rounding_decision=ALWAYS_ROUND, Emax=DEFAULT_MAX_EXPONENT, --- 2953,2960 ---- # Is mutable, so than new contexts can have different default values DefaultContext = Context( prec=28, rounding=ROUND_HALF_EVEN, ! traps=[DivisionByZero, Overflow, InvalidOperation], ! flags=[], _rounding_decision=ALWAYS_ROUND, Emax=DEFAULT_MAX_EXPONENT, *************** *** 2965,2975 **** # of the spec. - _basic_traps = dict.fromkeys(Signals, 1) - _basic_traps.update({Inexact:0, Rounded:0, Subnormal:0}) - BasicContext = Context( prec=9, rounding=ROUND_HALF_UP, ! trap_enablers=_basic_traps, ! flags=None, _rounding_decision=ALWAYS_ROUND, ) --- 2968,2975 ---- # of the spec. BasicContext = Context( prec=9, rounding=ROUND_HALF_UP, ! traps=[DivisionByZero, Overflow, InvalidOperation, Clamped, Underflow], ! flags=[], _rounding_decision=ALWAYS_ROUND, ) *************** *** 2977,2982 **** ExtendedContext = Context( prec=9, rounding=ROUND_HALF_EVEN, ! trap_enablers=dict.fromkeys(Signals, 0), ! flags=None, _rounding_decision=ALWAYS_ROUND, ) --- 2977,2982 ---- ExtendedContext = Context( prec=9, rounding=ROUND_HALF_EVEN, ! traps=[], ! flags=[], _rounding_decision=ALWAYS_ROUND, ) From rhettinger at users.sourceforge.net Sat Jul 10 16:14:40 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Jul 10 16:14:44 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libdecimal.tex,1.10,1.11 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30067/Doc/lib Modified Files: libdecimal.tex Log Message: Improve Context construction and representation: * Rename "trap_enablers" to just "traps". * Simplify names of "settraps" and "setflags" to just "traps" and "flags". * Show "capitals" in the context representation * Simplify the Context constructor to match its repr form so that only the set flags and traps need to be listed. * Representation can now be run through eval(). Improve the error message when the Decimal constructor is given a float. The test suite no longer needs a duplicate reset_flags method. Index: libdecimal.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libdecimal.tex,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** libdecimal.tex 9 Jul 2004 10:02:52 -0000 1.10 --- libdecimal.tex 10 Jul 2004 14:14:37 -0000 1.11 *************** *** 113,117 **** >>> getcontext() Context(prec=28, rounding=ROUND_HALF_EVEN, Emin=-999999999, Emax=999999999, ! setflags=[], settraps=[]) >>> getcontext().prec = 7 --- 113,117 ---- >>> getcontext() Context(prec=28, rounding=ROUND_HALF_EVEN, Emin=-999999999, Emax=999999999, ! capitals=1, flags=[], traps=[]) >>> getcontext().prec = 7 *************** *** 205,212 **** >>> myothercontext Context(prec=60, rounding=ROUND_HALF_DOWN, Emin=-999999999, Emax=999999999, ! setflags=[], settraps=[]) >>> ExtendedContext Context(prec=9, rounding=ROUND_HALF_EVEN, Emin=-999999999, Emax=999999999, ! setflags=[], settraps=[]) >>> setcontext(myothercontext) >>> Decimal(1) / Decimal(7) --- 205,212 ---- >>> myothercontext Context(prec=60, rounding=ROUND_HALF_DOWN, Emin=-999999999, Emax=999999999, ! capitals=1, flags=[], traps=[]) >>> ExtendedContext Context(prec=9, rounding=ROUND_HALF_EVEN, Emin=-999999999, Emax=999999999, ! capitals=1, flags=[], traps=[]) >>> setcontext(myothercontext) >>> Decimal(1) / Decimal(7) *************** *** 237,249 **** >>> getcontext() Context(prec=9, rounding=ROUND_HALF_EVEN, Emin=-999999999, Emax=999999999, ! setflags=['Inexact', 'Rounded'], settraps=[]) \end{verbatim} ! The \var{setflags} entry shows that the rational approximation to \constant{Pi} was rounded (digits beyond the context precision were thrown away) and that the result is inexact (some of the discarded digits were non-zero). ! Individual traps are set using the dictionary in the \member{trap_enablers} field of a context: --- 237,249 ---- >>> getcontext() Context(prec=9, rounding=ROUND_HALF_EVEN, Emin=-999999999, Emax=999999999, ! capitals=1, flags=[Inexact, Rounded], traps=[]) \end{verbatim} ! The \var{flags} entry shows that the rational approximation to \constant{Pi} was rounded (digits beyond the context precision were thrown away) and that the result is inexact (some of the discarded digits were non-zero). ! Individual traps are set using the dictionary in the \member{traps} field of a context: *************** *** 251,255 **** >>> Decimal(1) / Decimal(0) Decimal("Infinity") ! >>> getcontext().trap_enablers[DivisionByZero] = 1 >>> Decimal(1) / Decimal(0) --- 251,255 ---- >>> Decimal(1) / Decimal(0) Decimal("Infinity") ! >>> getcontext().traps[DivisionByZero] = 1 >>> Decimal(1) / Decimal(0) *************** *** 265,276 **** \begin{verbatim} >>> getcontext.clear_flags() ! >>> for sig in getcontext().trap_enablers: ! ... getcontext().trap_enablers[sig] = 1 ! >>> getcontext().trap_enablers.update({Rounded:0, Inexact:0, Subnormal:0}) >>> getcontext() Context(prec=9, rounding=ROUND_HALF_EVEN, Emin=-999999999, Emax=999999999, ! setflags=[], settraps=['Clamped', 'Underflow', 'InvalidOperation', ! 'DivisionByZero', 'Overflow']) \end{verbatim} --- 265,276 ---- \begin{verbatim} >>> getcontext.clear_flags() ! >>> for sig in getcontext().traps: ! ... getcontext().traps[sig] = 1 ! >>> getcontext().traps.update({Rounded:0, Inexact:0, Subnormal:0}) >>> getcontext() Context(prec=9, rounding=ROUND_HALF_EVEN, Emin=-999999999, Emax=999999999, ! capitals=1, flags=[], traps=[Clamped, Underflow, ! InvalidOperation, DivisionByZero, Overflow]) \end{verbatim} *************** *** 490,494 **** with the \class{Context} constructor. ! \begin{classdesc}{Context}{prec=None, rounding=None, trap_enablers=None, flags=None, Emin=None, Emax=None, capitals=1} Creates a new context. If a field is not specified or is \constant{None}, --- 490,494 ---- with the \class{Context} constructor. ! \begin{classdesc}{Context}{prec=None, rounding=None, traps=None, flags=None, Emin=None, Emax=None, capitals=1} Creates a new context. If a field is not specified or is \constant{None}, *************** *** 509,513 **** \constant{ROUND_UP} (away from zero). ! The \var{trap_enablers} and \var{flags} fields are mappings from signals to either \constant{0} or \constant{1}. --- 509,513 ---- \constant{ROUND_UP} (away from zero). ! The \var{traps} and \var{flags} fields are mappings from signals to either \constant{0} or \constant{1}. *************** *** 840,844 **** DefaultContext.prec=12 DefaultContext.rounding=ROUND_DOWN ! DefaultContext.trap_enablers=dict.fromkeys(Signals, 0) setcontext(DefaultContext) --- 840,844 ---- DefaultContext.prec=12 DefaultContext.rounding=ROUND_DOWN ! DefaultContext.traps=dict.fromkeys(Signals, 0) setcontext(DefaultContext) From akuchling at users.sourceforge.net Sat Jul 10 16:14:54 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sat Jul 10 16:14:56 2004 Subject: [Python-checkins] python/dist/src/Lib cgitb.py,1.13,1.14 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30082 Modified Files: cgitb.py Log Message: [Patch #987052 from Thomas Guettler] Don't output empty tags Escape page header Remove

before (tidy complains) Index: cgitb.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/cgitb.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** cgitb.py 7 Jun 2004 11:20:40 -0000 1.13 --- cgitb.py 10 Jul 2004 14:14:51 -0000 1.14 *************** *** 38,44 **** __UNDEF__ = [] # a special sentinel object ! def small(text): return '' + text + '' ! def strong(text): return '' + text + '' ! def grey(text): return '' + text + '' def lookup(name, frame, locals): --- 38,58 ---- __UNDEF__ = [] # a special sentinel object ! def small(text): ! if text: ! return '' + text + '' ! else: ! return '' ! ! def strong(text): ! if text: ! return '' + text + '' ! else: ! return '' ! ! def grey(text): ! if text: ! return '' + text + '' ! else: ! return '' def lookup(name, frame, locals): *************** *** 89,96 **** date = time.ctime(time.time()) head = '' + pydoc.html.heading( ! '%s' % str(etype), '#ffffff', '#6622aa', pyver + '
' + date) + '''

A problem occurred in a Python script. Here is the sequence of ! function calls leading up to the error, in the order they occurred.''' indent = '' + small(' ' * 5) + ' ' --- 103,111 ---- date = time.ctime(time.time()) head = '' + pydoc.html.heading( ! '%s' % ! strong(pydoc.html.escape(str(etype))), '#ffffff', '#6622aa', pyver + '
' + date) + '''

A problem occurred in a Python script. Here is the sequence of ! function calls leading up to the error, in the order they occurred.

''' indent = '' + small(' ' * 5) + ' ' *************** *** 143,147 **** rows.append('' % small(grey(', '.join(dump)))) ! frames.append('''

%s
%s
''' % '\n'.join(rows)) --- 158,162 ---- rows.append('%s' % small(grey(', '.join(dump)))) ! frames.append(''' %s
''' % '\n'.join(rows)) From akuchling at users.sourceforge.net Sat Jul 10 16:19:24 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sat Jul 10 16:19:30 2004 Subject: [Python-checkins] python/dist/src/Modules socketmodule.c, 1.293, 1.294 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31191 Modified Files: socketmodule.c Log Message: [Patch #982665 ] add SO_EXCLUSIVEADDRUSE constant Index: socketmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/socketmodule.c,v retrieving revision 1.293 retrieving revision 1.294 diff -C2 -d -r1.293 -r1.294 *** socketmodule.c 7 Jul 2004 14:02:59 -0000 1.293 --- socketmodule.c 10 Jul 2004 14:19:21 -0000 1.294 *************** *** 3884,3887 **** --- 3884,3891 ---- PyModule_AddIntConstant(m, "SO_REUSEADDR", SO_REUSEADDR); #endif + #ifdef SO_EXCLUSIVEADDRUSE + PyModule_AddIntConstant(m, "SO_EXCLUSIVEADDRUSE", SO_EXCLUSIVEADDRUSE); + #endif + #ifdef SO_KEEPALIVE PyModule_AddIntConstant(m, "SO_KEEPALIVE", SO_KEEPALIVE); From akuchling at users.sourceforge.net Sat Jul 10 17:34:37 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sat Jul 10 17:34:39 2004 Subject: [Python-checkins] python/dist/src/Lib urllib2.py,1.69,1.70 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11012 Modified Files: urllib2.py Log Message: [Patch #988504] Fix HTTP error handling via a patch from John J. Lee Index: urllib2.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/urllib2.py,v retrieving revision 1.69 retrieving revision 1.70 diff -C2 -d -r1.69 -r1.70 *** urllib2.py 29 Jun 2004 13:19:19 -0000 1.69 --- urllib2.py 10 Jul 2004 15:34:34 -0000 1.70 *************** *** 997,1010 **** raise URLError(err) ! if r.status in (200, 206): ! # Pick apart the HTTPResponse object to get the addinfourl ! # object initialized properly ! resp = addinfourl(r.fp, r.msg, req.get_full_url()) ! resp.code = r.status ! resp.msg = r.reason ! return resp ! else: ! return self.parent.error("http", req, r.fp, r.status, r.msg, ! r.msg.dict) --- 997,1006 ---- raise URLError(err) ! # Pick apart the HTTPResponse object to get the addinfourl ! # object initialized properly ! resp = addinfourl(r.fp, r.msg, req.get_full_url()) ! resp.code = r.status ! resp.msg = r.reason ! return resp From akuchling at users.sourceforge.net Sat Jul 10 17:40:31 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sat Jul 10 17:40:35 2004 Subject: [Python-checkins] python/dist/src/Lib zipfile.py,1.31,1.32 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11963 Modified Files: zipfile.py Log Message: [Bug #835415] AIX can return modes that are >65536, which causes an OverflowError. Fix from Albert Chin Index: zipfile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/zipfile.py,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** zipfile.py 27 Jun 2003 22:25:03 -0000 1.31 --- zipfile.py 10 Jul 2004 15:40:29 -0000 1.32 *************** *** 397,401 **** else: zinfo = ZipInfo(arcname, date_time) ! zinfo.external_attr = st[0] << 16L # Unix attributes if compress_type is None: zinfo.compress_type = self.compression --- 397,401 ---- else: zinfo = ZipInfo(arcname, date_time) ! zinfo.external_attr = (st[0] & 0xFFFF) << 16L # Unix attributes if compress_type is None: zinfo.compress_type = self.compression From akuchling at users.sourceforge.net Sat Jul 10 17:51:21 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sat Jul 10 17:51:24 2004 Subject: [Python-checkins] python/dist/src/Lib asyncore.py,1.55,1.56 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13386 Modified Files: asyncore.py Log Message: [Patch #982681] Fix dispatcher.set_reuse_addr() on Windows; patch from Garth Bushell Index: asyncore.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/asyncore.py,v retrieving revision 1.55 retrieving revision 1.56 diff -C2 -d -r1.55 -r1.56 *** asyncore.py 7 Jul 2004 20:54:44 -0000 1.55 --- asyncore.py 10 Jul 2004 15:51:19 -0000 1.56 *************** *** 510,514 **** def close(self): ! return os.close(self.fd) def fileno(self): --- 510,514 ---- def close(self): ! os.close(self.fd) def fileno(self): *************** *** 520,528 **** dispatcher.__init__(self, None, map) self.connected = True # set it to non-blocking mode flags = fcntl.fcntl(fd, fcntl.F_GETFL, 0) flags = flags | os.O_NONBLOCK fcntl.fcntl(fd, fcntl.F_SETFL, flags) - self.set_file(fd) def set_file(self, fd): --- 520,528 ---- dispatcher.__init__(self, None, map) self.connected = True + self.set_file(fd) # set it to non-blocking mode flags = fcntl.fcntl(fd, fcntl.F_GETFL, 0) flags = flags | os.O_NONBLOCK fcntl.fcntl(fd, fcntl.F_SETFL, flags) def set_file(self, fd): From akuchling at users.sourceforge.net Sat Jul 10 17:53:33 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sat Jul 10 17:53:36 2004 Subject: [Python-checkins] python/dist/src/Lib zipfile.py,1.31,1.31.6.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13692 Modified Files: Tag: release23-branch zipfile.py Log Message: [Bug #835415] AIX can return modes that are >65536, which causes an OverflowError. Fix from Albert Chin Index: zipfile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/zipfile.py,v retrieving revision 1.31 retrieving revision 1.31.6.1 diff -C2 -d -r1.31 -r1.31.6.1 *** zipfile.py 27 Jun 2003 22:25:03 -0000 1.31 --- zipfile.py 10 Jul 2004 15:53:30 -0000 1.31.6.1 *************** *** 397,401 **** else: zinfo = ZipInfo(arcname, date_time) ! zinfo.external_attr = st[0] << 16L # Unix attributes if compress_type is None: zinfo.compress_type = self.compression --- 397,401 ---- else: zinfo = ZipInfo(arcname, date_time) ! zinfo.external_attr = (st[0] & 0xFFFF) << 16L # Unix attributes if compress_type is None: zinfo.compress_type = self.compression From akuchling at users.sourceforge.net Sat Jul 10 18:01:12 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sat Jul 10 18:01:15 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libgettext.tex,1.23,1.24 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14910 Modified Files: libgettext.tex Log Message: [Bug 949832] Fix example; edit sentence Index: libgettext.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libgettext.tex,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** libgettext.tex 8 Jan 2004 15:01:08 -0000 1.23 --- libgettext.tex 10 Jul 2004 16:01:10 -0000 1.24 *************** *** 119,124 **** implements the parsing of GNU \file{.mo} format files, and has methods for returning either standard 8-bit strings or Unicode strings. ! Translations instances can also install themselves in the built-in ! namespace as the function \function{_()}. \begin{funcdesc}{find}{domain\optional{, localedir\optional{, --- 119,124 ---- implements the parsing of GNU \file{.mo} format files, and has methods for returning either standard 8-bit strings or Unicode strings. ! Instances of this ``translations'' class can also install themselves ! in the built-in namespace as the function \function{_()}. \begin{funcdesc}{find}{domain\optional{, localedir\optional{, *************** *** 366,370 **** 'There is %(num)d file in this directory', 'There are %(num)d files in this directory', ! n) % {'n': n} \end{verbatim} --- 366,370 ---- 'There is %(num)d file in this directory', 'There are %(num)d files in this directory', ! n) % {'num': n} \end{verbatim} From rhettinger at users.sourceforge.net Sat Jul 10 18:10:43 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Jul 10 18:10:47 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1027,1.1028 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16583/Misc Modified Files: NEWS Log Message: Fix typo. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1027 retrieving revision 1.1028 diff -C2 -d -r1.1027 -r1.1028 *** NEWS 9 Jul 2004 10:02:53 -0000 1.1027 --- NEWS 10 Jul 2004 16:10:39 -0000 1.1028 *************** *** 417,421 **** original exception. ! - Added Decimal.py per PEP 327. - Bug #981299: rsync is now a recognized protocol in urlparse that uses a --- 417,421 ---- original exception. ! - Added decimal.py per PEP 327. - Bug #981299: rsync is now a recognized protocol in urlparse that uses a From rhettinger at users.sourceforge.net Sat Jul 10 18:11:06 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Jul 10 18:11:09 2004 Subject: [Python-checkins] python/dist/src/Doc/tut tut.tex,1.239,1.240 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/tut In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16680/Doc/tut Modified Files: tut.tex Log Message: Fix typo. Index: tut.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/tut/tut.tex,v retrieving revision 1.239 retrieving revision 1.240 diff -C2 -d -r1.239 -r1.240 *** tut.tex 9 Jul 2004 06:00:32 -0000 1.239 --- tut.tex 10 Jul 2004 16:11:03 -0000 1.240 *************** *** 4366,4370 **** Generators are a simple and powerful tool for creating iterators. They are written like regular functions but use the \keyword{yield} statement whenever ! they want to return data. Each time the \method{next()} is called, the generator resumes where it left-off (it remembers all the data values and which statement was last executed). An example shows that generators can --- 4366,4370 ---- Generators are a simple and powerful tool for creating iterators. They are written like regular functions but use the \keyword{yield} statement whenever ! they want to return data. Each time \method{next()} is called, the generator resumes where it left-off (it remembers all the data values and which statement was last executed). An example shows that generators can From akuchling at users.sourceforge.net Sat Jul 10 18:12:19 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sat Jul 10 18:12:21 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libgettext.tex, 1.20, 1.20.4.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16948 Modified Files: Tag: release23-branch libgettext.tex Log Message: [Bug #949832] Fix typo in example Index: libgettext.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libgettext.tex,v retrieving revision 1.20 retrieving revision 1.20.4.1 diff -C2 -d -r1.20 -r1.20.4.1 *** libgettext.tex 22 Jul 2003 00:49:11 -0000 1.20 --- libgettext.tex 10 Jul 2004 16:12:16 -0000 1.20.4.1 *************** *** 366,370 **** 'There is %(num)d file in this directory', 'There are %(num)d files in this directory', ! n) % {'n': n} \end{verbatim} --- 366,370 ---- 'There is %(num)d file in this directory', 'There are %(num)d files in this directory', ! n) % {'num': n} \end{verbatim} From lemburg at users.sourceforge.net Sat Jul 10 18:16:23 2004 From: lemburg at users.sourceforge.net (lemburg@users.sourceforge.net) Date: Sat Jul 10 18:16:26 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1028,1.1029 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17549/Misc Modified Files: NEWS Log Message: Added note about new codecs module APIs. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1028 retrieving revision 1.1029 diff -C2 -d -r1.1028 -r1.1029 *** NEWS 10 Jul 2004 16:10:39 -0000 1.1028 --- NEWS 10 Jul 2004 16:16:06 -0000 1.1029 *************** *** 30,33 **** --- 30,37 ---- no longer part of the public API. + - codecs module now has two new generic APIs: encode() and decode() + which don't restrict the return types (unlike the unicode and + string methods of the same name). + Tools/Demos ----------- From rjnr at slovhron.sk Sat Jul 10 18:03:22 2004 From: rjnr at slovhron.sk (eddie wilhelm) Date: Sat Jul 10 18:46:27 2004 Subject: [Python-checkins] Tnrxptkxul fresh feel Message-ID: in-office greenbe leamingt 0`n|ine Pharm Stop the pai.n, get +Vi+co+din+ now Real doctors providing for your health and well being. (opt out pls follow the webpage insturct ) E N http://hxdk.info.netvh.com/abc/03/ if others disagree with what we do or say, they still love us. They accept us. They appreciate our contributions to the world. While it would be wonderful to have these types of relationships with all people, we know that that's hard to do. We can, however, have them with some others, but only when we first have them with ourselves-and, ironically, this is often the hardest relationship of all. The 'houses' are mansions and their architecture a complete fantasy.Manicured lawns,and driveways displying mega-buck motors.Foliage and flora like a suburban Babylon.Front doors that are three storeys tall,and architectural motifs that range from Fake Chateau,Sunshine Tudor,Santa Fe Adobe,Cotswold Cobble to Hansel-and-Gretel Disney.Side by vast-lawn-in-between side.No sign of any people except the odd truck piled with garden refuse manned by a Mexican gardener. zeninsei9tenkabut03syoutots,sitipo sadogash. From akuchling at users.sourceforge.net Sat Jul 10 19:36:13 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sat Jul 10 19:36:17 2004 Subject: [Python-checkins] python/dist/src/Lib asyncore.py,1.56,1.57 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30755 Modified Files: asyncore.py Log Message: In poll(), check connections for exceptional conditions Index: asyncore.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/asyncore.py,v retrieving revision 1.56 retrieving revision 1.57 diff -C2 -d -r1.56 -r1.57 *** asyncore.py 10 Jul 2004 15:51:19 -0000 1.56 --- asyncore.py 10 Jul 2004 17:36:11 -0000 1.57 *************** *** 81,84 **** --- 81,92 ---- obj.handle_error() + def _exception (obj): + try: + obj.handle_expt_event() + except ExitNow: + raise + except: + obj.handle_error() + def readwrite(obj, flags): try: *************** *** 100,103 **** --- 108,112 ---- r = []; w = []; e = [] for fd, obj in map.items(): + e.append(fd) if obj.readable(): r.append(fd) *************** *** 127,130 **** --- 136,145 ---- write(obj) + for fd in e: + obj = map.get(fd) + if obj is None: + continue + _exception(obj) + def poll2(timeout=0.0, map=None): # Use the poll() support added to the select module in Python 2.0 From katharinenixonjef at protectotters.com Sat Jul 10 17:43:03 2004 From: katharinenixonjef at protectotters.com (mathew aloe) Date: Sat Jul 10 19:38:04 2004 Subject: [Python-checkins] Frxs Ref1ll For Your Darv0cet 0rder Message-ID: <4AC7EB42.290D205@protectotters.com> jeffparke ftclaytn klarholz The b`est meeds available You can now order V~a|ium, X~a.nax securely and discreetly. No fo.rms to fill out! E`very`one is a`ppr.oved. A G http://u.fkc.analgesia2470pills.us/f74/ When the time came to pick it up, however, I grew skeptical. How could I have been so foolish as to just leave a $1,200 wedding dress in the hands of someone I barely knew? What if she made a mess out of it? I had no idea if she could even sew on a button. Take time out during the day for quiet time to listen to your inner voice. I call this inner voice the voice of God. This is similar to point number one, but it takes it a step further - beyond the natural mind to the supernatural heart. You may want to use your quiet time to meditate or pray. However you use this time, the key is to shut out all of the noise around you by focusing deep within yourself. Breathing deeply during quiet time will also help you focus. sauna9tetsuko03kumiko,tenwa simera. From akuchling at users.sourceforge.net Sat Jul 10 20:28:36 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sat Jul 10 20:28:40 2004 Subject: [Python-checkins] python/dist/src/Doc/lib liburllib2.tex,1.18,1.19 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7121 Modified Files: liburllib2.tex Log Message: [Patch #972310] Apply correction to docs Index: liburllib2.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/liburllib2.tex,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** liburllib2.tex 31 May 2004 18:22:39 -0000 1.18 --- liburllib2.tex 10 Jul 2004 18:28:33 -0000 1.19 *************** *** 366,369 **** --- 366,372 ---- OpenerDirector objects open URLs in three stages: + The order in which these methods are called within each stage is + determined by sorting the handler instances. + \begin{enumerate} \item Every handler with a method named like *************** *** 371,378 **** pre-process the request. - The order in which these methods are called is determined by - sorting the handler instances by the \member{.processor_order} - attribute. - \item Handlers with a method named like \method{\var{protocol}_open()} are called to handle the request. --- 374,377 ---- *************** *** 392,405 **** \method{.error()} methods. - The order in which these methods are called is determined by - sorting the handler instances. - \item Every handler with a method named like \method{\var{protocol}_response()} has that method called to post-process the response. - The order in which these methods are called is determined by - sorting the handler instances by the \member{.processor_order} - attribute. \end{enumerate} --- 391,398 ---- From akuchling at users.sourceforge.net Sat Jul 10 20:32:14 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sat Jul 10 20:32:17 2004 Subject: [Python-checkins] python/dist/src/Lib cookielib.py,1.2,1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7676 Modified Files: cookielib.py Log Message: [Patch #969907] Add traceback to warning output Index: cookielib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/cookielib.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** cookielib.py 1 Jun 2004 04:36:51 -0000 1.2 --- cookielib.py 10 Jul 2004 18:32:12 -0000 1.3 *************** *** 50,57 **** raise # swallowed an exception ! import warnings ! warnings.warn("cookielib bug!", stacklevel=2) ! import traceback ! traceback.print_exc() --- 50,58 ---- raise # swallowed an exception ! import warnings, traceback, StringIO ! f = StringIO.StringIO() ! traceback.print_exc(None, f) ! msg = f.getvalue() ! warnings.warn("cookielib bug!\n%s" % msg, stacklevel=2) From akuchling at users.sourceforge.net Sat Jul 10 20:41:30 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sat Jul 10 20:41:36 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libcookielib.tex,1.1,1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8992 Modified Files: libcookielib.tex Log Message: [Patch #969900] Various corrections and updates to cookielib docs Index: libcookielib.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libcookielib.tex,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** libcookielib.tex 31 May 2004 18:22:39 -0000 1.1 --- libcookielib.tex 10 Jul 2004 18:41:28 -0000 1.2 *************** *** 141,145 **** \subsection{CookieJar and FileCookieJar Objects \label{cookie-jar-objects}} ! \class{CookieJar} objects support the iterator protocol. \class{CookieJar} has the following methods: --- 141,146 ---- \subsection{CookieJar and FileCookieJar Objects \label{cookie-jar-objects}} ! \class{CookieJar} objects support the iterator protocol for iterating ! over contained \class{Cookie} objects. \class{CookieJar} has the following methods: *************** *** 148,155 **** Add correct \mailheader{Cookie} header to \var{request}. ! If the CookiePolicy allows (ie. the \class{CookiePolicy} instance's ! \member{rfc2965} and \member{hide_cookie2} attributes are true and ! false respectively), the \mailheader{Cookie2} header is also added ! when appropriate. The \var{request} object (usually a \class{urllib2.Request} instance) --- 149,156 ---- Add correct \mailheader{Cookie} header to \var{request}. ! If policy allows (ie. the \member{rfc2965} and \member{hide_cookie2} ! attributes of the \class{CookieJar}'s \class{CookiePolicy} instance ! are true and false respectively), the \mailheader{Cookie2} header is ! also added when appropriate. The \var{request} object (usually a \class{urllib2.Request} instance) *************** *** 280,292 **** \begin{memberdesc}{filename} ! Filename of default file in which to keep cookies. \end{memberdesc} \begin{memberdesc}{delayload} ! If true, load cookies lazily from disk. This is only a hint, since ! this only affects performance, not behaviour (unless the cookies on ! disk are changing). A \class{CookieJar} object may ignore it. None ! of the \class{FileCookieJar} classes included in the standard library ! lazily loads cookies. \end{memberdesc} --- 281,295 ---- \begin{memberdesc}{filename} ! Filename of default file in which to keep cookies. This attribute may ! be assigned to. \end{memberdesc} \begin{memberdesc}{delayload} ! If true, load cookies lazily from disk. This attribute should not be ! assigned to. This is only a hint, since this only affects ! performance, not behaviour (unless the cookies on disk are changing). ! A \class{CookieJar} object may ignore it. None of the ! \class{FileCookieJar} classes included in the standard library lazily ! loads cookies. \end{memberdesc} *************** *** 304,308 **** A \class{FileCookieJar} that can load from and save cookies to disk in the Mozilla \code{cookies.txt} file format (which is also used by the ! lynx and Netscape browsers). \note{This loses information about RFC 2965 cookies, and also about newer or non-standard cookie-attributes such as \code{port}.} --- 307,311 ---- A \class{FileCookieJar} that can load from and save cookies to disk in the Mozilla \code{cookies.txt} file format (which is also used by the ! Lynx and Netscape browsers). \note{This loses information about RFC 2965 cookies, and also about newer or non-standard cookie-attributes such as \code{port}.} *************** *** 352,358 **** This method is an optimization. It removes the need for checking every cookie with a particular domain (which might involve reading ! many files). The default implementations of ! \method{domain_return_ok()} and \method{path_return_ok()} ! (\samp{return True}) leave all the work to \method{return_ok()}. If \method{domain_return_ok()} returns true for the cookie domain, --- 355,360 ---- This method is an optimization. It removes the need for checking every cookie with a particular domain (which might involve reading ! many files). Returning true from \method{domain_return_ok()} and ! \method{path_return_ok()} leaves all the work to \method{return_ok()}. If \method{domain_return_ok()} returns true for the cookie domain, *************** *** 387,391 **** \begin{memberdesc}{netscape} ! Implement netscape protocol. \end{memberdesc} \begin{memberdesc}{rfc2965} --- 389,393 ---- \begin{memberdesc}{netscape} ! Implement Netscape protocol. \end{memberdesc} \begin{memberdesc}{rfc2965} *************** *** 393,398 **** \end{memberdesc} \begin{memberdesc}{hide_cookie2} ! Don't add Cookie2 header to requests (the presence of this header ! indicates to the server that we understand RFC 2965 cookies). \end{memberdesc} --- 395,401 ---- \end{memberdesc} \begin{memberdesc}{hide_cookie2} ! Don't add \mailheader{Cookie2} header to requests (the presence of ! this header indicates to the server that we understand RFC 2965 ! cookies). \end{memberdesc} *************** *** 400,404 **** subclassing from \class{DefaultCookiePolicy} and overriding some or all of the methods above. \class{CookiePolicy} itself may be used as ! a 'null policy' to allow setting and receiving any and all cookies. --- 403,408 ---- subclassing from \class{DefaultCookiePolicy} and overriding some or all of the methods above. \class{CookiePolicy} itself may be used as ! a 'null policy' to allow setting and receiving any and all cookies ! (this is unlikely to be useful). *************** *** 441,446 **** again by setting it to \constant{None}. ! Domains in block or allow lists that do not start with a dot must be ! equal. For example, \code{"example.com"} matches a blacklist entry of \code{"example.com"}, but \code{"www.example.com"} does not. Domains that do start with a dot are matched by more specific domains too. --- 445,451 ---- again by setting it to \constant{None}. ! Domains in block or allow lists that do not start with a dot must ! equal the cookie domain to be matched. For example, ! \code{"example.com"} matches a blacklist entry of \code{"example.com"}, but \code{"www.example.com"} does not. Domains that do start with a dot are matched by more specific domains too. *************** *** 535,542 **** \begin{memberdesc}{DomainStrictNonDomain} Cookies that did not explicitly specify a \code{domain} ! cookie-attribute can only be returned to a domain that string-compares ! equal to the domain that set the cookie (eg. \code{spam.example.com} ! won't be returned cookies from \code{example.com} that had no ! \code{domain} cookie-attribute). \end{memberdesc} \begin{memberdesc}{DomainRFC2965Match} --- 540,547 ---- \begin{memberdesc}{DomainStrictNonDomain} Cookies that did not explicitly specify a \code{domain} ! cookie-attribute can only be returned to a domain equal to the domain ! that set the cookie (eg. \code{spam.example.com} won't be returned ! cookies from \code{example.com} that had no \code{domain} ! cookie-attribute). \end{memberdesc} \begin{memberdesc}{DomainRFC2965Match} *************** *** 575,582 **** \end{memberdesc} \begin{memberdesc}[Cookie]{name} ! Cookie name (a string), or \constant{None}. \end{memberdesc} \begin{memberdesc}[Cookie]{value} ! Cookie value (a string). \end{memberdesc} \begin{memberdesc}[Cookie]{port} --- 580,587 ---- \end{memberdesc} \begin{memberdesc}[Cookie]{name} ! Cookie name (a string). \end{memberdesc} \begin{memberdesc}[Cookie]{value} ! Cookie value (a string), or \constant{None}. \end{memberdesc} \begin{memberdesc}[Cookie]{port} *************** *** 585,589 **** \end{memberdesc} \begin{memberdesc}[Cookie]{path} ! Cookie path (a string, eg. '/acme/rocket_launchers'). \end{memberdesc} \begin{memberdesc}[Cookie]{secure} --- 590,594 ---- \end{memberdesc} \begin{memberdesc}[Cookie]{path} ! Cookie path (a string, eg. \code{'/acme/rocket_launchers'}). \end{memberdesc} \begin{memberdesc}[Cookie]{secure} *************** *** 615,619 **** \begin{memberdesc}[Cookie]{domain_initial_dot} True if the domain explicitly specified by the server began with a ! dot ('.'). \end{memberdesc} --- 620,624 ---- \begin{memberdesc}[Cookie]{domain_initial_dot} True if the domain explicitly specified by the server began with a ! dot (\code{'.'}). \end{memberdesc} *************** *** 653,663 **** This example illustrates how to open a URL using your Netscape, ! Mozilla, or lynx cookies (assumes \UNIX{} convention for location of ! the cookies file): \begin{verbatim} import os, cookielib, urllib2 cj = cookielib.MozillaCookieJar() ! cj.load(os.path.join(os.environ["HOME"], "/.netscape/cookies.txt")) opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj)) r = opener.open("http://example.com/") --- 658,668 ---- This example illustrates how to open a URL using your Netscape, ! Mozilla, or Lynx cookies (assumes \UNIX{}/Netscape convention for ! location of the cookies file): \begin{verbatim} import os, cookielib, urllib2 cj = cookielib.MozillaCookieJar() ! cj.load(os.path.join(os.environ["HOME"], ".netscape/cookies.txt")) opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj)) r = opener.open("http://example.com/") *************** *** 671,677 **** \begin{verbatim} import urllib2 ! from cookielib import CookieJar, DefaultCookiePolicy as Policy ! policy = Policy(rfc2965=True, strict_ns_domain=Policy.DomainStrict, ! blocked_domains=["ads.net", ".ads.net"]) cj = CookieJar(policy) opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj)) --- 676,683 ---- \begin{verbatim} import urllib2 ! from cookielib import CookieJar, DefaultCookiePolicy ! policy = DefaultCookiePolicy( ! rfc2965=True, strict_ns_domain=Policy.DomainStrict, ! blocked_domains=["ads.net", ".ads.net"]) cj = CookieJar(policy) opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj)) From akuchling at users.sourceforge.net Sat Jul 10 20:43:35 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sat Jul 10 20:43:39 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1029,1.1030 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9450/Misc Modified Files: NEWS Log Message: Add an item Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1029 retrieving revision 1.1030 diff -C2 -d -r1.1029 -r1.1030 *** NEWS 10 Jul 2004 16:16:06 -0000 1.1029 --- NEWS 10 Jul 2004 18:43:32 -0000 1.1030 *************** *** 34,37 **** --- 34,40 ---- string methods of the same name). + - asyncore's dispatcher.set_reuse_addr() now works correctly on Windows. + SF patch 982681. + Tools/Demos ----------- From bcannon at users.sourceforge.net Sat Jul 10 21:09:23 2004 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Sat Jul 10 21:09:27 2004 Subject: [Python-checkins] python/dist/src/Lib zipfile.py,1.32,1.33 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12810/Lib Modified Files: zipfile.py Log Message: Make struct formats for specifying file size to be unsigned instead of signed (ZIP file spec. says in section K, "General notes" in point 1 that unless specified otherwise values are unsigned and they are not specified as signed in the spec). Closes bug #679953. Thanks Jimmy Burgett. Index: zipfile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/zipfile.py,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** zipfile.py 10 Jul 2004 15:40:29 -0000 1.32 --- zipfile.py 10 Jul 2004 19:09:20 -0000 1.33 *************** *** 24,30 **** structEndArchive = "<4s4H2lH" # 9 items, end of archive, 22 bytes stringEndArchive = "PK\005\006" # magic number for end of archive record ! structCentralDir = "<4s4B4H3l5HLl"# 19 items, central directory, 46 bytes stringCentralDir = "PK\001\002" # magic number for central directory ! structFileHeader = "<4s2B4H3l2H" # 12 items, file header record, 30 bytes stringFileHeader = "PK\003\004" # magic number for file header --- 24,30 ---- structEndArchive = "<4s4H2lH" # 9 items, end of archive, 22 bytes stringEndArchive = "PK\005\006" # magic number for end of archive record ! structCentralDir = "<4s4B4HlLL5HLl"# 19 items, central directory, 46 bytes stringCentralDir = "PK\001\002" # magic number for central directory ! structFileHeader = "<4s2B4HlLL2H" # 12 items, file header record, 30 bytes stringFileHeader = "PK\003\004" # magic number for file header *************** *** 440,444 **** position = self.fp.tell() # Preserve current position in file self.fp.seek(zinfo.header_offset + 14, 0) ! self.fp.write(struct.pack(" Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14479/Misc Modified Files: NEWS ACKS Log Message: Add note about closing of bug #679953 and add Jimmy Burgett for helping out to Misc/ACKS. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1030 retrieving revision 1.1031 diff -C2 -d -r1.1030 -r1.1031 *** NEWS 10 Jul 2004 18:43:32 -0000 1.1030 --- NEWS 10 Jul 2004 19:13:42 -0000 1.1031 *************** *** 27,30 **** --- 27,34 ---- ------- + - bug #679953: zipfile.py should now work for files over 2 GB. The packed data + for file sizes (compressed and uncompressed) was being stored as signed + instead of unsigned. + - decimal.py now only uses signals in the spec. The other conditions are no longer part of the public API. Index: ACKS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/ACKS,v retrieving revision 1.270 retrieving revision 1.271 diff -C2 -d -r1.270 -r1.271 *** ACKS 7 Jul 2004 17:44:10 -0000 1.270 --- ACKS 10 Jul 2004 19:13:42 -0000 1.271 *************** *** 84,87 **** --- 84,88 ---- Tommy Burnette Roger Burnham + Jimmy Burgett Alastair Burt Tarn Weisner Burton From bcannon at users.sourceforge.net Sat Jul 10 21:19:06 2004 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Sat Jul 10 21:19:10 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS, 1.831.4.129, 1.831.4.130 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15190/Misc Modified Files: Tag: release23-maint NEWS Log Message: zipfile now handles file sizes over 2 GB. Was incorrectly storing file sizes as signed when the ZIP spec says they should be stored as unsigned. Closes bug #679953. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.831.4.129 retrieving revision 1.831.4.130 diff -C2 -d -r1.831.4.129 -r1.831.4.130 *** NEWS 6 Jul 2004 17:55:25 -0000 1.831.4.129 --- NEWS 10 Jul 2004 19:19:03 -0000 1.831.4.130 *************** *** 40,43 **** --- 40,47 ---- Library ------- + + - Bug #679953: zipfile can now handle file sizes over 2 GB. Previously the + compressed and uncompressed file sizes were being stored as signed longs + instead of unsigned as the ZIP spec specifies. - Bug #981530: Fix UnboundLocalError in shutil.rmtree(). This affects From bcannon at users.sourceforge.net Sat Jul 10 21:19:06 2004 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Sat Jul 10 21:19:11 2004 Subject: [Python-checkins] python/dist/src/Lib zipfile.py,1.31,1.31.8.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15190/Lib Modified Files: Tag: release23-maint zipfile.py Log Message: zipfile now handles file sizes over 2 GB. Was incorrectly storing file sizes as signed when the ZIP spec says they should be stored as unsigned. Closes bug #679953. Index: zipfile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/zipfile.py,v retrieving revision 1.31 retrieving revision 1.31.8.1 diff -C2 -d -r1.31 -r1.31.8.1 *** zipfile.py 27 Jun 2003 22:25:03 -0000 1.31 --- zipfile.py 10 Jul 2004 19:19:03 -0000 1.31.8.1 *************** *** 24,30 **** structEndArchive = "<4s4H2lH" # 9 items, end of archive, 22 bytes stringEndArchive = "PK\005\006" # magic number for end of archive record ! structCentralDir = "<4s4B4H3l5HLl"# 19 items, central directory, 46 bytes stringCentralDir = "PK\001\002" # magic number for central directory ! structFileHeader = "<4s2B4H3l2H" # 12 items, file header record, 30 bytes stringFileHeader = "PK\003\004" # magic number for file header --- 24,30 ---- structEndArchive = "<4s4H2lH" # 9 items, end of archive, 22 bytes stringEndArchive = "PK\005\006" # magic number for end of archive record ! structCentralDir = "<4s4B4HlLL5HLl"# 19 items, central directory, 46 bytes stringCentralDir = "PK\001\002" # magic number for central directory ! structFileHeader = "<4s2B4HlLL2H" # 12 items, file header record, 30 bytes stringFileHeader = "PK\003\004" # magic number for file header *************** *** 440,444 **** position = self.fp.tell() # Preserve current position in file self.fp.seek(zinfo.header_offset + 14, 0) ! self.fp.write(struct.pack(" Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17021/Modules Modified Files: addrinfo.h Log Message: Add comments at end of every #endif and fix ones already there when for closing off #ifndef's. Index: addrinfo.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/addrinfo.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** addrinfo.h 29 Mar 2003 10:04:54 -0000 1.5 --- addrinfo.h 10 Jul 2004 19:30:39 -0000 1.6 *************** *** 54,58 **** #undef getaddrinfo #define getaddrinfo fake_getaddrinfo ! #endif #define EAI_ADDRFAMILY 1 /* address family for hostname not supported */ --- 54,58 ---- #undef getaddrinfo #define getaddrinfo fake_getaddrinfo ! #endif /* EAI_ADDRFAMILY */ #define EAI_ADDRFAMILY 1 /* address family for hostname not supported */ *************** *** 84,88 **** #undef AI_V4MAPPED #undef AI_DEFAULT ! #endif #define AI_PASSIVE 0x00000001 /* get address to use bind() */ --- 84,88 ---- #undef AI_V4MAPPED #undef AI_DEFAULT ! #endif /* AI_PASSIVE */ #define AI_PASSIVE 0x00000001 /* get address to use bind() */ *************** *** 99,103 **** #define AI_DEFAULT (AI_V4MAPPED_CFG | AI_ADDRCONFIG) ! #endif /* HAVE_GETADDRINFO */ #ifndef HAVE_GETNAMEINFO --- 99,103 ---- #define AI_DEFAULT (AI_V4MAPPED_CFG | AI_ADDRCONFIG) ! #endif /* !HAVE_GETADDRINFO */ #ifndef HAVE_GETNAMEINFO *************** *** 109,113 **** #define NI_MAXHOST 1025 #define NI_MAXSERV 32 ! #endif /* --- 109,113 ---- #define NI_MAXHOST 1025 #define NI_MAXSERV 32 ! #endif /* !NI_MAXHOST */ /* *************** *** 120,126 **** #define NI_NUMERICSERV 0x00000008 #define NI_DGRAM 0x00000010 ! #endif ! #endif /* HAVE_GETNAMEINFO */ #ifndef HAVE_ADDRINFO --- 120,126 ---- #define NI_NUMERICSERV 0x00000008 #define NI_DGRAM 0x00000010 ! #endif /* !NI_NOFQDN */ ! #endif /* !HAVE_GETNAMEINFO */ #ifndef HAVE_ADDRINFO *************** *** 135,139 **** struct addrinfo *ai_next; /* next structure in linked list */ }; ! #endif #ifndef HAVE_SOCKADDR_STORAGE --- 135,139 ---- struct addrinfo *ai_next; /* next structure in linked list */ }; ! #endif /* !HAVE_ADDRINFO */ #ifndef HAVE_SOCKADDR_STORAGE *************** *** 146,150 **** #else #define _SS_ALIGNSIZE (sizeof(double)) ! #endif #define _SS_PAD1SIZE (_SS_ALIGNSIZE - sizeof(u_char) * 2) #define _SS_PAD2SIZE (_SS_MAXSIZE - sizeof(u_char) * 2 - \ --- 146,150 ---- #else #define _SS_ALIGNSIZE (sizeof(double)) ! #endif /* HAVE_LONG_LONG */ #define _SS_PAD1SIZE (_SS_ALIGNSIZE - sizeof(u_char) * 2) #define _SS_PAD2SIZE (_SS_MAXSIZE - sizeof(u_char) * 2 - \ *************** *** 157,161 **** #else unsigned short ss_family; /* address family */ ! #endif char __ss_pad1[_SS_PAD1SIZE]; #ifdef HAVE_LONG_LONG --- 157,161 ---- #else unsigned short ss_family; /* address family */ ! #endif /* HAVE_SOCKADDR_SA_LEN */ char __ss_pad1[_SS_PAD1SIZE]; #ifdef HAVE_LONG_LONG *************** *** 163,170 **** #else double __ss_align; /* force desired structure storage alignment */ ! #endif char __ss_pad2[_SS_PAD2SIZE]; }; ! #endif #ifdef __cplusplus --- 163,170 ---- #else double __ss_align; /* force desired structure storage alignment */ ! #endif /* HAVE_LONG_LONG */ char __ss_pad2[_SS_PAD2SIZE]; }; ! #endif /* !HAVE_SOCKADDR_STORAGE */ #ifdef __cplusplus From akuchling at users.sourceforge.net Sat Jul 10 21:46:42 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sat Jul 10 21:46:46 2004 Subject: [Python-checkins] python/dist/src/Lib urllib2.py,1.70,1.71 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19354 Modified Files: urllib2.py Log Message: [Patch #988602] Move the urllib2 tests into the test framework Index: urllib2.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/urllib2.py,v retrieving revision 1.70 retrieving revision 1.71 diff -C2 -d -r1.70 -r1.71 *** urllib2.py 10 Jul 2004 15:34:34 -0000 1.70 --- urllib2.py 10 Jul 2004 19:46:40 -0000 1.71 *************** *** 1275,1353 **** ph = ph() opener.add_handler(ph) - - if __name__ == "__main__": - # XXX some of the test code depends on machine configurations that - # are internal to CNRI. Need to set up a public server with the - # right authentication configuration for test purposes. - if socket.gethostname() == 'bitdiddle': - localhost = 'bitdiddle.cnri.reston.va.us' - elif socket.gethostname() == 'bitdiddle.concentric.net': - localhost = 'localhost' - else: - localhost = None - urls = [ - # Thanks to Fred for finding these! - 'gopher://gopher.lib.ncsu.edu/11/library/stacks/Alex', - 'gopher://gopher.vt.edu:10010/10/33', - - 'file:/etc/passwd', - 'file://nonsensename/etc/passwd', - 'ftp://www.python.org/pub/python/misc/sousa.au', - 'ftp://www.python.org/pub/tmp/blat', - 'http://www.espn.com/', # redirect - 'http://www.python.org/Spanish/Inquistion/', - ('http://www.python.org/cgi-bin/faqw.py', - 'query=pythonistas&querytype=simple&casefold=yes&req=search'), - 'http://www.python.org/', - 'ftp://gatekeeper.research.compaq.com/pub/DEC/SRC/research-reports/00README-Legal-Rules-Regs', - ] - - ## if localhost is not None: - ## urls = urls + [ - ## 'file://%s/etc/passwd' % localhost, - ## 'http://%s/simple/' % localhost, - ## 'http://%s/digest/' % localhost, - ## 'http://%s/not/found.h' % localhost, - ## ] - - ## bauth = HTTPBasicAuthHandler() - ## bauth.add_password('basic_test_realm', localhost, 'jhylton', - ## 'password') - ## dauth = HTTPDigestAuthHandler() - ## dauth.add_password('digest_test_realm', localhost, 'jhylton', - ## 'password') - - - cfh = CacheFTPHandler() - cfh.setTimeout(1) - - ## # XXX try out some custom proxy objects too! - ## def at_cnri(req): - ## host = req.get_host() - ## print host - ## if host[-18:] == '.cnri.reston.va.us': - ## return 1 - ## p = CustomProxy('http', at_cnri, 'proxy.cnri.reston.va.us') - ## ph = CustomProxyHandler(p) - - ## install_opener(build_opener(dauth, bauth, cfh, GopherHandler, ph)) - install_opener(build_opener(cfh, GopherHandler)) - - for url in urls: - if isinstance(url, tuple): - url, req = url - else: - req = None - print url - try: - f = urlopen(url, req) - except IOError, err: - print "IOError:", err - except socket.error, err: - print "socket.error:", err - else: - buf = f.read() - f.close() - print "read %d bytes" % len(buf) - print - time.sleep(0.1) --- 1275,1276 ---- From akuchling at users.sourceforge.net Sat Jul 10 21:46:42 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sat Jul 10 21:46:47 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_urllib2.py, 1.16, 1.17 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19354/test Modified Files: test_urllib2.py Log Message: [Patch #988602] Move the urllib2 tests into the test framework Index: test_urllib2.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_urllib2.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** test_urllib2.py 8 Jul 2004 04:22:19 -0000 1.16 --- test_urllib2.py 10 Jul 2004 19:46:40 -0000 1.17 *************** *** 2,6 **** from test import test_support ! import os import StringIO --- 2,6 ---- from test import test_support ! import os, socket import StringIO *************** *** 672,675 **** --- 672,681 ---- class NetworkTests(unittest.TestCase): + def setUp(self): + if 0: # for debugging + import logging + logger = logging.getLogger("test_urllib2") + logger.addHandler(logging.StreamHandler()) + def test_range (self): req = urllib2.Request("http://www.python.org", *************** *** 679,682 **** --- 685,810 ---- self.assertEqual(len(data), 20) + # XXX The rest of these tests aren't very good -- they don't check much. + # They do sometimes catch some major disasters, though. + + def test_ftp(self): + urls = [ + 'ftp://www.python.org/pub/python/misc/sousa.au', + 'ftp://www.python.org/pub/tmp/blat', + 'ftp://gatekeeper.research.compaq.com/pub/DEC/SRC' + '/research-reports/00README-Legal-Rules-Regs', + ] + self._test_urls(urls, self._extra_handlers()) + + def test_gopher(self): + urls = [ + # Thanks to Fred for finding these! + 'gopher://gopher.lib.ncsu.edu/11/library/stacks/Alex', + 'gopher://gopher.vt.edu:10010/10/33', + ] + self._test_urls(urls, self._extra_handlers()) + + def test_file(self): + TESTFN = test_support.TESTFN + f = open(TESTFN, 'w') + try: + f.write('hi there\n') + f.close() + urls = [ + 'file:'+sanepathname2url(os.path.abspath(TESTFN)), + + # XXX bug, should raise URLError + #('file://nonsensename/etc/passwd', None, urllib2.URLError) + ('file://nonsensename/etc/passwd', None, (OSError, socket.error)) + ] + self._test_urls(urls, self._extra_handlers()) + finally: + os.remove(TESTFN) + + def test_http(self): + urls = [ + 'http://www.espn.com/', # redirect + 'http://www.python.org/Spanish/Inquistion/', + ('http://www.python.org/cgi-bin/faqw.py', + 'query=pythonistas&querytype=simple&casefold=yes&req=search', None), + 'http://www.python.org/', + ] + self._test_urls(urls, self._extra_handlers()) + + # XXX Following test depends on machine configurations that are internal + # to CNRI. Need to set up a public server with the right authentication + # configuration for test purposes. + + ## def test_cnri(self): + ## if socket.gethostname() == 'bitdiddle': + ## localhost = 'bitdiddle.cnri.reston.va.us' + ## elif socket.gethostname() == 'bitdiddle.concentric.net': + ## localhost = 'localhost' + ## else: + ## localhost = None + ## if localhost is not None: + ## urls = [ + ## 'file://%s/etc/passwd' % localhost, + ## 'http://%s/simple/' % localhost, + ## 'http://%s/digest/' % localhost, + ## 'http://%s/not/found.h' % localhost, + ## ] + + ## bauth = HTTPBasicAuthHandler() + ## bauth.add_password('basic_test_realm', localhost, 'jhylton', + ## 'password') + ## dauth = HTTPDigestAuthHandler() + ## dauth.add_password('digest_test_realm', localhost, 'jhylton', + ## 'password') + + ## self._test_urls(urls, self._extra_handlers()+[bauth, dauth]) + + def _test_urls(self, urls, handlers): + import socket + import time + import logging + debug = logging.getLogger("test_urllib2").debug + + urllib2.install_opener(urllib2.build_opener(*handlers)) + + for url in urls: + if isinstance(url, tuple): + url, req, expected_err = url + else: + req = expected_err = None + debug(url) + try: + f = urllib2.urlopen(url, req) + except (IOError, socket.error, OSError), err: + debug(err) + if expected_err: + self.assert_(isinstance(err, expected_err)) + else: + buf = f.read() + f.close() + debug("read %d bytes" % len(buf)) + debug("******** next url coming up...") + time.sleep(0.1) + + def _extra_handlers(self): + handlers = [] + + handlers.append(urllib2.GopherHandler) + + cfh = urllib2.CacheFTPHandler() + cfh.setTimeout(1) + handlers.append(cfh) + + ## # XXX try out some custom proxy objects too! + ## def at_cnri(req): + ## host = req.get_host() + ## debug(host) + ## if host[-18:] == '.cnri.reston.va.us': + ## return True + ## p = CustomProxy('http', at_cnri, 'proxy.cnri.reston.va.us') + ## ph = CustomProxyHandler(p) + ## handlers.append(ph) + + return handlers From bcannon at users.sourceforge.net Sat Jul 10 22:42:25 2004 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Sat Jul 10 22:42:28 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_ntpath.py, 1.18, 1.19 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27463/Lib/test Modified Files: test_ntpath.py Log Message: Make ntpath compress multiple slashes between drive letter and the rest of the path. Also clarifies UNC handling and adds appropriate tests. Applies patch #988607 to fix bug #980327. Thanks Paul Moore. Index: test_ntpath.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_ntpath.py,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** test_ntpath.py 24 Dec 2002 18:31:27 -0000 1.18 --- test_ntpath.py 10 Jul 2004 20:42:22 -0000 1.19 *************** *** 100,109 **** tester("ntpath.normpath('e:A/foo/../B')", r'e:A\B') ! # Next 3 seem dubious, and especially the 3rd, but normpath is possibly ! # trying to leave UNC paths alone without actually knowing anything about ! # them. ! tester("ntpath.normpath('C:///A//B')", r'C:\\\A\B') ! tester("ntpath.normpath('D:///A/./B')", r'D:\\\A\B') ! tester("ntpath.normpath('e:///A/foo/../B')", r'e:\\\A\B') tester("ntpath.normpath('..')", r'..') --- 100,106 ---- tester("ntpath.normpath('e:A/foo/../B')", r'e:A\B') ! tester("ntpath.normpath('C:///A//B')", r'C:\A\B') ! tester("ntpath.normpath('D:///A/./B')", r'D:\A\B') ! tester("ntpath.normpath('e:///A/foo/../B')", r'e:\A\B') tester("ntpath.normpath('..')", r'..') *************** *** 116,119 **** --- 113,118 ---- tester("ntpath.normpath('../.././..')", r'..\..\..') tester("ntpath.normpath('K:../.././..')", r'K:..\..\..') + tester("ntpath.normpath('C:////a/b')", r'C:\a\b') + tester("ntpath.normpath('//machine/share//a/b')", r'\\machine\share\a\b') # ntpath.abspath() can only be used on a system with the "nt" module From bcannon at users.sourceforge.net Sat Jul 10 22:42:25 2004 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Sat Jul 10 22:42:29 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1031,1.1032 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27463/Misc Modified Files: NEWS Log Message: Make ntpath compress multiple slashes between drive letter and the rest of the path. Also clarifies UNC handling and adds appropriate tests. Applies patch #988607 to fix bug #980327. Thanks Paul Moore. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1031 retrieving revision 1.1032 diff -C2 -d -r1.1031 -r1.1032 *** NEWS 10 Jul 2004 19:13:42 -0000 1.1031 --- NEWS 10 Jul 2004 20:42:22 -0000 1.1032 *************** *** 27,30 **** --- 27,34 ---- ------- + - Bug #980327: ntpath not handles compressing erroneous slashes between the + drive letter and the rest of the path. Also clearly handles UNC addresses now + as well. Thanks Paul Moore. + - bug #679953: zipfile.py should now work for files over 2 GB. The packed data for file sizes (compressed and uncompressed) was being stored as signed From bcannon at users.sourceforge.net Sat Jul 10 22:42:25 2004 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Sat Jul 10 22:42:32 2004 Subject: [Python-checkins] python/dist/src/Lib ntpath.py,1.59,1.60 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27463/Lib Modified Files: ntpath.py Log Message: Make ntpath compress multiple slashes between drive letter and the rest of the path. Also clarifies UNC handling and adds appropriate tests. Applies patch #988607 to fix bug #980327. Thanks Paul Moore. Index: ntpath.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/ntpath.py,v retrieving revision 1.59 retrieving revision 1.60 diff -C2 -d -r1.59 -r1.60 *** ntpath.py 8 Jun 2004 08:29:32 -0000 1.59 --- ntpath.py 10 Jul 2004 20:42:21 -0000 1.60 *************** *** 441,447 **** path = path.replace("/", "\\") prefix, path = splitdrive(path) ! while path[:1] == "\\": ! prefix = prefix + "\\" ! path = path[1:] comps = path.split("\\") i = 0 --- 441,463 ---- path = path.replace("/", "\\") prefix, path = splitdrive(path) ! # We need to be careful here. If the prefix is empty, and the path starts ! # with a backslash, it could either be an absolute path on the current ! # drive (\dir1\dir2\file) or a UNC filename (\\server\mount\dir1\file). It ! # is therefore imperative NOT to collapse multiple backslashes blindly in ! # that case. ! # The code below preserves multiple backslashes when there is no drive ! # letter. This means that the invalid filename \\\a\b is preserved ! # unchanged, where a\\\b is normalised to a\b. It's not clear that there ! # is any better behaviour for such edge cases. ! if prefix == '': ! # No drive letter - preserve initial backslashes ! while path[:1] == "\\": ! prefix = prefix + "\\" ! path = path[1:] ! else: ! # We have a drive letter - collapse initial backslashes ! if path.startswith("\\"): ! prefix = prefix + "\\" ! path = path.lstrip("\\") comps = path.split("\\") i = 0 From bcannon at users.sourceforge.net Sat Jul 10 22:47:31 2004 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Sat Jul 10 22:47:35 2004 Subject: [Python-checkins] python/dist/src/Lib ntpath.py, 1.57.10.1, 1.57.10.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28277/Lib Modified Files: Tag: release23-maint ntpath.py Log Message: ntpath now compresses erroneous slashes between the drive letter and rest of the path. Also clarifies handling of UNC paths. Appropriate test were added. Fixes bug #980327 with patch #988607. Thanks Paul Moore. Index: ntpath.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/ntpath.py,v retrieving revision 1.57.10.1 retrieving revision 1.57.10.2 diff -C2 -d -r1.57.10.1 -r1.57.10.2 *** ntpath.py 20 Oct 2003 14:34:45 -0000 1.57.10.1 --- ntpath.py 10 Jul 2004 20:47:28 -0000 1.57.10.2 *************** *** 440,446 **** path = path.replace("/", "\\") prefix, path = splitdrive(path) ! while path[:1] == "\\": ! prefix = prefix + "\\" ! path = path[1:] comps = path.split("\\") i = 0 --- 440,462 ---- path = path.replace("/", "\\") prefix, path = splitdrive(path) ! # We need to be careful here. If the prefix is empty, and the path starts ! # with a backslash, it could either be an absolute path on the current ! # drive (\dir1\dir2\file) or a UNC filename (\\server\mount\dir1\file). It ! # is therefore imperative NOT to collapse multiple backslashes blindly in ! # that case. ! # The code below preserves multiple backslashes when there is no drive ! # letter. This means that the invalid filename \\\a\b is preserved ! # unchanged, where a\\\b is normalised to a\b. It's not clear that there ! # is any better behaviour for such edge cases. ! if prefix == '': ! # No drive letter - preserve initial backslashes ! while path[:1] == "\\": ! prefix = prefix + "\\" ! path = path[1:] ! else: ! # We have a drive letter - collapse initial backslashes ! if path.startswith("\\"): ! prefix = prefix + "\\" ! path = path.lstrip("\\") comps = path.split("\\") i = 0 From bcannon at users.sourceforge.net Sat Jul 10 22:47:31 2004 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Sat Jul 10 22:47:36 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_ntpath.py, 1.18, 1.18.16.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28277/Lib/test Modified Files: Tag: release23-maint test_ntpath.py Log Message: ntpath now compresses erroneous slashes between the drive letter and rest of the path. Also clarifies handling of UNC paths. Appropriate test were added. Fixes bug #980327 with patch #988607. Thanks Paul Moore. Index: test_ntpath.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_ntpath.py,v retrieving revision 1.18 retrieving revision 1.18.16.1 diff -C2 -d -r1.18 -r1.18.16.1 *** test_ntpath.py 24 Dec 2002 18:31:27 -0000 1.18 --- test_ntpath.py 10 Jul 2004 20:47:28 -0000 1.18.16.1 *************** *** 100,109 **** tester("ntpath.normpath('e:A/foo/../B')", r'e:A\B') ! # Next 3 seem dubious, and especially the 3rd, but normpath is possibly ! # trying to leave UNC paths alone without actually knowing anything about ! # them. ! tester("ntpath.normpath('C:///A//B')", r'C:\\\A\B') ! tester("ntpath.normpath('D:///A/./B')", r'D:\\\A\B') ! tester("ntpath.normpath('e:///A/foo/../B')", r'e:\\\A\B') tester("ntpath.normpath('..')", r'..') --- 100,106 ---- tester("ntpath.normpath('e:A/foo/../B')", r'e:A\B') ! tester("ntpath.normpath('C:///A//B')", r'C:\A\B') ! tester("ntpath.normpath('D:///A/./B')", r'D:\A\B') ! tester("ntpath.normpath('e:///A/foo/../B')", r'e:\A\B') tester("ntpath.normpath('..')", r'..') *************** *** 116,119 **** --- 113,118 ---- tester("ntpath.normpath('../.././..')", r'..\..\..') tester("ntpath.normpath('K:../.././..')", r'K:..\..\..') + tester("ntpath.normpath('C:////a/b')", r'C:\a\b') + tester("ntpath.normpath('//machine/share//a/b')", r'\\machine\share\a\b') # ntpath.abspath() can only be used on a system with the "nt" module From bcannon at users.sourceforge.net Sat Jul 10 22:47:31 2004 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Sat Jul 10 22:47:37 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS, 1.831.4.130, 1.831.4.131 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28277/Misc Modified Files: Tag: release23-maint NEWS Log Message: ntpath now compresses erroneous slashes between the drive letter and rest of the path. Also clarifies handling of UNC paths. Appropriate test were added. Fixes bug #980327 with patch #988607. Thanks Paul Moore. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.831.4.130 retrieving revision 1.831.4.131 diff -C2 -d -r1.831.4.130 -r1.831.4.131 *** NEWS 10 Jul 2004 19:19:03 -0000 1.831.4.130 --- NEWS 10 Jul 2004 20:47:29 -0000 1.831.4.131 *************** *** 41,44 **** --- 41,48 ---- ------- + - Bug #980327/Patch #988607: ntpath now compresses extra slashes between the + drive letter and the rest of the path properly. Also removed ambiguity from + UNC paths. Thanks Paul Moore. + - Bug #679953: zipfile can now handle file sizes over 2 GB. Previously the compressed and uncompressed file sizes were being stored as signed longs From bcannon at users.sourceforge.net Sat Jul 10 23:04:47 2004 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Sat Jul 10 23:04:49 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libinspect.tex, 1.13.10.3, 1.13.10.4 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31131/Doc/lib Modified Files: Tag: release23-maint libinspect.tex Log Message: Clarify docs for getargspec() that when there are not default values the fourth value in the returned tuple is None. Closes bug #637217 by clarifying the behavior. Index: libinspect.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libinspect.tex,v retrieving revision 1.13.10.3 retrieving revision 1.13.10.4 diff -C2 -d -r1.13.10.3 -r1.13.10.4 *** libinspect.tex 12 May 2004 03:03:44 -0000 1.13.10.3 --- libinspect.tex 10 Jul 2004 21:04:44 -0000 1.13.10.4 *************** *** 256,262 **** \var{varargs} and \var{varkw} are the names of the \code{*} and \code{**} arguments or \code{None}. ! \var{defaults} is a tuple of default argument values; if this tuple ! has \var{n} elements, they correspond to the last \var{n} elements ! listed in \var{args}. \end{funcdesc} --- 256,262 ---- \var{varargs} and \var{varkw} are the names of the \code{*} and \code{**} arguments or \code{None}. ! \var{defaults} is a tuple of default argument values or None if there are not ! any; if the tuple has \var{n} elements, they correspond to the last \var{n} ! elements listed in \var{args}. \end{funcdesc} From bcannon at users.sourceforge.net Sat Jul 10 23:13:10 2004 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Sat Jul 10 23:13:12 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libinspect.tex,1.16,1.17 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32707/Doc/lib Modified Files: libinspect.tex Log Message: Clarify docs for inspect.getargspec() that the fourth value is None when there are no default arguments for the function. Index: libinspect.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libinspect.tex,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** libinspect.tex 12 May 2004 03:07:27 -0000 1.16 --- libinspect.tex 10 Jul 2004 21:13:06 -0000 1.17 *************** *** 256,262 **** \var{varargs} and \var{varkw} are the names of the \code{*} and \code{**} arguments or \code{None}. ! \var{defaults} is a tuple of default argument values; if this tuple ! has \var{n} elements, they correspond to the last \var{n} elements ! listed in \var{args}. \end{funcdesc} --- 256,262 ---- \var{varargs} and \var{varkw} are the names of the \code{*} and \code{**} arguments or \code{None}. ! \var{defaults} is a tuple of default argument values or None if there are no ! default arguments; if this tuple has \var{n} elements, they correspond to ! the last \var{n} elements listed in \var{args}. \end{funcdesc} From akuchling at users.sourceforge.net Sat Jul 10 23:15:20 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sat Jul 10 23:15:24 2004 Subject: [Python-checkins] python/dist/src/Modules _ssl.c,1.16,1.17 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv656 Modified Files: _ssl.c Log Message: [Patch #945642] Fix non-blocking SSL sockets, which blocked on reads/writes in Python 2.3. (It turns out that the Debian unstable packaging of Python 2.3.4 includes this patch.) Patch by Tino Lange. Index: _ssl.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_ssl.c,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** _ssl.c 23 Mar 2004 23:16:54 -0000 1.16 --- _ssl.c 10 Jul 2004 21:15:17 -0000 1.17 *************** *** 65,72 **** static PyObject *PySSL_SSLwrite(PySSLObject *self, PyObject *args); static PyObject *PySSL_SSLread(PySSLObject *self, PyObject *args); ! static int wait_for_timeout(PySocketSockObject *s, int writing); #define PySSLObject_Check(v) ((v)->ob_type == &PySSL_Type) /* XXX It might be helpful to augment the error message generated below with the name of the SSL function that generated the error. --- 65,81 ---- static PyObject *PySSL_SSLwrite(PySSLObject *self, PyObject *args); static PyObject *PySSL_SSLread(PySSLObject *self, PyObject *args); ! static int check_socket_and_wait_for_timeout(PySocketSockObject *s, ! int writing); #define PySSLObject_Check(v) ((v)->ob_type == &PySSL_Type) + typedef enum { + SOCKET_IS_NONBLOCKING, + SOCKET_IS_BLOCKING, + SOCKET_HAS_TIMED_OUT, + SOCKET_HAS_BEEN_CLOSED, + SOCKET_OPERATION_OK + } timeout_state; + /* XXX It might be helpful to augment the error message generated below with the name of the SSL function that generated the error. *************** *** 171,175 **** int ret; int err; ! int timedout; self = PyObject_New(PySSLObject, &PySSL_Type); /* Create new object */ --- 180,184 ---- int ret; int err; ! int sockstate; self = PyObject_New(PySSLObject, &PySSL_Type); /* Create new object */ *************** *** 240,244 **** /* Actually negotiate SSL connection */ /* XXX If SSL_connect() returns 0, it's also a failure. */ ! timedout = 0; do { Py_BEGIN_ALLOW_THREADS --- 249,253 ---- /* Actually negotiate SSL connection */ /* XXX If SSL_connect() returns 0, it's also a failure. */ ! sockstate = 0; do { Py_BEGIN_ALLOW_THREADS *************** *** 250,260 **** } if (err == SSL_ERROR_WANT_READ) { ! timedout = wait_for_timeout(Sock, 0); } else if (err == SSL_ERROR_WANT_WRITE) { ! timedout = wait_for_timeout(Sock, 1); } ! if (timedout) { ! errstr = "The connect operation timed out"; goto fail; } } while (err == SSL_ERROR_WANT_READ || err == SSL_ERROR_WANT_WRITE); --- 259,276 ---- } if (err == SSL_ERROR_WANT_READ) { ! sockstate = check_socket_and_wait_for_timeout(Sock, 0); } else if (err == SSL_ERROR_WANT_WRITE) { ! sockstate = check_socket_and_wait_for_timeout(Sock, 1); ! } else { ! sockstate = SOCKET_OPERATION_OK; } ! if (sockstate == SOCKET_HAS_TIMED_OUT) { ! PyErr_SetString(PySSLErrorObject, "The connect operation timed out"); ! goto fail; ! } else if (sockstate == SOCKET_HAS_BEEN_CLOSED) { ! PyErr_SetString(PySSLErrorObject, "Underlying socket has been closed."); goto fail; + } else if (sockstate == SOCKET_IS_NONBLOCKING) { + break; } } while (err == SSL_ERROR_WANT_READ || err == SSL_ERROR_WANT_WRITE); *************** *** 335,342 **** /* If the socket has a timeout, do a select() on the socket. The argument writing indicates the direction. ! Return non-zero if the socket timed out, zero otherwise. */ static int ! wait_for_timeout(PySocketSockObject *s, int writing) { fd_set fds; --- 351,359 ---- /* If the socket has a timeout, do a select() on the socket. The argument writing indicates the direction. ! Returns one of the possibilities in the timeout_state enum (above). */ + static int ! check_socket_and_wait_for_timeout(PySocketSockObject *s, int writing) { fd_set fds; *************** *** 345,354 **** /* Nothing to do unless we're in timeout mode (not non-blocking) */ ! if (s->sock_timeout <= 0.0) ! return 0; /* Guard against closed socket */ if (s->sock_fd < 0) ! return 0; /* Construct the arguments to select */ --- 362,373 ---- /* Nothing to do unless we're in timeout mode (not non-blocking) */ ! if (s->sock_timeout < 0.0) ! return SOCKET_IS_BLOCKING; ! else if (s->sock_timeout == 0.0) ! return SOCKET_IS_NONBLOCKING; /* Guard against closed socket */ if (s->sock_fd < 0) ! return SOCKET_HAS_BEEN_CLOSED; /* Construct the arguments to select */ *************** *** 366,371 **** Py_END_ALLOW_THREADS ! /* Return 1 on timeout, 0 otherwise */ ! return rc == 0; } --- 385,391 ---- Py_END_ALLOW_THREADS ! /* Return SOCKET_TIMED_OUT on timeout, SOCKET_OPERATION_OK otherwise ! (when we are able to write or when there's something to read) */ ! return rc == 0 ? SOCKET_HAS_TIMED_OUT : SOCKET_OPERATION_OK; } *************** *** 375,379 **** int len; int count; ! int timedout; int err; --- 395,399 ---- int len; int count; ! int sockstate; int err; *************** *** 381,388 **** return NULL; ! timedout = wait_for_timeout(self->Socket, 1); ! if (timedout) { PyErr_SetString(PySSLErrorObject, "The write operation timed out"); return NULL; } do { --- 401,411 ---- return NULL; ! sockstate = check_socket_and_wait_for_timeout(self->Socket, 1); ! if (sockstate == SOCKET_HAS_TIMED_OUT) { PyErr_SetString(PySSLErrorObject, "The write operation timed out"); return NULL; + } else if (sockstate == SOCKET_HAS_BEEN_CLOSED) { + PyErr_SetString(PySSLErrorObject, "Underlying socket has been closed."); + return NULL; } do { *************** *** 396,406 **** } if (err == SSL_ERROR_WANT_READ) { ! timedout = wait_for_timeout(self->Socket, 0); } else if (err == SSL_ERROR_WANT_WRITE) { ! timedout = wait_for_timeout(self->Socket, 1); } ! if (timedout) { PyErr_SetString(PySSLErrorObject, "The write operation timed out"); return NULL; } } while (err == SSL_ERROR_WANT_READ || err == SSL_ERROR_WANT_WRITE); --- 419,436 ---- } if (err == SSL_ERROR_WANT_READ) { ! sockstate = check_socket_and_wait_for_timeout(self->Socket, 0); } else if (err == SSL_ERROR_WANT_WRITE) { ! sockstate = check_socket_and_wait_for_timeout(self->Socket, 1); ! } else { ! sockstate = SOCKET_OPERATION_OK; } ! if (sockstate == SOCKET_HAS_TIMED_OUT) { PyErr_SetString(PySSLErrorObject, "The write operation timed out"); return NULL; + } else if (sockstate == SOCKET_HAS_BEEN_CLOSED) { + PyErr_SetString(PySSLErrorObject, "Underlying socket has been closed."); + return NULL; + } else if (sockstate == SOCKET_IS_NONBLOCKING) { + break; } } while (err == SSL_ERROR_WANT_READ || err == SSL_ERROR_WANT_WRITE); *************** *** 422,426 **** int count = 0; int len = 1024; ! int timedout; int err; --- 452,456 ---- int count = 0; int len = 1024; ! int sockstate; int err; *************** *** 431,436 **** return NULL; ! timedout = wait_for_timeout(self->Socket, 0); ! if (timedout) { PyErr_SetString(PySSLErrorObject, "The read operation timed out"); Py_DECREF(buf); --- 461,466 ---- return NULL; ! sockstate = check_socket_and_wait_for_timeout(self->Socket, 0); ! if (sockstate == SOCKET_HAS_TIMED_OUT) { PyErr_SetString(PySSLErrorObject, "The read operation timed out"); Py_DECREF(buf); *************** *** 448,459 **** } if (err == SSL_ERROR_WANT_READ) { ! timedout = wait_for_timeout(self->Socket, 0); } else if (err == SSL_ERROR_WANT_WRITE) { ! timedout = wait_for_timeout(self->Socket, 1); } ! if (timedout) { PyErr_SetString(PySSLErrorObject, "The read operation timed out"); Py_DECREF(buf); return NULL; } } while (err == SSL_ERROR_WANT_READ || err == SSL_ERROR_WANT_WRITE); --- 478,493 ---- } if (err == SSL_ERROR_WANT_READ) { ! sockstate = check_socket_and_wait_for_timeout(self->Socket, 0); } else if (err == SSL_ERROR_WANT_WRITE) { ! sockstate = check_socket_and_wait_for_timeout(self->Socket, 1); ! } else { ! sockstate = SOCKET_OPERATION_OK; } ! if (sockstate == SOCKET_HAS_TIMED_OUT) { PyErr_SetString(PySSLErrorObject, "The read operation timed out"); Py_DECREF(buf); return NULL; + } else if (sockstate == SOCKET_IS_NONBLOCKING) { + break; } } while (err == SSL_ERROR_WANT_READ || err == SSL_ERROR_WANT_WRITE); From akuchling at users.sourceforge.net Sat Jul 10 23:21:57 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sat Jul 10 23:22:00 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS, 1.1032, 1.1033 ACKS, 1.271, 1.272 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1777/Misc Modified Files: NEWS ACKS Log Message: Add item Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1032 retrieving revision 1.1033 diff -C2 -d -r1.1032 -r1.1033 *** NEWS 10 Jul 2004 20:42:22 -0000 1.1032 --- NEWS 10 Jul 2004 21:21:54 -0000 1.1033 *************** *** 45,48 **** --- 45,51 ---- SF patch 982681. + - Non-blocking SSL sockets work again; they were broken in Python 2.3. + SF patch 945642. + Tools/Demos ----------- Index: ACKS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/ACKS,v retrieving revision 1.271 retrieving revision 1.272 diff -C2 -d -r1.271 -r1.272 *** ACKS 10 Jul 2004 19:13:42 -0000 1.271 --- ACKS 10 Jul 2004 21:21:55 -0000 1.272 *************** *** 329,332 **** --- 329,333 ---- Vladimir Kushnir Cameron Laird + Tino Lange Andrew Langmead Detlef Lannert From akuchling at users.sourceforge.net Sat Jul 10 23:36:57 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sat Jul 10 23:37:01 2004 Subject: [Python-checkins] python/dist/src/Modules _ssl.c,1.17,1.18 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3678 Modified Files: _ssl.c Log Message: [Patch #909007] Enable a bunch of safe bug workarounds in OpenSSL, for compatibility with various broken SSL implementations out there. Index: _ssl.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_ssl.c,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** _ssl.c 10 Jul 2004 21:15:17 -0000 1.17 --- _ssl.c 10 Jul 2004 21:36:55 -0000 1.18 *************** *** 221,224 **** --- 221,225 ---- cert_file); Py_END_ALLOW_THREADS + SSL_CTX_set_options(self->ctx, SSL_OP_ALL); /* ssl compatibility */ if (ret < 1) { errstr = "SSL_CTX_use_certificate_chain_file error"; From bcannon at users.sourceforge.net Sat Jul 10 23:41:16 2004 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Sat Jul 10 23:41:23 2004 Subject: [Python-checkins] python/dist/src/Modules _codecsmodule.c, 2.18, 2.19 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4118/Modules Modified Files: _codecsmodule.c Log Message: Change some declarations from ``char *`` to ``const char *``. Also added docstrings for decode and encode; accidentally were left out of the PyMethodDev table. Index: _codecsmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_codecsmodule.c,v retrieving revision 2.18 retrieving revision 2.19 diff -C2 -d -r2.18 -r2.19 *** _codecsmodule.c 10 Jul 2004 12:06:09 -0000 2.18 --- _codecsmodule.c 10 Jul 2004 21:41:14 -0000 2.19 *************** *** 98,103 **** codec_encode(PyObject *self, PyObject *args) { ! char *encoding = NULL; ! char *errors = NULL; PyObject *v; --- 98,103 ---- codec_encode(PyObject *self, PyObject *args) { ! const char *encoding = NULL; ! const char *errors = NULL; PyObject *v; *************** *** 131,136 **** codec_decode(PyObject *self, PyObject *args) { ! char *encoding = NULL; ! char *errors = NULL; PyObject *v; --- 131,136 ---- codec_decode(PyObject *self, PyObject *args) { ! const char *encoding = NULL; ! const char *errors = NULL; PyObject *v; *************** *** 836,841 **** {"lookup", codec_lookup, METH_VARARGS, lookup__doc__}, ! {"encode", codec_encode, METH_VARARGS}, ! {"decode", codec_decode, METH_VARARGS}, {"escape_encode", escape_encode, METH_VARARGS}, {"escape_decode", escape_decode, METH_VARARGS}, --- 836,843 ---- {"lookup", codec_lookup, METH_VARARGS, lookup__doc__}, ! {"encode", codec_encode, METH_VARARGS, ! encode__doc__}, ! {"decode", codec_decode, METH_VARARGS, ! decode__doc__}, {"escape_encode", escape_encode, METH_VARARGS}, {"escape_decode", escape_decode, METH_VARARGS}, From akuchling at users.sourceforge.net Sat Jul 10 23:49:48 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sat Jul 10 23:50:01 2004 Subject: [Python-checkins] python/dist/src/Lib markupbase.py,1.9,1.10 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5710 Modified Files: markupbase.py Log Message: [Patch #965175] Incorporate a suggestion for a better error message Index: markupbase.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/markupbase.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** markupbase.py 12 Feb 2004 17:35:06 -0000 1.9 --- markupbase.py 10 Jul 2004 21:49:45 -0000 1.10 *************** *** 376,380 **** else: self.updatepos(declstartpos, i) ! self.error("expected name token") # To be overridden -- handlers for unknown objects --- 376,381 ---- else: self.updatepos(declstartpos, i) ! self.error("expected name token at %r" ! % rawdata[declstartpos:declstartpos+20]) # To be overridden -- handlers for unknown objects From akuchling at users.sourceforge.net Sun Jul 11 00:02:20 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sun Jul 11 00:02:24 2004 Subject: [Python-checkins] python/dist/src/Lib tarfile.py,1.10,1.11 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7570 Modified Files: tarfile.py Log Message: [Patch 988444] Read multiple special headers - fixed/improved handling of extended/special headers in read-mode (adding new extended headers should be less painful now). - improved nts() function. - removed TarFile.chunks datastructure which is not (and was never) needed. - fixed TarInfo.tobuf(), fields could overflow with too large values, values are now clipped. Index: tarfile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/tarfile.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** tarfile.py 2 Jan 2004 15:44:29 -0000 1.10 --- tarfile.py 10 Jul 2004 22:02:11 -0000 1.11 *************** *** 136,140 **** """Convert a null-terminated string buffer to a python string. """ ! return s.split(NUL, 1)[0] def calc_chksum(buf): --- 136,140 ---- """Convert a null-terminated string buffer to a python string. """ ! return s.rstrip(NUL) def calc_chksum(buf): *************** *** 714,718 **** ): l = len(value) ! parts.append(value + (fieldsize - l) * NUL) buf = "".join(parts) --- 714,718 ---- ): l = len(value) ! parts.append(value[:fieldsize] + (fieldsize - l) * NUL) buf = "".join(parts) *************** *** 797,801 **** self.members = [] # list of members as TarInfo objects self.membernames = [] # names of members - self.chunks = [0] # chunk cache self._loaded = False # flag if all members have been read self.offset = 0L # current position in the archive file --- 797,800 ---- *************** *** 1282,1288 **** self.offset += blocks * BLOCKSIZE ! self.members.append(tarinfo) ! self.membernames.append(tarinfo.name) ! self.chunks.append(self.offset) def extract(self, member, path=""): --- 1281,1285 ---- self.offset += blocks * BLOCKSIZE ! self._record_member(tarinfo) def extract(self, member, path=""): *************** *** 1552,1556 **** # Read the next block. ! self.fileobj.seek(self.chunks[-1]) while True: buf = self.fileobj.read(BLOCKSIZE) --- 1549,1553 ---- # Read the next block. ! self.fileobj.seek(self.offset) while True: buf = self.fileobj.read(BLOCKSIZE) *************** *** 1570,1574 **** else: # Block is empty or unreadable. ! if self.chunks[-1] == 0: # If the first block is invalid. That does not # look like a tar archive we can handle. --- 1567,1571 ---- else: # Block is empty or unreadable. ! if self.offset == 0: # If the first block is invalid. That does not # look like a tar archive we can handle. *************** *** 1593,1602 **** # method is registered in the TYPE_METH. If so, then call it. if tarinfo.type in self.TYPE_METH: ! tarinfo = self.TYPE_METH[tarinfo.type](self, tarinfo) ! else: ! tarinfo.offset_data = self.offset ! if tarinfo.isreg() or tarinfo.type not in SUPPORTED_TYPES: ! # Skip the following data blocks. ! self.offset += self._block(tarinfo.size) if tarinfo.isreg() and tarinfo.name[:-1] == "/": --- 1590,1599 ---- # method is registered in the TYPE_METH. If so, then call it. if tarinfo.type in self.TYPE_METH: ! return self.TYPE_METH[tarinfo.type](self, tarinfo) ! ! tarinfo.offset_data = self.offset ! if tarinfo.isreg() or tarinfo.type not in SUPPORTED_TYPES: ! # Skip the following data blocks. ! self.offset += self._block(tarinfo.size) if tarinfo.isreg() and tarinfo.name[:-1] == "/": *************** *** 1604,1610 **** tarinfo.type = DIRTYPE ! self.members.append(tarinfo) ! self.membernames.append(tarinfo.name) ! self.chunks.append(self.offset) return tarinfo --- 1601,1605 ---- tarinfo.type = DIRTYPE ! self._record_member(tarinfo) return tarinfo *************** *** 1621,1625 **** # 2. set self.offset to the position where the next member's header will # begin. ! # 3. return a valid TarInfo object. def proc_gnulong(self, tarinfo): --- 1616,1622 ---- # 2. set self.offset to the position where the next member's header will # begin. ! # 3. call self._record_member() if the tarinfo object is supposed to ! # appear as a member of the TarFile object. ! # 4. return tarinfo or another valid TarInfo object. def proc_gnulong(self, tarinfo): *************** *** 1637,1658 **** count -= BLOCKSIZE ! if tarinfo.type == GNUTYPE_LONGNAME: ! name = nts(buf) ! if tarinfo.type == GNUTYPE_LONGLINK: ! linkname = nts(buf) ! ! buf = self.fileobj.read(BLOCKSIZE) ! tarinfo = TarInfo.frombuf(buf) ! tarinfo.offset = self.offset ! self.offset += BLOCKSIZE ! tarinfo.offset_data = self.offset ! tarinfo.name = name or tarinfo.name ! tarinfo.linkname = linkname or tarinfo.linkname ! if tarinfo.isreg() or tarinfo.type not in SUPPORTED_TYPES: ! # Skip the following data blocks. ! self.offset += self._block(tarinfo.size) ! return tarinfo def proc_sparse(self, tarinfo): --- 1634,1647 ---- count -= BLOCKSIZE ! # Fetch the next header ! next = self.next() ! next.offset = tarinfo.offset ! if tarinfo.type == GNUTYPE_LONGNAME: ! next.name = nts(buf) ! elif tarinfo.type == GNUTYPE_LONGLINK: ! next.linkname = nts(buf) ! return next def proc_sparse(self, tarinfo): *************** *** 1710,1713 **** --- 1699,1704 ---- self.offset += self._block(tarinfo.size) tarinfo.size = origsize + + self._record_member(tarinfo) return tarinfo *************** *** 1746,1749 **** --- 1737,1746 ---- return self.members[i] + def _record_member(self, tarinfo): + """Record a tarinfo object in the internal datastructures. + """ + self.members.append(tarinfo) + self.membernames.append(tarinfo.name) + def _load(self): """Read through the entire archive file and look for readable From akuchling at users.sourceforge.net Sun Jul 11 00:07:05 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sun Jul 11 00:07:08 2004 Subject: [Python-checkins] python/dist/src/Lib webbrowser.py,1.36,1.37 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8311 Modified Files: webbrowser.py Log Message: [Patch #981794] Add support for Firefox/Firebird Index: webbrowser.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/webbrowser.py,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** webbrowser.py 4 May 2004 09:21:43 -0000 1.36 --- webbrowser.py 10 Jul 2004 22:07:02 -0000 1.37 *************** *** 278,289 **** # X browsers have more in the way of options if os.environ.get("DISPLAY"): ! _tryorder = ["galeon", "skipstone", "mozilla", "netscape", "kfm", "grail"] + _tryorder # First, the Netscape series ! if _iscommand("mozilla"): ! register("mozilla", None, Netscape("mozilla")) ! if _iscommand("netscape"): ! register("netscape", None, Netscape("netscape")) # Next, Mosaic -- old but still in use. --- 278,290 ---- # X browsers have more in the way of options if os.environ.get("DISPLAY"): ! _tryorder = ["galeon", "skipstone", ! "mozilla-firefox", "mozilla-firebird", "mozilla", "netscape", "kfm", "grail"] + _tryorder # First, the Netscape series ! for browser in ("mozilla-firefox", "mozilla-firebird", ! "mozilla", "netscape"): ! if _iscommand(browser): ! register(browser, None, Netscape(browser)) # Next, Mosaic -- old but still in use. From bcannon at users.sourceforge.net Sun Jul 11 00:20:34 2004 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Sun Jul 11 00:20:37 2004 Subject: [Python-checkins] python/dist/src/Doc/api utilities.tex,1.15,1.16 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/api In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10742/Doc/api Modified Files: utilities.tex Log Message: Add PyArg_VaParseTupleAndKeywords(). Document this function and PyArg_VaParse(). Closes patch #550732. Thanks Greg Chapman. Index: utilities.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/utilities.tex,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** utilities.tex 1 Jul 2004 20:55:42 -0000 1.15 --- utilities.tex 10 Jul 2004 22:20:17 -0000 1.16 *************** *** 146,150 **** \begin{cfuncdesc}{PyObject*}{PyImport_AddModule}{char *name} Return the module object corresponding to a module name. The ! \var{name} argument may be of the form \code{package.module}). First check the modules dictionary if there's one there, and if not, create a new one and insert it in the modules dictionary. --- 146,150 ---- \begin{cfuncdesc}{PyObject*}{PyImport_AddModule}{char *name} Return the module object corresponding to a module name. The ! \var{name} argument may be of the form \code{package.module}. First check the modules dictionary if there's one there, and if not, create a new one and insert it in the modules dictionary. *************** *** 676,679 **** --- 676,685 ---- \end{cfuncdesc} + \begin{cfuncdesc}{int}{PyArg_VaParse}{PyObject *args, char *format, + va_list vargs} + Identical to \cfunction{PyArg_ParseTuple()}, except that it accepts a + va_list rather than a variable number of arguments. + \end{cfuncdesc} + \begin{cfuncdesc}{int}{PyArg_ParseTupleAndKeywords}{PyObject *args, PyObject *kw, char *format, char *keywords[], *************** *** 684,687 **** --- 690,700 ---- \end{cfuncdesc} + \begin{cfuncdesc}{int}{PyArg_VaParseTupleAndKeywords}{PyObject *args, + PyObject *kw, char *format, char *keywords[], + va_list vargs} + Identical to \cfunction{PyArg_ParseTupleAndKeywords()}, except that it + accepts a va_list rather than a variable number of arguments. + \end{cfuncdesc} + \begin{cfuncdesc}{int}{PyArg_Parse}{PyObject *args, char *format, \moreargs} From bcannon at users.sourceforge.net Sun Jul 11 00:20:36 2004 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Sun Jul 11 00:20:39 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1033,1.1034 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10742/Misc Modified Files: NEWS Log Message: Add PyArg_VaParseTupleAndKeywords(). Document this function and PyArg_VaParse(). Closes patch #550732. Thanks Greg Chapman. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1033 retrieving revision 1.1034 diff -C2 -d -r1.1033 -r1.1034 *** NEWS 10 Jul 2004 21:21:54 -0000 1.1033 --- NEWS 10 Jul 2004 22:20:32 -0000 1.1034 *************** *** 13,16 **** --- 13,19 ---- ----------------- + - Patch #550732: Add PyArg_VaParseTupleAndKeywords(). Analogous to + PyArg_VaParse(). Both are now documented. Thanks Greg Chapman. + - Allow string and unicode return types from .encode()/.decode() methods on string and unicode objects. Added unicode.decode() From bcannon at users.sourceforge.net Sun Jul 11 00:20:49 2004 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Sun Jul 11 00:20:54 2004 Subject: [Python-checkins] python/dist/src/Include modsupport.h,2.40,2.41 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10742/Include Modified Files: modsupport.h Log Message: Add PyArg_VaParseTupleAndKeywords(). Document this function and PyArg_VaParse(). Closes patch #550732. Thanks Greg Chapman. Index: modsupport.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/modsupport.h,v retrieving revision 2.40 retrieving revision 2.41 diff -C2 -d -r2.40 -r2.41 *** modsupport.h 19 Aug 2002 21:43:18 -0000 2.40 --- modsupport.h 10 Jul 2004 22:20:17 -0000 2.41 *************** *** 18,21 **** --- 18,23 ---- PyAPI_FUNC(int) PyArg_VaParse(PyObject *, char *, va_list); + PyAPI_FUNC(int) PyArg_VaParseTupleAndKeywords(PyObject *, PyObject *, + char *, char **, va_list); PyAPI_FUNC(PyObject *) Py_VaBuildValue(char *, va_list); From bcannon at users.sourceforge.net Sun Jul 11 00:20:49 2004 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Sun Jul 11 00:20:55 2004 Subject: [Python-checkins] python/dist/src/Python getargs.c,2.100,2.101 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10742/Python Modified Files: getargs.c Log Message: Add PyArg_VaParseTupleAndKeywords(). Document this function and PyArg_VaParse(). Closes patch #550732. Thanks Greg Chapman. Index: getargs.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/getargs.c,v retrieving revision 2.100 retrieving revision 2.101 diff -C2 -d -r2.100 -r2.101 *** getargs.c 3 May 2003 10:00:22 -0000 2.100 --- getargs.c 10 Jul 2004 22:20:16 -0000 2.101 *************** *** 13,16 **** --- 13,19 ---- int PyArg_ParseTupleAndKeywords(PyObject *, PyObject *, char *, char **, ...); + int PyArg_VaParseTupleAndKeywords(PyObject *, PyObject *, + char *, char **, va_list); + /* Forward */ *************** *** 1154,1157 **** --- 1157,1193 ---- + int + PyArg_VaParseTupleAndKeywords(PyObject *args, + PyObject *keywords, + char *format, + char **kwlist, va_list va) + { + int retval; + va_list lva; + + if ((args == NULL || !PyTuple_Check(args)) || + (keywords != NULL && !PyDict_Check(keywords)) || + format == NULL || + kwlist == NULL) + { + PyErr_BadInternalCall(); + return 0; + } + + #ifdef VA_LIST_IS_ARRAY + memcpy(lva, va, sizeof(va_list)); + #else + #ifdef __va_copy + __va_copy(lva, va); + #else + lva = va; + #endif + #endif + + retval = vgetargskeywords(args, keywords, format, kwlist, &lva); + return retval; + } + + static int vgetargskeywords(PyObject *args, PyObject *keywords, char *format, From bcannon at users.sourceforge.net Sun Jul 11 00:55:18 2004 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Sun Jul 11 00:55:23 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1034,1.1035 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16735/Misc Modified Files: NEWS Log Message: posixpath.realpath() now detects symlink loops and returns the path just before the loop starts. Closes bug #930024. Thanks AM Kuchling. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1034 retrieving revision 1.1035 diff -C2 -d -r1.1034 -r1.1035 *** NEWS 10 Jul 2004 22:20:32 -0000 1.1034 --- NEWS 10 Jul 2004 22:55:15 -0000 1.1035 *************** *** 30,33 **** --- 30,37 ---- ------- + - Bug #930024: posixpath.realpath() now handles infinite loops in symlinks by + returning the last point in the path that was not part of any loop. Thanks + AM Kuchling. + - Bug #980327: ntpath not handles compressing erroneous slashes between the drive letter and the rest of the path. Also clearly handles UNC addresses now From bcannon at users.sourceforge.net Sun Jul 11 00:55:17 2004 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Sun Jul 11 00:55:24 2004 Subject: [Python-checkins] python/dist/src/Lib posixpath.py,1.66,1.67 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16735/Lib Modified Files: posixpath.py Log Message: posixpath.realpath() now detects symlink loops and returns the path just before the loop starts. Closes bug #930024. Thanks AM Kuchling. Index: posixpath.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/posixpath.py,v retrieving revision 1.66 retrieving revision 1.67 diff -C2 -d -r1.66 -r1.67 *** posixpath.py 8 Jun 2004 08:29:32 -0000 1.66 --- posixpath.py 10 Jul 2004 22:55:13 -0000 1.67 *************** *** 406,417 **** for i in range(2, len(bits)+1): component = join(*bits[0:i]) ! if islink(component): ! resolved = os.readlink(component) ! (dir, file) = split(component) ! resolved = normpath(join(dir, resolved)) ! newpath = join(*([resolved] + bits[i:])) ! return realpath(newpath) return filename supports_unicode_filenames = False --- 406,441 ---- for i in range(2, len(bits)+1): component = join(*bits[0:i]) ! # Resolve symbolic links. ! if islink(component): ! resolved = _resolve_link(component) ! if resolved is None: ! # Infinite loop -- return original component + rest of the path ! return join(*([component] + bits[i:])) ! else: ! newpath = join(*([resolved] + bits[i:])) ! return realpath(newpath) return filename + + def _resolve_link(path): + """Internal helper function. Takes a path and follows symlinks + until we either arrive at something that isn't a symlink, or + encounter a path we've seen before (meaning that there's a loop). + """ + paths_seen = [] + while islink(path): + if path in paths_seen: + # Already seen this path, so we must have a symlink loop + return None + paths_seen.append(path) + # Resolve where the link points to + resolved = os.readlink(path) + if not abspath(resolved): + dir = dirname(path) + path = normpath(join(dir, resolved)) + else: + path = normpath(resolved) + return path + supports_unicode_filenames = False From bcannon at users.sourceforge.net Sun Jul 11 00:58:35 2004 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Sun Jul 11 00:58:38 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS, 1.831.4.131, 1.831.4.132 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17214/Misc Modified Files: Tag: release23-maint NEWS Log Message: posixpath.realpath() now detects loops from symlinks and returns the longest path before recursion. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.831.4.131 retrieving revision 1.831.4.132 diff -C2 -d -r1.831.4.131 -r1.831.4.132 *** NEWS 10 Jul 2004 20:47:29 -0000 1.831.4.131 --- NEWS 10 Jul 2004 22:58:32 -0000 1.831.4.132 *************** *** 41,44 **** --- 41,47 ---- ------- + - Bug #930024: posixpath.realpath() now detects loops from symlinks and returns + the longest path before the loop begins. + - Bug #980327/Patch #988607: ntpath now compresses extra slashes between the drive letter and the rest of the path properly. Also removed ambiguity from From bcannon at users.sourceforge.net Sun Jul 11 00:58:34 2004 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Sun Jul 11 00:58:39 2004 Subject: [Python-checkins] python/dist/src/Lib posixpath.py, 1.62.6.1, 1.62.6.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17214/Lib Modified Files: Tag: release23-maint posixpath.py Log Message: posixpath.realpath() now detects loops from symlinks and returns the longest path before recursion. Index: posixpath.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/posixpath.py,v retrieving revision 1.62.6.1 retrieving revision 1.62.6.2 diff -C2 -d -r1.62.6.1 -r1.62.6.2 *** posixpath.py 12 May 2004 03:47:01 -0000 1.62.6.1 --- posixpath.py 10 Jul 2004 22:58:31 -0000 1.62.6.2 *************** *** 409,420 **** for i in range(2, len(bits)+1): component = join(*bits[0:i]) ! if islink(component): ! resolved = os.readlink(component) ! (dir, file) = split(component) ! resolved = normpath(join(dir, resolved)) ! newpath = join(*([resolved] + bits[i:])) ! return realpath(newpath) return filename supports_unicode_filenames = False --- 409,444 ---- for i in range(2, len(bits)+1): component = join(*bits[0:i]) ! # Resolve symbolic links. ! if islink(component): ! resolved = _resolve_link(component) ! if resolved is None: ! # Infinite loop -- return original component + rest of the path ! return join(*([component] + bits[i:])) ! else: ! newpath = join(*([resolved] + bits[i:])) ! return realpath(newpath) return filename + + def _resolve_link(path): + """Internal helper function. Takes a path and follows symlinks + until we either arrive at something that isn't a symlink, or + encounter a path we've seen before (meaning that there's a loop). + """ + paths_seen = [] + while islink(path): + if path in paths_seen: + # Already seen this path, so we must have a symlink loop + return None + paths_seen.append(path) + # Resolve where the link points to + resolved = os.readlink(path) + if not abspath(resolved): + dir = dirname(path) + path = normpath(join(dir, resolved)) + else: + path = normpath(resolved) + return path + supports_unicode_filenames = False From bcannon at users.sourceforge.net Sun Jul 11 01:06:10 2004 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Sun Jul 11 01:06:12 2004 Subject: [Python-checkins] python/dist/src/Doc/lib liboptparse.tex, 1.13, 1.14 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18828/Doc/lib Modified Files: liboptparse.tex Log Message: Fix minor error in example. Index: liboptparse.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/liboptparse.tex,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** liboptparse.tex 27 Jan 2004 21:08:04 -0000 1.13 --- liboptparse.tex 10 Jul 2004 23:06:07 -0000 1.14 *************** *** 607,611 **** options, args = parser.parse_args() ! if len(args) != 1: parser.error("incorrect number of arguments") --- 607,611 ---- options, args = parser.parse_args() ! if len(args) != 2: parser.error("incorrect number of arguments") From bcannon at users.sourceforge.net Sun Jul 11 01:14:32 2004 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Sun Jul 11 01:14:35 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1035,1.1036 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20220/Misc Modified Files: NEWS Log Message: Debug output is now printed to sys.stderr . Closes bug #980938. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1035 retrieving revision 1.1036 diff -C2 -d -r1.1035 -r1.1036 *** NEWS 10 Jul 2004 22:55:15 -0000 1.1035 --- NEWS 10 Jul 2004 23:14:30 -0000 1.1036 *************** *** 30,33 **** --- 30,35 ---- ------- + - Bug #980938: smtplib now prints debug output to sys.stderr. + - Bug #930024: posixpath.realpath() now handles infinite loops in symlinks by returning the last point in the path that was not part of any loop. Thanks From bcannon at users.sourceforge.net Sun Jul 11 01:14:32 2004 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Sun Jul 11 01:14:36 2004 Subject: [Python-checkins] python/dist/src/Lib smtplib.py,1.64,1.65 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20220/Lib Modified Files: smtplib.py Log Message: Debug output is now printed to sys.stderr . Closes bug #980938. Index: smtplib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/smtplib.py,v retrieving revision 1.64 retrieving revision 1.65 diff -C2 -d -r1.64 -r1.65 *** smtplib.py 12 Feb 2004 17:35:07 -0000 1.64 --- smtplib.py 10 Jul 2004 23:14:29 -0000 1.65 *************** *** 48,51 **** --- 48,52 ---- import hmac from email.base64MIME import encode as encode_base64 + from sys import stderr __all__ = ["SMTPException","SMTPServerDisconnected","SMTPResponseException", *************** *** 283,287 **** raise socket.error, "nonnumeric port" if not port: port = SMTP_PORT ! if self.debuglevel > 0: print 'connect:', (host, port) msg = "getaddrinfo returns an empty list" self.sock = None --- 284,288 ---- raise socket.error, "nonnumeric port" if not port: port = SMTP_PORT ! if self.debuglevel > 0: print>>stderr, 'connect:', (host, port) msg = "getaddrinfo returns an empty list" self.sock = None *************** *** 290,297 **** try: self.sock = socket.socket(af, socktype, proto) ! if self.debuglevel > 0: print 'connect:', (host, port) self.sock.connect(sa) except socket.error, msg: ! if self.debuglevel > 0: print 'connect fail:', (host, port) if self.sock: self.sock.close() --- 291,298 ---- try: self.sock = socket.socket(af, socktype, proto) ! if self.debuglevel > 0: print>>stderr, 'connect:', (host, port) self.sock.connect(sa) except socket.error, msg: ! if self.debuglevel > 0: print>>stderr, 'connect fail:', (host, port) if self.sock: self.sock.close() *************** *** 302,311 **** raise socket.error, msg (code, msg) = self.getreply() ! if self.debuglevel > 0: print "connect:", msg return (code, msg) def send(self, str): """Send `str' to the server.""" ! if self.debuglevel > 0: print 'send:', repr(str) if self.sock: try: --- 303,312 ---- raise socket.error, msg (code, msg) = self.getreply() ! if self.debuglevel > 0: print>>stderr, "connect:", msg return (code, msg) def send(self, str): """Send `str' to the server.""" ! if self.debuglevel > 0: print>>stderr, 'send:', repr(str) if self.sock: try: *************** *** 346,350 **** self.close() raise SMTPServerDisconnected("Connection unexpectedly closed") ! if self.debuglevel > 0: print 'reply:', repr(line) resp.append(line[4:].strip()) code=line[:3] --- 347,351 ---- self.close() raise SMTPServerDisconnected("Connection unexpectedly closed") ! if self.debuglevel > 0: print>>stderr, 'reply:', repr(line) resp.append(line[4:].strip()) code=line[:3] *************** *** 362,366 **** errmsg = "\n".join(resp) if self.debuglevel > 0: ! print 'reply: retcode (%s); Msg: %s' % (errcode,errmsg) return errcode, errmsg --- 363,367 ---- errmsg = "\n".join(resp) if self.debuglevel > 0: ! print>>stderr, 'reply: retcode (%s); Msg: %s' % (errcode,errmsg) return errcode, errmsg *************** *** 475,479 **** self.putcmd("data") (code,repl)=self.getreply() ! if self.debuglevel >0 : print "data:", (code,repl) if code != 354: raise SMTPDataError(code,repl) --- 476,480 ---- self.putcmd("data") (code,repl)=self.getreply() ! if self.debuglevel >0 : print>>stderr, "data:", (code,repl) if code != 354: raise SMTPDataError(code,repl) *************** *** 485,489 **** self.send(q) (code,msg)=self.getreply() ! if self.debuglevel >0 : print "data:", (code,msg) return (code,msg) --- 486,490 ---- self.send(q) (code,msg)=self.getreply() ! if self.debuglevel >0 : print>>stderr, "data:", (code,msg) return (code,msg) From akuchling at users.sourceforge.net Sun Jul 11 01:39:38 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sun Jul 11 01:39:40 2004 Subject: [Python-checkins] python/dist/src/Modules socketmodule.c, 1.294, 1.295 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24420 Modified Files: socketmodule.c Log Message: [Patch #947352 from Jason Andryuk] Add support for AF_PACKET hardware addresses Index: socketmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/socketmodule.c,v retrieving revision 1.294 retrieving revision 1.295 diff -C2 -d -r1.294 -r1.295 *** socketmodule.c 10 Jul 2004 14:19:21 -0000 1.294 --- socketmodule.c 10 Jul 2004 23:39:35 -0000 1.295 *************** *** 51,57 **** the Ethernet protocol number to be received. For example: ("eth0",0x1234). Optional 3rd,4th,5th elements in the tuple ! specify packet-type and ha-type/addr -- these are ignored by ! networking code, but accepted since they are returned by the ! getsockname() method. Local naming conventions: --- 51,55 ---- the Ethernet protocol number to be received. For example: ("eth0",0x1234). Optional 3rd,4th,5th elements in the tuple ! specify packet-type and ha-type/addr. Local naming conventions: *************** *** 1224,1231 **** int hatype = 0; int pkttype = 0; ! char *haddr; ! if (!PyArg_ParseTuple(args, "si|iis", &interfaceName, ! &protoNumber, &pkttype, &hatype, &haddr)) return 0; strncpy(ifr.ifr_name, interfaceName, sizeof(ifr.ifr_name)); --- 1222,1231 ---- int hatype = 0; int pkttype = 0; ! char *haddr = NULL; ! unsigned int halen = 0; ! if (!PyArg_ParseTuple(args, "si|iis#", &interfaceName, ! &protoNumber, &pkttype, &hatype, ! &haddr, &halen)) return 0; strncpy(ifr.ifr_name, interfaceName, sizeof(ifr.ifr_name)); *************** *** 1241,1244 **** --- 1241,1253 ---- addr->sll_pkttype = pkttype; addr->sll_hatype = hatype; + if (halen > 8) { + PyErr_SetString(PyExc_ValueError, + "Hardware address must be 8 bytes or less"); + return 0; + } + if (halen != 0) { + memcpy(&addr->sll_addr, haddr, halen); + } + addr->sll_halen = halen; *addr_ret = (struct sockaddr *) addr; *len_ret = sizeof *addr; From bcannon at users.sourceforge.net Sun Jul 11 01:54:09 2004 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Sun Jul 11 01:54:13 2004 Subject: [Python-checkins] python/dist/src/Lib difflib.py,1.20,1.21 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26258/Lib Modified Files: difflib.py Log Message: SequenceMatcher(None, [], []).get_grouped_opcodes() now returns a generator that behaves as if both lists has an empty string in each of them. Closes bug #979794 (and duplicate bug #980117). Index: difflib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/difflib.py,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** difflib.py 15 Jun 2004 23:53:34 -0000 1.20 --- difflib.py 10 Jul 2004 23:54:07 -0000 1.21 *************** *** 573,576 **** --- 573,578 ---- codes = self.get_opcodes() + if not codes: + codes = [("equal", 0, 1, 0, 1)] # Fixup leading and trailing groups if they show no changes. if codes[0][0] == 'equal': From bcannon at users.sourceforge.net Sun Jul 11 01:54:10 2004 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Sun Jul 11 01:54:14 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_difflib.py, 1.9, 1.10 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26258/Lib/test Modified Files: test_difflib.py Log Message: SequenceMatcher(None, [], []).get_grouped_opcodes() now returns a generator that behaves as if both lists has an empty string in each of them. Closes bug #979794 (and duplicate bug #980117). Index: test_difflib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_difflib.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** test_difflib.py 18 Jan 2004 20:29:55 -0000 1.9 --- test_difflib.py 10 Jul 2004 23:54:07 -0000 1.10 *************** *** 13,16 **** --- 13,23 ---- self.assertEqual(s.real_quick_ratio(), 1) + def test_comparing_empty_lists(self): + # Check fix for bug #979794 + group_gen = difflib.SequenceMatcher(None, [], []).get_grouped_opcodes() + self.assertRaises(StopIteration, group_gen.next) + diff_gen = difflib.unified_diff([], []) + self.assertRaises(StopIteration, diff_gen.next) + Doctests = doctest.DocTestSuite(difflib) From bcannon at users.sourceforge.net Sun Jul 11 01:54:10 2004 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Sun Jul 11 01:54:15 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1036,1.1037 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26258/Misc Modified Files: NEWS Log Message: SequenceMatcher(None, [], []).get_grouped_opcodes() now returns a generator that behaves as if both lists has an empty string in each of them. Closes bug #979794 (and duplicate bug #980117). Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1036 retrieving revision 1.1037 diff -C2 -d -r1.1036 -r1.1037 *** NEWS 10 Jul 2004 23:14:30 -0000 1.1036 --- NEWS 10 Jul 2004 23:54:07 -0000 1.1037 *************** *** 30,33 **** --- 30,37 ---- ------- + - Bug #979794: difflib.get_grouped_opcodes() now handles the case of when it is + comparing two empty lists. Was affecting both context_diff() and + unified_diff(). Was also a duplicate of bug #980117. + - Bug #980938: smtplib now prints debug output to sys.stderr. From guido at python.org Sun Jul 11 02:24:55 2004 From: guido at python.org (Guido van Rossum) Date: Sun Jul 11 02:24:35 2004 Subject: [Python-checkins] python/dist/src/Modules _ssl.c,1.17,1.18 In-Reply-To: Your message of "Sat, 10 Jul 2004 14:36:57 PDT." References: Message-ID: <200407110024.i6B0OtY01657@guido.python.org> > Modified Files: > _ssl.c > Log Message: > [Patch #909007] Enable a bunch of safe bug workarounds in OpenSSL, for compatibility with various broken SSL implementations out there. Can you or someone backport this to 2.3? --Guido van Rossum (home page: http://www.python.org/~guido/) From kbk at users.sourceforge.net Sun Jul 11 04:13:19 2004 From: kbk at users.sourceforge.net (kbk@users.sourceforge.net) Date: Sun Jul 11 04:13:22 2004 Subject: [Python-checkins] python/dist/src/Doc/lib liburllib2.tex,1.19,1.20 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13716 Modified Files: liburllib2.tex Log Message: Patch 851752 (fixes bug 820583) Patch by John J Lee Reviewed by Jeff Epler / KBK Doc built OK. urlopen() may return None if no handler handles the request. Also clarify what install_opener does. M liburllib2.tex Index: liburllib2.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/liburllib2.tex,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** liburllib2.tex 10 Jul 2004 18:28:33 -0000 1.19 --- liburllib2.tex 11 Jul 2004 02:13:17 -0000 1.20 *************** *** 34,43 **** Raises \exception{URLError} on errors. \end{funcdesc} \begin{funcdesc}{install_opener}{opener} ! Install an \class{OpenerDirector} instance as the default opener. ! The code does not check for a real \class{OpenerDirector}, and any ! class with the appropriate interface will work. \end{funcdesc} --- 34,50 ---- Raises \exception{URLError} on errors. + + Note that \code{None} may be returned if no handler handles the + request (though the default installed global \class{OpenerDirector} + uses \class{UnknownHandler} to ensure this never happens). \end{funcdesc} \begin{funcdesc}{install_opener}{opener} ! Install an \class{OpenerDirector} instance as the default global ! opener. Installing an opener is only necessary if you want urlopen to ! use that opener; otherwise, simply call \method{OpenerDirector.open()} ! instead of \function{urlopen()}. The code does not check for a real ! \class{OpenerDirector}, and any class with the appropriate interface ! will work. \end{funcdesc} From kbk at users.sourceforge.net Sun Jul 11 06:10:26 2004 From: kbk at users.sourceforge.net (kbk@users.sourceforge.net) Date: Sun Jul 11 06:10:30 2004 Subject: [Python-checkins] python/dist/src/Doc Makefile,1.274,1.275 Message-ID: Update of /cvsroot/python/python/dist/src/Doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28277 Modified Files: Makefile Log Message: Clarify requirement for GNU make Index: Makefile =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/Makefile,v retrieving revision 1.274 retrieving revision 1.275 diff -C2 -d -r1.274 -r1.275 *** Makefile 8 Apr 2004 18:50:51 -0000 1.274 --- Makefile 11 Jul 2004 04:10:14 -0000 1.275 *************** *** 84,87 **** --- 84,89 ---- # identifying mkhowto and the commontex/ directory using absolute paths. # + # If your doc build fails immediately, you may need to switch to GNU make. + # (e.g. OpenBSD needs package gmake installed; use gmake instead of make) PWD=$(shell pwd) From rhettinger at users.sourceforge.net Sun Jul 11 14:40:22 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sun Jul 11 14:40:27 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libdecimal.tex,1.11,1.12 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11727 Modified Files: libdecimal.tex Log Message: Minor improvements, fixups and wording changes everywhere. Index: libdecimal.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libdecimal.tex,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** libdecimal.tex 10 Jul 2004 14:14:37 -0000 1.11 --- libdecimal.tex 11 Jul 2004 12:40:19 -0000 1.12 *************** *** 22,26 **** \item Decimal numbers can be represented exactly. In contrast, numbers like ! \constant{1.1} do not have an exact representations in binary floating point. End users typically wound not expect \constant{1.1} to display as \constant{1.1000000000000001} as it does with binary floating point. --- 22,26 ---- \item Decimal numbers can be represented exactly. In contrast, numbers like ! \constant{1.1} do not have an exact representation in binary floating point. End users typically wound not expect \constant{1.1} to display as \constant{1.1000000000000001} as it does with binary floating point. *************** *** 71,82 **** The context for arithmetic is an environment specifying precision, rounding ! rules, limits on exponents, flags that indicate the results of operations, ! and trap enablers which determine whether signals are to be treated as exceptions. Rounding options include \constant{ROUND_CEILING}, \constant{ROUND_DOWN}, \constant{ROUND_FLOOR}, \constant{ROUND_HALF_DOWN}, \constant{ROUND_HALF_EVEN}, \constant{ROUND_HALF_UP}, and \constant{ROUND_UP}. ! Signals are types of information that arise during the course of a ! computation. Depending on the needs of the application, some signals may be ignored, considered as informational, or treated as exceptions. The signals in the decimal module are: \constant{Clamped}, \constant{InvalidOperation}, --- 71,82 ---- The context for arithmetic is an environment specifying precision, rounding ! rules, limits on exponents, flags indicating the results of operations, ! and trap enablers which determine whether signals are treated as exceptions. Rounding options include \constant{ROUND_CEILING}, \constant{ROUND_DOWN}, \constant{ROUND_FLOOR}, \constant{ROUND_HALF_DOWN}, \constant{ROUND_HALF_EVEN}, \constant{ROUND_HALF_UP}, and \constant{ROUND_UP}. ! Signals are groups of exceptional conditions arising during the course of ! computation. Depending on the needs of the application, signals may be ignored, considered as informational, or treated as exceptions. The signals in the decimal module are: \constant{Clamped}, \constant{InvalidOperation}, *************** *** 105,111 **** \subsection{Quick-start Tutorial \label{decimal-tutorial}} ! The normal start to using decimals is to import the module, and then use ! \function{getcontext()} to view the context and, if necessary, set the context ! precision, rounding, or trap enablers: \begin{verbatim} --- 105,111 ---- \subsection{Quick-start Tutorial \label{decimal-tutorial}} ! The usual start to using decimals is importing the module, viewing the current ! context with \function{getcontext()} and, if necessary, setting new values ! for precision, rounding, or enabled traps: \begin{verbatim} *************** *** 113,128 **** >>> getcontext() Context(prec=28, rounding=ROUND_HALF_EVEN, Emin=-999999999, Emax=999999999, ! capitals=1, flags=[], traps=[]) ! >>> getcontext().prec = 7 \end{verbatim} Decimal instances can be constructed from integers, strings or tuples. To create a Decimal from a \class{float}, first convert it to a string. This serves as an explicit reminder of the details of the conversion (including ! representation error). Malformed strings signal \constant{InvalidOperation} ! and return a special kind of Decimal called a \constant{NaN} which stands for ! ``Not a number''. Positive and negative \constant{Infinity} is yet another ! special kind of Decimal. \begin{verbatim} --- 113,129 ---- >>> getcontext() Context(prec=28, rounding=ROUND_HALF_EVEN, Emin=-999999999, Emax=999999999, ! capitals=1, flags=[], traps=[Overflow, InvalidOperation, ! DivisionByZero]) ! >>> getcontext().prec = 7 # Set a new precision \end{verbatim} + Decimal instances can be constructed from integers, strings or tuples. To create a Decimal from a \class{float}, first convert it to a string. This serves as an explicit reminder of the details of the conversion (including ! representation error). Decimal numbers include special values such as ! \constant{NaN} which stands for ``Not a number'', positive and negative ! \constant{Infinity}, and \constant{-0}. \begin{verbatim} *************** *** 141,152 **** \end{verbatim} ! Creating decimals is unaffected by context precision. Their level of ! significance is completely determined by the number of digits input. It is ! the arithmetic operations that are governed by context. \begin{verbatim} >>> getcontext().prec = 6 - >>> Decimal('3.0000') - Decimal("3.0000") >>> Decimal('3.0') Decimal("3.0") --- 142,152 ---- \end{verbatim} ! ! The significance of a new Decimal is determined solely by the number ! of digits input. Context precision and rounding only come into play during ! arithmetic operations. \begin{verbatim} >>> getcontext().prec = 6 >>> Decimal('3.0') Decimal("3.0") *************** *** 160,163 **** --- 160,164 ---- \end{verbatim} + Decimals interact well with much of the rest of python. Here is a small decimal floating point flying circus: *************** *** 191,198 **** \end{verbatim} ! The \function{getcontext()} function accesses the current context. This one ! context is sufficient for many applications; however, for more advanced work, ! multiple contexts can be created using the Context() constructor. To make a ! new context active, use the \function{setcontext()} function. In accordance with the standard, the \module{Decimal} module provides two --- 192,213 ---- \end{verbatim} ! The \method{quantize()} method rounds a number to a fixed exponent. This ! method is useful for monetary applications that often round results to a fixed ! number of places: ! ! \begin{verbatim} ! >>> Decimal('7.325').quantize(Decimal('.01'), rounding=ROUND_DOWN) ! Decimal("7.32") ! >>> Decimal('7.325').quantize(Decimal('1.'), rounding=ROUND_UP) ! Decimal("8") ! \end{verbatim} ! ! As shown above, the \function{getcontext()} function accesses the current ! context and allows the settings to be changed. This approach meets the ! needs of most applications. ! ! For more advanced work, it may be useful to create alternate contexts using ! the Context() constructor. To make an alternate active, use the ! \function{setcontext()} function. In accordance with the standard, the \module{Decimal} module provides two *************** *** 206,215 **** Context(prec=60, rounding=ROUND_HALF_DOWN, Emin=-999999999, Emax=999999999, capitals=1, flags=[], traps=[]) - >>> ExtendedContext - Context(prec=9, rounding=ROUND_HALF_EVEN, Emin=-999999999, Emax=999999999, - capitals=1, flags=[], traps=[]) >>> setcontext(myothercontext) >>> Decimal(1) / Decimal(7) Decimal("0.142857142857142857142857142857142857142857142857142857142857") >>> setcontext(ExtendedContext) >>> Decimal(1) / Decimal(7) --- 221,231 ---- Context(prec=60, rounding=ROUND_HALF_DOWN, Emin=-999999999, Emax=999999999, capitals=1, flags=[], traps=[]) >>> setcontext(myothercontext) >>> Decimal(1) / Decimal(7) Decimal("0.142857142857142857142857142857142857142857142857142857142857") + + >>> ExtendedContext + Context(prec=9, rounding=ROUND_HALF_EVEN, Emin=-999999999, Emax=999999999, + capitals=1, flags=[], traps=[]) >>> setcontext(ExtendedContext) >>> Decimal(1) / Decimal(7) *************** *** 217,220 **** --- 233,237 ---- >>> Decimal(42) / Decimal(0) Decimal("Infinity") + >>> setcontext(BasicContext) >>> Decimal(42) / Decimal(0) *************** *** 225,236 **** \end{verbatim} ! Besides using contexts to control precision, rounding, and trapping signals, ! they can be used to monitor flags which give information collected during ! computation. The flags remain set until explicitly cleared, so it is best to ! clear the flags before each set of monitored computations by using the ! \method{clear_flags()} method. \begin{verbatim} >>> setcontext(ExtendedContext) >>> Decimal(355) / Decimal(113) Decimal("3.14159292") --- 242,254 ---- \end{verbatim} ! ! Contexts also have signal flags for monitoring exceptional conditions ! encountered during computations. The flags remain set until explicitly ! cleared, so it is best to clear the flags before each set of monitored ! computations by using the \method{clear_flags()} method. \begin{verbatim} >>> setcontext(ExtendedContext) + >>> getcontext().clear_flags() >>> Decimal(355) / Decimal(113) Decimal("3.14159292") *************** *** 240,247 **** \end{verbatim} ! The \var{flags} entry shows that the rational approximation to ! \constant{Pi} was rounded (digits beyond the context precision were thrown ! away) and that the result is inexact (some of the discarded digits were ! non-zero). Individual traps are set using the dictionary in the \member{traps} --- 258,264 ---- \end{verbatim} ! The \var{flags} entry shows that the rational approximation to \constant{Pi} ! was rounded (digits beyond the context precision were thrown away) and that ! the result is inexact (some of the discarded digits were non-zero). Individual traps are set using the dictionary in the \member{traps} *************** *** 260,283 **** \end{verbatim} ! To turn all the traps on or off all at once, use a loop. Also, the ! \method{dict.update()} method is useful for changing a handfull of values. ! ! \begin{verbatim} ! >>> getcontext.clear_flags() ! >>> for sig in getcontext().traps: ! ... getcontext().traps[sig] = 1 ! ! >>> getcontext().traps.update({Rounded:0, Inexact:0, Subnormal:0}) ! >>> getcontext() ! Context(prec=9, rounding=ROUND_HALF_EVEN, Emin=-999999999, Emax=999999999, ! capitals=1, flags=[], traps=[Clamped, Underflow, ! InvalidOperation, DivisionByZero, Overflow]) ! \end{verbatim} ! ! Applications typically set the context once at the beginning of a program ! and no further changes are needed. For many applications, the data resides ! in a resource external to the program and is converted to \class{Decimal} with ! a single cast inside a loop. Afterwards, decimals are as easily manipulated ! as other Python numeric types. --- 277,285 ---- \end{verbatim} ! Most programs adjust the current context only once, at the beginning of the ! program. And, in many applications, data is converted to \class{Decimal} with ! a single cast inside a loop. With context set and decimals created, the bulk ! of the program manipulates the data no differently than with other Python ! numeric types. *************** *** 309,326 **** If \var{value} is a \class{tuple}, it should have three components, a sign (\constant{0} for positive or \constant{1} for negative), ! a \class{tuple} of digits, and an exponent represented as an integer. ! For example, \samp{Decimal((0, (1, 4, 1, 4), -3))} returns ! \code{Decimal("1.414")}. ! The supplied \var{context} or, if not specified, the current context ! governs only the handling of malformed strings not conforming to the ! numeric string syntax. If the context traps \constant{InvalidOperation}, ! an exception is raised; otherwise, the constructor returns a new Decimal ! with the value of \constant{NaN}. ! The context serves no other purpose. The number of significant digits ! recorded is determined solely by the \var{value} and the \var{context} ! precision is not a factor. For example, \samp{Decimal("3.0000")} records ! all four zeroes even if the context precision is only three. Once constructed, \class{Decimal} objects are immutable. --- 311,326 ---- If \var{value} is a \class{tuple}, it should have three components, a sign (\constant{0} for positive or \constant{1} for negative), ! a \class{tuple} of digits, and an integer exponent. For example, ! \samp{Decimal((0, (1, 4, 1, 4), -3))} returns \code{Decimal("1.414")}. ! The \var{context} precision does not affect how many digits are stored. ! That is determined exclusively by the number of digits in \var{value}. For ! example, \samp{Decimal("3.00000")} records all five zeroes even if the ! context precision is only three. ! The purpose of the \var{context} argument is determining what to do if ! \var{value} is a malformed string. If the context traps ! \constant{InvalidOperation}, an exception is raised; otherwise, the ! constructor returns a new Decimal with the value of \constant{NaN}. Once constructed, \class{Decimal} objects are immutable. *************** *** 335,345 **** In addition to the standard numeric properties, decimal floating point objects ! have a number of more specialized methods: \begin{methoddesc}{adjusted}{} Return the adjusted exponent after shifting out the coefficient's rightmost digits until only the lead digit remains: \code{Decimal("321e+5").adjusted()} ! returns seven. Used for determining the place value of the most significant ! digit. \end{methoddesc} --- 335,345 ---- In addition to the standard numeric properties, decimal floating point objects ! also have a number of specialized methods: \begin{methoddesc}{adjusted}{} Return the adjusted exponent after shifting out the coefficient's rightmost digits until only the lead digit remains: \code{Decimal("321e+5").adjusted()} ! returns seven. Used for determining the position of the most significant ! digit with respect to the decimal point. \end{methoddesc} *************** *** 390,394 **** \begin{methoddesc}{remainder_near}{other\optional{, context}} ! Computed the modulo as either a positive or negative value depending on which is closest to zero. For instance, \samp{Decimal(10).remainder_near(6)} returns \code{Decimal("-2")} --- 390,394 ---- \begin{methoddesc}{remainder_near}{other\optional{, context}} ! Computes the modulo as either a positive or negative value depending on which is closest to zero. For instance, \samp{Decimal(10).remainder_near(6)} returns \code{Decimal("-2")} *************** *** 423,433 **** \end{methoddesc} ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \subsection{Context objects \label{decimal-decimal}} ! Contexts are environments for arithmetic operations. They govern the precision, ! rules for rounding, determine which signals are treated as exceptions, and set limits ! on the range for exponents. Each thread has its own current context which is accessed or changed using --- 423,434 ---- \end{methoddesc} ! ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \subsection{Context objects \label{decimal-decimal}} ! Contexts are environments for arithmetic operations. They govern precision, ! set rules for rounding, determine which signals are treated as exceptions, and ! limit the range for exponents. Each thread has its own current context which is accessed or changed using *************** *** 465,473 **** that prefer to have result value of \constant{NaN} or \constant{Infinity} instead of raising exceptions. This allows an application to complete a ! run in the presense of conditions that would otherwise halt the program. \end{classdesc*} \begin{classdesc*}{DefaultContext} ! This class is used by the \class{Context} constructor as a prototype for new contexts. Changing a field (such a precision) has the effect of changing the default for new contexts creating by the \class{Context} --- 466,474 ---- that prefer to have result value of \constant{NaN} or \constant{Infinity} instead of raising exceptions. This allows an application to complete a ! run in the presence of conditions that would otherwise halt the program. \end{classdesc*} \begin{classdesc*}{DefaultContext} ! This context is used by the \class{Context} constructor as a prototype for new contexts. Changing a field (such a precision) has the effect of changing the default for new contexts creating by the \class{Context} *************** *** 480,487 **** In single threaded environments, it is preferable to not use this context ! at all. Instead, simply create contexts explicitly. This is especially ! important because the default values context may change between releases ! (with initial release having precision=28, rounding=ROUND_HALF_EVEN, ! cleared flags, and no traps enabled). \end{classdesc*} --- 481,488 ---- In single threaded environments, it is preferable to not use this context ! at all. Instead, simply create contexts explicitly as described below. ! ! The default values are precision=28, rounding=ROUND_HALF_EVEN, and enabled ! traps for Overflow, InvalidOperation, and DivisionByZero. \end{classdesc*} *************** *** 509,514 **** \constant{ROUND_UP} (away from zero). ! The \var{traps} and \var{flags} fields are mappings from signals ! to either \constant{0} or \constant{1}. The \var{Emin} and \var{Emax} fields are integers specifying the outer --- 510,515 ---- \constant{ROUND_UP} (away from zero). ! The \var{traps} and \var{flags} fields list any signals to be set. ! Generally, new contexts should only set traps and leave the flags clear. The \var{Emin} and \var{Emax} fields are integers specifying the outer *************** *** 517,525 **** The \var{capitals} field is either \constant{0} or \constant{1} (the default). If set to \constant{1}, exponents are printed with a capital ! \constant{E}; otherwise, lowercase is used: \constant{Decimal('6.02e+23')}. \end{classdesc} ! The \class{Context} class defines several general methods as well as a ! large number of methods for doing arithmetic directly from the context. \begin{methoddesc}{clear_flags}{} --- 518,527 ---- The \var{capitals} field is either \constant{0} or \constant{1} (the default). If set to \constant{1}, exponents are printed with a capital ! \constant{E}; otherwise, a lowercase \constant{e} is used: ! \constant{Decimal('6.02e+23')}. \end{classdesc} ! The \class{Context} class defines several general purpose methods as well as a ! large number of methods for doing arithmetic directly in a given context. \begin{methoddesc}{clear_flags}{} *************** *** 532,541 **** \begin{methoddesc}{create_decimal}{num} ! Creates a new Decimal instance but using \var{self} as context. ! Unlike the \class{Decimal} constructor, context precision, rounding method, flags, and traps are applied to the conversion. ! This is useful because constants are often given to a greater ! precision than is needed by the application. \end{methoddesc} --- 534,543 ---- \begin{methoddesc}{create_decimal}{num} ! Creates a new Decimal instance from \var{num} but using \var{self} as ! context. Unlike the \class{Decimal} constructor, the context precision, rounding method, flags, and traps are applied to the conversion. ! This is useful because constants are often given to a greater precision than ! is needed by the application. \end{methoddesc} *************** *** 543,547 **** Returns a value equal to \samp{Emin - prec + 1} which is the minimum exponent value for subnormal results. When underflow occurs, the ! exponont is set to \constant{Etiny}. \end{methoddesc} --- 545,549 ---- Returns a value equal to \samp{Emin - prec + 1} which is the minimum exponent value for subnormal results. When underflow occurs, the ! exponent is set to \constant{Etiny}. \end{methoddesc} *************** *** 554,558 **** instances and then apply arithmetic operations which take place within the current context for the active thread. An alternate approach is to use ! context methods for calculating within s specific context. The methods are similar to those for the \class{Decimal} class and are only briefly recounted here. --- 556,560 ---- instances and then apply arithmetic operations which take place within the current context for the active thread. An alternate approach is to use ! context methods for calculating within a specific context. The methods are similar to those for the \class{Decimal} class and are only briefly recounted here. *************** *** 587,591 **** \begin{methoddesc}{max}{x, y} ! Compare two values numerically and returns the maximum. If they are numerically equal then the left-hand operand is chosen as the --- 589,593 ---- \begin{methoddesc}{max}{x, y} ! Compare two values numerically and return the maximum. If they are numerically equal then the left-hand operand is chosen as the *************** *** 594,598 **** \begin{methoddesc}{min}{x, y} ! Compare two values numerically and returns the minimum. If they are numerically equal then the left-hand operand is chosen as the --- 596,600 ---- \begin{methoddesc}{min}{x, y} ! Compare two values numerically and return the minimum. If they are numerically equal then the left-hand operand is chosen as the *************** *** 637,648 **** \begin{methoddesc}{quantize}{x, y} ! Returns a value equal to \var{x} after rounding and having the ! exponent of v\var{y}. Unlike other operations, if the length of the coefficient after the quantize ! operation would be greater than precision then an \constant{InvalidOperation} is signaled. This guarantees that, unless there ! is an error condition, the exponent of the result of a quantize is always ! equal to that of the right-hand operand. Also unlike other operations, quantize never signals Underflow, even --- 639,650 ---- \begin{methoddesc}{quantize}{x, y} ! Returns a value equal to \var{x} after rounding and having the exponent of ! \var{y}. Unlike other operations, if the length of the coefficient after the quantize ! operation would be greater than precision, then an \constant{InvalidOperation} is signaled. This guarantees that, unless there ! is an error condition, the quantized exponent is always equal to that of the ! right-hand operand. Also unlike other operations, quantize never signals Underflow, even *************** *** 713,717 **** If the context's trap enabler is set for the signal, then the condition causes a Python exception to be raised. For example, if the ! \class{DivisionByZero} trap is set, the a \exception{DivisionByZero} exception is raised upon encountering the condition. --- 715,719 ---- If the context's trap enabler is set for the signal, then the condition causes a Python exception to be raised. For example, if the ! \class{DivisionByZero} trap is set, then a \exception{DivisionByZero} exception is raised upon encountering the condition. *************** *** 726,730 **** \begin{classdesc*}{DecimalException} ! Base class for other signals. \end{classdesc*} --- 728,733 ---- \begin{classdesc*}{DecimalException} ! Base class for other signals and is a subclass of ! \exception{ArithmeticError}. \end{classdesc*} *************** *** 732,738 **** Signals the division of a non-infinite number by zero. ! Can occur with division, modulo division, or when raising a number to ! a negative power. If this signal is not trapped, return ! \constant{Infinity} or \constant{-Infinity} with sign determined by the inputs to the calculation. \end{classdesc*} --- 735,741 ---- Signals the division of a non-infinite number by zero. ! Can occur with division, modulo division, or when raising a number to a ! negative power. If this signal is not trapped, returns ! \constant{Infinity} or \constant{-Infinity} with the sign determined by the inputs to the calculation. \end{classdesc*} *************** *** 741,747 **** Indicates that rounding occurred and the result is not exact. ! Signals whenever non-zero digits were discarded during rounding. ! The rounded result is returned. The signal flag or trap is used ! to detect when results are inexact. \end{classdesc*} --- 744,750 ---- Indicates that rounding occurred and the result is not exact. ! Signals when non-zero digits were discarded during rounding. The rounded ! result is returned. The signal flag or trap is used to detect when ! results are inexact. \end{classdesc*} *************** *** 821,825 **** object for each thread. Having separate thread contexts means that threads may make changes (such as \code{getcontext.prec=10}) without interfering with ! other threads and without needing mutexes. Likewise, the \function{setcontext()} function automatically assigns its target --- 824,828 ---- object for each thread. Having separate thread contexts means that threads may make changes (such as \code{getcontext.prec=10}) without interfering with ! other threads. Likewise, the \function{setcontext()} function automatically assigns its target *************** *** 830,847 **** in the current thread. ! The new context is copied from a prototype context called \var{DefaultContext}. ! To control the defaults so that each thread will use the same values ! throughout the application, directly modify the \var{DefaultContext} object. ! This should be done \emph{before} any threads are started so that there won't ! be a race condition with threads calling \function{getcontext()}. For example: \begin{verbatim} # Set applicationwide defaults for all threads about to be launched ! DefaultContext.prec=12 ! DefaultContext.rounding=ROUND_DOWN ! DefaultContext.traps=dict.fromkeys(Signals, 0) setcontext(DefaultContext) ! # Now start all of the threads t1.start() t2.start() --- 833,849 ---- in the current thread. ! The new context is copied from a prototype context called ! \var{DefaultContext}. To control the defaults so that each thread will use the ! same values throughout the application, directly modify the ! \var{DefaultContext} object. This should be done \emph{before} any threads are ! started so that there won't be a race condition between threads calling ! \function{getcontext()}. For example: \begin{verbatim} # Set applicationwide defaults for all threads about to be launched ! DefaultContext = Context(prec=12, rounding=ROUND_DOWN, traps=[InvalidOperation]) setcontext(DefaultContext) ! # Afterward, the threads can be started t1.start() t2.start() *************** *** 855,866 **** \subsection{Recipes \label{decimal-recipes}} ! Here are some functions demonstrating ways to work with the ! \class{Decimal} class: \begin{verbatim} ! from decimal import Decimal, getcontext ! getcontext().prec = 28 ! ! def moneyfmt(value, places=2, curr='$', sep=',', dp='.', pos='', neg='-'): """Convert Decimal to a money formatted string. --- 857,866 ---- \subsection{Recipes \label{decimal-recipes}} ! Here are a few recipes that serve as utility functions and that demonstrate ! ways to work with the \class{Decimal} class: \begin{verbatim} ! def moneyfmt(value, places=2, curr='', sep=',', dp='.', ! pos='', neg='-', trailneg=''): """Convert Decimal to a money formatted string. *************** *** 869,884 **** sep: optional grouping separator (comma, period, or blank) dp: decimal point indicator (comma or period) ! only set to blank if places is zero ! pos: optional sign for positive numbers ("+" or blank) ! neg: optional sign for negative numbers ("-" or blank) ! leave blank to separately add brackets or a trailing minus >>> d = Decimal('-1234567.8901') ! >>> moneyfmt(d) '-$1,234,567.89' ! >>> moneyfmt(d, places=0, curr='', sep='.', dp='') ! '-1.234.568' ! >>> '($%s)' % moneyfmt(d, curr='', neg='') '($1,234,567.89)' """ q = Decimal((0, (1,), -places)) # 2 places --> '0.01' --- 869,885 ---- sep: optional grouping separator (comma, period, or blank) dp: decimal point indicator (comma or period) ! only specify as blank when places is zero ! pos: optional sign for positive numbers: "+", space or blank ! neg: optional sign for negative numbers: "-", "(", space or blank ! trailneg:optional trailing minus indicator: "-", ")", space or blank >>> d = Decimal('-1234567.8901') ! >>> moneyfmt(d, curr='$') '-$1,234,567.89' ! >>> moneyfmt(d, places=0, sep='.', dp='', neg='', trailneg='-') ! '1.234.568-' ! >>> moneyfmt(d, curr='$', neg='(', trailneg=')') '($1,234,567.89)' + """ q = Decimal((0, (1,), -places)) # 2 places --> '0.01' *************** *** 886,901 **** result = [] digits = map(str, digits) ! build, next = result.append, digits.pop for i in range(places): build(next()) build(dp) ! try: ! while 1: ! for i in range(3): ! build(next()) ! if digits: ! build(sep) ! except IndexError: ! pass build(curr) if sign: --- 887,903 ---- result = [] digits = map(str, digits) ! build, next = result.append, digits.pop ! if sign: ! build(trailneg) for i in range(places): build(next()) build(dp) ! i = 0 ! while digits: ! build(next()) ! i += 1 ! if i == 3: ! i = 0 ! build(sep) build(curr) if sign: *************** *** 911,926 **** >>> print pi() 3.141592653589793238462643383 """ getcontext().prec += 2 # extra digits for intermediate steps three = Decimal(3) # substitute "three=3.0" for regular floats ! lastc, t, c, n, na, d, da = 0, three, 3, 1, 0, 0, 24 ! while c != lastc: ! lastc = c n, na = n+na, na+8 d, da = d+da, da+32 t = (t * n) / d ! c += t getcontext().prec -= 2 ! return c + 0 # Adding zero causes rounding to the new precision def exp(x): --- 913,929 ---- >>> print pi() 3.141592653589793238462643383 + """ getcontext().prec += 2 # extra digits for intermediate steps three = Decimal(3) # substitute "three=3.0" for regular floats ! lasts, t, s, n, na, d, da = 0, three, 3, 1, 0, 0, 24 ! while s != lasts: ! lasts = s n, na = n+na, na+8 d, da = d+da, da+32 t = (t * n) / d ! s += t getcontext().prec -= 2 ! return +s # unary plus applies the new precision def exp(x): *************** *** 935,949 **** >>> print exp(2+0j) (7.38905609893+0j) """ ! getcontext().prec += 2 # extra digits for intermediate steps ! i, laste, e, fact, num = 0, 0, 1, 1, 1 ! while e != laste: ! laste = e i += 1 fact *= i num *= x ! e += num / fact getcontext().prec -= 2 ! return e + 0 def cos(x): --- 938,953 ---- >>> print exp(2+0j) (7.38905609893+0j) + """ ! getcontext().prec += 2 ! i, lasts, s, fact, num = 0, 0, 1, 1, 1 ! while s != lasts: ! lasts = s i += 1 fact *= i num *= x ! s += num / fact getcontext().prec -= 2 ! return +s def cos(x): *************** *** 956,971 **** >>> print cos(0.5+0j) (0.87758256189+0j) """ ! getcontext().prec += 2 # extra digits for intermediate steps ! i, laste, e, fact, num, sign = 0, 0, 1, 1, 1, 1 ! while e != laste: ! laste = e i += 2 fact *= i * (i-1) num *= x * x sign *= -1 ! e += num / fact * sign getcontext().prec -= 2 ! return e + 0 def sin(x): --- 960,976 ---- >>> print cos(0.5+0j) (0.87758256189+0j) + """ ! getcontext().prec += 2 ! i, lasts, s, fact, num, sign = 0, 0, 1, 1, 1, 1 ! while s != lasts: ! lasts = s i += 2 fact *= i * (i-1) num *= x * x sign *= -1 ! s += num / fact * sign getcontext().prec -= 2 ! return +s def sin(x): *************** *** 978,993 **** >>> print sin(0.5+0j) (0.479425538604+0j) """ ! getcontext().prec += 2 # extra digits for intermediate steps ! i, laste, e, fact, num, sign = 1, 0, x, 1, x, 1 ! while e != laste: ! laste = e i += 2 fact *= i * (i-1) num *= x * x sign *= -1 ! e += num / fact * sign getcontext().prec -= 2 ! return e + 0 \end{verbatim} --- 983,999 ---- >>> print sin(0.5+0j) (0.479425538604+0j) + """ ! getcontext().prec += 2 ! i, lasts, s, fact, num, sign = 1, 0, x, 1, x, 1 ! while s != lasts: ! lasts = s i += 2 fact *= i * (i-1) num *= x * x sign *= -1 ! s += num / fact * sign getcontext().prec -= 2 ! return +s \end{verbatim} From rhettinger at users.sourceforge.net Sun Jul 11 14:49:50 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sun Jul 11 14:49:54 2004 Subject: [Python-checkins] python/dist/src/Doc/tut tut.tex,1.240,1.241 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/tut In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13201 Modified Files: tut.tex Log Message: Fix decimal write-up nits. Index: tut.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/tut/tut.tex,v retrieving revision 1.240 retrieving revision 1.241 diff -C2 -d -r1.240 -r1.241 *** tut.tex 10 Jul 2004 16:11:03 -0000 1.240 --- tut.tex 11 Jul 2004 12:49:47 -0000 1.241 *************** *** 5067,5071 **** rounding to meet legal or regulatory requirements, tracking of significant decimal places, or for applications where the user expects the results to ! calculations done by hand. For example, calculating a 5\%{} tax on a 70 cent phone charge gives --- 5067,5071 ---- rounding to meet legal or regulatory requirements, tracking of significant decimal places, or for applications where the user expects the results to ! match calculations done by hand. For example, calculating a 5\%{} tax on a 70 cent phone charge gives *************** *** 5082,5089 **** \end{verbatim} ! Note that the \class{Decimal} result keeps a trailing zero, automatically ! inferring four place significance from two digit mulitiplicands. Decimal ! reproduces mathematics as done by hand and avoids issues that can arise ! when binary floating point cannot exactly represent decimal quantities. Exact representation enables the \class{Decimal} class to perform --- 5082,5089 ---- \end{verbatim} ! The \class{Decimal} result keeps a trailing zero, automatically inferring four ! place significance from the two digit multiplicands. Decimal reproduces ! mathematics as done by hand and avoids issues that can arise when binary ! floating point cannot exactly represent decimal quantities. Exact representation enables the \class{Decimal} class to perform *************** *** 5103,5108 **** \end{verbatim} ! The \module{decimal} module also allows arbitrarily large precisions to be ! set for calculation: \begin{verbatim} --- 5103,5108 ---- \end{verbatim} ! The \module{decimal} module provides arithmetic with as much precision as ! needed: \begin{verbatim} From rhettinger at users.sourceforge.net Sun Jul 11 15:20:14 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sun Jul 11 15:20:16 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libitertools.tex, 1.30, 1.31 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18500 Modified Files: libitertools.tex Log Message: Style nit. Index: libitertools.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libitertools.tex,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** libitertools.tex 12 Jun 2004 07:59:40 -0000 1.30 --- libitertools.tex 11 Jul 2004 13:20:11 -0000 1.31 *************** *** 134,138 **** \begin{funcdesc}{groupby}{iterable\optional{, key}} Make an iterator that returns consecutive keys and groups from the ! \var{iterable}. \var{key} is a function computing a key value for each element. If not specified or is \code{None}, \var{key} defaults to an identity function and returns the element unchanged. Generally, the --- 134,138 ---- \begin{funcdesc}{groupby}{iterable\optional{, key}} Make an iterator that returns consecutive keys and groups from the ! \var{iterable}. The \var{key} is a function computing a key value for each element. If not specified or is \code{None}, \var{key} defaults to an identity function and returns the element unchanged. Generally, the *************** *** 333,337 **** \begin{funcdesc}{tee}{iterable\optional{, n=2}} Return \var{n} independent iterators from a single iterable. ! The case where \var{n} is two is equivalent to: \begin{verbatim} --- 333,337 ---- \begin{funcdesc}{tee}{iterable\optional{, n=2}} Return \var{n} independent iterators from a single iterable. ! The case where \code{n==2} is equivalent to: \begin{verbatim} From fdrake at users.sourceforge.net Sun Jul 11 18:25:27 2004 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Sun Jul 11 18:25:30 2004 Subject: [Python-checkins] python/dist/src/Doc Makefile.deps,1.116,1.117 Message-ID: Update of /cvsroot/python/python/dist/src/Doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15563 Modified Files: Makefile.deps Log Message: Added documentation for the "smtpd" module. Closes SF bug #450803. Index: Makefile.deps =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/Makefile.deps,v retrieving revision 1.116 retrieving revision 1.117 diff -C2 -d -r1.116 -r1.117 *** Makefile.deps 29 Jan 2004 15:13:08 -0000 1.116 --- Makefile.deps 11 Jul 2004 16:25:24 -0000 1.117 *************** *** 289,292 **** --- 289,293 ---- lib/libmimetypes.tex \ lib/libsmtplib.tex \ + lib/libsmtpd.tex \ lib/libcmd.tex \ lib/libmultifile.tex \ From fdrake at users.sourceforge.net Sun Jul 11 18:25:27 2004 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Sun Jul 11 18:25:32 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libsmtpd.tex, NONE, 1.1 lib.tex, 1.227, 1.228 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15563/lib Modified Files: lib.tex Added Files: libsmtpd.tex Log Message: Added documentation for the "smtpd" module. Closes SF bug #450803. --- NEW FILE: libsmtpd.tex --- \section{\module{smtpd} --- SMTP Server} \declaremodule{standard}{smtpd} \moduleauthor{Barry Warsaw}{barry@zope.com} \sectionauthor{Moshe Zadka}{moshez@moshez.org} \modulesynopsis{Implement a flexible SMTP server} This module offers several classes to implement SMTP servers. One is a generic do-nothing implementation, which can be overridden, while the other two offer specific mail-sending strategies. \subsection{SMTPServer Objects} \begin{classdesc}{SMTPServer}{localaddr, remoteaddr} Create a new \class{SMTPServer} object, which binds to local address \var{localaddr}. It will treat \var{remoteaddr} as an upstream SMTP relayer. It inherits from \class{asyncore.dispatcher}, and so will insert itself into \refmodule{asyncore}'s event loop on instantiation. \end{classdesc} \begin{methoddesc}[SMTPServer]{process_message}{peer, mailfrom, rcpttos, data} Raise \exception{NotImplementedError} exception. Override this in subclasses to do something useful with this message. Whatever was passed in the constructor as \var{remoteaddr} will be available as the \member{_remoteaddr} attribute. \var{peer} is the remote host's address, \var{mailfrom} is the envelope originator, \var{rcpttos} are the envelope recipients and \var{data} is a string containing the contents of the e-mail (which should be in \rfc{2822} format). \end{methoddesc} \subsection{DebuggingServer Objects} \begin{classdesc}{DebuggingServer}{localaddr, remoteaddr} Create a new debugging server. Arguments are as per \class{SMTPServer}. Messages will be discarded, and printed on stdout. \end{classdesc} \subsection{PureProxy Objects} \begin{classdesc}{PureProxy}{localaddr, remoteaddr} Create a new pure proxy server. Arguments are as per \class{SMTPServer}. Everything will be relayed to \var{remoteaddr}. Note that running this has a good chance to make you into an open relay, so please be careful. \end{classdesc} \subsection{MailmanProxy Objects} \begin{classdesc}{MailmanProxy}{localaddr, remoteaddr} Create a new pure proxy server. Arguments are as per \class{SMTPServer}. Everything will be relayed to \var{remoteaddr}, unless local mailman configurations knows about an address, in which case it will be handled via mailman. Note that running this has a good chance to make you into an open relay, so please be careful. \end{classdesc} Index: lib.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/lib.tex,v retrieving revision 1.227 retrieving revision 1.228 diff -C2 -d -r1.227 -r1.228 *** lib.tex 5 Jul 2004 05:52:03 -0000 1.227 --- lib.tex 11 Jul 2004 16:25:25 -0000 1.228 *************** *** 229,232 **** --- 229,233 ---- \input{libnntplib} \input{libsmtplib} + \input{libsmtpd} \input{libtelnetlib} \input{liburlparse} From kbk at users.sourceforge.net Sun Jul 11 18:40:33 2004 From: kbk at users.sourceforge.net (kbk@users.sourceforge.net) Date: Sun Jul 11 18:40:36 2004 Subject: [Python-checkins] python/dist/src/Doc README,1.54,1.55 Message-ID: Update of /cvsroot/python/python/dist/src/Doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17764 Modified Files: README Log Message: Add FAQ on non-GNU make error. Update copyright date to 2004. Index: README =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/README,v retrieving revision 1.54 retrieving revision 1.55 diff -C2 -d -r1.54 -r1.55 *** README 13 Jan 2004 23:56:03 -0000 1.54 --- README 11 Jul 2004 16:40:31 -0000 1.55 *************** *** 144,147 **** --- 144,154 ---- + I got a make error: "make: don't know how to make commontex/patchlevel.tex." + ---------------------------------------------------------------------------- + + Your version of make doesn't support the 'shell' function. You will need to + use a version which does, e.g. GNU make. + + LaTeX (or pdfLaTeX) ran out of memory; how can I fix it? -------------------------------------------------------- *************** *** 223,227 **** ---------------------------------------------------------------------- ! Copyright (c) 2000-2003 Python Software Foundation. All rights reserved. --- 230,234 ---- ---------------------------------------------------------------------- ! Copyright (c) 2000-2004 Python Software Foundation. All rights reserved. From kbk at users.sourceforge.net Sun Jul 11 19:14:15 2004 From: kbk at users.sourceforge.net (kbk@users.sourceforge.net) Date: Sun Jul 11 19:14:18 2004 Subject: [Python-checkins] python/dist/src/Lib urllib2.py,1.71,1.72 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23077 Modified Files: urllib2.py Log Message: Patch [ 972332 ] urllib2 FTPHandler bugs / John J. Lee Modified Files: urllib2.py test/test_urllib2.py Index: urllib2.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/urllib2.py,v retrieving revision 1.71 retrieving revision 1.72 diff -C2 -d -r1.71 -r1.72 *** urllib2.py 10 Jul 2004 19:46:40 -0000 1.71 --- urllib2.py 11 Jul 2004 17:14:12 -0000 1.72 *************** *** 117,121 **** from urllib import unwrap, unquote, splittype, splithost, \ addinfourl, splitport, splitgophertype, splitquery, \ ! splitattr, ftpwrapper, noheaders, splituser, splitpasswd # support for FileHandler, proxies via environment variables --- 117,121 ---- from urllib import unwrap, unquote, splittype, splithost, \ addinfourl, splitport, splitgophertype, splitquery, \ ! splitattr, ftpwrapper, noheaders, splituser, splitpasswd, splitvalue # support for FileHandler, proxies via environment variables *************** *** 1144,1147 **** --- 1144,1149 ---- if port is None: port = ftplib.FTP_PORT + else: + port = int(port) # username/password handling *************** *** 1169,1173 **** type = file and 'I' or 'D' for attr in attrs: ! attr, value = splitattr(attr) if attr.lower() == 'type' and \ value in ('a', 'A', 'i', 'I', 'd', 'D'): --- 1171,1175 ---- type = file and 'I' or 'D' for attr in attrs: ! attr, value = splitvalue(attr) if attr.lower() == 'type' and \ value in ('a', 'A', 'i', 'I', 'd', 'D'): From kbk at users.sourceforge.net Sun Jul 11 19:14:15 2004 From: kbk at users.sourceforge.net (kbk@users.sourceforge.net) Date: Sun Jul 11 19:14:19 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_urllib2.py, 1.17, 1.18 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23077/test Modified Files: test_urllib2.py Log Message: Patch [ 972332 ] urllib2 FTPHandler bugs / John J. Lee Modified Files: urllib2.py test/test_urllib2.py Index: test_urllib2.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_urllib2.py,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** test_urllib2.py 10 Jul 2004 19:46:40 -0000 1.17 --- test_urllib2.py 11 Jul 2004 17:14:13 -0000 1.18 *************** *** 315,327 **** "localhost", ftplib.FTP_PORT, "I", ["foo", "bar"], "baz.html", "text/html"), ! # XXXX Bug: FTPHandler tries to gethostbyname "localhost:80", with the ! # port still there. ! ## ("ftp://localhost:80/foo/bar/", ! ## "localhost", 80, "D", ! ## ["foo", "bar"], "", None), ! # XXXX bug: second use of splitattr() in FTPHandler should be splitvalue() ! ## ("ftp://localhost/baz.gif;type=a", ! ## "localhost", ftplib.FTP_PORT, "A", ! ## [], "baz.gif", "image/gif"), ]: r = h.ftp_open(Request(url)) --- 315,324 ---- "localhost", ftplib.FTP_PORT, "I", ["foo", "bar"], "baz.html", "text/html"), ! ("ftp://localhost:80/foo/bar/", ! "localhost", 80, "D", ! ["foo", "bar"], "", None), ! ("ftp://localhost/baz.gif;type=a", ! "localhost", ftplib.FTP_PORT, "A", ! [], "baz.gif", None), # XXX really this should guess image/gif ]: r = h.ftp_open(Request(url)) *************** *** 334,338 **** self.assertEqual(h.ftpwrapper.filetype, type_) headers = r.info() ! self.assertEqual(headers["Content-type"], mimetype) self.assertEqual(int(headers["Content-length"]), len(data)) --- 331,335 ---- self.assertEqual(h.ftpwrapper.filetype, type_) headers = r.info() ! self.assertEqual(headers.get("Content-type"), mimetype) self.assertEqual(int(headers["Content-length"]), len(data)) From bcannon at users.sourceforge.net Sun Jul 11 21:16:23 2004 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Sun Jul 11 21:16:27 2004 Subject: [Python-checkins] python/dist/src/Lib posixpath.py,1.67,1.68 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10473/Lib Modified Files: posixpath.py Log Message: Remove tabs introduced in last commit. Index: posixpath.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/posixpath.py,v retrieving revision 1.67 retrieving revision 1.68 diff -C2 -d -r1.67 -r1.68 *** posixpath.py 10 Jul 2004 22:55:13 -0000 1.67 --- posixpath.py 11 Jul 2004 19:16:21 -0000 1.68 *************** *** 407,411 **** component = join(*bits[0:i]) # Resolve symbolic links. ! if islink(component): resolved = _resolve_link(component) if resolved is None: --- 407,411 ---- component = join(*bits[0:i]) # Resolve symbolic links. ! if islink(component): resolved = _resolve_link(component) if resolved is None: *************** *** 426,435 **** paths_seen = [] while islink(path): ! if path in paths_seen: # Already seen this path, so we must have a symlink loop return None ! paths_seen.append(path) # Resolve where the link points to ! resolved = os.readlink(path) if not abspath(resolved): dir = dirname(path) --- 426,435 ---- paths_seen = [] while islink(path): ! if path in paths_seen: # Already seen this path, so we must have a symlink loop return None ! paths_seen.append(path) # Resolve where the link points to ! resolved = os.readlink(path) if not abspath(resolved): dir = dirname(path) From bcannon at users.sourceforge.net Sun Jul 11 21:17:41 2004 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Sun Jul 11 21:17:44 2004 Subject: [Python-checkins] python/dist/src/Lib posixpath.py, 1.62.6.2, 1.62.6.3 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10934/Lib Modified Files: Tag: release23-maint posixpath.py Log Message: Remove tabs introduced in last commit. Index: posixpath.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/posixpath.py,v retrieving revision 1.62.6.2 retrieving revision 1.62.6.3 diff -C2 -d -r1.62.6.2 -r1.62.6.3 *** posixpath.py 10 Jul 2004 22:58:31 -0000 1.62.6.2 --- posixpath.py 11 Jul 2004 19:17:38 -0000 1.62.6.3 *************** *** 410,414 **** component = join(*bits[0:i]) # Resolve symbolic links. ! if islink(component): resolved = _resolve_link(component) if resolved is None: --- 410,414 ---- component = join(*bits[0:i]) # Resolve symbolic links. ! if islink(component): resolved = _resolve_link(component) if resolved is None: *************** *** 429,438 **** paths_seen = [] while islink(path): ! if path in paths_seen: # Already seen this path, so we must have a symlink loop return None ! paths_seen.append(path) # Resolve where the link points to ! resolved = os.readlink(path) if not abspath(resolved): dir = dirname(path) --- 429,438 ---- paths_seen = [] while islink(path): ! if path in paths_seen: # Already seen this path, so we must have a symlink loop return None ! paths_seen.append(path) # Resolve where the link points to ! resolved = os.readlink(path) if not abspath(resolved): dir = dirname(path) From tim_one at users.sourceforge.net Sun Jul 11 21:26:21 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 11 21:26:24 2004 Subject: [Python-checkins] python/dist/src/Doc/api concrete.tex,1.45,1.46 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/api In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12108/Doc/api Modified Files: concrete.tex Log Message: SF patch 986010: add missing doc for datetime C API, from Anthony Tuininga. This is a derived patch, taking the opportunity to add some organization to the now-large pile of datetime-related macros, and to factor out tedious repeated text. Also improved some clumsy wording in NEWS. Index: concrete.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/concrete.tex,v retrieving revision 1.45 retrieving revision 1.46 diff -C2 -d -r1.45 -r1.46 *** concrete.tex 20 Jun 2004 22:41:23 -0000 1.45 --- concrete.tex 11 Jul 2004 19:26:19 -0000 1.46 *************** *** 2657,2663 **** must be invoked. The macro arranges to put a pointer to a C structure in a static variable \code{PyDateTimeAPI}, which is used by the following ! macros: ! \begin{cfuncdesc}{int}{PyDate_Check}{ob} Return true if \var{ob} is of type \cdata{PyDateTime_DateType} or a subtype of \cdata{PyDateTime_DateType}. \var{ob} must not be --- 2657,2665 ---- must be invoked. The macro arranges to put a pointer to a C structure in a static variable \code{PyDateTimeAPI}, which is used by the following ! macros. ! Type-check macros: ! ! \begin{cfuncdesc}{int}{PyDate_Check}{PyObject *ob} Return true if \var{ob} is of type \cdata{PyDateTime_DateType} or a subtype of \cdata{PyDateTime_DateType}. \var{ob} must not be *************** *** 2666,2670 **** \end{cfuncdesc} ! \begin{cfuncdesc}{int}{PyDate_CheckExact}{ob} Return true if \var{ob} is of type \cdata{PyDateTime_DateType}. \var{ob} must not be \NULL{}. --- 2668,2672 ---- \end{cfuncdesc} ! \begin{cfuncdesc}{int}{PyDate_CheckExact}{PyObject *ob} Return true if \var{ob} is of type \cdata{PyDateTime_DateType}. \var{ob} must not be \NULL{}. *************** *** 2672,2676 **** \end{cfuncdesc} ! \begin{cfuncdesc}{int}{PyDateTime_Check}{ob} Return true if \var{ob} is of type \cdata{PyDateTime_DateTimeType} or a subtype of \cdata{PyDateTime_DateTimeType}. \var{ob} must not be --- 2674,2678 ---- \end{cfuncdesc} ! \begin{cfuncdesc}{int}{PyDateTime_Check}{PyObject *ob} Return true if \var{ob} is of type \cdata{PyDateTime_DateTimeType} or a subtype of \cdata{PyDateTime_DateTimeType}. \var{ob} must not be *************** *** 2679,2683 **** \end{cfuncdesc} ! \begin{cfuncdesc}{int}{PyDateTime_CheckExact}{ob} Return true if \var{ob} is of type \cdata{PyDateTime_DateTimeType}. \var{ob} must not be \NULL{}. --- 2681,2685 ---- \end{cfuncdesc} ! \begin{cfuncdesc}{int}{PyDateTime_CheckExact}{PyObject *ob} Return true if \var{ob} is of type \cdata{PyDateTime_DateTimeType}. \var{ob} must not be \NULL{}. *************** *** 2685,2689 **** \end{cfuncdesc} ! \begin{cfuncdesc}{int}{PyTime_Check}{ob} Return true if \var{ob} is of type \cdata{PyDateTime_TimeType} or a subtype of \cdata{PyDateTime_TimeType}. \var{ob} must not be --- 2687,2691 ---- \end{cfuncdesc} ! \begin{cfuncdesc}{int}{PyTime_Check}{PyObject *ob} Return true if \var{ob} is of type \cdata{PyDateTime_TimeType} or a subtype of \cdata{PyDateTime_TimeType}. \var{ob} must not be *************** *** 2692,2696 **** \end{cfuncdesc} ! \begin{cfuncdesc}{int}{PyTime_CheckExact}{ob} Return true if \var{ob} is of type \cdata{PyDateTime_TimeType}. \var{ob} must not be \NULL{}. --- 2694,2698 ---- \end{cfuncdesc} ! \begin{cfuncdesc}{int}{PyTime_CheckExact}{PyObject *ob} Return true if \var{ob} is of type \cdata{PyDateTime_TimeType}. \var{ob} must not be \NULL{}. *************** *** 2698,2702 **** \end{cfuncdesc} ! \begin{cfuncdesc}{int}{PyDelta_Check}{ob} Return true if \var{ob} is of type \cdata{PyDateTime_DeltaType} or a subtype of \cdata{PyDateTime_DeltaType}. \var{ob} must not be --- 2700,2704 ---- \end{cfuncdesc} ! \begin{cfuncdesc}{int}{PyDelta_Check}{PyObject *ob} Return true if \var{ob} is of type \cdata{PyDateTime_DeltaType} or a subtype of \cdata{PyDateTime_DeltaType}. \var{ob} must not be *************** *** 2705,2709 **** \end{cfuncdesc} ! \begin{cfuncdesc}{int}{PyDelta_CheckExact}{ob} Return true if \var{ob} is of type \cdata{PyDateTime_DeltaType}. \var{ob} must not be \NULL{}. --- 2707,2711 ---- \end{cfuncdesc} ! \begin{cfuncdesc}{int}{PyDelta_CheckExact}{PyObject *ob} Return true if \var{ob} is of type \cdata{PyDateTime_DeltaType}. \var{ob} must not be \NULL{}. *************** *** 2711,2715 **** \end{cfuncdesc} ! \begin{cfuncdesc}{int}{PyTZInfo_Check}{ob} Return true if \var{ob} is of type \cdata{PyDateTime_TZInfoType} or a subtype of \cdata{PyDateTime_TZInfoType}. \var{ob} must not be --- 2713,2717 ---- \end{cfuncdesc} ! \begin{cfuncdesc}{int}{PyTZInfo_Check}{PyObject *ob} Return true if \var{ob} is of type \cdata{PyDateTime_TZInfoType} or a subtype of \cdata{PyDateTime_TZInfoType}. \var{ob} must not be *************** *** 2718,2722 **** \end{cfuncdesc} ! \begin{cfuncdesc}{int}{PyTZInfo_CheckExact}{ob} Return true if \var{ob} is of type \cdata{PyDateTime_TZInfoType}. \var{ob} must not be \NULL{}. --- 2720,2724 ---- \end{cfuncdesc} ! \begin{cfuncdesc}{int}{PyTZInfo_CheckExact}{PyObject *ob} Return true if \var{ob} is of type \cdata{PyDateTime_TZInfoType}. \var{ob} must not be \NULL{}. *************** *** 2724,2727 **** --- 2726,2731 ---- \end{cfuncdesc} + Macros to create objects: + \begin{cfuncdesc}{PyObject*}{PyDate_FromDate}{int year, int month, int day} Return a \code{datetime.date} object with the specified year, month *************** *** 2753,2761 **** \end{cfuncdesc} \begin{cfuncdesc}{PyObject*}{PyDateTime_FromTimestamp}{PyObject *args} Create and return a new \code{datetime.datetime} object given an argument tuple suitable for passing to \code{datetime.datetime.fromtimestamp()}. - This macro is included for the convenience of modules implementing the - DB API. \versionadded{2.4} \end{cfuncdesc} --- 2757,2833 ---- \end{cfuncdesc} + Macros to extract fields from date objects. The argument must an + instance of \cdata{PyDateTime_Date}, including subclasses (such as + \cdata{PyDateTime_DateTime}). The argument must not be \NULL{}, and + the type is not checked: + + \begin{cfuncdesc}{int}{PyDateTime_GET_YEAR}{PyDateTime_Date *o} + Return the year, as a positive int. + \versionadded{2.4} + \end{cfuncdesc} + + \begin{cfuncdesc}{int}{PyDateTime_GET_MONTH}{PyDateTime_Date *o} + Return the month, as an int from 1 through 12. + \versionadded{2.4} + \end{cfuncdesc} + + \begin{cfuncdesc}{int}{PyDateTime_GET_DAY}{PyDateTime_Date *o} + Return the day, as an int from 1 through 31. + \versionadded{2.4} + \end{cfuncdesc} + + Macros to extract fields from datetime objects. The argument must an + instance of \cdata{PyDateTime_DateTime}, including subclasses. + The argument must not be \NULL{}, and the type is not checked: + + \begin{cfuncdesc}{int}{PyDateTime_DATE_GET_HOUR}{PyDateTime_DateTime *o} + Return the hour, an an int from 0 though 23. + \versionadded{2.4} + \end{cfuncdesc} + + \begin{cfuncdesc}{int}{PyDateTime_DATE_GET_MINUTE}{PyDateTime_DateTime *o} + Return the minute, as an int from 0 through 59. + \versionadded{2.4} + \end{cfuncdesc} + + \begin{cfuncdesc}{int}{PyDateTime_DATE_GET_SECOND}{PyDateTime_DateTime *o} + Return the second, as an int from 0 through 59. + \versionadded{2.4} + \end{cfuncdesc} + + \begin{cfuncdesc}{int}{PyDateTime_DATE_GET_MICROSECOND}{PyDateTime_DateTime *o} + Return the microsecond, as an int from 0 through 999999. + \versionadded{2.4} + \end{cfuncdesc} + + Macros to extract fields from time objects. The argument must an + instance of \cdata{PyDateTime_Time}, including subclasses. + The argument must not be \NULL{}, and the type is not checked: + + \begin{cfuncdesc}{int}{PyDateTime_TIME_GET_HOUR}{PyDateTime_Time *o} + Return the hour, as an int from 0 though 23. + \versionadded{2.4} + \end{cfuncdesc} + + \begin{cfuncdesc}{int}{PyDateTime_TIME_GET_MINUTE}{PyDateTime_Time *o} + Return the minute, as an int from 0 through 59. + \versionadded{2.4} + \end{cfuncdesc} + + \begin{cfuncdesc}{int}{PyDateTime_TIME_GET_SECOND}{PyDateTime_Time *o} + Return the second, as an int from 0 through 59. + \versionadded{2.4} + \end{cfuncdesc} + + \begin{cfuncdesc}{int}{PyDateTime_TIME_GET_MICROSECOND}{PyDateTime_Time *o} + Return the microsecond, as an int from 0 through 999999. + \versionadded{2.4} + \end{cfuncdesc} + + Macros for the convenience of modules implementing the DB API: + \begin{cfuncdesc}{PyObject*}{PyDateTime_FromTimestamp}{PyObject *args} Create and return a new \code{datetime.datetime} object given an argument tuple suitable for passing to \code{datetime.datetime.fromtimestamp()}. \versionadded{2.4} \end{cfuncdesc} *************** *** 2764,2769 **** Create and return a new \code{datetime.date} object given an argument tuple suitable for passing to \code{datetime.date.fromtimestamp()}. - This macro is included for the convenience of modules implementing the - DB API. \versionadded{2.4} \end{cfuncdesc} --- 2836,2839 ---- From tim_one at users.sourceforge.net Sun Jul 11 21:26:22 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 11 21:26:25 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1037,1.1038 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12108/Misc Modified Files: NEWS Log Message: SF patch 986010: add missing doc for datetime C API, from Anthony Tuininga. This is a derived patch, taking the opportunity to add some organization to the now-large pile of datetime-related macros, and to factor out tedious repeated text. Also improved some clumsy wording in NEWS. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1037 retrieving revision 1.1038 diff -C2 -d -r1.1037 -r1.1038 *** NEWS 10 Jul 2004 23:54:07 -0000 1.1037 --- NEWS 11 Jul 2004 19:26:19 -0000 1.1038 *************** *** 14,24 **** - Patch #550732: Add PyArg_VaParseTupleAndKeywords(). Analogous to ! PyArg_VaParse(). Both are now documented. Thanks Greg Chapman. - Allow string and unicode return types from .encode()/.decode() ! methods on string and unicode objects. Added unicode.decode() which was missing for no apparent reason. ! - An attempt to fix the mess that is Python's behaviour with signal handlers and threads, complicated by readline's behaviour. It's quite possible that there are still bugs here. --- 14,24 ---- - Patch #550732: Add PyArg_VaParseTupleAndKeywords(). Analogous to ! PyArg_VaParse(). Both are now documented. Thanks Greg Chapman. - Allow string and unicode return types from .encode()/.decode() ! methods on string and unicode objects. Added unicode.decode() which was missing for no apparent reason. ! - An attempt to fix the mess that is Python's behaviour with signal handlers and threads, complicated by readline's behaviour. It's quite possible that there are still bugs here. *************** *** 30,36 **** ------- ! - Bug #979794: difflib.get_grouped_opcodes() now handles the case of when it is ! comparing two empty lists. Was affecting both context_diff() and ! unified_diff(). Was also a duplicate of bug #980117. - Bug #980938: smtplib now prints debug output to sys.stderr. --- 30,36 ---- ------- ! - Bugs #979794 and #980117: difflib.get_grouped_opcodes() now handles the ! case of comparing two empty lists. This affected both context_diff() and ! unified_diff(), - Bug #980938: smtplib now prints debug output to sys.stderr. *************** *** 48,52 **** instead of unsigned. ! - decimal.py now only uses signals in the spec. The other conditions are no longer part of the public API. --- 48,52 ---- instead of unsigned. ! - decimal.py now only uses signals in the IBM spec. The other conditions are no longer part of the public API. *************** *** 58,62 **** SF patch 982681. ! - Non-blocking SSL sockets work again; they were broken in Python 2.3. SF patch 945642. --- 58,62 ---- SF patch 982681. ! - Non-blocking SSL sockets work again; they were broken in Python 2.3. SF patch 945642. *************** *** 70,73 **** --- 70,76 ---- ----- + - A large pile of datetime field-extraction macros is now documented, + thanks to Anthony Tuininga (patch #986010). + New platforms ------------- *************** *** 439,443 **** Library ------- ! - Bug #981530: Fix UnboundLocalError in shutil.rmtree(). This affects the documented behavior: the function passed to the onerror() --- 442,446 ---- Library ------- ! - Bug #981530: Fix UnboundLocalError in shutil.rmtree(). This affects the documented behavior: the function passed to the onerror() From tim_one at users.sourceforge.net Mon Jul 12 02:45:18 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Mon Jul 12 02:45:21 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1038,1.1039 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32296/Misc Modified Files: NEWS Log Message: Bug #788520: Queue class has logic error when non-blocking I don't agree it had a bug (see the report), so this is *not* a candidate for backporting, but the docs were confusing and the Queue implementation was old enough to vote. Rewrote put/put_nowait/get/get_nowait from scratch, to use a pair of Conditions (not_full and not_empty), sharing a common mutex. The code is 1/4 the size now, and 6.25x easier to understand. For blocking with timeout, we also get to reuse (indirectly) the tedious timeout code from threading.Condition. The Full and Empty exceptions raised by non-blocking calls are now easy (instead of nearly impossible) to explain truthfully: Full is raised if and only if the Queue truly is full when the non-blocking put call checks the queue size, and similarly for Empty versus non-blocking get. What I don't know is whether the new implementation is slower (or faster) than the old one. I don't really care. Anyone who cares a lot is encouraged to check that. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1038 retrieving revision 1.1039 diff -C2 -d -r1.1038 -r1.1039 *** NEWS 11 Jul 2004 19:26:19 -0000 1.1038 --- NEWS 12 Jul 2004 00:45:14 -0000 1.1039 *************** *** 30,33 **** --- 30,44 ---- ------- + - Bug #788520. Queue.{get, get_nowait, put, put_nowait} have new + implementations, exploiting Conditions (which didn't exist at the time + Queue was introduced). A minor semantic change is that the Full and + Empty exceptions raised by non-blocking calls now occur only if the + queue truly was full or empty at the instant the queue was checked (of + course the Queue may no longer be full or empty by the time a calling + thread sees those exceptions, though). Before, the exceptions could + also be raised if it was "merely inconvenient" for the implementation + to determine the true state of the Queue (because the Queue was locked + by some other method in progress). + - Bugs #979794 and #980117: difflib.get_grouped_opcodes() now handles the case of comparing two empty lists. This affected both context_diff() and From tim_one at users.sourceforge.net Mon Jul 12 02:45:16 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Mon Jul 12 02:45:24 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libqueue.tex,1.14,1.15 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32296/Doc/lib Modified Files: libqueue.tex Log Message: Bug #788520: Queue class has logic error when non-blocking I don't agree it had a bug (see the report), so this is *not* a candidate for backporting, but the docs were confusing and the Queue implementation was old enough to vote. Rewrote put/put_nowait/get/get_nowait from scratch, to use a pair of Conditions (not_full and not_empty), sharing a common mutex. The code is 1/4 the size now, and 6.25x easier to understand. For blocking with timeout, we also get to reuse (indirectly) the tedious timeout code from threading.Condition. The Full and Empty exceptions raised by non-blocking calls are now easy (instead of nearly impossible) to explain truthfully: Full is raised if and only if the Queue truly is full when the non-blocking put call checks the queue size, and similarly for Empty versus non-blocking get. What I don't know is whether the new implementation is slower (or faster) than the old one. I don't really care. Anyone who cares a lot is encouraged to check that. Index: libqueue.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libqueue.tex,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** libqueue.tex 29 Jan 2004 06:37:48 -0000 1.14 --- libqueue.tex 12 Jul 2004 00:45:14 -0000 1.15 *************** *** 27,31 **** Exception raised when non-blocking \method{get()} (or \method{get_nowait()}) is called on a \class{Queue} object which is ! empty or locked. \end{excdesc} --- 27,31 ---- Exception raised when non-blocking \method{get()} (or \method{get_nowait()}) is called on a \class{Queue} object which is ! empty. \end{excdesc} *************** *** 33,37 **** Exception raised when non-blocking \method{put()} (or \method{put_nowait()}) is called on a \class{Queue} object which is ! full or locked. \end{excdesc} --- 33,37 ---- Exception raised when non-blocking \method{put()} (or \method{put_nowait()}) is called on a \class{Queue} object which is ! full. \end{excdesc} *************** *** 52,56 **** \begin{methoddesc}{empty}{} Return \code{True} if the queue is empty, \code{False} otherwise. ! Becauseof multithreading semantics, this is not reliable. \end{methoddesc} --- 52,56 ---- \begin{methoddesc}{empty}{} Return \code{True} if the queue is empty, \code{False} otherwise. ! Because of multithreading semantics, this is not reliable. \end{methoddesc} From tim_one at users.sourceforge.net Mon Jul 12 02:45:16 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Mon Jul 12 02:45:25 2004 Subject: [Python-checkins] python/dist/src/Lib Queue.py,1.20,1.21 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32296/Lib Modified Files: Queue.py Log Message: Bug #788520: Queue class has logic error when non-blocking I don't agree it had a bug (see the report), so this is *not* a candidate for backporting, but the docs were confusing and the Queue implementation was old enough to vote. Rewrote put/put_nowait/get/get_nowait from scratch, to use a pair of Conditions (not_full and not_empty), sharing a common mutex. The code is 1/4 the size now, and 6.25x easier to understand. For blocking with timeout, we also get to reuse (indirectly) the tedious timeout code from threading.Condition. The Full and Empty exceptions raised by non-blocking calls are now easy (instead of nearly impossible) to explain truthfully: Full is raised if and only if the Queue truly is full when the non-blocking put call checks the queue size, and similarly for Empty versus non-blocking get. What I don't know is whether the new implementation is slower (or faster) than the old one. I don't really care. Anyone who cares a lot is encouraged to check that. Index: Queue.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/Queue.py,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** Queue.py 29 Jan 2004 06:37:49 -0000 1.20 --- Queue.py 12 Jul 2004 00:45:14 -0000 1.21 *************** *** 1,5 **** """A multi-producer, multi-consumer queue.""" ! from time import time as _time, sleep as _sleep from collections import deque --- 1,5 ---- """A multi-producer, multi-consumer queue.""" ! from time import time as _time from collections import deque *************** *** 21,32 **** """ try: ! import thread except ImportError: ! import dummy_thread as thread self._init(maxsize) ! self.mutex = thread.allocate_lock() ! self.esema = thread.allocate_lock() ! self.esema.acquire() ! self.fsema = thread.allocate_lock() def qsize(self): --- 21,39 ---- """ try: ! import threading except ImportError: ! import dummy_threading as threading self._init(maxsize) ! # mutex must be held whenever the queue is mutating. All methods ! # that acquire mutex must release it before returning. mutex ! # is shared between the two conditions, so acquiring and ! # releasing the conditions also acquires and releases mutex. ! self.mutex = threading.Lock() ! # Notify not_empty whenever an item is added to the queue; a ! # thread waiting to get is notified then. ! self.not_empty = threading.Condition(self.mutex) ! # Notify not_full whenever an item is removed from the queue; ! # a thread waiting to put is notified then. ! self.not_full = threading.Condition(self.mutex) def qsize(self): *************** *** 62,110 **** is ignored in that case). """ ! if block: if timeout is None: ! # blocking, w/o timeout, i.e. forever ! self.fsema.acquire() ! elif timeout >= 0: ! # waiting max. 'timeout' seconds. ! # this code snipped is from threading.py: _Event.wait(): ! # Balancing act: We can't afford a pure busy loop, so we ! # have to sleep; but if we sleep the whole timeout time, ! # we'll be unresponsive. The scheme here sleeps very ! # little at first, longer as time goes on, but never longer ! # than 20 times per second (or the timeout time remaining). ! delay = 0.0005 # 500 us -> initial delay of 1 ms endtime = _time() + timeout ! while True: ! if self.fsema.acquire(0): ! break remaining = endtime - _time() ! if remaining <= 0: #time is over and no slot was free raise Full ! delay = min(delay * 2, remaining, .05) ! _sleep(delay) #reduce CPU usage by using a sleep ! else: ! raise ValueError("'timeout' must be a positive number") ! elif not self.fsema.acquire(0): ! raise Full ! self.mutex.acquire() ! release_fsema = True ! try: ! was_empty = self._empty() self._put(item) ! # If we fail before here, the empty state has ! # not changed, so we can skip the release of esema ! if was_empty: ! self.esema.release() ! # If we fail before here, the queue can not be full, so ! # release_full_sema remains True ! release_fsema = not self._full() finally: ! # Catching system level exceptions here (RecursionDepth, ! # OutOfMemory, etc) - so do as little as possible in terms ! # of Python calls. ! if release_fsema: ! self.fsema.release() ! self.mutex.release() def put_nowait(self, item): --- 69,92 ---- is ignored in that case). """ ! if not block: ! return self.put_nowait(item) ! self.not_full.acquire() ! try: if timeout is None: ! while self._full(): ! self.not_full.wait() ! else: ! if timeout < 0: ! raise ValueError("'timeout' must be a positive number") endtime = _time() + timeout ! while self._full(): remaining = endtime - _time() ! if remaining < 0.0: raise Full ! self.not_full.wait(remaining) self._put(item) ! self.not_empty.notify() finally: ! self.not_full.release() def put_nowait(self, item): *************** *** 114,118 **** Otherwise raise the Full exception. """ ! return self.put(item, False) def get(self, block=True, timeout=None): --- 96,108 ---- Otherwise raise the Full exception. """ ! self.not_full.acquire() ! try: ! if self._full(): ! raise Full ! else: ! self._put(item) ! self.not_empty.notify() ! finally: ! self.not_full.release() def get(self, block=True, timeout=None): *************** *** 127,173 **** in that case). """ ! if block: if timeout is None: ! # blocking, w/o timeout, i.e. forever ! self.esema.acquire() ! elif timeout >= 0: ! # waiting max. 'timeout' seconds. ! # this code snipped is from threading.py: _Event.wait(): ! # Balancing act: We can't afford a pure busy loop, so we ! # have to sleep; but if we sleep the whole timeout time, ! # we'll be unresponsive. The scheme here sleeps very ! # little at first, longer as time goes on, but never longer ! # than 20 times per second (or the timeout time remaining). ! delay = 0.0005 # 500 us -> initial delay of 1 ms endtime = _time() + timeout ! while 1: ! if self.esema.acquire(0): ! break remaining = endtime - _time() ! if remaining <= 0: #time is over and no element arrived raise Empty ! delay = min(delay * 2, remaining, .05) ! _sleep(delay) #reduce CPU usage by using a sleep ! else: ! raise ValueError("'timeout' must be a positive number") ! elif not self.esema.acquire(0): ! raise Empty ! self.mutex.acquire() ! release_esema = True ! try: ! was_full = self._full() item = self._get() ! # If we fail before here, the full state has ! # not changed, so we can skip the release of fsema ! if was_full: ! self.fsema.release() ! # Failure means empty state also unchanged - release_esema ! # remains True. ! release_esema = not self._empty() finally: ! if release_esema: ! self.esema.release() ! self.mutex.release() ! return item def get_nowait(self): --- 117,141 ---- in that case). """ ! if not block: ! return self.get_nowait() ! self.not_empty.acquire() ! try: if timeout is None: ! while self._empty(): ! self.not_empty.wait() ! else: ! if timeout < 0: ! raise ValueError("'timeout' must be a positive number") endtime = _time() + timeout ! while self._empty(): remaining = endtime - _time() ! if remaining < 0.0: raise Empty ! self.not_empty.wait(remaining) item = self._get() ! self.not_full.notify() ! return item finally: ! self.not_empty.release() def get_nowait(self): *************** *** 177,181 **** raise the Empty exception. """ ! return self.get(False) # Override these methods to implement other queue organizations --- 145,158 ---- raise the Empty exception. """ ! self.not_empty.acquire() ! try: ! if self._empty(): ! raise Empty ! else: ! item = self._get() ! self.not_full.notify() ! return item ! finally: ! self.not_empty.release() # Override these methods to implement other queue organizations From tim_one at users.sourceforge.net Mon Jul 12 03:20:39 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Mon Jul 12 03:20:41 2004 Subject: [Python-checkins] python/dist/src/Lib Queue.py,1.21,1.22 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6276/Lib Modified Files: Queue.py Log Message: Simplified the new get/get_nowait/put/put_nowait implementations a bit. Index: Queue.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/Queue.py,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** Queue.py 12 Jul 2004 00:45:14 -0000 1.21 --- Queue.py 12 Jul 2004 01:20:32 -0000 1.22 *************** *** 69,77 **** is ignored in that case). """ - if not block: - return self.put_nowait(item) self.not_full.acquire() try: ! if timeout is None: while self._full(): self.not_full.wait() --- 69,78 ---- is ignored in that case). """ self.not_full.acquire() try: ! if not block: ! if self._full(): ! raise Full ! elif timeout is None: while self._full(): self.not_full.wait() *************** *** 82,86 **** while self._full(): remaining = endtime - _time() ! if remaining < 0.0: raise Full self.not_full.wait(remaining) --- 83,87 ---- while self._full(): remaining = endtime - _time() ! if remaining <= 0.0: raise Full self.not_full.wait(remaining) *************** *** 96,108 **** Otherwise raise the Full exception. """ ! self.not_full.acquire() ! try: ! if self._full(): ! raise Full ! else: ! self._put(item) ! self.not_empty.notify() ! finally: ! self.not_full.release() def get(self, block=True, timeout=None): --- 97,101 ---- Otherwise raise the Full exception. """ ! return self.put(item, False) def get(self, block=True, timeout=None): *************** *** 117,125 **** in that case). """ - if not block: - return self.get_nowait() self.not_empty.acquire() try: ! if timeout is None: while self._empty(): self.not_empty.wait() --- 110,119 ---- in that case). """ self.not_empty.acquire() try: ! if not block: ! if self._empty(): ! raise Empty ! elif timeout is None: while self._empty(): self.not_empty.wait() *************** *** 130,134 **** while self._empty(): remaining = endtime - _time() ! if remaining < 0.0: raise Empty self.not_empty.wait(remaining) --- 124,128 ---- while self._empty(): remaining = endtime - _time() ! if remaining <= 0.0: raise Empty self.not_empty.wait(remaining) *************** *** 145,158 **** raise the Empty exception. """ ! self.not_empty.acquire() ! try: ! if self._empty(): ! raise Empty ! else: ! item = self._get() ! self.not_full.notify() ! return item ! finally: ! self.not_empty.release() # Override these methods to implement other queue organizations --- 139,143 ---- raise the Empty exception. """ ! return self.get(False) # Override these methods to implement other queue organizations From anthonybaxter at users.sourceforge.net Mon Jul 12 10:15:40 2004 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Mon Jul 12 10:15:43 2004 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew24.tex, 1.64, 1.65 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31401 Modified Files: whatsnew24.tex Log Message: another note for amk Index: whatsnew24.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew24.tex,v retrieving revision 1.64 retrieving revision 1.65 diff -C2 -d -r1.64 -r1.65 *** whatsnew24.tex 9 Jul 2004 16:16:46 -0000 1.64 --- whatsnew24.tex 12 Jul 2004 08:15:37 -0000 1.65 *************** *** 845,848 **** --- 845,850 ---- the group didn't match, the pattern \var{B} will be used instead. + % XXX sre is now non-recursive. + \item The \module{weakref} module now supports a wider variety of objects including Python functions, class instances, sets, frozensets, deques, From vsajip at users.sourceforge.net Mon Jul 12 11:21:45 2004 From: vsajip at users.sourceforge.net (vsajip@users.sourceforge.net) Date: Mon Jul 12 11:21:49 2004 Subject: [Python-checkins] python/dist/src/Lib/logging handlers.py, 1.15, 1.16 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/logging In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10143 Modified Files: handlers.py Log Message: Removed debugging print statements from TimedRotatingFileHandler, and sorted list returned by glob.glob() (SF #987166) Index: handlers.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/logging/handlers.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** handlers.py 8 Jul 2004 10:24:04 -0000 1.15 --- handlers.py 12 Jul 2004 09:21:41 -0000 1.16 *************** *** 225,229 **** self.rolloverAt += (daysToWait * (60 * 60 * 24)) ! print "Will rollover at %d, %d seconds from now" % (self.rolloverAt, self.rolloverAt - currentTime) def shouldRollover(self, record): --- 225,229 ---- self.rolloverAt += (daysToWait * (60 * 60 * 24)) ! #print "Will rollover at %d, %d seconds from now" % (self.rolloverAt, self.rolloverAt - currentTime) def shouldRollover(self, record): *************** *** 237,241 **** if t >= self.rolloverAt: return 1 ! print "No need to rollover: %d, %d" % (t, self.rolloverAt) return 0 --- 237,241 ---- if t >= self.rolloverAt: return 1 ! #print "No need to rollover: %d, %d" % (t, self.rolloverAt) return 0 *************** *** 260,265 **** s = glob.glob(self.baseFilename + ".20*") if len(s) > self.backupCount: os.remove(s[0]) ! print "%s -> %s" % (self.baseFilename, dfn) self.stream = open(self.baseFilename, "w") self.rolloverAt = int(time.time()) + self.interval --- 260,266 ---- s = glob.glob(self.baseFilename + ".20*") if len(s) > self.backupCount: + s.sort() os.remove(s[0]) ! #print "%s -> %s" % (self.baseFilename, dfn) self.stream = open(self.baseFilename, "w") self.rolloverAt = int(time.time()) + self.interval From anthonybaxter at users.sourceforge.net Mon Jul 12 11:25:21 2004 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Mon Jul 12 11:25:25 2004 Subject: [Python-checkins] python/dist/src Makefile.pre.in,1.145,1.146 Message-ID: Update of /cvsroot/python/python/dist/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10696 Modified Files: Makefile.pre.in Log Message: install test/decimaltestdata as well Index: Makefile.pre.in =================================================================== RCS file: /cvsroot/python/python/dist/src/Makefile.pre.in,v retrieving revision 1.145 retrieving revision 1.146 diff -C2 -d -r1.145 -r1.146 *** Makefile.pre.in 8 Jun 2004 18:52:39 -0000 1.145 --- Makefile.pre.in 12 Jul 2004 09:25:18 -0000 1.146 *************** *** 659,662 **** --- 659,663 ---- PLATMACPATH=:plat-mac:plat-mac/lib-scriptpackages LIBSUBDIRS= lib-old lib-tk site-packages test test/output test/data \ + test/decimaltestdata \ encodings email email/test email/test/data compiler hotshot \ logging bsddb bsddb/test csv idlelib idlelib/Icons \ From anthonybaxter at users.sourceforge.net Mon Jul 12 11:33:42 2004 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Mon Jul 12 11:33:45 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1039,1.1040 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12191 Modified Files: NEWS Log Message: install test/decimaltestdata as well Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1039 retrieving revision 1.1040 diff -C2 -d -r1.1039 -r1.1040 *** NEWS 12 Jul 2004 00:45:14 -0000 1.1039 --- NEWS 12 Jul 2004 09:33:39 -0000 1.1040 *************** *** 90,93 **** --- 90,96 ---- ----- + - The test data files for the decimal test suite are now installed on + platforms that use the Makefile. + Windows ------- From full-disclosure-admin at lists.netsys.com Mon Jul 12 13:51:05 2004 From: full-disclosure-admin at lists.netsys.com (full-disclosure-admin@lists.netsys.com) Date: Mon Jul 12 14:06:02 2004 Subject: [Python-checkins] Your message to Full-Disclosure awaits moderator approval Message-ID: <20040712115105.18141.51902.Mailman@NETSYS.COM> Your mail to 'Full-Disclosure' with the subject Mail Delivery (failure full-disclosure@lists.netsys.com) Is being held until the list moderator can review it for approval. The reason it is being held: Post by non-member to a members-only list Either the message will get posted to the list, or you will receive notification of the moderator's decision. From aimacintyre at users.sourceforge.net Mon Jul 12 14:10:33 2004 From: aimacintyre at users.sourceforge.net (aimacintyre@users.sourceforge.net) Date: Mon Jul 12 14:10:37 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_socket.py, 1.71, 1.72 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3203 Modified Files: test_socket.py Log Message: FreeBSD's services file contains an additional echo service entry, with a non-standard protocol and on a lower port than the tcp/udp entries, which breaks the assumption that there will only be one service by a given name on a given port when no protocol is specified. Previous versions of this code have had other problems as a result of different service definitions amongst common platforms. As this platform has an extra, unexpected, service entry, I've special cased the platform rather than re-order the list of services checked to highlight the pitfall. Index: test_socket.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_socket.py,v retrieving revision 1.71 retrieving revision 1.72 diff -C2 -d -r1.71 -r1.72 *** test_socket.py 6 Jul 2004 16:48:25 -0000 1.71 --- test_socket.py 12 Jul 2004 12:10:30 -0000 1.72 *************** *** 290,294 **** # I've ordered this by protocols that have both a tcp and udp # protocol, at least for modern Linuxes. ! for service in ('echo', 'daytime', 'domain'): try: port = socket.getservbyname(service, 'tcp') --- 290,300 ---- # I've ordered this by protocols that have both a tcp and udp # protocol, at least for modern Linuxes. ! if sys.platform in ('freebsd4', 'freebsd5'): ! # avoid the 'echo' service on this platform, as there is an ! # assumption breaking non-standard port/protocol entry ! services = ('daytime', 'qotd', 'domain') ! else: ! services = ('echo', 'daytime', 'domain') ! for service in services: try: port = socket.getservbyname(service, 'tcp') From rhettinger at users.sourceforge.net Mon Jul 12 15:00:53 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Mon Jul 12 15:00:56 2004 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew24.tex, 1.65, 1.66 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10634 Modified Files: whatsnew24.tex Log Message: Fix markup. Index: whatsnew24.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew24.tex,v retrieving revision 1.65 retrieving revision 1.66 diff -C2 -d -r1.65 -r1.66 *** whatsnew24.tex 12 Jul 2004 08:15:37 -0000 1.65 --- whatsnew24.tex 12 Jul 2004 13:00:45 -0000 1.66 *************** *** 106,110 **** The problematic expressions are primarily left shifts and lengthy ! hexadecimal and octal constants. For example, \code{2 << 32} results in a warning in 2.3, evaluating to 0 on 32-bit platforms. In Python 2.4, this expression now returns the correct answer, 8589934592. --- 106,111 ---- The problematic expressions are primarily left shifts and lengthy ! hexadecimal and octal constants. For example, ! \code{2 \textless{}\textless{} 32} results in a warning in 2.3, evaluating to 0 on 32-bit platforms. In Python 2.4, this expression now returns the correct answer, 8589934592. *************** *** 369,373 **** 351364.18288201344j >>> d.sqrt() ! Decimal(``351364.1828820134592177245001'') \end{verbatim} --- 370,374 ---- 351364.18288201344j >>> d.sqrt() ! Decimal("351364.1828820134592177245001") \end{verbatim} *************** *** 397,404 **** 28 >>> decimal.Decimal(1) / decimal.Decimal(7) ! Decimal(``0.1428571428571428571428571429'') >>> decimal.getcontext().prec = 9 >>> decimal.Decimal(1) / decimal.Decimal(7) ! Decimal(``0.142857143'') \end{verbatim} --- 398,405 ---- 28 >>> decimal.Decimal(1) / decimal.Decimal(7) ! Decimal("0.1428571428571428571428571429") >>> decimal.getcontext().prec = 9 >>> decimal.Decimal(1) / decimal.Decimal(7) ! Decimal("0.142857143") \end{verbatim} *************** *** 409,413 **** \begin{verbatim} >>> decimal.Decimal(1) / decimal.Decimal(0) ! Decimal(``Infinity'') >>> decimal.getcontext().trap_enablers[decimal.DivisionByZero] = True >>> decimal.Decimal(1) / decimal.Decimal(0) --- 410,414 ---- \begin{verbatim} >>> decimal.Decimal(1) / decimal.Decimal(0) ! Decimal("Infinity") >>> decimal.getcontext().trap_enablers[decimal.DivisionByZero] = True >>> decimal.Decimal(1) / decimal.Decimal(0) *************** *** 426,430 **** by Facundo Batista, Eric Price, Raymond Hettinger, Aahz, and Tim Peters.} ! \seeurl{http://research.microsoft.com/~hollasch/cgindex/coding/ieeefloat.html} {A more detailed overview of the IEEE-754 representation.} --- 427,431 ---- by Facundo Batista, Eric Price, Raymond Hettinger, Aahz, and Tim Peters.} ! \seeurl{http://research.microsoft.com/\textasciitilde hollasch/cgindex/coding/ieeefloat.html} {A more detailed overview of the IEEE-754 representation.} *************** *** 437,441 **** is being proposed as a standard, and underlies the new Python decimal type. Much of this material was written by Mike Cowlishaw, designer of the ! REXX language.} \end{seealso} --- 438,442 ---- is being proposed as a standard, and underlies the new Python decimal type. Much of this material was written by Mike Cowlishaw, designer of the ! Rexx language.} \end{seealso} *************** *** 585,589 **** \begin{itemize} ! \item The inner loops for list and tupleslicing were optimized and now run about one-third faster. The inner loops were also optimized for dictionaries with performance --- 586,590 ---- \begin{itemize} ! \item The inner loops for list and tuple slicing were optimized and now run about one-third faster. The inner loops were also optimized for dictionaries with performance *************** *** 858,862 **** %====================================================================== ! % whole new modules get described in \subsections here \subsection{cookielib} --- 859,863 ---- %====================================================================== ! % whole new modules get described in subsections here \subsection{cookielib} From akuchling at users.sourceforge.net Mon Jul 12 15:10:49 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Mon Jul 12 15:10:55 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS, 1.831.4.132, 1.831.4.133 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12595/Misc Modified Files: Tag: release23-maint NEWS Log Message: Patch #909007] Enable a bunch of safe bug workarounds in OpenSSL, for compatibility with various broken SSL implementations out there. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.831.4.132 retrieving revision 1.831.4.133 diff -C2 -d -r1.831.4.132 -r1.831.4.133 *** NEWS 10 Jul 2004 22:58:32 -0000 1.831.4.132 --- NEWS 12 Jul 2004 13:10:45 -0000 1.831.4.133 *************** *** 38,41 **** --- 38,44 ---- line numbers + - Patch #909007: Enable a bunch of safe bug workarounds in OpenSSL, for + the sake of compatibility with various broken SSL implementations. + Library ------- From akuchling at users.sourceforge.net Mon Jul 12 15:10:49 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Mon Jul 12 15:10:57 2004 Subject: [Python-checkins] python/dist/src/Modules _ssl.c,1.13.6.2,1.13.6.3 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12595/Modules Modified Files: Tag: release23-maint _ssl.c Log Message: Patch #909007] Enable a bunch of safe bug workarounds in OpenSSL, for compatibility with various broken SSL implementations out there. Index: _ssl.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_ssl.c,v retrieving revision 1.13.6.2 retrieving revision 1.13.6.3 diff -C2 -d -r1.13.6.2 -r1.13.6.3 *** _ssl.c 27 Oct 2003 14:24:41 -0000 1.13.6.2 --- _ssl.c 12 Jul 2004 13:10:47 -0000 1.13.6.3 *************** *** 221,224 **** --- 221,225 ---- SSL_CTX_set_verify(self->ctx, SSL_VERIFY_NONE, NULL); /* set verify lvl */ + SSL_CTX_set_options(self->ctx, SSL_OP_ALL); /* ssl compatibility */ self->ssl = SSL_new(self->ctx); /* New ssl struct */ Py_END_ALLOW_THREADS From mwh at users.sourceforge.net Mon Jul 12 15:15:58 2004 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Mon Jul 12 15:16:02 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_transformer.py, NONE, 1.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13510/Lib/test Added Files: test_transformer.py Log Message: this is patch [ 988698 ] compiler.transformer fix for (a, b) = 1, 2 fixing bug [ 988613 ] compiler.transformer and tuple unpacking --- NEW FILE: test_transformer.py --- import unittest from test import test_support from compiler import transformer, ast from compiler import compile class Tests(unittest.TestCase): def testMultipleLHS(self): """ Test multiple targets on the left hand side. """ snippets = ['a, b = 1, 2', '(a, b) = 1, 2', '((a, b), c) = (1, 2), 3'] for s in snippets: a = transformer.parse(s) assert isinstance(a, ast.Module) child1 = a.getChildNodes()[0] assert isinstance(child1, ast.Stmt) child2 = child1.getChildNodes()[0] assert isinstance(child2, ast.Assign) # This actually tests the compiler, but it's a way to assure the ast # is correct c = compile(s, '', 'single') vals = {} exec c in vals assert vals['a'] == 1 assert vals['b'] == 2 def test_main(): test_support.run_unittest( Tests ) if __name__ == "__main__": test_main() From mwh at users.sourceforge.net Mon Jul 12 15:15:58 2004 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Mon Jul 12 15:16:03 2004 Subject: [Python-checkins] python/dist/src/Lib/compiler transformer.py, 1.39, 1.40 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/compiler In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13510/Lib/compiler Modified Files: transformer.py Log Message: this is patch [ 988698 ] compiler.transformer fix for (a, b) = 1, 2 fixing bug [ 988613 ] compiler.transformer and tuple unpacking Index: transformer.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/compiler/transformer.py,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** transformer.py 19 May 2004 08:20:08 -0000 1.39 --- transformer.py 12 Jul 2004 13:15:56 -0000 1.40 *************** *** 930,934 **** while 1: t = node[0] ! if t == symbol.exprlist or t == symbol.testlist: if len(node) > 2: return self.com_assign_tuple(node, assigning) --- 930,934 ---- while 1: t = node[0] ! if t == symbol.exprlist or t == symbol.testlist or t == symbol.testlist_gexp: if len(node) > 2: return self.com_assign_tuple(node, assigning) From rhettinger at users.sourceforge.net Mon Jul 12 15:16:52 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Mon Jul 12 15:16:54 2004 Subject: [Python-checkins] python/dist/src/Tools/scripts texcheck.py, 1.10, 1.11 Message-ID: Update of /cvsroot/python/python/dist/src/Tools/scripts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13853 Modified Files: texcheck.py Log Message: Add more known macros. Index: texcheck.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/scripts/texcheck.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** texcheck.py 8 Jul 2004 04:22:35 -0000 1.10 --- texcheck.py 12 Jul 2004 13:16:49 -0000 1.11 *************** *** 58,61 **** --- 58,62 ---- \email \kwindex \refexmodindex \filenq \e \menuselection \exindex \linev \newsgroup \verbatim \setshortversion + \author \authoraddress \paragraph \subparagraph \cmemberline """ From rhettinger at users.sourceforge.net Mon Jul 12 15:22:16 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Mon Jul 12 15:22:19 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libdecimal.tex,1.12,1.13 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14866 Modified Files: libdecimal.tex Log Message: Small elaboration and typo fixes. Index: libdecimal.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libdecimal.tex,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** libdecimal.tex 11 Jul 2004 12:40:19 -0000 1.12 --- libdecimal.tex 12 Jul 2004 13:22:14 -0000 1.13 *************** *** 23,27 **** \item Decimal numbers can be represented exactly. In contrast, numbers like \constant{1.1} do not have an exact representation in binary floating point. ! End users typically wound not expect \constant{1.1} to display as \constant{1.1000000000000001} as it does with binary floating point. --- 23,27 ---- \item Decimal numbers can be represented exactly. In contrast, numbers like \constant{1.1} do not have an exact representation in binary floating point. ! End users typically would not expect \constant{1.1} to display as \constant{1.1000000000000001} as it does with binary floating point. *************** *** 539,543 **** This is useful because constants are often given to a greater precision than ! is needed by the application. \end{methoddesc} --- 539,555 ---- This is useful because constants are often given to a greater precision than ! is needed by the application. Another benefit is that rounding immediately ! eliminates unintended effects from digits beyond the current precision. ! In the following example, using unrounded inputs means that adding zero ! to a sum can change the result: ! ! \begin{verbatim} ! >>> getcontext().prec = 3 ! >>> Decimal("3.4445") + Decimal("1.0023") ! Decimal("4.45") ! >>> Decimal("3.4445") + Decimal(0) + Decimal("1.0023") ! Decimal("4.44") ! \end{verbatim} ! \end{methoddesc} *************** *** 613,622 **** Normalize reduces an operand to its simplest form. ! Essentially a plus operation with all trailing zeros removed from the ! result. \end{methoddesc} \begin{methoddesc}{plus}{x} ! Minus corresponds to the unary prefix plus operator in Python. \end{methoddesc} --- 625,636 ---- Normalize reduces an operand to its simplest form. ! Essentially a \method{plus} operation with all trailing zeros removed from ! the result. \end{methoddesc} \begin{methoddesc}{plus}{x} ! Plus corresponds to the unary prefix plus operator in Python. This ! operation applies the context precision and rounding, so it is ! \emph{not} an identity operation. \end{methoddesc} From rhettinger at users.sourceforge.net Mon Jul 12 15:29:13 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Mon Jul 12 15:29:16 2004 Subject: [Python-checkins] python/dist/src/Tools/scripts texcheck.py, 1.11, 1.12 Message-ID: Update of /cvsroot/python/python/dist/src/Tools/scripts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16059 Modified Files: texcheck.py Log Message: Use set() instead of sets.Set() Index: texcheck.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/scripts/texcheck.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** texcheck.py 12 Jul 2004 13:16:49 -0000 1.11 --- texcheck.py 12 Jul 2004 13:29:10 -0000 1.12 *************** *** 24,28 **** import re - import sets import sys import getopt --- 24,27 ---- *************** *** 88,92 **** falsetexcmd = re.compile(r'\/([A-Za-z]+)') # Mismarked with forward slash ! validcmds = sets.Set(cmdstr.split()) for cmd in morecmds: validcmds.add('\\' + cmd) --- 87,91 ---- falsetexcmd = re.compile(r'\/([A-Za-z]+)') # Mismarked with forward slash ! validcmds = set(cmdstr.split()) for cmd in morecmds: validcmds.add('\\' + cmd) *************** *** 96,100 **** else: pairmap = {']':'[', ')':'('} # Normal opener for a given closer ! openpunct = sets.Set('([') # Set of valid openers delimiters = re.compile(r'\\(begin|end){([_a-zA-Z]+)}|([()\[\]])') --- 95,99 ---- else: pairmap = {']':'[', ')':'('} # Normal opener for a given closer ! openpunct = set('([') # Set of valid openers delimiters = re.compile(r'\\(begin|end){([_a-zA-Z]+)}|([()\[\]])') From mondragon at users.sourceforge.net Mon Jul 12 15:44:28 2004 From: mondragon at users.sourceforge.net (mondragon@users.sourceforge.net) Date: Mon Jul 12 15:44:31 2004 Subject: [Python-checkins] python/dist/src/Lib profile.py,1.56,1.57 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18767/Lib Modified Files: profile.py Log Message: Fix SF Bug #989066 Index: profile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/profile.py,v retrieving revision 1.56 retrieving revision 1.57 diff -C2 -d -r1.56 -r1.57 *** profile.py 7 Jul 2004 20:54:45 -0000 1.56 --- profile.py 12 Jul 2004 13:44:26 -0000 1.57 *************** *** 217,221 **** if event == "c_call": ! self.c_func_name = arg if self.dispatch[event](self, frame,t): --- 217,221 ---- if event == "c_call": ! self.c_func_name = repr(arg) if self.dispatch[event](self, frame,t): *************** *** 234,238 **** if event == "c_call": ! self.c_func_name = arg if self.dispatch[event](self, frame, t): --- 234,238 ---- if event == "c_call": ! self.c_func_name = repr(arg) if self.dispatch[event](self, frame, t): *************** *** 249,253 **** if event == "c_call": ! self.c_func_name = arg if self.dispatch[event](self, frame, t): --- 249,253 ---- if event == "c_call": ! self.c_func_name = repr(arg) if self.dispatch[event](self, frame, t): *************** *** 263,267 **** if event == "c_call": ! self.c_func_name = arg if self.dispatch[event](self, frame, t): --- 263,267 ---- if event == "c_call": ! self.c_func_name = repr(arg) if self.dispatch[event](self, frame, t): From fernribeiro52004xz at mailcity.com Mon Jul 12 15:49:36 2004 From: fernribeiro52004xz at mailcity.com (Fernando Ribeiro) Date: Mon Jul 12 15:49:18 2004 Subject: [Python-checkins] Mala Direta por e-mail - Listas atualizadas: http://www.divulgamail.vze.com Message-ID: <20040712134917.635C91E4003@bag.python.org> Emails super atualizados para mala direta, listas de e-mails para divulga??o, email marketing, programas para envio e captura de e-mails. Cadastros segmentados por estados e atividades http://www.gueb.de/divulgamail Emails segmentados e genericos para marketing direto (mala direta por e-mail),valida??o de listas de emails,dicas,bulk mail,e-list,lista eletr?nica,cadastros de home pages em sites de buscas, publicidade, propaganda, marketing, bulk mail http://www.gueb.de/divulgamail From rhettinger at users.sourceforge.net Mon Jul 12 16:39:57 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Mon Jul 12 16:40:00 2004 Subject: [Python-checkins] python/nondist/peps pep-0289.txt,1.14,1.15 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30815 Modified Files: pep-0289.txt Log Message: Small update. Index: pep-0289.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0289.txt,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** pep-0289.txt 3 Jul 2004 22:26:41 -0000 1.14 --- pep-0289.txt 12 Jul 2004 14:39:54 -0000 1.15 *************** *** 251,257 **** The utility of generator expressions is greatly enhanced when combined ! with reduction functions like sum(), min(), and max(). The sandbox ! contains a draft statistics module with several new accumulation ! functions including: product(), average(), nlargest(), and nsmallest(). --- 251,258 ---- The utility of generator expressions is greatly enhanced when combined ! with reduction functions like sum(), min(), and max(). The heapq ! module in Python 2.4 includes two new reduction functions: nlargest() ! and nsmallest(). Both work well with generator expressions and keep ! no more than n items in memory at one time. From vsajip at users.sourceforge.net Mon Jul 12 17:48:06 2004 From: vsajip at users.sourceforge.net (vsajip@users.sourceforge.net) Date: Mon Jul 12 17:48:10 2004 Subject: [Python-checkins] python/dist/src/Doc/lib liblogging.tex,1.20,1.21 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11802 Modified Files: liblogging.tex Log Message: Fixed minor bugs in the example configuration file Index: liblogging.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/liblogging.tex,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** liblogging.tex 7 Jul 2004 15:59:49 -0000 1.20 --- liblogging.tex 12 Jul 2004 15:48:04 -0000 1.21 *************** *** 1216,1220 **** [handler_hand06] ! class=NTEventLogHandler level=CRITICAL formatter=form06 --- 1216,1220 ---- [handler_hand06] ! class=handlers.NTEventLogHandler level=CRITICAL formatter=form06 *************** *** 1222,1226 **** [handler_hand07] ! class=SMTPHandler level=WARN formatter=form07 --- 1222,1226 ---- [handler_hand07] ! class=handlers.SMTPHandler level=WARN formatter=form07 *************** *** 1228,1232 **** [handler_hand08] ! class=MemoryHandler level=NOTSET formatter=form08 --- 1228,1232 ---- [handler_hand08] ! class=handlers.MemoryHandler level=NOTSET formatter=form08 *************** *** 1235,1239 **** [handler_hand09] ! class=HTTPHandler level=NOTSET formatter=form09 --- 1235,1239 ---- [handler_hand09] ! class=handlers.HTTPHandler level=NOTSET formatter=form09 From theller at users.sourceforge.net Mon Jul 12 21:15:36 2004 From: theller at users.sourceforge.net (theller@users.sourceforge.net) Date: Mon Jul 12 21:15:39 2004 Subject: [Python-checkins] python/nondist/sandbox/msi msi.py,1.10,1.11 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/msi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24098 Modified Files: msi.py Log Message: Remove unused local variables. Index: msi.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/msi/msi.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** msi.py 8 Jul 2004 09:36:32 -0000 1.10 --- msi.py 12 Jul 2004 19:15:33 -0000 1.11 *************** *** 97,101 **** def remove_old_versions(db): start = "%s.%s.0" % (major, minor) - remove_package = 0 migrate_features = 1 if alpha: --- 97,100 ---- *************** *** 560,564 **** def extract_msvcr71(): ! import _winreg, win32api # Find the location of the merge modules k = _winreg.OpenKey( --- 559,563 ---- def extract_msvcr71(): ! import _winreg # Find the location of the merge modules k = _winreg.OpenKey( From bcannon at users.sourceforge.net Mon Jul 12 21:34:06 2004 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Mon Jul 12 21:34:12 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_strptime.py, 1.24, 1.25 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28133/Lib/test Modified Files: test_strptime.py Log Message: Fix test case for when time.tzname[0] is either UTC or GMT. Also have test output more telling details when there is a failure. Index: test_strptime.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_strptime.py,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** test_strptime.py 16 Nov 2003 16:17:48 -0000 1.24 --- test_strptime.py 12 Jul 2004 19:34:02 -0000 1.25 *************** *** 280,284 **** if sys.platform == "mac": return #MacOS9 has severely broken timezone support. ! tz_name= time.tzname[0] try: original_tzname = time.tzname --- 280,286 ---- if sys.platform == "mac": return #MacOS9 has severely broken timezone support. ! tz_name = time.tzname[0] ! if tz_name.lower() in ("UTC", "GMT"): ! return try: original_tzname = time.tzname *************** *** 287,291 **** time.daylight = 1 tz_value = _strptime.strptime(tz_name, "%Z")[8] ! self.failUnlessEqual(tz_value, -1) finally: time.tzname = original_tzname --- 289,296 ---- time.daylight = 1 tz_value = _strptime.strptime(tz_name, "%Z")[8] ! self.failUnlessEqual(tz_value, -1, ! "%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 From debian-knoppix-admin at linuxtag.org Mon Jul 12 21:46:01 2004 From: debian-knoppix-admin at linuxtag.org (debian-knoppix-admin@linuxtag.org) Date: Mon Jul 12 21:46:10 2004 Subject: [Python-checkins] Your message to debian-knoppix awaits moderator approval Message-ID: <20040712194601.3048.68163.Mailman@hydra.linuxtag.uni-kl.de> Your mail to 'debian-knoppix' with the subject Does it matter? Is being held until the list moderator can review it for approval. The reason it is being held: Post by non-member to a members-only list Either the message will get posted to the list, or you will receive notification of the moderator's decision. From dcjim at users.sourceforge.net Mon Jul 12 22:40:19 2004 From: dcjim at users.sourceforge.net (dcjim@users.sourceforge.net) Date: Mon Jul 12 22:40:24 2004 Subject: [Python-checkins] python/dist/src/Tools/modulator genmodule.py, 1.5, 1.5.16.1 Message-ID: Update of /cvsroot/python/python/dist/src/Tools/modulator In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11285 Modified Files: Tag: jim-modulator genmodule.py Log Message: Updating to generate new-stype types. Checking in work on progress. Maybe someone else wants to try it out. Index: genmodule.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/modulator/genmodule.py,v retrieving revision 1.5 retrieving revision 1.5.16.1 diff -C2 -d -r1.5 -r1.5.16.1 *** genmodule.py 11 Sep 2002 20:36:01 -0000 1.5 --- genmodule.py 12 Jul 2004 20:40:15 -0000 1.5.16.1 *************** *** 27,33 **** # Names of functions in the object-description struct. # ! FUNCLIST = ['new', 'tp_dealloc', 'tp_print', 'tp_getattr', 'tp_setattr', ! 'tp_compare', 'tp_repr', 'tp_hash', 'tp_call', 'tp_str'] ! TYPELIST = ['tp_as_number', 'tp_as_sequence', 'tp_as_mapping', 'structure'] # --- 27,38 ---- # Names of functions in the object-description struct. # ! FUNCLIST = ['tp_dealloc', 'tp_init', 'tp_new', ! 'tp_print', 'tp_getattr', 'tp_setattr', ! 'tp_compare', 'tp_repr', 'tp_hash', 'tp_call', 'tp_str', ! 'tp_descr_get', 'tp_descr_set', ! 'tp_iter', 'tp_iternext' ! ] ! TYPELIST = ['tp_as_number', 'tp_as_sequence', 'tp_as_mapping', ! 'structure', 'getset', 'gc'] # *************** *** 74,77 **** --- 79,84 ---- self.addcode('module_head', fp) for o in self.objects: + o.module = self.name + for o in self.objects: o.writehead(fp) for o in self.objects: *************** *** 82,96 **** self.addcode('module_method', fp) new_ml = new_ml + ( ! '{"%s",\t(PyCFunction)%s_%s,\tMETH_VARARGS,\t%s_%s__doc__},\n' %(fn, self.abbrev, fn, self.abbrev, fn)) self.methodlist = new_ml self.addcode('module_tail', fp) class object(writer): _type = 'object' def __init__(self): self.typelist = [] self.methodlist = [] ! self.funclist = ['new'] writer.__init__(self) --- 89,129 ---- self.addcode('module_method', fp) new_ml = new_ml + ( ! '\t{"%s",\t(PyCFunction)%s_%s,\tMETH_VARARGS,\n' ! '\t %s_%s__doc__},\n' %(fn, self.abbrev, fn, self.abbrev, fn)) self.methodlist = new_ml + + if self.objects: + ready_types = ['', '/* Initialize types: */'] + add_types = ['', '/* Add types: */'] + + for o in self.objects: + ready_types.extend(['if (PyType_Ready(&%s%s) < 0)' + % (o.abbrev, o.type), + '\treturn;' + ]) + add_types.extend(['if (PyModule_AddObject(m, "%s", ' + '(PyObject *)&%s%s) < 0)' + % (o.name, o.abbrev, o.type), + '\treturn;' + ]) + self.ready_types = '\n'.join(ready_types)+'\n' + self.add_types = '\n'.join(add_types)+'\n' + + else: + self.ready_types = self.add_types = '' + self.addcode('module_tail', fp) class object(writer): _type = 'object' + + def __init__(self): self.typelist = [] self.methodlist = [] ! self.funclist = [] ! self.object = '' ! self.type = 'Type' writer.__init__(self) *************** *** 104,137 **** def writebody(self, fp): ! new_ml = '' ! for fn in self.methodlist: ! self.method = fn ! self.addcode('object_method', fp) ! new_ml = new_ml + ( ! '{"%s",\t(PyCFunction)%s_%s,\tMETH_VARARGS,\t%s_%s__doc__},\n' ! %(fn, self.abbrev, fn, self.abbrev, fn)) ! self.methodlist = new_ml ! self.addcode('object_mlist', fp) ! # Add getattr if we have methods ! if self.methodlist and not 'tp_getattr' in self.funclist: ! self.funclist.insert(0, 'tp_getattr') for fn in FUNCLIST: setattr(self, fn, '0') - # - # Special case for structure-access objects: put getattr in the - # list of functions but don't generate code for it directly, - # the code is obtained from the object_structure template. - # The same goes for setattr. - # if 'structure' in self.typelist: ! if 'tp_getattr' in self.funclist: ! self.funclist.remove('tp_getattr') ! if 'tp_setattr' in self.funclist: ! self.funclist.remove('tp_setattr') ! self.tp_getattr = self.abbrev + '_getattr' ! self.tp_setattr = self.abbrev + '_setattr' for fn in self.funclist: self.addcode('object_'+fn, fp) --- 137,187 ---- def writebody(self, fp): ! if self.methodlist: ! new_ml = '' ! for fn in self.methodlist: ! self.method = fn ! self.addcode('object_method', fp) ! new_ml = new_ml + ( ! '\t{"%s",\t(PyCFunction)%s_%s,\tMETH_VARARGS,\n' ! '\t %s_%s__doc__},\n' ! %(fn, self.abbrev, fn, self.abbrev, fn)) ! self.methodlist = new_ml ! self.addcode('object_mlist', fp) ! self.tp_methods = self.abbrev + '_methods' ! ! else: ! self.tp_methods = '0' ! ! if 'gc' in self.typelist: ! self.call_clear = '\n\t' + self.abbrev + '_clear(self);' ! if 'tp_dealloc' in self.funclist: ! self.funclist.remove('tp_dealloc') ! self.typelist.append('tp_dealloc') ! self.extra_flags = "\n\t| Py_TPFLAGS_HAVE_GC" ! self.tp_traverse = self.abbrev + "_traverse" ! self.tp_clear = self.abbrev + "_clear" ! else: ! self.extra_flags = "" ! self.tp_traverse = self.tp_clear = "0" ! self.call_clear = '' ! for fn in FUNCLIST: setattr(self, fn, '0') if 'structure' in self.typelist: ! self.tp_members = self.abbrev + '_members' ! else: ! self.tp_members = '0' ! ! if 'getset' in self.typelist: ! self.tp_getset = self.abbrev + '_getset' ! else: ! self.tp_getset = '0' ! ! if 'tp_new' not in self.funclist: ! self.tp_new = 'PyType_GenericNew' ! for fn in self.funclist: self.addcode('object_'+fn, fp) From dcjim at users.sourceforge.net Mon Jul 12 22:40:19 2004 From: dcjim at users.sourceforge.net (dcjim@users.sourceforge.net) Date: Mon Jul 12 22:40:25 2004 Subject: [Python-checkins] python/dist/src/Tools/modulator/Templates object_gc, NONE, 1.1.2.1 object_getset, NONE, 1.1.2.1 object_tp_descr_get, NONE, 1.1.2.1 object_tp_descr_set, NONE, 1.1.2.1 object_tp_init, NONE, 1.1.2.1 object_tp_iter, NONE, 1.1.2.1 object_tp_iternext, NONE, 1.1.2.1 object_tp_new, NONE, 1.1.2.1 module_tail, 1.4, 1.4.46.1 object_head, 1.3, 1.3.16.1 object_method, 1.4, 1.4.18.1 object_mlist, 1.2, 1.2.46.1 object_structure, 1.3, 1.3.18.1 object_tail, 1.4, 1.4.46.1 object_tp_as_mapping, 1.3, 1.3.18.1 object_tp_as_number, 1.3, 1.3.18.1 object_tp_as_sequence, 1.3, 1.3.18.1 object_tp_call, 1.3, 1.3.18.1 object_tp_compare, 1.2, 1.2.18.1 object_tp_dealloc, 1.3, 1.3.18.1 object_tp_getattr, 1.3, 1.3.18.1 object_tp_hash, 1.2, 1.2.18.1 object_tp_print, 1.2, 1.2.18.1 object_tp_repr, 1.3, 1.3.18.1 object_tp_setattr, 1.4, 1.4.18.1 object_tp_str, 1.2, 1.2.18.1 object_new, 1.2, NONE Message-ID: Update of /cvsroot/python/python/dist/src/Tools/modulator/Templates In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11285/Templates Modified Files: Tag: jim-modulator module_tail object_head object_method object_mlist object_structure object_tail object_tp_as_mapping object_tp_as_number object_tp_as_sequence object_tp_call object_tp_compare object_tp_dealloc object_tp_getattr object_tp_hash object_tp_print object_tp_repr object_tp_setattr object_tp_str Added Files: Tag: jim-modulator object_gc object_getset object_tp_descr_get object_tp_descr_set object_tp_init object_tp_iter object_tp_iternext object_tp_new Removed Files: Tag: jim-modulator object_new Log Message: Updating to generate new-stype types. Checking in work on progress. Maybe someone else wants to try it out. --- NEW FILE: object_gc --- static int $abbrev$_traverse($abbrev$$object$ *self, visitproc visit, void *arg) { /* For each subobject that could be involved in cycles, do code like: if (self->xxx != NULL && visit(self->xxx, arg) < 0) return -1; */ return 0; } static int $abbrev$_clear($abbrev$$object$ *self) { /* XXXX Drop references that may have created reference cycles. Immutable objects do not have to define this method since they can never directly create reference cycles. Note that the object must still be valid after calling this method (don't just call Py_DECREF() on a reference). The collector will call this method if it detects that this object is involved in a reference cycle. */ return 0; } --- NEW FILE: object_getset --- /* Code to use getters and/or setters to support attributes */ /* Create gettrs and settrs. Here's an example that gets and sets a first name. */ /* static PyObject * $abbrev$_getfirst($abbrev$$object$ *self, void *closure) { Py_INCREF(self->first); return self->first; } */ /* static int $abbrev$_setfirst($abbrev$$object$ *self, PyObject *value, void *closure) { Py_DECREF(self->first); Py_INCREF(value); self->first = value; return 0; } */ static PyGetSetDef $abbrev$_getset[] = { /* {"first", (getter)$abbrev$_getfirst, (setter)$abbrev$_setfirst, "first name", NULL}, */ {NULL} /* Sentinel */ }; --- NEW FILE: object_tp_descr_get --- static PyObject * $abbrev$_descr_get($abbrev$$object$ *self, PyObject *inst, PyObject *cls) { /* XXXX Add your own get code here */ /* Note that inst may be NULL */ } --- NEW FILE: object_tp_descr_set --- static int $abbrev$_descr_set($abbrev$$object$ *self, PyObject *inst, PyObject *newvalue) { /* XXXX Add your own set code here */ return 0; } --- NEW FILE: object_tp_init --- static int $abbrev$_init($abbrev$$object$ *self, PyObject *args, PyObject *kwds) { static char *kwlist[] = {NULL}; if (! PyArg_ParseTupleAndKeywords(args, kwds, "", kwlist, )) return NULL; return 0 } --- NEW FILE: object_tp_iter --- static PyObject * $abbrev$_iter($abbrev$$object$ *self) { /* XXXX Return an iterator for the object. If the object is an iterator, then just return the object. */ } --- NEW FILE: object_tp_iternext --- static PyObject * $abbrev$_iternext($abbrev$$object$ *self) { /* XXXX Return the next object in the iteration. Raise StopIteration when done. */ PyErr_SetObject(PyExc_StopIteration, Py_None); } --- NEW FILE: object_tp_new --- static PyObject * $abbrev$_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { $abbrev$$object$ *self; self = ($abbrev$$object$ *)type->tp_alloc(type, 0); if (self != NULL) { /* setup instance variables here */ } return (PyObject *)self; } Index: module_tail =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/modulator/Templates/module_tail,v retrieving revision 1.4 retrieving revision 1.4.46.1 diff -C2 -d -r1.4 -r1.4.46.1 *** module_tail 7 Mar 1996 16:16:54 -0000 1.4 --- module_tail 12 Jul 2004 20:40:15 -0000 1.4.46.1 *************** *** 3,37 **** static struct PyMethodDef $abbrev$_methods[] = { ! $methodlist$ {NULL, (PyCFunction)NULL, 0, NULL} /* sentinel */ }; - /* Initialization function for the module (*must* be called init$name$) */ - static char $name$_module_documentation[] = "" ; ! void ! init$name$() { ! PyObject *m, *d; ! /* Create the module and add the functions */ ! m = Py_InitModule4("$name$", $abbrev$_methods, ! $name$_module_documentation, ! (PyObject*)NULL,PYTHON_API_VERSION); /* Add some symbolic constants to the module */ - d = PyModule_GetDict(m); ErrorObject = PyString_FromString("$name$.error"); ! PyDict_SetItemString(d, "error", ErrorObject); ! /* XXXX Add constants here */ - - /* Check for errors */ - if (PyErr_Occurred()) - Py_FatalError("can't initialize module $name$"); } --- 3,36 ---- static struct PyMethodDef $abbrev$_methods[] = { ! $methodlist$ {NULL, (PyCFunction)NULL, 0, NULL} /* sentinel */ }; static char $name$_module_documentation[] = "" ; ! #ifndef PyMODINIT_FUNC /* declarations for DLL import/export */ ! #define PyMODINIT_FUNC void ! #endif ! PyMODINIT_FUNC ! init$name$(void) { ! PyObject *m; ! $ready_types$ /* Create the module and add the functions */ ! m = Py_InitModule3("$name$", $abbrev$_methods, ! $name$_module_documentation); ! ! if (m == NULL) ! return; /* Add some symbolic constants to the module */ ErrorObject = PyString_FromString("$name$.error"); ! if (PyModule_AddObject(m, "error", ErrorObject) < 0) ! return; ! $add_types$ /* XXXX Add constants here */ } Index: object_head =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/modulator/Templates/object_head,v retrieving revision 1.3 retrieving revision 1.3.16.1 diff -C2 -d -r1.3 -r1.3.16.1 *** object_head 17 Jul 2002 16:30:39 -0000 1.3 --- object_head 12 Jul 2004 20:40:15 -0000 1.3.16.1 *************** *** 1,13 **** - /* Declarations for objects of type $name$ */ - typedef struct { PyObject_HEAD /* XXXX Add your own stuff here */ ! } $abbrev$object; ! ! static PyTypeObject $Abbrev$type; ! ! ! ! /* ---------------------------------------------------------------- */ --- 1,5 ---- typedef struct { PyObject_HEAD /* XXXX Add your own stuff here */ ! } $abbrev$$object$; Index: object_method =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/modulator/Templates/object_method,v retrieving revision 1.4 retrieving revision 1.4.18.1 diff -C2 -d -r1.4 -r1.4.18.1 *** object_method 27 Dec 2001 23:35:42 -0000 1.4 --- object_method 12 Jul 2004 20:40:15 -0000 1.4.18.1 *************** *** 5,9 **** static PyObject * ! $abbrev$_$method$($abbrev$object *self, PyObject *args) { if (!PyArg_ParseTuple(args, "")) --- 5,9 ---- static PyObject * ! $abbrev$_$method$($abbrev$$object$ *self, PyObject *args) { if (!PyArg_ParseTuple(args, "")) Index: object_mlist =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/modulator/Templates/object_mlist,v retrieving revision 1.2 retrieving revision 1.2.46.1 diff -C2 -d -r1.2 -r1.2.46.1 *** object_mlist 16 May 1995 13:46:53 -0000 1.2 --- object_mlist 12 Jul 2004 20:40:15 -0000 1.2.46.1 *************** *** 1,8 **** static struct PyMethodDef $abbrev$_methods[] = { ! $methodlist$ {NULL, NULL} /* sentinel */ }; - - /* ---------- */ - --- 1,5 ---- static struct PyMethodDef $abbrev$_methods[] = { ! $methodlist$ {NULL, NULL} /* sentinel */ }; Index: object_structure =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/modulator/Templates/object_structure,v retrieving revision 1.3 retrieving revision 1.3.18.1 diff -C2 -d -r1.3 -r1.3.18.1 *** object_structure 27 Dec 2001 23:35:42 -0000 1.3 --- object_structure 12 Jul 2004 20:40:15 -0000 1.3.18.1 *************** *** 4,37 **** #include "structmember.h" ! #define OFF(x) offsetof(XXXXobject, x) ! ! static struct memberlist $abbrev$_memberlist[] = { ! /* XXXX Add lines like { "foo", T_INT, OFF(foo), RO } */ {NULL} /* Sentinel */ }; - - static PyObject * - $abbrev$_getattr($abbrev$object *self, char *name) - { - PyObject *rv; - - /* XXXX Add your own getattr code here */ - rv = PyMember_Get((char *)/*XXXX*/0, $abbrev$_memberlist, name); - if (rv) - return rv; - PyErr_Clear(); - return Py_FindMethod($abbrev$_methods, (PyObject *)self, name); - } - - - static int - $abbrev$_setattr($abbrev$object *self, char *name, PyObject *v) - { - /* XXXX Add your own setattr code here */ - if ( v == NULL ) { - PyErr_SetString(PyExc_AttributeError, "Cannot delete attribute"); - return -1; - } - return PyMember_Set((char *)/*XXXX*/0, $abbrev$_memberlist, name, v); - } --- 4,12 ---- #include "structmember.h" ! static PyMemberDef $abbrev$_members[] = { ! /* XXXX Add lines like ! { "foo", T_INT, offsetof($abbrev$$object$, foo), RO }, ! */ {NULL} /* Sentinel */ }; Index: object_tail =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/modulator/Templates/object_tail,v retrieving revision 1.4 retrieving revision 1.4.46.1 diff -C2 -d -r1.4 -r1.4.46.1 *** object_tail 12 Oct 1995 13:45:24 -0000 1.4 --- object_tail 12 Jul 2004 20:40:15 -0000 1.4.46.1 *************** *** 1,30 **** ! static char $Abbrev$type__doc__[] = "" ; ! static PyTypeObject $Abbrev$type = { ! PyObject_HEAD_INIT(&PyType_Type) ! 0, /*ob_size*/ ! "$name$", /*tp_name*/ ! sizeof($abbrev$object), /*tp_basicsize*/ ! 0, /*tp_itemsize*/ ! /* methods */ ! (destructor)$tp_dealloc$, /*tp_dealloc*/ ! (printfunc)$tp_print$, /*tp_print*/ ! (getattrfunc)$tp_getattr$, /*tp_getattr*/ ! (setattrfunc)$tp_setattr$, /*tp_setattr*/ ! (cmpfunc)$tp_compare$, /*tp_compare*/ ! (reprfunc)$tp_repr$, /*tp_repr*/ ! $tp_as_number$, /*tp_as_number*/ ! $tp_as_sequence$, /*tp_as_sequence*/ ! $tp_as_mapping$, /*tp_as_mapping*/ ! (hashfunc)$tp_hash$, /*tp_hash*/ ! (ternaryfunc)$tp_call$, /*tp_call*/ ! (reprfunc)$tp_str$, /*tp_str*/ ! ! /* Space for future expansion */ ! 0L,0L,0L,0L, ! $Abbrev$type__doc__ /* Documentation string */ }; --- 1,51 ---- ! static char $Abbrev$$type$__doc__[] = "" ; ! static PyTypeObject $abbrev$$type$ = { ! PyObject_HEAD_INIT(NULL) ! /* ob_size */ 0, ! /* tp_name */ "$module$." ! "$name$", ! /* tp_basicsize */ sizeof($abbrev$$object$), ! /* tp_itemsize */ 0, ! /* tp_dealloc */ (destructor)$tp_dealloc$, ! /* tp_print */ (printfunc)$tp_print$, ! /* tp_getattr */ (getattrfunc)0, ! /* tp_setattr */ (setattrfunc)0, ! /* tp_compare */ (cmpfunc)$tp_compare$, ! /* tp_repr */ (reprfunc)$tp_repr$, ! /* tp_as_number */ $tp_as_number$, ! /* tp_as_sequence */ $tp_as_sequence$, ! /* tp_as_mapping */ $tp_as_mapping$, ! /* tp_hash */ (hashfunc)$tp_hash$, ! /* tp_call */ (ternaryfunc)$tp_call$, ! /* tp_str */ (reprfunc)$tp_str$, ! /* tp_getattro */ (getattrofunc)$tp_getattr$o, ! /* tp_setattro */ (setattrofunc)$tp_setattr$o, ! /* tp_as_buffer */ 0, ! /* tp_flags */ Py_TPFLAGS_DEFAULT ! | Py_TPFLAGS_BASETYPE $extra_flags$, ! /* tp_doc */ $Abbrev$$type$__doc__, ! /* tp_traverse */ (traverseproc)$tp_traverse$, ! /* tp_clear */ (inquiry)$tp_clear$, ! /* tp_richcompare */ (richcmpfunc)0, ! /* tp_weaklistoffset */ (long)0, ! /* tp_iter */ (getiterfunc)$tp_iter$, ! /* tp_iternext */ (iternextfunc)$tp_iternext$, ! /* tp_methods */ $tp_methods$, ! /* tp_members */ $tp_members$, ! /* tp_getset */ $tp_getset$, ! /* tp_base */ 0, ! /* tp_dict */ 0, /* internal use */ ! /* tp_descr_get */ (descrgetfunc)$tp_descr_get$, ! /* tp_descr_set */ (descrsetfunc)$tp_descr_set$, ! /* tp_dictoffset */ 0, ! /* tp_init */ (initproc)$tp_init$, ! /* tp_alloc */ (allocfunc)0, ! /* tp_new */ (newfunc)$tp_new$, ! /* tp_free */ 0, /* Low-level free-mem routine */ ! /* tp_is_gc */ (inquiry)0, /* For PyObject_IS_GC */ }; Index: object_tp_as_mapping =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/modulator/Templates/object_tp_as_mapping,v retrieving revision 1.3 retrieving revision 1.3.18.1 diff -C2 -d -r1.3 -r1.3.18.1 *** object_tp_as_mapping 27 Dec 2001 23:35:42 -0000 1.3 --- object_tp_as_mapping 12 Jul 2004 20:40:15 -0000 1.3.18.1 *************** *** 3,7 **** static int ! $abbrev$_length($abbrev$object *self) { /* XXXX Return the size of the mapping */ --- 3,7 ---- static int ! $abbrev$_length($abbrev$$object$ *self) { /* XXXX Return the size of the mapping */ *************** *** 9,13 **** static PyObject * ! $abbrev$_subscript($abbrev$object *self, PyObject *key) { /* XXXX Return the item of self indexed by key */ --- 9,13 ---- static PyObject * ! $abbrev$_subscript($abbrev$$object$ *self, PyObject *key) { /* XXXX Return the item of self indexed by key */ *************** *** 15,19 **** static int ! $abbrev$_ass_sub($abbrev$object *self, PyObject *v, PyObject *w) { /* XXXX Put w in self under key v */ --- 15,19 ---- static int ! $abbrev$_ass_sub($abbrev$$object$ *self, PyObject *v, PyObject *w) { /* XXXX Put w in self under key v */ *************** *** 22,28 **** static PyMappingMethods $abbrev$_as_mapping = { ! (inquiry)$abbrev$_length, /*mp_length*/ ! (binaryfunc)$abbrev$_subscript, /*mp_subscript*/ ! (objobjargproc)$abbrev$_ass_sub, /*mp_ass_subscript*/ }; --- 22,28 ---- static PyMappingMethods $abbrev$_as_mapping = { ! /* mp_length */ (inquiry)$abbrev$_length, ! /* mp_subscript */ (binaryfunc)$abbrev$_subscript, ! /* mp_ass_subscript */ (objobjargproc)$abbrev$_ass_sub, }; Index: object_tp_as_number =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/modulator/Templates/object_tp_as_number,v retrieving revision 1.3 retrieving revision 1.3.18.1 diff -C2 -d -r1.3 -r1.3.18.1 *** object_tp_as_number 27 Dec 2001 23:35:42 -0000 1.3 --- object_tp_as_number 12 Jul 2004 20:40:15 -0000 1.3.18.1 *************** *** 2,7 **** /* Code to access $name$ objects as numbers */ static PyObject * ! $abbrev$_add($abbrev$object *v, $abbrev$object *w) { /* XXXX Add them */ --- 2,18 ---- /* Code to access $name$ objects as numbers */ + /* Note that we follow the new pattern without coersion. + We leave the coerce slot empty and all binary and ternary operations + take PyObject* arguments. At least one of the arguments will be of + an $abbrev$$object$, but it may not be the first. + */ + + /* If you don't want to implement any of these, just remove the + function def and change the reference to a 0 in the structure + below. + */ + static PyObject * ! $abbrev$_add(PyObject *v, PyObject *w) { /* XXXX Add them */ *************** *** 9,13 **** static PyObject * ! $abbrev$_sub($abbrev$object *v, $abbrev$object *w) { /* XXXX Subtract them */ --- 20,24 ---- static PyObject * ! $abbrev$_sub(PyObject *v, PyObject *w) { /* XXXX Subtract them */ *************** *** 15,19 **** static PyObject * ! $abbrev$_mul($abbrev$object *v, $abbrev$object *w) { /* XXXX Multiply them */ --- 26,30 ---- static PyObject * ! $abbrev$_mul(PyObject *v, PyObject *w) { /* XXXX Multiply them */ *************** *** 21,25 **** static PyObject * ! $abbrev$_div($abbrev$object *x, $abbrev$object *y) { /* XXXX Divide them */ --- 32,36 ---- static PyObject * ! $abbrev$_div(PyObject *x, PyObject *y) { /* XXXX Divide them */ *************** *** 27,31 **** static PyObject * ! $abbrev$_mod($abbrev$object *x, $abbrev$object *y) { /* XXXX Modulo them */ --- 38,42 ---- static PyObject * ! $abbrev$_mod(PyObject *x, PyObject *y) { /* XXXX Modulo them */ *************** *** 33,37 **** static PyObject * ! $abbrev$_divmod($abbrev$object *x, $abbrev$object *y) { /* XXXX Return 2-tuple with div and mod */ --- 44,48 ---- static PyObject * ! $abbrev$_divmod(PyObject *x, PyObject *y) { /* XXXX Return 2-tuple with div and mod */ *************** *** 39,43 **** static PyObject * ! $abbrev$_pow($abbrev$object *v, $abbrev$object *w, $abbrev$object *z) { /* XXXX */ --- 50,54 ---- static PyObject * ! $abbrev$_pow(PyObject *v, PyObject *w, PyObject *z) { /* XXXX */ *************** *** 45,49 **** static PyObject * ! $abbrev$_neg($abbrev$object *v) { /* XXXX */ --- 56,60 ---- static PyObject * ! $abbrev$_neg($abbrev$$object$ *v) { /* XXXX */ *************** *** 51,55 **** static PyObject * ! $abbrev$_pos($abbrev$object *v) { /* XXXX */ --- 62,66 ---- static PyObject * ! $abbrev$_pos($abbrev$$object$ *v) { /* XXXX */ *************** *** 57,61 **** static PyObject * ! $abbrev$_abs($abbrev$object *v) { /* XXXX */ --- 68,72 ---- static PyObject * ! $abbrev$_abs($abbrev$$object$ *v) { /* XXXX */ *************** *** 63,67 **** static int ! $abbrev$_nonzero($abbrev$object *v) { /* XXXX Return 1 if non-zero */ --- 74,78 ---- static int ! $abbrev$_nonzero($abbrev$$object$ *v) { /* XXXX Return 1 if non-zero */ *************** *** 69,73 **** static PyObject * ! $abbrev$_invert($abbrev$object *v) { /* XXXX */ --- 80,84 ---- static PyObject * ! $abbrev$_invert($abbrev$$object$ *v) { /* XXXX */ *************** *** 75,79 **** static PyObject * ! $abbrev$_lshift($abbrev$object *v, $abbrev$object *w) { /* XXXX */ --- 86,90 ---- static PyObject * ! $abbrev$_lshift(PyObject *v, PyObject *w) { /* XXXX */ *************** *** 81,85 **** static PyObject * ! $abbrev$_rshift($abbrev$object *v, $abbrev$object *w) { /* XXXX */ --- 92,96 ---- static PyObject * ! $abbrev$_rshift(PyObject *v, PyObject *w) { /* XXXX */ *************** *** 87,91 **** static PyObject * ! $abbrev$_and($abbrev$object *v, $abbrev$object *w) { /* XXXX */ --- 98,102 ---- static PyObject * ! $abbrev$_and(PyObject *v, PyObject *w) { /* XXXX */ *************** *** 93,97 **** static PyObject * ! $abbrev$_xor($abbrev$object *v, $abbrev$object *w) { /* XXXX */ --- 104,108 ---- static PyObject * ! $abbrev$_xor(PyObject *v, PyObject *w) { /* XXXX */ *************** *** 99,116 **** static PyObject * ! $abbrev$_or($abbrev$object *v, $abbrev$object *w) { /* XXXX */ } - static int - $abbrev$_coerce(PyObject **pv, PyObject **pw) - { - /* XXXX I haven't a clue... */ - return 1; - } - static PyObject * ! $abbrev$_int($abbrev$object *v) { /* XXXX */ --- 110,120 ---- static PyObject * ! $abbrev$_or(PyObject *v, PyObject *w) { /* XXXX */ } static PyObject * ! $abbrev$_int($abbrev$$object$ *v) { /* XXXX */ *************** *** 118,122 **** static PyObject * ! $abbrev$_long($abbrev$object *v) { /* XXXX */ --- 122,126 ---- static PyObject * ! $abbrev$_long($abbrev$$object$ *v) { /* XXXX */ *************** *** 124,128 **** static PyObject * ! $abbrev$_float($abbrev$object *v) { /* XXXX */ --- 128,132 ---- static PyObject * ! $abbrev$_float($abbrev$$object$ *v) { /* XXXX */ *************** *** 130,134 **** static PyObject * ! $abbrev$_oct($abbrev$object *v) { /* XXXX Return object as octal stringobject */ --- 134,138 ---- static PyObject * ! $abbrev$_oct($abbrev$$object$ *v) { /* XXXX Return object as octal stringobject */ *************** *** 136,169 **** static PyObject * ! $abbrev$_hex($abbrev$object *v) { /* XXXX Return object as hex stringobject */ } static PyNumberMethods $abbrev$_as_number = { ! (binaryfunc)$abbrev$_add, /*nb_add*/ ! (binaryfunc)$abbrev$_sub, /*nb_subtract*/ ! (binaryfunc)$abbrev$_mul, /*nb_multiply*/ ! (binaryfunc)$abbrev$_div, /*nb_divide*/ ! (binaryfunc)$abbrev$_mod, /*nb_remainder*/ ! (binaryfunc)$abbrev$_divmod, /*nb_divmod*/ ! (ternaryfunc)$abbrev$_pow, /*nb_power*/ ! (unaryfunc)$abbrev$_neg, /*nb_negative*/ ! (unaryfunc)$abbrev$_pos, /*nb_positive*/ ! (unaryfunc)$abbrev$_abs, /*nb_absolute*/ ! (inquiry)$abbrev$_nonzero, /*nb_nonzero*/ ! (unaryfunc)$abbrev$_invert, /*nb_invert*/ ! (binaryfunc)$abbrev$_lshift, /*nb_lshift*/ ! (binaryfunc)$abbrev$_rshift, /*nb_rshift*/ ! (binaryfunc)$abbrev$_and, /*nb_and*/ ! (binaryfunc)$abbrev$_xor, /*nb_xor*/ ! (binaryfunc)$abbrev$_or, /*nb_or*/ ! (coercion)$abbrev$_coerce, /*nb_coerce*/ ! (unaryfunc)$abbrev$_int, /*nb_int*/ ! (unaryfunc)$abbrev$_long, /*nb_long*/ ! (unaryfunc)$abbrev$_float, /*nb_float*/ ! (unaryfunc)$abbrev$_oct, /*nb_oct*/ ! (unaryfunc)$abbrev$_hex, /*nb_hex*/ }; ! /* ------------------------------------------------------- */ --- 140,263 ---- static PyObject * ! $abbrev$_hex($abbrev$$object$ *v) { /* XXXX Return object as hex stringobject */ } + PyObject * + $abbrev$_inplace_add(PyObject *v, PyObject *w) + { + } + + PyObject * + $abbrev$_inplace_subtract(PyObject *v, PyObject *w) + { + } + + PyObject * + $abbrev$_inplace_multiply(PyObject *v, PyObject *w) + { + } + + PyObject * + $abbrev$_inplace_divide(PyObject *v, PyObject *w) + { + } + + PyObject * + $abbrev$_inplace_remainder(PyObject *v, PyObject *w) + { + } + + PyObject * + $abbrev$b_inplace_power(PyObject *v, PyObject *w, PyObject *modulo) + { + } + + PyObject * + $abbrev$_inplace_lshift(PyObject *v, PyObject *w) + { + } + + PyObject * + $abbrev$_inplace_rshift(PyObject *v, PyObject *w) + { + } + + PyObject * + $abbrev$_inplace_and(PyObject *v, PyObject *w) + { + } + + PyObject * + $abbrev$_inplace_xor(PyObject *v, PyObject *w) + { + } + + PyObject * + $abbrev$_inplace_or(PyObject *v, PyObject *w) + { + } + + PyObject * + $abbrev$_floor_divide(PyObject *v, PyObject *w) + { + } + + PyObject * + $abbrev$_true_divide(PyObject *v, PyObject *w) + { + } + + PyObject * + $abbrev$_inplace_floor_divide(PyObject *v, PyObject *w) + { + } + + PyObject * + $abbrev$_inplace_true_divide(PyObject *v, PyObject *w) + { + } + static PyNumberMethods $abbrev$_as_number = { ! /* nb_add */ (binaryfunc)$abbrev$_add, ! /* nb_subtract */ (binaryfunc)$abbrev$_sub, ! /* nb_multiply */ (binaryfunc)$abbrev$_mul, ! /* nb_divide */ (binaryfunc)$abbrev$_div, ! /* nb_remainder */ (binaryfunc)$abbrev$_mod, ! /* nb_divmod */ (binaryfunc)$abbrev$_divmod, ! /* nb_power */ (ternaryfunc)$abbrev$_pow, ! /* nb_negative */ (unaryfunc)$abbrev$_neg, ! /* nb_positive */ (unaryfunc)$abbrev$_pos, ! /* nb_absolute */ (unaryfunc)$abbrev$_abs, ! /* nb_nonzero */ (inquiry)$abbrev$_nonzero, ! /* nb_invert */ (unaryfunc)$abbrev$_invert, ! /* nb_lshift */ (binaryfunc)$abbrev$_lshift, ! /* nb_rshift */ (binaryfunc)$abbrev$_rshift, ! /* nb_and */ (binaryfunc)$abbrev$_and, ! /* nb_xor */ (binaryfunc)$abbrev$_xor, ! /* nb_or */ (binaryfunc)$abbrev$_or, ! /* nb_coerce */ 0, /* Coercion is obsolete! */ ! /* nb_int */ (unaryfunc)$abbrev$_int, ! /* nb_long */ (unaryfunc)$abbrev$_long, ! /* nb_float */ (unaryfunc)$abbrev$_float, ! /* nb_oct */ (unaryfunc)$abbrev$_oct, ! /* nb_hex */ (unaryfunc)$abbrev$_hex, ! /* nb_inplace_add */ (binaryfunc)$abbrev$_inplace_add, ! /* nb_inplace_subtract */ (binaryfunc)$abbrev$_inplace_subtract, ! /* nb_inplace_multiply */ (binaryfunc)$abbrev$_inplace_multiply, ! /* nb_inplace_divide */ (binaryfunc)$abbrev$_inplace_divide, ! /* nb_inplace_remainder */ (binaryfunc)$abbrev$_inplace_remainder, ! /* nb_inplace_power */ (ternaryfunc)$abbrev$_inplace_power, ! /* nb_inplace_lshift */ (binaryfunc)$abbrev$_inplace_lshift, ! /* nb_inplace_rshift */ (binaryfunc)$abbrev$_inplace_rshift, ! /* nb_inplace_and */ (binaryfunc)$abbrev$_inplace_and, ! /* nb_inplace_xor */ (binaryfunc)$abbrev$_inplace_xor, ! /* nb_inplace_or */ (binaryfunc)$abbrev$_inplace_or, ! /* nb_floor_divide */ (binaryfunc)$abbrev$_floor_divide, ! /* nb_true_divide */ (binaryfunc)$abbrev$_true_divide, ! /* nb_inplace_floor_divide */ (binaryfunc)$abbrev$_inplace_floor_divide, ! /* nb_inplace_true_divide */ (binaryfunc)$abbrev$_inplace_true_divide, }; ! /* ------------------------------------------------------- */ Index: object_tp_as_sequence =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/modulator/Templates/object_tp_as_sequence,v retrieving revision 1.3 retrieving revision 1.3.18.1 diff -C2 -d -r1.3 -r1.3.18.1 *** object_tp_as_sequence 27 Dec 2001 23:35:42 -0000 1.3 --- object_tp_as_sequence 12 Jul 2004 20:40:15 -0000 1.3.18.1 *************** *** 3,7 **** static int ! $abbrev$_length($abbrev$object *self) { /* XXXX Return the size of the object */ --- 3,7 ---- static int ! $abbrev$_length($abbrev$$object$ *self) { /* XXXX Return the size of the object */ *************** *** 9,13 **** static PyObject * ! $abbrev$_concat($abbrev$object *self, PyObject *bb) { /* XXXX Return the concatenation of self and bb */ --- 9,13 ---- static PyObject * ! $abbrev$_concat($abbrev$$object$ *self, PyObject *bb) { /* XXXX Return the concatenation of self and bb */ *************** *** 15,19 **** static PyObject * ! $abbrev$_repeat($abbrev$object *self, int n) { /* XXXX Return a new object that is n times self */ --- 15,19 ---- static PyObject * ! $abbrev$_repeat($abbrev$$object$ *self, int n) { /* XXXX Return a new object that is n times self */ *************** *** 21,25 **** static PyObject * ! $abbrev$_item($abbrev$object *self, int i) { /* XXXX Return the i-th object of self */ --- 21,25 ---- static PyObject * ! $abbrev$_item($abbrev$$object$ *self, int i) { /* XXXX Return the i-th object of self */ *************** *** 27,31 **** static PyObject * ! $abbrev$_slice($abbrev$object *self, int ilow, int ihigh) { /* XXXX Return the ilow..ihigh slice of self in a new object */ --- 27,31 ---- static PyObject * ! $abbrev$_slice($abbrev$$object$ *self, int ilow, int ihigh) { /* XXXX Return the ilow..ihigh slice of self in a new object */ *************** *** 33,37 **** static int ! $abbrev$_ass_item($abbrev$object *self, int i, PyObject *v) { /* XXXX Assign to the i-th element of self */ --- 33,37 ---- static int ! $abbrev$_ass_item($abbrev$$object$ *self, int i, PyObject *v) { /* XXXX Assign to the i-th element of self */ *************** *** 40,44 **** static int ! $abbrev$_ass_slice(PyListObject *self, int ilow, int ihigh, PyObject *v) { /* XXXX Replace ilow..ihigh slice of self with v */ --- 40,44 ---- static int ! $abbrev$_ass_slice($abbrev$$object$ *self, int ilow, int ihigh, PyObject *v) { /* XXXX Replace ilow..ihigh slice of self with v */ *************** *** 46,57 **** } static PySequenceMethods $abbrev$_as_sequence = { ! (inquiry)$abbrev$_length, /*sq_length*/ ! (binaryfunc)$abbrev$_concat, /*sq_concat*/ ! (intargfunc)$abbrev$_repeat, /*sq_repeat*/ ! (intargfunc)$abbrev$_item, /*sq_item*/ ! (intintargfunc)$abbrev$_slice, /*sq_slice*/ ! (intobjargproc)$abbrev$_ass_item, /*sq_ass_item*/ ! (intintobjargproc)$abbrev$_ass_slice, /*sq_ass_slice*/ }; --- 46,79 ---- } + static int + $abbrev$_contains($abbrev$$object$ *self, PyObject *v) + { + /* XXXX Does self contain v? */ + return 0; + } + + static PyObject * + $abbrev$_inplace_concat($abbrev$$object$ *self, PyObject *v) + { + /* XXXX Concat self and v in place */ + } + + static PyObject * + $abbrev$_inplace_repeat($abbrev$$object$ *self, int i) + { + /* XXXX Repeat self in place */ + } + static PySequenceMethods $abbrev$_as_sequence = { ! /* sq_length */ (inquiry)$abbrev$_length, ! /* sq_concat */ (binaryfunc)$abbrev$_concat, ! /* sq_repeat */ (intargfunc)$abbrev$_repeat, ! /* sq_item */ (intargfunc)$abbrev$_item, ! /* sq_slice */ (intintargfunc)$abbrev$_slice, ! /* sq_ass_item */ (intobjargproc)$abbrev$_ass_item, ! /* sq_ass_slice */ (intintobjargproc)$abbrev$_ass_slice, ! /* sq_contains */ (objobjproc)$abbrev$_contains, ! /* sq_inplace_concat */ (binaryfunc)$abbrev$_inplace_concat, ! /* sq_inplace_repeat */ (intargfunc)$abbrev$_inplace_repeat, }; Index: object_tp_call =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/modulator/Templates/object_tp_call,v retrieving revision 1.3 retrieving revision 1.3.18.1 diff -C2 -d -r1.3 -r1.3.18.1 *** object_tp_call 27 Dec 2001 23:35:42 -0000 1.3 --- object_tp_call 12 Jul 2004 20:40:15 -0000 1.3.18.1 *************** *** 1,5 **** static PyObject * ! $abbrev$_call($abbrev$object *self, PyObject *args, PyObject *kwargs) { /* XXXX Return the result of calling self with argument args */ --- 1,5 ---- static PyObject * ! $abbrev$_call($abbrev$$object$ *self, PyObject *args, PyObject *kwargs) { /* XXXX Return the result of calling self with argument args */ Index: object_tp_compare =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/modulator/Templates/object_tp_compare,v retrieving revision 1.2 retrieving revision 1.2.18.1 diff -C2 -d -r1.2 -r1.2.18.1 *** object_tp_compare 27 Dec 2001 23:35:42 -0000 1.2 --- object_tp_compare 12 Jul 2004 20:40:15 -0000 1.2.18.1 *************** *** 1,5 **** static int ! $abbrev$_compare($abbrev$object *v, $abbrev$object *w) { /* XXXX Compare objects and return -1, 0 or 1 */ --- 1,5 ---- static int ! $abbrev$_compare($abbrev$$object$ *v, $abbrev$$object$ *w) { /* XXXX Compare objects and return -1, 0 or 1 */ Index: object_tp_dealloc =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/modulator/Templates/object_tp_dealloc,v retrieving revision 1.3 retrieving revision 1.3.18.1 diff -C2 -d -r1.3 -r1.3.18.1 *** object_tp_dealloc 27 Dec 2001 23:35:43 -0000 1.3 --- object_tp_dealloc 12 Jul 2004 20:40:15 -0000 1.3.18.1 *************** *** 1,7 **** static void ! $abbrev$_dealloc($abbrev$object *self) ! { /* XXXX Add your own cleanup code here */ ! PyMem_DEL(self); } --- 1,7 ---- static void ! $abbrev$_dealloc($abbrev$$object$ *self) ! {$call_clear$ /* XXXX Add your own cleanup code here */ ! self->ob_type->tp_free((PyObject*)self); } Index: object_tp_getattr =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/modulator/Templates/object_tp_getattr,v retrieving revision 1.3 retrieving revision 1.3.18.1 diff -C2 -d -r1.3 -r1.3.18.1 *** object_tp_getattr 27 Dec 2001 23:35:43 -0000 1.3 --- object_tp_getattr 12 Jul 2004 20:40:15 -0000 1.3.18.1 *************** *** 1,7 **** static PyObject * ! $abbrev$_getattr($abbrev$object *self, char *name) { ! /* XXXX Add your own getattr code here */ ! return Py_FindMethod($abbrev$_methods, (PyObject *)self, name); } --- 1,10 ---- static PyObject * ! $abbrev$_getattro($abbrev$$object$ *self, PyObject *name) { ! /* XXXX Add your own getattr code here ! Do you *really* want to do this? Rather than using ! descriptors? */ ! Py_INCREF(Py_None); ! return Py_None; } Index: object_tp_hash =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/modulator/Templates/object_tp_hash,v retrieving revision 1.2 retrieving revision 1.2.18.1 diff -C2 -d -r1.2 -r1.2.18.1 *** object_tp_hash 27 Dec 2001 23:35:43 -0000 1.2 --- object_tp_hash 12 Jul 2004 20:40:15 -0000 1.2.18.1 *************** *** 1,5 **** static long ! $abbrev$_hash($abbrev$object *self) { /* XXXX Return a hash of self (or -1) */ --- 1,5 ---- static long ! $abbrev$_hash($abbrev$$object$ *self) { /* XXXX Return a hash of self (or -1) */ Index: object_tp_print =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/modulator/Templates/object_tp_print,v retrieving revision 1.2 retrieving revision 1.2.18.1 diff -C2 -d -r1.2 -r1.2.18.1 *** object_tp_print 27 Dec 2001 23:35:43 -0000 1.2 --- object_tp_print 12 Jul 2004 20:40:15 -0000 1.2.18.1 *************** *** 1,5 **** static int ! $abbrev$_print($abbrev$object *self, FILE *fp, int flags) { /* XXXX Add code here to print self to fp */ --- 1,5 ---- static int ! $abbrev$_print($abbrev$$object$ *self, FILE *fp, int flags) { /* XXXX Add code here to print self to fp */ Index: object_tp_repr =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/modulator/Templates/object_tp_repr,v retrieving revision 1.3 retrieving revision 1.3.18.1 diff -C2 -d -r1.3 -r1.3.18.1 *** object_tp_repr 27 Dec 2001 23:35:43 -0000 1.3 --- object_tp_repr 12 Jul 2004 20:40:15 -0000 1.3.18.1 *************** *** 1,5 **** static PyObject * ! $abbrev$_repr($abbrev$object *self) { PyObject *s; --- 1,5 ---- static PyObject * ! $abbrev$_repr($abbrev$$object$ *self) { PyObject *s; Index: object_tp_setattr =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/modulator/Templates/object_tp_setattr,v retrieving revision 1.4 retrieving revision 1.4.18.1 diff -C2 -d -r1.4 -r1.4.18.1 *** object_tp_setattr 27 Dec 2001 23:35:43 -0000 1.4 --- object_tp_setattr 12 Jul 2004 20:40:15 -0000 1.4.18.1 *************** *** 1,5 **** static int ! $abbrev$_setattr($abbrev$object *self, char *name, PyObject *v) { /* Set attribute 'name' to value 'v'. v==NULL means delete */ --- 1,5 ---- static int ! $abbrev$_setattro($abbrev$$object$ *self, PyObject *name, PyObject *v) { /* Set attribute 'name' to value 'v'. v==NULL means delete */ Index: object_tp_str =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/modulator/Templates/object_tp_str,v retrieving revision 1.2 retrieving revision 1.2.18.1 diff -C2 -d -r1.2 -r1.2.18.1 *** object_tp_str 27 Dec 2001 23:35:43 -0000 1.2 --- object_tp_str 12 Jul 2004 20:40:15 -0000 1.2.18.1 *************** *** 1,5 **** static PyObject * ! $abbrev$_str($abbrev$object *self) { PyObject *s; --- 1,5 ---- static PyObject * ! $abbrev$_str($abbrev$$object$ *self) { PyObject *s; --- object_new DELETED --- From theller at users.sourceforge.net Mon Jul 12 22:55:38 2004 From: theller at users.sourceforge.net (theller@users.sourceforge.net) Date: Mon Jul 12 22:55:42 2004 Subject: [Python-checkins] python/nondist/sandbox/msi msi.py,1.11,1.12 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/msi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14485 Modified Files: msi.py Log Message: Also install file lib/distutils/command/wininst-6.exe. Index: msi.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/msi/msi.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** msi.py 12 Jul 2004 19:15:33 -0000 1.11 --- msi.py 12 Jul 2004 20:55:36 -0000 1.12 *************** *** 644,647 **** --- 644,648 ---- lib.add_file("idle.icns") if dir=="command": + lib.add_file("wininst-6.exe") lib.add_file("wininst-7.1.exe") if dir=="data" and parent.physical=="test" and parent.basedir.physical=="email": From bwarsaw at users.sourceforge.net Tue Jul 13 01:10:15 2004 From: bwarsaw at users.sourceforge.net (bwarsaw@users.sourceforge.net) Date: Tue Jul 13 01:10:18 2004 Subject: [Python-checkins] python/dist/src/Lib smtpd.py,1.15,1.16 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7918 Modified Files: smtpd.py Log Message: Updated my email address to something that works . Index: smtpd.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/smtpd.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** smtpd.py 26 Jun 2004 19:42:10 -0000 1.15 --- smtpd.py 12 Jul 2004 23:10:08 -0000 1.16 *************** *** 62,66 **** # Please note that this script requires Python 2.0 # ! # Author: Barry Warsaw # # TODO: --- 62,66 ---- # Please note that this script requires Python 2.0 # ! # Author: Barry Warsaw # # TODO: From bwarsaw at users.sourceforge.net Tue Jul 13 01:10:44 2004 From: bwarsaw at users.sourceforge.net (bwarsaw@users.sourceforge.net) Date: Tue Jul 13 01:10:47 2004 Subject: [Python-checkins] python/dist/src/Lib smtpd.py,1.13,1.13.16.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8183 Modified Files: Tag: release23-maint smtpd.py Log Message: Updated my email address to something that works . Index: smtpd.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/smtpd.py,v retrieving revision 1.13 retrieving revision 1.13.16.1 diff -C2 -d -r1.13 -r1.13.16.1 *** smtpd.py 14 May 2002 02:13:30 -0000 1.13 --- smtpd.py 12 Jul 2004 23:10:42 -0000 1.13.16.1 *************** *** 62,66 **** # Please note that this script requires Python 2.0 # ! # Author: Barry Warsaw # # TODO: --- 62,66 ---- # Please note that this script requires Python 2.0 # ! # Author: Barry Warsaw # # TODO: From mondragon at users.sourceforge.net Tue Jul 13 01:38:04 2004 From: mondragon at users.sourceforge.net (mondragon@users.sourceforge.net) Date: Tue Jul 13 01:38:06 2004 Subject: [Python-checkins] python/dist/src/Lib profile.py,1.57,1.58 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13563/Lib Modified Files: profile.py Log Message: Using repr() generates entries that the current stats package can't collate, so setting it back to the function name Index: profile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/profile.py,v retrieving revision 1.57 retrieving revision 1.58 diff -C2 -d -r1.57 -r1.58 *** profile.py 12 Jul 2004 13:44:26 -0000 1.57 --- profile.py 12 Jul 2004 23:38:01 -0000 1.58 *************** *** 217,221 **** if event == "c_call": ! self.c_func_name = repr(arg) if self.dispatch[event](self, frame,t): --- 217,221 ---- if event == "c_call": ! self.c_func_name = arg.__name__ if self.dispatch[event](self, frame,t): *************** *** 234,238 **** if event == "c_call": ! self.c_func_name = repr(arg) if self.dispatch[event](self, frame, t): --- 234,238 ---- if event == "c_call": ! self.c_func_name = arg.__name__ if self.dispatch[event](self, frame, t): *************** *** 249,253 **** if event == "c_call": ! self.c_func_name = repr(arg) if self.dispatch[event](self, frame, t): --- 249,253 ---- if event == "c_call": ! self.c_func_name = arg.__name__ if self.dispatch[event](self, frame, t): *************** *** 263,267 **** if event == "c_call": ! self.c_func_name = repr(arg) if self.dispatch[event](self, frame, t): --- 263,267 ---- if event == "c_call": ! self.c_func_name = arg.__name__ if self.dispatch[event](self, frame, t): From mondragon at users.sourceforge.net Tue Jul 13 01:38:04 2004 From: mondragon at users.sourceforge.net (mondragon@users.sourceforge.net) Date: Tue Jul 13 01:38:07 2004 Subject: [Python-checkins] python/dist/src/Lib/test/output test_profile, 1.4, 1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test/output In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13563/Lib/test/output Modified Files: test_profile Log Message: Using repr() generates entries that the current stats package can't collate, so setting it back to the function name Index: test_profile =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/output/test_profile,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** test_profile 25 Jun 2004 23:31:05 -0000 1.4 --- test_profile 12 Jul 2004 23:38:02 -0000 1.5 *************** *** 5,11 **** ncalls tottime percall cumtime percall filename:lineno(function) ! 12 0.000 0.000 0.012 0.001 :0() ! 8 0.000 0.000 0.000 0.000 :0() ! 1 0.000 0.000 0.000 0.000 :0() 1 0.000 0.000 1.000 1.000 :1(?) 0 0.000 0.000 profile:0(profiler) --- 5,11 ---- ncalls tottime percall cumtime percall filename:lineno(function) ! 12 0.000 0.000 0.012 0.001 :0(hasattr) ! 8 0.000 0.000 0.000 0.000 :0(range) ! 1 0.000 0.000 0.000 0.000 :0(setprofile) 1 0.000 0.000 1.000 1.000 :1(?) 0 0.000 0.000 profile:0(profiler) From bcannon at users.sourceforge.net Tue Jul 13 02:48:44 2004 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Tue Jul 13 02:48:48 2004 Subject: [Python-checkins] python/dist/src/Doc/lib liburllib.tex,1.52,1.53 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26039/Doc/lib Modified Files: liburllib.tex Log Message: Add another point in the "Restrictions" section about how the handling of FTP URLs will seemingly succeed to read a URL that points to a file whose permissions you do not have to read. Backport candidate once everyone agrees with the wording. Index: liburllib.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/liburllib.tex,v retrieving revision 1.52 retrieving revision 1.53 diff -C2 -d -r1.52 -r1.53 *** liburllib.tex 25 Mar 2004 16:51:12 -0000 1.52 --- liburllib.tex 13 Jul 2004 00:48:42 -0000 1.53 *************** *** 330,333 **** --- 330,350 ---- \item + The code handling the FTP\index{FTP} protocol cannot differentiate between a + file and a directory and can lead to unexpected behavior when attempting to + read a URL that points to a file that is not accessible. + If the URL ends in a \code{/} then it is assumed to be a + directory and will be handled as such only. But if an attempt to read a file + leads to a 550 error (signaling the URL cannot be found or is not accessible, + often for permission reasons), then the path is treated as a directory in order + to handle the case of when a directory is specified by a URL but a trailing + \code{/} is left off. + This can lead to the apparent successful fetching of a file whose read + permissions you do not have by still succeeding by returning the directory + listing for the file from treating it as a directory. + If more fine-grained control is needed, consider using the \module{ftplib} + module, subclassing \class{FancyURLOpener}, or changing \var{_urlopener} to + meet your needs. + + \item This module does not support the use of proxies which require authentication. This may be implemented in the future. From bcannon at users.sourceforge.net Tue Jul 13 09:12:29 2004 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Tue Jul 13 09:12:36 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_site.py,1.4,1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8794/Lib/test Modified Files: test_site.py Log Message: Fixes a bug in testing code handling .pth files that did not restore the original module that is removed for testing "import" lines. Originally deleted the entry from sys.modules and then just let other code that needed it to import it again. Problem with this solution is that it lead to code that had already imported the module in question to have their own reference to a new copy of the module in question that new code couldn't reach. This lead to a failure in test_strptime since it monkey-patched the 'time' module it had a reference to while _strptime had its own reference to another copy of 'time' from being imported by test___all__ that it was using for a calculation. Also moved the testing code out of the PthFile class and into the actual test class. This was to stop using 'assert' which is useless with a -O execution. Index: test_site.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_site.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** test_site.py 10 Jul 2004 02:10:45 -0000 1.4 --- test_site.py 13 Jul 2004 07:12:25 -0000 1.5 *************** *** 57,60 **** --- 57,67 ---- "by _init_pathinfo(): %s" % (entry, dir_set)) + def pth_file_tests(self, pth_file): + """Contain common code for testing results of reading a .pth file""" + self.failUnless(pth_file.imported in sys.modules, + "%s not in sys.path" % pth_file.imported) + self.failUnless(site.makepath(pth_file.good_dir_path)[0] in sys.path) + self.failUnless(not os.path.exists(pth_file.bad_dir_path)) + def test_addpackage(self): # Make sure addpackage() imports if the line starts with 'import', *************** *** 63,72 **** # file resides; invalid directories are not added pth_file = PthFile() ! pth_file.cleanup() # to make sure that nothing is pre-existing that ! # shouldn't be try: pth_file.create() site.addpackage(pth_file.base_dir, pth_file.filename, set()) ! unittest.FunctionTestCase(pth_file.test) finally: pth_file.cleanup() --- 70,79 ---- # file resides; invalid directories are not added pth_file = PthFile() ! pth_file.cleanup(prep=True) # to make sure that nothing is ! # pre-existing that shouldn't be try: pth_file.create() site.addpackage(pth_file.base_dir, pth_file.filename, set()) ! self.pth_file_tests(pth_file) finally: pth_file.cleanup() *************** *** 76,84 **** # calls addpackage() for every .pth file in the directory pth_file = PthFile() ! pth_file.cleanup() # Make sure that nothing is pre-existing that is ! # tested for try: site.addsitedir(pth_file.base_dir, set()) ! unittest.FunctionTestCase(pth_file.test) finally: pth_file.cleanup() --- 83,92 ---- # calls addpackage() for every .pth file in the directory pth_file = PthFile() ! pth_file.cleanup(prep=True) # Make sure that nothing is pre-existing ! # that is tested for try: + pth_file.create() site.addsitedir(pth_file.base_dir, set()) ! self.pth_file_tests(pth_file) finally: pth_file.cleanup() *************** *** 93,97 **** self.base_dir = os.path.abspath('') self.file_path = os.path.join(self.base_dir, self.filename) ! self.imported = "time" self.good_dirname = good_dirname self.bad_dirname = bad_dirname --- 101,105 ---- self.base_dir = os.path.abspath('') self.file_path = os.path.join(self.base_dir, self.filename) ! self.imported = imported self.good_dirname = good_dirname self.bad_dirname = bad_dirname *************** *** 121,152 **** os.mkdir(self.good_dir_path) ! def cleanup(self): """Make sure that the .pth file is deleted, self.imported is not in sys.modules, and that both self.good_dirname and self.bad_dirname are not existing directories.""" ! try: os.remove(self.file_path) ! except OSError: ! pass ! try: ! del sys.modules[self.imported] ! except KeyError: ! pass ! try: os.rmdir(self.good_dir_path) ! except OSError: ! pass ! try: os.rmdir(self.bad_dir_path) - except OSError: - pass - - def test(self): - """Test to make sure that was and was not supposed to be created by - using the .pth file occurred""" - assert site.makepath(self.good_dir_path)[0] in sys.path - assert self.imported in sys.modules - assert not os.path.exists(self.bad_dir_path) - class ImportSideEffectTests(unittest.TestCase): --- 129,149 ---- os.mkdir(self.good_dir_path) ! def cleanup(self, prep=False): """Make sure that the .pth file is deleted, self.imported is not in sys.modules, and that both self.good_dirname and self.bad_dirname are not existing directories.""" ! if os.path.exists(self.file_path): os.remove(self.file_path) ! if prep: ! self.imported_module = sys.modules.get(self.imported) ! if self.imported_module: ! del sys.modules[self.imported] ! else: ! if self.imported_module: ! sys.modules[self.imported] = self.imported_module ! if os.path.exists(self.good_dir_path): os.rmdir(self.good_dir_path) ! if os.path.exists(self.bad_dir_path): os.rmdir(self.bad_dir_path) class ImportSideEffectTests(unittest.TestCase): From akuchling at users.sourceforge.net Tue Jul 13 16:03:35 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Tue Jul 13 16:03:38 2004 Subject: [Python-checkins] python/dist/src/Doc/lib liburllib.tex,1.53,1.54 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13357 Modified Files: liburllib.tex Log Message: Wordsmithing Index: liburllib.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/liburllib.tex,v retrieving revision 1.53 retrieving revision 1.54 diff -C2 -d -r1.53 -r1.54 *** liburllib.tex 13 Jul 2004 00:48:42 -0000 1.53 --- liburllib.tex 13 Jul 2004 14:03:31 -0000 1.54 *************** *** 330,348 **** \item ! The code handling the FTP\index{FTP} protocol cannot differentiate between a ! file and a directory and can lead to unexpected behavior when attempting to ! read a URL that points to a file that is not accessible. ! If the URL ends in a \code{/} then it is assumed to be a ! directory and will be handled as such only. But if an attempt to read a file ! leads to a 550 error (signaling the URL cannot be found or is not accessible, ! often for permission reasons), then the path is treated as a directory in order ! to handle the case of when a directory is specified by a URL but a trailing ! \code{/} is left off. ! This can lead to the apparent successful fetching of a file whose read ! permissions you do not have by still succeeding by returning the directory ! listing for the file from treating it as a directory. ! If more fine-grained control is needed, consider using the \module{ftplib} ! module, subclassing \class{FancyURLOpener}, or changing \var{_urlopener} to ! meet your needs. \item --- 330,348 ---- \item ! The code handling the FTP\index{FTP} protocol cannot differentiate ! between a file and a directory. This can lead to unexpected behavior ! when attempting to read a URL that points to a file that is not ! accessible. If the URL ends in a \code{/}, it is assumed to refer to ! a directory and will be handled accordingly. But if an attempt to ! read a file leads to a 550 error (meaning the URL cannot be found or ! is not accessible, often for permission reasons), then the path is ! treated as a directory in order to handle the case when a directory is ! specified by a URL but the trailing \code{/} has been left off. This can ! cause misleading results when you try to fetch a file whose read ! permissions make it inaccessible; the FTP code will try to read it, ! fail with a 550 error, and then perform a directory listing for the ! unreadable file. If fine-grained control is needed, consider using the ! \module{ftplib} module, subclassing \class{FancyURLOpener}, or changing ! \var{_urlopener} to meet your needs. \item From fdrake at users.sourceforge.net Tue Jul 13 19:08:12 2004 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Tue Jul 13 19:08:16 2004 Subject: [Python-checkins] python/dist/src/Doc/tools update-docs.sh, 1.11, 1.12 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/tools In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21304 Modified Files: update-docs.sh Log Message: generalize a bit; no need to mention my user id directly Index: update-docs.sh =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/tools/update-docs.sh,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** update-docs.sh 17 Jun 2004 17:19:12 -0000 1.11 --- update-docs.sh 13 Jul 2004 17:08:10 -0000 1.12 *************** *** 8,12 **** if [ -z "$HOME" ] ; then ! HOME=`grep fdrake /etc/passwd | sed 's|^.*:\([^:]*\):[^:]*$|\1|'` export HOME fi --- 8,12 ---- if [ -z "$HOME" ] ; then ! HOME=`grep "$LOGNAME" /etc/passwd | sed 's|^.*:\([^:]*\):[^:]*$|\1|'` export HOME fi From fdrake at users.sourceforge.net Tue Jul 13 19:09:56 2004 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Tue Jul 13 19:09:59 2004 Subject: [Python-checkins] python/dist/src/Doc/tools update-docs.sh, 1.10, 1.10.16.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/tools In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21678 Modified Files: Tag: release23-maint update-docs.sh Log Message: generalize a bit; no need to mention my user id directly Index: update-docs.sh =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/tools/update-docs.sh,v retrieving revision 1.10 retrieving revision 1.10.16.1 diff -C2 -d -r1.10 -r1.10.16.1 *** update-docs.sh 9 Aug 2002 22:56:46 -0000 1.10 --- update-docs.sh 13 Jul 2004 17:09:54 -0000 1.10.16.1 *************** *** 8,12 **** if [ -z "$HOME" ] ; then ! HOME=`grep fdrake /etc/passwd | sed 's|^.*:\([^:]*\):[^:]*$|\1|'` export HOME fi --- 8,12 ---- if [ -z "$HOME" ] ; then ! HOME=`grep "$LOGNAME" /etc/passwd | sed 's|^.*:\([^:]*\):[^:]*$|\1|'` export HOME fi From tim_one at users.sourceforge.net Tue Jul 13 19:18:12 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Tue Jul 13 19:18:19 2004 Subject: [Python-checkins] python/dist/src/Doc/api newtypes.tex,1.30,1.31 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/api In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23417/Doc/api Modified Files: newtypes.tex Log Message: Claifications: visit procs are supplied by the core, users aren't expected to write their own. A NULL "object" must not be passed to the visit callback. A non-zero return from a visit proc isn't necessarily an error return (and it doesn't matter to the tp_traverse code *what* it might signify, their only job is to return it). Index: newtypes.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/newtypes.tex,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** newtypes.tex 17 Feb 2004 04:17:36 -0000 1.30 --- newtypes.tex 13 Jul 2004 17:18:10 -0000 1.31 *************** *** 1646,1650 **** handler. The function should be called with an object to traverse as \var{object} and the third parameter to the \member{tp_traverse} ! handler as \var{arg}. \end{ctypedesc} --- 1646,1652 ---- handler. The function should be called with an object to traverse as \var{object} and the third parameter to the \member{tp_traverse} ! handler as \var{arg}. The Python core uses several visitor functions ! to implement cyclic garbage detection; it's not expected that users will ! need to write their own visitor functions. \end{ctypedesc} *************** *** 1656,1661 **** call the \var{visit} function for each object directly contained by \var{self}, with the parameters to \var{visit} being the contained ! object and the \var{arg} value passed to the handler. If ! \var{visit} returns a non-zero value then an error has occurred and that value should be returned immediately. \end{ctypedesc} --- 1658,1664 ---- call the \var{visit} function for each object directly contained by \var{self}, with the parameters to \var{visit} being the contained ! object and the \var{arg} value passed to the handler. The \var{visit} ! function must not be called with a \NULL{} object argument. If ! \var{visit} returns a non-zero value that value should be returned immediately. \end{ctypedesc} From fdrake at users.sourceforge.net Tue Jul 13 23:04:29 2004 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Tue Jul 13 23:04:32 2004 Subject: [Python-checkins] python/dist/src/Doc/doc doc.tex,1.85,1.86 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11722 Modified Files: doc.tex Log Message: clarify where \versionadded and \versionchanged should be placed when they are used Index: doc.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/doc/doc.tex,v retrieving revision 1.85 retrieving revision 1.86 diff -C2 -d -r1.85 -r1.86 *** doc.tex 10 May 2004 18:39:32 -0000 1.85 --- doc.tex 13 Jul 2004 21:04:26 -0000 1.86 *************** *** 1019,1022 **** --- 1019,1046 ---- \end{macrodesc} + \begin{macrodesc}{warning}{\p{text}} + An important bit of information about an API that a user should + be very aware of when using whatever bit of API the warning + pertains to. This should be the last thing in the paragraph as + the end of the warning is not visually marked in any way. The + content of \var{text} should be written in complete sentences + and include all appropriate punctuation. This differs from + \macro{note} in that it is recommended over \macro{note} for + information regarding security. + \end{macrodesc} + + The following two macros are used to describe information that's + associated with changes from one release to another. For features + which are described by a single paragraph, these are typically + added as separate source lines at the end of the paragraph. When + adding these to features described by multiple paragraphs, they + are usually collected in a single separate paragraph after the + description. When both \macro{versionadded} and + \macro{versionchanged} are used, \macro{versionadded} should come + first; the versions should be listed in chronological order. Both + of these should come before availability statements. The location + should be selected so the explanation makes sense and may vary as + needed. + \begin{macrodesc}{versionadded}{\op{explanation}\p{version}} The version of Python which added the described feature to the *************** *** 1024,1031 **** explanation of the change consisting of a capitalized sentence fragment; a period will be appended by the formatting process. ! This is typically added to the end of the first paragraph of the ! description before any availability notes. The location should ! be selected so the explanation makes sense and may vary as ! needed. \end{macrodesc} --- 1048,1053 ---- explanation of the change consisting of a capitalized sentence fragment; a period will be appended by the formatting process. ! When this applies to an entire module, it should be placed at ! the top of the module section before any prose. \end{macrodesc} *************** *** 1035,1054 **** \var{explanation} should be a \emph{brief} explanation of the change consisting of a capitalized sentence fragment; a ! period will be appended by the formatting process. ! This is typically added to the end of the first paragraph of the ! description before any availability notes and after ! \macro{versionadded}. The location should be selected so the ! explanation makes sense and may vary as needed. ! \end{macrodesc} ! ! \begin{macrodesc}{warning}{\p{text}} ! An important bit of information about an API that a user should ! be very aware of when using whatever bit of API the warning ! pertains to. This should be the last thing in the paragraph as ! the end of the warning is not visually marked in any way. The ! content of \var{text} should be written in complete sentences ! and include all appropriate punctuation. This differs from ! \macro{note} in that it is recommended over \macro{note} for ! information regarding security. \end{macrodesc} --- 1057,1062 ---- \var{explanation} should be a \emph{brief} explanation of the change consisting of a capitalized sentence fragment; a ! period will be appended by the formatting process. This should ! not generally be applied to modules. \end{macrodesc} From greg at users.sourceforge.net Tue Jul 13 23:06:54 2004 From: greg at users.sourceforge.net (greg@users.sourceforge.net) Date: Tue Jul 13 23:06:56 2004 Subject: [Python-checkins] python/dist/src/Lib/bsddb __init__.py, 1.5.10.4, 1.5.10.5 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/bsddb In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12062 Modified Files: Tag: release23-maint __init__.py Log Message: fix for SF bug #897820 (backport of cvs diff -r1.14 -r1.15 __init__.py) Use os.unlink() instead of the BerkeleyDB DB_TRUNCATE flag. Index: __init__.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/bsddb/__init__.py,v retrieving revision 1.5.10.4 retrieving revision 1.5.10.5 diff -C2 -d -r1.5.10.4 -r1.5.10.5 *** __init__.py 26 Feb 2004 10:21:13 -0000 1.5.10.4 --- __init__.py 13 Jul 2004 21:06:51 -0000 1.5.10.5 *************** *** 53,57 **** #---------------------------------------------------------------------- ! import sys # for backwards compatibility with python versions older than 2.3, the --- 53,57 ---- #---------------------------------------------------------------------- ! import sys, os # for backwards compatibility with python versions older than 2.3, the *************** *** 182,186 **** cachesize=None, lorder=None, hflags=0): ! flags = _checkflag(flag) d = db.DB() d.set_flags(hflags) --- 182,186 ---- cachesize=None, lorder=None, hflags=0): ! flags = _checkflag(flag, file) d = db.DB() d.set_flags(hflags) *************** *** 199,203 **** pgsize=None, lorder=None): ! flags = _checkflag(flag) d = db.DB() if cachesize is not None: d.set_cachesize(0, cachesize) --- 199,203 ---- pgsize=None, lorder=None): ! flags = _checkflag(flag, file) d = db.DB() if cachesize is not None: d.set_cachesize(0, cachesize) *************** *** 217,221 **** rlen=None, delim=None, source=None, pad=None): ! flags = _checkflag(flag) d = db.DB() if cachesize is not None: d.set_cachesize(0, cachesize) --- 217,221 ---- rlen=None, delim=None, source=None, pad=None): ! flags = _checkflag(flag, file) d = db.DB() if cachesize is not None: d.set_cachesize(0, cachesize) *************** *** 233,237 **** ! def _checkflag(flag): if flag == 'r': flags = db.DB_RDONLY --- 233,237 ---- ! def _checkflag(flag, file): if flag == 'r': flags = db.DB_RDONLY *************** *** 243,247 **** flags = db.DB_CREATE elif flag == 'n': ! flags = db.DB_CREATE | db.DB_TRUNCATE else: raise error, "flags should be one of 'r', 'w', 'c' or 'n'" --- 243,252 ---- flags = db.DB_CREATE elif flag == 'n': ! flags = db.DB_CREATE ! #flags = db.DB_CREATE | db.DB_TRUNCATE ! # we used db.DB_TRUNCATE flag for this before but BerkeleyDB ! # 4.2.52 changed to disallowed truncate with txn environments. ! if os.path.isfile(file): ! os.unlink(file) else: raise error, "flags should be one of 'r', 'w', 'c' or 'n'" From bcannon at users.sourceforge.net Wed Jul 14 02:43:54 2004 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Wed Jul 14 02:43:58 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_strptime.py, 1.25, 1.26 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32411/Lib/test Modified Files: test_strptime.py Log Message: It helps when doing checks if something is in a tuple of strings that if you put everything in the tuple in caps to use str.upper() instead of str.lower(). Index: test_strptime.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_strptime.py,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** test_strptime.py 12 Jul 2004 19:34:02 -0000 1.25 --- test_strptime.py 14 Jul 2004 00:43:51 -0000 1.26 *************** *** 281,285 **** return #MacOS9 has severely broken timezone support. tz_name = time.tzname[0] ! if tz_name.lower() in ("UTC", "GMT"): return try: --- 281,285 ---- return #MacOS9 has severely broken timezone support. tz_name = time.tzname[0] ! if tz_name.upper() in ("UTC", "GMT"): return try: From gvanrossum at users.sourceforge.net Wed Jul 14 02:46:05 2004 From: gvanrossum at users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Wed Jul 14 02:46:08 2004 Subject: [Python-checkins] python/dist/src/Lib shutil.py,1.29,1.30 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv322 Modified Files: shutil.py Log Message: - Bug #981530: Fix UnboundLocalError in shutil.rmtree(). This affects the documented behavior: the function passed to the onerror() handler can now also be os.listdir. [I could've sworn I checked this in, but apparently I didn't, or it got lost???] Index: shutil.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/shutil.py,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** shutil.py 19 Jun 2004 21:11:34 -0000 1.29 --- shutil.py 14 Jul 2004 00:45:59 -0000 1.30 *************** *** 129,132 **** --- 129,133 ---- arg = path try: + func = os.listdir # Make sure it isn't unset _build_cmdtuple(path, cmdtuples) for func, arg in cmdtuples: From gvanrossum at users.sourceforge.net Wed Jul 14 02:46:28 2004 From: gvanrossum at users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Wed Jul 14 02:46:31 2004 Subject: [Python-checkins] python/dist/src/Lib shutil.py, 1.28.10.1, 1.28.10.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv412 Modified Files: Tag: release23-maint shutil.py Log Message: Backport: - Bug #981530: Fix UnboundLocalError in shutil.rmtree(). This affects the documented behavior: the function passed to the onerror() handler can now also be os.listdir. [I could've sworn I checked this in, but apparently I didn't, or it got lost???] Index: shutil.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/shutil.py,v retrieving revision 1.28.10.1 retrieving revision 1.28.10.2 diff -C2 -d -r1.28.10.1 -r1.28.10.2 *** shutil.py 19 Jun 2004 21:39:22 -0000 1.28.10.1 --- shutil.py 14 Jul 2004 00:46:26 -0000 1.28.10.2 *************** *** 129,132 **** --- 129,133 ---- arg = path try: + func = os.listdir # Make sure it isn't unset _build_cmdtuple(path, cmdtuples) for func, arg in cmdtuples: From gvanrossum at users.sourceforge.net Wed Jul 14 02:48:05 2004 From: gvanrossum at users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Wed Jul 14 02:48:08 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_shutil.py, 1.2.8.1, 1.2.8.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv625 Modified Files: Tag: release23-maint test_shutil.py Log Message: Backport: - Bug #981530: Fix UnboundLocalError in shutil.rmtree(). This affects the documented behavior: the function passed to the onerror() handler can now also be os.listdir. [I could've sworn I checked this in, but apparently I didn't, or it got lost???] Index: test_shutil.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_shutil.py,v retrieving revision 1.2.8.1 retrieving revision 1.2.8.2 diff -C2 -d -r1.2.8.1 -r1.2.8.2 *** test_shutil.py 19 Jun 2004 21:39:23 -0000 1.2.8.1 --- test_shutil.py 14 Jul 2004 00:48:02 -0000 1.2.8.2 *************** *** 14,17 **** --- 14,18 ---- self.assertRaises(OSError, shutil.rmtree, filename) self.assertEqual(shutil.rmtree(filename, True), None) + shutil.rmtree(filename, False, lambda func, arg, exc: None) def test_dont_move_dir_in_itself(self): From gvanrossum at users.sourceforge.net Wed Jul 14 02:48:34 2004 From: gvanrossum at users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Wed Jul 14 02:48:37 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_shutil.py,1.3,1.4 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv688 Modified Files: test_shutil.py Log Message: - Bug #981530: Fix UnboundLocalError in shutil.rmtree(). This affects the documented behavior: the function passed to the onerror() handler can now also be os.listdir. [I could've sworn I checked this in, but apparently I didn't, or it got lost???] Index: test_shutil.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_shutil.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** test_shutil.py 19 Jun 2004 21:11:35 -0000 1.3 --- test_shutil.py 14 Jul 2004 00:48:32 -0000 1.4 *************** *** 14,17 **** --- 14,18 ---- self.assertRaises(OSError, shutil.rmtree, filename) self.assertEqual(shutil.rmtree(filename, True), None) + shutil.rmtree(filename, False, lambda func, arg, exc: None) def test_dont_move_dir_in_itself(self): From gvanrossum at users.sourceforge.net Wed Jul 14 02:49:00 2004 From: gvanrossum at users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Wed Jul 14 02:49:02 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libshutil.tex,1.14,1.15 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv725 Modified Files: libshutil.tex Log Message: - Bug #981530: Fix UnboundLocalError in shutil.rmtree(). This affects the documented behavior: the function passed to the onerror() handler can now also be os.listdir. [I could've sworn I checked this in, but apparently I didn't, or it got lost???] Index: libshutil.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libshutil.tex,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** libshutil.tex 5 May 2004 17:21:51 -0000 1.14 --- libshutil.tex 14 Jul 2004 00:48:58 -0000 1.15 *************** *** 91,95 **** three parameters: \var{function}, \var{path}, and \var{excinfo}. The first parameter, \var{function}, is the function which raised ! the exception; it will be \function{os.remove()} or \function{os.rmdir()}. The second parameter, \var{path}, will be the path name passed to \var{function}. The third parameter, --- 91,95 ---- three parameters: \var{function}, \var{path}, and \var{excinfo}. The first parameter, \var{function}, is the function which raised ! the exception; it will be \function{os.listdir()}, \function{os.remove()} or \function{os.rmdir()}. The second parameter, \var{path}, will be the path name passed to \var{function}. The third parameter, From gvanrossum at users.sourceforge.net Wed Jul 14 02:49:23 2004 From: gvanrossum at users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Wed Jul 14 02:49:25 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libshutil.tex, 1.13, 1.13.12.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv796 Modified Files: Tag: release23-maint libshutil.tex Log Message: Backport: - Bug #981530: Fix UnboundLocalError in shutil.rmtree(). This affects the documented behavior: the function passed to the onerror() handler can now also be os.listdir. [I could've sworn I checked this in, but apparently I didn't, or it got lost???] Index: libshutil.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libshutil.tex,v retrieving revision 1.13 retrieving revision 1.13.12.1 diff -C2 -d -r1.13 -r1.13.12.1 *** libshutil.tex 23 Feb 2003 21:36:47 -0000 1.13 --- libshutil.tex 14 Jul 2004 00:49:20 -0000 1.13.12.1 *************** *** 89,93 **** three parameters: \var{function}, \var{path}, and \var{excinfo}. The first parameter, \var{function}, is the function which raised ! the exception; it will be \function{os.remove()} or \function{os.rmdir()}. The second parameter, \var{path}, will be the path name passed to \var{function}. The third parameter, --- 89,93 ---- three parameters: \var{function}, \var{path}, and \var{excinfo}. The first parameter, \var{function}, is the function which raised ! the exception; it will be \function{os.listdir()}, \function{os.remove()} or \function{os.rmdir()}. The second parameter, \var{path}, will be the path name passed to \var{function}. The third parameter, From debian-knoppix-admin at linuxtag.org Wed Jul 14 10:19:01 2004 From: debian-knoppix-admin at linuxtag.org (debian-knoppix-admin@linuxtag.org) Date: Wed Jul 14 10:19:03 2004 Subject: [Python-checkins] Your message to debian-knoppix awaits moderator approval Message-ID: <20040714081901.20928.43892.Mailman@hydra.linuxtag.uni-kl.de> Your mail to 'debian-knoppix' with the subject Hi Is being held until the list moderator can review it for approval. The reason it is being held: Post by non-member to a members-only list Either the message will get posted to the list, or you will receive notification of the moderator's decision. From mwh at users.sourceforge.net Wed Jul 14 13:28:08 2004 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Wed Jul 14 13:28:11 2004 Subject: [Python-checkins] python/dist/src/Python modsupport.c,2.70,2.71 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9485 Modified Files: modsupport.c Log Message: This is Pete Shinners' patch from his bug report [ 984722 ] Py_BuildValue loses reference counts on error I'm ever-so-slightly uneasy at the amount of work this can do with an exception pending, but I don't think that this can result in anything more serious than a strange error message. Index: modsupport.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/modsupport.c,v retrieving revision 2.70 retrieving revision 2.71 diff -C2 -d -r2.70 -r2.71 *** modsupport.c 19 Nov 2003 15:24:47 -0000 2.70 --- modsupport.c 14 Jul 2004 11:28:06 -0000 2.71 *************** *** 153,160 **** --- 153,163 ---- PyObject *d; int i; + int itemfailed = 0; if (n < 0) return NULL; if ((d = PyDict_New()) == NULL) return NULL; + /* Note that we can't bail immediately on error as this will leak + refcounts on any 'N' arguments. */ for (i = 0; i < n; i+= 2) { PyObject *k, *v; *************** *** 162,178 **** k = do_mkvalue(p_format, p_va); if (k == NULL) { ! Py_DECREF(d); ! return NULL; } v = do_mkvalue(p_format, p_va); if (v == NULL) { ! Py_DECREF(k); ! Py_DECREF(d); ! return NULL; } err = PyDict_SetItem(d, k, v); Py_DECREF(k); Py_DECREF(v); ! if (err < 0) { Py_DECREF(d); return NULL; --- 165,182 ---- k = do_mkvalue(p_format, p_va); if (k == NULL) { ! itemfailed = 1; ! Py_INCREF(Py_None); ! k = Py_None; } v = do_mkvalue(p_format, p_va); if (v == NULL) { ! itemfailed = 1; ! Py_INCREF(Py_None); ! v = Py_None; } err = PyDict_SetItem(d, k, v); Py_DECREF(k); Py_DECREF(v); ! if (err < 0 || itemfailed) { Py_DECREF(d); return NULL; *************** *** 195,207 **** PyObject *v; int i; if (n < 0) return NULL; if ((v = PyList_New(n)) == NULL) return NULL; for (i = 0; i < n; i++) { PyObject *w = do_mkvalue(p_format, p_va); if (w == NULL) { ! Py_DECREF(v); ! return NULL; } PyList_SetItem(v, i, w); --- 199,215 ---- PyObject *v; int i; + int itemfailed = 0; if (n < 0) return NULL; if ((v = PyList_New(n)) == NULL) return NULL; + /* Note that we can't bail immediately on error as this will leak + refcounts on any 'N' arguments. */ for (i = 0; i < n; i++) { PyObject *w = do_mkvalue(p_format, p_va); if (w == NULL) { ! itemfailed = 1; ! Py_INCREF(Py_None); ! w = Py_None; } PyList_SetItem(v, i, w); *************** *** 215,218 **** --- 223,230 ---- else if (endchar) ++*p_format; + if (itemfailed) { + Py_DECREF(v); + v = NULL; + } return v; } *************** *** 234,246 **** PyObject *v; int i; if (n < 0) return NULL; if ((v = PyTuple_New(n)) == NULL) return NULL; for (i = 0; i < n; i++) { PyObject *w = do_mkvalue(p_format, p_va); if (w == NULL) { ! Py_DECREF(v); ! return NULL; } PyTuple_SetItem(v, i, w); --- 246,262 ---- PyObject *v; int i; + int itemfailed = 0; if (n < 0) return NULL; if ((v = PyTuple_New(n)) == NULL) return NULL; + /* Note that we can't bail immediately on error as this will leak + refcounts on any 'N' arguments. */ for (i = 0; i < n; i++) { PyObject *w = do_mkvalue(p_format, p_va); if (w == NULL) { ! itemfailed = 1; ! Py_INCREF(Py_None); ! w = Py_None; } PyTuple_SetItem(v, i, w); *************** *** 254,257 **** --- 270,277 ---- else if (endchar) ++*p_format; + if (itemfailed) { + Py_DECREF(v); + v = NULL; + } return v; } From theller at users.sourceforge.net Wed Jul 14 16:53:52 2004 From: theller at users.sourceforge.net (theller@users.sourceforge.net) Date: Wed Jul 14 16:53:55 2004 Subject: [Python-checkins] python/dist/src/PC/bdist_wininst install.c, 1.7, 1.8 Message-ID: Update of /cvsroot/python/python/dist/src/PC/bdist_wininst In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14647 Modified Files: install.c Log Message: Don't complain that non-existant registry entries cannot be deleted. Index: install.c =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/bdist_wininst/install.c,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** install.c 7 Jul 2004 07:34:40 -0000 1.7 --- install.c 14 Jul 2004 14:53:50 -0000 1.8 *************** *** 2170,2174 **** else { result = RegDeleteKey(hKey, subkeyname); ! if (result != ERROR_SUCCESS) MessageBox(GetFocus(), string, "Could not delete key", MB_OK); RegCloseKey(hKey); --- 2170,2174 ---- else { result = RegDeleteKey(hKey, subkeyname); ! if (result != ERROR_SUCCESS && result != ERROR_FILE_NOT_FOUND) MessageBox(GetFocus(), string, "Could not delete key", MB_OK); RegCloseKey(hKey); *************** *** 2212,2216 **** else { result = RegDeleteValue(hKey, valuename); ! if (result != ERROR_SUCCESS) MessageBox(GetFocus(), string, "Could not delete value", MB_OK); RegCloseKey(hKey); --- 2212,2216 ---- else { result = RegDeleteValue(hKey, valuename); ! if (result != ERROR_SUCCESS && result != ERROR_FILE_NOT_FOUND) MessageBox(GetFocus(), string, "Could not delete value", MB_OK); RegCloseKey(hKey); From theller at users.sourceforge.net Wed Jul 14 16:56:13 2004 From: theller at users.sourceforge.net (theller@users.sourceforge.net) Date: Wed Jul 14 16:56:17 2004 Subject: [Python-checkins] python/dist/src/PC/bdist_wininst install.c, 1.1.14.2, 1.1.14.3 Message-ID: Update of /cvsroot/python/python/dist/src/PC/bdist_wininst In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15066 Modified Files: Tag: release23-maint install.c Log Message: Don't complain that non-existant registry entries cannot be deleted. Backported from trunk. Index: install.c =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/bdist_wininst/install.c,v retrieving revision 1.1.14.2 retrieving revision 1.1.14.3 diff -C2 -d -r1.1.14.2 -r1.1.14.3 *** install.c 2 Jul 2004 07:54:30 -0000 1.1.14.2 --- install.c 14 Jul 2004 14:56:11 -0000 1.1.14.3 *************** *** 1983,1987 **** else { result = RegDeleteKey(hKey, subkeyname); ! if (result != ERROR_SUCCESS) MessageBox(GetFocus(), string, "Could not delete key", MB_OK); RegCloseKey(hKey); --- 1983,1987 ---- else { result = RegDeleteKey(hKey, subkeyname); ! if (result != ERROR_SUCCESS && result != ERROR_FILE_NOT_FOUND) MessageBox(GetFocus(), string, "Could not delete key", MB_OK); RegCloseKey(hKey); *************** *** 2025,2029 **** else { result = RegDeleteValue(hKey, valuename); ! if (result != ERROR_SUCCESS) MessageBox(GetFocus(), string, "Could not delete value", MB_OK); RegCloseKey(hKey); --- 2025,2029 ---- else { result = RegDeleteValue(hKey, valuename); ! if (result != ERROR_SUCCESS && result != ERROR_FILE_NOT_FOUND) MessageBox(GetFocus(), string, "Could not delete value", MB_OK); RegCloseKey(hKey); From theller at users.sourceforge.net Wed Jul 14 17:02:09 2004 From: theller at users.sourceforge.net (theller@users.sourceforge.net) Date: Wed Jul 14 17:02:13 2004 Subject: [Python-checkins] python/dist/src/PC/bdist_wininst resource.h, 1.1, 1.1.14.1 install.rc, 1.1, 1.1.14.1 install.c, 1.1.14.3, 1.1.14.4 extract.c, 1.1, 1.1.14.1 archive.h, 1.1, 1.1.14.1 Message-ID: Update of /cvsroot/python/python/dist/src/PC/bdist_wininst In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16243 Modified Files: Tag: release23-maint resource.h install.rc install.c extract.c archive.h Log Message: Add a warning so that it isn't forgotten to recreate the binary AND CHECK INTO CVS if these files are changed. Index: resource.h =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/bdist_wininst/resource.h,v retrieving revision 1.1 retrieving revision 1.1.14.1 diff -C2 -d -r1.1 -r1.1.14.1 *** resource.h 22 Nov 2002 20:39:33 -0000 1.1 --- resource.h 14 Jul 2004 15:02:07 -0000 1.1.14.1 *************** *** 1,2 **** --- 1,10 ---- + /* + IMPORTANT NOTE: IF THIS FILE IS CHANGED, WININST.EXE MUST BE RECOMPILED WITH + THE MSVC6 WININST.DSW WORKSPACE FILE MANUALLY. + + IF CHANGES TO THIS FILE ARE CHECKED INTO PYTHON CVS, THE RECOMPILED BINARY + MUST BE CHECKED IN AS WELL! + */ + //{{NO_DEPENDENCIES}} // Microsoft Developer Studio generated include file. Index: install.rc =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/bdist_wininst/install.rc,v retrieving revision 1.1 retrieving revision 1.1.14.1 diff -C2 -d -r1.1 -r1.1.14.1 *** install.rc 22 Nov 2002 20:39:33 -0000 1.1 --- install.rc 14 Jul 2004 15:02:07 -0000 1.1.14.1 *************** *** 1,2 **** --- 1,10 ---- + /* + IMPORTANT NOTE: IF THIS FILE IS CHANGED, WININST.EXE MUST BE RECOMPILED WITH + THE MSVC6 WININST.DSW WORKSPACE FILE MANUALLY. + + IF CHANGES TO THIS FILE ARE CHECKED INTO PYTHON CVS, THE RECOMPILED BINARY + MUST BE CHECKED IN AS WELL! + */ + //Microsoft Developer Studio generated resource script. // Index: install.c =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/bdist_wininst/install.c,v retrieving revision 1.1.14.3 retrieving revision 1.1.14.4 diff -C2 -d -r1.1.14.3 -r1.1.14.4 *** install.c 14 Jul 2004 14:56:11 -0000 1.1.14.3 --- install.c 14 Jul 2004 15:02:07 -0000 1.1.14.4 *************** *** 1,3 **** --- 1,11 ---- /* + IMPORTANT NOTE: IF THIS FILE IS CHANGED, WININST.EXE MUST BE RECOMPILED WITH + THE MSVC6 WININST.DSW WORKSPACE FILE MANUALLY. + + IF CHANGES TO THIS FILE ARE CHECKED INTO PYTHON CVS, THE RECOMPILED BINARY + MUST BE CHECKED IN AS WELL! + */ + + /* * Written by Thomas Heller, May 2000 * Index: extract.c =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/bdist_wininst/extract.c,v retrieving revision 1.1 retrieving revision 1.1.14.1 diff -C2 -d -r1.1 -r1.1.14.1 *** extract.c 22 Nov 2002 20:39:33 -0000 1.1 --- extract.c 14 Jul 2004 15:02:07 -0000 1.1.14.1 *************** *** 1,2 **** --- 1,10 ---- + /* + IMPORTANT NOTE: IF THIS FILE IS CHANGED, WININST.EXE MUST BE RECOMPILED WITH + THE MSVC6 WININST.DSW WORKSPACE FILE MANUALLY. + + IF CHANGES TO THIS FILE ARE CHECKED INTO PYTHON CVS, THE RECOMPILED BINARY + MUST BE CHECKED IN AS WELL! + */ + #include Index: archive.h =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/bdist_wininst/archive.h,v retrieving revision 1.1 retrieving revision 1.1.14.1 diff -C2 -d -r1.1 -r1.1.14.1 *** archive.h 22 Nov 2002 20:39:33 -0000 1.1 --- archive.h 14 Jul 2004 15:02:07 -0000 1.1.14.1 *************** *** 1,2 **** --- 1,10 ---- + /* + IMPORTANT NOTE: IF THIS FILE IS CHANGED, WININST.EXE MUST BE RECOMPILED WITH + THE MSVC6 WININST.DSW WORKSPACE FILE MANUALLY. + + IF CHANGES TO THIS FILE ARE CHECKED INTO PYTHON CVS, THE RECOMPILED BINARY + MUST BE CHECKED IN AS WELL! + */ + #pragma pack(1) From theller at users.sourceforge.net Wed Jul 14 17:03:48 2004 From: theller at users.sourceforge.net (theller@users.sourceforge.net) Date: Wed Jul 14 17:03:50 2004 Subject: [Python-checkins] python/dist/src/PC/bdist_wininst install.c, 1.1.14.4, 1.1.14.5 Message-ID: Update of /cvsroot/python/python/dist/src/PC/bdist_wininst In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16501 Modified Files: Tag: release23-maint install.c Log Message: Remove the annoing and useless messagebox asking about overwriting files. Fixes SF #984290. Backport from trunk. Index: install.c =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/bdist_wininst/install.c,v retrieving revision 1.1.14.4 retrieving revision 1.1.14.5 diff -C2 -d -r1.1.14.4 -r1.1.14.5 *** install.c 14 Jul 2004 15:02:07 -0000 1.1.14.4 --- install.c 14 Jul 2004 15:03:45 -0000 1.1.14.5 *************** *** 149,154 **** /* lParam: points to pathname */ - enum { UNSPECIFIED, ALWAYS, NEVER } allow_overwrite = UNSPECIFIED; - static BOOL notify(int code, char *fmt, ...); --- 149,152 ---- *************** *** 685,710 **** } - static BOOL AskOverwrite(char *filename) - { - int result; - again: - if (allow_overwrite == ALWAYS) - return TRUE; - if (allow_overwrite == NEVER) - return FALSE; - result = MessageBox(hDialog, - "Overwrite existing files?\n" - "\n" - "Press YES to ALWAYS overwrite existing files,\n" - "press NO to NEVER overwrite existing files.", - "Overwrite options", - MB_YESNO | MB_ICONQUESTION); - if (result == IDYES) - allow_overwrite = ALWAYS; - else if (result == IDNO) - allow_overwrite = NEVER; - goto again; - } - static BOOL notify (int code, char *fmt, ...) { --- 683,686 ---- *************** *** 721,725 **** /* Questions */ case CAN_OVERWRITE: - result = AskOverwrite(Buffer); break; --- 697,700 ---- From theller at users.sourceforge.net Wed Jul 14 17:11:08 2004 From: theller at users.sourceforge.net (theller@users.sourceforge.net) Date: Wed Jul 14 17:11:10 2004 Subject: [Python-checkins] python/dist/src/Lib/distutils/command wininst.exe, 1.1.16.3, 1.1.16.4 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils/command In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17643 Modified Files: Tag: release23-maint wininst.exe Log Message: Recompiled after recent source changes. Index: wininst.exe =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/Attic/wininst.exe,v retrieving revision 1.1.16.3 retrieving revision 1.1.16.4 diff -C2 -d -r1.1.16.3 -r1.1.16.4 Binary files /tmp/cvs2LsNCR and /tmp/cvsB3lVwp differ From theller at users.sourceforge.net Wed Jul 14 17:17:07 2004 From: theller at users.sourceforge.net (theller@users.sourceforge.net) Date: Wed Jul 14 17:17:10 2004 Subject: [Python-checkins] python/dist/src/PC/bdist_wininst resource.h, 1.1, 1.2 install.rc, 1.1, 1.2 install.c, 1.8, 1.9 extract.c, 1.1, 1.2 archive.h, 1.1, 1.2 Message-ID: Update of /cvsroot/python/python/dist/src/PC/bdist_wininst In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18777 Modified Files: resource.h install.rc install.c extract.c archive.h Log Message: Add a warning so that it isn't forgotten to recreate the binaries AND CHECK INTO CVS if these files are changed. Index: resource.h =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/bdist_wininst/resource.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** resource.h 22 Nov 2002 20:39:33 -0000 1.1 --- resource.h 14 Jul 2004 15:17:04 -0000 1.2 *************** *** 1,2 **** --- 1,11 ---- + /* + IMPORTANT NOTE: IF THIS FILE IS CHANGED, WININST-6.EXE MUST BE RECOMPILED + WITH THE MSVC6 WININST.DSW WORKSPACE FILE MANUALLY, AND WININST-7.1.EXE MUST + BE RECOMPILED WITH THE MSVC 2003.NET WININST-7.1.VCPROJ FILE MANUALLY. + + IF CHANGES TO THIS FILE ARE CHECKED INTO PYTHON CVS, THE RECOMPILED BINARIES + MUST BE CHECKED IN AS WELL! + */ + //{{NO_DEPENDENCIES}} // Microsoft Developer Studio generated include file. Index: install.rc =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/bdist_wininst/install.rc,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** install.rc 22 Nov 2002 20:39:33 -0000 1.1 --- install.rc 14 Jul 2004 15:17:04 -0000 1.2 *************** *** 1,2 **** --- 1,11 ---- + /* + IMPORTANT NOTE: IF THIS FILE IS CHANGED, WININST-6.EXE MUST BE RECOMPILED + WITH THE MSVC6 WININST.DSW WORKSPACE FILE MANUALLY, AND WININST-7.1.EXE MUST + BE RECOMPILED WITH THE MSVC 2003.NET WININST-7.1.VCPROJ FILE MANUALLY. + + IF CHANGES TO THIS FILE ARE CHECKED INTO PYTHON CVS, THE RECOMPILED BINARIES + MUST BE CHECKED IN AS WELL! + */ + //Microsoft Developer Studio generated resource script. // Index: install.c =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/bdist_wininst/install.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** install.c 14 Jul 2004 14:53:50 -0000 1.8 --- install.c 14 Jul 2004 15:17:04 -0000 1.9 *************** *** 1,3 **** --- 1,12 ---- /* + IMPORTANT NOTE: IF THIS FILE IS CHANGED, WININST-6.EXE MUST BE RECOMPILED + WITH THE MSVC6 WININST.DSW WORKSPACE FILE MANUALLY, AND WININST-7.1.EXE MUST + BE RECOMPILED WITH THE MSVC 2003.NET WININST-7.1.VCPROJ FILE MANUALLY. + + IF CHANGES TO THIS FILE ARE CHECKED INTO PYTHON CVS, THE RECOMPILED BINARIES + MUST BE CHECKED IN AS WELL! + */ + + /* * Written by Thomas Heller, May 2000 * Index: extract.c =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/bdist_wininst/extract.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** extract.c 22 Nov 2002 20:39:33 -0000 1.1 --- extract.c 14 Jul 2004 15:17:04 -0000 1.2 *************** *** 1,2 **** --- 1,11 ---- + /* + IMPORTANT NOTE: IF THIS FILE IS CHANGED, WININST-6.EXE MUST BE RECOMPILED + WITH THE MSVC6 WININST.DSW WORKSPACE FILE MANUALLY, AND WININST-7.1.EXE MUST + BE RECOMPILED WITH THE MSVC 2003.NET WININST-7.1.VCPROJ FILE MANUALLY. + + IF CHANGES TO THIS FILE ARE CHECKED INTO PYTHON CVS, THE RECOMPILED BINARIES + MUST BE CHECKED IN AS WELL! + */ + #include Index: archive.h =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/bdist_wininst/archive.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** archive.h 22 Nov 2002 20:39:33 -0000 1.1 --- archive.h 14 Jul 2004 15:17:04 -0000 1.2 *************** *** 1,2 **** --- 1,11 ---- + /* + IMPORTANT NOTE: IF THIS FILE IS CHANGED, WININST-6.EXE MUST BE RECOMPILED + WITH THE MSVC6 WININST.DSW WORKSPACE FILE MANUALLY, AND WININST-7.1.EXE MUST + BE RECOMPILED WITH THE MSVC 2003.NET WININST-7.1.VCPROJ FILE MANUALLY. + + IF CHANGES TO THIS FILE ARE CHECKED INTO PYTHON CVS, THE RECOMPILED BINARIES + MUST BE CHECKED IN AS WELL! + */ + #pragma pack(1) From theller at users.sourceforge.net Wed Jul 14 17:19:47 2004 From: theller at users.sourceforge.net (theller@users.sourceforge.net) Date: Wed Jul 14 17:19:51 2004 Subject: [Python-checkins] python/dist/src/PC/bdist_wininst .cvsignore, 1.1, 1.2 Message-ID: Update of /cvsroot/python/python/dist/src/PC/bdist_wininst In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19262 Modified Files: .cvsignore Log Message: Ignore some more build products. Index: .cvsignore =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/bdist_wininst/.cvsignore,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** .cvsignore 22 Nov 2002 20:39:33 -0000 1.1 --- .cvsignore 14 Jul 2004 15:19:45 -0000 1.2 *************** *** 1,4 **** --- 1,8 ---- temp-debug temp-release + wininst-7.1.ncb + wininst-7.1.suo wininst.ncb + wininst.opt + wininst.pdb wininst.plg From theller at users.sourceforge.net Wed Jul 14 17:20:25 2004 From: theller at users.sourceforge.net (theller@users.sourceforge.net) Date: Wed Jul 14 17:20:27 2004 Subject: [Python-checkins] python/dist/src/PC/bdist_wininst .cvsignore, 1.1, 1.1.14.1 Message-ID: Update of /cvsroot/python/python/dist/src/PC/bdist_wininst In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19415 Modified Files: Tag: release23-maint .cvsignore Log Message: Ignore some more build products. Index: .cvsignore =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/bdist_wininst/.cvsignore,v retrieving revision 1.1 retrieving revision 1.1.14.1 diff -C2 -d -r1.1 -r1.1.14.1 *** .cvsignore 22 Nov 2002 20:39:33 -0000 1.1 --- .cvsignore 14 Jul 2004 15:20:23 -0000 1.1.14.1 *************** *** 2,4 **** --- 2,5 ---- temp-release wininst.ncb + wininst.opt wininst.plg From theller at users.sourceforge.net Wed Jul 14 17:22:07 2004 From: theller at users.sourceforge.net (theller@users.sourceforge.net) Date: Wed Jul 14 17:22:08 2004 Subject: [Python-checkins] python/dist/src/Lib/distutils/command wininst-7.1.exe, 1.3, 1.4 wininst-6.exe, 1.3, 1.4 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils/command In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19674 Modified Files: wininst-7.1.exe wininst-6.exe Log Message: Recompiled after source file changes. Index: wininst-7.1.exe =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/wininst-7.1.exe,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 Binary files /tmp/cvsDe1X2a and /tmp/cvsb3mE2O differ Index: wininst-6.exe =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/wininst-6.exe,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 Binary files /tmp/cvs2qruKb and /tmp/cvsGSw5LP differ From rhettinger at users.sourceforge.net Wed Jul 14 17:41:59 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Wed Jul 14 17:42:02 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_decimal.py,1.8,1.9 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23358/test Modified Files: test_decimal.py Log Message: * Rename "Signals" to "_signals" making it non-public. * Context.create_decimal can take a zero default just like Decimal(). * Fix typo in comment. Index: test_decimal.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_decimal.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** test_decimal.py 10 Jul 2004 14:14:37 -0000 1.8 --- test_decimal.py 14 Jul 2004 15:41:57 -0000 1.9 *************** *** 36,39 **** --- 36,42 ---- import random + # Useful Test Constant + Signals = getcontext().flags.keys() + # Tests are built around these assumed context defaults DefaultContext.prec=9 *************** *** 481,485 **** # empty ! self.assertRaises(TypeError, nc.create_decimal) # from None --- 484,491 ---- # empty ! d = Decimal() ! self.assertEqual(str(d), '0') ! d = nc.create_decimal() ! self.assertEqual(str(d), '0') # from None From rhettinger at users.sourceforge.net Wed Jul 14 17:41:59 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Wed Jul 14 17:42:03 2004 Subject: [Python-checkins] python/dist/src/Lib decimal.py,1.15,1.16 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23358 Modified Files: decimal.py Log Message: * Rename "Signals" to "_signals" making it non-public. * Context.create_decimal can take a zero default just like Decimal(). * Fix typo in comment. Index: decimal.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/decimal.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** decimal.py 10 Jul 2004 14:14:37 -0000 1.15 --- decimal.py 14 Jul 2004 15:41:56 -0000 1.16 *************** *** 121,125 **** 'ROUND_DOWN', 'ROUND_HALF_UP', 'ROUND_HALF_EVEN', 'ROUND_CEILING', 'ROUND_FLOOR', 'ROUND_UP', 'ROUND_HALF_DOWN', - 'Signals', # <-- Used for building trap/flag dictionaries # Functions for manipulating contexts --- 121,124 ---- *************** *** 369,373 **** # List of public traps and flags ! Signals = [Clamped, DivisionByZero, Inexact, Overflow, Rounded, Underflow, InvalidOperation, Subnormal] --- 368,372 ---- # List of public traps and flags ! _signals = [Clamped, DivisionByZero, Inexact, Overflow, Rounded, Underflow, InvalidOperation, Subnormal] *************** *** 2121,2127 **** _ignored_flags=[]): if not isinstance(flags, dict): ! flags = dict([(s,s in flags) for s in Signals]) if traps is not None and not isinstance(traps, dict): ! traps = dict([(s,s in traps) for s in Signals]) for name, val in locals().items(): if val is None: --- 2120,2126 ---- _ignored_flags=[]): if not isinstance(flags, dict): ! flags = dict([(s,s in flags) for s in _signals]) if traps is not None and not isinstance(traps, dict): ! traps = dict([(s,s in traps) for s in _signals]) for name, val in locals().items(): if val is None: *************** *** 2176,2180 **** def _ignore_all_flags(self): """Ignore all flags, if they are raised""" ! return self._ignore_flags(*Signals) def _ignore_flags(self, *flags): --- 2175,2179 ---- def _ignore_all_flags(self): """Ignore all flags, if they are raised""" ! return self._ignore_flags(*_signals) def _ignore_flags(self, *flags): *************** *** 2245,2249 **** return rounding ! def create_decimal(self, num): """Creates a new Decimal instance but using self as context.""" d = Decimal(num, context=self) --- 2244,2248 ---- return rounding ! def create_decimal(self, num='0'): """Creates a new Decimal instance but using self as context.""" d = Decimal(num, context=self) *************** *** 2951,2955 **** # The default context prototype used by Context() ! # Is mutable, so than new contexts can have different default values DefaultContext = Context( --- 2950,2954 ---- # The default context prototype used by Context() ! # Is mutable, so that new contexts can have different default values DefaultContext = Context( From rhettinger at users.sourceforge.net Wed Jul 14 18:35:32 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Wed Jul 14 18:35:35 2004 Subject: [Python-checkins] python/dist/src/Lib decimal.py,1.16,1.17 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2022 Modified Files: decimal.py Log Message: * Hide a loop induction variable that was inadvertantly being picked up by the locals() call in the context constructor. * Remove unnecessary properties for int, exp, and sign which duplicated information returned by as_tuple(). Index: decimal.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/decimal.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** decimal.py 14 Jul 2004 15:41:56 -0000 1.16 --- decimal.py 14 Jul 2004 16:35:29 -0000 1.17 *************** *** 2055,2069 **** return 0 - #properties to immutability-near feature - def _get_sign(self): - return self._sign - def _get_int(self): - return self._int - def _get_exp(self): - return self._exp - sign = property(_get_sign) - int = property(_get_int) - exp = property(_get_exp) - # support for pickling, copy, and deepcopy def __reduce__(self): --- 2055,2058 ---- *************** *** 2121,2126 **** --- 2110,2117 ---- if not isinstance(flags, dict): flags = dict([(s,s in flags) for s in _signals]) + del s if traps is not None and not isinstance(traps, dict): traps = dict([(s,s in traps) for s in _signals]) + del s for name, val in locals().items(): if val is None: From rhettinger at users.sourceforge.net Wed Jul 14 18:35:32 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Wed Jul 14 18:35:36 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_decimal.py, 1.9, 1.10 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2022/test Modified Files: test_decimal.py Log Message: * Hide a loop induction variable that was inadvertantly being picked up by the locals() call in the context constructor. * Remove unnecessary properties for int, exp, and sign which duplicated information returned by as_tuple(). Index: test_decimal.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_decimal.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** test_decimal.py 14 Jul 2004 15:41:57 -0000 1.9 --- test_decimal.py 14 Jul 2004 16:35:30 -0000 1.10 *************** *** 955,986 **** self.assertEqual(d.as_tuple(), (0, (0,), 'F') ) - def test_immutability_onpurpose(self): - #Try to change internal objects and see if immutable. - - d = Decimal(42) - - #you can get the attributes... - d.exp - d.int - d.sign - - #...but not change them! - try: - d.exp = 20 - d.int = 3 - d.sign = 1 - except AttributeError: - pass - else: - self.fail('Did not raised an error!') - - #some new attribute - try: - d.newone = None - except AttributeError: - pass - else: - self.fail('Did not raised an error!') - def test_immutability_operations(self): # Do operations and check that it didn't change change internal objects. --- 955,958 ---- From dcjim at users.sourceforge.net Wed Jul 14 21:06:52 2004 From: dcjim at users.sourceforge.net (dcjim@users.sourceforge.net) Date: Wed Jul 14 21:06:57 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py,1.35,1.36 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15309/Lib Modified Files: doctest.py Log Message: Ported some features from zope: - Fixed the display of tests in verbose output - Allow setUp and tearDown functions to be provided for DocTestSuites. Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** doctest.py 7 Jul 2004 20:54:45 -0000 1.35 --- doctest.py 14 Jul 2004 19:06:50 -0000 1.36 *************** *** 290,294 **** 'is_private', 'Tester', - 'DocTestTestFailure', 'DocTestSuite', 'testsource', --- 290,293 ---- *************** *** 1290,1353 **** return tests ! # unittest helpers. ! # A function passed to unittest, for unittest to drive. ! # tester is doctest Tester instance. doc is the docstring whose ! # doctests are to be run. ! def _utest(tester, name, doc, filename, lineno): ! import sys ! from StringIO import StringIO ! old = sys.stdout ! sys.stdout = new = StringIO() ! try: ! failures, tries = tester.runstring(doc, name) ! finally: ! sys.stdout = old ! if failures: ! msg = new.getvalue() ! lname = '.'.join(name.split('.')[-1:]) ! if not lineno: ! lineno = "0 (don't know line number)" ! # Don't change this format! It was designed so that Emacs can ! # parse it naturally. ! raise DocTestTestFailure('Failed doctest test for %s\n' ! ' File "%s", line %s, in %s\n\n%s' % ! (name, filename, lineno, lname, msg)) ! class DocTestTestFailure(Exception): ! """A doctest test failed""" ! def DocTestSuite(module=None): ! """Convert doctest tests for a module to a unittest TestSuite. ! The returned TestSuite is to be run by the unittest framework, and ! runs each doctest in the module. If any of the doctests fail, ! then the synthesized unit test fails, and an error is raised showing ! the name of the file containing the test and a (sometimes approximate) ! line number. ! The optional module argument provides the module to be tested. It ! can be a module object or a (possibly dotted) module name. If not ! specified, the module calling DocTestSuite() is used. ! Example (although note that unittest supplies many ways to use the ! TestSuite returned; see the unittest docs): ! import unittest ! import doctest ! import my_module_with_doctests ! suite = doctest.DocTestSuite(my_module_with_doctests) ! runner = unittest.TextTestRunner() ! runner.run(suite) ! """ ! import unittest - module = _normalize_module(module) - tests = _find_tests(module) if not tests: raise ValueError(module, "has no tests") --- 1289,1378 ---- return tests ! ############################################################################### ! # unitest support ! from StringIO import StringIO ! import os ! import sys ! import tempfile ! import unittest ! class DocTestTestCase(unittest.TestCase): ! """A test case that wraps a test function. ! This is useful for slipping pre-existing test functions into the ! PyUnit framework. Optionally, set-up and tidy-up functions can be ! supplied. As with TestCase, the tidy-up ('tearDown') function will ! always be called if the set-up ('setUp') function ran successfully. ! """ ! def __init__(self, tester, name, doc, filename, lineno, ! setUp=None, tearDown=None): ! unittest.TestCase.__init__(self) ! (self.__tester, self.__name, self.__doc, ! self.__filename, self.__lineno, ! self.__setUp, self.__tearDown ! ) = tester, name, doc, filename, lineno, setUp, tearDown ! def setUp(self): ! if self.__setUp is not None: ! self.__setUp() ! def tearDown(self): ! if self.__tearDown is not None: ! self.__tearDown() ! def runTest(self): ! old = sys.stdout ! new = StringIO() ! try: ! sys.stdout = new ! failures, tries = self.__tester.runstring(self.__doc, self.__name) ! finally: ! sys.stdout = old ! if failures: ! lname = '.'.join(self.__name.split('.')[-1:]) ! lineno = self.__lineno or "0 (don't know line no)" ! raise self.failureException( ! 'Failed doctest test for %s\n' ! ' File "%s", line %s, in %s\n\n%s' ! % (self.__name, self.__filename, lineno, lname, new.getvalue()) ! ) ! def id(self): ! return self.__name ! def __repr__(self): ! name = self.__name.split('.') ! return "%s (%s)" % (name[-1], '.'.join(name[:-1])) ! __str__ = __repr__ ! def shortDescription(self): ! return "Doctest: " + self.__name ! ! ! def DocTestSuite(module=None, ! setUp=lambda: None, ! tearDown=lambda: None, ! ): ! """Convert doctest tests for a mudule to a unittest test suite ! ! This tests convers each documentation string in a module that ! contains doctest tests to a unittest test case. If any of the ! tests in a doc string fail, then the test case fails. An error is ! raised showing the name of the file containing the test and a ! (sometimes approximate) line number. ! ! A module argument provides the module to be tested. The argument ! can be either a module or a module name. ! ! If no argument is given, the calling module is used. ! ! """ ! module = _normalizeModule(module) ! tests = _findTests(module) if not tests: raise ValueError(module, "has no tests") *************** *** 1363,1378 **** elif filename.endswith(".pyo"): filename = filename[:-1] ! def runit(name=name, doc=doc, filename=filename, lineno=lineno): ! _utest(tester, name, doc, filename, lineno) ! suite.addTest(unittest.FunctionTestCase( ! runit, ! description="doctest of " + name)) return suite ! # Debugging support. def _expect(expect): ! # Return the expected output (if any), formatted as a Python ! # comment block. if expect: expect = "\n# ".join(expect.split("\n")) --- 1388,1472 ---- elif filename.endswith(".pyo"): filename = filename[:-1] ! ! suite.addTest(DocTestTestCase( ! tester, name, doc, filename, lineno, ! setUp, tearDown)) ! return suite ! def _normalizeModule(module): ! # Normalize a module ! if module is None: ! # Test the calling module ! module = sys._getframe(2).f_globals['__name__'] ! module = sys.modules[module] ! ! elif isinstance(module, (str, unicode)): ! module = __import__(module, globals(), locals(), ["*"]) ! ! return module ! ! def _doc(name, object, tests, prefix, filename='', lineno=''): ! doc = getattr(object, '__doc__', '') ! if doc and doc.find('>>>') >= 0: ! tests.append((prefix+name, doc, filename, lineno)) ! ! ! def _findTests(module, prefix=None): ! if prefix is None: ! prefix = module.__name__ ! dict = module.__dict__ ! tests = [] ! _doc(prefix, module, tests, '', ! lineno="1 (or below)") ! prefix = prefix and (prefix + ".") ! _find(dict.items(), module, dict, tests, prefix) ! return tests ! ! def _find(items, module, dict, tests, prefix, minlineno=0): ! for name, object in items: ! ! # Only interested in named objects ! if not hasattr(object, '__name__'): ! continue ! ! if hasattr(object, 'func_globals'): ! # Looks like a func ! if object.func_globals is not dict: ! # Non-local func ! continue ! code = getattr(object, 'func_code', None) ! filename = getattr(code, 'co_filename', '') ! lineno = getattr(code, 'co_firstlineno', -1) + 1 ! if minlineno: ! minlineno = min(lineno, minlineno) ! else: ! minlineno = lineno ! _doc(name, object, tests, prefix, filename, lineno) ! ! elif hasattr(object, "__module__"): ! # Maybe a class-like things. In which case, we care ! if object.__module__ != module.__name__: ! continue # not the same module ! if not (hasattr(object, '__dict__') ! and hasattr(object, '__bases__')): ! continue # not a class ! ! lineno = _find(object.__dict__.items(), module, dict, tests, ! prefix+name+".") ! ! _doc(name, object, tests, prefix, ! lineno="%s (or above)" % (lineno-3)) ! ! return minlineno ! ! # end unitest support ! ############################################################################### ! ! ############################################################################### ! # debugger def _expect(expect): ! # Return the expected output, if any if expect: expect = "\n# ".join(expect.split("\n")) *************** *** 1381,1438 **** def testsource(module, name): ! """Extract the doctest examples from a docstring. Provide the module (or dotted name of the module) containing the ! tests to be extracted, and the name (within the module) of the object ! with the docstring containing the tests to be extracted. - The doctest examples are returned as a string containing Python - code. The expected output blocks in the examples are converted - to Python comments. """ ! ! module = _normalize_module(module) ! tests = _find_tests(module, "") ! test = [doc for (tname, doc, dummy, dummy) in tests ! if tname == name] if not test: raise ValueError(name, "not found in tests") test = test[0] ! examples = [source + _expect(expect) ! for source, expect, dummy in _extract_examples(test)] ! return '\n'.join(examples) ! ! def debug(module, name): ! """Debug a single docstring containing doctests. ! Provide the module (or dotted name of the module) containing the ! docstring to be debugged, and the name (within the module) of the ! object with the docstring to be debugged. ! The doctest examples are extracted (see function testsource()), ! and written to a temp file. The Python debugger (pdb) is then ! invoked on that file. """ ! import os import pdb - import tempfile - module = _normalize_module(module) - testsrc = testsource(module, name) srcfilename = tempfile.mktemp("doctestdebug.py") ! f = file(srcfilename, 'w') ! f.write(testsrc) ! f.close() - globs = {} - globs.update(module.__dict__) try: ! # Note that %r is vital here. '%s' instead can, e.g., cause ! # backslashes to get treated as metacharacters on Windows. ! pdb.run("execfile(%r)" % srcfilename, globs, globs) finally: os.remove(srcfilename) --- 1475,1551 ---- def testsource(module, name): ! """Extract the test sources from a doctest test docstring as a script Provide the module (or dotted name of the module) containing the ! test to be debugged and the name (within the module) of the object ! with the doc string with tests to be debugged. """ ! module = _normalizeModule(module) ! tests = _findTests(module, "") ! test = [doc for (tname, doc, f, l) in tests if tname == name] if not test: raise ValueError(name, "not found in tests") test = test[0] ! # XXX we rely on an internal doctest function: ! examples = _extract_examples(test) ! testsrc = '\n'.join([ ! "%s%s" % (source, _expect(expect)) ! for (source, expect, lineno) in examples ! ]) ! return testsrc ! def debug_src(src, pm=False, globs=None): ! """Debug a single doctest test doc string ! The string is provided directly """ + # XXX we rely on an internal doctest function: + examples = _extract_examples(src) + src = '\n'.join([ + "%s%s" % (source, _expect(expect)) + for (source, expect, lineno) in examples + ]) + debug_script(src, pm, globs) ! def debug_script(src, pm=False, globs=None): ! "Debug a test script" import pdb srcfilename = tempfile.mktemp("doctestdebug.py") ! open(srcfilename, 'w').write(src) ! if globs: ! globs = globs.copy() ! else: ! globs = {} try: ! if pm: ! try: ! execfile(srcfilename, globs, globs) ! except: ! print sys.exc_info()[1] ! pdb.post_mortem(sys.exc_info()[2]) ! else: ! # Note that %r is vital here. '%s' instead can, e.g., cause ! # backslashes to get treated as metacharacters on Windows. ! pdb.run("execfile(%r)" % srcfilename, globs, globs) finally: os.remove(srcfilename) + def debug(module, name, pm=False): + """Debug a single doctest test doc string + + Provide the module (or dotted name of the module) containing the + test to be debugged and the name (within the module) of the object + with the doc string with tests to be debugged. + + """ + module = _normalizeModule(module) + testsrc = testsource(module, name) + debug_script(testsrc, pm, module.__dict__) + + # end debugger + ############################################################################### From dcjim at users.sourceforge.net Wed Jul 14 21:07:17 2004 From: dcjim at users.sourceforge.net (dcjim@users.sourceforge.net) Date: Wed Jul 14 21:07:19 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_threading_local.py, NONE, 1.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15417/Lib/test Added Files: test_threading_local.py Log Message: Implemented thread-local data as proposed on python-dev: http://mail.python.org/pipermail/python-dev/2004-June/045785.html --- NEW FILE: test_threading_local.py --- import unittest from doctest import DocTestSuite from test import test_support def test_main(): suite = DocTestSuite('_threading_local') try: from thread import _local except ImportError: pass else: import _threading_local local_orig = _threading_local.local def setUp(): _threading_local.local = _local def tearDown(): _threading_local.local = local_orig suite.addTest(DocTestSuite('_threading_local', setUp=setUp, tearDown=tearDown) ) test_support.run_suite(suite) if __name__ == '__main__': test_main() From dcjim at users.sourceforge.net Wed Jul 14 21:07:17 2004 From: dcjim at users.sourceforge.net (dcjim@users.sourceforge.net) Date: Wed Jul 14 21:07:20 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libthreading.tex, 1.18, 1.19 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15417/Doc/lib Modified Files: libthreading.tex Log Message: Implemented thread-local data as proposed on python-dev: http://mail.python.org/pipermail/python-dev/2004-June/045785.html Index: libthreading.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libthreading.tex,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** libthreading.tex 30 Jun 2003 21:47:47 -0000 1.18 --- libthreading.tex 14 Jul 2004 19:07:15 -0000 1.19 *************** *** 50,53 **** --- 50,72 ---- \end{funcdesc} + \begin{classdesc*}{local}{} + A class that represents thread-local data. Thread-local data are data + who's values are thread specific. To manage thread-local data, just + create an instance of \class{local} (or a subclass) and store + attributes on it: + + \begin{verbatim} + >>> mydata = threading.local() + >>> mydata.x = 1 + \end{verbatim} + + The instance's values will be different for separate threads. + + For more details and extensive examples, see the documentation string + of the _threading_local module. + + \versionadded{2.4} + \end{classdesc*} + \begin{funcdesc}{Lock}{} A factory function that returns a new primitive lock object. Once From dcjim at users.sourceforge.net Wed Jul 14 21:07:17 2004 From: dcjim at users.sourceforge.net (dcjim@users.sourceforge.net) Date: Wed Jul 14 21:07:22 2004 Subject: [Python-checkins] python/dist/src/Lib _threading_local.py, NONE, 1.1 threading.py, 1.42, 1.43 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15417/Lib Modified Files: threading.py Added Files: _threading_local.py Log Message: Implemented thread-local data as proposed on python-dev: http://mail.python.org/pipermail/python-dev/2004-June/045785.html --- NEW FILE: _threading_local.py --- """Thread-local objects (Note that this module provides a Python version of thread threading.local class. Deoending on the version of Python you're using, there may be a faster one available. You should always import the local class from threading.) Thread-local objects support the management of thread-local data. If you have data that you want to be local to a thread, simply create a thread-local object and use it's attributes: >>> mydata = local() >>> mydata.number = 42 >>> mydata.number 42 You can also access the local-object's dictionary: >>> mydata.__dict__ {'number': 42} >>> mydata.__dict__.setdefault('widgets', []) [] >>> mydata.widgets [] What's important about thread-local objects is that their data are local to a thread. If we access the data in a different thread: >>> log = [] >>> def f(): ... items = mydata.__dict__.items() ... items.sort() ... log.append(items) ... mydata.number = 11 ... log.append(mydata.number) >>> import threading >>> thread = threading.Thread(target=f) >>> thread.start() >>> thread.join() >>> log [[], 11] we get different data. Furthermore, changes made in the other thread don't affect data seen in this thread: >>> mydata.number 42 Of course, values you get from a local object, including a __dict__ attribute, are for whatever thread was current at the time the attribute was read. For that reason, you generally don't want to save these values across threads, as they apply only to the thread they came from. You can create custom local objects by subclassing the local class: >>> class MyLocal(local): ... number = 2 ... initialized = False ... def __init__(self, **kw): ... if self.initialized: ... raise SystemError('__init__ called too many times') ... self.initialized = True ... self.__dict__.update(kw) ... def squared(self): ... return self.number ** 2 This can be useful to support default values, methods and initialization. Note that if you define an __init__ method, it will be called each time the local object is used in a separate thread. This is necessary to initialize each thread's dictionary. Now if we create a local object: >>> mydata = MyLocal(color='red') Now we have a default number: >>> mydata.number 2 an initial color: >>> mydata.color 'red' >>> del mydata.color And a method that operates on the data: >>> mydata.squared() 4 As before, we can access the data in a separate thread: >>> log = [] >>> thread = threading.Thread(target=f) >>> thread.start() >>> thread.join() >>> log [[('color', 'red'), ('initialized', True)], 11] without effecting this threads data: >>> mydata.number 2 >>> mydata.color Traceback (most recent call last): ... AttributeError: 'MyLocal' object has no attribute 'color' Note that subclasses can define slots, but they are not thread local. They are shared across threads: >>> class MyLocal(local): ... __slots__ = 'number' >>> mydata = MyLocal() >>> mydata.number = 42 >>> mydata.color = 'red' So, the separate thread: >>> thread = threading.Thread(target=f) >>> thread.start() >>> thread.join() affects what we see: >>> mydata.number 11 >>> del mydata """ # Threading import is at end class _localbase(object): __slots__ = '_local__key', '_local__args', '_local__lock' def __new__(cls, *args, **kw): self = object.__new__(cls) key = '_local__key', 'thread.local.' + str(id(self)) object.__setattr__(self, '_local__key', key) object.__setattr__(self, '_local__args', (args, kw)) object.__setattr__(self, '_local__lock', RLock()) if args or kw and (cls.__init__ is object.__init__): raise TypeError("Initialization arguments are not supported") # We need to create the thread dict in anticipation of # __init__ being called, to make sire we don't cal it # again ourselves. dict = object.__getattribute__(self, '__dict__') currentThread().__dict__[key] = dict return self def _patch(self): key = object.__getattribute__(self, '_local__key') d = currentThread().__dict__.get(key) if d is None: d = {} currentThread().__dict__[key] = d object.__setattr__(self, '__dict__', d) # we have a new instance dict, so call out __init__ if we have # one cls = type(self) if cls.__init__ is not object.__init__: args, kw = object.__getattribute__(self, '_local__args') cls.__init__(self, *args, **kw) else: object.__setattr__(self, '__dict__', d) class local(_localbase): def __getattribute__(self, name): lock = object.__getattribute__(self, '_local__lock') lock.acquire() try: _patch(self) return object.__getattribute__(self, name) finally: lock.release() def __setattr__(self, name, value): lock = object.__getattribute__(self, '_local__lock') lock.acquire() try: _patch(self) return object.__setattr__(self, name, value) finally: lock.release() def __delattr__(self, name): lock = object.__getattribute__(self, '_local__lock') lock.acquire() try: _patch(self) return object.__delattr__(self, name) finally: lock.release() def __del__(): threading_enumerate = enumerate __getattribute__ = object.__getattribute__ def __del__(self): key = __getattribute__(self, '_local__key') try: threads = list(threading_enumerate()) except: # if enumerate fails, as it seems to do during # shutdown, we'll skip cleanup under the assumption # that there is nothing to clean up return for thread in threads: try: __dict__ = thread.__dict__ except AttributeError: # Thread is dying, rest in peace continue if key in __dict__: try: del __dict__[key] except KeyError: pass # didn't have nything in this thread return __del__ __del__ = __del__() from threading import currentThread, enumerate, RLock Index: threading.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/threading.py,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -d -r1.42 -r1.43 *** threading.py 3 Jul 2004 03:52:35 -0000 1.42 --- threading.py 14 Jul 2004 19:07:15 -0000 1.43 *************** *** 16,20 **** __all__ = ['activeCount', 'Condition', 'currentThread', 'enumerate', 'Event', 'Lock', 'RLock', 'Semaphore', 'BoundedSemaphore', 'Thread', ! 'Timer', 'setprofile', 'settrace'] _start_new_thread = thread.start_new_thread --- 16,20 ---- __all__ = ['activeCount', 'Condition', 'currentThread', 'enumerate', 'Event', 'Lock', 'RLock', 'Semaphore', 'BoundedSemaphore', 'Thread', ! 'Timer', 'setprofile', 'settrace', 'local'] _start_new_thread = thread.start_new_thread *************** *** 662,665 **** --- 662,673 ---- _MainThread() + # get thread-local implementation, either from the thread + # module, or from the python fallback + + try: + from thread import _local as local + except ImportError: + from _threading_local import local + # Self-test code From dcjim at users.sourceforge.net Wed Jul 14 21:07:18 2004 From: dcjim at users.sourceforge.net (dcjim@users.sourceforge.net) Date: Wed Jul 14 21:07:23 2004 Subject: [Python-checkins] python/dist/src/Modules threadmodule.c,2.57,2.58 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15417/Modules Modified Files: threadmodule.c Log Message: Implemented thread-local data as proposed on python-dev: http://mail.python.org/pipermail/python-dev/2004-June/045785.html Index: threadmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/threadmodule.c,v retrieving revision 2.57 retrieving revision 2.58 diff -C2 -d -r2.57 -r2.58 *** threadmodule.c 24 Mar 2004 22:22:11 -0000 2.57 --- threadmodule.c 14 Jul 2004 19:07:15 -0000 2.58 *************** *** 159,162 **** --- 159,415 ---- }; + /* Thread-local objects */ + + #include "structmember.h" + + typedef struct { + PyObject_HEAD + PyObject *key; + PyObject *args; + PyObject *kw; + PyObject *dict; + } localobject; + + static PyTypeObject localtype; + + static PyObject * + local_new(PyTypeObject *type, PyObject *args, PyObject *kw) + { + localobject *self; + PyObject *tdict; + + if (type->tp_init == PyBaseObject_Type.tp_init + && ((args && PyObject_IsTrue(args)) + || + (kw && PyObject_IsTrue(kw)) + ) + ) { + PyErr_SetString(PyExc_TypeError, + "Initialization arguments are not supported"); + return NULL; + } + + self = (localobject *)type->tp_alloc(type, 0); + if (self == NULL) + return NULL; + + Py_XINCREF(args); + self->args = args; + Py_XINCREF(kw); + self->kw = kw; + self->dict = NULL; /* making sure */ + self->key = PyString_FromFormat("thread.local.%p", self); + if (self->key == NULL) + goto err; + + self->dict = PyDict_New(); + if (self->dict == NULL) + goto err; + + tdict = PyThreadState_GetDict(); + if (tdict == NULL) { + PyErr_SetString(PyExc_SystemError, + "Couldn't get thread-state dictionary"); + goto err; + } + + if (PyDict_SetItem(tdict, self->key, self->dict) < 0) + goto err; + + return (PyObject *)self; + + err: + Py_DECREF(self); + return NULL; + } + + static int + local_traverse(localobject *self, visitproc visit, void *arg) + { + Py_VISIT(self->args); + Py_VISIT(self->kw); + Py_VISIT(self->dict); + return 0; + } + + static int + local_clear(localobject *self) + { + Py_CLEAR(self->key); + Py_CLEAR(self->args); + Py_CLEAR(self->kw); + Py_CLEAR(self->dict); + return 0; + } + + static void + local_dealloc(localobject *self) + { + PyThreadState *tstate; + if (self->key + && (tstate = PyThreadState_Get()) + && tstate->interp) { + for(tstate = PyInterpreterState_ThreadHead(tstate->interp); + tstate; + tstate = PyThreadState_Next(tstate) + ) + if (tstate->dict && + PyDict_GetItem(tstate->dict, self->key)) + PyDict_DelItem(tstate->dict, self->key); + } + + local_clear(self); + self->ob_type->tp_free((PyObject*)self); + } + + static PyObject * + _ldict(localobject *self) + { + PyObject *tdict, *ldict; + + tdict = PyThreadState_GetDict(); + if (tdict == NULL) { + PyErr_SetString(PyExc_SystemError, + "Couldn't get thread-state dictionary"); + return NULL; + } + + ldict = PyDict_GetItem(tdict, self->key); + if (ldict == NULL) { + ldict = PyDict_New(); /* we own ldict */ + + if (ldict == NULL) + return NULL; + else { + int i = PyDict_SetItem(tdict, self->key, ldict); + Py_DECREF(ldict); /* now ldict is borowed */ + if (i < 0) + return NULL; + } + + Py_CLEAR(self->dict); + Py_INCREF(ldict); + self->dict = ldict; /* still borrowed */ + + if (self->ob_type->tp_init != PyBaseObject_Type.tp_init && + self->ob_type->tp_init((PyObject*)self, + self->args, self->kw) < 0 + ) { + /* we need to get rid of ldict from thread so + we create a new one the next time we do an attr + acces */ + PyDict_DelItem(tdict, self->key); + return NULL; + } + + } + else if (self->dict != ldict) { + Py_CLEAR(self->dict); + Py_INCREF(ldict); + self->dict = ldict; + } + + return ldict; + } + + static PyObject * + local_getattro(localobject *self, PyObject *name) + { + PyObject *ldict, *value; + + ldict = _ldict(self); + if (ldict == NULL) + return NULL; + + if (self->ob_type != &localtype) + /* use generic lookup for subtypes */ + return PyObject_GenericGetAttr((PyObject *)self, name); + + /* Optimization: just look in dict ourselves */ + value = PyDict_GetItem(ldict, name); + if (value == NULL) + /* Fall back on generic to get __class__ and __dict__ */ + return PyObject_GenericGetAttr((PyObject *)self, name); + + Py_INCREF(value); + return value; + } + + static int + local_setattro(localobject *self, PyObject *name, PyObject *v) + { + PyObject *ldict; + + ldict = _ldict(self); + if (ldict == NULL) + return -1; + + return PyObject_GenericSetAttr((PyObject *)self, name, v); + } + + static PyObject * + local_getdict(localobject *self, void *closure) + { + if (self->dict == NULL) { + PyErr_SetString(PyExc_AttributeError, "__dict__"); + return NULL; + } + + Py_INCREF(self->dict); + return self->dict; + } + + static PyGetSetDef local_getset[] = { + {"__dict__", + (getter)local_getdict, (setter)0, + "Local-data dictionary", + NULL}, + {NULL} /* Sentinel */ + }; + + static PyTypeObject localtype = { + PyObject_HEAD_INIT(NULL) + /* ob_size */ 0, + /* tp_name */ "thread._local", + /* tp_basicsize */ sizeof(localobject), + /* tp_itemsize */ 0, + /* tp_dealloc */ (destructor)local_dealloc, + /* tp_print */ (printfunc)0, + /* tp_getattr */ (getattrfunc)0, + /* tp_setattr */ (setattrfunc)0, + /* tp_compare */ (cmpfunc)0, + /* tp_repr */ (reprfunc)0, + /* tp_as_number */ 0, + /* tp_as_sequence */ 0, + /* tp_as_mapping */ 0, + /* tp_hash */ (hashfunc)0, + /* tp_call */ (ternaryfunc)0, + /* tp_str */ (reprfunc)0, + /* tp_getattro */ (getattrofunc)local_getattro, + /* tp_setattro */ (setattrofunc)local_setattro, + /* tp_as_buffer */ 0, + /* tp_flags */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, + /* tp_doc */ "Thread-local data", + /* tp_traverse */ (traverseproc)local_traverse, + /* tp_clear */ (inquiry)local_clear, + /* tp_richcompare */ (richcmpfunc)0, + /* tp_weaklistoffset */ (long)0, + /* tp_iter */ (getiterfunc)0, + /* tp_iternext */ (iternextfunc)0, + /* tp_methods */ 0, + /* tp_members */ 0, + /* tp_getset */ local_getset, + /* tp_base */ 0, + /* tp_dict */ 0, /* internal use */ + /* tp_descr_get */ (descrgetfunc)0, + /* tp_descr_set */ (descrsetfunc)0, + /* tp_dictoffset */ offsetof(localobject, dict), + /* tp_init */ (initproc)0, + /* tp_alloc */ (allocfunc)0, + /* tp_new */ (newfunc)local_new, + /* tp_free */ 0, /* Low-level free-mem routine */ + /* tp_is_gc */ (inquiry)0, /* For PyObject_IS_GC */ + }; + /* Module functions */ *************** *** 390,393 **** --- 643,650 ---- { PyObject *m, *d; + + /* Initialize types: */ + if (PyType_Ready(&localtype) < 0) + return; /* Create the module and add the functions */ *************** *** 402,405 **** --- 659,665 ---- PyDict_SetItemString(d, "LockType", (PyObject *)&Locktype); + if (PyModule_AddObject(m, "_local", (PyObject *)&localtype) < 0) + return; + /* Initialize the C thread library */ PyThread_init_thread(); From dcjim at users.sourceforge.net Wed Jul 14 21:07:27 2004 From: dcjim at users.sourceforge.net (dcjim@users.sourceforge.net) Date: Wed Jul 14 21:07:30 2004 Subject: [Python-checkins] python/dist/src/Doc/ext newtypes.tex, 1.36, 1.37 noddy4.c, 1.1, 1.2 noddy2.c, 1.4, 1.5 noddy3.c, 1.4, 1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/ext In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15472/Doc/ext Modified Files: newtypes.tex noddy4.c noddy2.c noddy3.c Log Message: Updated documentation to: - point out the importance of reassigning data members before assigning thier values - correct my missconception about return values from visitprocs. Sigh. - mention the labor saving Py_VISIT and Py_CLEAR macros. Index: newtypes.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ext/newtypes.tex,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** newtypes.tex 6 Jun 2004 15:59:18 -0000 1.36 --- newtypes.tex 14 Jul 2004 19:07:24 -0000 1.37 *************** *** 240,245 **** \begin{verbatim} ! import noddy ! mynoddy = noddy.Noddy() \end{verbatim} --- 240,245 ---- \begin{verbatim} ! >>> import noddy ! >>> mynoddy = noddy.Noddy() \end{verbatim} *************** *** 383,387 **** values were \NULL, we could have used \cfunction{PyType_GenericNew()} as our new method, as we did before. \cfunction{PyType_GenericNew()} ! initializes all of the instance variable members to NULLs. The new method is a static method that is passed the type being --- 383,387 ---- values were \NULL, we could have used \cfunction{PyType_GenericNew()} as our new method, as we did before. \cfunction{PyType_GenericNew()} ! initializes all of the instance variable members to \NULL. The new method is a static method that is passed the type being *************** *** 408,412 **** such subclasses without getting a \exception{TypeError}.)} - We provide an initialization function: --- 408,411 ---- *************** *** 415,419 **** Noddy_init(Noddy *self, PyObject *args, PyObject *kwds) { ! PyObject *first=NULL, *last=NULL; static char *kwlist[] = {"first", "last", "number", NULL}; --- 414,418 ---- Noddy_init(Noddy *self, PyObject *args, PyObject *kwds) { ! PyObject *first=NULL, *last=NULL, *tmp; static char *kwlist[] = {"first", "last", "number", NULL}; *************** *** 425,437 **** if (first) { ! Py_XDECREF(self->first); Py_INCREF(first); self->first = first; } if (last) { ! Py_XDECREF(self->last); Py_INCREF(last); self->last = last; } --- 424,438 ---- if (first) { ! tmp = self->first; Py_INCREF(first); self->first = first; + Py_XDECREF(tmp); } if (last) { ! tmp = self->last; Py_INCREF(last); self->last = last; + Py_XDECREF(tmp); } *************** *** 454,457 **** --- 455,496 ---- positional and keyword arguments. + Initializers can be called multiple times. Anyone can call the + \method{__init__()} method on our objects. For this reason, we have + to be extra careful when assigning the new values. We might be + tempted, for example to assign the \member{first} member like this: + + \begin{verbatim} + if (first) { + Py_XDECREF(self->first); + Py_INCREF(first); + self->first = first; + } + \end{verbatim} + + But this would be risky. Our type doesn't restrict the type of the + \member{first} member, so it could be any kind of object. It could + have a destructor that causes code to be executed that tries to + access the \member{first} member. To be paranoid and protect + ourselves against this possibility, we almost always reassign members + before decrementing their reference counts. When don't we have to do + this? + \begin{itemize} + \item when we absolutely know that the reference count is greater than + 1 + \item when we know that deallocation of the object\footnote{This is + true when we know that the object is a basic type, like a string or + a float} will not cause any + calls back into our type's code + \item when decrementing a reference count in a \member{tp_dealloc} + handler when garbage-collections is not supported\footnote{We relied + on this in the \member{tp_dealloc} handler in this example, because + our type doesn't support garbage collection. Even if a type supports + garbage collection, there are calls that can be made to ``untrack'' + the object from garbage collection, however, these calls are + advanced and not covered here.} + \item + \end{itemize} + + We want to want to expose our instance variables as attributes. There are a number of ways to do that. The simplest way is to define member *************** *** 683,686 **** --- 722,764 ---- \end{verbatim} + We also need to update the \member{tp_init} handler to only allow + strings\footnote{We now know that the first and last members are strings, + so perhaps we could be less careful about decrementing their + reference counts, however, we accept instances of string subclasses. + Even though deallocating normal strings won't call back into our + objects, we can't guarantee that deallocating an instance of a string + subclass won't. call back into out objects.} to be passed: + + \begin{verbatim} + static int + Noddy_init(Noddy *self, PyObject *args, PyObject *kwds) + { + PyObject *first=NULL, *last=NULL, *tmp; + + static char *kwlist[] = {"first", "last", "number", NULL}; + + if (! PyArg_ParseTupleAndKeywords(args, kwds, "|SSi", kwlist, + &first, &last, + &self->number)) + return -1; + + if (first) { + tmp = self->first; + Py_INCREF(first); + self->first = first; + Py_DECREF(tmp); + } + + if (last) { + tmp = self->last; + Py_INCREF(last); + self->last = last; + Py_DECREF(tmp); + } + + return 0; + } + \end{verbatim} + With these changes, we can assure that the \member{first} and \member{last} members are never NULL so we can remove checks for \NULL *************** *** 714,719 **** In the second version of the \class{Noddy} example, we allowed any kind of object to be stored in the \member{first} or \member{last} ! attributes. This means that \class{Noddy} objects can participate in ! cycles: \begin{verbatim} --- 792,799 ---- In the second version of the \class{Noddy} example, we allowed any kind of object to be stored in the \member{first} or \member{last} ! attributes\footnote{Even in the third version, we aren't guaranteed to ! avoid cycles. Instances of string subclasses are allowed and string ! subclasses could allow cycles even if normal strings don't.}. This ! means that \class{Noddy} objects can participate in cycles: \begin{verbatim} *************** *** 738,745 **** Noddy_traverse(Noddy *self, visitproc visit, void *arg) { ! if (self->first && visit(self->first, arg) < 0) ! return -1; ! if (self->last && visit(self->last, arg) < 0) ! return -1; return 0; --- 818,833 ---- Noddy_traverse(Noddy *self, visitproc visit, void *arg) { ! int vret; ! ! if (self->first) { ! vret = visit(self->first, arg); ! if (vret != 0) ! return vret; ! } ! if (self->last) { ! vret = visit(self->last, arg); ! if (vret != 0) ! return vret; ! } return 0; *************** *** 750,754 **** \cfunction{visit()} function, which is passed to the traversal method. The \cfunction{visit()} function takes as arguments the subobject and ! the extra argument \var{arg} passed to the traversal method. We also need to provide a method for clearing any subobjects that can --- 838,859 ---- \cfunction{visit()} function, which is passed to the traversal method. The \cfunction{visit()} function takes as arguments the subobject and ! the extra argument \var{arg} passed to the traversal method. It ! returns an integer value that must be returned if it is non-zero. ! ! ! Python 2.4 and higher provide a \cfunction{Py_VISIT()} that automates ! calling visit functions. With \cfunction{Py_VISIT()}, the ! \cfunction{Noddy_traverse()} can be simplified: ! ! ! \begin{verbatim} ! static int ! Noddy_traverse(Noddy *self, visitproc visit, void *arg) ! { ! Py_VISIT(self->first); ! Py_VISIT(self->last); ! return 0; ! } ! \end{verbatim} We also need to provide a method for clearing any subobjects that can *************** *** 760,767 **** Noddy_clear(Noddy *self) { ! Py_XDECREF(self->first); self->first = NULL; ! Py_XDECREF(self->last); self->last = NULL; return 0; --- 865,877 ---- Noddy_clear(Noddy *self) { ! PyObject *tmp; ! ! tmp = self->first; self->first = NULL; ! Py_XDECREF(tmp); ! ! tmp = self->last; self->last = NULL; + Py_XDECREF(tmp); return 0; *************** *** 776,779 **** --- 886,916 ---- \end{verbatim} + Notice the use of a temporary variable in \cfunction{Noddy_clear()}. + We use the temporary variable so that we can set each member to \NULL + before decrementing it's reference count. We do this because, as was + discussed earlier, if the reference count drops to zero, we might + cause code to run that calls back into the object. In addition, + because we now support garbage collection, we also have to worry about + code being run that triggers garbage collection. If garbage + collection is run, our \member{tp_traverse} handler could get called. + We can't take a chance of having \cfunction{Noddy_traverse()} called + when a member's reference count has dropped to zero and it's value + hasn't been set to \NULL. + + Python 2.4 and higher provide a \cfunction{Py_CLEAR()} that automates + the careful decrementing of reference counts. With + \cfunction{Py_CLEAR()}, the \cfunction{Noddy_clear()} function can be + simplified: + + \begin{verbatim} + static int + Noddy_clear(Noddy *self) + { + Py_CLEAR(self->first); + Py_CLEAR(self->last); + return 0; + } + \end{verbatim} + Finally, we add the \constant{Py_TPFLAGS_HAVE_GC} flag to the class flags: *************** *** 807,811 **** they are defined in the structure, because there is a lot of historical baggage that impacts the ordering of the fields; be sure ! your type initializaion keeps the fields in the right order! It's often easiest to find an example that includes all the fields you need (even if they're initialized to \code{0}) and then change the values --- 944,948 ---- they are defined in the structure, because there is a lot of historical baggage that impacts the ordering of the fields; be sure ! your type initialization keeps the fields in the right order! It's often easiest to find an example that includes all the fields you need (even if they're initialized to \code{0}) and then change the values *************** *** 825,829 **** These fields tell the runtime how much memory to allocate when new ! objects of this type are created. Python has some builtin support for variable length structures (think: strings, lists) which is where the \member{tp_itemsize} field comes in. This will be dealt with --- 962,966 ---- These fields tell the runtime how much memory to allocate when new ! objects of this type are created. Python has some built-in support for variable length structures (think: strings, lists) which is where the \member{tp_itemsize} field comes in. This will be dealt with *************** *** 836,840 **** Here you can put a string (or its address) that you want returned when the Python script references \code{obj.__doc__} to retrieve the ! docstring. Now we come to the basic type methods---the ones most extension types --- 973,977 ---- Here you can put a string (or its address) that you want returned when the Python script references \code{obj.__doc__} to retrieve the ! doc string. Now we come to the basic type methods---the ones most extension types *************** *** 916,920 **** In Python, there are three ways to generate a textual representation of an object: the \function{repr()}\bifuncindex{repr} function (or ! equivalent backtick syntax), the \function{str()}\bifuncindex{str} function, and the \keyword{print} statement. For most objects, the \keyword{print} statement is equivalent to the \function{str()} --- 1053,1057 ---- In Python, there are three ways to generate a textual representation of an object: the \function{repr()}\bifuncindex{repr} function (or ! equivalent back-tick syntax), the \function{str()}\bifuncindex{str} function, and the \keyword{print} statement. For most objects, the \keyword{print} statement is equivalent to the \function{str()} *************** *** 984,988 **** likely want to write to that file object. ! Here is a sampe print function: \begin{verbatim} --- 1121,1125 ---- likely want to write to that file object. ! Here is a sample print function: \begin{verbatim} *************** *** 1139,1146 **** An interesting advantage of using the \member{tp_members} table to build descriptors that are used at runtime is that any attribute ! defined this way can have an associated docstring simply by providing the text in the table. An application can use the introspection API to retrieve the descriptor from the class object, and get the ! docstring using its \member{__doc__} attribute. As with the \member{tp_methods} table, a sentinel entry with a --- 1276,1283 ---- An interesting advantage of using the \member{tp_members} table to build descriptors that are used at runtime is that any attribute ! defined this way can have an associated doc string simply by providing the text in the table. An application can use the introspection API to retrieve the descriptor from the class object, and get the ! doc string using its \member{__doc__} attribute. As with the \member{tp_methods} table, a sentinel entry with a *************** *** 1287,1291 **** indicate that the slots are present and should be checked by the interpreter. (The flag bit does not indicate that the slot values are ! non-\NULL. The flag may be set to indicate the presense of a slot, but a slot may still be unfilled.) --- 1424,1428 ---- indicate that the slots are present and should be checked by the interpreter. (The flag bit does not indicate that the slot values are ! non-\NULL. The flag may be set to indicate the presence of a slot, but a slot may still be unfilled.) *************** *** 1310,1314 **** This function, if you choose to provide it, should return a hash ! number for an instance of your datatype. Here is a moderately pointless example: --- 1447,1451 ---- This function, if you choose to provide it, should return a hash ! number for an instance of your data type. Here is a moderately pointless example: *************** *** 1328,1333 **** \end{verbatim} ! This function is called when an instance of your datatype is "called", ! for example, if \code{obj1} is an instance of your datatype and the Python script contains \code{obj1('hello')}, the \member{tp_call} handler is invoked. --- 1465,1470 ---- \end{verbatim} ! This function is called when an instance of your data type is "called", ! for example, if \code{obj1} is an instance of your data type and the Python script contains \code{obj1('hello')}, the \member{tp_call} handler is invoked. *************** *** 1337,1341 **** \begin{enumerate} \item ! \var{arg1} is the instance of the datatype which is the subject of the call. If the call is \code{obj1('hello')}, then \var{arg1} is \code{obj1}. --- 1474,1478 ---- \begin{enumerate} \item ! \var{arg1} is the instance of the data type which is the subject of the call. If the call is \code{obj1('hello')}, then \var{arg1} is \code{obj1}. *************** *** 1431,1435 **** In order to learn how to implement any specific method for your new ! datatype, do the following: Download and unpack the Python source distribution. Go the \file{Objects} directory, then search the C source files for \code{tp_} plus the function you want (for --- 1568,1572 ---- In order to learn how to implement any specific method for your new ! data type, do the following: Download and unpack the Python source distribution. Go the \file{Objects} directory, then search the C source files for \code{tp_} plus the function you want (for Index: noddy4.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ext/noddy4.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** noddy4.c 28 Jun 2003 13:29:16 -0000 1.1 --- noddy4.c 14 Jul 2004 19:07:24 -0000 1.2 *************** *** 12,19 **** Noddy_traverse(Noddy *self, visitproc visit, void *arg) { ! if (self->first && visit(self->first, arg) < 0) ! return -1; ! if (self->last && visit(self->last, arg) < 0) ! return -1; return 0; --- 12,27 ---- Noddy_traverse(Noddy *self, visitproc visit, void *arg) { ! int vret; ! ! if (self->first) { ! vret = visit(self->first, arg); ! if (vret != 0) ! return vret; ! } ! if (self->last) { ! vret = visit(self->last, arg); ! if (vret != 0) ! return vret; ! } return 0; *************** *** 23,30 **** Noddy_clear(Noddy *self) { ! Py_XDECREF(self->first); self->first = NULL; ! Py_XDECREF(self->last); self->last = NULL; return 0; --- 31,43 ---- Noddy_clear(Noddy *self) { ! PyObject *tmp; ! ! tmp = self->first; self->first = NULL; ! Py_XDECREF(tmp); ! ! tmp = self->last; self->last = NULL; + Py_XDECREF(tmp); return 0; *************** *** 68,72 **** Noddy_init(Noddy *self, PyObject *args, PyObject *kwds) { ! PyObject *first=NULL, *last=NULL; static char *kwlist[] = {"first", "last", "number", NULL}; --- 81,85 ---- Noddy_init(Noddy *self, PyObject *args, PyObject *kwds) { ! PyObject *first=NULL, *last=NULL, *tmp; static char *kwlist[] = {"first", "last", "number", NULL}; *************** *** 78,90 **** if (first) { ! Py_XDECREF(self->first); Py_INCREF(first); self->first = first; } if (last) { ! Py_XDECREF(self->last); Py_INCREF(last); self->last = last; } --- 91,105 ---- if (first) { ! tmp = self->first; Py_INCREF(first); self->first = first; + Py_XDECREF(tmp); } if (last) { ! tmp = self->last; Py_INCREF(last); self->last = last; + Py_XDECREF(tmp); } Index: noddy2.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ext/noddy2.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** noddy2.c 28 Jun 2003 11:53:47 -0000 1.4 --- noddy2.c 14 Jul 2004 19:07:24 -0000 1.5 *************** *** 47,51 **** Noddy_init(Noddy *self, PyObject *args, PyObject *kwds) { ! PyObject *first=NULL, *last=NULL; static char *kwlist[] = {"first", "last", "number", NULL}; --- 47,51 ---- Noddy_init(Noddy *self, PyObject *args, PyObject *kwds) { ! PyObject *first=NULL, *last=NULL, *tmp; static char *kwlist[] = {"first", "last", "number", NULL}; *************** *** 57,69 **** if (first) { ! Py_XDECREF(self->first); Py_INCREF(first); self->first = first; } if (last) { ! Py_XDECREF(self->last); Py_INCREF(last); self->last = last; } --- 57,71 ---- if (first) { ! tmp = self->first; Py_INCREF(first); self->first = first; + Py_XDECREF(tmp); } if (last) { ! tmp = self->last; Py_INCREF(last); self->last = last; + Py_XDECREF(tmp); } Index: noddy3.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ext/noddy3.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** noddy3.c 28 Jun 2003 11:54:03 -0000 1.4 --- noddy3.c 14 Jul 2004 19:07:24 -0000 1.5 *************** *** 47,55 **** Noddy_init(Noddy *self, PyObject *args, PyObject *kwds) { ! PyObject *first=NULL, *last=NULL; static char *kwlist[] = {"first", "last", "number", NULL}; ! if (! PyArg_ParseTupleAndKeywords(args, kwds, "|OOi", kwlist, &first, &last, &self->number)) --- 47,55 ---- Noddy_init(Noddy *self, PyObject *args, PyObject *kwds) { ! PyObject *first=NULL, *last=NULL, *tmp; static char *kwlist[] = {"first", "last", "number", NULL}; ! if (! PyArg_ParseTupleAndKeywords(args, kwds, "|SSi", kwlist, &first, &last, &self->number)) *************** *** 57,69 **** if (first) { ! Py_DECREF(self->first); Py_INCREF(first); self->first = first; } if (last) { ! Py_DECREF(self->last); Py_INCREF(last); self->last = last; } --- 57,71 ---- if (first) { ! tmp = self->first; Py_INCREF(first); self->first = first; + Py_DECREF(tmp); } if (last) { ! tmp = self->last; Py_INCREF(last); self->last = last; + Py_DECREF(tmp); } From dcjim at users.sourceforge.net Wed Jul 14 21:07:42 2004 From: dcjim at users.sourceforge.net (dcjim@users.sourceforge.net) Date: Wed Jul 14 21:07:45 2004 Subject: [Python-checkins] python/dist/src/Doc/api refcounting.tex,1.2,1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/api In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15507/Doc/api Modified Files: refcounting.tex Log Message: Implemented a new Py_CLEAR macro. This macro should be used when decrementing the refcount of variables that might be accessed as a result of calling Python Index: refcounting.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/refcounting.tex,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** refcounting.tex 22 Apr 2004 17:23:21 -0000 1.2 --- refcounting.tex 14 Jul 2004 19:07:35 -0000 1.3 *************** *** 43,46 **** --- 43,62 ---- \end{cfuncdesc} + \begin{cfuncdesc}{void}{Py_CLEAR}{PyObject *o} + Decrement the reference count for object \var{o}. The object may be + \NULL, in which case the macro has no effect; otherwise the effect + is the same as for \cfunction{Py_DECREF()}, except that the argument + is also set to \NULL. The warning for \cfunction{Py_DECREF()}, does + not apply with respect to the object passed because the macro + carefully uses a temporary variable and sets the argument to \NULL + before decrementing it's reference count. + + It is a good idea to use this macro whenever decrementing the value + of a variable that might be traversed during garbage collection. + + \versionadded{2.4} + \end{cfuncdesc} + + The following functions are for runtime dynamic embedding of Python: \cfunction{Py_IncRef(PyObject *o)}, \cfunction{Py_DecRef(PyObject *o)}. From dcjim at users.sourceforge.net Wed Jul 14 21:08:07 2004 From: dcjim at users.sourceforge.net (dcjim@users.sourceforge.net) Date: Wed Jul 14 21:08:09 2004 Subject: [Python-checkins] python/dist/src/Include object.h,2.126,2.127 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15507/Include Modified Files: object.h Log Message: Implemented a new Py_CLEAR macro. This macro should be used when decrementing the refcount of variables that might be accessed as a result of calling Python Index: object.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/object.h,v retrieving revision 2.126 retrieving revision 2.127 diff -C2 -d -r2.126 -r2.127 *** object.h 22 Apr 2004 17:23:30 -0000 2.126 --- object.h 14 Jul 2004 19:07:35 -0000 2.127 *************** *** 621,624 **** --- 621,633 ---- _Py_Dealloc((PyObject *)(op)) + #define Py_CLEAR(op) \ + do { \ + if (op) { \ + PyObject *tmp = (op); \ + (op) = NULL; \ + Py_DECREF(tmp); \ + } \ + } while (0) + /* Macros to use in case the object pointer may be NULL: */ #define Py_XINCREF(op) if ((op) == NULL) ; else Py_INCREF(op) From dcjim at users.sourceforge.net Wed Jul 14 21:08:19 2004 From: dcjim at users.sourceforge.net (dcjim@users.sourceforge.net) Date: Wed Jul 14 21:08:22 2004 Subject: [Python-checkins] python/dist/src/Doc/api newtypes.tex,1.31,1.32 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/api In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15695/Doc/api Modified Files: newtypes.tex Log Message: Documented the new Py_VISIT macro to simplify implementation of tp_traverse handlers. (Tim made me do it. ;) Index: newtypes.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/newtypes.tex,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** newtypes.tex 13 Jul 2004 17:18:10 -0000 1.31 --- newtypes.tex 14 Jul 2004 19:08:17 -0000 1.32 *************** *** 1664,1667 **** --- 1664,1690 ---- \end{ctypedesc} + To simplify writing \member{tp_traverse} handlers, a + \cfunction{Py_VISIT()} is provided: + + \begin{cfuncdesc}{void}{Py_VISIT}{PyObject *o} + Call the \var{visit} for \var{o} with \var{arg}. If \var{visit} + returns a non-zero value, then return it. Using this macro, + \member{tp_traverse} handlers look like: + + + \begin{verbatim} + static int + my_traverse(Noddy *self, visitproc visit, void *arg) + { + Py_VISIT(self->foo); + Py_VISIT(self->bar); + return 0; + } + \end{verbatim} + + \versionadded{2.4} + \end{cfuncdesc} + + The \member{tp_clear} handler must be of the \ctype{inquiry} type, or \NULL{} if the object is immutable. From dcjim at users.sourceforge.net Wed Jul 14 21:08:19 2004 From: dcjim at users.sourceforge.net (dcjim@users.sourceforge.net) Date: Wed Jul 14 21:08:23 2004 Subject: [Python-checkins] python/dist/src/Include objimpl.h,2.58,2.59 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15695/Include Modified Files: objimpl.h Log Message: Documented the new Py_VISIT macro to simplify implementation of tp_traverse handlers. (Tim made me do it. ;) Index: objimpl.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/objimpl.h,v retrieving revision 2.58 retrieving revision 2.59 diff -C2 -d -r2.58 -r2.59 *** objimpl.h 17 Apr 2003 17:29:20 -0000 2.58 --- objimpl.h 14 Jul 2004 19:08:17 -0000 2.59 *************** *** 303,306 **** --- 303,316 ---- + /* Utility macro to help write tp_traverse functions */ + #define Py_VISIT(op) \ + do { \ + if (op) { \ + int vret = visit((op), arg); \ + if (vret) \ + return vret; \ + } \ + } while (0) + /* This is here for the sake of backwards compatibility. Extensions that * use the old GC API will still compile but the objects will not be From dcjim at users.sourceforge.net Wed Jul 14 21:08:31 2004 From: dcjim at users.sourceforge.net (dcjim@users.sourceforge.net) Date: Wed Jul 14 21:08:34 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1040,1.1041 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15798/Misc Modified Files: NEWS Log Message: Summarized changes: threading.local, Py_CLEAR, Py_VISIT, improved type tutorial. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1040 retrieving revision 1.1041 diff -C2 -d -r1.1040 -r1.1041 *** NEWS 12 Jul 2004 09:33:39 -0000 1.1040 --- NEWS 14 Jul 2004 19:08:28 -0000 1.1041 *************** *** 24,27 **** --- 24,30 ---- It's quite possible that there are still bugs here. + - Added C macros Py_CLEAR and Py_VISIT to ease the implementation of + types that support garbage collection. + Extension modules ----------------- *************** *** 72,75 **** --- 75,88 ---- SF patch 945642. + - doctest unittest integration improvements: + + o Improved the unitest test output for doctest-based unit tests + + o Can now pass setUp and tearDown functions when creating + DocTestSuites. + + - The threading module has a new class, local, for creating objects + that provide thread-local data. + Tools/Demos ----------- *************** *** 84,87 **** --- 97,113 ---- thanks to Anthony Tuininga (patch #986010). + Documentation + ------------- + + Improved the tutorial on creating types in C. + + - point out the importance of reassigning data members before + assigning thier values + + - correct my missconception about return values from visitprocs. Sigh. + + - mention the labor saving Py_VISIT and Py_CLEAR macros. + + New platforms ------------- From dcjim at users.sourceforge.net Wed Jul 14 21:11:52 2004 From: dcjim at users.sourceforge.net (dcjim@users.sourceforge.net) Date: Wed Jul 14 21:11:55 2004 Subject: [Python-checkins] python/dist/src/Lib dummy_threading.py,1.1,1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16836/Lib Modified Files: dummy_threading.py Log Message: Implemented thread-local data as proposed on python-dev: http://mail.python.org/pipermail/python-dev/2004-June/045785.html Index: dummy_threading.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/dummy_threading.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** dummy_threading.py 30 Dec 2002 22:30:22 -0000 1.1 --- dummy_threading.py 14 Jul 2004 19:11:50 -0000 1.2 *************** *** 19,22 **** --- 19,23 ---- holding_thread = False holding_threading = False + holding__threading_local = False try: *************** *** 38,45 **** --- 39,57 ---- holding_threading = True del sys_modules['threading'] + + if '_threading_local' in sys_modules: + # If ``_threading_local`` is already imported, might as well prevent + # trying to import it more than needed by saving it if it is + # already imported before deleting it. + held__threading_local = sys_modules['_threading_local'] + holding__threading_local = True + del sys_modules['_threading_local'] + import threading # Need a copy of the code kept somewhere... sys_modules['_dummy_threading'] = sys_modules['threading'] del sys_modules['threading'] + sys_modules['_dummy__threading_local'] = sys_modules['_threading_local'] + del sys_modules['_threading_local'] from _dummy_threading import * from _dummy_threading import __all__ *************** *** 47,50 **** --- 59,63 ---- finally: # Put back ``threading`` if we overwrote earlier + if holding_threading: sys_modules['threading'] = held_threading *************** *** 52,55 **** --- 65,75 ---- del holding_threading + # Put back ``_threading_local`` if we overwrote earlier + + if holding__threading_local: + sys_modules['_threading_local'] = held__threading_local + del held__threading_local + del holding__threading_local + # Put back ``thread`` if we overwrote, else del the entry we made if holding_thread: From rhettinger at users.sourceforge.net Wed Jul 14 21:56:59 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Wed Jul 14 21:57:01 2004 Subject: [Python-checkins] python/dist/src/Lib decimal.py,1.17,1.18 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24915 Modified Files: decimal.py Log Message: Factor out two unnecessary global variables. Index: decimal.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/decimal.py,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** decimal.py 14 Jul 2004 16:35:29 -0000 1.17 --- decimal.py 14 Jul 2004 19:56:56 -0000 1.18 *************** *** 130,137 **** import operator - #Exponent Range - DEFAULT_MAX_EXPONENT = 999999999 - DEFAULT_MIN_EXPONENT = -999999999 - #Rounding ROUND_DOWN = 'ROUND_DOWN' --- 130,133 ---- *************** *** 1700,1704 **** firstprec = context.prec ! if not modulo and firstprec + elength + 1 > DEFAULT_MAX_EXPONENT: return context._raise_error(Overflow, 'Too much precision.', sign) --- 1696,1700 ---- firstprec = context.prec ! if not modulo and firstprec + elength + 1 > DefaultContext.Emax: return context._raise_error(Overflow, 'Too much precision.', sign) *************** *** 1923,1928 **** Emax, Emin = context.Emax, context.Emin ! context.Emax, context.Emin = DEFAULT_MAX_EXPONENT, DEFAULT_MIN_EXPONENT ! half = Decimal('0.5') --- 1919,1923 ---- Emax, Emin = context.Emax, context.Emin ! context.Emax, context.Emin = DefaultContext.Emax, DefaultContext.Emin half = Decimal('0.5') *************** *** 2948,2953 **** flags=[], _rounding_decision=ALWAYS_ROUND, ! Emax=DEFAULT_MAX_EXPONENT, ! Emin=DEFAULT_MIN_EXPONENT, capitals=1 ) --- 2943,2948 ---- flags=[], _rounding_decision=ALWAYS_ROUND, ! Emax=999999999, ! Emin=-999999999, capitals=1 ) *************** *** 2962,2966 **** traps=[DivisionByZero, Overflow, InvalidOperation, Clamped, Underflow], flags=[], - _rounding_decision=ALWAYS_ROUND, ) --- 2957,2960 ---- *************** *** 2969,2973 **** traps=[], flags=[], - _rounding_decision=ALWAYS_ROUND, ) --- 2963,2966 ---- From python at rcn.com Wed Jul 14 10:23:45 2004 From: python at rcn.com (Raymond Hettinger) Date: Wed Jul 14 22:25:13 2004 Subject: [Python-checkins] python/dist/src/Include objimpl.h,2.58,2.59 In-Reply-To: Message-ID: <001401c4697b$e1ee4800$e841fea9@oemcomputer> > Documented the new Py_VISIT macro to simplify implementation of > tp_traverse handlers. (Tim made me do it. ;) That Tim has been tyrant lately ;-) > + /* Utility macro to help write tp_traverse functions */ > + #define Py_VISIT(op) \ > + do { \ > + if (op) { \ > + int vret = visit((op), arg); \ > + if (vret) \ > + return vret; \ > + } \ > + } while (0) I tried out this macro with the itertools module and found that it did a nice job of compacting boilerplate code. One thought jumped out though. The macro assumes that the enclosing function has consistent with the use of the variable names "visit" and "arg": static int islice_traverse(isliceobject *lz, visitproc visit, void *arg) { Py_VISIT(lz->it); return 0; } If the parameters are named something else ("vfunc" for example), MSVC++6.0 complains: C:\py24\Modules\itertoolsmodule.c(1118) : warning C4013: 'visit' undefined; assuming extern returning int Don't know if it is worth it, but you could safeguard the macro by including visit and arg in the parameter list. Raymond Hettinger From rhettinger at users.sourceforge.net Wed Jul 14 23:04:30 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Wed Jul 14 23:04:33 2004 Subject: [Python-checkins] python/dist/src/Lib decimal.py,1.18,1.19 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5949 Modified Files: decimal.py Log Message: Use threading.local() instead of threading.currentThread(). Index: decimal.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/decimal.py,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** decimal.py 14 Jul 2004 19:56:56 -0000 1.18 --- decimal.py 14 Jul 2004 21:04:27 -0000 1.19 *************** *** 375,402 **** ##### Context Functions ####################################### ! #To fix reloading, force it to create a new context ! #Old contexts have different exceptions in their dicts, making problems. ! if hasattr(threading.currentThread(), '__decimal_context__'): ! del threading.currentThread().__decimal_context__ ! def setcontext(context): ! """Set this thread's context to context.""" ! if context in (DefaultContext, BasicContext, ExtendedContext): ! context = context.copy() ! threading.currentThread().__decimal_context__ = context ! def getcontext(): ! """Returns this thread's context. ! If this thread does not yet have a context, returns ! a new context and sets this thread's context. ! New contexts are copies of DefaultContext. ! """ ! try: ! return threading.currentThread().__decimal_context__ ! except AttributeError: ! context = Context() threading.currentThread().__decimal_context__ = context ! return context --- 375,438 ---- ##### Context Functions ####################################### ! # The getcontext() and setcontext() function manage access to a thread-local ! # current context. Py2.4 offers direct support for thread locals. If that ! # is not available, use threading.currentThread() which is slower but will ! # work for older Pythons. ! try: ! threading.local ! except AttributeError: ! #To fix reloading, force it to create a new context ! #Old contexts have different exceptions in their dicts, making problems. ! if hasattr(threading.currentThread(), '__decimal_context__'): ! del threading.currentThread().__decimal_context__ ! ! def setcontext(context): ! """Set this thread's context to context.""" ! if context in (DefaultContext, BasicContext, ExtendedContext): ! context = context.copy() threading.currentThread().__decimal_context__ = context ! ! def getcontext(): ! """Returns this thread's context. ! ! If this thread does not yet have a context, returns ! a new context and sets this thread's context. ! New contexts are copies of DefaultContext. ! """ ! try: ! return threading.currentThread().__decimal_context__ ! except AttributeError: ! context = Context() ! threading.currentThread().__decimal_context__ = context ! return context ! ! else: ! ! local = threading.local() ! ! def getcontext(_local=local): ! """Returns this thread's context. ! ! If this thread does not yet have a context, returns ! a new context and sets this thread's context. ! New contexts are copies of DefaultContext. ! """ ! try: ! return _local.__decimal_context__ ! except AttributeError: ! context = Context() ! _local.__decimal_context__ = context ! return context ! ! def setcontext(context, _local=local): ! """Set this thread's context to context.""" ! if context in (DefaultContext, BasicContext, ExtendedContext): ! context = context.copy() ! _local.__decimal_context__ = context ! ! del threading, local # Don't contaminate the namespace From rhettinger at users.sourceforge.net Wed Jul 14 23:06:58 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Wed Jul 14 23:07:00 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libdecimal.tex,1.13,1.14 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6506 Modified Files: libdecimal.tex Log Message: Improve examples for working with the context API. Index: libdecimal.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libdecimal.tex,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** libdecimal.tex 12 Jul 2004 13:22:14 -0000 1.13 --- libdecimal.tex 14 Jul 2004 21:06:55 -0000 1.14 *************** *** 180,184 **** >>> float(a) 1.3400000000000001 ! >>> round(a, 1) 1.3 >>> int(a) --- 180,184 ---- >>> float(a) 1.3400000000000001 ! >>> round(a, 1) # round() first converts to binary floating point 1.3 >>> int(a) *************** *** 218,224 **** \begin{verbatim} >>> myothercontext = Context(prec=60, rounding=ROUND_HALF_DOWN) - >>> myothercontext - Context(prec=60, rounding=ROUND_HALF_DOWN, Emin=-999999999, Emax=999999999, - capitals=1, flags=[], traps=[]) >>> setcontext(myothercontext) >>> Decimal(1) / Decimal(7) --- 218,221 ---- *************** *** 856,863 **** \begin{verbatim} # Set applicationwide defaults for all threads about to be launched ! DefaultContext = Context(prec=12, rounding=ROUND_DOWN, traps=[InvalidOperation]) setcontext(DefaultContext) ! # Afterward, the threads can be started t1.start() t2.start() --- 853,863 ---- \begin{verbatim} # Set applicationwide defaults for all threads about to be launched ! DefaultContext.prec = 12 ! DefaultContext.rounding = ROUND_DOWN ! DefaultContext.traps = ExtendedContext.traps.copy() ! DefaultContext.traps[InvalidOperation] = 1 setcontext(DefaultContext) ! # Afterwards, the threads can be started t1.start() t2.start() From barry at python.org Wed Jul 14 23:29:28 2004 From: barry at python.org (Barry Warsaw) Date: Wed Jul 14 23:29:30 2004 Subject: [Python-checkins] python/dist/src/Include object.h,2.126,2.127 In-Reply-To: References: Message-ID: <1089840568.8804.135.camel@localhost> On Wed, 2004-07-14 at 15:08, dcjim@users.sourceforge.net wrote: > Log Message: > Implemented a new Py_CLEAR macro. This macro should be used when > decrementing the refcount of variables that might be accessed as a > result of calling Python Didn't Guido pronounce that it should be Py_ZAP instead? -Barry -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 307 bytes Desc: This is a digitally signed message part Url : http://mail.python.org/pipermail/python-checkins/attachments/20040714/27516bd7/attachment.pgp From akuchling at users.sourceforge.net Wed Jul 14 23:56:21 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Wed Jul 14 23:56:24 2004 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew24.tex, 1.66, 1.67 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16674 Modified Files: whatsnew24.tex Log Message: Bump version; update date Index: whatsnew24.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew24.tex,v retrieving revision 1.66 retrieving revision 1.67 diff -C2 -d -r1.66 -r1.67 *** whatsnew24.tex 12 Jul 2004 13:00:45 -0000 1.66 --- whatsnew24.tex 14 Jul 2004 21:56:19 -0000 1.67 *************** *** 11,15 **** \title{What's New in Python 2.4} ! \release{0.1} \author{A.M.\ Kuchling} \authoraddress{ --- 11,15 ---- \title{What's New in Python 2.4} ! \release{0.2} \author{A.M.\ Kuchling} \authoraddress{ *************** *** 22,27 **** \tableofcontents ! This article explains the new features in Python 2.4 alpha1, scheduled ! for release in early July 2004. The final version of Python 2.4 is expected to be released around September 2004. --- 22,27 ---- \tableofcontents ! This article explains the new features in Python 2.4 alpha2, scheduled ! for release in late July 2004. The final version of Python 2.4 is expected to be released around September 2004. From tim_one at users.sourceforge.net Thu Jul 15 06:06:01 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Thu Jul 15 06:06:05 2004 Subject: [Python-checkins] python/dist/src/Doc/api newtypes.tex,1.32,1.33 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/api In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14504/Doc/api Modified Files: newtypes.tex Log Message: Formalize that the Py_VISIT macro requires that the tp_traverse implementation it's used in must give its arguments specific names. Index: newtypes.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/newtypes.tex,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** newtypes.tex 14 Jul 2004 19:08:17 -0000 1.32 --- newtypes.tex 15 Jul 2004 04:05:59 -0000 1.33 *************** *** 1665,1675 **** To simplify writing \member{tp_traverse} handlers, a ! \cfunction{Py_VISIT()} is provided: \begin{cfuncdesc}{void}{Py_VISIT}{PyObject *o} ! Call the \var{visit} for \var{o} with \var{arg}. If \var{visit} ! returns a non-zero value, then return it. Using this macro, ! \member{tp_traverse} handlers look like: ! \begin{verbatim} --- 1665,1676 ---- To simplify writing \member{tp_traverse} handlers, a ! \cfunction{Py_VISIT()} macro is provided. In order to use this macro, ! the \member{tp_traverse} implementation must name its arguments ! exactly \var{visit} and \var{arg}: \begin{cfuncdesc}{void}{Py_VISIT}{PyObject *o} ! Call the \var{visit} callback, with arguments \var{o} and \var{arg}. ! If \var{visit} returns a non-zero value, then return it. Using this ! macro, \member{tp_traverse} handlers look like: \begin{verbatim} From tim_one at users.sourceforge.net Thu Jul 15 06:06:01 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Thu Jul 15 06:06:06 2004 Subject: [Python-checkins] python/dist/src/Include objimpl.h,2.59,2.60 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14504/Include Modified Files: objimpl.h Log Message: Formalize that the Py_VISIT macro requires that the tp_traverse implementation it's used in must give its arguments specific names. Index: objimpl.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/objimpl.h,v retrieving revision 2.59 retrieving revision 2.60 diff -C2 -d -r2.59 -r2.60 *** objimpl.h 14 Jul 2004 19:08:17 -0000 2.59 --- objimpl.h 15 Jul 2004 04:05:59 -0000 2.60 *************** *** 303,307 **** ! /* Utility macro to help write tp_traverse functions */ #define Py_VISIT(op) \ do { \ --- 303,311 ---- ! /* Utility macro to help write tp_traverse functions. ! * To use this macro, the tp_traverse function must name its arguments ! * "visit" and "arg". This is intended to keep tp_traverse functions ! * looking as much alike as possible. ! */ #define Py_VISIT(op) \ do { \ From tim_one at users.sourceforge.net Thu Jul 15 06:06:01 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Thu Jul 15 06:06:07 2004 Subject: [Python-checkins] python/dist/src/Doc/ext newtypes.tex,1.37,1.38 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/ext In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14504/Doc/ext Modified Files: newtypes.tex Log Message: Formalize that the Py_VISIT macro requires that the tp_traverse implementation it's used in must give its arguments specific names. Index: newtypes.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ext/newtypes.tex,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** newtypes.tex 14 Jul 2004 19:07:24 -0000 1.37 --- newtypes.tex 15 Jul 2004 04:05:59 -0000 1.38 *************** *** 107,111 **** definition above. The remaining fields will be filled with zeros by the C compiler, and it's common practice to not specify them ! explicitly unless you need them. This is so important that we're going to pick the top of it apart still --- 107,111 ---- definition above. The remaining fields will be filled with zeros by the C compiler, and it's common practice to not specify them ! explicitly unless you need them. This is so important that we're going to pick the top of it apart still *************** *** 150,154 **** Note that the name is a dotted name that includes both the module name ! and the name of the type within the module. The module in this case is \module{noddy} and the type is \class{Noddy}, so we set the type name to \class{noddy.Noddy}. --- 150,154 ---- Note that the name is a dotted name that includes both the module name ! and the name of the type within the module. The module in this case is \module{noddy} and the type is \class{Noddy}, so we set the type name to \class{noddy.Noddy}. *************** *** 181,185 **** Skipping a number of type methods that we don't provide, we set the ! class flags to \constant{Py_TPFLAGS_DEFAULT}. \begin{verbatim} --- 181,185 ---- Skipping a number of type methods that we don't provide, we set the ! class flags to \constant{Py_TPFLAGS_DEFAULT}. \begin{verbatim} *************** *** 198,203 **** Now we get into the type methods, the things that make your objects different from the others. We aren't going to implement any of these ! in this version of the module. We'll expand this example later to ! have more interesting behavior. For now, all we want to be able to do is to create new \class{Noddy} --- 198,203 ---- Now we get into the type methods, the things that make your objects different from the others. We aren't going to implement any of these ! in this version of the module. We'll expand this example later to ! have more interesting behavior. For now, all we want to be able to do is to create new \class{Noddy} *************** *** 269,273 **** \subsection{Adding data and methods to the Basic example} ! Let's expend the basic example to add some data and methods. Let's also make the type usable as a base class. We'll create --- 269,273 ---- \subsection{Adding data and methods to the Basic example} ! Let's expend the basic example to add some data and methods. Let's also make the type usable as a base class. We'll create *************** *** 352,356 **** return NULL; } ! self->last = PyString_FromString(""); if (self->last == NULL) --- 352,356 ---- return NULL; } ! self->last = PyString_FromString(""); if (self->last == NULL) *************** *** 418,425 **** static char *kwlist[] = {"first", "last", "number", NULL}; ! if (! PyArg_ParseTupleAndKeywords(args, kwds, "|OOi", kwlist, ! &first, &last, &self->number)) ! return -1; if (first) { --- 418,425 ---- static char *kwlist[] = {"first", "last", "number", NULL}; ! if (! PyArg_ParseTupleAndKeywords(args, kwds, "|OOi", kwlist, ! &first, &last, &self->number)) ! return -1; if (first) { *************** *** 489,493 **** the object from garbage collection, however, these calls are advanced and not covered here.} ! \item \end{itemize} --- 489,493 ---- the object from garbage collection, however, these calls are advanced and not covered here.} ! \item \end{itemize} *************** *** 528,532 **** We define a single method, \method{name}, that outputs the objects ! name as the concatenation of the first and last names. \begin{verbatim} --- 528,532 ---- We define a single method, \method{name}, that outputs the objects ! name as the concatenation of the first and last names. \begin{verbatim} *************** *** 559,563 **** result = PyString_Format(format, args); Py_DECREF(args); ! return result; } --- 559,563 ---- result = PyString_Format(format, args); Py_DECREF(args); ! return result; } *************** *** 657,670 **** return -1; } ! if (! PyString_Check(value)) { ! PyErr_SetString(PyExc_TypeError, "The first attribute value must be a string"); return -1; } ! Py_DECREF(self->first); Py_INCREF(value); ! self->first = value; return 0; --- 657,670 ---- return -1; } ! if (! PyString_Check(value)) { ! PyErr_SetString(PyExc_TypeError, "The first attribute value must be a string"); return -1; } ! Py_DECREF(self->first); Py_INCREF(value); ! self->first = value; return 0; *************** *** 688,696 **** \begin{verbatim} static PyGetSetDef Noddy_getseters[] = { ! {"first", (getter)Noddy_getfirst, (setter)Noddy_setfirst, "first name", NULL}, ! {"last", (getter)Noddy_getlast, (setter)Noddy_setlast, "last name", --- 688,696 ---- \begin{verbatim} static PyGetSetDef Noddy_getseters[] = { ! {"first", (getter)Noddy_getfirst, (setter)Noddy_setfirst, "first name", NULL}, ! {"last", (getter)Noddy_getlast, (setter)Noddy_setlast, "last name", *************** *** 706,710 **** \end{verbatim} ! to register out attribute getters and setters. The last item in a \ctype{PyGetSetDef} structure is the closure --- 706,710 ---- \end{verbatim} ! to register out attribute getters and setters. The last item in a \ctype{PyGetSetDef} structure is the closure *************** *** 738,745 **** static char *kwlist[] = {"first", "last", "number", NULL}; ! if (! PyArg_ParseTupleAndKeywords(args, kwds, "|SSi", kwlist, ! &first, &last, &self->number)) ! return -1; if (first) { --- 738,745 ---- static char *kwlist[] = {"first", "last", "number", NULL}; ! if (! PyArg_ParseTupleAndKeywords(args, kwds, "|SSi", kwlist, ! &first, &last, &self->number)) ! return -1; if (first) { *************** *** 839,847 **** The \cfunction{visit()} function takes as arguments the subobject and the extra argument \var{arg} passed to the traversal method. It ! returns an integer value that must be returned if it is non-zero. ! Python 2.4 and higher provide a \cfunction{Py_VISIT()} that automates ! calling visit functions. With \cfunction{Py_VISIT()}, the \cfunction{Noddy_traverse()} can be simplified: --- 839,847 ---- The \cfunction{visit()} function takes as arguments the subobject and the extra argument \var{arg} passed to the traversal method. It ! returns an integer value that must be returned if it is non-zero. ! Python 2.4 and higher provide a \cfunction{Py_VISIT()} macro that automates ! calling visit functions. With \cfunction{Py_VISIT()}, \cfunction{Noddy_traverse()} can be simplified: *************** *** 857,860 **** --- 857,865 ---- \end{verbatim} + \note{Note that the \member{tp_traverse} implementation must name its + arguments exactly \var{visit} and \var{arg} in order to use + \cfunction{Py_VISIT()}. This is to encourage uniformity + across these boring implementations.} + We also need to provide a method for clearing any subobjects that can participate in cycles. We implement the method and reimplement the *************** *** 862,866 **** \begin{verbatim} ! static int Noddy_clear(Noddy *self) { --- 867,871 ---- \begin{verbatim} ! static int Noddy_clear(Noddy *self) { *************** *** 904,908 **** \begin{verbatim} ! static int Noddy_clear(Noddy *self) { --- 909,913 ---- \begin{verbatim} ! static int Noddy_clear(Noddy *self) { *************** *** 974,978 **** the Python script references \code{obj.__doc__} to retrieve the doc string. ! Now we come to the basic type methods---the ones most extension types will implement. --- 979,983 ---- the Python script references \code{obj.__doc__} to retrieve the doc string. ! Now we come to the basic type methods---the ones most extension types will implement. *************** *** 1282,1286 **** As with the \member{tp_methods} table, a sentinel entry with a ! \member{name} value of \NULL{} is required. --- 1287,1291 ---- As with the \member{tp_methods} table, a sentinel entry with a ! \member{name} value of \NULL{} is required. *************** *** 1346,1350 **** an exception; if this were really all you wanted, the \member{tp_setattr} handler should be set to \NULL. ! \begin{verbatim} static int --- 1351,1355 ---- an exception; if this were really all you wanted, the \member{tp_setattr} handler should be set to \NULL. ! \begin{verbatim} static int *************** *** 1390,1394 **** { long result; ! if (obj1->obj_UnderlyingDatatypePtr->size < obj2->obj_UnderlyingDatatypePtr->size) { --- 1395,1399 ---- { long result; ! if (obj1->obj_UnderlyingDatatypePtr->size < obj2->obj_UnderlyingDatatypePtr->size) { *************** *** 1490,1494 **** saying that keyword arguments are not supported. \end{enumerate} ! Here is a desultory example of the implementation of the call function. --- 1495,1499 ---- saying that keyword arguments are not supported. \end{enumerate} ! Here is a desultory example of the implementation of the call function. From tim_one at users.sourceforge.net Thu Jul 15 06:23:15 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Thu Jul 15 06:23:19 2004 Subject: [Python-checkins] python/dist/src/Doc/ext newtypes.tex,1.38,1.39 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/ext In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16709/Doc/ext Modified Files: newtypes.tex Log Message: s/it's/its/, s/NULL/NULL{}/, where appropriate. Index: newtypes.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ext/newtypes.tex,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** newtypes.tex 15 Jul 2004 04:05:59 -0000 1.38 --- newtypes.tex 15 Jul 2004 04:23:13 -0000 1.39 *************** *** 762,766 **** With these changes, we can assure that the \member{first} and ! \member{last} members are never NULL so we can remove checks for \NULL values in almost all cases. This means that most of the \cfunction{Py_XDECREF()} calls can be converted to \cfunction{Py_DECREF()} --- 762,766 ---- With these changes, we can assure that the \member{first} and ! \member{last} members are never \NULL{} so we can remove checks for \NULL{} values in almost all cases. This means that most of the \cfunction{Py_XDECREF()} calls can be converted to \cfunction{Py_DECREF()} *************** *** 892,897 **** Notice the use of a temporary variable in \cfunction{Noddy_clear()}. ! We use the temporary variable so that we can set each member to \NULL ! before decrementing it's reference count. We do this because, as was discussed earlier, if the reference count drops to zero, we might cause code to run that calls back into the object. In addition, --- 892,897 ---- Notice the use of a temporary variable in \cfunction{Noddy_clear()}. ! We use the temporary variable so that we can set each member to \NULL{} ! before decrementing its reference count. We do this because, as was discussed earlier, if the reference count drops to zero, we might cause code to run that calls back into the object. In addition, *************** *** 900,904 **** collection is run, our \member{tp_traverse} handler could get called. We can't take a chance of having \cfunction{Noddy_traverse()} called ! when a member's reference count has dropped to zero and it's value hasn't been set to \NULL. --- 900,904 ---- collection is run, our \member{tp_traverse} handler could get called. We can't take a chance of having \cfunction{Noddy_traverse()} called ! when a member's reference count has dropped to zero and its value hasn't been set to \NULL. From perky at users.sourceforge.net Thu Jul 15 06:30:28 2004 From: perky at users.sourceforge.net (perky@users.sourceforge.net) Date: Thu Jul 15 06:30:31 2004 Subject: [Python-checkins] python/dist/src/Modules unicodedata.c,2.30,2.31 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17597 Modified Files: unicodedata.c Log Message: Fix typo. Index: unicodedata.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/unicodedata.c,v retrieving revision 2.30 retrieving revision 2.31 diff -C2 -d -r2.30 -r2.31 *** unicodedata.c 17 Apr 2004 19:36:48 -0000 2.30 --- unicodedata.c 15 Jul 2004 04:30:25 -0000 2.31 *************** *** 512,516 **** PyObject *input; ! if(!PyArg_ParseTuple(args, "sO!:normalized", &form, &PyUnicode_Type, &input)) return NULL; --- 512,516 ---- PyObject *input; ! if(!PyArg_ParseTuple(args, "sO!:normalize", &form, &PyUnicode_Type, &input)) return NULL; From kbk at users.sourceforge.net Thu Jul 15 06:54:59 2004 From: kbk at users.sourceforge.net (kbk@users.sourceforge.net) Date: Thu Jul 15 06:55:02 2004 Subject: [Python-checkins] python/dist/src/Lib/idlelib EditorWindow.py, 1.59, 1.60 NEWS.txt, 1.37, 1.38 configHelpSourceEdit.py, 1.6, 1.7 idlever.py, 1.16, 1.17 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/idlelib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20235 Modified Files: EditorWindow.py NEWS.txt configHelpSourceEdit.py idlever.py Log Message: Checking sys.platform for substring 'win' was breaking IDLE docs on Mac (darwin). Also, Mac Safari browser requires full file:// URIs. SF 900580 M EditorWindow.py M NEWS.txt M configHelpSourceEdit.py M idlever.py Index: EditorWindow.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/EditorWindow.py,v retrieving revision 1.59 retrieving revision 1.60 diff -C2 -d -r1.59 -r1.60 *** EditorWindow.py 6 Jun 2004 01:29:21 -0000 1.59 --- EditorWindow.py 15 Jul 2004 04:54:57 -0000 1.60 *************** *** 61,69 **** dochome = os.path.join(basepath, pyver, 'Doc', 'index.html') ! elif sys.platform.count('win') or sys.platform.count('nt'): chmfile = os.path.join(sys.prefix, "Python%d%d.chm" % sys.version_info[:2]) if os.path.isfile(chmfile): dochome = chmfile - print "dochome =", dochome dochome = os.path.normpath(dochome) if os.path.isfile(dochome): --- 61,68 ---- dochome = os.path.join(basepath, pyver, 'Doc', 'index.html') ! elif sys.platform[:3] == 'win': chmfile = os.path.join(sys.prefix, "Python%d%d.chm" % sys.version_info[:2]) if os.path.isfile(chmfile): dochome = chmfile dochome = os.path.normpath(dochome) if os.path.isfile(dochome): *************** *** 315,332 **** def python_docs(self, event=None): ! if sys.platform.count('win') or sys.platform.count('nt'): os.startfile(self.help_url) - return "break" else: webbrowser.open(self.help_url) ! return "break" ! ! def display_docs(self, url): ! if not (url.startswith('www') or url.startswith('http')): ! url = os.path.normpath(url) ! if sys.platform.count('win') or sys.platform.count('nt'): ! os.startfile(url) ! else: ! webbrowser.open(url) def cut(self,event): --- 314,322 ---- def python_docs(self, event=None): ! if sys.platform[:3] == 'win': os.startfile(self.help_url) else: webbrowser.open(self.help_url) ! return "break" def cut(self,event): *************** *** 579,583 **** "Create a callback with the helpfile value frozen at definition time" def display_extra_help(helpfile=helpfile): ! self.display_docs(helpfile) return display_extra_help --- 569,578 ---- "Create a callback with the helpfile value frozen at definition time" def display_extra_help(helpfile=helpfile): ! if not (helpfile.startswith('www') or helpfile.startswith('http')): ! url = os.path.normpath(helpfile) ! if sys.platform[:3] == 'win': ! os.startfile(helpfile) ! else: ! webbrowser.open(helpfile) return display_extra_help Index: NEWS.txt =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/NEWS.txt,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** NEWS.txt 8 Jul 2004 05:59:42 -0000 1.37 --- NEWS.txt 15 Jul 2004 04:54:57 -0000 1.38 *************** *** 1,2 **** --- 1,11 ---- + What's New in IDLE 1.1a2? + ========================= + + *Release date: XX-JUL-2004* + + - checking sys.platform for substring 'win' was breaking IDLE docs on Mac + (darwin). Also, Mac Safari browser requires full file:// URIs. SF 900580. + + What's New in IDLE 1.1a1? ========================= Index: configHelpSourceEdit.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/configHelpSourceEdit.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** configHelpSourceEdit.py 27 Jan 2003 02:36:18 -0000 1.6 --- configHelpSourceEdit.py 15 Jul 2004 04:54:57 -0000 1.7 *************** *** 2,5 **** --- 2,6 ---- import os + import sys from Tkinter import * *************** *** 85,89 **** else: base = None ! if sys.platform.count('win') or sys.platform.count('nt'): dir = os.path.join(os.path.dirname(sys.executable), 'Doc') if not os.path.isdir(dir): --- 86,90 ---- else: base = None ! if sys.platform[:3] == 'win': dir = os.path.join(os.path.dirname(sys.executable), 'Doc') if not os.path.isdir(dir): *************** *** 128,138 **** pathOk = False elif path.startswith('www.') or path.startswith('http'): ! pathOk = True ! elif not os.path.exists(path): ! tkMessageBox.showerror(title='File Path Error', ! message='Help file path does not exist.', ! parent=self) ! self.entryPath.focus_set() ! pathOk = False return pathOk --- 129,142 ---- pathOk = False elif path.startswith('www.') or path.startswith('http'): ! pass ! else: ! if path[:5] == 'file:': ! path = path[5:] ! if not os.path.exists(path): ! tkMessageBox.showerror(title='File Path Error', ! message='Help file path does not exist.', ! parent=self) ! self.entryPath.focus_set() ! pathOk = False return pathOk *************** *** 141,144 **** --- 145,156 ---- self.result = (self.menu.get().strip(), self.path.get().strip()) + if sys.platform == 'darwin': + path = self.result[1] + if (path.startswith('www') or path.startswith('file:') + or path.startswith('http:')): + pass + else: + # Mac Safari insists on using the URI form for local files + self.result[1] = "file://" + path self.destroy() Index: idlever.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/idlever.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** idlever.py 24 Nov 2003 03:23:16 -0000 1.16 --- idlever.py 15 Jul 2004 04:54:57 -0000 1.17 *************** *** 1 **** ! IDLE_VERSION = "1.1a0" --- 1 ---- ! IDLE_VERSION = "1.1a2" From rhettinger at users.sourceforge.net Thu Jul 15 07:32:50 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Thu Jul 15 07:32:53 2004 Subject: [Python-checkins] python/dist/src/Modules itertoolsmodule.c, 1.33, 1.34 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24565 Modified Files: itertoolsmodule.c Log Message: Exercise Jim's VISIT macro. Index: itertoolsmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/itertoolsmodule.c,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** itertoolsmodule.c 8 May 2004 19:49:42 -0000 1.33 --- itertoolsmodule.c 15 Jul 2004 05:32:47 -0000 1.34 *************** *** 65,95 **** groupby_traverse(groupbyobject *gbo, visitproc visit, void *arg) { ! int err; ! ! if (gbo->it) { ! err = visit(gbo->it, arg); ! if (err) ! return err; ! } ! if (gbo->keyfunc) { ! err = visit(gbo->keyfunc, arg); ! if (err) ! return err; ! } ! if (gbo->tgtkey) { ! err = visit(gbo->tgtkey, arg); ! if (err) ! return err; ! } ! if (gbo->currkey) { ! err = visit(gbo->currkey, arg); ! if (err) ! return err; ! } ! if (gbo->currvalue) { ! err = visit(gbo->currvalue, arg); ! if (err) ! return err; ! } return 0; } --- 65,73 ---- groupby_traverse(groupbyobject *gbo, visitproc visit, void *arg) { ! Py_VISIT(gbo->it); ! Py_VISIT(gbo->keyfunc); ! Py_VISIT(gbo->tgtkey); ! Py_VISIT(gbo->currkey); ! Py_VISIT(gbo->currvalue); return 0; } *************** *** 672,687 **** cycle_traverse(cycleobject *lz, visitproc visit, void *arg) { ! int err; ! ! if (lz->it) { ! err = visit(lz->it, arg); ! if (err) ! return err; ! } ! if (lz->saved) { ! err = visit(lz->saved, arg); ! if (err) ! return err; ! } return 0; } --- 650,655 ---- cycle_traverse(cycleobject *lz, visitproc visit, void *arg) { ! Py_VISIT(lz->it); ! Py_VISIT(lz->saved); return 0; } *************** *** 821,836 **** dropwhile_traverse(dropwhileobject *lz, visitproc visit, void *arg) { ! int err; ! ! if (lz->it) { ! err = visit(lz->it, arg); ! if (err) ! return err; ! } ! if (lz->func) { ! err = visit(lz->func, arg); ! if (err) ! return err; ! } return 0; } --- 789,794 ---- dropwhile_traverse(dropwhileobject *lz, visitproc visit, void *arg) { ! Py_VISIT(lz->it); ! Py_VISIT(lz->func); return 0; } *************** *** 972,987 **** takewhile_traverse(takewhileobject *lz, visitproc visit, void *arg) { ! int err; ! ! if (lz->it) { ! err = visit(lz->it, arg); ! if (err) ! return err; ! } ! if (lz->func) { ! err = visit(lz->func, arg); ! if (err) ! return err; ! } return 0; } --- 930,935 ---- takewhile_traverse(takewhileobject *lz, visitproc visit, void *arg) { ! Py_VISIT(lz->it); ! Py_VISIT(lz->func); return 0; } *************** *** 1168,1173 **** islice_traverse(isliceobject *lz, visitproc visit, void *arg) { ! if (lz->it) ! return visit(lz->it, arg); return 0; } --- 1116,1120 ---- islice_traverse(isliceobject *lz, visitproc visit, void *arg) { ! Py_VISIT(lz->it); return 0; } *************** *** 1310,1325 **** starmap_traverse(starmapobject *lz, visitproc visit, void *arg) { ! int err; ! ! if (lz->it) { ! err = visit(lz->it, arg); ! if (err) ! return err; ! } ! if (lz->func) { ! err = visit(lz->func, arg); ! if (err) ! return err; ! } return 0; } --- 1257,1262 ---- starmap_traverse(starmapobject *lz, visitproc visit, void *arg) { ! Py_VISIT(lz->it); ! Py_VISIT(lz->func); return 0; } *************** *** 1463,1478 **** imap_traverse(imapobject *lz, visitproc visit, void *arg) { ! int err; ! ! if (lz->iters) { ! err = visit(lz->iters, arg); ! if (err) ! return err; ! } ! if (lz->func) { ! err = visit(lz->func, arg); ! if (err) ! return err; ! } return 0; } --- 1400,1405 ---- imap_traverse(imapobject *lz, visitproc visit, void *arg) { ! Py_VISIT(lz->iters); ! Py_VISIT(lz->func); return 0; } *************** *** 1649,1654 **** chain_traverse(chainobject *lz, visitproc visit, void *arg) { ! if (lz->ittuple) ! return visit(lz->ittuple, arg); return 0; } --- 1576,1580 ---- chain_traverse(chainobject *lz, visitproc visit, void *arg) { ! Py_VISIT(lz->ittuple); return 0; } *************** *** 1779,1794 **** ifilter_traverse(ifilterobject *lz, visitproc visit, void *arg) { ! int err; ! ! if (lz->it) { ! err = visit(lz->it, arg); ! if (err) ! return err; ! } ! if (lz->func) { ! err = visit(lz->func, arg); ! if (err) ! return err; ! } return 0; } --- 1705,1710 ---- ifilter_traverse(ifilterobject *lz, visitproc visit, void *arg) { ! Py_VISIT(lz->it); ! Py_VISIT(lz->func); return 0; } *************** *** 1930,1945 **** ifilterfalse_traverse(ifilterfalseobject *lz, visitproc visit, void *arg) { ! int err; ! ! if (lz->it) { ! err = visit(lz->it, arg); ! if (err) ! return err; ! } ! if (lz->func) { ! err = visit(lz->func, arg); ! if (err) ! return err; ! } return 0; } --- 1846,1851 ---- ifilterfalse_traverse(ifilterfalseobject *lz, visitproc visit, void *arg) { ! Py_VISIT(lz->it); ! Py_VISIT(lz->func); return 0; } *************** *** 2200,2215 **** izip_traverse(izipobject *lz, visitproc visit, void *arg) { ! int err; ! ! if (lz->ittuple) { ! err = visit(lz->ittuple, arg); ! if (err) ! return err; ! } ! if (lz->result) { ! err = visit(lz->result, arg); ! if (err) ! return err; ! } return 0; } --- 2106,2111 ---- izip_traverse(izipobject *lz, visitproc visit, void *arg) { ! Py_VISIT(lz->ittuple); ! Py_VISIT(lz->result); return 0; } *************** *** 2358,2363 **** repeat_traverse(repeatobject *ro, visitproc visit, void *arg) { ! if (ro->element) ! return visit(ro->element, arg); return 0; } --- 2254,2258 ---- repeat_traverse(repeatobject *ro, visitproc visit, void *arg) { ! Py_VISIT(ro->element); return 0; } From tim_one at users.sourceforge.net Thu Jul 15 07:46:40 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Thu Jul 15 07:46:43 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libos.tex,1.137,1.138 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25712/Doc/lib Modified Files: libos.tex Log Message: SF bug 990749: os constants missing A LaTeX comment identified the 6 os.O_XXX constants the docs claimed are available on Windows but aren't. The bug report listed the same 6. Split these non-Windows constants into a different table with a possibly correct "Availability:" claim. Index: libos.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libos.tex,v retrieving revision 1.137 retrieving revision 1.138 diff -C2 -d -r1.137 -r1.138 *** libos.tex 8 Jun 2004 08:29:32 -0000 1.137 --- libos.tex 15 Jul 2004 05:46:37 -0000 1.138 *************** *** 587,597 **** \dataline{O_WRONLY} \dataline{O_RDWR} - \dataline{O_NDELAY} - \dataline{O_NONBLOCK} \dataline{O_APPEND} - \dataline{O_DSYNC} - \dataline{O_RSYNC} - \dataline{O_SYNC} - \dataline{O_NOCTTY} \dataline{O_CREAT} \dataline{O_EXCL} --- 587,591 ---- *************** *** 600,604 **** These can be bit-wise OR'd together. Availability: Macintosh, \UNIX, Windows. ! % XXX O_NDELAY, O_NONBLOCK, O_DSYNC, O_RSYNC, O_SYNC, O_NOCTTY are not on Windows. \end{datadesc} --- 594,607 ---- These can be bit-wise OR'd together. Availability: Macintosh, \UNIX, Windows. ! \end{datadesc} ! ! begin{datadesc}{O_DSYNC} ! \dataline{O_RSYNC} ! \dataline{O_SYNC} ! \dataline{O_NDELAY} ! \dataline{O_NONBLOCK} ! \dataline{O_NOCTTY} ! More options for the \var{flag} argument to the \function{open()} function. ! Availability: Macintosh, \UNIX. \end{datadesc} From akuchling at users.sourceforge.net Thu Jul 15 13:44:44 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Thu Jul 15 13:44:48 2004 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew24.tex, 1.67, 1.68 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16188 Modified Files: whatsnew24.tex Log Message: Correct a paragraph: basicConfig() isn't actually new Index: whatsnew24.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew24.tex,v retrieving revision 1.67 retrieving revision 1.68 diff -C2 -d -r1.67 -r1.68 *** whatsnew24.tex 14 Jul 2004 21:56:19 -0000 1.67 --- whatsnew24.tex 15 Jul 2004 11:44:42 -0000 1.68 *************** *** 1,2 **** --- 1,3 ---- + \documentclass{howto} \usepackage{distutils} *************** *** 786,795 **** bookmarking, windowing, or lookahead iterators. ! \item A \function{basicConfig} function was added to the ! \module{logging} package to simplify log configuration. It defaults ! to logging to standard error, but a ! number of optional keyword arguments can be specified to ! log to a particular file, change the logging format, or set the ! logging level. For example: \begin{verbatim} --- 787,795 ---- bookmarking, windowing, or lookahead iterators. ! \item The \module{logging} package's \function{basicConfig} function ! gained some keyword arguments to simplify log configuration. The ! default behavior is to log messages to standard error, but ! various keyword arguments can be specified to log to a particular file, ! change the logging format, or set the logging level. For example: \begin{verbatim} From akuchling at users.sourceforge.net Thu Jul 15 13:52:43 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Thu Jul 15 13:52:47 2004 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew24.tex, 1.68, 1.69 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16985 Modified Files: whatsnew24.tex Log Message: Add thread-local feature Index: whatsnew24.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew24.tex,v retrieving revision 1.68 retrieving revision 1.69 diff -C2 -d -r1.68 -r1.69 *** whatsnew24.tex 15 Jul 2004 11:44:42 -0000 1.68 --- whatsnew24.tex 15 Jul 2004 11:52:40 -0000 1.69 *************** *** 848,851 **** --- 848,868 ---- % XXX sre is now non-recursive. + \item The \module{threading} module now has an elegantly simple way to support + thread-local data. The module contains a \class{local} class whose + attribute values are local to different threads. + + \begin{verbatim} + import threading + + data = threading.local() + data.number = 42 + data.url = ('www.python.org', 80) + \end{verbatim} + + Other threads can assign and retrieve their own values for the + \member{number} and \member{url} attributes. You can subclass + \class{local} to initialize attributes or to add methods. + (Contributed by Jim Fulton.) + \item The \module{weakref} module now supports a wider variety of objects including Python functions, class instances, sets, frozensets, deques, *************** *** 853,857 **** \item The \module{xmlrpclib} module now supports a multi-call extension for ! tranmitting multiple XML-RPC calls in a single HTTP operation. \end{itemize} --- 870,874 ---- \item The \module{xmlrpclib} module now supports a multi-call extension for ! transmitting multiple XML-RPC calls in a single HTTP operation. \end{itemize} From akuchling at users.sourceforge.net Thu Jul 15 14:17:45 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Thu Jul 15 14:17:49 2004 Subject: [Python-checkins] python/dist/src/Lib _threading_local.py,1.1,1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21062 Modified Files: _threading_local.py Log Message: Typo fixes Index: _threading_local.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/_threading_local.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** _threading_local.py 14 Jul 2004 19:07:15 -0000 1.1 --- _threading_local.py 15 Jul 2004 12:17:26 -0000 1.2 *************** *** 2,6 **** (Note that this module provides a Python version of thread ! threading.local class. Deoending on the version of Python you're using, there may be a faster one available. You should always import the local class from threading.) --- 2,6 ---- (Note that this module provides a Python version of thread ! threading.local class. Depending on the version of Python you're using, there may be a faster one available. You should always import the local class from threading.) *************** *** 8,12 **** Thread-local objects support the management of thread-local data. If you have data that you want to be local to a thread, simply create ! a thread-local object and use it's attributes: >>> mydata = local() --- 8,12 ---- Thread-local objects support the management of thread-local data. If you have data that you want to be local to a thread, simply create ! a thread-local object and use its attributes: >>> mydata = local() *************** *** 101,105 **** [[('color', 'red'), ('initialized', True)], 11] ! without effecting this threads data: >>> mydata.number --- 101,105 ---- [[('color', 'red'), ('initialized', True)], 11] ! without affecting this thread's data: >>> mydata.number *************** *** 230,234 **** del __dict__[key] except KeyError: ! pass # didn't have nything in this thread return __del__ --- 230,234 ---- del __dict__[key] except KeyError: ! pass # didn't have anything in this thread return __del__ From jackjansen at users.sourceforge.net Thu Jul 15 15:21:19 2004 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Thu Jul 15 15:21:21 2004 Subject: [Python-checkins] python/dist/src/Mac/Modules OSATerminology.c, 1.4, 1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31245/Mac/Modules Modified Files: OSATerminology.c Log Message: Get rid of incorrect use of OSAGetCurrentDialect. Fixes #884085. Index: OSATerminology.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/OSATerminology.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** OSATerminology.c 20 Nov 2003 13:30:55 -0000 1.4 --- OSATerminology.c 15 Jul 2004 13:21:16 -0000 1.5 *************** *** 29,34 **** err = GetComponentInstanceError (defaultComponent); if (err) return PyMac_Error(err); - err = OSAGetCurrentDialect(defaultComponent, &defaultTerminology); - if (err) return PyMac_Error(err); err = OSAGetAppTerminology ( defaultComponent, --- 29,32 ---- *************** *** 60,65 **** err = GetComponentInstanceError (defaultComponent); if (err) return PyMac_Error(err); - err = OSAGetCurrentDialect(defaultComponent, &defaultTerminology); - if (err) return PyMac_Error(err); err = OSAGetAppTerminology ( defaultComponent, --- 58,61 ---- From jackjansen at users.sourceforge.net Thu Jul 15 15:22:04 2004 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Thu Jul 15 15:22:06 2004 Subject: [Python-checkins] python/dist/src/Mac/Modules OSATerminology.c, 1.2, 1.2.14.1 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32306/Mac/Modules Modified Files: Tag: release23-maint OSATerminology.c Log Message: Backport of 1.5: Get rid of incorrect use of OSAGetCurrentDialect. Fixes #884085. Index: OSATerminology.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/OSATerminology.c,v retrieving revision 1.2 retrieving revision 1.2.14.1 diff -C2 -d -r1.2 -r1.2.14.1 *** OSATerminology.c 6 Mar 2003 23:02:59 -0000 1.2 --- OSATerminology.c 15 Jul 2004 13:22:02 -0000 1.2.14.1 *************** *** 33,38 **** err = GetComponentInstanceError (defaultComponent); if (err) return PyMac_Error(err); - err = OSAGetCurrentDialect(defaultComponent, &defaultTerminology); - if (err) return PyMac_Error(err); err = OSAGetAppTerminology ( defaultComponent, --- 33,36 ---- *************** *** 64,69 **** err = GetComponentInstanceError (defaultComponent); if (err) return PyMac_Error(err); - err = OSAGetCurrentDialect(defaultComponent, &defaultTerminology); - if (err) return PyMac_Error(err); err = OSAGetAppTerminology ( defaultComponent, --- 62,65 ---- From jackjansen at users.sourceforge.net Thu Jul 15 15:31:41 2004 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Thu Jul 15 15:31:44 2004 Subject: [Python-checkins] python/dist/src/Include pymactoolbox.h,1.10,1.11 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1637/Include Modified Files: pymactoolbox.h Log Message: Moved PyMac_GetScript() to _localemodule, which is the only place where it is used, and made it private. Should fix #978662. Index: pymactoolbox.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/pymactoolbox.h,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** pymactoolbox.h 20 Nov 2003 13:28:19 -0000 1.10 --- pymactoolbox.h 15 Jul 2004 13:31:39 -0000 1.11 *************** *** 14,18 **** ** Helper routines for error codes and such. */ - char *PyMac_getscript(void); /* Get the default encoding for our 8bit character set */ char *PyMac_StrError(int); /* strerror with mac errors */ extern PyObject *PyMac_OSErrException; /* Exception for OSErr */ --- 14,17 ---- From jackjansen at users.sourceforge.net Thu Jul 15 15:31:41 2004 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Thu Jul 15 15:31:45 2004 Subject: [Python-checkins] python/dist/src/Python mactoolboxglue.c, 1.22, 1.23 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1637/Python Modified Files: mactoolboxglue.c Log Message: Moved PyMac_GetScript() to _localemodule, which is the only place where it is used, and made it private. Should fix #978662. Index: mactoolboxglue.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/mactoolboxglue.c,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** mactoolboxglue.c 19 Nov 2003 16:34:03 -0000 1.22 --- mactoolboxglue.c 15 Jul 2004 13:31:39 -0000 1.23 *************** *** 28,55 **** - /* - ** Find out what the current script is. - ** Donated by Fredrik Lund. - */ - char *PyMac_getscript() - { - CFStringEncoding enc = CFStringGetSystemEncoding(); - static CFStringRef name = NULL; - /* Return the code name for the encodings for which we have codecs. */ - switch(enc) { - case kCFStringEncodingMacRoman: return "mac-roman"; - case kCFStringEncodingMacGreek: return "mac-greek"; - case kCFStringEncodingMacCyrillic: return "mac-cyrillic"; - case kCFStringEncodingMacTurkish: return "mac-turkish"; - case kCFStringEncodingMacIcelandic: return "mac-icelandic"; - /* XXX which one is mac-latin2? */ - } - if (!name) { - /* This leaks a an object. */ - name = CFStringConvertEncodingToIANACharSetName(enc); - } - return (char *)CFStringGetCStringPtr(name, 0); - } - /* Like strerror() but for Mac OS error numbers */ char *PyMac_StrError(int err) --- 28,31 ---- From jackjansen at users.sourceforge.net Thu Jul 15 15:31:42 2004 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Thu Jul 15 15:31:47 2004 Subject: [Python-checkins] python/dist/src/Modules _localemodule.c, 2.46, 2.47 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1637/Modules Modified Files: _localemodule.c Log Message: Moved PyMac_GetScript() to _localemodule, which is the only place where it is used, and made it private. Should fix #978662. Index: _localemodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_localemodule.c,v retrieving revision 2.46 retrieving revision 2.47 diff -C2 -d -r2.46 -r2.47 *** _localemodule.c 8 Jun 2004 18:52:52 -0000 2.46 --- _localemodule.c 15 Jul 2004 13:31:39 -0000 2.47 *************** *** 31,35 **** #if defined(__APPLE__) ! #include "pymactoolbox.h" #endif --- 31,35 ---- #if defined(__APPLE__) ! #include #endif *************** *** 407,414 **** #if defined(__APPLE__) static PyObject* PyLocale_getdefaultlocale(PyObject* self) { ! return Py_BuildValue("Os", Py_None, PyMac_getscript()); } #endif --- 407,438 ---- #if defined(__APPLE__) + /* + ** Find out what the current script is. + ** Donated by Fredrik Lund. + */ + static char *mac_getscript(void) + { + CFStringEncoding enc = CFStringGetSystemEncoding(); + static CFStringRef name = NULL; + /* Return the code name for the encodings for which we have codecs. */ + switch(enc) { + case kCFStringEncodingMacRoman: return "mac-roman"; + case kCFStringEncodingMacGreek: return "mac-greek"; + case kCFStringEncodingMacCyrillic: return "mac-cyrillic"; + case kCFStringEncodingMacTurkish: return "mac-turkish"; + case kCFStringEncodingMacIcelandic: return "mac-icelandic"; + /* XXX which one is mac-latin2? */ + } + if (!name) { + /* This leaks a an object. */ + name = CFStringConvertEncodingToIANACharSetName(enc); + } + return (char *)CFStringGetCStringPtr(name, 0); + } + static PyObject* PyLocale_getdefaultlocale(PyObject* self) { ! return Py_BuildValue("Os", Py_None, mac_getscript()); } #endif From jackjansen at users.sourceforge.net Thu Jul 15 15:42:14 2004 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Thu Jul 15 15:42:19 2004 Subject: [Python-checkins] python/dist/src/Mac/Modules/cf _CFmodule.c, 1.24, 1.25 cfsupport.py, 1.24, 1.25 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/cf In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3852 Modified Files: _CFmodule.c cfsupport.py Log Message: Make CF module PEP253 based (finally). Index: _CFmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/cf/_CFmodule.c,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** _CFmodule.c 20 Nov 2003 13:30:56 -0000 1.24 --- _CFmodule.c 15 Jul 2004 13:42:06 -0000 1.25 *************** *** 160,164 **** self->ob_freeit((CFTypeRef)self->ob_itself); } ! PyObject_Free((PyObject *)self); } --- 160,164 ---- self->ob_freeit((CFTypeRef)self->ob_itself); } ! self->ob_type->tp_free((PyObject *)self); } [...1315 lines suppressed...] CFStringRef_Type.ob_type = &PyType_Type; + CFStringRef_Type.tp_base = &CFTypeRef_Type; if (PyType_Ready(&CFStringRef_Type) < 0) return; Py_INCREF(&CFStringRef_Type); *************** *** 4415,4418 **** --- 4944,4948 ---- PyModule_AddObject(m, "CFStringRefType", (PyObject *)&CFStringRef_Type); CFMutableStringRef_Type.ob_type = &PyType_Type; + CFMutableStringRef_Type.tp_base = &CFStringRef_Type; if (PyType_Ready(&CFMutableStringRef_Type) < 0) return; Py_INCREF(&CFMutableStringRef_Type); *************** *** 4422,4425 **** --- 4952,4956 ---- PyModule_AddObject(m, "CFMutableStringRefType", (PyObject *)&CFMutableStringRef_Type); CFURLRef_Type.ob_type = &PyType_Type; + CFURLRef_Type.tp_base = &CFTypeRef_Type; if (PyType_Ready(&CFURLRef_Type) < 0) return; Py_INCREF(&CFURLRef_Type); Index: cfsupport.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/cf/cfsupport.py,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** cfsupport.py 19 Nov 2003 16:13:24 -0000 1.24 --- cfsupport.py 15 Jul 2004 13:42:06 -0000 1.25 *************** *** 251,255 **** # Our (opaque) objects ! class MyGlobalObjectDefinition(GlobalObjectDefinition): def outputCheckNewArg(self): Output('if (itself == NULL)') --- 251,255 ---- # Our (opaque) objects ! class MyGlobalObjectDefinition(PEP253Mixin, GlobalObjectDefinition): def outputCheckNewArg(self): Output('if (itself == NULL)') *************** *** 303,311 **** OutRbrace() class CFTypeRefObjectDefinition(MyGlobalObjectDefinition): pass class CFArrayRefObjectDefinition(MyGlobalObjectDefinition): ! basechain = "&CFTypeRefObj_chain" def outputRepr(self): --- 303,339 ---- OutRbrace() + def output_tp_newBody(self): + Output("PyObject *self;") + Output + Output("if ((self = type->tp_alloc(type, 0)) == NULL) return NULL;") + Output("((%s *)self)->ob_itself = NULL;", self.objecttype) + Output("((%s *)self)->ob_freeit = CFRelease;", self.objecttype) + Output("return self;") + + def output_tp_initBody(self): + Output("%s itself;", self.itselftype) + Output("char *kw[] = {\"itself\", 0};") + Output() + Output("if (PyArg_ParseTupleAndKeywords(args, kwds, \"O&\", kw, %s_Convert, &itself))", + self.prefix) + OutLbrace() + Output("((%s *)self)->ob_itself = itself;", self.objecttype) + Output("return 0;") + OutRbrace() + if self.prefix != 'CFTypeRefObj': + Output() + Output("/* Any CFTypeRef descendent is allowed as initializer too */") + Output("if (PyArg_ParseTupleAndKeywords(args, kwds, \"O&\", kw, CFTypeRefObj_Convert, &itself))") + OutLbrace() + Output("((%s *)self)->ob_itself = itself;", self.objecttype) + Output("return 0;") + OutRbrace() + Output("return -1;") + class CFTypeRefObjectDefinition(MyGlobalObjectDefinition): pass class CFArrayRefObjectDefinition(MyGlobalObjectDefinition): ! basetype = "CFTypeRef_Type" def outputRepr(self): *************** *** 319,323 **** class CFMutableArrayRefObjectDefinition(MyGlobalObjectDefinition): ! basechain = "&CFArrayRefObj_chain" def outputRepr(self): --- 347,351 ---- class CFMutableArrayRefObjectDefinition(MyGlobalObjectDefinition): ! basetype = "CFArrayRef_Type" def outputRepr(self): *************** *** 331,335 **** class CFDictionaryRefObjectDefinition(MyGlobalObjectDefinition): ! basechain = "&CFTypeRefObj_chain" def outputRepr(self): --- 359,363 ---- class CFDictionaryRefObjectDefinition(MyGlobalObjectDefinition): ! basetype = "CFTypeRef_Type" def outputRepr(self): *************** *** 343,347 **** class CFMutableDictionaryRefObjectDefinition(MyGlobalObjectDefinition): ! basechain = "&CFDictionaryRefObj_chain" def outputRepr(self): --- 371,375 ---- class CFMutableDictionaryRefObjectDefinition(MyGlobalObjectDefinition): ! basetype = "CFDictionaryRef_Type" def outputRepr(self): *************** *** 355,359 **** class CFDataRefObjectDefinition(MyGlobalObjectDefinition): ! basechain = "&CFTypeRefObj_chain" def outputCheckConvertArg(self): --- 383,387 ---- class CFDataRefObjectDefinition(MyGlobalObjectDefinition): ! basetype = "CFTypeRef_Type" def outputCheckConvertArg(self): *************** *** 379,383 **** class CFMutableDataRefObjectDefinition(MyGlobalObjectDefinition): ! basechain = "&CFDataRefObj_chain" def outputRepr(self): --- 407,411 ---- class CFMutableDataRefObjectDefinition(MyGlobalObjectDefinition): ! basetype = "CFDataRef_Type" def outputRepr(self): *************** *** 391,395 **** class CFStringRefObjectDefinition(MyGlobalObjectDefinition): ! basechain = "&CFTypeRefObj_chain" def outputCheckConvertArg(self): --- 419,423 ---- class CFStringRefObjectDefinition(MyGlobalObjectDefinition): ! basetype = "CFTypeRef_Type" def outputCheckConvertArg(self): *************** *** 424,428 **** class CFMutableStringRefObjectDefinition(CFStringRefObjectDefinition): ! basechain = "&CFStringRefObj_chain" def outputCheckConvertArg(self): --- 452,456 ---- class CFMutableStringRefObjectDefinition(CFStringRefObjectDefinition): ! basetype = "CFStringRef_Type" def outputCheckConvertArg(self): *************** *** 440,444 **** class CFURLRefObjectDefinition(MyGlobalObjectDefinition): ! basechain = "&CFTypeRefObj_chain" def outputRepr(self): --- 468,472 ---- class CFURLRefObjectDefinition(MyGlobalObjectDefinition): ! basetype = "CFTypeRef_Type" def outputRepr(self): From jackjansen at users.sourceforge.net Thu Jul 15 16:11:33 2004 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Thu Jul 15 16:11:35 2004 Subject: [Python-checkins] python/dist/src/Mac/Modules/cf _CFmodule.c, 1.25, 1.26 cfsupport.py, 1.25, 1.26 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/cf In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9228 Modified Files: _CFmodule.c cfsupport.py Log Message: CFStringGetUnicode() returned an extra null character at the end of the string. fixed. Index: _CFmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/cf/_CFmodule.c,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** _CFmodule.c 15 Jul 2004 13:42:06 -0000 1.25 --- _CFmodule.c 15 Jul 2004 14:11:30 -0000 1.26 *************** *** 2350,2354 **** if( data == NULL ) return PyErr_NoMemory(); CFStringGetCharacters(_self->ob_itself, range, data); ! _res = (PyObject *)PyUnicode_FromUnicode(data, size); free(data); return _res; --- 2350,2354 ---- if( data == NULL ) return PyErr_NoMemory(); CFStringGetCharacters(_self->ob_itself, range, data); ! _res = (PyObject *)PyUnicode_FromUnicode(data, size-1); free(data); return _res; Index: cfsupport.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/cf/cfsupport.py,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** cfsupport.py 15 Jul 2004 13:42:06 -0000 1.25 --- cfsupport.py 15 Jul 2004 14:11:30 -0000 1.26 *************** *** 576,580 **** if( data == NULL ) return PyErr_NoMemory(); CFStringGetCharacters(_self->ob_itself, range, data); ! _res = (PyObject *)PyUnicode_FromUnicode(data, size); free(data); return _res; --- 576,580 ---- if( data == NULL ) return PyErr_NoMemory(); CFStringGetCharacters(_self->ob_itself, range, data); ! _res = (PyObject *)PyUnicode_FromUnicode(data, size-1); free(data); return _res; From jackjansen at users.sourceforge.net Thu Jul 15 16:12:23 2004 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Thu Jul 15 16:12:26 2004 Subject: [Python-checkins] python/dist/src/Mac/Modules/cf _CFmodule.c, 1.22, 1.22.8.1 cfsupport.py, 1.23, 1.23.8.1 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/cf In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9438 Modified Files: Tag: release23-maint _CFmodule.c cfsupport.py Log Message: Backport of 1.26: CFStringGetUnicode() returned an extra null character at the end of the string. fixed. Index: _CFmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/cf/_CFmodule.c,v retrieving revision 1.22 retrieving revision 1.22.8.1 diff -C2 -d -r1.22 -r1.22.8.1 *** _CFmodule.c 31 May 2003 22:09:33 -0000 1.22 --- _CFmodule.c 15 Jul 2004 14:12:20 -0000 1.22.8.1 *************** *** 6,15 **** - #ifdef _WIN32 - #include "pywintoolbox.h" - #else - #include "macglue.h" #include "pymactoolbox.h" - #endif /* Macro to test whether a weak-loaded CFM function exists */ --- 6,10 ---- *************** *** 2002,2006 **** if( data == NULL ) return PyErr_NoMemory(); CFStringGetCharacters(_self->ob_itself, range, data); ! _res = (PyObject *)PyUnicode_FromUnicode(data, size); free(data); return _res; --- 1997,2001 ---- if( data == NULL ) return PyErr_NoMemory(); CFStringGetCharacters(_self->ob_itself, range, data); ! _res = (PyObject *)PyUnicode_FromUnicode(data, size-1); free(data); return _res; Index: cfsupport.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/cf/cfsupport.py,v retrieving revision 1.23 retrieving revision 1.23.8.1 diff -C2 -d -r1.23 -r1.23.8.1 *** cfsupport.py 31 May 2003 22:09:33 -0000 1.23 --- cfsupport.py 15 Jul 2004 14:12:20 -0000 1.23.8.1 *************** *** 559,563 **** if( data == NULL ) return PyErr_NoMemory(); CFStringGetCharacters(_self->ob_itself, range, data); ! _res = (PyObject *)PyUnicode_FromUnicode(data, size); free(data); return _res; --- 559,563 ---- if( data == NULL ) return PyErr_NoMemory(); CFStringGetCharacters(_self->ob_itself, range, data); ! _res = (PyObject *)PyUnicode_FromUnicode(data, size-1); free(data); return _res; From jackjansen at users.sourceforge.net Thu Jul 15 16:25:51 2004 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Thu Jul 15 16:25:53 2004 Subject: [Python-checkins] python/dist/src/Mac/Modules/cf _CFmodule.c, 1.26, 1.27 cfsupport.py, 1.26, 1.27 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/cf In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12053 Modified Files: _CFmodule.c cfsupport.py Log Message: The CF inheritance could cause double frees of the underlying objects. Fixed. Index: _CFmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/cf/_CFmodule.c,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** _CFmodule.c 15 Jul 2004 14:11:30 -0000 1.26 --- _CFmodule.c 15 Jul 2004 14:25:48 -0000 1.27 *************** *** 159,162 **** --- 159,163 ---- { self->ob_freeit((CFTypeRef)self->ob_itself); + self->ob_itself = NULL; } self->ob_type->tp_free((PyObject *)self); *************** *** 520,523 **** --- 521,525 ---- { self->ob_freeit((CFTypeRef)self->ob_itself); + self->ob_itself = NULL; } self->ob_type->tp_base->tp_dealloc((PyObject *)self); *************** *** 729,732 **** --- 731,735 ---- { self->ob_freeit((CFTypeRef)self->ob_itself); + self->ob_itself = NULL; } self->ob_type->tp_base->tp_dealloc((PyObject *)self); *************** *** 967,970 **** --- 970,974 ---- { self->ob_freeit((CFTypeRef)self->ob_itself); + self->ob_itself = NULL; } self->ob_type->tp_base->tp_dealloc((PyObject *)self); *************** *** 1158,1161 **** --- 1162,1166 ---- { self->ob_freeit((CFTypeRef)self->ob_itself); + self->ob_itself = NULL; } self->ob_type->tp_base->tp_dealloc((PyObject *)self); *************** *** 1339,1342 **** --- 1344,1348 ---- { self->ob_freeit((CFTypeRef)self->ob_itself); + self->ob_itself = NULL; } self->ob_type->tp_base->tp_dealloc((PyObject *)self); *************** *** 1562,1565 **** --- 1568,1572 ---- { self->ob_freeit((CFTypeRef)self->ob_itself); + self->ob_itself = NULL; } self->ob_type->tp_base->tp_dealloc((PyObject *)self); *************** *** 1840,1843 **** --- 1847,1851 ---- { self->ob_freeit((CFTypeRef)self->ob_itself); + self->ob_itself = NULL; } self->ob_type->tp_base->tp_dealloc((PyObject *)self); *************** *** 2565,2568 **** --- 2573,2577 ---- { self->ob_freeit((CFTypeRef)self->ob_itself); + self->ob_itself = NULL; } self->ob_type->tp_base->tp_dealloc((PyObject *)self); *************** *** 2951,2954 **** --- 2960,2964 ---- { self->ob_freeit((CFTypeRef)self->ob_itself); + self->ob_itself = NULL; } self->ob_type->tp_base->tp_dealloc((PyObject *)self); Index: cfsupport.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/cf/cfsupport.py,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** cfsupport.py 15 Jul 2004 14:11:30 -0000 1.26 --- cfsupport.py 15 Jul 2004 14:25:48 -0000 1.27 *************** *** 274,277 **** --- 274,278 ---- OutLbrace() Output("self->ob_freeit((CFTypeRef)self->ob_itself);") + Output("self->ob_itself = NULL;") OutRbrace() From jackjansen at users.sourceforge.net Thu Jul 15 17:06:10 2004 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Thu Jul 15 17:06:13 2004 Subject: [Python-checkins] python/dist/src/Lib/plat-mac bgenlocations.py, 1.6, 1.7 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/plat-mac In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19900 Modified Files: bgenlocations.py Log Message: Allow overriding of bgen pathnames in an optional module bgenlocationcustomize. Editing of bgenlocations.py isn't easy if your Python was supplied by Apple. Index: bgenlocations.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/bgenlocations.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** bgenlocations.py 19 Nov 2003 16:12:08 -0000 1.6 --- bgenlocations.py 15 Jul 2004 15:06:07 -0000 1.7 *************** *** 32,35 **** --- 32,43 ---- CREATOR="CWIE" + # The previous definitions can be overriden by creating a module + # bgenlocationscustomize.py and putting it in site-packages (or anywere else + # on sys.path, actually) + try: + from bgenlocationscustomize import * + except ImportError: + pass + if not os.path.exists(BGENDIR): raise Error, "Please fix bgenlocations.py, BGENDIR does not exist: %s" % BGENDIR From mondragon at users.sourceforge.net Thu Jul 15 17:54:07 2004 From: mondragon at users.sourceforge.net (mondragon@users.sourceforge.net) Date: Thu Jul 15 17:54:11 2004 Subject: [Python-checkins] python/dist/src/Include pyport.h,2.67,2.68 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28803/Include Modified Files: pyport.h Log Message: Moved SunPro warning suppression into pyport.h and out of individual modules and objects. Index: pyport.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/pyport.h,v retrieving revision 2.67 retrieving revision 2.68 diff -C2 -d -r2.67 -r2.68 *** pyport.h 22 Mar 2004 08:43:55 -0000 2.67 --- pyport.h 15 Jul 2004 15:54:03 -0000 2.68 *************** *** 580,582 **** --- 580,589 ---- #endif + /* Eliminate end-of-loop code not reached warnings from SunPro C + * when using do{...}while(0) macros + */ + #ifdef __SUNPRO_C + #pragma error_messages (off,E_END_OF_LOOP_CODE_NOT_REACHED) + #endif + #endif /* Py_PYPORT_H */ From mondragon at users.sourceforge.net Thu Jul 15 17:54:08 2004 From: mondragon at users.sourceforge.net (mondragon@users.sourceforge.net) Date: Thu Jul 15 17:54:13 2004 Subject: [Python-checkins] python/dist/src/Modules _sre.c, 2.106, 2.107 collectionsmodule.c, 1.19, 1.20 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28803/Modules Modified Files: _sre.c collectionsmodule.c Log Message: Moved SunPro warning suppression into pyport.h and out of individual modules and objects. Index: _sre.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_sre.c,v retrieving revision 2.106 retrieving revision 2.107 diff -C2 -d -r2.106 -r2.107 *** _sre.c 17 Jun 2004 18:27:16 -0000 2.106 --- _sre.c 15 Jul 2004 15:54:04 -0000 2.107 *************** *** 35,42 **** */ - #ifdef __SUNPRO_C - #pragma error_messages (off,E_END_OF_LOOP_CODE_NOT_REACHED) - #endif - #ifndef SRE_RECURSIVE --- 35,38 ---- Index: collectionsmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/collectionsmodule.c,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** collectionsmodule.c 9 Jul 2004 04:10:20 -0000 1.19 --- collectionsmodule.c 15 Jul 2004 15:54:04 -0000 1.20 *************** *** 2,9 **** #include "structmember.h" - #ifdef __SUNPRO_C - #pragma error_messages (off,E_END_OF_LOOP_CODE_NOT_REACHED) - #endif - /* collections module implementation of a deque() datatype Written and maintained by Raymond D. Hettinger --- 2,5 ---- From mondragon at users.sourceforge.net Thu Jul 15 17:54:10 2004 From: mondragon at users.sourceforge.net (mondragon@users.sourceforge.net) Date: Thu Jul 15 17:54:17 2004 Subject: [Python-checkins] python/dist/src/Objects dictobject.c, 2.161, 2.162 listobject.c, 2.206, 2.207 setobject.c, 1.28, 1.29 unicodeobject.c, 2.216, 2.217 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28803/Objects Modified Files: dictobject.c listobject.c setobject.c unicodeobject.c Log Message: Moved SunPro warning suppression into pyport.h and out of individual modules and objects. Index: dictobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/dictobject.c,v retrieving revision 2.161 retrieving revision 2.162 diff -C2 -d -r2.161 -r2.162 *** dictobject.c 18 Jun 2004 19:57:13 -0000 2.161 --- dictobject.c 15 Jul 2004 15:54:04 -0000 2.162 *************** *** 10,17 **** #include "Python.h" - #ifdef __SUNPRO_C - #pragma error_messages (off,E_END_OF_LOOP_CODE_NOT_REACHED) - #endif - typedef PyDictEntry dictentry; typedef PyDictObject dictobject; --- 10,13 ---- Index: listobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/listobject.c,v retrieving revision 2.206 retrieving revision 2.207 diff -C2 -d -r2.206 -r2.207 *** listobject.c 17 Jun 2004 18:27:18 -0000 2.206 --- listobject.c 15 Jul 2004 15:54:05 -0000 2.207 *************** *** 3,10 **** #include "Python.h" - #ifdef __SUNPRO_C - #pragma error_messages (off,E_END_OF_LOOP_CODE_NOT_REACHED) - #endif - #ifdef STDC_HEADERS #include --- 3,6 ---- Index: setobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/setobject.c,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** setobject.c 17 Jun 2004 18:27:18 -0000 1.28 --- setobject.c 15 Jul 2004 15:54:05 -0000 1.29 *************** *** 11,18 **** */ - #ifdef __SUNPRO_C - #pragma error_messages (off,E_END_OF_LOOP_CODE_NOT_REACHED) - #endif - static PyObject * set_update(PySetObject *so, PyObject *other) --- 11,14 ---- Index: unicodeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/unicodeobject.c,v retrieving revision 2.216 retrieving revision 2.217 diff -C2 -d -r2.216 -r2.217 *** unicodeobject.c 10 Jul 2004 12:04:20 -0000 2.216 --- unicodeobject.c 15 Jul 2004 15:54:05 -0000 2.217 *************** *** 42,49 **** #include "ucnhash.h" - #ifdef __SUNPRO_C - #pragma error_messages (off,E_END_OF_LOOP_CODE_NOT_REACHED) - #endif - #ifdef MS_WINDOWS #include --- 42,45 ---- From jackjansen at users.sourceforge.net Thu Jul 15 18:03:57 2004 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Thu Jul 15 18:03:59 2004 Subject: [Python-checkins] python/dist/src/Mac/OSX fixversions.py,NONE,1.1 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/OSX In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30725 Added Files: fixversions.py Log Message: A script to fix version strings in .plist files. --- NEW FILE: fixversions.py --- """fixversions - Fix version numbers in .plist files to match current python version and date""" import sys import os import time import plistlib SHORTVERSION = "%d.%d" % (sys.version_info[0], sys.version_info[1]) if sys.version_info[2]: SHORTVERSION = SHORTVERSION + ".%d" % sys.version_info[2] if sys.version_info[3] != 'final': SHORTVERSION = SHORTVERSION + "%s%d" % (sys.version_info[3], sys.version_info[4]) COPYRIGHT = "(c) %d Python Software Foundation." % time.gmtime()[0] LONGVERSION = SHORTVERSION + ", " + COPYRIGHT def fix(file): plist = plistlib.Plist.fromFile(file) changed = False if plist.has_key("CFBundleGetInfoString") and \ plist["CFBundleGetInfoString"] != LONGVERSION: plist["CFBundleGetInfoString"] = LONGVERSION changed = True if plist.has_key("CFBundleLongVersionString") and \ plist["CFBundleLongVersionString"] != LONGVERSION: plist["CFBundleLongVersionString"] = LONGVERSION changed = True if plist.has_key("NSHumanReadableCopyright") and \ plist["NSHumanReadableCopyright"] != COPYRIGHT: plist["NSHumanReadableCopyright"] = COPYRIGHT changed = True if plist.has_key("CFBundleVersion") and \ plist["CFBundleVersion"] != SHORTVERSION: plist["CFBundleVersion"] = SHORTVERSION changed = True if plist.has_key("CFBundleShortVersionString") and \ plist["CFBundleShortVersionString"] != SHORTVERSION: plist["CFBundleShortVersionString"] = SHORTVERSION changed = True if changed: os.rename(file, file + '~') plist.write(file) def main(): if len(sys.argv) < 2: print "Usage: %s plistfile ..." % sys.argv[0] print "or: %s -a fix standard Python plist files" sys.exit(1) if sys.argv[1] == "-a": files = [ "../OSXResources/app/Info.plist", "../OSXResources/framework/version.plist", "../Tools/IDE/PackageManager.plist", "../Tools/IDE/PythonIDE.plist", "../scripts/BuildApplet.plist" ] if not os.path.exists(files[0]): print "%s -a must be run from Mac/OSX directory" sys.exit(1) else: files = sys.argv[1:] for file in files: fix(file) sys.exit(0) if __name__ == "__main__": main() From akuchling at users.sourceforge.net Thu Jul 15 18:17:09 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Thu Jul 15 18:17:13 2004 Subject: [Python-checkins] python/dist/src/Lib asyncore.py,1.57,1.58 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv860 Modified Files: asyncore.py Log Message: [Patch #982681] Apply this patch correctly; makes set_reuse_addr() work on Windows Index: asyncore.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/asyncore.py,v retrieving revision 1.57 retrieving revision 1.58 diff -C2 -d -r1.57 -r1.58 *** asyncore.py 10 Jul 2004 17:36:11 -0000 1.57 --- asyncore.py 15 Jul 2004 16:17:07 -0000 1.58 *************** *** 264,275 **** # try to re-use a server port if possible try: self.socket.setsockopt( ! socket.SOL_SOCKET, socket.SO_REUSEADDR, self.socket.getsockopt(socket.SOL_SOCKET, ! socket.SO_REUSEADDR) | 1 ) except socket.error: pass ! # ================================================== # predicates for select() --- 264,281 ---- # try to re-use a server port if possible try: + # Windows SO_REUSEADDR is very broken (from a unixy perspective) + if sys.platform == 'win32': + reuse_constant = socket.SO_EXCLUSIVEADDRUSE + else: + reuse_constant = socket.SO_REUSEADDR + self.socket.setsockopt( ! socket.SOL_SOCKET, reuse_constant, self.socket.getsockopt(socket.SOL_SOCKET, ! reuse_constant) | 1 ) except socket.error: pass ! # ================================================== # predicates for select() From loewis at users.sourceforge.net Thu Jul 15 18:51:41 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Jul 15 18:51:45 2004 Subject: [Python-checkins] python/nondist/sandbox/msi msi.py,1.12,1.13 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/msi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7364 Modified Files: msi.py Log Message: Provide support for configuration file. Fix usage of product code for alpha installations. Index: msi.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/msi/msi.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** msi.py 12 Jul 2004 20:55:36 -0000 1.12 --- msi.py 15 Jul 2004 16:51:39 -0000 1.13 *************** *** 6,15 **** from win32com.client import constants msilib.Win64 = 0 current_version = "2.4.0" alpha = 1 testpackage = 0 ! srcdir = r'e:\pyinst\python' major, minor, micro = current_version.split(".") --- 6,31 ---- from win32com.client import constants + # Settings can be overridden in config.py below + # 1 for Itanium build msilib.Win64 = 0 + # Micro version current_version = "2.4.0" + # 0 for beta or final releases; + # 1 means to use a new product code for each package alpha = 1 + # 1 means that file extension is px, not py, + # and binaries start with x testpackage = 0 + # Location of build tree + srcdir = r'c:\release\python' + # Text to be displayed as the version in dialogs etc. + # goes into file name and ProductCode. Defaults to + # current_version.day for Alpha, current_version otherwise + full_current_version = None ! try: ! from config import * ! except ImportError: ! pass major, minor, micro = current_version.split(".") *************** *** 29,32 **** --- 45,52 ---- product_code = product_codes[current_version] + if alpha: + release = int(time.time()/3600/24) + product_code = msilib.gen_uuid() + extensions = [ 'bz2.pyd', *************** *** 54,62 **** ]) ! if alpha: ! release = int(time.time()/3600/24) ! full_current_version = "%s.%d" % (current_version, release) ! else: ! full_current_version = current_version if testpackage: --- 74,82 ---- ]) ! if full_current_version is None: ! if alpha: ! full_current_version = "%s.%d" % (current_version, release) ! else: ! full_current_version = current_version if testpackage: *************** *** 78,89 **** cv = "%s.%s.%s" % (major, minor, release) uc = upgrade_code_alpha - pc = msilib.gen_uuid() else: cv = current_version uc = upgrade_code - pc = product_code db = msilib.init_database("python%s.msi" % full_current_version, schema, ProductName="Python "+full_current_version, ! ProductCode=pc, ProductVersion=cv, Manufacturer=u"Martin v. L\xf6wis") --- 98,107 ---- cv = "%s.%s.%s" % (major, minor, release) uc = upgrade_code_alpha else: cv = current_version uc = upgrade_code db = msilib.init_database("python%s.msi" % full_current_version, schema, ProductName="Python "+full_current_version, ! ProductCode=product_code, ProductVersion=cv, Manufacturer=u"Martin v. L\xf6wis") From loewis at users.sourceforge.net Thu Jul 15 19:37:14 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Jul 15 19:37:18 2004 Subject: [Python-checkins] python/nondist/sandbox/msi msi.py,1.13,1.14 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/msi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16342 Modified Files: msi.py Log Message: Add missing test files. Fixes #988784 . Index: msi.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/msi/msi.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** msi.py 15 Jul 2004 16:51:39 -0000 1.13 --- msi.py 15 Jul 2004 17:37:11 -0000 1.14 *************** *** 646,656 **** lib.remove_pyc() if dir=='test' and parent.physical=='Lib': - lib.add_file("audiotest.au") lib.add_file("185test.db") ! lib.add_file("test.xml.out") ! lib.add_file("readme.txt", src="README") ! lib.glob("*.uue") lib.add_file("test.xml") lib.add_file("testtar.tar") if dir=='output': lib.glob("test_*") --- 646,659 ---- lib.remove_pyc() if dir=='test' and parent.physical=='Lib': lib.add_file("185test.db") ! lib.add_file("audiotest.au") ! lib.add_file("cfgparser.1") lib.add_file("test.xml") + lib.add_file("test.xml.out") lib.add_file("testtar.tar") + lib.glob("*.uue") + lib.add_file("readme.txt", src="README") + if dir=='decimaltestdata': + lib.glob("*.decTest") if dir=='output': lib.glob("test_*") From jackjansen at users.sourceforge.net Thu Jul 15 21:56:28 2004 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Thu Jul 15 21:56:31 2004 Subject: [Python-checkins] python/dist/src setup.py,1.190,1.191 Message-ID: Update of /cvsroot/python/python/dist/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11984 Modified Files: setup.py Log Message: _localemodule now needs to be linked with CoreFoundation on darwin. Index: setup.py =================================================================== RCS file: /cvsroot/python/python/dist/src/setup.py,v retrieving revision 1.190 retrieving revision 1.191 diff -C2 -d -r1.190 -r1.191 *** setup.py 26 Jun 2004 22:29:42 -0000 1.190 --- setup.py 15 Jul 2004 19:56:25 -0000 1.191 *************** *** 342,347 **** else: locale_libs = [] exts.append( Extension('_locale', ['_localemodule.c'], ! libraries=locale_libs ) ) # Modules with some UNIX dependencies -- on by default: --- 342,354 ---- else: locale_libs = [] + if platform == 'darwin': + locale_extra_link_args = ['-framework', 'CoreFoundation'] + else: + locale_extra_link_args = [] + + exts.append( Extension('_locale', ['_localemodule.c'], ! libraries=locale_libs, ! extra_link_args=locale_extra_link_args) ) # Modules with some UNIX dependencies -- on by default: From jackjansen at users.sourceforge.net Thu Jul 15 23:24:10 2004 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Thu Jul 15 23:24:14 2004 Subject: [Python-checkins] python/dist/src/Tools/bgen/bgen bgenObjectDefinition.py, 1.25, 1.26 Message-ID: Update of /cvsroot/python/python/dist/src/Tools/bgen/bgen In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27630/Tools/bgen/bgen Modified Files: bgenObjectDefinition.py Log Message: Call the correct tp_dealloc. Index: bgenObjectDefinition.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/bgen/bgen/bgenObjectDefinition.py,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** bgenObjectDefinition.py 19 Jan 2003 21:53:56 -0000 1.25 --- bgenObjectDefinition.py 15 Jul 2004 21:24:07 -0000 1.26 *************** *** 136,140 **** self.outputCleanupStructMembers() if self.basetype: ! Output("%s.tp_dealloc(self)", self.basetype) elif hasattr(self, 'output_tp_free'): # This is a new-style object with tp_free slot --- 136,140 ---- self.outputCleanupStructMembers() if self.basetype: ! Output("self->ob_type->tp_base->tp_dealloc((PyObject *)self);") elif hasattr(self, 'output_tp_free'): # This is a new-style object with tp_free slot *************** *** 211,215 **** Output("""%s.ob_type = &PyType_Type;""", self.typename) if self.basetype: ! Output("%s.tp_base = %s;", self.typename, self.basetype) Output("if (PyType_Ready(&%s) < 0) return;", self.typename) Output("""Py_INCREF(&%s);""", self.typename) --- 211,215 ---- Output("""%s.ob_type = &PyType_Type;""", self.typename) if self.basetype: ! Output("%s.tp_base = &%s;", self.typename, self.basetype) Output("if (PyType_Ready(&%s) < 0) return;", self.typename) Output("""Py_INCREF(&%s);""", self.typename) From jackjansen at users.sourceforge.net Thu Jul 15 23:30:47 2004 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Thu Jul 15 23:30:50 2004 Subject: [Python-checkins] python/dist/src/Mac/scripts BuildApplet.plist, 1.2, 1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/scripts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28685/scripts Modified Files: BuildApplet.plist Log Message: - Added a note about fixversions.py - Ran it. Index: BuildApplet.plist =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/scripts/BuildApplet.plist,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** BuildApplet.plist 19 Nov 2003 13:37:22 -0000 1.2 --- BuildApplet.plist 15 Jul 2004 21:30:41 -0000 1.3 *************** *** 1,5 **** ! ! CFBundleDevelopmentRegion --- 1,5 ---- ! ! CFBundleDevelopmentRegion *************** *** 26,39 **** CFBundleExecutable BuildApplet - CFBundleGetInfoString ! 2.3.2, (c) 2003 Python Software Foundation. ! CFBundleLongVersionString ! 2.3.2, (c) 2003 Python Software Foundation. ! NSHumanReadableCopyright ! Copyright 2003 Python Software Foundation. ! CFBundleShortVersionString ! 2.3.2 ! CFBundleIconFile BuildApplet.icns --- 26,31 ---- CFBundleExecutable BuildApplet CFBundleGetInfoString ! 2.4alpha1, (c) 2004 Python Software Foundation. CFBundleIconFile BuildApplet.icns *************** *** 42,57 **** CFBundleInfoDictionaryVersion 6.0 CFBundleName PythonIDE CFBundlePackageType APPL CFBundleSignature Pide CFBundleVersion ! 2.3.2 ! LSRequiresCarbon ! CSResourcesFileMapped --- 34,55 ---- CFBundleInfoDictionaryVersion 6.0 + CFBundleLongVersionString + 2.4alpha1, (c) 2004 Python Software Foundation. CFBundleName PythonIDE CFBundlePackageType APPL + CFBundleShortVersionString + 2.4alpha1 CFBundleSignature Pide CFBundleVersion ! 2.4alpha1 CSResourcesFileMapped + LSRequiresCarbon + + NSHumanReadableCopyright + (c) 2004 Python Software Foundation. From jackjansen at users.sourceforge.net Thu Jul 15 23:30:47 2004 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Thu Jul 15 23:30:51 2004 Subject: [Python-checkins] python/dist/src/Mac/OSX README,1.11,1.12 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/OSX In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28685/OSX Modified Files: README Log Message: - Added a note about fixversions.py - Ran it. Index: README =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/OSX/README,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** README 20 Jun 2003 15:14:08 -0000 1.11 --- README 15 Jul 2004 21:30:40 -0000 1.12 *************** *** 120,123 **** --- 120,127 ---- ----------------------------------------- + First go to Mac/OSX and run "python fixversions.py -a" with the Python + you are going to distribute. This will fix the version numbers and copyright + strings in the various Info.plist files. + Go to the Mac/OSX/Dist directory. There you find a script "build" that does all the work: it configures and builds a framework Python, installs *************** *** 157,159 **** files. ! Jack Jansen, Jack.Jansen@cwi.nl, 20-Jun-2003. \ No newline at end of file --- 161,163 ---- files. ! Jack Jansen, Jack.Jansen@cwi.nl, 15-Jul-2004. \ No newline at end of file From jackjansen at users.sourceforge.net Thu Jul 15 23:30:47 2004 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Thu Jul 15 23:30:53 2004 Subject: [Python-checkins] python/dist/src/Mac/OSXResources/framework version.plist, 1.4, 1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/OSXResources/framework In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28685/OSXResources/framework Modified Files: version.plist Log Message: - Added a note about fixversions.py - Ran it. Index: version.plist =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/OSXResources/framework/version.plist,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** version.plist 19 Nov 2003 13:48:13 -0000 1.4 --- version.plist 15 Jul 2004 21:30:41 -0000 1.5 *************** *** 1,12 **** ! ! BuildVersion 1 CFBundleShortVersionString ! 2.4a0 CFBundleVersion ! 2.4a0 ProjectName Python --- 1,12 ---- ! ! BuildVersion 1 CFBundleShortVersionString ! 2.4alpha1 CFBundleVersion ! 2.4alpha1 ProjectName Python From jackjansen at users.sourceforge.net Thu Jul 15 23:30:47 2004 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Thu Jul 15 23:30:54 2004 Subject: [Python-checkins] python/dist/src/Mac/OSXResources/app Info.plist, 1.12, 1.13 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/OSXResources/app In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28685/OSXResources/app Modified Files: Info.plist Log Message: - Added a note about fixversions.py - Ran it. Index: Info.plist =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/OSXResources/app/Info.plist,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** Info.plist 19 Nov 2003 13:50:21 -0000 1.12 --- Info.plist 15 Jul 2004 21:30:41 -0000 1.13 *************** *** 1,5 **** ! ! CFBundleDevelopmentRegion --- 1,5 ---- ! ! CFBundleDevelopmentRegion *************** *** 20,33 **** CFBundleExecutable Python - CFBundleGetInfoString ! 2.4a0, (c) 2003 Python Software Foundation. ! CFBundleLongVersionString ! 2.4a0, (c) 2003 Python Software Foundation. ! NSHumanReadableCopyright ! Copyright 2003 Python Software Foundation. ! CFBundleShortVersionString ! 2.4a0 ! CFBundleHelpBookFolder --- 20,25 ---- CFBundleExecutable Python CFBundleGetInfoString ! 2.4alpha1, (c) 2004 Python Software Foundation. CFBundleHelpBookFolder *************** *** 39,43 **** CFBundleHelpTOCFile index.html - CFBundleIconFile PythonInterpreter.icns --- 31,34 ---- *************** *** 46,63 **** CFBundleInfoDictionaryVersion 6.0 CFBundleName Python CFBundlePackageType APPL CFBundleSignature PytX CFBundleVersion ! 2.4a0 ! LSRequiresCarbon ! CSResourcesFileMapped NSAppleScriptEnabled --- 37,60 ---- CFBundleInfoDictionaryVersion 6.0 + CFBundleLongVersionString + 2.4alpha1, (c) 2004 Python Software Foundation. CFBundleName Python CFBundlePackageType APPL + CFBundleShortVersionString + 2.4alpha1 CFBundleSignature PytX CFBundleVersion ! 2.4alpha1 CSResourcesFileMapped + LSRequiresCarbon + NSAppleScriptEnabled + NSHumanReadableCopyright + (c) 2004 Python Software Foundation. From jackjansen at users.sourceforge.net Thu Jul 15 23:30:47 2004 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Thu Jul 15 23:30:55 2004 Subject: [Python-checkins] python/dist/src/Mac/Tools/IDE PackageManager.plist, 1.2, 1.3 PythonIDE.plist, 1.3, 1.4 PythonIDE.py, 1.14, 1.15 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Tools/IDE In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28685/Tools/IDE Modified Files: PackageManager.plist PythonIDE.plist PythonIDE.py Log Message: - Added a note about fixversions.py - Ran it. Index: PackageManager.plist =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Tools/IDE/PackageManager.plist,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PackageManager.plist 19 Nov 2003 13:45:26 -0000 1.2 --- PackageManager.plist 15 Jul 2004 21:30:41 -0000 1.3 *************** *** 1,5 **** ! ! CFBundleDevelopmentRegion --- 1,5 ---- ! ! CFBundleDevelopmentRegion *************** *** 10,23 **** CFBundleExecutable PackageManager - CFBundleGetInfoString ! 2.3.2, (c) 2003 Python Software Foundation. ! CFBundleLongVersionString ! 2.3.2, (c) 2003 Python Software Foundation. ! NSHumanReadableCopyright ! Copyright 2003 Python Software Foundation. ! CFBundleShortVersionString ! 2.3.2 ! CFBundleIconFile PackageManager.icns --- 10,15 ---- CFBundleExecutable PackageManager CFBundleGetInfoString ! 2.4alpha1, (c) 2004 Python Software Foundation. CFBundleIconFile PackageManager.icns *************** *** 26,41 **** CFBundleInfoDictionaryVersion 6.0 CFBundleName PythonIDE CFBundlePackageType APPL CFBundleSignature Pide CFBundleVersion ! 2.3.2 ! LSRequiresCarbon ! CSResourcesFileMapped --- 18,39 ---- CFBundleInfoDictionaryVersion 6.0 + CFBundleLongVersionString + 2.4alpha1, (c) 2004 Python Software Foundation. CFBundleName PythonIDE CFBundlePackageType APPL + CFBundleShortVersionString + 2.4alpha1 CFBundleSignature Pide CFBundleVersion ! 2.4alpha1 CSResourcesFileMapped + LSRequiresCarbon + + NSHumanReadableCopyright + (c) 2004 Python Software Foundation. Index: PythonIDE.plist =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Tools/IDE/PythonIDE.plist,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PythonIDE.plist 19 Nov 2003 13:45:26 -0000 1.3 --- PythonIDE.plist 15 Jul 2004 21:30:41 -0000 1.4 *************** *** 1,5 **** ! ! CFBundleDevelopmentRegion --- 1,5 ---- ! ! CFBundleDevelopmentRegion *************** *** 26,39 **** CFBundleExecutable PythonIDE - CFBundleGetInfoString ! 2.4a0, (c) 2003 Python Software Foundation. ! CFBundleLongVersionString ! 2.4a0, (c) 2003 Python Software Foundation. ! NSHumanReadableCopyright ! Copyright 2003 Python Software Foundation. ! CFBundleShortVersionString ! 2.4a0 ! CFBundleHelpBookFolder --- 26,31 ---- CFBundleExecutable PythonIDE CFBundleGetInfoString ! 2.4alpha1, (c) 2004 Python Software Foundation. CFBundleHelpBookFolder *************** *** 44,48 **** CFBundleHelpTOCFile index.html - CFBundleIconFile PythonIDE.icns --- 36,39 ---- *************** *** 51,66 **** CFBundleInfoDictionaryVersion 6.0 CFBundleName PythonIDE CFBundlePackageType APPL CFBundleSignature Pide CFBundleVersion ! 2.3.2 ! LSRequiresCarbon ! CSResourcesFileMapped --- 42,63 ---- CFBundleInfoDictionaryVersion 6.0 + CFBundleLongVersionString + 2.4alpha1, (c) 2004 Python Software Foundation. CFBundleName PythonIDE CFBundlePackageType APPL + CFBundleShortVersionString + 2.4alpha1 CFBundleSignature Pide CFBundleVersion ! 2.4alpha1 CSResourcesFileMapped + LSRequiresCarbon + + NSHumanReadableCopyright + (c) 2004 Python Software Foundation. Index: PythonIDE.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Tools/IDE/PythonIDE.py,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** PythonIDE.py 19 Nov 2003 13:45:26 -0000 1.14 --- PythonIDE.py 15 Jul 2004 21:30:41 -0000 1.15 *************** *** 4,8 **** # it like the "normal" interpreter. ! __version__ = '1.0.1' import sys import os --- 4,8 ---- # it like the "normal" interpreter. ! __version__ = '1.0.2' import sys import os From rhettinger at users.sourceforge.net Thu Jul 15 23:32:20 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Thu Jul 15 23:32:23 2004 Subject: [Python-checkins] python/dist/src/Modules collectionsmodule.c, 1.20, 1.21 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29010 Modified Files: collectionsmodule.c Log Message: Apply VISIT macro. Index: collectionsmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/collectionsmodule.c,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** collectionsmodule.c 15 Jul 2004 15:54:04 -0000 1.20 --- collectionsmodule.c 15 Jul 2004 21:32:18 -0000 1.21 *************** *** 466,470 **** block * b = deque->leftblock; int index = deque->leftindex; - int err; PyObject *item; --- 466,469 ---- *************** *** 472,482 **** item = b->data[index]; index++; ! if (index == BLOCKLEN && b->rightlink != NULL) { b = b->rightlink; index = 0; } ! err = visit(item, arg); ! if (err) ! return err; } return 0; --- 471,480 ---- item = b->data[index]; index++; ! if (index == BLOCKLEN ) { ! assert(b->rightlink != NULL); b = b->rightlink; index = 0; } ! Py_VISIT(item); } return 0; From jackjansen at users.sourceforge.net Thu Jul 15 23:32:48 2004 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Thu Jul 15 23:32:51 2004 Subject: [Python-checkins] python/dist/src/Mac/OSX fixversions.py, NONE, 1.1.2.1 README, 1.11, 1.11.8.1 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/OSX In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28994 Modified Files: Tag: release23-maint README Added Files: Tag: release23-maint fixversions.py Log Message: Imported fixversions.py and the note referring to it from 2.4. --- NEW FILE: fixversions.py --- """fixversions - Fix version numbers in .plist files to match current python version and date""" import sys import os import time import plistlib SHORTVERSION = "%d.%d" % (sys.version_info[0], sys.version_info[1]) if sys.version_info[2]: SHORTVERSION = SHORTVERSION + ".%d" % sys.version_info[2] if sys.version_info[3] != 'final': SHORTVERSION = SHORTVERSION + "%s%d" % (sys.version_info[3], sys.version_info[4]) COPYRIGHT = "(c) %d Python Software Foundation." % time.gmtime()[0] LONGVERSION = SHORTVERSION + ", " + COPYRIGHT def fix(file): plist = plistlib.Plist.fromFile(file) changed = False if plist.has_key("CFBundleGetInfoString") and \ plist["CFBundleGetInfoString"] != LONGVERSION: plist["CFBundleGetInfoString"] = LONGVERSION changed = True if plist.has_key("CFBundleLongVersionString") and \ plist["CFBundleLongVersionString"] != LONGVERSION: plist["CFBundleLongVersionString"] = LONGVERSION changed = True if plist.has_key("NSHumanReadableCopyright") and \ plist["NSHumanReadableCopyright"] != COPYRIGHT: plist["NSHumanReadableCopyright"] = COPYRIGHT changed = True if plist.has_key("CFBundleVersion") and \ plist["CFBundleVersion"] != SHORTVERSION: plist["CFBundleVersion"] = SHORTVERSION changed = True if plist.has_key("CFBundleShortVersionString") and \ plist["CFBundleShortVersionString"] != SHORTVERSION: plist["CFBundleShortVersionString"] = SHORTVERSION changed = True if changed: os.rename(file, file + '~') plist.write(file) def main(): if len(sys.argv) < 2: print "Usage: %s plistfile ..." % sys.argv[0] print "or: %s -a fix standard Python plist files" sys.exit(1) if sys.argv[1] == "-a": files = [ "../OSXResources/app/Info.plist", "../OSXResources/framework/version.plist", "../Tools/IDE/PackageManager.plist", "../Tools/IDE/PythonIDE.plist", "../scripts/BuildApplet.plist" ] if not os.path.exists(files[0]): print "%s -a must be run from Mac/OSX directory" sys.exit(1) else: files = sys.argv[1:] for file in files: fix(file) sys.exit(0) if __name__ == "__main__": main() Index: README =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/OSX/README,v retrieving revision 1.11 retrieving revision 1.11.8.1 diff -C2 -d -r1.11 -r1.11.8.1 *** README 20 Jun 2003 15:14:08 -0000 1.11 --- README 15 Jul 2004 21:32:45 -0000 1.11.8.1 *************** *** 120,123 **** --- 120,127 ---- ----------------------------------------- + First go to Mac/OSX and run "python fixversions.py -a" with the Python + you are going to distribute. This will fix the version numbers and copyright + strings in the various Info.plist files. + Go to the Mac/OSX/Dist directory. There you find a script "build" that does all the work: it configures and builds a framework Python, installs *************** *** 157,159 **** files. ! Jack Jansen, Jack.Jansen@cwi.nl, 20-Jun-2003. \ No newline at end of file --- 161,163 ---- files. ! Jack Jansen, Jack.Jansen@cwi.nl, 15-Jul-2004. \ No newline at end of file From jackjansen at users.sourceforge.net Fri Jul 16 00:08:36 2004 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Fri Jul 16 00:08:39 2004 Subject: [Python-checkins] python/dist/src/Mac/Tools/IDE Wcontrols.py, 1.14, 1.15 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Tools/IDE In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2905 Modified Files: Wcontrols.py Log Message: After more than two years of puzzlement Jurjen Bos found the reason for the double-scroll problem: when you pass a tracker function to TrackControl you shouldn't call your hit function again afterwards. Fixes #711989. Index: Wcontrols.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Tools/IDE/Wcontrols.py,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** Wcontrols.py 30 Nov 2002 00:01:27 -0000 1.14 --- Wcontrols.py 15 Jul 2004 22:08:33 -0000 1.15 *************** *** 381,386 **** self._hit(part) part = self._control.TrackControl(point, hitter) - if part: - self._hit(part) def _hit(self, part): --- 381,384 ---- From jackjansen at users.sourceforge.net Fri Jul 16 00:10:55 2004 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Fri Jul 16 00:10:59 2004 Subject: [Python-checkins] python/dist/src/Mac/Tools/IDE Wcontrols.py, 1.14, 1.14.14.1 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Tools/IDE In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4047 Modified Files: Tag: release23-maint Wcontrols.py Log Message: Backport of 1.15: After more than two years of puzzlement Jurjen Bos found the reason for the double-scroll problem: when you pass a tracker function to TrackControl you shouldn't call your hit function again afterwards. Fixes #711989. Index: Wcontrols.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Tools/IDE/Wcontrols.py,v retrieving revision 1.14 retrieving revision 1.14.14.1 diff -C2 -d -r1.14 -r1.14.14.1 *** Wcontrols.py 30 Nov 2002 00:01:27 -0000 1.14 --- Wcontrols.py 15 Jul 2004 22:10:52 -0000 1.14.14.1 *************** *** 381,386 **** self._hit(part) part = self._control.TrackControl(point, hitter) - if part: - self._hit(part) def _hit(self, part): --- 381,384 ---- From jackjansen at users.sourceforge.net Fri Jul 16 00:12:39 2004 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Fri Jul 16 00:12:42 2004 Subject: [Python-checkins] python/dist/src/Mac/OSX Makefile.panther, 1.1.2.3, 1.1.2.4 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/OSX In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4346 Modified Files: Tag: release23-maint Makefile.panther Log Message: Add Wcontrols.py to the patched IDE files. Index: Makefile.panther =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/OSX/Attic/Makefile.panther,v retrieving revision 1.1.2.3 retrieving revision 1.1.2.4 diff -C2 -d -r1.1.2.3 -r1.1.2.4 *** Makefile.panther 4 Nov 2003 21:02:59 -0000 1.1.2.3 --- Makefile.panther 15 Jul 2004 22:12:36 -0000 1.1.2.4 *************** *** 24,30 **** BUILDPYTHON=$(APPLE_PYTHON) INSTALLED_PYTHONW=$(APPLE_PYTHONW) \ DESTDIR=$(DESTDIR) PYTHONAPPSDIR=$(PYTHONAPPSDIR) ! # Add the extra file to the resources. This is to work around a bugs in ! # PythonIDEMain.py in the original 2.3. cp ../Tools/IDE/PythonIDEMain.py $(DESTDIR)$(PYTHONAPPSDIR)/PythonIDE.app/Contents/Resources install_PackageManager: --- 24,33 ---- BUILDPYTHON=$(APPLE_PYTHON) INSTALLED_PYTHONW=$(APPLE_PYTHONW) \ DESTDIR=$(DESTDIR) PYTHONAPPSDIR=$(PYTHONAPPSDIR) ! # Add the extra files to the resources. This is to work around bugs in ! # them in the original 2.3. cp ../Tools/IDE/PythonIDEMain.py $(DESTDIR)$(PYTHONAPPSDIR)/PythonIDE.app/Contents/Resources + cp ../Tools/IDE/Wapplication.py $(DESTDIR)$(PYTHONAPPSDIR)/PythonIDE.app/Contents/Resources + cp ../Tools/IDE/Wcontrols.py $(DESTDIR)$(PYTHONAPPSDIR)/PythonIDE.app/Contents/Resources + cp ../Tools/IDE/PyEdit.py $(DESTDIR)$(PYTHONAPPSDIR)/PythonIDE.app/Contents/Resources install_PackageManager: From jackjansen at users.sourceforge.net Fri Jul 16 00:28:51 2004 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Fri Jul 16 00:28:53 2004 Subject: [Python-checkins] python/dist/src/Python dynload_next.c,2.14,2.15 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7564 Modified Files: dynload_next.c Log Message: Fix for 838140: don't call NSUnlinkModule when we fail to find our expected entrypoint. The unlinking will crash the application if the module contained ObjC code. The price of this is small: a little wasted memory, and only in a case than isn't expected to occur often. Index: dynload_next.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/dynload_next.c,v retrieving revision 2.14 retrieving revision 2.15 diff -C2 -d -r2.14 -r2.15 *** dynload_next.c 23 Dec 2002 21:03:36 -0000 2.14 --- dynload_next.c 15 Jul 2004 22:28:48 -0000 2.15 *************** *** 93,97 **** if (!NSIsSymbolNameDefined(funcname)) { /* UnlinkModule() isn't implemented in current versions, but calling it does no harm */ ! NSUnLinkModule(newModule, FALSE); PyErr_Format(PyExc_ImportError, "Loaded module does not contain symbol %.200s", --- 93,97 ---- if (!NSIsSymbolNameDefined(funcname)) { /* UnlinkModule() isn't implemented in current versions, but calling it does no harm */ ! /* NSUnLinkModule(newModule, FALSE); removed: causes problems for ObjC code */ PyErr_Format(PyExc_ImportError, "Loaded module does not contain symbol %.200s", *************** *** 103,107 **** theSym = NSLookupSymbolInModule(newModule, funcname); if ( theSym == NULL ) { ! NSUnLinkModule(newModule, FALSE); PyErr_Format(PyExc_ImportError, "Loaded module does not contain symbol %.200s", --- 103,107 ---- theSym = NSLookupSymbolInModule(newModule, funcname); if ( theSym == NULL ) { ! /* NSUnLinkModule(newModule, FALSE); removed: causes problems for ObjC code */ PyErr_Format(PyExc_ImportError, "Loaded module does not contain symbol %.200s", From jackjansen at users.sourceforge.net Fri Jul 16 00:38:10 2004 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Fri Jul 16 00:38:13 2004 Subject: [Python-checkins] python/dist/src/Doc/mac using.tex,1.10,1.11 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/mac In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9604 Modified Files: using.tex Log Message: Fix for #795649: explain how to use TextEdit for editing Python code. Index: using.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/mac/using.tex,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** using.tex 14 Dec 2003 15:02:54 -0000 1.10 --- using.tex 15 Jul 2004 22:38:06 -0000 1.11 *************** *** 241,245 **** You can create a text file with any word processing program such as \program{MSWord} or \program{AppleWorks} but you need to make sure ! that the file is saved as ``\ASCII'' or ``plain text''. --- 241,247 ---- You can create a text file with any word processing program such as \program{MSWord} or \program{AppleWorks} but you need to make sure ! that the file is saved as ``\ASCII'' or ``plain text''. This also ! works for \program{TextEdit}, but you need to use the command ``Make Plain Text`` ! in the ``Format`` menu before trying to save. From jackjansen at users.sourceforge.net Fri Jul 16 10:42:38 2004 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Fri Jul 16 10:42:41 2004 Subject: [Python-checkins] python/dist/src configure.in, 1.461, 1.462 Makefile.pre.in, 1.146, 1.147 Message-ID: Update of /cvsroot/python/python/dist/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29326 Modified Files: configure.in Makefile.pre.in Log Message: Don't hardcode "Python" as the framework name, we have a variable for it: $PYTHONFRAMEWORK. Index: configure.in =================================================================== RCS file: /cvsroot/python/python/dist/src/configure.in,v retrieving revision 1.461 retrieving revision 1.462 diff -C2 -d -r1.461 -r1.462 *** configure.in 7 Jul 2004 17:44:09 -0000 1.461 --- configure.in 16 Jul 2004 08:42:35 -0000 1.462 *************** *** 1181,1190 **** LIBTOOL_CRUFT="-lcc_dynamic -arch_only ppc" LIBTOOL_CRUFT="$LIBTOOL_CRUFT $extra_frameworks" ! LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/Python' LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';; Darwin/*) LIBTOOL_CRUFT="-lcc_dynamic -arch_only ppc" LIBTOOL_CRUFT="$LIBTOOL_CRUFT $extra_frameworks" ! LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/Python' LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';; esac --- 1181,1190 ---- LIBTOOL_CRUFT="-lcc_dynamic -arch_only ppc" LIBTOOL_CRUFT="$LIBTOOL_CRUFT $extra_frameworks" ! LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';; Darwin/*) LIBTOOL_CRUFT="-lcc_dynamic -arch_only ppc" LIBTOOL_CRUFT="$LIBTOOL_CRUFT $extra_frameworks" ! LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';; esac *************** *** 1400,1404 **** if test "$enable_framework" then ! LINKFORSHARED="$LINKFORSHARED -Wl,-F. -framework Python" fi LINKFORSHARED="$LINKFORSHARED $extra_frameworks";; --- 1400,1404 ---- if test "$enable_framework" then ! LINKFORSHARED="$LINKFORSHARED -Wl,-F. -framework "'$(PYTHONFRAMEWORK)' fi LINKFORSHARED="$LINKFORSHARED $extra_frameworks";; Index: Makefile.pre.in =================================================================== RCS file: /cvsroot/python/python/dist/src/Makefile.pre.in,v retrieving revision 1.146 retrieving revision 1.147 diff -C2 -d -r1.146 -r1.147 *** Makefile.pre.in 12 Jul 2004 09:25:18 -0000 1.146 --- Makefile.pre.in 16 Jul 2004 08:42:35 -0000 1.147 *************** *** 382,386 **** $(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/Resources/English.lproj/InfoPlist.strings $(LN) -fsn $(VERSION) $(PYTHONFRAMEWORKDIR)/Versions/Current ! $(LN) -fsn Versions/Current/Python $(PYTHONFRAMEWORKDIR)/Python $(LN) -fsn Versions/Current/Headers $(PYTHONFRAMEWORKDIR)/Headers $(LN) -fsn Versions/Current/Resources $(PYTHONFRAMEWORKDIR)/Resources --- 382,386 ---- $(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/Resources/English.lproj/InfoPlist.strings $(LN) -fsn $(VERSION) $(PYTHONFRAMEWORKDIR)/Versions/Current ! $(LN) -fsn Versions/Current/$(PYTHONFRAMEWORK) $(PYTHONFRAMEWORKDIR)/$(PYTHONFRAMEWORK) $(LN) -fsn Versions/Current/Headers $(PYTHONFRAMEWORKDIR)/Headers $(LN) -fsn Versions/Current/Resources $(PYTHONFRAMEWORKDIR)/Resources From jackjansen at users.sourceforge.net Fri Jul 16 10:43:52 2004 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Fri Jul 16 10:43:55 2004 Subject: [Python-checkins] python/dist/src configure,1.450,1.451 Message-ID: Update of /cvsroot/python/python/dist/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29521 Modified Files: configure Log Message: Don't hardcode "Python" as the framework name, we have a variable for it: $PYTHONFRAMEWORK. Index: configure =================================================================== RCS file: /cvsroot/python/python/dist/src/configure,v retrieving revision 1.450 retrieving revision 1.451 diff -C2 -d -r1.450 -r1.451 *** configure 7 Jul 2004 17:44:03 -0000 1.450 --- configure 16 Jul 2004 08:43:47 -0000 1.451 *************** *** 1,4 **** #! /bin/sh ! # From configure.in Revision: 1.460 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.57 for python 2.4. --- 1,4 ---- #! /bin/sh ! # From configure.in Revision: 1.462 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.57 for python 2.4. *************** *** 9341,9350 **** LIBTOOL_CRUFT="-lcc_dynamic -arch_only ppc" LIBTOOL_CRUFT="$LIBTOOL_CRUFT $extra_frameworks" ! LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/Python' LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';; Darwin/*) LIBTOOL_CRUFT="-lcc_dynamic -arch_only ppc" LIBTOOL_CRUFT="$LIBTOOL_CRUFT $extra_frameworks" ! LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/Python' LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';; esac --- 9341,9350 ---- LIBTOOL_CRUFT="-lcc_dynamic -arch_only ppc" LIBTOOL_CRUFT="$LIBTOOL_CRUFT $extra_frameworks" ! LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';; Darwin/*) LIBTOOL_CRUFT="-lcc_dynamic -arch_only ppc" LIBTOOL_CRUFT="$LIBTOOL_CRUFT $extra_frameworks" ! LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';; esac *************** *** 9576,9580 **** if test "$enable_framework" then ! LINKFORSHARED="$LINKFORSHARED -Wl,-F. -framework Python" fi LINKFORSHARED="$LINKFORSHARED $extra_frameworks";; --- 9576,9580 ---- if test "$enable_framework" then ! LINKFORSHARED="$LINKFORSHARED -Wl,-F. -framework "'$(PYTHONFRAMEWORK)' fi LINKFORSHARED="$LINKFORSHARED $extra_frameworks";; From jackjansen at users.sourceforge.net Fri Jul 16 13:45:02 2004 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Fri Jul 16 13:45:06 2004 Subject: [Python-checkins] python/dist/src/Lib urllib.py,1.162,1.163 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24498 Modified Files: urllib.py Log Message: Fix for #779167: use InternetConfig proxy settings on MacOSX (in addition to unix-style). Index: urllib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/urllib.py,v retrieving revision 1.162 retrieving revision 1.163 diff -C2 -d -r1.162 -r1.163 *** urllib.py 23 Mar 2004 23:50:17 -0000 1.162 --- urllib.py 16 Jul 2004 11:45:00 -0000 1.163 *************** *** 1188,1193 **** return proxies ! if os.name == 'mac': ! def getproxies(): """Return a dictionary of scheme -> proxy server URL mappings. --- 1188,1193 ---- return proxies ! if sys.platform == 'darwin': ! def getproxies_internetconfig(): """Return a dictionary of scheme -> proxy server URL mappings. *************** *** 1222,1225 **** --- 1222,1228 ---- return 0 + def getproxies(): + return getproxies_environment() or getproxies_internetconfig() + elif os.name == 'nt': def getproxies_registry(): From rhettinger at users.sourceforge.net Fri Jul 16 14:13:41 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Fri Jul 16 14:13:44 2004 Subject: [Python-checkins] python/dist/src/Python compile.c,2.306,2.307 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28894 Modified Files: compile.c Log Message: Treat None as a constant. Index: compile.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/compile.c,v retrieving revision 2.306 retrieving revision 2.307 diff -C2 -d -r2.306 -r2.307 *** compile.c 8 Jul 2004 01:49:00 -0000 2.306 --- compile.c 16 Jul 2004 12:13:38 -0000 2.307 *************** *** 364,368 **** static PyObject * ! optimize_code(PyObject *code, PyObject* consts) { int i, j, codelen; --- 364,368 ---- static PyObject * ! optimize_code(PyObject *code, PyObject* consts, PyObject *names) { int i, j, codelen; *************** *** 370,373 **** --- 370,374 ---- unsigned char *codestr; unsigned int *blocks; + char *name; /* Make a modifiable copy of the code string */ *************** *** 419,422 **** --- 420,438 ---- SETARG(codestr, i, (j^1)); codestr[i+3] = NOP; + + /* Replace LOAD_GLOBAL/LOAD_NAME None with LOAD_CONST None */ + case LOAD_NAME: + case LOAD_GLOBAL: + j = GETARG(codestr, i); + name = PyString_AsString(PyTuple_GET_ITEM(names, j)); + if (name == NULL || strcmp(name, "None") != 0) + continue; + for (j=0 ; j < PyTuple_GET_SIZE(consts) ; j++) { + if (PyTuple_GET_ITEM(consts, j) == Py_None) { + codestr[i] = LOAD_CONST; + SETARG(codestr, i, j); + break; + } + } break; *************** *** 442,446 **** if (!ISBASICBLOCK(blocks,i,6)) continue; ! if (GETARG(codestr, i) == 2 && \ GETARG(codestr, i+3) == 2) { codestr[i] = ROT_TWO; --- 458,462 ---- if (!ISBASICBLOCK(blocks,i,6)) continue; ! if (GETARG(codestr, i) == 2 && GETARG(codestr, i+3) == 2) { codestr[i] = ROT_TWO; *************** *** 451,455 **** continue; } ! if (GETARG(codestr, i) == 3 && \ GETARG(codestr, i+3) == 3) { codestr[i] = ROT_THREE; --- 467,471 ---- continue; } ! if (GETARG(codestr, i) == 3 && GETARG(codestr, i+3) == 3) { codestr[i] = ROT_THREE; *************** *** 543,547 **** co->co_stacksize = stacksize; co->co_flags = flags; ! co->co_code = optimize_code(code, consts); Py_INCREF(consts); co->co_consts = consts; --- 559,563 ---- co->co_stacksize = stacksize; co->co_flags = flags; ! co->co_code = optimize_code(code, consts, names); Py_INCREF(consts); co->co_consts = consts; From rhettinger at users.sourceforge.net Fri Jul 16 14:16:53 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Fri Jul 16 14:16:56 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1041,1.1042 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29689 Modified Files: NEWS Log Message: Treat None as a constant. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1041 retrieving revision 1.1042 diff -C2 -d -r1.1041 -r1.1042 *** NEWS 14 Jul 2004 19:08:28 -0000 1.1041 --- NEWS 16 Jul 2004 12:16:48 -0000 1.1042 *************** *** 27,30 **** --- 27,32 ---- types that support garbage collection. + - Compiler now treats None as a constant. + Extension modules ----------------- From jackjansen at users.sourceforge.net Fri Jul 16 14:34:37 2004 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Fri Jul 16 14:34:40 2004 Subject: [Python-checkins] python/dist/src/Mac/OSX/PythonLauncher factorySettings.plist, 1.4, 1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/OSX/PythonLauncher In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv785 Modified Files: factorySettings.plist Log Message: Cleaned up list of interpreters. Index: factorySettings.plist =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/OSX/PythonLauncher/factorySettings.plist,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** factorySettings.plist 19 Feb 2003 10:37:08 -0000 1.4 --- factorySettings.plist 16 Jul 2004 12:34:23 -0000 1.5 *************** *** 12,19 **** /usr/local/bin/pythonw - /sw/bin/pythonw - /Library/Frameworks/Python.framework/Versions/Current/Resources/Python.app/Contents/MacOS/python /usr/bin/pythonw ! /Applications/MacPython-OSX/python-additions/Python.app/Contents/MacOS/python honourhashbang --- 12,17 ---- /usr/local/bin/pythonw /usr/bin/pythonw ! /sw/bin/pythonw honourhashbang *************** *** 39,54 **** /usr/local/bin/pythonw - /sw/bin/pythonw - /Library/Frameworks/Python.framework/Versions/Current/Resources/Python.app/Contents/MacOS/python - /usr/bin/pythonw - /Applications/MacPython-OSX/python-additions/Python.app/Contents/MacOS/python /usr/local/bin/python ! /sw/bin/python ! /Library/Frameworks/Python.framework/Versions/Current/bin/python /usr/bin/python honourhashbang ! nosite optimize --- 37,49 ---- /usr/local/bin/pythonw /usr/local/bin/python ! /usr/bin/pythonw /usr/bin/python + /sw/bin/pythonw + /sw/bin/python honourhashbang ! nosite optimize *************** *** 70,81 **** /usr/local/bin/pythonw - /sw/bin/pythonw - /Library/Frameworks/Python.framework/Versions/Current/Resources/Python.app/Contents/MacOS/python - /usr/bin/pythonw - /Applications/MacPython-OSX/python-additions/Python.app/Contents/MacOS/python /usr/local/bin/python ! /sw/bin/python ! /Library/Frameworks/Python.framework/Versions/Current/bin/python /usr/bin/python honourhashbang --- 65,73 ---- /usr/local/bin/pythonw /usr/local/bin/python ! /usr/bin/pythonw /usr/bin/python + /sw/bin/pythonw + /sw/bin/python honourhashbang From jackjansen at users.sourceforge.net Fri Jul 16 14:35:10 2004 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Fri Jul 16 14:35:25 2004 Subject: [Python-checkins] python/dist/src/Mac/OSX/PythonLauncher/PreferenceWindow.nib info.nib, 1.4, 1.5 objects.nib, 1.4, 1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/OSX/PythonLauncher/PreferenceWindow.nib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv834/PreferenceWindow.nib Modified Files: info.nib objects.nib Log Message: Made preference window resizable (and do the most logical thing on resize) Index: info.nib =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/OSX/PythonLauncher/PreferenceWindow.nib/info.nib,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** info.nib 2 Jul 2003 22:08:28 -0000 1.4 --- info.nib 16 Jul 2004 12:35:06 -0000 1.5 *************** *** 4,12 **** IBDocumentLocation ! 660 84 519 534 0 0 1280 1002 IBFramework Version ! 291.0 IBSystem Version ! 6L60 --- 4,16 ---- IBDocumentLocation ! 565 235 519 534 0 0 1280 1002 IBFramework Version ! 364.0 ! IBOpenObjects ! ! 5 ! IBSystem Version ! 7H63 Index: objects.nib =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/OSX/PythonLauncher/PreferenceWindow.nib/objects.nib,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 Binary files /tmp/cvsCXEOo3 and /tmp/cvsFzhzAw differ From jackjansen at users.sourceforge.net Fri Jul 16 14:36:04 2004 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Fri Jul 16 14:36:09 2004 Subject: [Python-checkins] python/dist/src/Mac/OSX/PythonLauncher PreferencesWindowController.h, 1.3, 1.4 PreferencesWindowController.m, 1.5, 1.6 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/OSX/PythonLauncher In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1039 Modified Files: PreferencesWindowController.h PreferencesWindowController.m Log Message: The interpreter popup was never filled with any data, fixed. Fixes #775878. Index: PreferencesWindowController.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/OSX/PythonLauncher/PreferencesWindowController.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PreferencesWindowController.h 17 Feb 2003 15:39:59 -0000 1.3 --- PreferencesWindowController.h 16 Jul 2004 12:36:02 -0000 1.4 *************** *** 8,12 **** { IBOutlet NSPopUpButton *filetype; ! IBOutlet NSTextField *interpreter; IBOutlet NSButton *honourhashbang; IBOutlet NSButton *debug; --- 8,12 ---- { IBOutlet NSPopUpButton *filetype; ! IBOutlet NSComboBox *interpreter; IBOutlet NSButton *honourhashbang; IBOutlet NSButton *debug; Index: PreferencesWindowController.m =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/OSX/PythonLauncher/PreferencesWindowController.m,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** PreferencesWindowController.m 20 Jun 2003 22:21:03 -0000 1.5 --- PreferencesWindowController.m 16 Jul 2004 12:36:02 -0000 1.6 *************** *** 30,33 **** --- 30,34 ---- // [[self window] setTitle: script]; + [interpreter reloadData]; [interpreter setStringValue: [settings interpreter]]; [honourhashbang setState: [settings honourhashbang]]; *************** *** 98,112 **** - (unsigned int)comboBox:(NSComboBox *)aComboBox indexOfItemWithStringValue:(NSString *)aString { ! return [[settings interpreters] indexOfObjectIdenticalTo: aString]; } - (id)comboBox:(NSComboBox *)aComboBox objectValueForItemAtIndex:(int)index { ! return [[settings interpreters] objectAtIndex: index]; } - (int)numberOfItemsInComboBox:(NSComboBox *)aComboBox { ! return [[settings interpreters] count]; } --- 99,119 ---- - (unsigned int)comboBox:(NSComboBox *)aComboBox indexOfItemWithStringValue:(NSString *)aString { ! NSArray *interp_list = [settings interpreters]; ! unsigned int rv = [interp_list indexOfObjectIdenticalTo: aString]; ! return rv; } - (id)comboBox:(NSComboBox *)aComboBox objectValueForItemAtIndex:(int)index { ! NSArray *interp_list = [settings interpreters]; ! id rv = [interp_list objectAtIndex: index]; ! return rv; } - (int)numberOfItemsInComboBox:(NSComboBox *)aComboBox { ! NSArray *interp_list = [settings interpreters]; ! int rv = [interp_list count]; ! return rv; } From theller at users.sourceforge.net Fri Jul 16 20:14:40 2004 From: theller at users.sourceforge.net (theller@users.sourceforge.net) Date: Fri Jul 16 20:14:43 2004 Subject: [Python-checkins] python/dist/src/Lib/distutils __init__.py, 1.23, 1.24 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3551 Modified Files: __init__.py Log Message: The new distutils features justify a new version number, imo. If someone has other ideas for the numbering scheme, please change to something else (1.1.0 ?). Index: __init__.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/__init__.py,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** __init__.py 19 Nov 2002 13:12:26 -0000 1.23 --- __init__.py 16 Jul 2004 18:14:37 -0000 1.24 *************** *** 13,15 **** __revision__ = "$Id$" ! __version__ = "1.0.3" --- 13,15 ---- __revision__ = "$Id$" ! __version__ = "1.0.4" From theller at python.net Fri Jul 16 20:15:51 2004 From: theller at python.net (Thomas Heller) Date: Fri Jul 16 20:16:10 2004 Subject: [Python-checkins] python/dist/src/Lib/distutils __init__.py, 1.23, 1.24 In-Reply-To: (theller@users.sourceforge.net's message of "Fri, 16 Jul 2004 11:14:40 -0700") References: Message-ID: theller@users.sourceforge.net writes: > Update of /cvsroot/python/python/dist/src/Lib/distutils > In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3551 > > Modified Files: > __init__.py > Log Message: > The new distutils features justify a new version number, imo. > > If someone has other ideas for the numbering scheme, please change to > something else (1.1.0 ?). After I committed this, it ocurred to me: certainly 2.4.0 ? Thomas From goodger at users.sourceforge.net Fri Jul 16 21:27:26 2004 From: goodger at users.sourceforge.net (goodger@users.sourceforge.net) Date: Fri Jul 16 21:27:29 2004 Subject: [Python-checkins] python/nondist/peps pep-0001.txt,1.43,1.44 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17911 Modified Files: pep-0001.txt Log Message: updated Index: pep-0001.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0001.txt,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -d -r1.43 -r1.44 *** pep-0001.txt 7 May 2003 00:03:13 -0000 1.43 --- pep-0001.txt 16 Jul 2004 19:27:23 -0000 1.44 *************** *** 60,67 **** appropriate forums, and attempts to build community consensus around the idea. The PEP champion (a.k.a. Author) should first attempt to ! ascertain whether the idea is PEP-able. Small enhancements or patches ! often don't need a PEP and can be injected into the Python development ! work flow with a patch submission to the SourceForge `patch manager`_ ! or `feature request tracker`_. The PEP champion then emails the PEP editor with a --- 60,69 ---- appropriate forums, and attempts to build community consensus around the idea. The PEP champion (a.k.a. Author) should first attempt to ! ascertain whether the idea is PEP-able. Posting to the ! comp.lang.python newsgroup (a.k.a. python-list@python.org mailing ! list) is recommended. Small enhancements or patches often don't need ! a PEP and can be injected into the Python development work flow with a ! patch submission to the SourceForge `patch manager`_ or `feature ! request tracker`_. The PEP champion then emails the PEP editor with a From tim_one at users.sourceforge.net Sat Jul 17 03:42:29 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sat Jul 17 03:42:33 2004 Subject: [Python-checkins] python/dist/src/Doc/api concrete.tex,1.46,1.47 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/api In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14897/Doc/api Modified Files: concrete.tex Log Message: Supply missing word in new datetime docs, aggravated by copy-paste-edit. Index: concrete.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/concrete.tex,v retrieving revision 1.46 retrieving revision 1.47 diff -C2 -d -r1.46 -r1.47 *** concrete.tex 11 Jul 2004 19:26:19 -0000 1.46 --- concrete.tex 17 Jul 2004 01:42:26 -0000 1.47 *************** *** 2757,2761 **** \end{cfuncdesc} ! Macros to extract fields from date objects. The argument must an instance of \cdata{PyDateTime_Date}, including subclasses (such as \cdata{PyDateTime_DateTime}). The argument must not be \NULL{}, and --- 2757,2761 ---- \end{cfuncdesc} ! Macros to extract fields from date objects. The argument must be an instance of \cdata{PyDateTime_Date}, including subclasses (such as \cdata{PyDateTime_DateTime}). The argument must not be \NULL{}, and *************** *** 2777,2781 **** \end{cfuncdesc} ! Macros to extract fields from datetime objects. The argument must an instance of \cdata{PyDateTime_DateTime}, including subclasses. The argument must not be \NULL{}, and the type is not checked: --- 2777,2781 ---- \end{cfuncdesc} ! Macros to extract fields from datetime objects. The argument must be an instance of \cdata{PyDateTime_DateTime}, including subclasses. The argument must not be \NULL{}, and the type is not checked: *************** *** 2801,2805 **** \end{cfuncdesc} ! Macros to extract fields from time objects. The argument must an instance of \cdata{PyDateTime_Time}, including subclasses. The argument must not be \NULL{}, and the type is not checked: --- 2801,2805 ---- \end{cfuncdesc} ! Macros to extract fields from time objects. The argument must be an instance of \cdata{PyDateTime_Time}, including subclasses. The argument must not be \NULL{}, and the type is not checked: From tim_one at users.sourceforge.net Sat Jul 17 07:00:55 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sat Jul 17 07:00:58 2004 Subject: [Python-checkins] python/dist/src/Python compile.c,2.307,2.308 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4812/Python Modified Files: compile.c Log Message: optimize_code(): Repaired gross error in new special-casing for None. The preceding case statement was missing a terminating "break" stmt, so fell into the new code by mistake. This caused uncaught out-of-bounds accesses to the "names" tuple, leading to a variety of insane behaviors. Index: compile.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/compile.c,v retrieving revision 2.307 retrieving revision 2.308 diff -C2 -d -r2.307 -r2.308 *** compile.c 16 Jul 2004 12:13:38 -0000 2.307 --- compile.c 17 Jul 2004 05:00:52 -0000 2.308 *************** *** 420,424 **** SETARG(codestr, i, (j^1)); codestr[i+3] = NOP; ! /* Replace LOAD_GLOBAL/LOAD_NAME None with LOAD_CONST None */ case LOAD_NAME: --- 420,425 ---- SETARG(codestr, i, (j^1)); codestr[i+3] = NOP; ! break; ! /* Replace LOAD_GLOBAL/LOAD_NAME None with LOAD_CONST None */ case LOAD_NAME: From akuchling at users.sourceforge.net Sat Jul 17 15:35:45 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sat Jul 17 15:35:49 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libthreading.tex, 1.19, 1.20 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31681 Modified Files: libthreading.tex Log Message: Minor edits Index: libthreading.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libthreading.tex,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** libthreading.tex 14 Jul 2004 19:07:15 -0000 1.19 --- libthreading.tex 17 Jul 2004 13:35:43 -0000 1.20 *************** *** 52,62 **** \begin{classdesc*}{local}{} A class that represents thread-local data. Thread-local data are data ! who's values are thread specific. To manage thread-local data, just create an instance of \class{local} (or a subclass) and store attributes on it: \begin{verbatim} ! >>> mydata = threading.local() ! >>> mydata.x = 1 \end{verbatim} --- 52,62 ---- \begin{classdesc*}{local}{} A class that represents thread-local data. Thread-local data are data ! whose values are thread specific. To manage thread-local data, just create an instance of \class{local} (or a subclass) and store attributes on it: \begin{verbatim} ! mydata = threading.local() ! mydata.x = 1 \end{verbatim} *************** *** 64,68 **** For more details and extensive examples, see the documentation string ! of the _threading_local module. \versionadded{2.4} --- 64,68 ---- For more details and extensive examples, see the documentation string ! of the \module{_threading_local} module. \versionadded{2.4} From perky at users.sourceforge.net Sat Jul 17 15:53:51 2004 From: perky at users.sourceforge.net (perky@users.sourceforge.net) Date: Sat Jul 17 15:53:54 2004 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew24.tex, 1.69, 1.70 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1129 Modified Files: whatsnew24.tex Log Message: SF #990497: Fix a trivial typo in sorted() example. (Submitted by Daniel Pezely) Index: whatsnew24.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew24.tex,v retrieving revision 1.69 retrieving revision 1.70 diff -C2 -d -r1.69 -r1.70 *** whatsnew24.tex 15 Jul 2004 11:52:40 -0000 1.69 --- whatsnew24.tex 17 Jul 2004 13:53:48 -0000 1.70 *************** *** 541,545 **** >>> [10+i for i in sorted(L)] # usable in a list comprehension [11, 12, 13, 14, 15, 16, 17, 18, 19] ! >>> L = [9,7,8,3,2,4,1,6,5] # original is left unchanged [9,7,8,3,2,4,1,6,5] --- 541,545 ---- >>> [10+i for i in sorted(L)] # usable in a list comprehension [11, 12, 13, 14, 15, 16, 17, 18, 19] ! >>> L # original is left unchanged [9,7,8,3,2,4,1,6,5] From akuchling at users.sourceforge.net Sat Jul 17 16:43:34 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sat Jul 17 16:43:38 2004 Subject: [Python-checkins] python/dist/src/Doc/tools py2texi.el,1.9,1.10 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/tools In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7874 Modified Files: py2texi.el Log Message: Add a definition (found in the Debian patches for 2.3.4) Index: py2texi.el =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/tools/py2texi.el,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** py2texi.el 28 Sep 2003 03:10:09 -0000 1.9 --- py2texi.el 17 Jul 2004 14:43:32 -0000 1.10 *************** *** 212,215 **** --- 212,216 ---- (progn (setq author-address (match-string 1 string)) "")) ("b" 1 "@w{\\1}") + ("backslash" 0 "@backslash{}") ("bf" 0 "@destroy") ("bifuncindex" 1 (progn (setq findex t) "@findex{\\1}")) From akuchling at users.sourceforge.net Sat Jul 17 16:44:19 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sat Jul 17 16:44:22 2004 Subject: [Python-checkins] python/dist/src/Demo/scripts ftpstats.py,1.4,1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Demo/scripts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8025/Demo/scripts Modified Files: ftpstats.py Log Message: Fix comment typo Index: ftpstats.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/scripts/ftpstats.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ftpstats.py 12 Feb 2004 17:35:03 -0000 1.4 --- ftpstats.py 17 Jul 2004 14:44:17 -0000 1.5 *************** *** 7,11 **** # -m maxitems: restrict number of items in "top-N" lists, default 25. # -s string: restrict statistics to lines containing this string. ! # Default file is /usr/adm/ftpd; a "-" means read stdandard input. # The script must be run on the host where the ftp daemon runs. --- 7,11 ---- # -m maxitems: restrict number of items in "top-N" lists, default 25. # -s string: restrict statistics to lines containing this string. ! # Default file is /usr/adm/ftpd; a "-" means read standard input. # The script must be run on the host where the ftp daemon runs. From perky at users.sourceforge.net Sat Jul 17 16:44:46 2004 From: perky at users.sourceforge.net (perky@users.sourceforge.net) Date: Sat Jul 17 16:44:48 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libcodecs.tex,1.30,1.31 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7792 Modified Files: libcodecs.tex Log Message: Change CJK encoding aliases to their most popular variation of hyphen and underscores in consistency of non-CJK aliases. (Spotted by Mike Brown at SF #969415) Index: libcodecs.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libcodecs.tex,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** libcodecs.tex 2 Jul 2004 02:14:34 -0000 1.30 --- libcodecs.tex 17 Jul 2004 14:44:43 -0000 1.31 *************** *** 546,550 **** \lineiii{big5} ! {big5_tw, csbig5} {Traditional Chinese} --- 546,550 ---- \lineiii{big5} ! {big5-tw, csbig5} {Traditional Chinese} *************** *** 634,638 **** \lineiii{cp932} ! {932, ms932, mskanji, ms_kanji} {Japanese} --- 634,638 ---- \lineiii{cp932} ! {932, ms932, mskanji, ms-kanji} {Japanese} *************** *** 694,698 **** \lineiii{euc_jp} ! {eucjp, ujis, u_jis} {Japanese} --- 694,698 ---- \lineiii{euc_jp} ! {eucjp, ujis, u-jis} {Japanese} *************** *** 702,711 **** \lineiii{euc_kr} ! {euckr, korean, ksc5601, ks_c_5601, ks_c_5601_1987, ksx1001, ks_x_1001} {Korean} \lineiii{gb2312} ! {chinese, csiso58gb231280, euc_cn, euccn, eucgb2312_cn, gb2312_1980, ! gb2312_80, iso_ir_58} {Simplified Chinese} --- 702,711 ---- \lineiii{euc_kr} ! {euckr, korean, ksc5601, ks_c-5601, ks_c-5601-1987, ksx1001, ks_x-1001} {Korean} \lineiii{gb2312} ! {chinese, csiso58gb231280, euc-cn, euccn, eucgb2312-cn, gb2312-1980, ! gb2312-80, iso-ir-58} {Simplified Chinese} *************** *** 715,747 **** \lineiii{gb18030} ! {gb18030_2000} {Unified Chinese} \lineiii{hz} ! {hzgb, hz_gb, hz_gb_2312} {Simplified Chinese} \lineiii{iso2022_jp} ! {csiso2022jp, iso2022jp, iso_2022_jp} {Japanese} \lineiii{iso2022_jp_1} ! {iso2022jp_1, iso_2022_jp_1} {Japanese} \lineiii{iso2022_jp_2} ! {iso2022jp_2, iso_2022_jp_2} {Japanese, Korean, Simplified Chinese, Western Europe, Greek} \lineiii{iso2022_jp_3} ! {iso2022jp_3, iso_2022_jp_3} {Japanese} \lineiii{iso2022_jp_ext} ! {iso2022jp_ext, iso_2022_jp_ext} {Japanese} \lineiii{iso2022_kr} ! {csiso2022kr, iso2022kr, iso_2022_kr} {Korean} --- 715,747 ---- \lineiii{gb18030} ! {gb18030-2000} {Unified Chinese} \lineiii{hz} ! {hzgb, hz-gb, hz-gb-2312} {Simplified Chinese} \lineiii{iso2022_jp} ! {csiso2022jp, iso2022jp, iso-2022-jp} {Japanese} \lineiii{iso2022_jp_1} ! {iso2022jp-1, iso-2022-jp-1} {Japanese} \lineiii{iso2022_jp_2} ! {iso2022jp-2, iso-2022-jp-2} {Japanese, Korean, Simplified Chinese, Western Europe, Greek} \lineiii{iso2022_jp_3} ! {iso2022jp-3, iso-2022-jp-3} {Japanese} \lineiii{iso2022_jp_ext} ! {iso2022jp-ext, iso-2022-jp-ext} {Japanese} \lineiii{iso2022_kr} ! {csiso2022kr, iso2022kr, iso-2022-kr} {Korean} From rhettinger at users.sourceforge.net Sat Jul 17 23:46:27 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Jul 17 23:46:30 2004 Subject: [Python-checkins] python/dist/src/Python compile.c,2.308,2.309 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv414/Python Modified Files: compile.c Log Message: Upgrade None assignment SyntaxWarning to a SyntaxError. Index: compile.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/compile.c,v retrieving revision 2.308 retrieving revision 2.309 diff -C2 -d -r2.308 -r2.309 *** compile.c 17 Jul 2004 05:00:52 -0000 2.308 --- compile.c 17 Jul 2004 21:46:24 -0000 2.309 *************** *** 1228,1235 **** else msg = "deleting None"; ! if (issue_warning(msg, c->c_filename, c->c_lineno) < 0) { ! c->c_errors++; ! return -1; ! } } return 0; --- 1228,1233 ---- else msg = "deleting None"; ! com_error(c, PyExc_SyntaxError, msg); ! return -1; } return 0; *************** *** 1248,1252 **** none_assignment_check(c, name, kind == VAR_STORE)) { - c->c_errors++; i = 255; goto done; --- 1246,1249 ---- *************** *** 5484,5489 **** *name == 'N' && strcmp(name, "None") == 0) { ! if (symtable_warn(st, "argument named None")) ! return -1; } if (_Py_Mangle(st->st_private, name, buffer, sizeof(buffer))) --- 5481,5488 ---- *name == 'N' && strcmp(name, "None") == 0) { ! PyErr_SetString(PyExc_SyntaxError, ! "Invalid syntax. Assignment to None."); ! symtable_error(st, 0); ! return -1; } if (_Py_Mangle(st->st_private, name, buffer, sizeof(buffer))) From rhettinger at users.sourceforge.net Sat Jul 17 23:46:27 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Jul 17 23:46:32 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_compile.py, 1.20, 1.21 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv414/Lib/test Modified Files: test_compile.py Log Message: Upgrade None assignment SyntaxWarning to a SyntaxError. Index: test_compile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_compile.py,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** test_compile.py 29 Nov 2003 23:52:12 -0000 1.20 --- test_compile.py 17 Jul 2004 21:46:25 -0000 1.21 *************** *** 139,142 **** --- 139,157 ---- self.assertEqual(j, -1) + def test_none_assignment(self): + stmts = [ + 'None = 0', + 'None += 0', + '__builtins__.None = 0', + 'def None(): pass', + 'class None: pass', + '(a, None) = 0, 0', + 'for None in range(10): pass', + 'def f(None): pass', + ] + for stmt in stmts: + stmt += "\n" + self.assertRaises(SyntaxError, compile, stmt, 'tmp', 'single') + self.assertRaises(SyntaxError, compile, stmt, 'tmp', 'exec') def test_main(): From tim_one at users.sourceforge.net Sun Jul 18 01:44:34 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 01:44:37 2004 Subject: [Python-checkins] python/dist/src/PCbuild rt.bat,1.8,1.9 Message-ID: Update of /cvsroot/python/python/dist/src/PCbuild In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17109/PCbuild Modified Files: rt.bat Log Message: Temporarily add the Tcl/Tk bin directory to PATH, so that test_tcl can actually run. When it fails, it pops up a dialog box, and the test run hangs waiting for you to click OK -- that sucks too much to bear. Index: rt.bat =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/rt.bat,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** rt.bat 7 Aug 2002 19:06:27 -0000 1.8 --- rt.bat 17 Jul 2004 23:44:32 -0000 1.9 *************** *** 19,22 **** --- 19,24 ---- @set _qmode=no @set _dashO= + @set _oldpath=%PATH% + @PATH %PATH%;..\..\tcl84\bin @goto CheckOpts :Again *************** *** 40,41 **** --- 42,45 ---- @set _qmode= @set _dashO= + @PATH %_oldpath% + @set _oldpath= From tim_one at users.sourceforge.net Sun Jul 18 02:00:06 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 02:00:09 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_pyclbr.py, 1.19, 1.20 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18845/Lib/test Modified Files: test_pyclbr.py Log Message: The Darwin-specific getproxies_internetconfig() was added to urllib, causing test_pyclbr to fail on all other platforms. Added that routine to the urllib "ignore" list. Removed the special case for "g" in the pickle module. types.py deletes "g" from its namespace; maybe it didn't always. Whatever, the special case isn't needed today. Index: test_pyclbr.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_pyclbr.py,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** test_pyclbr.py 16 Nov 2003 16:17:48 -0000 1.19 --- test_pyclbr.py 18 Jul 2004 00:00:03 -0000 1.20 *************** *** 141,146 **** cm('mhlib') cm('urllib', ignore=('getproxies_registry', ! 'open_https')) # not on all platforms ! cm('pickle', ignore=('g',)) # from types import * cm('aifc', ignore=('openfp',)) # set with = in module cm('Cookie') --- 141,146 ---- cm('mhlib') cm('urllib', ignore=('getproxies_registry', ! 'open_https', ! 'getproxies_internetconfig',)) # not on all platforms cm('aifc', ignore=('openfp',)) # set with = in module cm('Cookie') From tim_one at users.sourceforge.net Sun Jul 18 02:08:13 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 02:08:17 2004 Subject: [Python-checkins] python/dist/src/Lib types.py,1.30,1.31 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20425/Lib Modified Files: types.py Log Message: Oops! Restored the pickle test to test_pyclbr, but changed types.py so that pyclbr doesn't need to special-case modules that do "from types import *". Index: types.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/types.py,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** types.py 10 Feb 2003 19:38:33 -0000 1.30 --- types.py 18 Jul 2004 00:08:11 -0000 1.31 *************** *** 49,56 **** pass ! def g(): yield 1 ! GeneratorType = type(g()) ! del g class _C: --- 49,55 ---- pass ! def _g(): yield 1 ! GeneratorType = type(_g()) class _C: *************** *** 88,90 **** NotImplementedType = type(NotImplemented) ! del sys, _f, _C, _x # Not for export --- 87,89 ---- NotImplementedType = type(NotImplemented) ! del sys, _f, _g, _C, _x # Not for export From tim_one at users.sourceforge.net Sun Jul 18 02:08:13 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 02:08:18 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_pyclbr.py, 1.20, 1.21 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20425/Lib/test Modified Files: test_pyclbr.py Log Message: Oops! Restored the pickle test to test_pyclbr, but changed types.py so that pyclbr doesn't need to special-case modules that do "from types import *". Index: test_pyclbr.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_pyclbr.py,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** test_pyclbr.py 18 Jul 2004 00:00:03 -0000 1.20 --- test_pyclbr.py 18 Jul 2004 00:08:11 -0000 1.21 *************** *** 143,146 **** --- 143,147 ---- 'open_https', 'getproxies_internetconfig',)) # not on all platforms + cm('pickle') cm('aifc', ignore=('openfp',)) # set with = in module cm('Cookie') From perky at users.sourceforge.net Sun Jul 18 05:06:29 2004 From: perky at users.sourceforge.net (perky@users.sourceforge.net) Date: Sun Jul 18 05:06:32 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1042,1.1043 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9316/Misc Modified Files: NEWS Log Message: Bring CJKCodecs 1.1 into trunk. This completely reorganizes source and installed layouts to make maintenance simple and easy. And it also adds four new codecs; big5hkscs, euc-jis-2004, shift-jis-2004 and iso2022-jp-2004. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1042 retrieving revision 1.1043 diff -C2 -d -r1.1042 -r1.1043 *** NEWS 16 Jul 2004 12:16:48 -0000 1.1042 --- NEWS 18 Jul 2004 03:06:26 -0000 1.1043 *************** *** 35,38 **** --- 35,41 ---- ------- + - Several new unicode codecs are added: big5hkscs, euc_jis_2004, + iso2022_jp_2004, shift_jis_2004. + - Bug #788520. Queue.{get, get_nowait, put, put_nowait} have new implementations, exploiting Conditions (which didn't exist at the time From perky at users.sourceforge.net Sun Jul 18 05:06:29 2004 From: perky at users.sourceforge.net (perky@users.sourceforge.net) Date: Sun Jul 18 05:06:34 2004 Subject: [Python-checkins] python/dist/src/Modules Setup.dist,1.44,1.45 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9316/Modules Modified Files: Setup.dist Log Message: Bring CJKCodecs 1.1 into trunk. This completely reorganizes source and installed layouts to make maintenance simple and easy. And it also adds four new codecs; big5hkscs, euc-jis-2004, shift-jis-2004 and iso2022-jp-2004. Index: Setup.dist =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/Setup.dist,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** Setup.dist 28 Jan 2004 09:03:28 -0000 1.44 --- Setup.dist 18 Jul 2004 03:06:27 -0000 1.45 *************** *** 485,524 **** #_multibytecodec cjkcodecs/multibytecodec.c ! # mapdata modules are required to support their respective dependent codecs ! #_codecs_mapdata_ja_JP cjkcodecs/mapdata_ja_JP.c ! #_codecs_mapdata_ko_KR cjkcodecs/mapdata_ko_KR.c ! #_codecs_mapdata_zh_CN cjkcodecs/mapdata_zh_CN.c ! #_codecs_mapdata_zh_TW cjkcodecs/mapdata_zh_TW.c ! ! # ja_JP codecs ! #_codecs_cp932 cjkcodecs/_cp932.c ! #_codecs_euc_jisx0213 cjkcodecs/_euc_jisx0213.c ! #_codecs_euc_jp cjkcodecs/_euc_jp.c ! #_codecs_iso2022_jp cjkcodecs/_iso2022_jp.c ! #_codecs_iso2022_jp_1 cjkcodecs/_iso2022_jp_1.c ! #_codecs_iso2022_jp_3 cjkcodecs/_iso2022_jp_3.c ! #_codecs_iso2022_jp_ext cjkcodecs/_iso2022_jp_ext.c ! #_codecs_shift_jis cjkcodecs/_shift_jis.c ! #_codecs_shift_jisx0213 cjkcodecs/_shift_jisx0213.c ! ! # ko_KR codecs ! #_codecs_cp949 cjkcodecs/_cp949.c ! #_codecs_euc_kr cjkcodecs/_euc_kr.c ! #_codecs_iso2022_kr cjkcodecs/_iso2022_kr.c ! #_codecs_johab cjkcodecs/_johab.c ! ! # zh_CN codecs ! #_codecs_gb18030 cjkcodecs/_gb18030.c ! #_codecs_gb2312 cjkcodecs/_gb2312.c ! #_codecs_gbk cjkcodecs/_gbk.c ! #_codecs_hz cjkcodecs/_hz.c ! ! # zh_TW codecs ! #_codecs_big5 cjkcodecs/_big5.c ! #_codecs_cp950 cjkcodecs/_cp950.c ! ! # international codecs ! #_codecs_iso2022_jp_2 cjkcodecs/_iso2022_jp_2.c # requires ja_JP, ko_KR, zh_CN ! # Example -- included for reference only: --- 485,494 ---- #_multibytecodec cjkcodecs/multibytecodec.c ! #_codecs_cn cjkcodecs/_codecs_cn.c ! #_codecs_hk cjkcodecs/_codecs_hk.c ! #_codecs_iso2022 cjkcodecs/_codecs_iso2022.c ! #_codecs_jp cjkcodecs/_codecs_jp.c ! #_codecs_kr cjkcodecs/_codecs_kr.c ! #_codecs_tw cjkcodecs/_codecs_tw.c # Example -- included for reference only: From perky at users.sourceforge.net Sun Jul 18 05:06:32 2004 From: perky at users.sourceforge.net (perky@users.sourceforge.net) Date: Sun Jul 18 05:06:36 2004 Subject: [Python-checkins] python/dist/src/Modules/cjkcodecs _codecs_cn.c, NONE, 1.1 _codecs_hk.c, NONE, 1.1 _codecs_iso2022.c, NONE, 1.1 _codecs_jp.c, NONE, 1.1 _codecs_kr.c, NONE, 1.1 _codecs_tw.c, NONE, 1.1 _codecs_unicode.c, NONE, 1.1 cjkcodecs.h, NONE, 1.1 emu_jisx0213_2000.h, NONE, 1.1 mappings_cn.h, NONE, 1.1 mappings_cns11643.h, NONE, 1.1 mappings_hk.h, NONE, 1.1 mappings_jisx0213_pair.h, NONE, 1.1 mappings_jp.h, NONE, 1.1 mappings_kr.h, NONE, 1.1 mappings_tw.h, NONE, 1.1 README, 1.1, 1.2 alg_jisx0201.h, 1.1, 1.2 multibytecodec.c, 1.1, 1.2 multibytecodec.h, 1.1, 1.2 _big5.c, 1.2, NONE _cp932.c, 1.2, NONE _cp949.c, 1.2, NONE _cp950.c, 1.2, NONE _euc_jisx0213.c, 1.2, NONE _euc_jp.c, 1.2, NONE _euc_kr.c, 1.2, NONE _gb18030.c, 1.1, NONE _gb2312.c, 1.2, NONE _gbk.c, 1.2, NONE _hz.c, 1.2, NONE _iso2022_jp.c, 1.2, NONE _iso2022_jp_1.c, 1.2, NONE _iso2022_jp_2.c, 1.2, NONE _iso2022_jp_3.c, 1.2, NONE _iso2022_jp_ext.c, 1.2, NONE _iso2022_kr.c, 1.2, NONE _johab.c, 1.2, NONE _shift_jis.c, 1.2, NONE _shift_jisx0213.c, 1.2, NONE alg_iso8859_1.h, 1.1, NONE alg_iso8859_7.h, 1.1, NONE cjkcommon.h, 1.1, NONE codeccommon.h, 1.2, NONE codecentry.h, 1.1, NONE iso2022common.h, 1.2, NONE map_big5.h, 1.1, NONE map_cp932ext.h, 1.1, NONE map_cp949.h, 1.1, NONE map_cp949ext.h, 1.1, NONE map_cp950ext.h, 1.1, NONE map_gb18030ext.h, 1.1, NONE map_gb18030uni.h, 1.1, NONE map_gb2312.h, 1.1, NONE map_gbcommon.h, 1.1, NONE map_gbkext.h, 1.1, NONE map_jisx0208.h, 1.1, NONE map_jisx0212.h, 1.1, NONE map_jisx0213.h, 1.1, NONE map_jisx0213_pairs.h, 1.1, NONE map_jisxcommon.h, 1.1, NONE map_ksx1001.h, 1.1, NONE mapdata_ja_JP.c, 1.1, NONE mapdata_ko_KR.c, 1.1, NONE mapdata_zh_CN.c, 1.1, NONE mapdata_zh_TW.c, 1.1, NONE tweak_gbk.h, 1.1, NONE Message-ID: Update of /cvsroot/python/python/dist/src/Modules/cjkcodecs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9316/Modules/cjkcodecs Modified Files: README alg_jisx0201.h multibytecodec.c multibytecodec.h Added Files: _codecs_cn.c _codecs_hk.c _codecs_iso2022.c _codecs_jp.c _codecs_kr.c _codecs_tw.c _codecs_unicode.c cjkcodecs.h emu_jisx0213_2000.h mappings_cn.h mappings_cns11643.h mappings_hk.h mappings_jisx0213_pair.h mappings_jp.h mappings_kr.h mappings_tw.h Removed Files: _big5.c _cp932.c _cp949.c _cp950.c _euc_jisx0213.c _euc_jp.c _euc_kr.c _gb18030.c _gb2312.c _gbk.c _hz.c _iso2022_jp.c _iso2022_jp_1.c _iso2022_jp_2.c _iso2022_jp_3.c _iso2022_jp_ext.c _iso2022_kr.c _johab.c _shift_jis.c _shift_jisx0213.c alg_iso8859_1.h alg_iso8859_7.h cjkcommon.h codeccommon.h codecentry.h iso2022common.h map_big5.h map_cp932ext.h map_cp949.h map_cp949ext.h map_cp950ext.h map_gb18030ext.h map_gb18030uni.h map_gb2312.h map_gbcommon.h map_gbkext.h map_jisx0208.h map_jisx0212.h map_jisx0213.h map_jisx0213_pairs.h map_jisxcommon.h map_ksx1001.h mapdata_ja_JP.c mapdata_ko_KR.c mapdata_zh_CN.c mapdata_zh_TW.c tweak_gbk.h Log Message: Bring CJKCodecs 1.1 into trunk. This completely reorganizes source and installed layouts to make maintenance simple and easy. And it also adds four new codecs; big5hkscs, euc-jis-2004, shift-jis-2004 and iso2022-jp-2004. --- NEW FILE: _codecs_cn.c --- /* * _codecs_cn.c: Codecs collection for Mainland Chinese encodings * * Written by Hye-Shik Chang * $CJKCodecs: _codecs_cn.c,v 1.8 2004/07/07 14:59:26 perky Exp $ */ #include "cjkcodecs.h" #include "mappings_cn.h" #define GBK_PREDECODE(dc1, dc2, assi) \ if ((dc1) == 0xa1 && (dc2) == 0xaa) (assi) = 0x2014; \ else if ((dc1) == 0xa8 && (dc2) == 0x44) (assi) = 0x2015; \ else if ((dc1) == 0xa1 && (dc2) == 0xa4) (assi) = 0x00b7; #define GBK_PREENCODE(code, assi) \ if ((code) == 0x2014) (assi) = 0xa1aa; \ else if ((code) == 0x2015) (assi) = 0xa844; \ else if ((code) == 0x00b7) (assi) = 0xa1a4; /* * GB2312 codec */ ENCODER(gb2312) { while (inleft > 0) { Py_UNICODE c = IN1; DBCHAR code; if (c < 0x80) { WRITE1((unsigned char)c) NEXT(1, 1) continue; } UCS4INVALID(c) REQUIRE_OUTBUF(2) TRYMAP_ENC(gbcommon, code, c); else return 1; if (code & 0x8000) /* MSB set: GBK */ return 1; OUT1((code >> 8) | 0x80) OUT2((code & 0xFF) | 0x80) NEXT(1, 2) } return 0; } DECODER(gb2312) { while (inleft > 0) { unsigned char c = **inbuf; REQUIRE_OUTBUF(1) if (c < 0x80) { OUT1(c) NEXT(1, 1) continue; } REQUIRE_INBUF(2) TRYMAP_DEC(gb2312, **outbuf, c ^ 0x80, IN2 ^ 0x80) { NEXT(2, 1) } else return 2; } return 0; } /* * GBK codec */ ENCODER(gbk) { while (inleft > 0) { Py_UNICODE c = IN1; DBCHAR code; if (c < 0x80) { WRITE1((unsigned char)c) NEXT(1, 1) continue; } UCS4INVALID(c) REQUIRE_OUTBUF(2) GBK_PREENCODE(c, code) else TRYMAP_ENC(gbcommon, code, c); else return 1; OUT1((code >> 8) | 0x80) if (code & 0x8000) OUT2((code & 0xFF)) /* MSB set: GBK */ else OUT2((code & 0xFF) | 0x80) /* MSB unset: GB2312 */ NEXT(1, 2) } return 0; } DECODER(gbk) { while (inleft > 0) { unsigned char c = IN1; REQUIRE_OUTBUF(1) if (c < 0x80) { OUT1(c) NEXT(1, 1) continue; } REQUIRE_INBUF(2) GBK_PREDECODE(c, IN2, **outbuf) else TRYMAP_DEC(gb2312, **outbuf, c ^ 0x80, IN2 ^ 0x80); else TRYMAP_DEC(gbkext, **outbuf, c, IN2); else return 2; NEXT(2, 1) } return 0; } /* * GB18030 codec */ ENCODER(gb18030) { while (inleft > 0) { ucs4_t c = IN1; DBCHAR code; if (c < 0x80) { WRITE1(c) NEXT(1, 1) continue; } DECODE_SURROGATE(c) if (c > 0x10FFFF) #if Py_UNICODE_SIZE == 2 return 2; /* surrogates pair */ #else return 1; #endif else if (c >= 0x10000) { ucs4_t tc = c - 0x10000; REQUIRE_OUTBUF(4) OUT4((unsigned char)(tc % 10) + 0x30) tc /= 10; OUT3((unsigned char)(tc % 126) + 0x81) tc /= 126; OUT2((unsigned char)(tc % 10) + 0x30) tc /= 10; OUT1((unsigned char)(tc + 0x90)) #if Py_UNICODE_SIZE == 2 NEXT(2, 4) /* surrogates pair */ #else NEXT(1, 4) #endif continue; } REQUIRE_OUTBUF(2) GBK_PREENCODE(c, code) else TRYMAP_ENC(gbcommon, code, c); else TRYMAP_ENC(gb18030ext, code, c); else { const struct _gb18030_to_unibmp_ranges *utrrange; REQUIRE_OUTBUF(4) for (utrrange = gb18030_to_unibmp_ranges; utrrange->first != 0; utrrange++) if (utrrange->first <= c && c <= utrrange->last) { Py_UNICODE tc; tc = c - utrrange->first + utrrange->base; OUT4((unsigned char)(tc % 10) + 0x30) tc /= 10; OUT3((unsigned char)(tc % 126) + 0x81) tc /= 126; OUT2((unsigned char)(tc % 10) + 0x30) tc /= 10; OUT1((unsigned char)tc + 0x81) NEXT(1, 4) break; } if (utrrange->first == 0) { PyErr_SetString(PyExc_RuntimeError, "unicode mapping invalid"); return 1; } continue; } OUT1((code >> 8) | 0x80) if (code & 0x8000) OUT2((code & 0xFF)) /* MSB set: GBK or GB18030ext */ else OUT2((code & 0xFF) | 0x80) /* MSB unset: GB2312 */ NEXT(1, 2) } return 0; } DECODER(gb18030) { while (inleft > 0) { unsigned char c = IN1, c2; REQUIRE_OUTBUF(1) if (c < 0x80) { OUT1(c) NEXT(1, 1) continue; } REQUIRE_INBUF(2) c2 = IN2; if (c2 >= 0x30 && c2 <= 0x39) { /* 4 bytes seq */ const struct _gb18030_to_unibmp_ranges *utr; unsigned char c3, c4; ucs4_t lseq; REQUIRE_INBUF(4) c3 = IN3; c4 = IN4; if (c < 0x81 || c3 < 0x81 || c4 < 0x30 || c4 > 0x39) return 4; c -= 0x81; c2 -= 0x30; c3 -= 0x81; c4 -= 0x30; if (c < 4) { /* U+0080 - U+FFFF */ lseq = ((ucs4_t)c * 10 + c2) * 1260 + (ucs4_t)c3 * 10 + c4; if (lseq < 39420) { for (utr = gb18030_to_unibmp_ranges; lseq >= (utr + 1)->base; utr++) ; OUT1(utr->first - utr->base + lseq) NEXT(4, 1) continue; } } else if (c >= 15) { /* U+10000 - U+10FFFF */ lseq = 0x10000 + (((ucs4_t)c-15) * 10 + c2) * 1260 + (ucs4_t)c3 * 10 + c4; if (lseq <= 0x10FFFF) { WRITEUCS4(lseq); NEXT_IN(4) continue; } } return 4; } GBK_PREDECODE(c, c2, **outbuf) else TRYMAP_DEC(gb2312, **outbuf, c ^ 0x80, c2 ^ 0x80); else TRYMAP_DEC(gbkext, **outbuf, c, c2); else TRYMAP_DEC(gb18030ext, **outbuf, c, c2); else return 2; NEXT(2, 1) } return 0; } /* * HZ codec */ ENCODER_INIT(hz) { state->i = 0; return 0; } ENCODER_RESET(hz) { if (state->i != 0) { WRITE2('~', '}') state->i = 0; NEXT_OUT(2) } return 0; } ENCODER(hz) { while (inleft > 0) { Py_UNICODE c = IN1; DBCHAR code; if (c < 0x80) { if (state->i == 0) { WRITE1((unsigned char)c) NEXT(1, 1) } else { WRITE3('~', '}', (unsigned char)c) NEXT(1, 3) state->i = 0; } continue; } UCS4INVALID(c) TRYMAP_ENC(gbcommon, code, c); else return 1; if (code & 0x8000) /* MSB set: GBK */ return 1; if (state->i == 0) { WRITE4('~', '{', code >> 8, code & 0xff) NEXT(1, 4) state->i = 1; } else { WRITE2(code >> 8, code & 0xff) NEXT(1, 2) } } return 0; } DECODER_INIT(hz) { state->i = 0; return 0; } DECODER_RESET(hz) { state->i = 0; return 0; } DECODER(hz) { while (inleft > 0) { unsigned char c = IN1; if (c == '~') { unsigned char c2 = IN2; REQUIRE_INBUF(2) if (c2 == '~') { WRITE1('~') NEXT(2, 1) continue; } else if (c2 == '{' && state->i == 0) state->i = 1; /* set GB */ else if (c2 == '}' && state->i == 1) state->i = 0; /* set ASCII */ else if (c2 == '\n') ; /* line-continuation */ else return 2; NEXT(2, 0); continue; } if (c & 0x80) return 1; if (state->i == 0) { /* ASCII mode */ WRITE1(c) NEXT(1, 1) } else { /* GB mode */ REQUIRE_INBUF(2) REQUIRE_OUTBUF(1) TRYMAP_DEC(gb2312, **outbuf, c, IN2) { NEXT(2, 1) } else return 2; } } return 0; } BEGIN_MAPPINGS_LIST MAPPING_DECONLY(gb2312) MAPPING_DECONLY(gbkext) MAPPING_ENCONLY(gbcommon) MAPPING_ENCDEC(gb18030ext) END_MAPPINGS_LIST BEGIN_CODECS_LIST CODEC_STATELESS(gb2312) CODEC_STATELESS(gbk) CODEC_STATELESS(gb18030) CODEC_STATEFUL(hz) END_CODECS_LIST I_AM_A_MODULE_FOR(cn) --- NEW FILE: _codecs_hk.c --- /* * _codecs_hk.c: Codecs collection for encodings from Hong Kong * * Written by Hye-Shik Chang * $CJKCodecs: _codecs_hk.c,v 1.3 2004/07/07 14:59:26 perky Exp $ */ #define USING_IMPORTED_MAPS #include "cjkcodecs.h" #include "mappings_hk.h" /* * BIG5HKSCS codec */ static const encode_map *big5_encmap = NULL; static const decode_map *big5_decmap = NULL; CODEC_INIT(big5hkscs) { static int initialized = 0; if (!initialized && IMPORT_MAP(tw, big5, &big5_encmap, &big5_decmap)) return -1; initialized = 1; return 0; } ENCODER(big5hkscs) { while (inleft > 0) { ucs4_t c = **inbuf; DBCHAR code; int insize; if (c < 0x80) { REQUIRE_OUTBUF(1) **outbuf = (unsigned char)c; NEXT(1, 1) continue; } DECODE_SURROGATE(c) insize = GET_INSIZE(c); REQUIRE_OUTBUF(2) if (c < 0x10000) { TRYMAP_ENC(big5hkscs_bmp, code, c); else TRYMAP_ENC(big5, code, c); else return 1; } else if (c < 0x20000) return insize; else if (c < 0x30000) { TRYMAP_ENC(big5hkscs_nonbmp, code, c & 0xffff); else return insize; } else return insize; OUT1(code >> 8) OUT2(code & 0xFF) NEXT(insize, 2) } return 0; } #define BH2S(c1, c2) (((c1) - 0x88) * (0xfe - 0x40 + 1) + ((c2) - 0x40)) DECODER(big5hkscs) { while (inleft > 0) { unsigned char c = IN1; ucs4_t decoded; REQUIRE_OUTBUF(1) if (c < 0x80) { OUT1(c) NEXT(1, 1) continue; } REQUIRE_INBUF(2) if (0xc6 <= c && c <= 0xc8 && (c >= 0xc7 || IN2 >= 0xa1)) goto hkscsdec; TRYMAP_DEC(big5, **outbuf, c, IN2) { NEXT(2, 1) } else hkscsdec: TRYMAP_DEC(big5hkscs, decoded, c, IN2) { int s = BH2S(c, IN2); const unsigned char *hintbase; assert(0x88 <= c && c <= 0xfe); assert(0x40 <= IN2 && IN2 <= 0xfe); if (BH2S(0x88, 0x40) <= s && s <= BH2S(0xa0, 0xfe)) { hintbase = big5hkscs_phint_0; s -= BH2S(0x88, 0x40); } else if (BH2S(0xc6,0xa1) <= s && s <= BH2S(0xc8,0xfe)){ hintbase = big5hkscs_phint_11939; s -= BH2S(0xc6, 0xa1); } else if (BH2S(0xf9,0xd6) <= s && s <= BH2S(0xfe,0xfe)){ hintbase = big5hkscs_phint_21733; s -= BH2S(0xf9, 0xd6); } else return MBERR_INTERNAL; if (hintbase[s >> 3] & (1 << (s & 7))) { WRITEUCS4(decoded | 0x20000) NEXT_IN(2) } else { OUT1(decoded) NEXT(2, 1) } } else return 2; } return 0; } BEGIN_MAPPINGS_LIST MAPPING_DECONLY(big5hkscs) MAPPING_ENCONLY(big5hkscs_bmp) MAPPING_ENCONLY(big5hkscs_nonbmp) END_MAPPINGS_LIST BEGIN_CODECS_LIST CODEC_STATELESS_WINIT(big5hkscs) END_CODECS_LIST I_AM_A_MODULE_FOR(hk) --- NEW FILE: _codecs_iso2022.c --- /* * _codecs_iso2022.c: Codecs collection for ISO-2022 encodings. * * Written by Hye-Shik Chang * $CJKCodecs: _codecs_iso2022.c,v 1.18 2004/07/07 18:30:17 perky Exp $ */ #define USING_IMPORTED_MAPS #define USING_BINARY_PAIR_SEARCH #define EXTERN_JISX0213_PAIR #define EMULATE_JISX0213_2000_ENCODE_INVALID MAP_UNMAPPABLE #define EMULATE_JISX0213_2000_DECODE_INVALID MAP_UNMAPPABLE #include "cjkcodecs.h" #include "alg_jisx0201.h" #include "emu_jisx0213_2000.h" #include "mappings_jisx0213_pair.h" /* STATE [...1078 lines suppressed...] END_MAPPINGS_LIST #define ISO2022_CODEC(variation) { \ "iso2022_" #variation, \ &iso2022_##variation##_config, \ iso2022_codec_init, \ _STATEFUL_METHODS(iso2022) \ }, BEGIN_CODECS_LIST ISO2022_CODEC(kr) ISO2022_CODEC(jp) ISO2022_CODEC(jp_1) ISO2022_CODEC(jp_2) ISO2022_CODEC(jp_2004) ISO2022_CODEC(jp_3) ISO2022_CODEC(jp_ext) END_CODECS_LIST I_AM_A_MODULE_FOR(iso2022) --- NEW FILE: _codecs_jp.c --- /* * _codecs_jp.c: Codecs collection for Japanese encodings * * Written by Hye-Shik Chang * $CJKCodecs: _codecs_jp.c,v 1.14 2004/07/07 17:54:47 perky Exp $ */ #define USING_BINARY_PAIR_SEARCH #define EMPBASE 0x20000 #include "cjkcodecs.h" #include "mappings_jp.h" #include "mappings_jisx0213_pair.h" #include "alg_jisx0201.h" #include "emu_jisx0213_2000.h" /* * CP932 codec */ ENCODER(cp932) { while (inleft > 0) { Py_UNICODE c = IN1; DBCHAR code; unsigned char c1, c2; if (c <= 0x80) { WRITE1((unsigned char)c) NEXT(1, 1) continue; } else if (c >= 0xff61 && c <= 0xff9f) { WRITE1(c - 0xfec0) NEXT(1, 1) continue; } else if (c >= 0xf8f0 && c <= 0xf8f3) { /* Windows compatability */ REQUIRE_OUTBUF(1) if (c == 0xf8f0) OUT1(0xa0) else OUT1(c - 0xfef1 + 0xfd) NEXT(1, 1) continue; } UCS4INVALID(c) REQUIRE_OUTBUF(2) TRYMAP_ENC(cp932ext, code, c) { OUT1(code >> 8) OUT2(code & 0xff) } else TRYMAP_ENC(jisxcommon, code, c) { if (code & 0x8000) /* MSB set: JIS X 0212 */ return 1; /* JIS X 0208 */ c1 = code >> 8; c2 = code & 0xff; c2 = (((c1 - 0x21) & 1) ? 0x5e : 0) + (c2 - 0x21); c1 = (c1 - 0x21) >> 1; OUT1(c1 < 0x1f ? c1 + 0x81 : c1 + 0xc1) OUT2(c2 < 0x3f ? c2 + 0x40 : c2 + 0x41) } else if (c >= 0xe000 && c < 0xe758) { /* User-defined area */ c1 = (Py_UNICODE)(c - 0xe000) / 188; c2 = (Py_UNICODE)(c - 0xe000) % 188; OUT1(c1 + 0xf0) OUT2(c2 < 0x3f ? c2 + 0x40 : c2 + 0x41) } else return 1; NEXT(1, 2) } return 0; } DECODER(cp932) { while (inleft > 0) { unsigned char c = IN1, c2; REQUIRE_OUTBUF(1) if (c <= 0x80) { OUT1(c) NEXT(1, 1) continue; } else if (c >= 0xa0 && c <= 0xdf) { if (c == 0xa0) OUT1(0xf8f0) /* half-width katakana */ else OUT1(0xfec0 + c) NEXT(1, 1) continue; } else if (c >= 0xfd/* && c <= 0xff*/) { /* Windows compatibility */ OUT1(0xf8f1 - 0xfd + c) NEXT(1, 1) continue; } REQUIRE_INBUF(2) c2 = IN2; TRYMAP_DEC(cp932ext, **outbuf, c, c2); else if ((c >= 0x81 && c <= 0x9f) || (c >= 0xe0 && c <= 0xea)){ if (c2 < 0x40 || (c2 > 0x7e && c2 < 0x80) || c2 > 0xfc) return 2; c = (c < 0xe0 ? c - 0x81 : c - 0xc1); c2 = (c2 < 0x80 ? c2 - 0x40 : c2 - 0x41); c = (2 * c + (c2 < 0x5e ? 0 : 1) + 0x21); c2 = (c2 < 0x5e ? c2 : c2 - 0x5e) + 0x21; TRYMAP_DEC(jisx0208, **outbuf, c, c2); else return 2; } else if (c >= 0xf0 && c <= 0xf9) { if ((c2 >= 0x40 && c2 <= 0x7e) || (c2 >= 0x80 && c2 <= 0xfc)) OUT1(0xe000 + 188 * (c - 0xf0) + (c2 < 0x80 ? c2 - 0x40 : c2 - 0x41)) else return 2; } else return 2; NEXT(2, 1) } return 0; } /* * EUC-JIS-2004 codec */ ENCODER(euc_jis_2004) { while (inleft > 0) { ucs4_t c = IN1; DBCHAR code; int insize; if (c < 0x80) { WRITE1(c) NEXT(1, 1) continue; } DECODE_SURROGATE(c) insize = GET_INSIZE(c); if (c <= 0xFFFF) { EMULATE_JISX0213_2000_ENCODE_BMP(code, c) else TRYMAP_ENC(jisx0213_bmp, code, c) { if (code == MULTIC) { if (inleft < 2) { if (flags & MBENC_FLUSH) { code = find_pairencmap( (ucs2_t)c, 0, jisx0213_pair_encmap, JISX0213_ENCPAIRS); if (code == DBCINV) return 1; } else return MBERR_TOOFEW; } else { code = find_pairencmap( (ucs2_t)c, (*inbuf)[1], jisx0213_pair_encmap, JISX0213_ENCPAIRS); if (code == DBCINV) { code = find_pairencmap( (ucs2_t)c, 0, jisx0213_pair_encmap, JISX0213_ENCPAIRS); if (code == DBCINV) return 1; } else insize = 2; } } } else TRYMAP_ENC(jisxcommon, code, c); else if (c >= 0xff61 && c <= 0xff9f) { /* JIS X 0201 half-width katakana */ WRITE2(0x8e, c - 0xfec0) NEXT(1, 2) continue; } else if (c == 0xff3c) /* F/W REVERSE SOLIDUS (see NOTES) */ code = 0x2140; else if (c == 0xff5e) /* F/W TILDE (see NOTES) */ code = 0x2232; else return 1; } else if (c >> 16 == EMPBASE >> 16) { EMULATE_JISX0213_2000_ENCODE_EMP(code, c) else TRYMAP_ENC(jisx0213_emp, code, c & 0xffff); else return insize; } else return insize; if (code & 0x8000) { /* Codeset 2 */ WRITE3(0x8f, code >> 8, (code & 0xFF) | 0x80) NEXT(insize, 3) } else { /* Codeset 1 */ WRITE2((code >> 8) | 0x80, (code & 0xFF) | 0x80) NEXT(insize, 2) } } return 0; } DECODER(euc_jis_2004) { while (inleft > 0) { unsigned char c = IN1; ucs4_t code; REQUIRE_OUTBUF(1) if (c < 0x80) { OUT1(c) NEXT(1, 1) continue; } if (c == 0x8e) { /* JIS X 0201 half-width katakana */ unsigned char c2; REQUIRE_INBUF(2) c2 = IN2; if (c2 >= 0xa1 && c2 <= 0xdf) { OUT1(0xfec0 + c2) NEXT(2, 1) } else return 2; } else if (c == 0x8f) { unsigned char c2, c3; REQUIRE_INBUF(3) c2 = IN2 ^ 0x80; c3 = IN3 ^ 0x80; /* JIS X 0213 Plane 2 or JIS X 0212 (see NOTES) */ EMULATE_JISX0213_2000_DECODE_PLANE2(**outbuf, c2, c3) else TRYMAP_DEC(jisx0213_2_bmp, **outbuf, c2, c3) ; else TRYMAP_DEC(jisx0213_2_emp, code, c2, c3) { WRITEUCS4(EMPBASE | code) NEXT_IN(3) continue; } else TRYMAP_DEC(jisx0212, **outbuf, c2, c3) ; else return 3; NEXT(3, 1) } else { unsigned char c2; REQUIRE_INBUF(2) c ^= 0x80; c2 = IN2 ^ 0x80; /* JIS X 0213 Plane 1 */ EMULATE_JISX0213_2000_DECODE_PLANE1(**outbuf, c, c2) else if (c == 0x21 && c2 == 0x40) **outbuf = 0xff3c; else if (c == 0x22 && c2 == 0x32) **outbuf = 0xff5e; else TRYMAP_DEC(jisx0208, **outbuf, c, c2); else TRYMAP_DEC(jisx0213_1_bmp, **outbuf, c, c2); else TRYMAP_DEC(jisx0213_1_emp, code, c, c2) { WRITEUCS4(EMPBASE | code) NEXT_IN(2) continue; } else TRYMAP_DEC(jisx0213_pair, code, c, c2) { WRITE2(code >> 16, code & 0xffff) NEXT(2, 2) continue; } else return 2; NEXT(2, 1) } } return 0; } /* * EUC-JP codec */ ENCODER(euc_jp) { while (inleft > 0) { Py_UNICODE c = IN1; DBCHAR code; if (c < 0x80) { WRITE1((unsigned char)c) NEXT(1, 1) continue; } UCS4INVALID(c) TRYMAP_ENC(jisxcommon, code, c); else if (c >= 0xff61 && c <= 0xff9f) { /* JIS X 0201 half-width katakana */ WRITE2(0x8e, c - 0xfec0) NEXT(1, 2) continue; } #ifndef STRICT_BUILD else if (c == 0xff3c) /* FULL-WIDTH REVERSE SOLIDUS */ code = 0x2140; else if (c == 0xa5) { /* YEN SIGN */ WRITE1(0x5c); NEXT(1, 1) continue; } else if (c == 0x203e) { /* OVERLINE */ WRITE1(0x7e); NEXT(1, 1) continue; } #endif else return 1; if (code & 0x8000) { /* JIS X 0212 */ WRITE3(0x8f, code >> 8, (code & 0xFF) | 0x80) NEXT(1, 3) } else { /* JIS X 0208 */ WRITE2((code >> 8) | 0x80, (code & 0xFF) | 0x80) NEXT(1, 2) } } return 0; } DECODER(euc_jp) { while (inleft > 0) { unsigned char c = IN1; REQUIRE_OUTBUF(1) if (c < 0x80) { OUT1(c) NEXT(1, 1) continue; } if (c == 0x8e) { /* JIS X 0201 half-width katakana */ unsigned char c2; REQUIRE_INBUF(2) c2 = IN2; if (c2 >= 0xa1 && c2 <= 0xdf) { OUT1(0xfec0 + c2) NEXT(2, 1) } else return 2; } else if (c == 0x8f) { unsigned char c2, c3; REQUIRE_INBUF(3) c2 = IN2; c3 = IN3; /* JIS X 0212 */ TRYMAP_DEC(jisx0212, **outbuf, c2 ^ 0x80, c3 ^ 0x80) { NEXT(3, 1) } else return 3; } else { unsigned char c2; REQUIRE_INBUF(2) c2 = IN2; /* JIS X 0208 */ #ifndef STRICT_BUILD if (c == 0xa1 && c2 == 0xc0) /* FULL-WIDTH REVERSE SOLIDUS */ **outbuf = 0xff3c; else #endif TRYMAP_DEC(jisx0208, **outbuf, c ^ 0x80, c2 ^ 0x80) ; else return 2; NEXT(2, 1) } } return 0; } /* * SHIFT_JIS codec */ ENCODER(shift_jis) { while (inleft > 0) { Py_UNICODE c = IN1; DBCHAR code; unsigned char c1, c2; #ifdef STRICT_BUILD JISX0201_R_ENCODE(c, code) #else if (c < 0x80) code = c; else if (c == 0x00a5) code = 0x5c; /* YEN SIGN */ else if (c == 0x203e) code = 0x7e; /* OVERLINE */ #endif else JISX0201_K_ENCODE(c, code) else UCS4INVALID(c) else code = NOCHAR; if (code < 0x80 || (code >= 0xa1 && code <= 0xdf)) { REQUIRE_OUTBUF(1) OUT1((unsigned char)code) NEXT(1, 1) continue; } REQUIRE_OUTBUF(2) if (code == NOCHAR) { TRYMAP_ENC(jisxcommon, code, c); #ifndef STRICT_BUILD else if (c == 0xff3c) code = 0x2140; /* FULL-WIDTH REVERSE SOLIDUS */ #endif else return 1; if (code & 0x8000) /* MSB set: JIS X 0212 */ return 1; } c1 = code >> 8; c2 = code & 0xff; c2 = (((c1 - 0x21) & 1) ? 0x5e : 0) + (c2 - 0x21); c1 = (c1 - 0x21) >> 1; OUT1(c1 < 0x1f ? c1 + 0x81 : c1 + 0xc1) OUT2(c2 < 0x3f ? c2 + 0x40 : c2 + 0x41) NEXT(1, 2) } return 0; } DECODER(shift_jis) { while (inleft > 0) { unsigned char c = IN1; REQUIRE_OUTBUF(1) #ifdef STRICT_BUILD JISX0201_R_DECODE(c, **outbuf) #else if (c < 0x80) **outbuf = c; #endif else JISX0201_K_DECODE(c, **outbuf) else if ((c >= 0x81 && c <= 0x9f) || (c >= 0xe0 && c <= 0xea)){ unsigned char c1, c2; REQUIRE_INBUF(2) c2 = IN2; if (c2 < 0x40 || (c2 > 0x7e && c2 < 0x80) || c2 > 0xfc) return 2; c1 = (c < 0xe0 ? c - 0x81 : c - 0xc1); c2 = (c2 < 0x80 ? c2 - 0x40 : c2 - 0x41); c1 = (2 * c1 + (c2 < 0x5e ? 0 : 1) + 0x21); c2 = (c2 < 0x5e ? c2 : c2 - 0x5e) + 0x21; #ifndef STRICT_BUILD if (c1 == 0x21 && c2 == 0x40) { /* FULL-WIDTH REVERSE SOLIDUS */ OUT1(0xff3c) NEXT(2, 1) continue; } #endif TRYMAP_DEC(jisx0208, **outbuf, c1, c2) { NEXT(2, 1) continue; } else return 2; } else return 2; NEXT(1, 1) /* JIS X 0201 */ } return 0; } /* * SHIFT_JIS-2004 codec */ ENCODER(shift_jis_2004) { while (inleft > 0) { ucs4_t c = IN1; DBCHAR code = NOCHAR; int c1, c2; size_t insize; JISX0201_ENCODE(c, code) else DECODE_SURROGATE(c) if (code < 0x80 || (code >= 0xa1 && code <= 0xdf)) { WRITE1((unsigned char)code) NEXT(1, 1) continue; } REQUIRE_OUTBUF(2) insize = GET_INSIZE(c); if (code == NOCHAR) { if (c <= 0xffff) { EMULATE_JISX0213_2000_ENCODE_BMP(code, c) else TRYMAP_ENC(jisx0213_bmp, code, c) { if (code == MULTIC) { if (inleft < 2) { if (flags & MBENC_FLUSH) { code = find_pairencmap ((ucs2_t)c, 0, jisx0213_pair_encmap, JISX0213_ENCPAIRS); if (code == DBCINV) return 1; } else return MBERR_TOOFEW; } else { code = find_pairencmap( (ucs2_t)c, IN2, jisx0213_pair_encmap, JISX0213_ENCPAIRS); if (code == DBCINV) { code = find_pairencmap( (ucs2_t)c, 0, jisx0213_pair_encmap, JISX0213_ENCPAIRS); if (code == DBCINV) return 1; } else insize = 2; } } } else TRYMAP_ENC(jisxcommon, code, c) { /* abandon JIS X 0212 codes */ if (code & 0x8000) return 1; } else return 1; } else if (c >> 16 == EMPBASE >> 16) { EMULATE_JISX0213_2000_ENCODE_EMP(code, c) else TRYMAP_ENC(jisx0213_emp, code, c&0xffff); else return insize; } else return insize; } c1 = code >> 8; c2 = (code & 0xff) - 0x21; if (c1 & 0x80) { /* Plane 2 */ if (c1 >= 0xee) c1 -= 0x87; else if (c1 >= 0xac || c1 == 0xa8) c1 -= 0x49; else c1 -= 0x43; } else /* Plane 1 */ c1 -= 0x21; if (c1 & 1) c2 += 0x5e; c1 >>= 1; OUT1(c1 + (c1 < 0x1f ? 0x81 : 0xc1)) OUT2(c2 + (c2 < 0x3f ? 0x40 : 0x41)) NEXT(insize, 2) } return 0; } DECODER(shift_jis_2004) { while (inleft > 0) { unsigned char c = IN1; REQUIRE_OUTBUF(1) JISX0201_DECODE(c, **outbuf) else if ((c >= 0x81 && c <= 0x9f) || (c >= 0xe0 && c <= 0xfc)){ unsigned char c1, c2 = IN2; ucs4_t code; REQUIRE_INBUF(2) if (c2 < 0x40 || (c2 > 0x7e && c2 < 0x80) || c2 > 0xfc) return 2; c1 = (c < 0xe0 ? c - 0x81 : c - 0xc1); c2 = (c2 < 0x80 ? c2 - 0x40 : c2 - 0x41); c1 = (2 * c1 + (c2 < 0x5e ? 0 : 1)); c2 = (c2 < 0x5e ? c2 : c2 - 0x5e) + 0x21; if (c1 < 0x5e) { /* Plane 1 */ c1 += 0x21; EMULATE_JISX0213_2000_DECODE_PLANE1(**outbuf, c1, c2) else TRYMAP_DEC(jisx0208, **outbuf, c1, c2) { NEXT_OUT(1) } else TRYMAP_DEC(jisx0213_1_bmp, **outbuf, c1, c2) { NEXT_OUT(1) } else TRYMAP_DEC(jisx0213_1_emp, code, c1, c2) { WRITEUCS4(EMPBASE | code) } else TRYMAP_DEC(jisx0213_pair, code, c1, c2) { WRITE2(code >> 16, code & 0xffff) NEXT_OUT(2) } else return 2; NEXT_IN(2) } else { /* Plane 2 */ if (c1 >= 0x67) c1 += 0x07; else if (c1 >= 0x63 || c1 == 0x5f) c1 -= 0x37; else c1 -= 0x3d; EMULATE_JISX0213_2000_DECODE_PLANE2(**outbuf, c1, c2) else TRYMAP_DEC(jisx0213_2_bmp, **outbuf, c1, c2) ; else TRYMAP_DEC(jisx0213_2_emp, code, c1, c2) { WRITEUCS4(EMPBASE | code) NEXT_IN(2) continue; } else return 2; NEXT(2, 1) } continue; } else return 2; NEXT(1, 1) /* JIS X 0201 */ } return 0; } BEGIN_MAPPINGS_LIST MAPPING_DECONLY(jisx0208) MAPPING_DECONLY(jisx0212) MAPPING_ENCONLY(jisxcommon) MAPPING_DECONLY(jisx0213_1_bmp) MAPPING_DECONLY(jisx0213_2_bmp) MAPPING_ENCONLY(jisx0213_bmp) MAPPING_DECONLY(jisx0213_1_emp) MAPPING_DECONLY(jisx0213_2_emp) MAPPING_ENCONLY(jisx0213_emp) MAPPING_ENCDEC(jisx0213_pair) MAPPING_ENCDEC(cp932ext) END_MAPPINGS_LIST BEGIN_CODECS_LIST CODEC_STATELESS(shift_jis) CODEC_STATELESS(cp932) CODEC_STATELESS(euc_jp) CODEC_STATELESS(shift_jis_2004) CODEC_STATELESS(euc_jis_2004) { "euc_jisx0213", (void *)2000, NULL, _STATELESS_METHODS(euc_jis_2004) }, { "shift_jisx0213", (void *)2000, NULL, _STATELESS_METHODS(shift_jis_2004) }, END_CODECS_LIST I_AM_A_MODULE_FOR(jp) --- NEW FILE: _codecs_kr.c --- /* * _codecs_kr.c: Codecs collection for Korean encodings * * Written by Hye-Shik Chang * $CJKCodecs: _codecs_kr.c,v 1.8 2004/07/07 14:59:26 perky Exp $ */ #include "cjkcodecs.h" #include "mappings_kr.h" /* * EUC-KR codec */ ENCODER(euc_kr) { while (inleft > 0) { Py_UNICODE c = IN1; DBCHAR code; if (c < 0x80) { WRITE1((unsigned char)c) NEXT(1, 1) continue; } UCS4INVALID(c) REQUIRE_OUTBUF(2) TRYMAP_ENC(cp949, code, c); else return 1; if (code & 0x8000) /* MSB set: CP949 */ return 1; OUT1((code >> 8) | 0x80) OUT2((code & 0xFF) | 0x80) NEXT(1, 2) } return 0; } DECODER(euc_kr) { while (inleft > 0) { unsigned char c = IN1; REQUIRE_OUTBUF(1) if (c < 0x80) { OUT1(c) NEXT(1, 1) continue; } REQUIRE_INBUF(2) TRYMAP_DEC(ksx1001, **outbuf, c ^ 0x80, IN2 ^ 0x80) { NEXT(2, 1) } else return 2; } return 0; } /* * CP949 codec */ ENCODER(cp949) { while (inleft > 0) { Py_UNICODE c = IN1; DBCHAR code; if (c < 0x80) { WRITE1((unsigned char)c) NEXT(1, 1) continue; } UCS4INVALID(c) REQUIRE_OUTBUF(2) TRYMAP_ENC(cp949, code, c); else return 1; OUT1((code >> 8) | 0x80) if (code & 0x8000) OUT2(code & 0xFF) /* MSB set: CP949 */ else OUT2((code & 0xFF) | 0x80) /* MSB unset: ks x 1001 */ NEXT(1, 2) } return 0; } DECODER(cp949) { while (inleft > 0) { unsigned char c = IN1; REQUIRE_OUTBUF(1) if (c < 0x80) { OUT1(c) NEXT(1, 1) continue; } REQUIRE_INBUF(2) TRYMAP_DEC(ksx1001, **outbuf, c ^ 0x80, IN2 ^ 0x80); else TRYMAP_DEC(cp949ext, **outbuf, c, IN2); else return 2; NEXT(2, 1) } return 0; } /* * JOHAB codec */ static const unsigned char u2johabidx_choseong[32] = { 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, }; static const unsigned char u2johabidx_jungseong[32] = { 0x03, 0x04, 0x05, 0x06, 0x07, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x1a, 0x1b, 0x1c, 0x1d, }; static const unsigned char u2johabidx_jongseong[32] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, }; static const DBCHAR u2johabjamo[] = { 0x8841, 0x8c41, 0x8444, 0x9041, 0x8446, 0x8447, 0x9441, 0x9841, 0x9c41, 0x844a, 0x844b, 0x844c, 0x844d, 0x844e, 0x844f, 0x8450, 0xa041, 0xa441, 0xa841, 0x8454, 0xac41, 0xb041, 0xb441, 0xb841, 0xbc41, 0xc041, 0xc441, 0xc841, 0xcc41, 0xd041, 0x8461, 0x8481, 0x84a1, 0x84c1, 0x84e1, 0x8541, 0x8561, 0x8581, 0x85a1, 0x85c1, 0x85e1, 0x8641, 0x8661, 0x8681, 0x86a1, 0x86c1, 0x86e1, 0x8741, 0x8761, 0x8781, 0x87a1, }; ENCODER(johab) { while (inleft > 0) { Py_UNICODE c = IN1; DBCHAR code; if (c < 0x80) { WRITE1((unsigned char)c) NEXT(1, 1) continue; } UCS4INVALID(c) REQUIRE_OUTBUF(2) if (c >= 0xac00 && c <= 0xd7a3) { c -= 0xac00; code = 0x8000 | (u2johabidx_choseong[c / 588] << 10) | (u2johabidx_jungseong[(c / 28) % 21] << 5) | u2johabidx_jongseong[c % 28]; } else if (c >= 0x3131 && c <= 0x3163) code = u2johabjamo[c - 0x3131]; else TRYMAP_ENC(cp949, code, c) { unsigned char c1, c2, t2; unsigned short t1; assert((code & 0x8000) == 0); c1 = code >> 8; c2 = code & 0xff; if (((c1 >= 0x21 && c1 <= 0x2c) || (c1 >= 0x4a && c1 <= 0x7d)) && (c2 >= 0x21 && c2 <= 0x7e)) { t1 = (c1 < 0x4a ? (c1 - 0x21 + 0x1b2) : (c1 - 0x21 + 0x197)); t2 = ((t1 & 1) ? 0x5e : 0) + (c2 - 0x21); OUT1(t1 >> 1) OUT2(t2 < 0x4e ? t2 + 0x31 : t2 + 0x43) NEXT(1, 2) continue; } else return 1; } else return 1; OUT1(code >> 8) OUT2(code & 0xff) NEXT(1, 2) } return 0; } #define FILL 0xfd #define NONE 0xff static const unsigned char johabidx_choseong[32] = { NONE, FILL, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, }; static const unsigned char johabidx_jungseong[32] = { NONE, NONE, FILL, 0x00, 0x01, 0x02, 0x03, 0x04, NONE, NONE, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, NONE, NONE, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, NONE, NONE, 0x11, 0x12, 0x13, 0x14, NONE, NONE, }; static const unsigned char johabidx_jongseong[32] = { NONE, FILL, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, NONE, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, NONE, NONE, }; static const unsigned char johabjamo_choseong[32] = { NONE, FILL, 0x31, 0x32, 0x34, 0x37, 0x38, 0x39, 0x41, 0x42, 0x43, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, }; static const unsigned char johabjamo_jungseong[32] = { NONE, NONE, FILL, 0x4f, 0x50, 0x51, 0x52, 0x53, NONE, NONE, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, NONE, NONE, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, NONE, NONE, 0x60, 0x61, 0x62, 0x63, NONE, NONE, }; static const unsigned char johabjamo_jongseong[32] = { NONE, FILL, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40, 0x41, NONE, 0x42, 0x44, 0x45, 0x46, 0x47, 0x48, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, NONE, NONE, }; DECODER(johab) { while (inleft > 0) { unsigned char c = IN1, c2; REQUIRE_OUTBUF(1) if (c < 0x80) { OUT1(c) NEXT(1, 1) continue; } REQUIRE_INBUF(2) c2 = IN2; if (c < 0xd8) { /* johab hangul */ unsigned char c_cho, c_jung, c_jong; unsigned char i_cho, i_jung, i_jong; c_cho = (c >> 2) & 0x1f; c_jung = ((c << 3) | c2 >> 5) & 0x1f; c_jong = c2 & 0x1f; i_cho = johabidx_choseong[c_cho]; i_jung = johabidx_jungseong[c_jung]; i_jong = johabidx_jongseong[c_jong]; if (i_cho == NONE || i_jung == NONE || i_jong == NONE) return 2; /* we don't use U+1100 hangul jamo yet. */ if (i_cho == FILL) { if (i_jung == FILL) { if (i_jong == FILL) OUT1(0x3000) else OUT1(0x3100 | johabjamo_jongseong[c_jong]) } else { if (i_jong == FILL) OUT1(0x3100 | johabjamo_jungseong[c_jung]) else return 2; } } else { if (i_jung == FILL) { if (i_jong == FILL) OUT1(0x3100 | johabjamo_choseong[c_cho]) else return 2; } else OUT1(0xac00 + i_cho * 588 + i_jung * 28 + (i_jong == FILL ? 0 : i_jong)) } NEXT(2, 1) } else { /* KS X 1001 except hangul jamos and syllables */ if (c == 0xdf || c > 0xf9 || c2 < 0x31 || (c2 >= 0x80 && c2 < 0x91) || (c2 & 0x7f) == 0x7f || (c == 0xda && (c2 >= 0xa1 && c2 <= 0xd3))) return 2; else { unsigned char t1, t2; t1 = (c < 0xe0 ? 2 * (c - 0xd9) : 2 * c - 0x197); t2 = (c2 < 0x91 ? c2 - 0x31 : c2 - 0x43); t1 = t1 + (t2 < 0x5e ? 0 : 1) + 0x21; t2 = (t2 < 0x5e ? t2 : t2 - 0x5e) + 0x21; TRYMAP_DEC(ksx1001, **outbuf, t1, t2); else return 2; NEXT(2, 1) } } } return 0; } #undef NONE #undef FILL BEGIN_MAPPINGS_LIST MAPPING_DECONLY(ksx1001) MAPPING_ENCONLY(cp949) MAPPING_DECONLY(cp949ext) END_MAPPINGS_LIST BEGIN_CODECS_LIST CODEC_STATELESS(euc_kr) CODEC_STATELESS(cp949) CODEC_STATELESS(johab) END_CODECS_LIST I_AM_A_MODULE_FOR(kr) --- NEW FILE: _codecs_tw.c --- /* * _codecs_tw.c: Codecs collection for Taiwan's encodings * * Written by Hye-Shik Chang * $CJKCodecs: _codecs_tw.c,v 1.10 2004/07/07 14:59:26 perky Exp $ */ #include "cjkcodecs.h" #include "mappings_tw.h" /* * BIG5 codec */ ENCODER(big5) { while (inleft > 0) { Py_UNICODE c = **inbuf; DBCHAR code; if (c < 0x80) { REQUIRE_OUTBUF(1) **outbuf = (unsigned char)c; NEXT(1, 1) continue; } UCS4INVALID(c) REQUIRE_OUTBUF(2) TRYMAP_ENC(big5, code, c); else return 1; OUT1(code >> 8) OUT2(code & 0xFF) NEXT(1, 2) } return 0; } DECODER(big5) { while (inleft > 0) { unsigned char c = IN1; REQUIRE_OUTBUF(1) if (c < 0x80) { OUT1(c) NEXT(1, 1) continue; } REQUIRE_INBUF(2) TRYMAP_DEC(big5, **outbuf, c, IN2) { NEXT(2, 1) } else return 2; } return 0; } /* * CP950 codec */ ENCODER(cp950) { while (inleft > 0) { Py_UNICODE c = IN1; DBCHAR code; if (c < 0x80) { WRITE1((unsigned char)c) NEXT(1, 1) continue; } UCS4INVALID(c) REQUIRE_OUTBUF(2) TRYMAP_ENC(cp950ext, code, c); else TRYMAP_ENC(big5, code, c); else return 1; OUT1(code >> 8) OUT2(code & 0xFF) NEXT(1, 2) } return 0; } DECODER(cp950) { while (inleft > 0) { unsigned char c = IN1; REQUIRE_OUTBUF(1) if (c < 0x80) { OUT1(c) NEXT(1, 1) continue; } REQUIRE_INBUF(2) TRYMAP_DEC(cp950ext, **outbuf, c, IN2); else TRYMAP_DEC(big5, **outbuf, c, IN2); else return 2; NEXT(2, 1) } return 0; } BEGIN_MAPPINGS_LIST MAPPING_ENCDEC(big5) MAPPING_ENCDEC(cp950ext) END_MAPPINGS_LIST BEGIN_CODECS_LIST CODEC_STATELESS(big5) CODEC_STATELESS(cp950) END_CODECS_LIST I_AM_A_MODULE_FOR(tw) --- NEW FILE: _codecs_unicode.c --- /* * _codecs_unicode.c: Codecs collection for Unicode encodings * * Written by Hye-Shik Chang * $CJKCodecs: _codecs_unicode.c,v 1.5 2004/06/27 21:41:15 perky Exp $ */ #include "cjkcodecs.h" /* * UTF-7 codec */ #define SET_DIRECT 1 #define SET_OPTIONAL 2 #define SET_WHITESPACE 3 #define _D SET_DIRECT #define _O SET_OPTIONAL #define _W SET_WHITESPACE static const char utf7_sets[128] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, _W, _W, 0, 0, _W, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, _W, _O, _O, _O, _O, _O, _O, _D, _D, _D, _O, 0, _D, _D, _D, 0, _D, _D, _D, _D, _D, _D, _D, _D, _D, _D, _D, _O, _O, _O, _O, _D, _O, _D, _D, _D, _D, _D, _D, _D, _D, _D, _D, _D, _D, _D, _D, _D, _D, _D, _D, _D, _D, _D, _D, _D, _D, _D, _D, _O, 0, _O, _O, _O, _O, _D, _D, _D, _D, _D, _D, _D, _D, _D, _D, _D, _D, _D, _D, _D, _D, _D, _D, _D, _D, _D, _D, _D, _D, _D, _D, _O, _O, _O, 0, 0, }; #undef _W #undef _O #undef _D #define B64(n) ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" \ "0123456789+/"[(n) & 0x3f]) #define B64CHAR(c) (((c) >= 'A' && (c) <= 'Z') || \ ((c) >= 'a' && (c) <= 'z') || \ ((c) >= '0' && (c) <= '9') || \ (c) == '+' || (c) == '/') #define UB64(c) ((c) == '+' ? 62 : (c) == '/' ? 63 : (c) >= 'a' ? \ (c) - 71 : (c) >= 'A' ? (c) - 65 : (c) + 4) #define UTF7_DENCODABLE_COMPATIBLE(c) (utf7_sets[c] != 0) #define UTF7_DENCODABLE_STRICT(c) (utf7_sets[c] == SET_DIRECT || \ utf7_sets[c] == SET_WHITESPACE) #define ESTATE_INITIALIZE(state) \ ESTATE_SETSTAGE(state, 0) \ ESTATE_CLEARSHIFTED(state) #define ESTATE_SETPENDING(state, v) (state)->c[0] = (v); #define ESTATE_GETPENDING(state) (state)->c[0] #define ESTATE_SETSHIFTED(state) (state)->c[2] = 1; #define ESTATE_ISSHIFTED(state) ((state)->c[2]) #define ESTATE_CLEARSHIFTED(state) (state)->c[2] = 0; #define ESTATE_SETSTAGE(state, v) (state)->c[3] = (v); #define ESTATE_GETSTAGE(state) ((state)->c[3]) ENCODER_INIT(utf_7) { ESTATE_INITIALIZE(state) return 0; } ENCODER_RESET(utf_7) { if (ESTATE_ISSHIFTED(state)) { if (ESTATE_GETSTAGE(state) != 0) { unsigned char oc; oc = B64(ESTATE_GETPENDING(state)); WRITE2(oc, '-') NEXT_OUT(2) } else { WRITE1('-') NEXT_OUT(1) } ESTATE_CLEARSHIFTED(state) } return 0; } ENCODER(utf_7) { while (inleft > 0) { Py_UNICODE c1 = IN1, c2 = 0; size_t insize = 1; #if Py_UNICODE_SIZE == 2 if (c1 >> 10 == 0xd800 >> 10) { /* high surrogate */ REQUIRE_INBUF(2) if (IN2 >> 10 != 0xdc00 >> 10) /* low surrogate */ return 2; /* invalid surrogate pair */ c2 = IN2; insize = 2; } #else if (c1 > 0x10ffff) /* UTF-16 unencodable */ return 1; else if (c1 > 0xffff) { c2 = 0xdc00 | ((c1 - 0x10000) & 0x3ff); c1 = 0xd800 | ((c1 - 0x10000) >> 10); } #endif for (;;) { unsigned char oc1, oc2, oc3; if (ESTATE_ISSHIFTED(state)) { if (c1 < 128 && UTF7_DENCODABLE_STRICT(c1)) { if (ESTATE_GETSTAGE(state) != 0) { oc1 = B64(ESTATE_GETPENDING( state)); WRITE3(oc1, '-', (unsigned char)c1) NEXT_OUT(3) } else { WRITE2('-', (unsigned char)c1) NEXT_OUT(2) } ESTATE_CLEARSHIFTED(state) } else { switch (ESTATE_GETSTAGE(state)) { case 0: oc1 = c1 >> 10; oc2 = (c1 >> 4) & 0x3f; WRITE2(B64(oc1), B64(oc2)) ESTATE_SETPENDING(state, (c1 & 0x0f) << 2) ESTATE_SETSTAGE(state, 2) NEXT_OUT(2) break; case 1: oc1 = ESTATE_GETPENDING(state) | (c1 >> 12); oc2 = (c1 >> 6) & 0x3f; oc3 = c1 & 0x3f; WRITE3(B64(oc1), B64(oc2), B64(oc3)) ESTATE_SETSTAGE(state, 0) NEXT_OUT(3) break; case 2: oc1 = ESTATE_GETPENDING(state) | (c1 >> 14); oc2 = (c1 >> 8) & 0x3f; oc3 = (c1 >> 2) & 0x3f; WRITE3(B64(oc1), B64(oc2), B64(oc3)) ESTATE_SETPENDING(state, (c1 & 0x03) << 4) ESTATE_SETSTAGE(state, 1) NEXT_OUT(3) break; default: return MBERR_INTERNAL; } } } else { if (c1 < 128 && UTF7_DENCODABLE_STRICT(c1)) { WRITE1((unsigned char)c1) NEXT_OUT(1) } else if (c1 == '+') { WRITE2('+', '-') NEXT_OUT(2) } else { oc1 = c1 >> 10; oc2 = (c1 >> 4) & 0x3f; WRITE3('+', B64(oc1), B64(oc2)) ESTATE_SETPENDING(state, (c1 & 0x0f) << 2) ESTATE_SETSTAGE(state, 2) ESTATE_SETSHIFTED(state) NEXT_OUT(3) } } if (c2 != 0) { c1 = c2; c2 = 0; } else break; } NEXT_IN(insize) } return 0; } #define DSTATE_INITIALIZE(state) \ DSTATE_SETBSTAGE(state, 0) \ DSTATE_CLEARSHIFTED(state) \ DSTATE_SETULENGTH(state, 0) \ DSTATE_SETUPENDING1(state, 0) \ DSTATE_SETUPENDING2(state, 0) /* XXX: Type-mixed usage of a state union may be not so portable. * If you see any problem with this on your platfom. Please let * me know. */ #define DSTATE_SETSHIFTED(state) (state)->c[0] = 1; #define DSTATE_ISSHIFTED(state) ((state)->c[0]) #define DSTATE_CLEARSHIFTED(state) (state)->c[0] = 0; #define DSTATE_SETBSTAGE(state, v) (state)->c[1] = (v); #define DSTATE_GETBSTAGE(state) ((state)->c[1]) #define DSTATE_SETBPENDING(state, v) (state)->c[2] = (v); #define DSTATE_GETBPENDING(state) ((state)->c[2]) #define DSTATE_SETULENGTH(state, v) (state)->c[3] = (v); #define DSTATE_GETULENGTH(state) ((state)->c[3]) #define DSTATE_SETUPENDING1(state, v) (state)->u2[2] = (v); #define DSTATE_GETUPENDING1(state) (state)->u2[2] #define DSTATE_SETUPENDING2(state, v) (state)->u2[3] = (v); #define DSTATE_GETUPENDING2(state) (state)->u2[3] #define DSTATE_UAPPEND(state, v) \ (state)->u2[(state)->c[3] > 1 ? 3 : 2] |= \ ((state)->c[3] & 1) ? (v) : ((ucs2_t)(v)) << 8; \ (state)->c[3]++; DECODER_INIT(utf_7) { DSTATE_INITIALIZE(state) return 0; } static int utf_7_flush(MultibyteCodec_State *state, Py_UNICODE **outbuf, size_t *outleft) { switch (DSTATE_GETULENGTH(state)) { case 2: { ucs2_t uc; uc = DSTATE_GETUPENDING1(state); #if Py_UNICODE_SIZE == 4 if (uc >> 10 == 0xd800 >> 10) return MBERR_TOOFEW; #endif OUT1(uc) (*outbuf)++; (*outleft)--; DSTATE_SETULENGTH(state, 0) DSTATE_SETUPENDING1(state, 0) break; } #if Py_UNICODE_SIZE == 4 case 4: if (DSTATE_GETUPENDING2(state) >> 10 != 0xdc00 >> 10) return 1; OUT1(0x10000 + (((ucs4_t)DSTATE_GETUPENDING1(state) - 0xd800) << 10) + (DSTATE_GETUPENDING2(state) - 0xdc00)) (*outbuf)++; (*outleft)--; DSTATE_SETULENGTH(state, 0) DSTATE_SETUPENDING1(state, 0) DSTATE_SETUPENDING2(state, 0) break; #endif case 0: /* FALLTHROUGH */ case 1: /* FALLTHROUGH */ case 3: return MBERR_TOOFEW; default: return MBERR_INTERNAL; } return 0; } DECODER_RESET(utf_7) { DSTATE_INITIALIZE(state) return 0; } DECODER(utf_7) { while (inleft > 0) { unsigned char c = IN1; int r; if (!DSTATE_ISSHIFTED(state)) { if (c == '+') { REQUIRE_INBUF(2) if (inleft >= 2 && IN2 == '-') { WRITE1('+') NEXT(2, 1) } else { DSTATE_SETSHIFTED(state) NEXT_IN(1) } } else if (c < 128 && UTF7_DENCODABLE_COMPATIBLE(c)) { WRITE1(c) NEXT(1, 1) } else return 1; } else if (B64CHAR(c)) { unsigned char tb; REQUIRE_OUTBUF(1) c = UB64(c); assert(DSTATE_GETULENGTH(state) < 4); switch (DSTATE_GETBSTAGE(state)) { case 0: DSTATE_SETBPENDING(state, c << 2) DSTATE_SETBSTAGE(state, 1) break; case 1: tb = DSTATE_GETBPENDING(state) | (c >> 4); DSTATE_SETBPENDING(state, c << 4) DSTATE_SETBSTAGE(state, 2) DSTATE_UAPPEND(state, tb) break; case 2: tb = DSTATE_GETBPENDING(state) | (c >> 2); DSTATE_SETBPENDING(state, c << 6) DSTATE_SETBSTAGE(state, 3) DSTATE_UAPPEND(state, tb) break; case 3: tb = DSTATE_GETBPENDING(state) | c; DSTATE_SETBSTAGE(state, 0) DSTATE_UAPPEND(state, tb) break; } r = utf_7_flush(state, outbuf, &outleft); if (r != 0 && r != MBERR_TOOFEW) return r; NEXT_IN(1) } else if (c == '-' || UTF7_DENCODABLE_COMPATIBLE(c)) { if (DSTATE_GETBSTAGE(state) != 0) { DSTATE_UAPPEND(state, DSTATE_GETBSTAGE(state)) DSTATE_SETBSTAGE(state, 0) } r = utf_7_flush(state, outbuf, &outleft); if (r != 0 && r != MBERR_TOOFEW) return r; DSTATE_CLEARSHIFTED(state) if (c != '-') { WRITE1(c) NEXT_OUT(1) } NEXT_IN(1) } else return 1; } return 0; } /* * UTF-8 codec */ ENCODER(utf_8) { while (inleft > 0) { ucs4_t c = **inbuf; size_t outsize, insize = 1; if (c < 0x80) outsize = 1; else if (c < 0x800) outsize = 2; else { #if Py_UNICODE_SIZE == 2 if (c >> 10 == 0xd800 >> 10) { /* high surrogate */ if (inleft < 2) { if (!(flags & MBENC_FLUSH)) return MBERR_TOOFEW; } else if ((*inbuf)[1] >> 10 == 0xdc00 >> 10) { /* low surrogate */ c = 0x10000 + ((c - 0xd800) << 10) + ((ucs4_t)((*inbuf)[1]) - 0xdc00); insize = 2; } } #endif if (c < 0x10000) outsize = 3; else if (c < 0x200000) outsize = 4; else if (c < 0x4000000) outsize = 5; else outsize = 6; } REQUIRE_OUTBUF(outsize) switch (outsize) { case 6: (*outbuf)[5] = 0x80 | (c & 0x3f); c = c >> 6; c |= 0x4000000; /* FALLTHROUGH */ case 5: (*outbuf)[4] = 0x80 | (c & 0x3f); c = c >> 6; c |= 0x200000; /* FALLTHROUGH */ case 4: (*outbuf)[3] = 0x80 | (c & 0x3f); c = c >> 6; c |= 0x10000; /* FALLTHROUGH */ case 3: (*outbuf)[2] = 0x80 | (c & 0x3f); c = c >> 6; c |= 0x800; /* FALLTHROUGH */ case 2: (*outbuf)[1] = 0x80 | (c & 0x3f); c = c >> 6; c |= 0xc0; /* FALLTHROUGH */ case 1: (*outbuf)[0] = c; } NEXT(insize, outsize) } return 0; } DECODER(utf_8) { while (inleft > 0) { unsigned char c = **inbuf; REQUIRE_OUTBUF(1) if (c < 0x80) { (*outbuf)[0] = (unsigned char)c; NEXT(1, 1) } else if (c < 0xc2) { return 1; } else if (c < 0xe0) { unsigned char c2; REQUIRE_INBUF(2) c2 = (*inbuf)[1]; if (!((c2 ^ 0x80) < 0x40)) return 2; **outbuf = ((Py_UNICODE)(c & 0x1f) << 6) | (Py_UNICODE)(c2 ^ 0x80); NEXT(2, 1) } else if (c < 0xf0) { unsigned char c2, c3; REQUIRE_INBUF(3) c2 = (*inbuf)[1]; c3 = (*inbuf)[2]; if (!((c2 ^ 0x80) < 0x40 && (c3 ^ 0x80) < 0x40 && (c >= 0xe1 || c2 >= 0xa0))) return 3; **outbuf = ((Py_UNICODE)(c & 0x0f) << 12) | ((Py_UNICODE)(c2 ^ 0x80) << 6) | (Py_UNICODE)(c3 ^ 0x80); NEXT(3, 1) } else if (c < 0xf8) { unsigned char c2, c3, c4; ucs4_t code; REQUIRE_INBUF(4) c2 = (*inbuf)[1]; c3 = (*inbuf)[2]; c4 = (*inbuf)[3]; if (!((c2 ^ 0x80) < 0x40 && (c3 ^ 0x80) < 0x40 && (c4 ^ 0x80) < 0x40 && (c >= 0xf1 || c2 >= 0x90))) return 4; code = ((ucs4_t)(c & 0x07) << 18) | ((ucs4_t)(c2 ^ 0x80) << 12) | ((ucs4_t)(c3 ^ 0x80) << 6) | (ucs4_t)(c4 ^ 0x80); WRITEUCS4(code) NEXT_IN(4) } else if (c < 0xfc) { unsigned char c2, c3, c4, c5; ucs4_t code; REQUIRE_INBUF(5) c2 = (*inbuf)[1]; c3 = (*inbuf)[2]; c4 = (*inbuf)[3]; c5 = (*inbuf)[4]; if (!((c2 ^ 0x80) < 0x40 && (c3 ^ 0x80) < 0x40 && (c4 ^ 0x80) < 0x40 && (c5 ^ 0x80) < 0x40 && (c >= 0xf9 || c2 >= 0x88))) return 5; code = ((ucs4_t)(c & 0x03) << 24) | ((ucs4_t)(c2 ^ 0x80) << 18) | ((ucs4_t)(c3 ^ 0x80) << 12) | ((ucs4_t)(c4 ^ 0x80) << 6) | (ucs4_t)(c5 ^ 0x80); WRITEUCS4(code) NEXT_IN(5) } else if (c < 0xff) { unsigned char c2, c3, c4, c5, c6; ucs4_t code; REQUIRE_INBUF(6) c2 = (*inbuf)[1]; c3 = (*inbuf)[2]; c4 = (*inbuf)[3]; c5 = (*inbuf)[4]; c6 = (*inbuf)[5]; if (!((c2 ^ 0x80) < 0x40 && (c3 ^ 0x80) < 0x40 && (c4 ^ 0x80) < 0x40 && (c5 ^ 0x80) < 0x40 && (c6 ^ 0x80) < 0x40 && (c >= 0xfd || c2 >= 0x84))) return 6; code = ((ucs4_t)(c & 0x01) << 30) | ((ucs4_t)(c2 ^ 0x80) << 24) | ((ucs4_t)(c3 ^ 0x80) << 18) | ((ucs4_t)(c4 ^ 0x80) << 12) | ((ucs4_t)(c5 ^ 0x80) << 6) | (ucs4_t)(c6 ^ 0x80); WRITEUCS4(code) NEXT_IN(6) } else return 1; } return 0; } BEGIN_MAPPINGS_LIST END_MAPPINGS_LIST BEGIN_CODECS_LIST CODEC_STATEFUL(utf_7) CODEC_STATELESS(utf_8) END_CODECS_LIST I_AM_A_MODULE_FOR(unicode) --- NEW FILE: cjkcodecs.h --- /* * cjkcodecs.h: common header for cjkcodecs * * Written by Hye-Shik Chang * $CJKCodecs: cjkcodecs.h,v 1.5 2004/07/06 17:05:24 perky Exp $ */ #ifndef _CJKCODECS_H_ #define _CJKCODECS_H_ #include "Python.h" #include "multibytecodec.h" #define UNIINV Py_UNICODE_REPLACEMENT_CHARACTER #define NOCHAR 0xFFFF #define MULTIC 0xFFFE #define DBCINV 0xFFFD /* shorter macros to save source size of mapping tables */ #define U UNIINV #define N NOCHAR #define M MULTIC #define D DBCINV struct dbcs_index { const ucs2_t *map; unsigned char bottom, top; }; typedef struct dbcs_index decode_map; struct widedbcs_index { const ucs4_t *map; unsigned char bottom, top; }; typedef struct widedbcs_index widedecode_map; struct unim_index { const DBCHAR *map; unsigned char bottom, top; }; typedef struct unim_index encode_map; struct unim_index_bytebased { const unsigned char *map; unsigned char bottom, top; }; struct dbcs_map { const char *charset; const struct unim_index *encmap; const struct dbcs_index *decmap; }; struct pair_encodemap { ucs4_t uniseq; DBCHAR code; }; static const MultibyteCodec codec_list[]; static const struct dbcs_map mapping_list[]; #define CODEC_INIT(encoding) \ static int encoding##_codec_init(const void *config) #define ENCODER_INIT(encoding) \ static int encoding##_encode_init( \ MultibyteCodec_State *state, const void *config) #define ENCODER(encoding) \ static int encoding##_encode( \ MultibyteCodec_State *state, const void *config, \ const Py_UNICODE **inbuf, size_t inleft, \ unsigned char **outbuf, size_t outleft, int flags) #define ENCODER_RESET(encoding) \ static int encoding##_encode_reset( \ MultibyteCodec_State *state, const void *config, \ unsigned char **outbuf, size_t outleft) #define DECODER_INIT(encoding) \ static int encoding##_decode_init( \ MultibyteCodec_State *state, const void *config) #define DECODER(encoding) \ static int encoding##_decode( \ MultibyteCodec_State *state, const void *config, \ const unsigned char **inbuf, size_t inleft, \ Py_UNICODE **outbuf, size_t outleft) #define DECODER_RESET(encoding) \ static int encoding##_decode_reset( \ MultibyteCodec_State *state, const void *config) #if Py_UNICODE_SIZE == 4 #define UCS4INVALID(code) \ if ((code) > 0xFFFF) \ return 1; #else #define UCS4INVALID(code) \ if (0) ; #endif #define NEXT_IN(i) \ (*inbuf) += (i); \ (inleft) -= (i); #define NEXT_OUT(o) \ (*outbuf) += (o); \ (outleft) -= (o); #define NEXT(i, o) \ NEXT_IN(i) NEXT_OUT(o) #define REQUIRE_INBUF(n) \ if (inleft < (n)) \ return MBERR_TOOFEW; #define REQUIRE_OUTBUF(n) \ if (outleft < (n)) \ return MBERR_TOOSMALL; #define IN1 ((*inbuf)[0]) #define IN2 ((*inbuf)[1]) #define IN3 ((*inbuf)[2]) #define IN4 ((*inbuf)[3]) #define OUT1(c) ((*outbuf)[0]) = (c); #define OUT2(c) ((*outbuf)[1]) = (c); #define OUT3(c) ((*outbuf)[2]) = (c); #define OUT4(c) ((*outbuf)[3]) = (c); #define WRITE1(c1) \ REQUIRE_OUTBUF(1) \ (*outbuf)[0] = (c1); #define WRITE2(c1, c2) \ REQUIRE_OUTBUF(2) \ (*outbuf)[0] = (c1); \ (*outbuf)[1] = (c2); #define WRITE3(c1, c2, c3) \ REQUIRE_OUTBUF(3) \ (*outbuf)[0] = (c1); \ (*outbuf)[1] = (c2); \ (*outbuf)[2] = (c3); #define WRITE4(c1, c2, c3, c4) \ REQUIRE_OUTBUF(4) \ (*outbuf)[0] = (c1); \ (*outbuf)[1] = (c2); \ (*outbuf)[2] = (c3); \ (*outbuf)[3] = (c4); #if Py_UNICODE_SIZE == 2 # define WRITEUCS4(c) \ REQUIRE_OUTBUF(2) \ (*outbuf)[0] = 0xd800 + (((c) - 0x10000) >> 10); \ (*outbuf)[1] = 0xdc00 + (((c) - 0x10000) & 0x3ff); \ NEXT_OUT(2) #else # define WRITEUCS4(c) \ REQUIRE_OUTBUF(1) \ **outbuf = (Py_UNICODE)(c); \ NEXT_OUT(1) #endif #define _TRYMAP_ENC(m, assi, val) \ if ((m)->map != NULL && (val) >= (m)->bottom && \ (val)<= (m)->top && ((assi) = (m)->map[(val) - \ (m)->bottom]) != NOCHAR) #define TRYMAP_ENC(charset, assi, uni) \ _TRYMAP_ENC(&charset##_encmap[(uni) >> 8], assi, (uni) & 0xff) #define _TRYMAP_DEC(m, assi, val) \ if ((m)->map != NULL && (val) >= (m)->bottom && \ (val)<= (m)->top && ((assi) = (m)->map[(val) - \ (m)->bottom]) != UNIINV) #define TRYMAP_DEC(charset, assi, c1, c2) \ _TRYMAP_DEC(&charset##_decmap[c1], assi, c2) #define _TRYMAP_ENC_MPLANE(m, assplane, asshi, asslo, val) \ if ((m)->map != NULL && (val) >= (m)->bottom && \ (val)<= (m)->top && \ ((assplane) = (m)->map[((val) - (m)->bottom)*3]) != 0 && \ (((asshi) = (m)->map[((val) - (m)->bottom)*3 + 1]), 1) && \ (((asslo) = (m)->map[((val) - (m)->bottom)*3 + 2]), 1)) #define TRYMAP_ENC_MPLANE(charset, assplane, asshi, asslo, uni) \ _TRYMAP_ENC_MPLANE(&charset##_encmap[(uni) >> 8], \ assplane, asshi, asslo, (uni) & 0xff) #define TRYMAP_DEC_MPLANE(charset, assi, plane, c1, c2) \ _TRYMAP_DEC(&charset##_decmap[plane][c1], assi, c2) #if Py_UNICODE_SIZE == 2 #define DECODE_SURROGATE(c) \ if (c >> 10 == 0xd800 >> 10) { /* high surrogate */ \ REQUIRE_INBUF(2) \ if (IN2 >> 10 == 0xdc00 >> 10) { /* low surrogate */ \ c = 0x10000 + ((ucs4_t)(c - 0xd800) << 10) + \ ((ucs4_t)(IN2) - 0xdc00); \ } \ } #define GET_INSIZE(c) ((c) > 0xffff ? 2 : 1) #else #define DECODE_SURROGATE(c) {;} #define GET_INSIZE(c) 1 #endif #define BEGIN_MAPPINGS_LIST static const struct dbcs_map mapping_list[] = { #define MAPPING_ENCONLY(enc) {#enc, (void*)enc##_encmap, NULL}, #define MAPPING_DECONLY(enc) {#enc, NULL, (void*)enc##_decmap}, #define MAPPING_ENCDEC(enc) {#enc, (void*)enc##_encmap, (void*)enc##_decmap}, #define END_MAPPINGS_LIST {"", NULL, NULL} }; #define BEGIN_CODECS_LIST static const MultibyteCodec codec_list[] = { #define _STATEFUL_METHODS(enc) \ enc##_encode, \ enc##_encode_init, \ enc##_encode_reset, \ enc##_decode, \ enc##_decode_init, \ enc##_decode_reset, #define _STATELESS_METHODS(enc) \ enc##_encode, NULL, NULL, \ enc##_decode, NULL, NULL, #define CODEC_STATEFUL(enc) { \ #enc, NULL, NULL, \ _STATEFUL_METHODS(enc) \ }, #define CODEC_STATELESS(enc) { \ #enc, NULL, NULL, \ _STATELESS_METHODS(enc) \ }, #define CODEC_STATELESS_WINIT(enc) { \ #enc, NULL, \ enc##_codec_init, \ _STATELESS_METHODS(enc) \ }, #define END_CODECS_LIST {"", NULL,} }; static PyObject * getmultibytecodec(void) { static PyObject *cofunc = NULL; if (cofunc == NULL) { PyObject *mod = PyImport_ImportModule("_multibytecodec"); if (mod == NULL) return NULL; cofunc = PyObject_GetAttrString(mod, "__create_codec"); Py_DECREF(mod); } return cofunc; } static PyObject * getcodec(PyObject *self, PyObject *encoding) { PyObject *codecobj, *r, *cofunc; const MultibyteCodec *codec; const char *enc; #ifdef NO_METH_O PyObject *args = encoding; if (!PyArg_ParseTuple(args, "O:getcodec", &encoding)) return NULL; #endif if (!PyString_Check(encoding)) { PyErr_SetString(PyExc_TypeError, "encoding name must be a string."); return NULL; } cofunc = getmultibytecodec(); if (cofunc == NULL) return NULL; enc = PyString_AS_STRING(encoding); for (codec = codec_list; codec->encoding[0]; codec++) if (strcmp(codec->encoding, enc) == 0) break; if (codec->encoding[0] == '\0') { PyErr_SetString(PyExc_LookupError, "no such codec is supported."); return NULL; } codecobj = PyCObject_FromVoidPtr((void *)codec, NULL); if (codecobj == NULL) return NULL; #if PY_VERSION_HEX >= 0x02020000 r = PyObject_CallFunctionObjArgs(cofunc, codecobj, NULL); #else r = PyObject_CallFunction(cofunc, "O", codecobj); #endif Py_DECREF(codecobj); return r; } static struct PyMethodDef __methods[] = { #ifndef NO_METH_O {"getcodec", (PyCFunction)getcodec, METH_O, ""}, #else {"getcodec", (PyCFunction)getcodec, METH_VARARGS, ""}, #endif {NULL, NULL}, }; static int register_maps(PyObject *module) { const struct dbcs_map *h; for (h = mapping_list; h->charset[0] != '\0'; h++) { char mhname[256] = "__map_"; int r; strcpy(mhname + sizeof("__map_") - 1, h->charset); r = PyModule_AddObject(module, mhname, PyCObject_FromVoidPtr((void *)h, NULL)); if (r == -1) return -1; } return 0; } #ifdef USING_BINARY_PAIR_SEARCH static DBCHAR find_pairencmap(ucs2_t body, ucs2_t modifier, const struct pair_encodemap *haystack, int haystacksize) { int pos, min, max; ucs4_t value = body << 16 | modifier; min = 0; max = haystacksize; for (pos = haystacksize >> 1; min != max; pos = (min + max) >> 1) if (value < haystack[pos].uniseq) { if (max == pos) break; else max = pos; } else if (value > haystack[pos].uniseq) { if (min == pos) break; else min = pos; } else break; if (value == haystack[pos].uniseq) return haystack[pos].code; else return DBCINV; } #endif #ifdef USING_IMPORTED_MAPS #define IMPORT_MAP(locale, charset, encmap, decmap) \ importmap("_codecs_" #locale, "__map_" #charset, \ (const void**)encmap, (const void**)decmap) static int importmap(const char *modname, const char *symbol, const void **encmap, const void **decmap) { PyObject *o, *mod; mod = PyImport_ImportModule((char *)modname); if (mod == NULL) return -1; o = PyObject_GetAttrString(mod, (char*)symbol); if (o == NULL) goto errorexit; else if (!PyCObject_Check(o)) { PyErr_SetString(PyExc_ValueError, "map data must be a CObject."); goto errorexit; } else { struct dbcs_map *map; map = PyCObject_AsVoidPtr(o); if (encmap != NULL) *encmap = map->encmap; if (decmap != NULL) *decmap = map->decmap; Py_DECREF(o); } Py_DECREF(mod); return 0; errorexit: Py_DECREF(mod); return -1; } #endif #define I_AM_A_MODULE_FOR(loc) \ void \ init_codecs_##loc(void) \ { \ PyObject *m = Py_InitModule("_codecs_" #loc, __methods);\ (void)register_maps(m); \ } #endif --- NEW FILE: emu_jisx0213_2000.h --- /* $CJKCodecs: emu_jisx0213_2000.h,v 1.3 2004/07/08 02:53:37 perky Exp $ */ /* These routines may be quite inefficient, but it's used only to emulate old * standards. */ #ifndef EMULATE_JISX0213_2000_ENCODE_INVALID #define EMULATE_JISX0213_2000_ENCODE_INVALID 1 #endif #define EMULATE_JISX0213_2000_ENCODE_BMP(assi, c) \ if (config == (void *)2000 && ( \ (c) == 0x9B1C || (c) == 0x4FF1 || \ (c) == 0x525D || (c) == 0x541E || \ (c) == 0x5653 || (c) == 0x59F8 || \ (c) == 0x5C5B || (c) == 0x5E77 || \ (c) == 0x7626 || (c) == 0x7E6B)) \ return EMULATE_JISX0213_2000_ENCODE_INVALID; \ else if (config == (void *)2000 && (c) == 0x9B1D) \ (assi) = 0x8000 | 0x7d3b; \ #define EMULATE_JISX0213_2000_ENCODE_EMP(assi, c) \ if (config == (void *)2000 && (c) == 0x20B9F) \ return EMULATE_JISX0213_2000_ENCODE_INVALID; #ifndef EMULATE_JISX0213_2000_DECODE_INVALID #define EMULATE_JISX0213_2000_DECODE_INVALID 2 #endif #define EMULATE_JISX0213_2000_DECODE_PLANE1(assi, c1, c2) \ if (config == (void *)2000 && \ (((c1) == 0x2E && (c2) == 0x21) || \ ((c1) == 0x2F && (c2) == 0x7E) || \ ((c1) == 0x4F && (c2) == 0x54) || \ ((c1) == 0x4F && (c2) == 0x7E) || \ ((c1) == 0x74 && (c2) == 0x27) || \ ((c1) == 0x7E && (c2) == 0x7A) || \ ((c1) == 0x7E && (c2) == 0x7B) || \ ((c1) == 0x7E && (c2) == 0x7C) || \ ((c1) == 0x7E && (c2) == 0x7D) || \ ((c1) == 0x7E && (c2) == 0x7E))) \ return EMULATE_JISX0213_2000_DECODE_INVALID; #define EMULATE_JISX0213_2000_DECODE_PLANE2(assi, c1, c2) \ if (config == (void *)2000 && (c1) == 0x7D && (c2) == 0x3B) \ (assi) = 0x9B1D; --- NEW FILE: mappings_cn.h --- /* * $CJKCodecs: mappings_cn.h,v 1.1 2004/07/07 14:59:27 perky Exp $ */ static const ucs2_t __gb2312_decmap[7482] = { 12288,12289,12290,12539,713,711,168,12291,12293,8213,65374,8214,8230,8216, 8217,8220,8221,12308,12309,12296,12297,12298,12299,12300,12301,12302,12303, 12310,12311,12304,12305,177,215,247,8758,8743,8744,8721,8719,8746,8745,8712, 8759,8730,8869,8741,8736,8978,8857,8747,8750,8801,8780,8776,8765,8733,8800, 8814,8815,8804,8805,8734,8757,8756,9794,9792,176,8242,8243,8451,65284,164, 65504,65505,8240,167,8470,9734,9733,9675,9679,9678,9671,9670,9633,9632,9651, 9650,8251,8594,8592,8593,8595,12307,9352,9353,9354,9355,9356,9357,9358,9359, 9360,9361,9362,9363,9364,9365,9366,9367,9368,9369,9370,9371,9332,9333,9334, 9335,9336,9337,9338,9339,9340,9341,9342,9343,9344,9345,9346,9347,9348,9349, 9350,9351,9312,9313,9314,9315,9316,9317,9318,9319,9320,9321,U,U,12832,12833, 12834,12835,12836,12837,12838,12839,12840,12841,U,U,8544,8545,8546,8547,8548, 8549,8550,8551,8552,8553,8554,8555,65281,65282,65283,65509,65285,65286,65287, 65288,65289,65290,65291,65292,65293,65294,65295,65296,65297,65298,65299,65300, 65301,65302,65303,65304,65305,65306,65307,65308,65309,65310,65311,65312,65313, [...4068 lines suppressed...] 13268,12395},{13270,13382,12397},{13384,13426,12510},{13428,13725,12553},{ 13727,13837,12851},{13839,13849,12962},{13851,14615,12973},{14617,14701,13738 },{14703,14798,13823},{14801,14814,13919},{14816,14962,13933},{14964,15181, 14080},{15183,15469,14298},{15471,15583,14585},{15585,16469,14698},{16471, 16734,15583},{16736,17206,15847},{17208,17323,16318},{17325,17328,16434},{ 17330,17372,16438},{17374,17621,16481},{17623,17995,16729},{17997,18016,17102 },{18018,18210,17122},{18212,18216,17315},{18218,18299,17320},{18301,18316, 17402},{18318,18758,17418},{18760,18809,17859},{18811,18812,17909},{18814, 18817,17911},{18820,18820,17915},{18823,18842,17916},{18844,18846,17936},{ 18848,18869,17939},{18872,19574,17961},{19576,19614,18664},{19620,19730,18703 },{19738,19885,18814},{19887,19967,18962},{40870,55295,19043},{59244,59244, 33469},{59336,59336,33470},{59367,59379,33471},{59413,59413,33484},{59417, 59421,33485},{59423,59429,33490},{59431,59434,33497},{59437,59440,33501},{ 59443,59450,33505},{59452,59458,33513},{59460,59475,33520},{59478,59491,33536 },{59493,63787,33550},{63789,63864,37845},{63866,63892,37921},{63894,63974, 37948},{63976,63984,38029},{63986,64011,38038},{64016,64016,38064},{64018, 64018,38065},{64021,64023,38066},{64025,64030,38069},{64034,64034,38075},{ 64037,64038,38076},{64042,65071,38078},{65074,65074,39108},{65093,65096,39109 },{65107,65107,39113},{65112,65112,39114},{65127,65127,39115},{65132,65280, 39116},{65375,65503,39265},{65510,65535,39394},{0,0,39420}}; --- NEW FILE: mappings_cns11643.h --- /* * $CJKCodecs: mappings_cns11643.h,v 1.1 2004/07/07 14:59:27 perky Exp $ */ static const ucs2_t __cns11643_1_decmap[5885] = { 32,44,12289,12290,46,183,59,58,63,33,65072,8230,8229,65104,65105,65106,8231, 65108,65109,65110,65111,U,U,U,U,U,U,U,65099,40,41,65077,65078,123,125,65079, 65080,12308,12309,65081,65082,12304,12305,65083,65084,12298,12299,65085,65086, 12296,12297,65087,65088,12300,12301,65089,65090,12302,12303,65091,65092,65113, 65114,65115,65116,65117,65118,8216,8217,8220,8221,12317,12318,8245,8242,35,38, 10035,8251,167,12291,9675,9679,9651,9650,9678,9734,9733,9671,9670,9633,9632, 9661,9660,12963,8453,U,U,U,95,65097,65098,65101,65102,U,U,65119,65120,65121, 43,45,215,247,177,8730,60,62,61,8806,8807,8800,8734,8786,8801,65122,65123, 65124,65125,65126,12316,8745,8746,8869,8736,8735,8895,13266,13265,8747,8750, 8757,8756,9792,9794,8853,8857,8593,8595,8594,8592,8598,8599,8601,8600,8214, 124,8260,92,47,65128,36,165,12306,162,163,37,64,8451,8457,65129,65130,65131, 13269,13212,13213,13214,13262,13217,13198,13199,13252,176,20825,20827,20830, 20829,20833,20835,21991,29929,31950,9601,9602,9603,9604,9605,9606,9607,9608, 9615,9614,9613,9612,9611,9610,9609,9532,9524,9516,9508,9500,9620,9472,9474, [...11825 lines suppressed...] },{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0, 0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{ 0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0 },{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0, 0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{ 0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0 },{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0, 0,0},{0,0,0},{0,0,0}, }; static const struct dbcs_index *cns11643_decmap[] = { NULL, cns11643_1_decmap, cns11643_2_decmap, cns11643_3_decmap, cns11643_4_decmap, cns11643_5_decmap, cns11643_6_decmap, cns11643_7_decmap, }; --- NEW FILE: mappings_hk.h --- /* * $CJKCodecs: mappings_hk.h,v 1.2 2004/07/07 15:07:23 perky Exp $ */ static const ucs2_t __big5hkscs_decmap[6095] = { 62211,62212,62213,62214,62215,268,62217,209,205,62220,62221,203,8168,62224, 202,62226,62227,62228,62229,270,62231,62232,256,193,461,192,274,201,282,200, 332,211,465,210,62245,7870,62247,7872,202,257,225,462,224,593,275,233,283,232, 299,237,464,236,333,243,466,242,363,250,468,249,470,472,474,U,U,U,U,U,U,U,U,U, U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,476,252,62276,7871,62278, 7873,234,609,62282,62283,41897,4421,U,25866,U,U,20029,28381,40270,37343,U,U, 30517,25745,20250,20264,20392,20822,20852,20892,20964,21153,21160,21307,21326, 21457,21464,22242,22768,22788,22791,22834,22836,23398,23454,23455,23706,24198, 24635,25993,26622,26628,26725,27982,28860,30005,32420,32428,32442,32455,32463, 32479,32518,32567,33402,33487,33647,35270,35774,35810,36710,36711,36718,U,U,U, U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,29713,31996, 32205,26950,31433,21031,U,U,U,U,37260,30904,37214,32956,U,36107,33014,2535,U, U,32927,40647,19661,40393,40460,19518,40438,28686,40458,41267,13761,U,28314, 33342,29977,U,18705,39532,39567,40857,31111,33900,7626,1488,10982,20004,20097, [...2305 lines suppressed...] __big5hkscs_nonbmp_encmap+25830,16,241},{__big5hkscs_nonbmp_encmap+26056,3,201 },{__big5hkscs_nonbmp_encmap+26255,40,77},{__big5hkscs_nonbmp_encmap+26293,5, 213},{__big5hkscs_nonbmp_encmap+26502,115,173},{__big5hkscs_nonbmp_encmap+ 26561,62,246},{__big5hkscs_nonbmp_encmap+26746,6,248},{ __big5hkscs_nonbmp_encmap+26989,35,222},{__big5hkscs_nonbmp_encmap+27177,20, 254},{__big5hkscs_nonbmp_encmap+27412,7,245},{__big5hkscs_nonbmp_encmap+27651, 32,255},{__big5hkscs_nonbmp_encmap+27875,169,169},{__big5hkscs_nonbmp_encmap+ 27876,52,91},{__big5hkscs_nonbmp_encmap+27916,198,203},{ __big5hkscs_nonbmp_encmap+27922,1,169},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0 },{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0, 0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{ 0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0 },{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0, 0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{ 0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0 },{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0, 0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{ __big5hkscs_nonbmp_encmap+28091,37,205},{__big5hkscs_nonbmp_encmap+28260,148, 212},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0}, }; --- NEW FILE: mappings_jisx0213_pair.h --- /* * $CJKCodecs: mappings_jisx0213_pair.h,v 1.2 2004/07/07 15:28:02 perky Exp $ */ #define JISX0213_ENCPAIRS 46 #ifdef EXTERN_JISX0213_PAIR static const struct widedbcs_index *jisx0213_pair_decmap; static const struct pair_encodemap *jisx0213_pair_encmap; #else static const ucs4_t __jisx0213_pair_decmap[49] = { 810234010,810365082,810496154,810627226,810758298,816525466,816656538, 816787610,816918682,817049754,817574042,818163866,818426010,838283418, 15074048,U,U,U,39060224,39060225,42730240,42730241,39387904,39387905,39453440, 39453441,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,48825061,48562921, }; static const struct widedbcs_index jisx0213_pair_decmap[256] = { {0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0 },{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0, 0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{ 0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{__jisx0213_pair_decmap +0,119,123},{__jisx0213_pair_decmap+5,119,126},{__jisx0213_pair_decmap+13,120, 120},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{__jisx0213_pair_decmap+14,68,102},{0,0,0 },{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0, 0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{ 0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0 },{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0, 0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{ 0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0 },{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0, 0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{ 0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0 },{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0, 0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{ 0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0 },{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0, 0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{ 0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0 },{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0, 0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{ 0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0 },{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0, 0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{ 0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0 },{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0}, }; static const struct pair_encodemap jisx0213_pair_encmap[JISX0213_ENCPAIRS] = { {0x00e60000,0x295c},{0x00e60300,0x2b44},{0x02540000,0x2b38},{0x02540300,0x2b48 },{0x02540301,0x2b49},{0x02590000,0x2b30},{0x02590300,0x2b4c},{0x02590301, 0x2b4d},{0x025a0000,0x2b43},{0x025a0300,0x2b4e},{0x025a0301,0x2b4f},{ 0x028c0000,0x2b37},{0x028c0300,0x2b4a},{0x028c0301,0x2b4b},{0x02e50000,0x2b60 },{0x02e502e9,0x2b66},{0x02e90000,0x2b64},{0x02e902e5,0x2b65},{0x304b0000, 0x242b},{0x304b309a,0x2477},{0x304d0000,0x242d},{0x304d309a,0x2478},{ 0x304f0000,0x242f},{0x304f309a,0x2479},{0x30510000,0x2431},{0x3051309a,0x247a },{0x30530000,0x2433},{0x3053309a,0x247b},{0x30ab0000,0x252b},{0x30ab309a, 0x2577},{0x30ad0000,0x252d},{0x30ad309a,0x2578},{0x30af0000,0x252f},{ 0x30af309a,0x2579},{0x30b10000,0x2531},{0x30b1309a,0x257a},{0x30b30000,0x2533 },{0x30b3309a,0x257b},{0x30bb0000,0x253b},{0x30bb309a,0x257c},{0x30c40000, 0x2544},{0x30c4309a,0x257d},{0x30c80000,0x2548},{0x30c8309a,0x257e},{ 0x31f70000,0x2675},{0x31f7309a,0x2678}, }; #endif --- NEW FILE: mappings_jp.h --- /* * $CJKCodecs: mappings_jp.h,v 1.3 2004/07/07 17:40:27 perky Exp $ */ static const ucs2_t __jisx0208_decmap[6956] = { 12288,12289,12290,65292,65294,12539,65306,65307,65311,65281,12443,12444,180, 65344,168,65342,65507,65343,12541,12542,12445,12446,12291,20189,12293,12294, 12295,12540,8213,8208,65295,92,12316,8214,65372,8230,8229,8216,8217,8220,8221, 65288,65289,12308,12309,65339,65341,65371,65373,12296,12297,12298,12299,12300, 12301,12302,12303,12304,12305,65291,8722,177,215,247,65309,8800,65308,65310, 8806,8807,8734,8756,9794,9792,176,8242,8243,8451,65509,65284,162,163,65285, 65283,65286,65290,65312,167,9734,9733,9675,9679,9678,9671,9670,9633,9632,9651, 9650,9661,9660,8251,12306,8594,8592,8593,8595,12307,U,U,U,U,U,U,U,U,U,U,U, 8712,8715,8838,8839,8834,8835,8746,8745,U,U,U,U,U,U,U,U,8743,8744,172,8658, 8660,8704,8707,U,U,U,U,U,U,U,U,U,U,U,8736,8869,8978,8706,8711,8801,8786,8810, 8811,8730,8765,8733,8757,8747,8748,U,U,U,U,U,U,U,8491,8240,9839,9837,9834, 8224,8225,182,U,U,U,U,9711,65296,65297,65298,65299,65300,65301,65302,65303, 65304,65305,U,U,U,U,U,U,U,65313,65314,65315,65316,65317,65318,65319,65320, 65321,65322,65323,65324,65325,65326,65327,65328,65329,65330,65331,65332,65333, [...4730 lines suppressed...] __jisx0213_emp_encmap+7993,144,144},{__jisx0213_emp_encmap+7994,207,207},{ __jisx0213_emp_encmap+7995,127,240},{__jisx0213_emp_encmap+8109,25,80},{ __jisx0213_emp_encmap+8165,198,198},{0,0,0},{__jisx0213_emp_encmap+8166,114, 114},{0,0,0},{0,0,0},{__jisx0213_emp_encmap+8167,219,219},{ __jisx0213_emp_encmap+8168,21,233},{__jisx0213_emp_encmap+8381,206,206},{ __jisx0213_emp_encmap+8382,26,249},{__jisx0213_emp_encmap+8606,144,144},{0,0,0 },{__jisx0213_emp_encmap+8607,140,140},{__jisx0213_emp_encmap+8608,55,55},{ __jisx0213_emp_encmap+8609,241,241},{__jisx0213_emp_encmap+8610,2,178},{0,0,0 },{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0, 0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{ 0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0 },{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0, 0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{ 0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0 },{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0, 0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{ 0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0 },{0,0,0}, }; --- NEW FILE: mappings_kr.h --- /* * $CJKCodecs: mappings_kr.h,v 1.1 2004/07/07 14:59:27 perky Exp $ */ static const ucs2_t __ksx1001_decmap[8264] = { 12288,12289,12290,183,8229,8230,168,12291,173,8213,8741,65340,8764,8216,8217, 8220,8221,12308,12309,12296,12297,12298,12299,12300,12301,12302,12303,12304, 12305,177,215,247,8800,8804,8805,8734,8756,176,8242,8243,8451,8491,65504, 65505,65509,9794,9792,8736,8869,8978,8706,8711,8801,8786,167,8251,9734,9733, 9675,9679,9678,9671,9670,9633,9632,9651,9650,9661,9660,8594,8592,8593,8595, 8596,12307,8810,8811,8730,8765,8733,8757,8747,8748,8712,8715,8838,8839,8834, 8835,8746,8745,8743,8744,65506,8658,8660,8704,8707,180,65374,711,728,733,730, 729,184,731,161,191,720,8750,8721,8719,164,8457,8240,9665,9664,9655,9654,9828, 9824,9825,9829,9831,9827,8857,9672,9635,9680,9681,9618,9636,9637,9640,9639, 9638,9641,9832,9743,9742,9756,9758,182,8224,8225,8597,8599,8601,8598,8600, 9837,9833,9834,9836,12927,12828,8470,13255,8482,13250,13272,8481,8364,174, 65281,65282,65283,65284,65285,65286,65287,65288,65289,65290,65291,65292,65293, 65294,65295,65296,65297,65298,65299,65300,65301,65302,65303,65304,65305,65306, 65307,65308,65309,65310,65311,65312,65313,65314,65315,65316,65317,65318,65319, [...3216 lines suppressed...] __cp949_encmap+24279,0,255},{__cp949_encmap+24535,0,255},{__cp949_encmap+24791 ,0,255},{__cp949_encmap+25047,0,255},{__cp949_encmap+25303,0,255},{ __cp949_encmap+25559,0,255},{__cp949_encmap+25815,0,255},{__cp949_encmap+26071 ,0,255},{__cp949_encmap+26327,0,255},{__cp949_encmap+26583,0,255},{ __cp949_encmap+26839,0,255},{__cp949_encmap+27095,0,255},{__cp949_encmap+27351 ,0,255},{__cp949_encmap+27607,0,255},{__cp949_encmap+27863,0,255},{ __cp949_encmap+28119,0,255},{__cp949_encmap+28375,0,255},{__cp949_encmap+28631 ,0,255},{__cp949_encmap+28887,0,255},{__cp949_encmap+29143,0,255},{ __cp949_encmap+29399,0,255},{__cp949_encmap+29655,0,255},{__cp949_encmap+29911 ,0,255},{__cp949_encmap+30167,0,255},{__cp949_encmap+30423,0,255},{ __cp949_encmap+30679,0,255},{__cp949_encmap+30935,0,255},{__cp949_encmap+31191 ,0,255},{__cp949_encmap+31447,0,255},{__cp949_encmap+31703,0,255},{ __cp949_encmap+31959,0,255},{__cp949_encmap+32215,0,255},{__cp949_encmap+32471 ,0,163},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0 },{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0, 0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{ 0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{__cp949_encmap+32635,0,255},{ __cp949_encmap+32891,0,11},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{__cp949_encmap+ 32903,1,230}, }; --- NEW FILE: mappings_tw.h --- /* * $CJKCodecs: mappings_tw.h,v 1.2 2004/07/07 15:07:23 perky Exp $ */ static const ucs2_t __big5_decmap[16702] = { 12288,65292,12289,12290,65294,8226,65307,65306,65311,65281,65072,8230,8229, 65104,65380,65106,183,65108,65109,65110,65111,65372,8211,65073,8212,65075, 9588,65076,65103,65288,65289,65077,65078,65371,65373,65079,65080,12308,12309, 65081,65082,12304,12305,65083,65084,12298,12299,65085,65086,12296,12297,65087, 65088,12300,12301,65089,65090,12302,12303,65091,65092,65113,65114,U,U,U,U,U,U, U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,65115,65116,65117, 65118,8216,8217,8220,8221,12317,12318,8245,8242,65283,65286,65290,8251,167, 12291,9675,9679,9651,9650,9678,9734,9733,9671,9670,9633,9632,9661,9660,12963, 8453,8254,65507,65343,717,65097,65098,65101,65102,65099,65100,65119,65120, 65121,65291,65293,215,247,177,8730,65308,65310,65309,8806,8807,8800,8734,8786, 8801,65122,65123,65124,65125,65126,8764,8745,8746,8869,8736,8735,8895,13266, 13265,8747,8750,8757,8756,9792,9794,9793,9737,8593,8595,8592,8594,8598,8599, 8601,8600,8741,8739,65295,65340,65295,65340,65284,165,12306,162,163,65285, 65312,8451,8457,65129,65130,65131,13269,13212,13213,13214,13262,13217,13198, [...2598 lines suppressed...] 82,82},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0 },{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0, 0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{__cp950ext_encmap+338,129,129},{0,0,0},{ 0,0,0},{0,0,0},{__cp950ext_encmap+339,167,167},{0,0,0},{0,0,0},{0,0,0},{0,0,0 },{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{__cp950ext_encmap+ 340,207,207},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{ 0,0,0},{__cp950ext_encmap+341,185,185},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0 },{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0, 0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{ 0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0 },{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0, 0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{ 0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0 },{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0, 0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{ 0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0 },{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0, 0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{__cp950ext_encmap+342,81,104},{ __cp950ext_encmap+366,15,229}, }; Index: README =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/cjkcodecs/README,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** README 17 Jan 2004 14:29:28 -0000 1.1 --- README 18 Jul 2004 03:06:27 -0000 1.2 *************** *** 3,7 **** This directory contains source files for cjkcodecs extension modules. They are based on CJKCodecs (http://cjkpython.i18n.org/#CJKCodecs) ! as of Jan 17 2004 currently. --- 3,7 ---- This directory contains source files for cjkcodecs extension modules. They are based on CJKCodecs (http://cjkpython.i18n.org/#CJKCodecs) ! as of Jul 18 2004 currently. Index: alg_jisx0201.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/cjkcodecs/alg_jisx0201.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** alg_jisx0201.h 17 Jan 2004 14:29:29 -0000 1.1 --- alg_jisx0201.h 18 Jul 2004 03:06:27 -0000 1.2 *************** *** 1,27 **** ! /* $CJKCodecs: alg_jisx0201.h,v 1.2 2003/11/27 16:42:20 perky Exp $ */ ! ! #define JISX0201_R_ENCODE(c, assi) \ ! if ((c) < 0x80 && (c) != 0x5c && (c) != 0x7e) \ ! (assi) = (c); \ ! else if ((c) == 0x00a5) (assi) = 0x5c; \ ! else if ((c) == 0x203e) (assi) = 0x7e; ! #define JISX0201_K_ENCODE(c, assi) \ ! if ((c) >= 0xff61 && (c) <= 0xff9f) \ ! (assi) = (c) - 0xfec0; ! #define JISX0201_ENCODE(c, assi) \ ! JISX0201_R_ENCODE(c, assi) \ ! else JISX0201_K_ENCODE(c, assi) ! #define JISX0201_R_DECODE(c, assi) \ ! if ((c) < 0x5c) (assi) = (c); \ ! else if ((c) == 0x5c) (assi) = 0x00a5; \ ! else if ((c) < 0x7e) (assi) = (c); \ ! else if ((c) == 0x7e) (assi) = 0x203e; \ ! else if ((c) == 0x7f) (assi) = 0x7f; ! #define JISX0201_K_DECODE(c, assi) \ ! if ((c) >= 0xa1 && (c) <= 0xdf) \ ! (assi) = 0xfec0 + (c); ! #define JISX0201_DECODE(c, assi) \ ! JISX0201_R_DECODE(c, assi) \ ! else JISX0201_K_DECODE(c, assi) --- 1,26 ---- ! /* $CJKCodecs: alg_jisx0201.h,v 1.2 2004/06/29 05:42:08 perky Exp $ */ ! #define JISX0201_R_ENCODE(c, assi) \ ! if ((c) < 0x80 && (c) != 0x5c && (c) != 0x7e) \ ! (assi) = (c); \ ! else if ((c) == 0x00a5) (assi) = 0x5c; \ ! else if ((c) == 0x203e) (assi) = 0x7e; ! #define JISX0201_K_ENCODE(c, assi) \ ! if ((c) >= 0xff61 && (c) <= 0xff9f) \ ! (assi) = (c) - 0xfec0; ! #define JISX0201_ENCODE(c, assi) \ ! JISX0201_R_ENCODE(c, assi) \ ! else JISX0201_K_ENCODE(c, assi) + #define JISX0201_R_DECODE(c, assi) \ + if ((c) < 0x5c) (assi) = (c); \ + else if ((c) == 0x5c) (assi) = 0x00a5; \ + else if ((c) < 0x7e) (assi) = (c); \ + else if ((c) == 0x7e) (assi) = 0x203e; \ + else if ((c) == 0x7f) (assi) = 0x7f; + #define JISX0201_K_DECODE(c, assi) \ + if ((c) >= 0xa1 && (c) <= 0xdf) \ + (assi) = 0xfec0 + (c); + #define JISX0201_DECODE(c, assi) \ + JISX0201_R_DECODE(c, assi) \ + else JISX0201_K_DECODE(c, assi) Index: multibytecodec.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/cjkcodecs/multibytecodec.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** multibytecodec.c 17 Jan 2004 14:29:29 -0000 1.1 --- multibytecodec.c 18 Jul 2004 03:06:29 -0000 1.2 *************** *** 3,7 **** * * Written by Hye-Shik Chang ! * $CJKCodecs: multibytecodec.c,v 1.6 2004/01/17 11:26:10 perky Exp $ */ --- 3,7 ---- * * Written by Hye-Shik Chang ! * $CJKCodecs: multibytecodec.c,v 1.12 2004/06/27 19:24:13 perky Exp $ */ [...2387 lines suppressed...] ! {NULL, NULL}, }; *************** *** 1204,1210 **** init_multibytecodec(void) { ! Py_InitModule("_multibytecodec", __methods); ! if (PyErr_Occurred()) ! Py_FatalError("can't initialize the _multibytecodec module"); } --- 1267,1273 ---- init_multibytecodec(void) { ! Py_InitModule("_multibytecodec", __methods); ! if (PyErr_Occurred()) ! Py_FatalError("can't initialize the _multibytecodec module"); } Index: multibytecodec.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/cjkcodecs/multibytecodec.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** multibytecodec.h 17 Jan 2004 14:29:29 -0000 1.1 --- multibytecodec.h 18 Jul 2004 03:06:29 -0000 1.2 *************** *** 3,7 **** * * Written by Hye-Shik Chang ! * $CJKCodecs: multibytecodec.h,v 1.2 2003/12/31 05:46:55 perky Exp $ */ --- 3,7 ---- * * Written by Hye-Shik Chang ! * $CJKCodecs: multibytecodec.h,v 1.7 2004/06/27 10:39:28 perky Exp $ */ *************** *** 12,85 **** #endif ! #include "cjkcommon.h" typedef union { ! void *p; ! int i; ! unsigned char c[8]; ! ucs2_t u2[4]; ! ucs4_t u4[2]; } MultibyteCodec_State; ! typedef int (*mbencode_func)(MultibyteCodec_State *state, ! const Py_UNICODE **inbuf, size_t inleft, ! unsigned char **outbuf, size_t outleft, ! int flags); ! typedef int (*mbencodeinit_func)(MultibyteCodec_State *state); typedef int (*mbencodereset_func)(MultibyteCodec_State *state, ! unsigned char **outbuf, size_t outleft); typedef int (*mbdecode_func)(MultibyteCodec_State *state, ! const unsigned char **inbuf, size_t inleft, ! Py_UNICODE **outbuf, size_t outleft); ! typedef int (*mbdecodeinit_func)(MultibyteCodec_State *state); ! typedef int (*mbdecodereset_func)(MultibyteCodec_State *state); typedef struct { ! const char *encoding; ! mbencode_func encode; ! mbencodeinit_func encinit; ! mbencodereset_func encreset; ! mbdecode_func decode; ! mbdecodeinit_func decinit; ! mbdecodereset_func decreset; } MultibyteCodec; typedef struct { ! PyObject_HEAD ! MultibyteCodec *codec; } MultibyteCodecObject; ! #define MAXDECPENDING 8 typedef struct { ! PyObject_HEAD ! MultibyteCodec *codec; ! MultibyteCodec_State state; ! unsigned char pending[MAXDECPENDING]; ! int pendingsize; ! PyObject *stream, *errors; } MultibyteStreamReaderObject; ! #define MAXENCPENDING 2 typedef struct { ! PyObject_HEAD ! MultibyteCodec *codec; ! MultibyteCodec_State state; ! Py_UNICODE pending[MAXENCPENDING]; ! int pendingsize; ! PyObject *stream, *errors; } MultibyteStreamWriterObject; /* positive values for illegal sequences */ ! #define MBERR_TOOSMALL (-1) /* insufficient output buffer space */ ! #define MBERR_TOOFEW (-2) /* incomplete input buffer */ ! #define MBERR_INTERNAL (-3) /* internal runtime error */ ! #define ERROR_STRICT (PyObject *)(1) ! #define ERROR_IGNORE (PyObject *)(2) ! #define ERROR_REPLACE (PyObject *)(3) ! #define ERROR_MAX ERROR_REPLACE ! #define MBENC_FLUSH 0x0001 /* encode all characters encodable */ ! #define MBENC_MAX MBENC_FLUSH #ifdef __cplusplus --- 12,103 ---- #endif ! #ifdef uint32_t ! typedef uint32_t ucs4_t; ! #else ! typedef unsigned int ucs4_t; ! #endif ! ! #ifdef uint16_t ! typedef uint16_t ucs2_t, DBCHAR; ! #else ! typedef unsigned short ucs2_t, DBCHAR; ! #endif typedef union { ! void *p; ! int i; ! unsigned char c[8]; ! ucs2_t u2[4]; ! ucs4_t u4[2]; } MultibyteCodec_State; ! typedef int (*mbcodec_init)(const void *config); ! typedef int (*mbencode_func)(MultibyteCodec_State *state, const void *config, ! const Py_UNICODE **inbuf, size_t inleft, ! unsigned char **outbuf, size_t outleft, ! int flags); ! typedef int (*mbencodeinit_func)(MultibyteCodec_State *state, ! const void *config); typedef int (*mbencodereset_func)(MultibyteCodec_State *state, ! const void *config, ! unsigned char **outbuf, size_t outleft); typedef int (*mbdecode_func)(MultibyteCodec_State *state, ! const void *config, ! const unsigned char **inbuf, size_t inleft, ! Py_UNICODE **outbuf, size_t outleft); ! typedef int (*mbdecodeinit_func)(MultibyteCodec_State *state, ! const void *config); ! typedef int (*mbdecodereset_func)(MultibyteCodec_State *state, ! const void *config); typedef struct { ! const char *encoding; ! const void *config; ! mbcodec_init codecinit; ! mbencode_func encode; ! mbencodeinit_func encinit; ! mbencodereset_func encreset; ! mbdecode_func decode; ! mbdecodeinit_func decinit; ! mbdecodereset_func decreset; } MultibyteCodec; typedef struct { ! PyObject_HEAD ! MultibyteCodec *codec; } MultibyteCodecObject; ! #define MAXDECPENDING 8 typedef struct { ! PyObject_HEAD ! MultibyteCodec *codec; ! MultibyteCodec_State state; ! unsigned char pending[MAXDECPENDING]; ! int pendingsize; ! PyObject *stream, *errors; } MultibyteStreamReaderObject; ! #define MAXENCPENDING 2 typedef struct { ! PyObject_HEAD ! MultibyteCodec *codec; ! MultibyteCodec_State state; ! Py_UNICODE pending[MAXENCPENDING]; ! int pendingsize; ! PyObject *stream, *errors; } MultibyteStreamWriterObject; /* positive values for illegal sequences */ ! #define MBERR_TOOSMALL (-1) /* insufficient output buffer space */ ! #define MBERR_TOOFEW (-2) /* incomplete input buffer */ ! #define MBERR_INTERNAL (-3) /* internal runtime error */ ! #define ERROR_STRICT (PyObject *)(1) ! #define ERROR_IGNORE (PyObject *)(2) ! #define ERROR_REPLACE (PyObject *)(3) ! #define ERROR_MAX ERROR_REPLACE ! #define MBENC_FLUSH 0x0001 /* encode all characters encodable */ ! #define MBENC_MAX MBENC_FLUSH #ifdef __cplusplus --- _big5.c DELETED --- --- _cp932.c DELETED --- --- _cp949.c DELETED --- --- _cp950.c DELETED --- --- _euc_jisx0213.c DELETED --- --- _euc_jp.c DELETED --- --- _euc_kr.c DELETED --- --- _gb18030.c DELETED --- --- _gb2312.c DELETED --- --- _gbk.c DELETED --- --- _hz.c DELETED --- --- _iso2022_jp.c DELETED --- --- _iso2022_jp_1.c DELETED --- --- _iso2022_jp_2.c DELETED --- --- _iso2022_jp_3.c DELETED --- --- _iso2022_jp_ext.c DELETED --- --- _iso2022_kr.c DELETED --- --- _johab.c DELETED --- --- _shift_jis.c DELETED --- --- _shift_jisx0213.c DELETED --- --- alg_iso8859_1.h DELETED --- --- alg_iso8859_7.h DELETED --- --- cjkcommon.h DELETED --- --- codeccommon.h DELETED --- --- codecentry.h DELETED --- --- iso2022common.h DELETED --- --- map_big5.h DELETED --- --- map_cp932ext.h DELETED --- --- map_cp949.h DELETED --- --- map_cp949ext.h DELETED --- --- map_cp950ext.h DELETED --- --- map_gb18030ext.h DELETED --- --- map_gb18030uni.h DELETED --- --- map_gb2312.h DELETED --- --- map_gbcommon.h DELETED --- --- map_gbkext.h DELETED --- --- map_jisx0208.h DELETED --- --- map_jisx0212.h DELETED --- --- map_jisx0213.h DELETED --- --- map_jisx0213_pairs.h DELETED --- --- map_jisxcommon.h DELETED --- --- map_ksx1001.h DELETED --- --- mapdata_ja_JP.c DELETED --- --- mapdata_ko_KR.c DELETED --- --- mapdata_zh_CN.c DELETED --- --- mapdata_zh_TW.c DELETED --- --- tweak_gbk.h DELETED --- From perky at users.sourceforge.net Sun Jul 18 05:06:59 2004 From: perky at users.sourceforge.net (perky@users.sourceforge.net) Date: Sun Jul 18 05:07:01 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libcodecs.tex,1.31,1.32 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9316/Doc/lib Modified Files: libcodecs.tex Log Message: Bring CJKCodecs 1.1 into trunk. This completely reorganizes source and installed layouts to make maintenance simple and easy. And it also adds four new codecs; big5hkscs, euc-jis-2004, shift-jis-2004 and iso2022-jp-2004. Index: libcodecs.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libcodecs.tex,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** libcodecs.tex 17 Jul 2004 14:44:43 -0000 1.31 --- libcodecs.tex 18 Jul 2004 03:06:26 -0000 1.32 *************** *** 549,552 **** --- 549,556 ---- {Traditional Chinese} + \lineiii{big5hkscs} + {big5-hkscs, hkscs} + {Traditional Chinese} + \lineiii{cp037} {IBM037, IBM039} *************** *** 697,702 **** {Japanese} \lineiii{euc_jisx0213} ! {jisx0213, eucjisx0213} {Japanese} --- 701,710 ---- {Japanese} + \lineiii{euc_jis_2004} + {jisx0213, eucjis2004} + {Japanese} + \lineiii{euc_jisx0213} ! {eucjisx0213} {Japanese} *************** *** 734,737 **** --- 742,749 ---- {Japanese, Korean, Simplified Chinese, Western Europe, Greek} + \lineiii{iso2022_jp_2004} + {iso2022jp-2004, iso-2022-jp-2004} + {Japanese} + \lineiii{iso2022_jp_3} {iso2022jp-3, iso-2022-jp-3} *************** *** 842,845 **** --- 854,861 ---- {Japanese} + \lineiii{shift_jis_2004} + {shiftjis2004, sjis_2004, sjis2004} + {Japanese} + \lineiii{shift_jisx0213} {shiftjisx0213, sjisx0213, s_jisx0213} From perky at users.sourceforge.net Sun Jul 18 05:06:59 2004 From: perky at users.sourceforge.net (perky@users.sourceforge.net) Date: Sun Jul 18 05:07:03 2004 Subject: [Python-checkins] python/dist/src setup.py,1.191,1.192 Message-ID: Update of /cvsroot/python/python/dist/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9316 Modified Files: setup.py Log Message: Bring CJKCodecs 1.1 into trunk. This completely reorganizes source and installed layouts to make maintenance simple and easy. And it also adds four new codecs; big5hkscs, euc-jis-2004, shift-jis-2004 and iso2022-jp-2004. Index: setup.py =================================================================== RCS file: /cvsroot/python/python/dist/src/setup.py,v retrieving revision 1.191 retrieving revision 1.192 diff -C2 -d -r1.191 -r1.192 *** setup.py 15 Jul 2004 19:56:25 -0000 1.191 --- setup.py 18 Jul 2004 03:06:26 -0000 1.192 *************** *** 764,776 **** exts.append(Extension('_multibytecodec', ['cjkcodecs/multibytecodec.c'])) ! for loc in ('ja_JP', 'ko_KR', 'zh_CN', 'zh_TW'): ! exts.append(Extension('_codecs_mapdata_' + loc, ! ['cjkcodecs/mapdata_%s.c' % loc])) ! for enc in ('shift_jis', 'cp932', 'euc_jp', 'iso2022_jp', ! 'iso2022_jp_1', 'iso2022_jp_2', 'iso2022_jp_3', ! 'iso2022_jp_ext', 'shift_jisx0213', 'euc_jisx0213', ! 'euc_kr', 'cp949', 'johab', 'iso2022_kr', 'gb2312', ! 'gbk', 'gb18030', 'hz', 'big5', 'cp950'): ! exts.append(Extension('_codecs_' + enc, ['cjkcodecs/_%s.c' % enc])) # Dynamic loading module --- 764,770 ---- exts.append(Extension('_multibytecodec', ['cjkcodecs/multibytecodec.c'])) ! for loc in ('kr', 'jp', 'cn', 'tw', 'hk', 'iso2022'): ! exts.append(Extension('_codecs_' + loc, ! ['cjkcodecs/_codecs_%s.c' % loc])) # Dynamic loading module From perky at users.sourceforge.net Sun Jul 18 05:07:00 2004 From: perky at users.sourceforge.net (perky@users.sourceforge.net) Date: Sun Jul 18 05:07:05 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_codecencodings_hk.py, NONE, 1.1 test_codecmaps_hk.py, NONE, 1.1 cjkencodings_test.py, 1.1, 1.2 test_codecencodings_cn.py, 1.2, 1.3 test_codecencodings_jp.py, 1.2, 1.3 test_codecencodings_kr.py, 1.2, 1.3 test_codecencodings_tw.py, 1.2, 1.3 test_codecmaps_cn.py, 1.2, 1.3 test_codecmaps_jp.py, 1.2, 1.3 test_codecmaps_kr.py, 1.2, 1.3 test_codecmaps_tw.py, 1.2, 1.3 test_multibytecodec.py, 1.3, 1.4 test_multibytecodec_support.py, 1.4, 1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9316/Lib/test Modified Files: cjkencodings_test.py test_codecencodings_cn.py test_codecencodings_jp.py test_codecencodings_kr.py test_codecencodings_tw.py test_codecmaps_cn.py test_codecmaps_jp.py test_codecmaps_kr.py test_codecmaps_tw.py test_multibytecodec.py test_multibytecodec_support.py Added Files: test_codecencodings_hk.py test_codecmaps_hk.py Log Message: Bring CJKCodecs 1.1 into trunk. This completely reorganizes source and installed layouts to make maintenance simple and easy. And it also adds four new codecs; big5hkscs, euc-jis-2004, shift-jis-2004 and iso2022-jp-2004. --- NEW FILE: test_codecencodings_hk.py --- #!/usr/bin/env python # # test_codecencodings_hk.py # Codec encoding tests for HongKong encodings. # # $CJKCodecs: test_codecencodings_hk.py,v 1.1 2004/07/10 17:35:20 perky Exp $ from test import test_support from test import test_multibytecodec_support import unittest class Test_Big5HKSCS(test_multibytecodec_support.TestBase, unittest.TestCase): encoding = 'big5hkscs' tstring = test_multibytecodec_support.load_teststring('big5hkscs') codectests = ( # invalid bytes ("abc\x80\x80\xc1\xc4", "strict", None), ("abc\xc8", "strict", None), ("abc\x80\x80\xc1\xc4", "replace", u"abc\ufffd\u8b10"), ("abc\x80\x80\xc1\xc4\xc8", "replace", u"abc\ufffd\u8b10\ufffd"), ("abc\x80\x80\xc1\xc4", "ignore", u"abc\u8b10"), ) def test_main(): suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(Test_Big5HKSCS)) test_support.run_suite(suite) if __name__ == "__main__": test_main() --- NEW FILE: test_codecmaps_hk.py --- #!/usr/bin/env python # # test_codecmaps_hk.py # Codec mapping tests for HongKong encodings # # $CJKCodecs: test_codecmaps_hk.py,v 1.1 2004/07/10 17:35:20 perky Exp $ from test import test_support from test import test_multibytecodec_support import unittest class TestBig5HKSCSMap(test_multibytecodec_support.TestBase_Mapping, unittest.TestCase): encoding = 'big5hkscs' mapfilename = 'BIG5HKSCS.TXT' mapfileurl = 'http://people.freebsd.org/~perky/i18n/BIG5HKSCS.TXT' def test_main(): suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(TestBig5HKSCSMap)) test_support.run_suite(suite) test_multibytecodec_support.register_skip_expected(TestBig5HKSCSMap) if __name__ == "__main__": test_main() Index: cjkencodings_test.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/cjkencodings_test.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** cjkencodings_test.py 17 Jan 2004 14:29:28 -0000 1.1 --- cjkencodings_test.py 18 Jul 2004 03:06:26 -0000 1.2 *************** *** 64,67 **** --- 64,70 ---- "\xab\x96\xe7\x9a\x84\xe5\x95\x8f\xe9\xa1\x8c\xe5\xb0\xb1\xe6\x98" "\xaf\x3a\x0a\x0a"), + 'big5hkscs': ( + "\x88\x45\x88\x5c\x8a\x73\x8b\xda\x8d\xd8\x0a", + "\xf0\xa0\x84\x8c\xc4\x9a\xe9\xb5\xae\xe7\xbd\x93\xe6\xb4\x86\x0a"), 'cp949': ( "\x8c\x63\xb9\xe6\xb0\xa2\xc7\xcf\x20\xbc\x84\xbd\xc3\xc4\xdd\xb6" Index: test_codecencodings_cn.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_codecencodings_cn.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** test_codecencodings_cn.py 18 Jan 2004 20:29:54 -0000 1.2 --- test_codecencodings_cn.py 18 Jul 2004 03:06:26 -0000 1.3 *************** *** 4,8 **** # Codec encoding tests for PRC encodings. # ! # $CJKCodecs: test_codecencodings_cn.py,v 1.1 2003/12/19 03:00:05 perky Exp $ from test import test_support --- 4,8 ---- # Codec encoding tests for PRC encodings. # ! # $CJKCodecs: test_codecencodings_cn.py,v 1.2 2004/06/19 06:09:55 perky Exp $ from test import test_support *************** *** 28,33 **** codectests = ( # invalid bytes ! ("abc\x80\x80\xc1\xc4", "strict", None), ! ("abc\xc8", "strict", None), ("abc\x80\x80\xc1\xc4", "replace", u"abc\ufffd\u804a"), ("abc\x80\x80\xc1\xc4\xc8", "replace", u"abc\ufffd\u804a\ufffd"), --- 28,33 ---- codectests = ( # invalid bytes ! ("abc\x80\x80\xc1\xc4", "strict", None), ! ("abc\xc8", "strict", None), ("abc\x80\x80\xc1\xc4", "replace", u"abc\ufffd\u804a"), ("abc\x80\x80\xc1\xc4\xc8", "replace", u"abc\ufffd\u804a\ufffd"), Index: test_codecencodings_jp.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_codecencodings_jp.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** test_codecencodings_jp.py 18 Jan 2004 20:29:54 -0000 1.2 --- test_codecencodings_jp.py 18 Jul 2004 03:06:26 -0000 1.3 *************** *** 4,8 **** # Codec encoding tests for Japanese encodings. # ! # $CJKCodecs: test_codecencodings_jp.py,v 1.2 2004/01/06 09:25:37 perky Exp $ from test import test_support --- 4,8 ---- # Codec encoding tests for Japanese encodings. # ! # $CJKCodecs: test_codecencodings_jp.py,v 1.3 2004/06/19 06:09:55 perky Exp $ from test import test_support *************** *** 65,78 **** ) - class Test_EUC_JP_STRICT(test_multibytecodec_support.TestBase, - unittest.TestCase): - encoding = 'euc_jp_strict' - tstring = test_multibytecodec_support.load_teststring('euc_jp') - codectests = eucjp_commontests + ( - ("\xa1\xc0\\", "strict", u"\\\\"), - (u"\xa5", "strict", None), - (u"\u203e", "strict", None), - ) - shiftjis_commonenctests = ( ("abc\x80\x80\x82\x84", "strict", None), --- 65,68 ---- *************** *** 91,102 **** ) - class Test_SJIS_STRICT(test_multibytecodec_support.TestBase, unittest.TestCase): - encoding = 'shift_jis_strict' - tstring = test_multibytecodec_support.load_teststring('shift_jis') - codectests = shiftjis_commonenctests + ( - ("\\\x7e", "replace", u"\xa5\u203e"), - ("\x81\x5f\x81\x61\x81\x7c", "replace", u"\x5c\u2016\u2212"), - ) - class Test_SJISX0213(test_multibytecodec_support.TestBase, unittest.TestCase): encoding = 'shift_jisx0213' --- 81,84 ---- *************** *** 124,130 **** suite.addTest(unittest.makeSuite(Test_EUC_JP_COMPAT)) suite.addTest(unittest.makeSuite(Test_SJIS_COMPAT)) - if test_multibytecodec_support.__cjkcodecs__: - suite.addTest(unittest.makeSuite(Test_EUC_JP_STRICT)) - suite.addTest(unittest.makeSuite(Test_SJIS_STRICT)) suite.addTest(unittest.makeSuite(Test_SJISX0213)) test_support.run_suite(suite) --- 106,109 ---- Index: test_codecencodings_kr.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_codecencodings_kr.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** test_codecencodings_kr.py 18 Jan 2004 20:29:54 -0000 1.2 --- test_codecencodings_kr.py 18 Jul 2004 03:06:26 -0000 1.3 *************** *** 4,8 **** # Codec encoding tests for ROK encodings. # ! # $CJKCodecs: test_codecencodings_kr.py,v 1.1 2003/12/19 03:00:06 perky Exp $ from test import test_support --- 4,8 ---- # Codec encoding tests for ROK encodings. # ! # $CJKCodecs: test_codecencodings_kr.py,v 1.2 2004/06/19 06:09:55 perky Exp $ from test import test_support Index: test_codecencodings_tw.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_codecencodings_tw.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** test_codecencodings_tw.py 18 Jan 2004 20:29:54 -0000 1.2 --- test_codecencodings_tw.py 18 Jul 2004 03:06:26 -0000 1.3 *************** *** 4,8 **** # Codec encoding tests for ROC encodings. # ! # $CJKCodecs: test_codecencodings_tw.py,v 1.1 2003/12/19 03:00:06 perky Exp $ from test import test_support --- 4,8 ---- # Codec encoding tests for ROC encodings. # ! # $CJKCodecs: test_codecencodings_tw.py,v 1.2 2004/06/19 06:09:55 perky Exp $ from test import test_support Index: test_codecmaps_cn.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_codecmaps_cn.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** test_codecmaps_cn.py 18 Jan 2004 20:29:54 -0000 1.2 --- test_codecmaps_cn.py 18 Jul 2004 03:06:26 -0000 1.3 *************** *** 4,8 **** # Codec mapping tests for PRC encodings # ! # $CJKCodecs: test_codecmaps_cn.py,v 1.2 2004/01/17 12:47:19 perky Exp $ from test import test_support --- 4,8 ---- # Codec mapping tests for PRC encodings # ! # $CJKCodecs: test_codecmaps_cn.py,v 1.3 2004/06/19 06:09:55 perky Exp $ from test import test_support Index: test_codecmaps_jp.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_codecmaps_jp.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** test_codecmaps_jp.py 18 Jan 2004 20:29:55 -0000 1.2 --- test_codecmaps_jp.py 18 Jul 2004 03:06:26 -0000 1.3 *************** *** 4,8 **** # Codec mapping tests for Japanese encodings # ! # $CJKCodecs: test_codecmaps_jp.py,v 1.2 2004/01/17 12:47:19 perky Exp $ from test import test_support --- 4,8 ---- # Codec mapping tests for Japanese encodings # ! # $CJKCodecs: test_codecmaps_jp.py,v 1.3 2004/06/19 06:09:55 perky Exp $ from test import test_support *************** *** 49,61 **** ] - - class TestSJISSTRICTMap(test_multibytecodec_support.TestBase_Mapping, - unittest.TestCase): - encoding = 'shift_jis_strict' - mapfilename = 'SHIFTJIS.TXT' - mapfileurl = 'http://www.unicode.org/Public/MAPPINGS/OBSOLETE' \ - '/EASTASIA/JIS/SHIFTJIS.TXT' - - class TestEUCJISX0213Map(test_multibytecodec_support.TestBase_Mapping, unittest.TestCase): --- 49,52 ---- *************** *** 77,82 **** suite.addTest(unittest.makeSuite(TestEUCJPCOMPATMap)) suite.addTest(unittest.makeSuite(TestSJISCOMPATMap)) - if test_multibytecodec_support.__cjkcodecs__: - suite.addTest(unittest.makeSuite(TestSJISSTRICTMap)) suite.addTest(unittest.makeSuite(TestEUCJISX0213Map)) suite.addTest(unittest.makeSuite(TestSJISX0213Map)) --- 68,71 ---- *************** *** 86,89 **** --- 75,79 ---- TestEUCJPCOMPATMap, TestSJISCOMPATMap, TestEUCJISX0213Map, TestSJISX0213Map) + if __name__ == "__main__": test_main() Index: test_codecmaps_kr.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_codecmaps_kr.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** test_codecmaps_kr.py 18 Jan 2004 20:29:55 -0000 1.2 --- test_codecmaps_kr.py 18 Jul 2004 03:06:26 -0000 1.3 *************** *** 4,8 **** # Codec mapping tests for ROK encodings # ! # $CJKCodecs: test_codecmaps_kr.py,v 1.2 2004/01/17 12:47:19 perky Exp $ from test import test_support --- 4,8 ---- # Codec mapping tests for ROK encodings # ! # $CJKCodecs: test_codecmaps_kr.py,v 1.3 2004/06/19 06:09:55 perky Exp $ from test import test_support Index: test_codecmaps_tw.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_codecmaps_tw.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** test_codecmaps_tw.py 18 Jan 2004 20:29:55 -0000 1.2 --- test_codecmaps_tw.py 18 Jul 2004 03:06:26 -0000 1.3 *************** *** 4,8 **** # Codec mapping tests for ROC encodings # ! # $CJKCodecs: test_codecmaps_tw.py,v 1.2 2004/01/17 12:47:19 perky Exp $ from test import test_support --- 4,8 ---- # Codec mapping tests for ROC encodings # ! # $CJKCodecs: test_codecmaps_tw.py,v 1.3 2004/06/19 06:09:55 perky Exp $ from test import test_support Index: test_multibytecodec.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_multibytecodec.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** test_multibytecodec.py 20 Jan 2004 09:11:48 -0000 1.3 --- test_multibytecodec.py 18 Jul 2004 03:06:26 -0000 1.4 *************** *** 4,8 **** # Unit test for multibytecodec itself # ! # $CJKCodecs: test_multibytecodec.py,v 1.5 2004/01/06 02:26:28 perky Exp $ from test import test_support --- 4,8 ---- # Unit test for multibytecodec itself # ! # $CJKCodecs: test_multibytecodec.py,v 1.8 2004/06/19 06:09:55 perky Exp $ from test import test_support *************** *** 70,73 **** --- 70,79 ---- self.assertEqual('abcd'.encode('gb18030'), 'abcd') + def test_streamwriter_strwrite(self): + s = StringIO.StringIO() + wr = codecs.getwriter('gb18030')(s) + wr.write('abcd') + self.assertEqual(s.getvalue(), 'abcd') + def test_main(): suite = unittest.TestSuite() Index: test_multibytecodec_support.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_multibytecodec_support.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** test_multibytecodec_support.py 8 Jul 2004 04:22:19 -0000 1.4 --- test_multibytecodec_support.py 18 Jul 2004 03:06:26 -0000 1.5 *************** *** 4,8 **** # Common Unittest Routines for CJK codecs # ! # $CJKCodecs: test_multibytecodec_support.py,v 1.5 2004/01/17 12:47:19 perky Exp $ import sys, codecs, os.path --- 4,8 ---- # Common Unittest Routines for CJK codecs # ! # $CJKCodecs: test_multibytecodec_support.py,v 1.6 2004/06/19 06:09:55 perky Exp $ import sys, codecs, os.path *************** *** 165,175 **** unittest.TestCase.__init__(self, *args, **kw) if not os.path.exists(self.mapfilename): ! parent = os.path.join(os.pardir, self.mapfilename) ! if not os.path.exists(parent): ! format = '%s not found, download from %s' ! raise test_support.TestSkipped(format % ! (self.mapfilename, self.mapfileurl)) ! else: ! self.mapfilename = parent def test_mapping_file(self): --- 165,170 ---- unittest.TestCase.__init__(self, *args, **kw) if not os.path.exists(self.mapfilename): ! raise test_support.TestSkipped('%s not found, download from %s' % ! (self.mapfilename, self.mapfileurl)) def test_mapping_file(self): From perky at users.sourceforge.net Sun Jul 18 05:07:00 2004 From: perky at users.sourceforge.net (perky@users.sourceforge.net) Date: Sun Jul 18 05:07:06 2004 Subject: [Python-checkins] python/dist/src/Lib/encodings big5hkscs.py, NONE, 1.1 euc_jis_2004.py, NONE, 1.1 iso2022_jp_2004.py, NONE, 1.1 shift_jis_2004.py, NONE, 1.1 aliases.py, 1.24, 1.25 big5.py, 1.2, 1.3 cp932.py, 1.2, 1.3 cp949.py, 1.2, 1.3 cp950.py, 1.2, 1.3 euc_jisx0213.py, 1.2, 1.3 euc_jp.py, 1.2, 1.3 euc_kr.py, 1.2, 1.3 gb18030.py, 1.2, 1.3 gb2312.py, 1.2, 1.3 gbk.py, 1.2, 1.3 hz.py, 1.2, 1.3 iso2022_jp.py, 1.2, 1.3 iso2022_jp_1.py, 1.2, 1.3 iso2022_jp_2.py, 1.2, 1.3 iso2022_jp_3.py, 1.2, 1.3 iso2022_jp_ext.py, 1.2, 1.3 iso2022_kr.py, 1.2, 1.3 johab.py, 1.2, 1.3 shift_jis.py, 1.2, 1.3 shift_jisx0213.py, 1.2, 1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/encodings In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9316/Lib/encodings Modified Files: aliases.py big5.py cp932.py cp949.py cp950.py euc_jisx0213.py euc_jp.py euc_kr.py gb18030.py gb2312.py gbk.py hz.py iso2022_jp.py iso2022_jp_1.py iso2022_jp_2.py iso2022_jp_3.py iso2022_jp_ext.py iso2022_kr.py johab.py shift_jis.py shift_jisx0213.py Added Files: big5hkscs.py euc_jis_2004.py iso2022_jp_2004.py shift_jis_2004.py Log Message: Bring CJKCodecs 1.1 into trunk. This completely reorganizes source and installed layouts to make maintenance simple and easy. And it also adds four new codecs; big5hkscs, euc-jis-2004, shift-jis-2004 and iso2022-jp-2004. --- NEW FILE: big5hkscs.py --- # # big5hkscs.py: Python Unicode Codec for BIG5HKSCS # # Written by Hye-Shik Chang # $CJKCodecs: big5hkscs.py,v 1.1 2004/06/29 05:14:27 perky Exp $ # import _codecs_hk, codecs codec = _codecs_hk.getcodec('big5hkscs') class Codec(codecs.Codec): encode = codec.encode decode = codec.decode class StreamReader(Codec, codecs.StreamReader): def __init__(self, stream, errors='strict'): codecs.StreamReader.__init__(self, stream, errors) __codec = codec.StreamReader(stream, errors) self.read = __codec.read self.readline = __codec.readline self.readlines = __codec.readlines self.reset = __codec.reset class StreamWriter(Codec, codecs.StreamWriter): def __init__(self, stream, errors='strict'): codecs.StreamWriter.__init__(self, stream, errors) __codec = codec.StreamWriter(stream, errors) self.write = __codec.write self.writelines = __codec.writelines self.reset = __codec.reset def getregentry(): return (codec.encode, codec.decode, StreamReader, StreamWriter) --- NEW FILE: euc_jis_2004.py --- # # euc_jis_2004.py: Python Unicode Codec for EUC_JIS_2004 # # Written by Hye-Shik Chang # $CJKCodecs: euc_jis_2004.py,v 1.1 2004/07/07 16:18:25 perky Exp $ # import _codecs_jp, codecs codec = _codecs_jp.getcodec('euc_jis_2004') class Codec(codecs.Codec): encode = codec.encode decode = codec.decode class StreamReader(Codec, codecs.StreamReader): def __init__(self, stream, errors='strict'): codecs.StreamReader.__init__(self, stream, errors) __codec = codec.StreamReader(stream, errors) self.read = __codec.read self.readline = __codec.readline self.readlines = __codec.readlines self.reset = __codec.reset class StreamWriter(Codec, codecs.StreamWriter): def __init__(self, stream, errors='strict'): codecs.StreamWriter.__init__(self, stream, errors) __codec = codec.StreamWriter(stream, errors) self.write = __codec.write self.writelines = __codec.writelines self.reset = __codec.reset def getregentry(): return (codec.encode, codec.decode, StreamReader, StreamWriter) --- NEW FILE: iso2022_jp_2004.py --- # # iso2022_jp_2004.py: Python Unicode Codec for ISO2022_JP_2004 # # Written by Hye-Shik Chang # $CJKCodecs: iso2022_jp_2004.py,v 1.1 2004/07/07 16:18:25 perky Exp $ # import _codecs_iso2022, codecs codec = _codecs_iso2022.getcodec('iso2022_jp_2004') class Codec(codecs.Codec): encode = codec.encode decode = codec.decode class StreamReader(Codec, codecs.StreamReader): def __init__(self, stream, errors='strict'): codecs.StreamReader.__init__(self, stream, errors) __codec = codec.StreamReader(stream, errors) self.read = __codec.read self.readline = __codec.readline self.readlines = __codec.readlines self.reset = __codec.reset class StreamWriter(Codec, codecs.StreamWriter): def __init__(self, stream, errors='strict'): codecs.StreamWriter.__init__(self, stream, errors) __codec = codec.StreamWriter(stream, errors) self.write = __codec.write self.writelines = __codec.writelines self.reset = __codec.reset def getregentry(): return (codec.encode, codec.decode, StreamReader, StreamWriter) --- NEW FILE: shift_jis_2004.py --- # # shift_jis_2004.py: Python Unicode Codec for SHIFT_JIS_2004 # # Written by Hye-Shik Chang # $CJKCodecs: shift_jis_2004.py,v 1.1 2004/07/07 16:18:25 perky Exp $ # import _codecs_jp, codecs codec = _codecs_jp.getcodec('shift_jis_2004') class Codec(codecs.Codec): encode = codec.encode decode = codec.decode class StreamReader(Codec, codecs.StreamReader): def __init__(self, stream, errors='strict'): codecs.StreamReader.__init__(self, stream, errors) __codec = codec.StreamReader(stream, errors) self.read = __codec.read self.readline = __codec.readline self.readlines = __codec.readlines self.reset = __codec.reset class StreamWriter(Codec, codecs.StreamWriter): def __init__(self, stream, errors='strict'): codecs.StreamWriter.__init__(self, stream, errors) __codec = codec.StreamWriter(stream, errors) self.write = __codec.write self.writelines = __codec.writelines self.reset = __codec.reset def getregentry(): return (codec.encode, codec.decode, StreamReader, StreamWriter) Index: aliases.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/encodings/aliases.py,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** aliases.py 19 Mar 2004 08:06:01 -0000 1.24 --- aliases.py 18 Jul 2004 03:06:26 -0000 1.25 *************** *** 40,43 **** --- 40,47 ---- 'csbig5' : 'big5', + # big5hkscs codec + 'big5_hkscs' : 'big5hkscs', + 'hkscs' : 'big5hkscs', + # bz2_codec codec 'bz2' : 'bz2_codec', *************** *** 198,203 **** 'ms950' : 'cp950', # euc_jisx0213 codec - 'jisx0213' : 'euc_jisx0213', 'eucjisx0213' : 'euc_jisx0213', --- 202,211 ---- 'ms950' : 'cp950', + # euc_jis_2004 codec + 'jisx0213' : 'euc_jis_2004', + 'eucjis2004' : 'euc_jis_2004', + 'euc_jis2004' : 'euc_jis_2004', + # euc_jisx0213 codec 'eucjisx0213' : 'euc_jisx0213', *************** *** 255,258 **** --- 263,270 ---- 'iso_2022_jp_2' : 'iso2022_jp_2', + # iso2022_jp_2004 codec + 'iso_2022_jp_2004' : 'iso2022_jp_2004', + 'iso2022jp_2004' : 'iso2022_jp_2004', + # iso2022_jp_3 codec 'iso2022jp_3' : 'iso2022_jp_3', *************** *** 417,420 **** --- 429,437 ---- 's_jis' : 'shift_jis', + # shift_jis_2004 codec + 'shiftjis2004' : 'shift_jis_2004', + 'sjis_2004' : 'shift_jis_2004', + 's_jis_2004' : 'shift_jis_2004', + # shift_jisx0213 codec 'shiftjisx0213' : 'shift_jisx0213', Index: big5.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/encodings/big5.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** big5.py 7 Jul 2004 20:54:47 -0000 1.2 --- big5.py 18 Jul 2004 03:06:26 -0000 1.3 *************** *** 3,11 **** # # Written by Hye-Shik Chang ! # $CJKCodecs: big5.py,v 1.3 2004/01/17 11:26:10 perky Exp $ # ! from _codecs_big5 import codec ! import codecs class Codec(codecs.Codec): --- 3,12 ---- # # Written by Hye-Shik Chang ! # $CJKCodecs: big5.py,v 1.8 2004/06/28 18:16:03 perky Exp $ # ! import _codecs_tw, codecs ! ! codec = _codecs_tw.getcodec('big5') class Codec(codecs.Codec): *************** *** 31,33 **** def getregentry(): ! return (Codec().encode,Codec().decode,StreamReader,StreamWriter) --- 32,34 ---- def getregentry(): ! return (codec.encode, codec.decode, StreamReader, StreamWriter) Index: cp932.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/encodings/cp932.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** cp932.py 7 Jul 2004 20:54:47 -0000 1.2 --- cp932.py 18 Jul 2004 03:06:26 -0000 1.3 *************** *** 3,11 **** # # Written by Hye-Shik Chang ! # $CJKCodecs: cp932.py,v 1.3 2004/01/17 11:26:10 perky Exp $ # ! from _codecs_cp932 import codec ! import codecs class Codec(codecs.Codec): --- 3,12 ---- # # Written by Hye-Shik Chang ! # $CJKCodecs: cp932.py,v 1.8 2004/06/28 18:16:03 perky Exp $ # ! import _codecs_jp, codecs ! ! codec = _codecs_jp.getcodec('cp932') class Codec(codecs.Codec): *************** *** 31,33 **** def getregentry(): ! return (Codec().encode,Codec().decode,StreamReader,StreamWriter) --- 32,34 ---- def getregentry(): ! return (codec.encode, codec.decode, StreamReader, StreamWriter) Index: cp949.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/encodings/cp949.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** cp949.py 7 Jul 2004 20:54:47 -0000 1.2 --- cp949.py 18 Jul 2004 03:06:26 -0000 1.3 *************** *** 3,11 **** # # Written by Hye-Shik Chang ! # $CJKCodecs: cp949.py,v 1.3 2004/01/17 11:26:10 perky Exp $ # ! from _codecs_cp949 import codec ! import codecs class Codec(codecs.Codec): --- 3,12 ---- # # Written by Hye-Shik Chang ! # $CJKCodecs: cp949.py,v 1.8 2004/06/28 18:16:03 perky Exp $ # ! import _codecs_kr, codecs ! ! codec = _codecs_kr.getcodec('cp949') class Codec(codecs.Codec): *************** *** 31,33 **** def getregentry(): ! return (Codec().encode,Codec().decode,StreamReader,StreamWriter) --- 32,34 ---- def getregentry(): ! return (codec.encode, codec.decode, StreamReader, StreamWriter) Index: cp950.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/encodings/cp950.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** cp950.py 7 Jul 2004 20:54:47 -0000 1.2 --- cp950.py 18 Jul 2004 03:06:26 -0000 1.3 *************** *** 3,11 **** # # Written by Hye-Shik Chang ! # $CJKCodecs: cp950.py,v 1.3 2004/01/17 11:26:10 perky Exp $ # ! from _codecs_cp950 import codec ! import codecs class Codec(codecs.Codec): --- 3,12 ---- # # Written by Hye-Shik Chang ! # $CJKCodecs: cp950.py,v 1.8 2004/06/28 18:16:03 perky Exp $ # ! import _codecs_tw, codecs ! ! codec = _codecs_tw.getcodec('cp950') class Codec(codecs.Codec): *************** *** 31,33 **** def getregentry(): ! return (Codec().encode,Codec().decode,StreamReader,StreamWriter) --- 32,34 ---- def getregentry(): ! return (codec.encode, codec.decode, StreamReader, StreamWriter) Index: euc_jisx0213.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/encodings/euc_jisx0213.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** euc_jisx0213.py 7 Jul 2004 20:54:47 -0000 1.2 --- euc_jisx0213.py 18 Jul 2004 03:06:26 -0000 1.3 *************** *** 3,11 **** # # Written by Hye-Shik Chang ! # $CJKCodecs: euc_jisx0213.py,v 1.3 2004/01/17 11:26:10 perky Exp $ # ! from _codecs_euc_jisx0213 import codec ! import codecs class Codec(codecs.Codec): --- 3,12 ---- # # Written by Hye-Shik Chang ! # $CJKCodecs: euc_jisx0213.py,v 1.8 2004/06/28 18:16:03 perky Exp $ # ! import _codecs_jp, codecs ! ! codec = _codecs_jp.getcodec('euc_jisx0213') class Codec(codecs.Codec): *************** *** 31,33 **** def getregentry(): ! return (Codec().encode,Codec().decode,StreamReader,StreamWriter) --- 32,34 ---- def getregentry(): ! return (codec.encode, codec.decode, StreamReader, StreamWriter) Index: euc_jp.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/encodings/euc_jp.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** euc_jp.py 7 Jul 2004 20:54:47 -0000 1.2 --- euc_jp.py 18 Jul 2004 03:06:26 -0000 1.3 *************** *** 3,11 **** # # Written by Hye-Shik Chang ! # $CJKCodecs: euc_jp.py,v 1.3 2004/01/17 11:26:10 perky Exp $ # ! from _codecs_euc_jp import codec ! import codecs class Codec(codecs.Codec): --- 3,12 ---- # # Written by Hye-Shik Chang ! # $CJKCodecs: euc_jp.py,v 1.8 2004/06/28 18:16:03 perky Exp $ # ! import _codecs_jp, codecs ! ! codec = _codecs_jp.getcodec('euc_jp') class Codec(codecs.Codec): *************** *** 31,33 **** def getregentry(): ! return (Codec().encode,Codec().decode,StreamReader,StreamWriter) --- 32,34 ---- def getregentry(): ! return (codec.encode, codec.decode, StreamReader, StreamWriter) Index: euc_kr.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/encodings/euc_kr.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** euc_kr.py 7 Jul 2004 20:54:47 -0000 1.2 --- euc_kr.py 18 Jul 2004 03:06:26 -0000 1.3 *************** *** 3,11 **** # # Written by Hye-Shik Chang ! # $CJKCodecs: euc_kr.py,v 1.3 2004/01/17 11:26:10 perky Exp $ # ! from _codecs_euc_kr import codec ! import codecs class Codec(codecs.Codec): --- 3,12 ---- # # Written by Hye-Shik Chang ! # $CJKCodecs: euc_kr.py,v 1.8 2004/06/28 18:16:03 perky Exp $ # ! import _codecs_kr, codecs ! ! codec = _codecs_kr.getcodec('euc_kr') class Codec(codecs.Codec): *************** *** 31,33 **** def getregentry(): ! return (Codec().encode,Codec().decode,StreamReader,StreamWriter) --- 32,34 ---- def getregentry(): ! return (codec.encode, codec.decode, StreamReader, StreamWriter) Index: gb18030.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/encodings/gb18030.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** gb18030.py 7 Jul 2004 20:54:47 -0000 1.2 --- gb18030.py 18 Jul 2004 03:06:26 -0000 1.3 *************** *** 3,11 **** # # Written by Hye-Shik Chang ! # $CJKCodecs: gb18030.py,v 1.3 2004/01/17 11:26:10 perky Exp $ # ! from _codecs_gb18030 import codec ! import codecs class Codec(codecs.Codec): --- 3,12 ---- # # Written by Hye-Shik Chang ! # $CJKCodecs: gb18030.py,v 1.8 2004/06/28 18:16:03 perky Exp $ # ! import _codecs_cn, codecs ! ! codec = _codecs_cn.getcodec('gb18030') class Codec(codecs.Codec): *************** *** 31,33 **** def getregentry(): ! return (Codec().encode,Codec().decode,StreamReader,StreamWriter) --- 32,34 ---- def getregentry(): ! return (codec.encode, codec.decode, StreamReader, StreamWriter) Index: gb2312.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/encodings/gb2312.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** gb2312.py 7 Jul 2004 20:54:47 -0000 1.2 --- gb2312.py 18 Jul 2004 03:06:26 -0000 1.3 *************** *** 3,11 **** # # Written by Hye-Shik Chang ! # $CJKCodecs: gb2312.py,v 1.3 2004/01/17 11:26:10 perky Exp $ # ! from _codecs_gb2312 import codec ! import codecs class Codec(codecs.Codec): --- 3,12 ---- # # Written by Hye-Shik Chang ! # $CJKCodecs: gb2312.py,v 1.8 2004/06/28 18:16:03 perky Exp $ # ! import _codecs_cn, codecs ! ! codec = _codecs_cn.getcodec('gb2312') class Codec(codecs.Codec): *************** *** 31,33 **** def getregentry(): ! return (Codec().encode,Codec().decode,StreamReader,StreamWriter) --- 32,34 ---- def getregentry(): ! return (codec.encode, codec.decode, StreamReader, StreamWriter) Index: gbk.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/encodings/gbk.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** gbk.py 7 Jul 2004 20:54:47 -0000 1.2 --- gbk.py 18 Jul 2004 03:06:26 -0000 1.3 *************** *** 3,11 **** # # Written by Hye-Shik Chang ! # $CJKCodecs: gbk.py,v 1.3 2004/01/17 11:26:10 perky Exp $ # ! from _codecs_gbk import codec ! import codecs class Codec(codecs.Codec): --- 3,12 ---- # # Written by Hye-Shik Chang ! # $CJKCodecs: gbk.py,v 1.8 2004/06/28 18:16:03 perky Exp $ # ! import _codecs_cn, codecs ! ! codec = _codecs_cn.getcodec('gbk') class Codec(codecs.Codec): *************** *** 31,33 **** def getregentry(): ! return (Codec().encode,Codec().decode,StreamReader,StreamWriter) --- 32,34 ---- def getregentry(): ! return (codec.encode, codec.decode, StreamReader, StreamWriter) Index: hz.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/encodings/hz.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** hz.py 7 Jul 2004 20:54:47 -0000 1.2 --- hz.py 18 Jul 2004 03:06:26 -0000 1.3 *************** *** 3,11 **** # # Written by Hye-Shik Chang ! # $CJKCodecs: hz.py,v 1.3 2004/01/17 11:26:10 perky Exp $ # ! from _codecs_hz import codec ! import codecs class Codec(codecs.Codec): --- 3,12 ---- # # Written by Hye-Shik Chang ! # $CJKCodecs: hz.py,v 1.8 2004/06/28 18:16:03 perky Exp $ # ! import _codecs_cn, codecs ! ! codec = _codecs_cn.getcodec('hz') class Codec(codecs.Codec): *************** *** 31,33 **** def getregentry(): ! return (Codec().encode,Codec().decode,StreamReader,StreamWriter) --- 32,34 ---- def getregentry(): ! return (codec.encode, codec.decode, StreamReader, StreamWriter) Index: iso2022_jp.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/encodings/iso2022_jp.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** iso2022_jp.py 7 Jul 2004 20:54:47 -0000 1.2 --- iso2022_jp.py 18 Jul 2004 03:06:26 -0000 1.3 *************** *** 1,11 **** # ! # iso2022_jp.py: Python Unicode Codec for ISO_2022_JP # # Written by Hye-Shik Chang ! # $CJKCodecs: iso2022_jp.py,v 1.3 2004/01/17 11:26:10 perky Exp $ # ! from _codecs_iso2022_jp import codec ! import codecs class Codec(codecs.Codec): --- 1,12 ---- # ! # iso2022_jp.py: Python Unicode Codec for ISO2022_JP # # Written by Hye-Shik Chang ! # $CJKCodecs: iso2022_jp.py,v 1.2 2004/06/28 18:16:03 perky Exp $ # ! import _codecs_iso2022, codecs ! ! codec = _codecs_iso2022.getcodec('iso2022_jp') class Codec(codecs.Codec): *************** *** 31,33 **** def getregentry(): ! return (Codec().encode,Codec().decode,StreamReader,StreamWriter) --- 32,34 ---- def getregentry(): ! return (codec.encode, codec.decode, StreamReader, StreamWriter) Index: iso2022_jp_1.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/encodings/iso2022_jp_1.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** iso2022_jp_1.py 7 Jul 2004 20:54:47 -0000 1.2 --- iso2022_jp_1.py 18 Jul 2004 03:06:26 -0000 1.3 *************** *** 1,11 **** # ! # iso2022_jp_1.py: Python Unicode Codec for ISO_2022_JP_1 # # Written by Hye-Shik Chang ! # $CJKCodecs: iso2022_jp_1.py,v 1.3 2004/01/17 11:26:10 perky Exp $ # ! from _codecs_iso2022_jp_1 import codec ! import codecs class Codec(codecs.Codec): --- 1,12 ---- # ! # iso2022_jp_1.py: Python Unicode Codec for ISO2022_JP_1 # # Written by Hye-Shik Chang ! # $CJKCodecs: iso2022_jp_1.py,v 1.2 2004/06/28 18:16:03 perky Exp $ # ! import _codecs_iso2022, codecs ! ! codec = _codecs_iso2022.getcodec('iso2022_jp_1') class Codec(codecs.Codec): *************** *** 31,33 **** def getregentry(): ! return (Codec().encode,Codec().decode,StreamReader,StreamWriter) --- 32,34 ---- def getregentry(): ! return (codec.encode, codec.decode, StreamReader, StreamWriter) Index: iso2022_jp_2.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/encodings/iso2022_jp_2.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** iso2022_jp_2.py 7 Jul 2004 20:54:47 -0000 1.2 --- iso2022_jp_2.py 18 Jul 2004 03:06:26 -0000 1.3 *************** *** 1,11 **** # ! # iso2022_jp_2.py: Python Unicode Codec for ISO_2022_JP_2 # # Written by Hye-Shik Chang ! # $CJKCodecs: iso2022_jp_2.py,v 1.3 2004/01/17 11:26:10 perky Exp $ # ! from _codecs_iso2022_jp_2 import codec ! import codecs class Codec(codecs.Codec): --- 1,12 ---- # ! # iso2022_jp_2.py: Python Unicode Codec for ISO2022_JP_2 # # Written by Hye-Shik Chang ! # $CJKCodecs: iso2022_jp_2.py,v 1.2 2004/06/28 18:16:03 perky Exp $ # ! import _codecs_iso2022, codecs ! ! codec = _codecs_iso2022.getcodec('iso2022_jp_2') class Codec(codecs.Codec): *************** *** 31,33 **** def getregentry(): ! return (Codec().encode,Codec().decode,StreamReader,StreamWriter) --- 32,34 ---- def getregentry(): ! return (codec.encode, codec.decode, StreamReader, StreamWriter) Index: iso2022_jp_3.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/encodings/iso2022_jp_3.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** iso2022_jp_3.py 7 Jul 2004 20:54:47 -0000 1.2 --- iso2022_jp_3.py 18 Jul 2004 03:06:26 -0000 1.3 *************** *** 1,11 **** # ! # iso2022_jp_3.py: Python Unicode Codec for ISO_2022_JP_3 # # Written by Hye-Shik Chang ! # $CJKCodecs: iso2022_jp_3.py,v 1.3 2004/01/17 11:26:10 perky Exp $ # ! from _codecs_iso2022_jp_3 import codec ! import codecs class Codec(codecs.Codec): --- 1,12 ---- # ! # iso2022_jp_3.py: Python Unicode Codec for ISO2022_JP_3 # # Written by Hye-Shik Chang ! # $CJKCodecs: iso2022_jp_3.py,v 1.2 2004/06/28 18:16:03 perky Exp $ # ! import _codecs_iso2022, codecs ! ! codec = _codecs_iso2022.getcodec('iso2022_jp_3') class Codec(codecs.Codec): *************** *** 31,33 **** def getregentry(): ! return (Codec().encode,Codec().decode,StreamReader,StreamWriter) --- 32,34 ---- def getregentry(): ! return (codec.encode, codec.decode, StreamReader, StreamWriter) Index: iso2022_jp_ext.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/encodings/iso2022_jp_ext.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** iso2022_jp_ext.py 7 Jul 2004 20:54:47 -0000 1.2 --- iso2022_jp_ext.py 18 Jul 2004 03:06:26 -0000 1.3 *************** *** 1,11 **** # ! # iso2022_jp_ext.py: Python Unicode Codec for ISO_2022_JP_EXT # # Written by Hye-Shik Chang ! # $CJKCodecs: iso2022_jp_ext.py,v 1.3 2004/01/17 11:26:10 perky Exp $ # ! from _codecs_iso2022_jp_ext import codec ! import codecs class Codec(codecs.Codec): --- 1,12 ---- # ! # iso2022_jp_ext.py: Python Unicode Codec for ISO2022_JP_EXT # # Written by Hye-Shik Chang ! # $CJKCodecs: iso2022_jp_ext.py,v 1.2 2004/06/28 18:16:03 perky Exp $ # ! import _codecs_iso2022, codecs ! ! codec = _codecs_iso2022.getcodec('iso2022_jp_ext') class Codec(codecs.Codec): *************** *** 31,33 **** def getregentry(): ! return (Codec().encode,Codec().decode,StreamReader,StreamWriter) --- 32,34 ---- def getregentry(): ! return (codec.encode, codec.decode, StreamReader, StreamWriter) Index: iso2022_kr.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/encodings/iso2022_kr.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** iso2022_kr.py 7 Jul 2004 20:54:47 -0000 1.2 --- iso2022_kr.py 18 Jul 2004 03:06:26 -0000 1.3 *************** *** 1,11 **** # ! # iso2022_kr.py: Python Unicode Codec for ISO_2022_KR # # Written by Hye-Shik Chang ! # $CJKCodecs: iso2022_kr.py,v 1.3 2004/01/17 11:26:10 perky Exp $ # ! from _codecs_iso2022_kr import codec ! import codecs class Codec(codecs.Codec): --- 1,12 ---- # ! # iso2022_kr.py: Python Unicode Codec for ISO2022_KR # # Written by Hye-Shik Chang ! # $CJKCodecs: iso2022_kr.py,v 1.2 2004/06/28 18:16:03 perky Exp $ # ! import _codecs_iso2022, codecs ! ! codec = _codecs_iso2022.getcodec('iso2022_kr') class Codec(codecs.Codec): *************** *** 31,33 **** def getregentry(): ! return (Codec().encode,Codec().decode,StreamReader,StreamWriter) --- 32,34 ---- def getregentry(): ! return (codec.encode, codec.decode, StreamReader, StreamWriter) Index: johab.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/encodings/johab.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** johab.py 7 Jul 2004 20:54:47 -0000 1.2 --- johab.py 18 Jul 2004 03:06:26 -0000 1.3 *************** *** 3,11 **** # # Written by Hye-Shik Chang ! # $CJKCodecs: johab.py,v 1.3 2004/01/17 11:26:10 perky Exp $ # ! from _codecs_johab import codec ! import codecs class Codec(codecs.Codec): --- 3,12 ---- # # Written by Hye-Shik Chang ! # $CJKCodecs: johab.py,v 1.8 2004/06/28 18:16:03 perky Exp $ # ! import _codecs_kr, codecs ! ! codec = _codecs_kr.getcodec('johab') class Codec(codecs.Codec): *************** *** 31,33 **** def getregentry(): ! return (Codec().encode,Codec().decode,StreamReader,StreamWriter) --- 32,34 ---- def getregentry(): ! return (codec.encode, codec.decode, StreamReader, StreamWriter) Index: shift_jis.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/encodings/shift_jis.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** shift_jis.py 7 Jul 2004 20:54:47 -0000 1.2 --- shift_jis.py 18 Jul 2004 03:06:26 -0000 1.3 *************** *** 3,11 **** # # Written by Hye-Shik Chang ! # $CJKCodecs: shift_jis.py,v 1.3 2004/01/17 11:26:10 perky Exp $ # ! from _codecs_shift_jis import codec ! import codecs class Codec(codecs.Codec): --- 3,12 ---- # # Written by Hye-Shik Chang ! # $CJKCodecs: shift_jis.py,v 1.8 2004/06/28 18:16:03 perky Exp $ # ! import _codecs_jp, codecs ! ! codec = _codecs_jp.getcodec('shift_jis') class Codec(codecs.Codec): *************** *** 31,33 **** def getregentry(): ! return (Codec().encode,Codec().decode,StreamReader,StreamWriter) --- 32,34 ---- def getregentry(): ! return (codec.encode, codec.decode, StreamReader, StreamWriter) Index: shift_jisx0213.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/encodings/shift_jisx0213.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** shift_jisx0213.py 7 Jul 2004 20:54:47 -0000 1.2 --- shift_jisx0213.py 18 Jul 2004 03:06:26 -0000 1.3 *************** *** 3,11 **** # # Written by Hye-Shik Chang ! # $CJKCodecs: shift_jisx0213.py,v 1.3 2004/01/17 11:26:10 perky Exp $ # ! from _codecs_shift_jisx0213 import codec ! import codecs class Codec(codecs.Codec): --- 3,12 ---- # # Written by Hye-Shik Chang ! # $CJKCodecs: shift_jisx0213.py,v 1.8 2004/06/28 18:16:03 perky Exp $ # ! import _codecs_jp, codecs ! ! codec = _codecs_jp.getcodec('shift_jisx0213') class Codec(codecs.Codec): *************** *** 31,33 **** def getregentry(): ! return (Codec().encode,Codec().decode,StreamReader,StreamWriter) --- 32,34 ---- def getregentry(): ! return (codec.encode, codec.decode, StreamReader, StreamWriter) From tim_one at users.sourceforge.net Sun Jul 18 05:48:49 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 05:48:53 2004 Subject: [Python-checkins] python/dist/src/PCbuild pythoncore.vcproj, 1.12, 1.13 Message-ID: Update of /cvsroot/python/python/dist/src/PCbuild In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14739/PCbuild Modified Files: pythoncore.vcproj Log Message: Teach VC 7.1 about the new cjkcodecs structure. This still doesn't compile on Windows, because of non-standard code in cjkcodes.h, but it's *almost* there. Index: pythoncore.vcproj =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/pythoncore.vcproj,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** pythoncore.vcproj 8 Jul 2004 07:11:33 -0000 1.12 --- pythoncore.vcproj 18 Jul 2004 03:48:47 -0000 1.13 *************** *** 153,160 **** ! ! ! ! ! ! ! ! ! ! ! ! - - - - - - - - - - - - - - - - - - --- 196,202 ---- *************** *** 230,257 **** - - - - - - - - - - - - - - - - - - - - --- 259,262 ---- From tim_one at users.sourceforge.net Sun Jul 18 06:20:17 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 06:20:21 2004 Subject: [Python-checkins] python/dist/src/Modules/cjkcodecs cjkcodecs.h, 1.1, 1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Modules/cjkcodecs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17982/Modules/cjkcodecs Modified Files: cjkcodecs.h Log Message: Changed the "predefinitions" of codec_list and mapping_list from static to extern. It's not legal C to say static whatever[]; because the size isn't given. Presumably this is a gcc extension. Index: cjkcodecs.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/cjkcodecs/cjkcodecs.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** cjkcodecs.h 18 Jul 2004 03:06:27 -0000 1.1 --- cjkcodecs.h 18 Jul 2004 04:20:15 -0000 1.2 *************** *** 58,63 **** }; ! static const MultibyteCodec codec_list[]; ! static const struct dbcs_map mapping_list[]; #define CODEC_INIT(encoding) \ --- 58,63 ---- }; ! extern const MultibyteCodec codec_list[]; ! extern const struct dbcs_map mapping_list[]; #define CODEC_INIT(encoding) \ From tim_one at users.sourceforge.net Sun Jul 18 06:26:12 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 06:26:14 2004 Subject: [Python-checkins] python/dist/src/Modules/cjkcodecs cjkcodecs.h, 1.2, 1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Modules/cjkcodecs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19323/Modules/cjkcodecs Modified Files: cjkcodecs.h Log Message: Added a comment explaining the extern ugliness. Index: cjkcodecs.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/cjkcodecs/cjkcodecs.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** cjkcodecs.h 18 Jul 2004 04:20:15 -0000 1.2 --- cjkcodecs.h 18 Jul 2004 04:26:10 -0000 1.3 *************** *** 58,61 **** --- 58,67 ---- }; + /* There are really static, and (re)declared so later by the expansions + * of the BEGIN_MAPPINGS_LIST and BEGIN_CODECS_LIST macros, but it's + * not legal C to declare a static array of unknown size. It would be + * better if the code were rearranged so as to not require declaration + * of these names before the macros define them. + */ extern const MultibyteCodec codec_list[]; extern const struct dbcs_map mapping_list[]; From tim_one at users.sourceforge.net Sun Jul 18 06:30:39 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 06:30:42 2004 Subject: [Python-checkins] python/dist/src/PC config.c,1.46,1.47 Message-ID: Update of /cvsroot/python/python/dist/src/PC In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19764/PC Modified Files: config.c Log Message: More cjkcodecs recovery: Python at least compiles on Window again. Index: config.c =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/config.c,v retrieving revision 1.46 retrieving revision 1.47 diff -C2 -d -r1.46 -r1.47 *** config.c 2 Jun 2004 18:58:35 -0000 1.46 --- config.c 18 Jul 2004 04:30:37 -0000 1.47 *************** *** 62,85 **** extern void init_codecs_mapdata_zh_CN(void); extern void init_codecs_mapdata_zh_TW(void); - extern void init_codecs_shift_jis(void); - extern void init_codecs_cp932(void); - extern void init_codecs_euc_jp(void); - extern void init_codecs_iso2022_jp(void); - extern void init_codecs_iso2022_jp_1(void); - extern void init_codecs_iso2022_jp_2(void); - extern void init_codecs_iso2022_jp_3(void); - extern void init_codecs_iso2022_jp_ext(void); - extern void init_codecs_shift_jisx0213(void); - extern void init_codecs_euc_jisx0213(void); - extern void init_codecs_euc_kr(void); - extern void init_codecs_cp949(void); - extern void init_codecs_johab(void); - extern void init_codecs_iso2022_kr(void); - extern void init_codecs_gb2312(void); - extern void init_codecs_gbk(void); - extern void init_codecs_gb18030(void); - extern void init_codecs_hz(void); - extern void init_codecs_big5(void); - extern void init_codecs_cp950(void); /* tools/freeze/makeconfig.py marker for additional "extern" */ --- 62,65 ---- *************** *** 154,177 **** {"_codecs_mapdata_zh_CN", init_codecs_mapdata_zh_CN}, {"_codecs_mapdata_zh_TW", init_codecs_mapdata_zh_TW}, - {"_codecs_shift_jis", init_codecs_shift_jis}, - {"_codecs_cp932", init_codecs_cp932}, - {"_codecs_euc_jp", init_codecs_euc_jp}, - {"_codecs_iso2022_jp", init_codecs_iso2022_jp}, - {"_codecs_iso2022_jp_1", init_codecs_iso2022_jp_1}, - {"_codecs_iso2022_jp_2", init_codecs_iso2022_jp_2}, - {"_codecs_iso2022_jp_3", init_codecs_iso2022_jp_3}, - {"_codecs_iso2022_jp_ext", init_codecs_iso2022_jp_ext}, - {"_codecs_shift_jisx0213", init_codecs_shift_jisx0213}, - {"_codecs_euc_jisx0213", init_codecs_euc_jisx0213}, - {"_codecs_euc_kr", init_codecs_euc_kr}, - {"_codecs_cp949", init_codecs_cp949}, - {"_codecs_johab", init_codecs_johab}, - {"_codecs_iso2022_kr", init_codecs_iso2022_kr}, - {"_codecs_gb2312", init_codecs_gb2312}, - {"_codecs_gbk", init_codecs_gbk}, - {"_codecs_gb18030", init_codecs_gb18030}, - {"_codecs_hz", init_codecs_hz}, - {"_codecs_big5", init_codecs_big5}, - {"_codecs_cp950", init_codecs_cp950}, /* tools/freeze/makeconfig.py marker for additional "_inittab" entries */ --- 134,137 ---- From tim_one at users.sourceforge.net Sun Jul 18 06:34:35 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 06:34:39 2004 Subject: [Python-checkins] python/dist/src/Modules/cjkcodecs _codecs_iso2022.c, 1.1, 1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Modules/cjkcodecs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20101/Modules/cjkcodecs Modified Files: _codecs_iso2022.c Log Message: Repair MS compiler warning about signed-vs-unsigned mismatch. The plane and width clearly don't need to be signed. Index: _codecs_iso2022.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/cjkcodecs/_codecs_iso2022.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** _codecs_iso2022.c 18 Jul 2004 03:06:27 -0000 1.1 --- _codecs_iso2022.c 18 Jul 2004 04:34:33 -0000 1.2 *************** *** 109,114 **** struct iso2022_designation { unsigned char mark; ! char plane; ! char width; iso2022_init_func initializer; iso2022_decode_func decoder; --- 109,114 ---- struct iso2022_designation { unsigned char mark; ! unsigned char plane; ! unsigned char width; iso2022_init_func initializer; iso2022_decode_func decoder; From tim_one at users.sourceforge.net Sun Jul 18 07:06:33 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 07:06:35 2004 Subject: [Python-checkins] python/dist/src/PC config.c,1.47,1.48 Message-ID: Update of /cvsroot/python/python/dist/src/PC In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23589/PC Modified Files: config.c Log Message: Woo hoo! All the encoding tests pass on Windows (& I downloaded the 14 input files needed to run all of them). Index: config.c =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/config.c,v retrieving revision 1.47 retrieving revision 1.48 diff -C2 -d -r1.47 -r1.48 *** config.c 18 Jul 2004 04:30:37 -0000 1.47 --- config.c 18 Jul 2004 05:06:31 -0000 1.48 *************** *** 58,65 **** extern void init_multibytecodec(void); ! extern void init_codecs_mapdata_ja_JP(void); ! extern void init_codecs_mapdata_ko_KR(void); ! extern void init_codecs_mapdata_zh_CN(void); ! extern void init_codecs_mapdata_zh_TW(void); /* tools/freeze/makeconfig.py marker for additional "extern" */ --- 58,66 ---- extern void init_multibytecodec(void); ! extern void init_codecs_cn(void); ! extern void init_codecs_hk(void); ! extern void init_codecs_jp(void); ! extern void init_codecs_kr(void); ! extern void init_codecs_tw(void); /* tools/freeze/makeconfig.py marker for additional "extern" */ *************** *** 130,137 **** /* CJK codecs */ {"_multibytecodec", init_multibytecodec}, ! {"_codecs_mapdata_ja_JP", init_codecs_mapdata_ja_JP}, ! {"_codecs_mapdata_ko_KR", init_codecs_mapdata_ko_KR}, ! {"_codecs_mapdata_zh_CN", init_codecs_mapdata_zh_CN}, ! {"_codecs_mapdata_zh_TW", init_codecs_mapdata_zh_TW}, /* tools/freeze/makeconfig.py marker for additional "_inittab" entries */ --- 131,139 ---- /* CJK codecs */ {"_multibytecodec", init_multibytecodec}, ! {"_codecs_cn", init_codecs_cn}, ! {"_codecs_hk", init_codecs_hk}, ! {"_codecs_jp", init_codecs_jp}, ! {"_codecs_kr", init_codecs_kr}, ! {"_codecs_tw", init_codecs_tw}, /* tools/freeze/makeconfig.py marker for additional "_inittab" entries */ From tim_one at users.sourceforge.net Sun Jul 18 07:31:33 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 07:31:36 2004 Subject: [Python-checkins] python/dist/src/Tools/scripts texi2html.py, 1.16, 1.17 Message-ID: Update of /cvsroot/python/python/dist/src/Tools/scripts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26240 Modified Files: texi2html.py Log Message: WTF is with this script? It contained illegal syntax and illegal indentation -- it could never have been run, under any version of Python. Index: texi2html.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/scripts/texi2html.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** texi2html.py 12 Feb 2004 17:35:32 -0000 1.16 --- texi2html.py 18 Jul 2004 05:31:31 -0000 1.17 *************** *** 807,811 **** # print '*** Recursive footnote -- expect weirdness' id = len(self.footnotes) + 1 ! self.write(self.FN_SOURCE_PATTERN % {'id': repr(id)) self.startsaving() --- 807,811 ---- # print '*** Recursive footnote -- expect weirdness' id = len(self.footnotes) + 1 ! self.write(self.FN_SOURCE_PATTERN % {'id': repr(id)}) self.startsaving() *************** *** 1858,1862 **** self.dumped = {} if self.nodelist: ! (nodename,None,None,None,None) = self.nodelist[0] self.topnode = nodename --- 1858,1862 ---- self.dumped = {} if self.nodelist: ! nodename, dummy, dummy, dummy, dummy = self.nodelist[0] self.topnode = nodename *************** *** 2057,2070 **** dirname = sys.argv[2] parser.setdirname(dirname) ! parser.setincludedir(os.path.dirname(file)) htmlhelp = HTMLHelp(helpbase, dirname) parser.sethtmlhelp(htmlhelp) ! try: ! fp = open(file, 'r') ! except IOError, msg: ! print file, ':', msg ! sys.exit(1) parser.parse(fp) --- 2057,2070 ---- dirname = sys.argv[2] parser.setdirname(dirname) ! parser.setincludedir(os.path.dirname(file)) htmlhelp = HTMLHelp(helpbase, dirname) parser.sethtmlhelp(htmlhelp) ! try: ! fp = open(file, 'r') ! except IOError, msg: ! print file, ':', msg ! sys.exit(1) parser.parse(fp) From tim_one at users.sourceforge.net Sun Jul 18 07:56:10 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 07:56:14 2004 Subject: [Python-checkins] python/dist/src/Demo/newmetaclasses Eiffel.py, 1.5, 1.6 Enum.py, 1.2, 1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Demo/newmetaclasses In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28702/Demo/newmetaclasses Modified Files: Eiffel.py Enum.py Log Message: Whitespace normalization. Ran reindent.py over the entire source tree. Index: Eiffel.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/newmetaclasses/Eiffel.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Eiffel.py 12 Jul 2002 15:42:10 -0000 1.5 --- Eiffel.py 18 Jul 2004 05:56:07 -0000 1.6 *************** *** 49,53 **** return method ! make_eiffel_method = staticmethod(make_eiffel_method) --- 49,53 ---- return method ! make_eiffel_method = staticmethod(make_eiffel_method) *************** *** 67,71 **** self._pre = pre self._post = post ! self.__name__ = func.__name__ self.__doc__ = func.__doc__ --- 67,71 ---- self._pre = pre self._post = post ! self.__name__ = func.__name__ self.__doc__ = func.__doc__ *************** *** 142,144 **** _test(EiffelMetaClass1) _test(EiffelMetaClass2) - --- 142,143 ---- Index: Enum.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/newmetaclasses/Enum.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Enum.py 12 Feb 2004 17:35:02 -0000 1.2 --- Enum.py 18 Jul 2004 05:56:07 -0000 1.3 *************** *** 176,178 **** _test() _test2() - --- 176,177 ---- From tim_one at users.sourceforge.net Sun Jul 18 07:56:27 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 07:56:31 2004 Subject: [Python-checkins] python/dist/src/Demo/rpc T.py, 1.4, 1.5 mountclient.py, 1.8, 1.9 nfsclient.py, 1.10, 1.11 rnusersclient.py, 1.4, 1.5 rpc.py, 1.12, 1.13 xdr.py, 1.11, 1.12 Message-ID: Update of /cvsroot/python/python/dist/src/Demo/rpc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28702/Demo/rpc Modified Files: T.py mountclient.py nfsclient.py rnusersclient.py rpc.py xdr.py Log Message: Whitespace normalization. Ran reindent.py over the entire source tree. Index: T.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/rpc/T.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** T.py 12 Feb 2004 17:35:02 -0000 1.4 --- T.py 18 Jul 2004 05:56:08 -0000 1.5 *************** *** 5,22 **** def TSTART(): ! global t0, t1 ! u, s, cu, cs = os.times() ! t0 = u+cu, s+cs, time.time() def TSTOP(*label): ! global t0, t1 ! u, s, cu, cs = os.times() ! t1 = u+cu, s+cs, time.time() ! tt = [] ! for i in range(3): ! tt.append(t1[i] - t0[i]) ! [u, s, r] = tt ! msg = '' ! for x in label: msg = msg + (x + ' ') ! msg = msg + '%r user, %r sys, %r real\n' % (u, s, r) ! sys.stderr.write(msg) --- 5,22 ---- def TSTART(): ! global t0, t1 ! u, s, cu, cs = os.times() ! t0 = u+cu, s+cs, time.time() def TSTOP(*label): ! global t0, t1 ! u, s, cu, cs = os.times() ! t1 = u+cu, s+cs, time.time() ! tt = [] ! for i in range(3): ! tt.append(t1[i] - t0[i]) ! [u, s, r] = tt ! msg = '' ! for x in label: msg = msg + (x + ' ') ! msg = msg + '%r user, %r sys, %r real\n' % (u, s, r) ! sys.stderr.write(msg) Index: mountclient.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/rpc/mountclient.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** mountclient.py 11 Oct 2001 19:23:28 -0000 1.8 --- mountclient.py 18 Jul 2004 05:56:08 -0000 1.9 *************** *** 27,32 **** class MountPacker(Packer): ! def pack_fhandle(self, fhandle): ! self.pack_fopaque(FHSIZE, fhandle) --- 27,32 ---- class MountPacker(Packer): ! def pack_fhandle(self, fhandle): ! self.pack_fopaque(FHSIZE, fhandle) *************** *** 40,72 **** class MountUnpacker(Unpacker): ! def unpack_fhandle(self): ! return self.unpack_fopaque(FHSIZE) ! def unpack_fhstatus(self): ! status = self.unpack_uint() ! if status == 0: ! fh = self.unpack_fhandle() ! else: ! fh = None ! return status, fh ! def unpack_mountlist(self): ! return self.unpack_list(self.unpack_mountstruct) ! def unpack_mountstruct(self): ! hostname = self.unpack_string() ! directory = self.unpack_string() ! return (hostname, directory) ! def unpack_exportlist(self): ! return self.unpack_list(self.unpack_exportstruct) ! def unpack_exportstruct(self): ! filesys = self.unpack_string() ! groups = self.unpack_groups() ! return (filesys, groups) ! def unpack_groups(self): ! return self.unpack_list(self.unpack_string) --- 40,72 ---- class MountUnpacker(Unpacker): ! def unpack_fhandle(self): ! return self.unpack_fopaque(FHSIZE) ! def unpack_fhstatus(self): ! status = self.unpack_uint() ! if status == 0: ! fh = self.unpack_fhandle() ! else: ! fh = None ! return status, fh ! def unpack_mountlist(self): ! return self.unpack_list(self.unpack_mountstruct) ! def unpack_mountstruct(self): ! hostname = self.unpack_string() ! directory = self.unpack_string() ! return (hostname, directory) ! def unpack_exportlist(self): ! return self.unpack_list(self.unpack_exportstruct) ! def unpack_exportstruct(self): ! filesys = self.unpack_string() ! groups = self.unpack_groups() ! return (filesys, groups) ! def unpack_groups(self): ! return self.unpack_list(self.unpack_string) *************** *** 76,157 **** class PartialMountClient: ! # This method is called by Client.__init__ to initialize ! # self.packer and self.unpacker ! def addpackers(self): ! self.packer = MountPacker() ! self.unpacker = MountUnpacker('') ! # This method is called by Client.__init__ to bind the socket ! # to a particular network interface and port. We use the ! # default network interface, but if we're running as root, ! # we want to bind to a reserved port ! def bindsocket(self): ! import os ! try: ! uid = os.getuid() ! except AttributeError: ! uid = 1 ! if uid == 0: ! port = rpc.bindresvport(self.sock, '') ! # 'port' is not used ! else: ! self.sock.bind(('', 0)) ! # This function is called to cough up a suitable ! # authentication object for a call to procedure 'proc'. ! def mkcred(self): ! if self.cred == None: ! self.cred = rpc.AUTH_UNIX, rpc.make_auth_unix_default() ! return self.cred ! # The methods Mnt, Dump etc. each implement one Remote ! # Procedure Call. This is done by calling self.make_call() ! # with as arguments: ! # ! # - the procedure number ! # - the arguments (or None) ! # - the "packer" function for the arguments (or None) ! # - the "unpacker" function for the return value (or None) ! # ! # The packer and unpacker function, if not None, *must* be ! # methods of self.packer and self.unpacker, respectively. ! # A value of None means that there are no arguments or is no ! # return value, respectively. ! # ! # The return value from make_call() is the return value from ! # the remote procedure call, as unpacked by the "unpacker" ! # function, or None if the unpacker function is None. ! # ! # (Even if you expect a result of None, you should still ! # return the return value from make_call(), since this may be ! # needed by a broadcasting version of the class.) ! # ! # If the call fails, make_call() raises an exception ! # (this includes time-outs and invalid results). ! # ! # Note that (at least with the UDP protocol) there is no ! # guarantee that a call is executed at most once. When you do ! # get a reply, you know it has been executed at least once; ! # when you don't get a reply, you know nothing. ! def Mnt(self, directory): ! return self.make_call(1, directory, \ ! self.packer.pack_string, \ ! self.unpacker.unpack_fhstatus) ! def Dump(self): ! return self.make_call(2, None, \ ! None, self.unpacker.unpack_mountlist) ! def Umnt(self, directory): ! return self.make_call(3, directory, \ ! self.packer.pack_string, None) ! def Umntall(self): ! return self.make_call(4, None, None, None) ! def Export(self): ! return self.make_call(5, None, \ ! None, self.unpacker.unpack_exportlist) --- 76,157 ---- class PartialMountClient: ! # This method is called by Client.__init__ to initialize ! # self.packer and self.unpacker ! def addpackers(self): ! self.packer = MountPacker() ! self.unpacker = MountUnpacker('') ! # This method is called by Client.__init__ to bind the socket ! # to a particular network interface and port. We use the ! # default network interface, but if we're running as root, ! # we want to bind to a reserved port ! def bindsocket(self): ! import os ! try: ! uid = os.getuid() ! except AttributeError: ! uid = 1 ! if uid == 0: ! port = rpc.bindresvport(self.sock, '') ! # 'port' is not used ! else: ! self.sock.bind(('', 0)) ! # This function is called to cough up a suitable ! # authentication object for a call to procedure 'proc'. ! def mkcred(self): ! if self.cred == None: ! self.cred = rpc.AUTH_UNIX, rpc.make_auth_unix_default() ! return self.cred ! # The methods Mnt, Dump etc. each implement one Remote ! # Procedure Call. This is done by calling self.make_call() ! # with as arguments: ! # ! # - the procedure number ! # - the arguments (or None) ! # - the "packer" function for the arguments (or None) ! # - the "unpacker" function for the return value (or None) ! # ! # The packer and unpacker function, if not None, *must* be ! # methods of self.packer and self.unpacker, respectively. ! # A value of None means that there are no arguments or is no ! # return value, respectively. ! # ! # The return value from make_call() is the return value from ! # the remote procedure call, as unpacked by the "unpacker" ! # function, or None if the unpacker function is None. ! # ! # (Even if you expect a result of None, you should still ! # return the return value from make_call(), since this may be ! # needed by a broadcasting version of the class.) ! # ! # If the call fails, make_call() raises an exception ! # (this includes time-outs and invalid results). ! # ! # Note that (at least with the UDP protocol) there is no ! # guarantee that a call is executed at most once. When you do ! # get a reply, you know it has been executed at least once; ! # when you don't get a reply, you know nothing. ! def Mnt(self, directory): ! return self.make_call(1, directory, \ ! self.packer.pack_string, \ ! self.unpacker.unpack_fhstatus) ! def Dump(self): ! return self.make_call(2, None, \ ! None, self.unpacker.unpack_mountlist) ! def Umnt(self, directory): ! return self.make_call(3, directory, \ ! self.packer.pack_string, None) ! def Umntall(self): ! return self.make_call(4, None, None, None) ! def Export(self): ! return self.make_call(5, None, \ ! None, self.unpacker.unpack_exportlist) *************** *** 163,174 **** class TCPMountClient(PartialMountClient, TCPClient): ! def __init__(self, host): ! TCPClient.__init__(self, host, MOUNTPROG, MOUNTVERS) class UDPMountClient(PartialMountClient, UDPClient): ! def __init__(self, host): ! UDPClient.__init__(self, host, MOUNTPROG, MOUNTVERS) --- 163,174 ---- class TCPMountClient(PartialMountClient, TCPClient): ! def __init__(self, host): ! TCPClient.__init__(self, host, MOUNTPROG, MOUNTVERS) class UDPMountClient(PartialMountClient, UDPClient): ! def __init__(self, host): ! UDPClient.__init__(self, host, MOUNTPROG, MOUNTVERS) *************** *** 180,202 **** def test(): ! import sys ! if sys.argv[1:] and sys.argv[1] == '-t': ! C = TCPMountClient ! del sys.argv[1] ! elif sys.argv[1:] and sys.argv[1] == '-u': ! C = UDPMountClient ! del sys.argv[1] ! else: ! C = UDPMountClient ! if sys.argv[1:]: host = sys.argv[1] ! else: host = '' ! mcl = C(host) ! list = mcl.Export() ! for item in list: ! print item ! try: ! mcl.Mnt(item[0]) ! except: ! print 'Sorry' ! continue ! mcl.Umnt(item[0]) --- 180,202 ---- def test(): ! import sys ! if sys.argv[1:] and sys.argv[1] == '-t': ! C = TCPMountClient ! del sys.argv[1] ! elif sys.argv[1:] and sys.argv[1] == '-u': ! C = UDPMountClient ! del sys.argv[1] ! else: ! C = UDPMountClient ! if sys.argv[1:]: host = sys.argv[1] ! else: host = '' ! mcl = C(host) ! list = mcl.Export() ! for item in list: ! print item ! try: ! mcl.Mnt(item[0]) ! except: ! print 'Sorry' ! continue ! mcl.Umnt(item[0]) Index: nfsclient.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/rpc/nfsclient.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** nfsclient.py 8 Oct 1998 15:23:50 -0000 1.10 --- nfsclient.py 18 Jul 2004 05:56:08 -0000 1.11 *************** *** 29,201 **** class NFSPacker(MountPacker): ! def pack_sattrargs(self, sa): ! file, attributes = sa ! self.pack_fhandle(file) ! self.pack_sattr(attributes) ! def pack_sattr(self, sa): ! mode, uid, gid, size, atime, mtime = sa ! self.pack_uint(mode) ! self.pack_uint(uid) ! self.pack_uint(gid) ! self.pack_uint(size) ! self.pack_timeval(atime) ! self.pack_timeval(mtime) ! def pack_diropargs(self, da): ! dir, name = da ! self.pack_fhandle(dir) ! self.pack_string(name) ! def pack_readdirargs(self, ra): ! dir, cookie, count = ra ! self.pack_fhandle(dir) ! self.pack_uint(cookie) ! self.pack_uint(count) ! def pack_timeval(self, tv): ! secs, usecs = tv ! self.pack_uint(secs) ! self.pack_uint(usecs) class NFSUnpacker(MountUnpacker): ! def unpack_readdirres(self): ! status = self.unpack_enum() ! if status == NFS_OK: ! entries = self.unpack_list(self.unpack_entry) ! eof = self.unpack_bool() ! rest = (entries, eof) ! else: ! rest = None ! return (status, rest) ! def unpack_entry(self): ! fileid = self.unpack_uint() ! name = self.unpack_string() ! cookie = self.unpack_uint() ! return (fileid, name, cookie) ! def unpack_diropres(self): ! status = self.unpack_enum() ! if status == NFS_OK: ! fh = self.unpack_fhandle() ! fa = self.unpack_fattr() ! rest = (fh, fa) ! else: ! rest = None ! return (status, rest) ! def unpack_attrstat(self): ! status = self.unpack_enum() ! if status == NFS_OK: ! attributes = self.unpack_fattr() ! else: ! attributes = None ! return status, attributes ! def unpack_fattr(self): ! type = self.unpack_enum() ! mode = self.unpack_uint() ! nlink = self.unpack_uint() ! uid = self.unpack_uint() ! gid = self.unpack_uint() ! size = self.unpack_uint() ! blocksize = self.unpack_uint() ! rdev = self.unpack_uint() ! blocks = self.unpack_uint() ! fsid = self.unpack_uint() ! fileid = self.unpack_uint() ! atime = self.unpack_timeval() ! mtime = self.unpack_timeval() ! ctime = self.unpack_timeval() ! return (type, mode, nlink, uid, gid, size, blocksize, \ ! rdev, blocks, fsid, fileid, atime, mtime, ctime) ! def unpack_timeval(self): ! secs = self.unpack_uint() ! usecs = self.unpack_uint() ! return (secs, usecs) class NFSClient(UDPClient): ! def __init__(self, host): ! UDPClient.__init__(self, host, NFS_PROGRAM, NFS_VERSION) ! def addpackers(self): ! self.packer = NFSPacker() ! self.unpacker = NFSUnpacker('') ! def mkcred(self): ! if self.cred == None: ! self.cred = rpc.AUTH_UNIX, rpc.make_auth_unix_default() ! return self.cred ! def Getattr(self, fh): ! return self.make_call(1, fh, \ ! self.packer.pack_fhandle, \ ! self.unpacker.unpack_attrstat) ! def Setattr(self, sa): ! return self.make_call(2, sa, \ ! self.packer.pack_sattrargs, \ ! self.unpacker.unpack_attrstat) ! # Root() is obsolete ! def Lookup(self, da): ! return self.make_call(4, da, \ ! self.packer.pack_diropargs, \ ! self.unpacker.unpack_diropres) ! # ... ! def Readdir(self, ra): ! return self.make_call(16, ra, \ ! self.packer.pack_readdirargs, \ ! self.unpacker.unpack_readdirres) - # Shorthand to get the entire contents of a directory - def Listdir(self, dir): - list = [] - ra = (dir, 0, 2000) - while 1: - (status, rest) = self.Readdir(ra) - if status <> NFS_OK: - break - entries, eof = rest - last_cookie = None - for fileid, name, cookie in entries: - list.append((fileid, name)) - last_cookie = cookie - if eof or last_cookie == None: - break - ra = (ra[0], last_cookie, ra[2]) - return list - def test(): ! import sys ! if sys.argv[1:]: host = sys.argv[1] ! else: host = '' ! if sys.argv[2:]: filesys = sys.argv[2] ! else: filesys = None ! from mountclient import UDPMountClient, TCPMountClient ! mcl = TCPMountClient(host) ! if filesys == None: ! list = mcl.Export() ! for item in list: ! print item ! return ! sf = mcl.Mnt(filesys) ! print sf ! fh = sf[1] ! if fh: ! ncl = NFSClient(host) ! as = ncl.Getattr(fh) ! print as ! list = ncl.Listdir(fh) ! for item in list: print item ! mcl.Umnt(filesys) --- 29,201 ---- class NFSPacker(MountPacker): ! def pack_sattrargs(self, sa): ! file, attributes = sa ! self.pack_fhandle(file) ! self.pack_sattr(attributes) ! def pack_sattr(self, sa): ! mode, uid, gid, size, atime, mtime = sa ! self.pack_uint(mode) ! self.pack_uint(uid) ! self.pack_uint(gid) ! self.pack_uint(size) ! self.pack_timeval(atime) ! self.pack_timeval(mtime) ! def pack_diropargs(self, da): ! dir, name = da ! self.pack_fhandle(dir) ! self.pack_string(name) ! def pack_readdirargs(self, ra): ! dir, cookie, count = ra ! self.pack_fhandle(dir) ! self.pack_uint(cookie) ! self.pack_uint(count) ! def pack_timeval(self, tv): ! secs, usecs = tv ! self.pack_uint(secs) ! self.pack_uint(usecs) class NFSUnpacker(MountUnpacker): ! def unpack_readdirres(self): ! status = self.unpack_enum() ! if status == NFS_OK: ! entries = self.unpack_list(self.unpack_entry) ! eof = self.unpack_bool() ! rest = (entries, eof) ! else: ! rest = None ! return (status, rest) ! def unpack_entry(self): ! fileid = self.unpack_uint() ! name = self.unpack_string() ! cookie = self.unpack_uint() ! return (fileid, name, cookie) ! def unpack_diropres(self): ! status = self.unpack_enum() ! if status == NFS_OK: ! fh = self.unpack_fhandle() ! fa = self.unpack_fattr() ! rest = (fh, fa) ! else: ! rest = None ! return (status, rest) ! def unpack_attrstat(self): ! status = self.unpack_enum() ! if status == NFS_OK: ! attributes = self.unpack_fattr() ! else: ! attributes = None ! return status, attributes ! def unpack_fattr(self): ! type = self.unpack_enum() ! mode = self.unpack_uint() ! nlink = self.unpack_uint() ! uid = self.unpack_uint() ! gid = self.unpack_uint() ! size = self.unpack_uint() ! blocksize = self.unpack_uint() ! rdev = self.unpack_uint() ! blocks = self.unpack_uint() ! fsid = self.unpack_uint() ! fileid = self.unpack_uint() ! atime = self.unpack_timeval() ! mtime = self.unpack_timeval() ! ctime = self.unpack_timeval() ! return (type, mode, nlink, uid, gid, size, blocksize, \ ! rdev, blocks, fsid, fileid, atime, mtime, ctime) ! def unpack_timeval(self): ! secs = self.unpack_uint() ! usecs = self.unpack_uint() ! return (secs, usecs) class NFSClient(UDPClient): ! def __init__(self, host): ! UDPClient.__init__(self, host, NFS_PROGRAM, NFS_VERSION) ! def addpackers(self): ! self.packer = NFSPacker() ! self.unpacker = NFSUnpacker('') ! def mkcred(self): ! if self.cred == None: ! self.cred = rpc.AUTH_UNIX, rpc.make_auth_unix_default() ! return self.cred ! def Getattr(self, fh): ! return self.make_call(1, fh, \ ! self.packer.pack_fhandle, \ ! self.unpacker.unpack_attrstat) ! def Setattr(self, sa): ! return self.make_call(2, sa, \ ! self.packer.pack_sattrargs, \ ! self.unpacker.unpack_attrstat) ! # Root() is obsolete ! def Lookup(self, da): ! return self.make_call(4, da, \ ! self.packer.pack_diropargs, \ ! self.unpacker.unpack_diropres) ! # ... ! def Readdir(self, ra): ! return self.make_call(16, ra, \ ! self.packer.pack_readdirargs, \ ! self.unpacker.unpack_readdirres) ! ! # Shorthand to get the entire contents of a directory ! def Listdir(self, dir): ! list = [] ! ra = (dir, 0, 2000) ! while 1: ! (status, rest) = self.Readdir(ra) ! if status <> NFS_OK: ! break ! entries, eof = rest ! last_cookie = None ! for fileid, name, cookie in entries: ! list.append((fileid, name)) ! last_cookie = cookie ! if eof or last_cookie == None: ! break ! ra = (ra[0], last_cookie, ra[2]) ! return list def test(): ! import sys ! if sys.argv[1:]: host = sys.argv[1] ! else: host = '' ! if sys.argv[2:]: filesys = sys.argv[2] ! else: filesys = None ! from mountclient import UDPMountClient, TCPMountClient ! mcl = TCPMountClient(host) ! if filesys == None: ! list = mcl.Export() ! for item in list: ! print item ! return ! sf = mcl.Mnt(filesys) ! print sf ! fh = sf[1] ! if fh: ! ncl = NFSClient(host) ! as = ncl.Getattr(fh) ! print as ! list = ncl.Listdir(fh) ! for item in list: print item ! mcl.Umnt(filesys) Index: rnusersclient.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/rpc/rnusersclient.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** rnusersclient.py 12 Feb 2004 17:35:02 -0000 1.4 --- rnusersclient.py 18 Jul 2004 05:56:08 -0000 1.5 *************** *** 6,98 **** class RnusersPacker(Packer): ! def pack_utmp(self, ui): ! ut_line, ut_name, ut_host, ut_time = utmp ! self.pack_string(ut_line) ! self.pack_string(ut_name) ! self.pack_string(ut_host) ! self.pack_int(ut_time) ! def pack_utmpidle(self, ui): ! ui_itmp, ui_idle = ui ! self.pack_utmp(ui_utmp) ! self.pack_uint(ui_idle) ! def pack_utmpidlearr(self, list): ! self.pack_array(list, self.pack_itmpidle) class RnusersUnpacker(Unpacker): ! def unpack_utmp(self): ! ut_line = self.unpack_string() ! ut_name = self.unpack_string() ! ut_host = self.unpack_string() ! ut_time = self.unpack_int() ! return ut_line, ut_name, ut_host, ut_time ! def unpack_utmpidle(self): ! ui_utmp = self.unpack_utmp() ! ui_idle = self.unpack_uint() ! return ui_utmp, ui_idle ! def unpack_utmpidlearr(self): ! return self.unpack_array(self.unpack_utmpidle) class PartialRnusersClient: ! def addpackers(self): ! self.packer = RnusersPacker() ! self.unpacker = RnusersUnpacker('') ! def Num(self): ! return self.make_call(1, None, None, self.unpacker.unpack_int) ! def Names(self): ! return self.make_call(2, None, \ ! None, self.unpacker.unpack_utmpidlearr) ! def Allnames(self): ! return self.make_call(3, None, \ ! None, self.unpacker.unpack_utmpidlearr) class RnusersClient(PartialRnusersClient, UDPClient): ! def __init__(self, host): ! UDPClient.__init__(self, host, 100002, 2) class BroadcastRnusersClient(PartialRnusersClient, BroadcastUDPClient): ! def __init__(self, bcastaddr): ! BroadcastUDPClient.__init__(self, bcastaddr, 100002, 2) def test(): ! import sys ! if not sys.argv[1:]: ! testbcast() ! return ! else: ! host = sys.argv[1] ! c = RnusersClient(host) ! list = c.Names() ! for (line, name, host, time), idle in list: ! line = strip0(line) ! name = strip0(name) ! host = strip0(host) ! print "%r %r %r %s %s" % (name, host, line, time, idle) def testbcast(): ! c = BroadcastRnusersClient('') ! def listit(list, fromaddr): ! host, port = fromaddr ! print host + '\t:', ! for (line, name, host, time), idle in list: ! print strip0(name), ! print ! c.set_reply_handler(listit) ! all = c.Names() ! print 'Total Count:', len(all) def strip0(s): ! while s and s[-1] == '\0': s = s[:-1] ! return s test() --- 6,98 ---- class RnusersPacker(Packer): ! def pack_utmp(self, ui): ! ut_line, ut_name, ut_host, ut_time = utmp ! self.pack_string(ut_line) ! self.pack_string(ut_name) ! self.pack_string(ut_host) ! self.pack_int(ut_time) ! def pack_utmpidle(self, ui): ! ui_itmp, ui_idle = ui ! self.pack_utmp(ui_utmp) ! self.pack_uint(ui_idle) ! def pack_utmpidlearr(self, list): ! self.pack_array(list, self.pack_itmpidle) class RnusersUnpacker(Unpacker): ! def unpack_utmp(self): ! ut_line = self.unpack_string() ! ut_name = self.unpack_string() ! ut_host = self.unpack_string() ! ut_time = self.unpack_int() ! return ut_line, ut_name, ut_host, ut_time ! def unpack_utmpidle(self): ! ui_utmp = self.unpack_utmp() ! ui_idle = self.unpack_uint() ! return ui_utmp, ui_idle ! def unpack_utmpidlearr(self): ! return self.unpack_array(self.unpack_utmpidle) class PartialRnusersClient: ! def addpackers(self): ! self.packer = RnusersPacker() ! self.unpacker = RnusersUnpacker('') ! def Num(self): ! return self.make_call(1, None, None, self.unpacker.unpack_int) ! def Names(self): ! return self.make_call(2, None, \ ! None, self.unpacker.unpack_utmpidlearr) ! def Allnames(self): ! return self.make_call(3, None, \ ! None, self.unpacker.unpack_utmpidlearr) class RnusersClient(PartialRnusersClient, UDPClient): ! def __init__(self, host): ! UDPClient.__init__(self, host, 100002, 2) class BroadcastRnusersClient(PartialRnusersClient, BroadcastUDPClient): ! def __init__(self, bcastaddr): ! BroadcastUDPClient.__init__(self, bcastaddr, 100002, 2) def test(): ! import sys ! if not sys.argv[1:]: ! testbcast() ! return ! else: ! host = sys.argv[1] ! c = RnusersClient(host) ! list = c.Names() ! for (line, name, host, time), idle in list: ! line = strip0(line) ! name = strip0(name) ! host = strip0(host) ! print "%r %r %r %s %s" % (name, host, line, time, idle) def testbcast(): ! c = BroadcastRnusersClient('') ! def listit(list, fromaddr): ! host, port = fromaddr ! print host + '\t:', ! for (line, name, host, time), idle in list: ! print strip0(name), ! print ! c.set_reply_handler(listit) ! all = c.Names() ! print 'Total Count:', len(all) def strip0(s): ! while s and s[-1] == '\0': s = s[:-1] ! return s test() From tim_one at users.sourceforge.net Sun Jul 18 07:56:27 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 07:56:32 2004 Subject: [Python-checkins] python/dist/src/Demo/scripts eqfix.py, 1.8, 1.9 fact.py, 1.6, 1.7 ftpstats.py, 1.5, 1.6 lpwatch.py, 1.8, 1.9 makedir.py, 1.4, 1.5 markov.py, 1.4, 1.5 mboxconvert.py, 1.5, 1.6 mkrcs.py, 1.5, 1.6 morse.py, 1.1, 1.2 mpzpi.py, 1.5, 1.6 newslist.py, 1.11, 1.12 pp.py, 1.6, 1.7 primes.py, 1.4, 1.5 script.py, 1.2, 1.3 update.py, 1.2, 1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Demo/scripts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28702/Demo/scripts Modified Files: eqfix.py fact.py ftpstats.py lpwatch.py makedir.py markov.py mboxconvert.py mkrcs.py morse.py mpzpi.py newslist.py pp.py primes.py script.py update.py Log Message: Whitespace normalization. Ran reindent.py over the entire source tree. Index: eqfix.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/scripts/eqfix.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** eqfix.py 12 Feb 2004 17:35:02 -0000 1.8 --- eqfix.py 18 Jul 2004 05:56:08 -0000 1.9 *************** *** 2,8 **** # Fix Python source files to use the new equality test operator, i.e., ! # if x = y: ... # is changed to ! # if x == y: ... # The script correctly tokenizes the Python program to reliably # distinguish between assignments and equality tests. --- 2,8 ---- # Fix Python source files to use the new equality test operator, i.e., ! # if x = y: ... # is changed to ! # if x == y: ... # The script correctly tokenizes the Python program to reliably # distinguish between assignments and equality tests. *************** *** 40,163 **** def main(): ! bad = 0 ! if not sys.argv[1:]: # No arguments ! err('usage: ' + sys.argv[0] + ' file-or-directory ...\n') ! sys.exit(2) ! for arg in sys.argv[1:]: ! if os.path.isdir(arg): ! if recursedown(arg): bad = 1 ! elif os.path.islink(arg): ! err(arg + ': will not process symbolic links\n') ! bad = 1 ! else: ! if fix(arg): bad = 1 ! sys.exit(bad) ispythonprog = regex.compile('^[a-zA-Z0-9_]+\.py$') def ispython(name): ! return ispythonprog.match(name) >= 0 def recursedown(dirname): ! dbg('recursedown(%r)\n' % (dirname,)) ! bad = 0 ! try: ! names = os.listdir(dirname) ! except os.error, msg: ! err('%s: cannot list directory: %r\n' % (dirname, msg)) ! return 1 ! names.sort() ! subdirs = [] ! for name in names: ! if name in (os.curdir, os.pardir): continue ! fullname = os.path.join(dirname, name) ! if os.path.islink(fullname): pass ! elif os.path.isdir(fullname): ! subdirs.append(fullname) ! elif ispython(name): ! if fix(fullname): bad = 1 ! for fullname in subdirs: ! if recursedown(fullname): bad = 1 ! return bad def fix(filename): ! ## dbg('fix(%r)\n' % (dirname,)) ! try: ! f = open(filename, 'r') ! except IOError, msg: ! err('%s: cannot open: %r\n' % (filename, msg)) ! return 1 ! head, tail = os.path.split(filename) ! tempname = os.path.join(head, '@' + tail) ! g = None ! # If we find a match, we rewind the file and start over but ! # now copy everything to a temp file. ! lineno = 0 ! while 1: ! line = f.readline() ! if not line: break ! lineno = lineno + 1 ! if g is None and '\0' in line: ! # Check for binary files ! err(filename + ': contains null bytes; not fixed\n') ! f.close() ! return 1 ! if lineno == 1 and g is None and line[:2] == '#!': ! # Check for non-Python scripts ! words = string.split(line[2:]) ! if words and regex.search('[pP]ython', words[0]) < 0: ! msg = filename + ': ' + words[0] ! msg = msg + ' script; not fixed\n' ! err(msg) ! f.close() ! return 1 ! while line[-2:] == '\\\n': ! nextline = f.readline() ! if not nextline: break ! line = line + nextline ! lineno = lineno + 1 ! newline = fixline(line) ! if newline != line: ! if g is None: ! try: ! g = open(tempname, 'w') ! except IOError, msg: ! f.close() ! err('%s: cannot create: %r\n' % (tempname, msg)) ! return 1 ! f.seek(0) ! lineno = 0 ! rep(filename + ':\n') ! continue # restart from the beginning ! rep(repr(lineno) + '\n') ! rep('< ' + line) ! rep('> ' + newline) ! if g is not None: ! g.write(newline) ! # End of file ! f.close() ! if not g: return 0 # No changes ! ! # Finishing touch -- move files ! # First copy the file's mode to the temp file ! try: ! statbuf = os.stat(filename) ! os.chmod(tempname, statbuf[ST_MODE] & 07777) ! except os.error, msg: ! err('%s: warning: chmod failed (%r)\n' % (tempname, msg)) ! # Then make a backup of the original file as filename~ ! try: ! os.rename(filename, filename + '~') ! except os.error, msg: ! err('%s: warning: backup failed (%r)\n' % (filename, msg)) ! # Now move the temp file to the original file ! try: ! os.rename(tempname, filename) ! except os.error, msg: ! err('%s: rename failed (%r)\n' % (filename, msg)) ! return 1 ! # Return succes ! return 0 --- 40,163 ---- def main(): ! bad = 0 ! if not sys.argv[1:]: # No arguments ! err('usage: ' + sys.argv[0] + ' file-or-directory ...\n') ! sys.exit(2) ! for arg in sys.argv[1:]: ! if os.path.isdir(arg): ! if recursedown(arg): bad = 1 ! elif os.path.islink(arg): ! err(arg + ': will not process symbolic links\n') ! bad = 1 ! else: ! if fix(arg): bad = 1 ! sys.exit(bad) ispythonprog = regex.compile('^[a-zA-Z0-9_]+\.py$') def ispython(name): ! return ispythonprog.match(name) >= 0 def recursedown(dirname): ! dbg('recursedown(%r)\n' % (dirname,)) ! bad = 0 ! try: ! names = os.listdir(dirname) ! except os.error, msg: ! err('%s: cannot list directory: %r\n' % (dirname, msg)) ! return 1 ! names.sort() ! subdirs = [] ! for name in names: ! if name in (os.curdir, os.pardir): continue ! fullname = os.path.join(dirname, name) ! if os.path.islink(fullname): pass ! elif os.path.isdir(fullname): ! subdirs.append(fullname) ! elif ispython(name): ! if fix(fullname): bad = 1 ! for fullname in subdirs: ! if recursedown(fullname): bad = 1 ! return bad def fix(filename): ! ## dbg('fix(%r)\n' % (dirname,)) ! try: ! f = open(filename, 'r') ! except IOError, msg: ! err('%s: cannot open: %r\n' % (filename, msg)) ! return 1 ! head, tail = os.path.split(filename) ! tempname = os.path.join(head, '@' + tail) ! g = None ! # If we find a match, we rewind the file and start over but ! # now copy everything to a temp file. ! lineno = 0 ! while 1: ! line = f.readline() ! if not line: break ! lineno = lineno + 1 ! if g is None and '\0' in line: ! # Check for binary files ! err(filename + ': contains null bytes; not fixed\n') ! f.close() ! return 1 ! if lineno == 1 and g is None and line[:2] == '#!': ! # Check for non-Python scripts ! words = string.split(line[2:]) ! if words and regex.search('[pP]ython', words[0]) < 0: ! msg = filename + ': ' + words[0] ! msg = msg + ' script; not fixed\n' ! err(msg) ! f.close() ! return 1 ! while line[-2:] == '\\\n': ! nextline = f.readline() ! if not nextline: break ! line = line + nextline ! lineno = lineno + 1 ! newline = fixline(line) ! if newline != line: ! if g is None: ! try: ! g = open(tempname, 'w') ! except IOError, msg: ! f.close() ! err('%s: cannot create: %r\n' % (tempname, msg)) ! return 1 ! f.seek(0) ! lineno = 0 ! rep(filename + ':\n') ! continue # restart from the beginning ! rep(repr(lineno) + '\n') ! rep('< ' + line) ! rep('> ' + newline) ! if g is not None: ! g.write(newline) ! # End of file ! f.close() ! if not g: return 0 # No changes ! # Finishing touch -- move files ! ! # First copy the file's mode to the temp file ! try: ! statbuf = os.stat(filename) ! os.chmod(tempname, statbuf[ST_MODE] & 07777) ! except os.error, msg: ! err('%s: warning: chmod failed (%r)\n' % (tempname, msg)) ! # Then make a backup of the original file as filename~ ! try: ! os.rename(filename, filename + '~') ! except os.error, msg: ! err('%s: warning: backup failed (%r)\n' % (filename, msg)) ! # Now move the temp file to the original file ! try: ! os.rename(tempname, filename) ! except os.error, msg: ! err('%s: rename failed (%r)\n' % (filename, msg)) ! return 1 ! # Return succes ! return 0 *************** *** 165,197 **** match = {'if':':', 'elif':':', 'while':':', 'return':'\n', \ ! '(':')', '[':']', '{':'}', '`':'`'} def fixline(line): ! # Quick check for easy case ! if '=' not in line: return line ! ! i, n = 0, len(line) ! stack = [] ! while i < n: ! j = tokenprog.match(line, i) ! if j < 0: ! # A bad token; forget about the rest of this line ! print '(Syntax error:)' ! print line, ! return line ! a, b = tokenprog.regs[3] # Location of the token proper ! token = line[a:b] ! i = i+j ! if stack and token == stack[-1]: ! del stack[-1] ! elif match.has_key(token): ! stack.append(match[token]) ! elif token == '=' and stack: ! line = line[:a] + '==' + line[b:] ! i, n = a + len('=='), len(line) ! elif token == '==' and not stack: ! print '(Warning: \'==\' at top level:)' ! print line, ! return line --- 165,197 ---- match = {'if':':', 'elif':':', 'while':':', 'return':'\n', \ ! '(':')', '[':']', '{':'}', '`':'`'} def fixline(line): ! # Quick check for easy case ! if '=' not in line: return line ! ! i, n = 0, len(line) ! stack = [] ! while i < n: ! j = tokenprog.match(line, i) ! if j < 0: ! # A bad token; forget about the rest of this line ! print '(Syntax error:)' ! print line, ! return line ! a, b = tokenprog.regs[3] # Location of the token proper ! token = line[a:b] ! i = i+j ! if stack and token == stack[-1]: ! del stack[-1] ! elif match.has_key(token): ! stack.append(match[token]) ! elif token == '=' and stack: ! line = line[:a] + '==' + line[b:] ! i, n = a + len('=='), len(line) ! elif token == '==' and not stack: ! print '(Warning: \'==\' at top level:)' ! print line, ! return line Index: fact.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/scripts/fact.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** fact.py 27 Nov 1996 19:46:48 -0000 1.6 --- fact.py 18 Jul 2004 05:56:08 -0000 1.7 *************** *** 9,48 **** from math import sqrt ! error = 'fact.error' # exception def fact(n): ! if n < 1: raise error # fact() argument should be >= 1 ! if n == 1: return [] # special case ! res = [] ! # Treat even factors special, so we can use i = i+2 later ! while n%2 == 0: ! res.append(2) ! n = n/2 ! # Try odd numbers up to sqrt(n) ! limit = sqrt(float(n+1)) ! i = 3 ! while i <= limit: ! if n%i == 0: ! res.append(i) ! n = n/i ! limit = sqrt(n+1) ! else: ! i = i+2 ! if n != 1: ! res.append(n) ! return res def main(): ! if len(sys.argv) > 1: ! for arg in sys.argv[1:]: ! n = eval(arg) ! print n, fact(n) ! else: ! try: ! while 1: ! n = input() ! print n, fact(n) ! except EOFError: ! pass main() --- 9,48 ---- from math import sqrt ! error = 'fact.error' # exception def fact(n): ! if n < 1: raise error # fact() argument should be >= 1 ! if n == 1: return [] # special case ! res = [] ! # Treat even factors special, so we can use i = i+2 later ! while n%2 == 0: ! res.append(2) ! n = n/2 ! # Try odd numbers up to sqrt(n) ! limit = sqrt(float(n+1)) ! i = 3 ! while i <= limit: ! if n%i == 0: ! res.append(i) ! n = n/i ! limit = sqrt(n+1) ! else: ! i = i+2 ! if n != 1: ! res.append(n) ! return res def main(): ! if len(sys.argv) > 1: ! for arg in sys.argv[1:]: ! n = eval(arg) ! print n, fact(n) ! else: ! try: ! while 1: ! n = input() ! print n, fact(n) ! except EOFError: ! pass main() Index: ftpstats.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/scripts/ftpstats.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ftpstats.py 17 Jul 2004 14:44:17 -0000 1.5 --- ftpstats.py 18 Jul 2004 05:56:08 -0000 1.6 *************** *** 22,144 **** def main(): ! maxitems = 25 ! search = None ! try: ! opts, args = getopt.getopt(sys.argv[1:], 'm:s:') ! except getopt.error, msg: ! print msg ! print 'usage: ftpstats [-m maxitems] [file]' ! sys.exit(2) ! for o, a in opts: ! if o == '-m': ! maxitems = string.atoi(a) ! if o == '-s': ! search = a ! file = '/usr/adm/ftpd' ! if args: file = args[0] ! if file == '-': ! f = sys.stdin ! else: ! try: ! f = open(file, 'r') ! except IOError, msg: ! print file, ':', msg ! sys.exit(1) ! bydate = {} ! bytime = {} ! byfile = {} ! bydir = {} ! byhost = {} ! byuser = {} ! bytype = {} ! lineno = 0 ! try: ! while 1: ! line = f.readline() ! if not line: break ! lineno = lineno + 1 ! if search and string.find(line, search) < 0: ! continue ! if prog.match(line) < 0: ! print 'Bad line', lineno, ':', repr(line) ! continue ! items = prog.group(1, 2, 3, 4, 5, 6) ! (logtime, loguser, loghost, logfile, logbytes, ! logxxx2) = items ! ## print logtime ! ## print '-->', loguser ! ## print '--> -->', loghost ! ## print '--> --> -->', logfile ! ## print '--> --> --> -->', logbytes ! ## print '--> --> --> --> -->', logxxx2 ! ## for i in logtime, loghost, logbytes, logxxx2: ! ## if '!' in i: print '???', i ! add(bydate, logtime[-4:] + ' ' + logtime[:6], items) ! add(bytime, logtime[7:9] + ':00-59', items) ! direction, logfile = logfile[0], logfile[1:] ! # The real path probably starts at the last //... ! while 1: ! i = string.find(logfile, '//') ! if i < 0: break ! logfile = logfile[i+1:] ! add(byfile, logfile + ' ' + direction, items) ! logdir = os.path.dirname(logfile) ! ## logdir = os.path.normpath(logdir) + '/.' ! while 1: ! add(bydir, logdir + ' ' + direction, items) ! dirhead = os.path.dirname(logdir) ! if dirhead == logdir: break ! logdir = dirhead ! add(byhost, loghost, items) ! add(byuser, loguser, items) ! add(bytype, direction, items) ! except KeyboardInterrupt: ! print 'Interrupted at line', lineno ! show(bytype, 'by transfer direction', maxitems) ! show(bydir, 'by directory', maxitems) ! show(byfile, 'by file', maxitems) ! show(byhost, 'by host', maxitems) ! show(byuser, 'by user', maxitems) ! showbar(bydate, 'by date') ! showbar(bytime, 'by time of day') def showbar(dict, title): ! n = len(title) ! print '='*((70-n)/2), title, '='*((71-n)/2) ! list = [] ! keys = dict.keys() ! keys.sort() ! for key in keys: ! n = len(str(key)) ! list.append((len(dict[key]), key)) ! maxkeylength = 0 ! maxcount = 0 ! for count, key in list: ! maxkeylength = max(maxkeylength, len(key)) ! maxcount = max(maxcount, count) ! maxbarlength = 72 - maxkeylength - 7 ! for count, key in list: ! barlength = int(round(maxbarlength*float(count)/maxcount)) ! bar = '*'*barlength ! print '%5d %-*s %s' % (count, maxkeylength, key, bar) def show(dict, title, maxitems): ! if len(dict) > maxitems: ! title = title + ' (first %d)'%maxitems ! n = len(title) ! print '='*((70-n)/2), title, '='*((71-n)/2) ! list = [] ! keys = dict.keys() ! for key in keys: ! list.append((-len(dict[key]), key)) ! list.sort() ! for count, key in list[:maxitems]: ! print '%5d %s' % (-count, key) def add(dict, key, item): ! if dict.has_key(key): ! dict[key].append(item) ! else: ! dict[key] = [item] main() --- 22,144 ---- def main(): ! maxitems = 25 ! search = None ! try: ! opts, args = getopt.getopt(sys.argv[1:], 'm:s:') ! except getopt.error, msg: ! print msg ! print 'usage: ftpstats [-m maxitems] [file]' ! sys.exit(2) ! for o, a in opts: ! if o == '-m': ! maxitems = string.atoi(a) ! if o == '-s': ! search = a ! file = '/usr/adm/ftpd' ! if args: file = args[0] ! if file == '-': ! f = sys.stdin ! else: ! try: ! f = open(file, 'r') ! except IOError, msg: ! print file, ':', msg ! sys.exit(1) ! bydate = {} ! bytime = {} ! byfile = {} ! bydir = {} ! byhost = {} ! byuser = {} ! bytype = {} ! lineno = 0 ! try: ! while 1: ! line = f.readline() ! if not line: break ! lineno = lineno + 1 ! if search and string.find(line, search) < 0: ! continue ! if prog.match(line) < 0: ! print 'Bad line', lineno, ':', repr(line) ! continue ! items = prog.group(1, 2, 3, 4, 5, 6) ! (logtime, loguser, loghost, logfile, logbytes, ! logxxx2) = items ! ## print logtime ! ## print '-->', loguser ! ## print '--> -->', loghost ! ## print '--> --> -->', logfile ! ## print '--> --> --> -->', logbytes ! ## print '--> --> --> --> -->', logxxx2 ! ## for i in logtime, loghost, logbytes, logxxx2: ! ## if '!' in i: print '???', i ! add(bydate, logtime[-4:] + ' ' + logtime[:6], items) ! add(bytime, logtime[7:9] + ':00-59', items) ! direction, logfile = logfile[0], logfile[1:] ! # The real path probably starts at the last //... ! while 1: ! i = string.find(logfile, '//') ! if i < 0: break ! logfile = logfile[i+1:] ! add(byfile, logfile + ' ' + direction, items) ! logdir = os.path.dirname(logfile) ! ## logdir = os.path.normpath(logdir) + '/.' ! while 1: ! add(bydir, logdir + ' ' + direction, items) ! dirhead = os.path.dirname(logdir) ! if dirhead == logdir: break ! logdir = dirhead ! add(byhost, loghost, items) ! add(byuser, loguser, items) ! add(bytype, direction, items) ! except KeyboardInterrupt: ! print 'Interrupted at line', lineno ! show(bytype, 'by transfer direction', maxitems) ! show(bydir, 'by directory', maxitems) ! show(byfile, 'by file', maxitems) ! show(byhost, 'by host', maxitems) ! show(byuser, 'by user', maxitems) ! showbar(bydate, 'by date') ! showbar(bytime, 'by time of day') def showbar(dict, title): ! n = len(title) ! print '='*((70-n)/2), title, '='*((71-n)/2) ! list = [] ! keys = dict.keys() ! keys.sort() ! for key in keys: ! n = len(str(key)) ! list.append((len(dict[key]), key)) ! maxkeylength = 0 ! maxcount = 0 ! for count, key in list: ! maxkeylength = max(maxkeylength, len(key)) ! maxcount = max(maxcount, count) ! maxbarlength = 72 - maxkeylength - 7 ! for count, key in list: ! barlength = int(round(maxbarlength*float(count)/maxcount)) ! bar = '*'*barlength ! print '%5d %-*s %s' % (count, maxkeylength, key, bar) def show(dict, title, maxitems): ! if len(dict) > maxitems: ! title = title + ' (first %d)'%maxitems ! n = len(title) ! print '='*((70-n)/2), title, '='*((71-n)/2) ! list = [] ! keys = dict.keys() ! for key in keys: ! list.append((-len(dict[key]), key)) ! list.sort() ! for count, key in list[:maxitems]: ! print '%5d %s' % (-count, key) def add(dict, key, item): ! if dict.has_key(key): ! dict[key].append(item) ! else: ! dict[key] = [item] main() From tim_one at users.sourceforge.net Sun Jul 18 07:56:27 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 07:56:34 2004 Subject: [Python-checkins] python/dist/src/Demo/pdist FSProxy.py, 1.1, 1.2 client.py, 1.5, 1.6 cmdfw.py, 1.3, 1.4 cmptree.py, 1.3, 1.4 cvslib.py, 1.13, 1.14 cvslock.py, 1.2, 1.3 mac.py, 1.1, 1.2 rcsclient.py, 1.6, 1.7 rcslib.py, 1.10, 1.11 rcvs.py, 1.22, 1.23 rrcs.py, 1.7, 1.8 security.py, 1.4, 1.5 server.py, 1.5, 1.6 sumtree.py, 1.1, 1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Demo/pdist In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28702/Demo/pdist Modified Files: FSProxy.py client.py cmdfw.py cmptree.py cvslib.py cvslock.py mac.py rcsclient.py rcslib.py rcvs.py rrcs.py security.py server.py sumtree.py Log Message: Whitespace normalization. Ran reindent.py over the entire source tree. Index: FSProxy.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/pdist/FSProxy.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** FSProxy.py 10 Apr 1995 11:40:46 -0000 1.1 --- FSProxy.py 18 Jul 2004 05:56:08 -0000 1.2 *************** *** 25,33 **** if os.name == 'mac': ! import macfs ! maxnamelen = 31 else: ! macfs = None ! maxnamelen = 255 skipnames = (os.curdir, os.pardir) --- 25,33 ---- if os.name == 'mac': ! import macfs ! maxnamelen = 31 else: ! macfs = None ! maxnamelen = 255 skipnames = (os.curdir, os.pardir) *************** *** 35,322 **** class FSProxyLocal: ! ! def __init__(self): ! self._dirstack = [] ! self._ignore = ['*.pyc'] + self._readignore() ! ! def _close(self): ! while self._dirstack: ! self.back() ! ! def _readignore(self): ! file = self._hide('ignore') ! try: ! f = open(file) ! except IOError: ! file = self._hide('synctree.ignorefiles') ! try: ! f = open(file) ! except IOError: ! return [] ! ignore = [] ! while 1: ! line = f.readline() ! if not line: break ! if line[-1] == '\n': line = line[:-1] ! ignore.append(line) ! f.close() ! return ignore ! ! def _hidden(self, name): ! if os.name == 'mac': ! return name[0] == '(' and name[-1] == ')' ! else: ! return name[0] == '.' ! ! def _hide(self, name): ! if os.name == 'mac': ! return '(%s)' % name ! else: ! return '.%s' % name ! ! def visible(self, name): ! if len(name) > maxnamelen: return 0 ! if name[-1] == '~': return 0 ! if name in skipnames: return 0 ! if self._hidden(name): return 0 ! head, tail = os.path.split(name) ! if head or not tail: return 0 ! if macfs: ! if os.path.exists(name) and not os.path.isdir(name): ! try: ! fs = macfs.FSSpec(name) ! c, t = fs.GetCreatorType() ! if t != 'TEXT': return 0 ! except macfs.error, msg: ! print "***", name, msg ! return 0 ! else: ! if os.path.islink(name): return 0 ! if '\0' in open(name, 'rb').read(512): return 0 ! for ign in self._ignore: ! if fnmatch.fnmatch(name, ign): return 0 ! return 1 ! ! def check(self, name): ! if not self.visible(name): ! raise os.error, "protected name %s" % repr(name) ! ! def checkfile(self, name): ! self.check(name) ! if not os.path.isfile(name): ! raise os.error, "not a plain file %s" % repr(name) ! ! def pwd(self): ! return os.getcwd() ! ! def cd(self, name): ! self.check(name) ! save = os.getcwd(), self._ignore ! os.chdir(name) ! self._dirstack.append(save) ! self._ignore = self._ignore + self._readignore() ! ! def back(self): ! if not self._dirstack: ! raise os.error, "empty directory stack" ! dir, ignore = self._dirstack[-1] ! os.chdir(dir) ! del self._dirstack[-1] ! self._ignore = ignore ! ! def _filter(self, files, pat = None): ! if pat: ! def keep(name, pat = pat): ! return fnmatch.fnmatch(name, pat) ! files = filter(keep, files) ! files = filter(self.visible, files) ! files.sort() ! return files ! ! def list(self, pat = None): ! files = os.listdir(os.curdir) ! return self._filter(files, pat) ! ! def listfiles(self, pat = None): ! files = os.listdir(os.curdir) ! files = filter(os.path.isfile, files) ! return self._filter(files, pat) ! ! def listsubdirs(self, pat = None): ! files = os.listdir(os.curdir) ! files = filter(os.path.isdir, files) ! return self._filter(files, pat) ! ! def exists(self, name): ! return self.visible(name) and os.path.exists(name) ! ! def isdir(self, name): ! return self.visible(name) and os.path.isdir(name) ! ! def islink(self, name): ! return self.visible(name) and os.path.islink(name) ! ! def isfile(self, name): ! return self.visible(name) and os.path.isfile(name) ! ! def sum(self, name): ! self.checkfile(name) ! BUFFERSIZE = 1024*8 ! f = open(name) ! sum = md5.new() ! while 1: ! buffer = f.read(BUFFERSIZE) ! if not buffer: ! break ! sum.update(buffer) ! return sum.digest() ! ! def size(self, name): ! self.checkfile(name) ! return os.stat(name)[ST_SIZE] ! ! def mtime(self, name): ! self.checkfile(name) ! return time.localtime(os.stat(name)[ST_MTIME]) ! ! def stat(self, name): ! self.checkfile(name) ! size = os.stat(name)[ST_SIZE] ! mtime = time.localtime(os.stat(name)[ST_MTIME]) ! return size, mtime ! ! def info(self, name): ! sum = self.sum(name) ! size = os.stat(name)[ST_SIZE] ! mtime = time.localtime(os.stat(name)[ST_MTIME]) ! return sum, size, mtime ! ! def _list(self, function, list): ! if list is None: ! list = self.listfiles() ! res = [] ! for name in list: ! try: ! res.append((name, function(name))) ! except (os.error, IOError): ! res.append((name, None)) ! return res ! ! def sumlist(self, list = None): ! return self._list(self.sum, list) ! ! def statlist(self, list = None): ! return self._list(self.stat, list) ! ! def mtimelist(self, list = None): ! return self._list(self.mtime, list) ! ! def sizelist(self, list = None): ! return self._list(self.size, list) ! ! def infolist(self, list = None): ! return self._list(self.info, list) ! ! def _dict(self, function, list): ! if list is None: ! list = self.listfiles() ! dict = {} ! for name in list: ! try: ! dict[name] = function(name) ! except (os.error, IOError): ! pass ! return dict ! ! def sumdict(self, list = None): ! return self.dict(self.sum, list) ! ! def sizedict(self, list = None): ! return self.dict(self.size, list) ! ! def mtimedict(self, list = None): ! return self.dict(self.mtime, list) ! ! def statdict(self, list = None): ! return self.dict(self.stat, list) ! ! def infodict(self, list = None): ! return self._dict(self.info, list) ! ! def read(self, name, offset = 0, length = -1): ! self.checkfile(name) ! f = open(name) ! f.seek(offset) ! if length == 0: ! data = '' ! elif length < 0: ! data = f.read() ! else: ! data = f.read(length) ! f.close() ! return data ! ! def create(self, name): ! self.check(name) ! if os.path.exists(name): ! self.checkfile(name) ! bname = name + '~' ! try: ! os.unlink(bname) ! except os.error: ! pass ! os.rename(name, bname) ! f = open(name, 'w') ! f.close() ! ! def write(self, name, data, offset = 0): ! self.checkfile(name) ! f = open(name, 'r+') ! f.seek(offset) ! f.write(data) ! f.close() ! ! def mkdir(self, name): ! self.check(name) ! os.mkdir(name, 0777) ! ! def rmdir(self, name): ! self.check(name) ! os.rmdir(name) class FSProxyServer(FSProxyLocal, server.Server): ! ! def __init__(self, address, verbose = server.VERBOSE): ! FSProxyLocal.__init__(self) ! server.Server.__init__(self, address, verbose) ! ! def _close(self): ! server.Server._close(self) ! FSProxyLocal._close(self) ! ! def _serve(self): ! server.Server._serve(self) ! # Retreat into start directory ! while self._dirstack: self.back() class FSProxyClient(client.Client): ! ! def __init__(self, address, verbose = client.VERBOSE): ! client.Client.__init__(self, address, verbose) def test(): ! import string ! import sys ! if sys.argv[1:]: ! port = string.atoi(sys.argv[1]) ! else: ! port = 4127 ! proxy = FSProxyServer(('', port)) ! proxy._serverloop() if __name__ == '__main__': ! test() --- 35,322 ---- class FSProxyLocal: ! ! def __init__(self): ! self._dirstack = [] ! self._ignore = ['*.pyc'] + self._readignore() ! ! def _close(self): ! while self._dirstack: ! self.back() ! ! def _readignore(self): ! file = self._hide('ignore') ! try: ! f = open(file) ! except IOError: ! file = self._hide('synctree.ignorefiles') ! try: ! f = open(file) ! except IOError: ! return [] ! ignore = [] ! while 1: ! line = f.readline() ! if not line: break ! if line[-1] == '\n': line = line[:-1] ! ignore.append(line) ! f.close() ! return ignore ! ! def _hidden(self, name): ! if os.name == 'mac': ! return name[0] == '(' and name[-1] == ')' ! else: ! return name[0] == '.' ! ! def _hide(self, name): ! if os.name == 'mac': ! return '(%s)' % name ! else: ! return '.%s' % name ! ! def visible(self, name): ! if len(name) > maxnamelen: return 0 ! if name[-1] == '~': return 0 ! if name in skipnames: return 0 ! if self._hidden(name): return 0 ! head, tail = os.path.split(name) ! if head or not tail: return 0 ! if macfs: ! if os.path.exists(name) and not os.path.isdir(name): ! try: ! fs = macfs.FSSpec(name) ! c, t = fs.GetCreatorType() ! if t != 'TEXT': return 0 ! except macfs.error, msg: ! print "***", name, msg ! return 0 ! else: ! if os.path.islink(name): return 0 ! if '\0' in open(name, 'rb').read(512): return 0 ! for ign in self._ignore: ! if fnmatch.fnmatch(name, ign): return 0 ! return 1 ! ! def check(self, name): ! if not self.visible(name): ! raise os.error, "protected name %s" % repr(name) ! ! def checkfile(self, name): ! self.check(name) ! if not os.path.isfile(name): ! raise os.error, "not a plain file %s" % repr(name) ! ! def pwd(self): ! return os.getcwd() ! ! def cd(self, name): ! self.check(name) ! save = os.getcwd(), self._ignore ! os.chdir(name) ! self._dirstack.append(save) ! self._ignore = self._ignore + self._readignore() ! ! def back(self): ! if not self._dirstack: ! raise os.error, "empty directory stack" ! dir, ignore = self._dirstack[-1] ! os.chdir(dir) ! del self._dirstack[-1] ! self._ignore = ignore ! ! def _filter(self, files, pat = None): ! if pat: ! def keep(name, pat = pat): ! return fnmatch.fnmatch(name, pat) ! files = filter(keep, files) ! files = filter(self.visible, files) ! files.sort() ! return files ! ! def list(self, pat = None): ! files = os.listdir(os.curdir) ! return self._filter(files, pat) ! ! def listfiles(self, pat = None): ! files = os.listdir(os.curdir) ! files = filter(os.path.isfile, files) ! return self._filter(files, pat) ! ! def listsubdirs(self, pat = None): ! files = os.listdir(os.curdir) ! files = filter(os.path.isdir, files) ! return self._filter(files, pat) ! ! def exists(self, name): ! return self.visible(name) and os.path.exists(name) ! ! def isdir(self, name): ! return self.visible(name) and os.path.isdir(name) ! ! def islink(self, name): ! return self.visible(name) and os.path.islink(name) ! ! def isfile(self, name): ! return self.visible(name) and os.path.isfile(name) ! ! def sum(self, name): ! self.checkfile(name) ! BUFFERSIZE = 1024*8 ! f = open(name) ! sum = md5.new() ! while 1: ! buffer = f.read(BUFFERSIZE) ! if not buffer: ! break ! sum.update(buffer) ! return sum.digest() ! ! def size(self, name): ! self.checkfile(name) ! return os.stat(name)[ST_SIZE] ! ! def mtime(self, name): ! self.checkfile(name) ! return time.localtime(os.stat(name)[ST_MTIME]) ! ! def stat(self, name): ! self.checkfile(name) ! size = os.stat(name)[ST_SIZE] ! mtime = time.localtime(os.stat(name)[ST_MTIME]) ! return size, mtime ! ! def info(self, name): ! sum = self.sum(name) ! size = os.stat(name)[ST_SIZE] ! mtime = time.localtime(os.stat(name)[ST_MTIME]) ! return sum, size, mtime ! ! def _list(self, function, list): ! if list is None: ! list = self.listfiles() ! res = [] ! for name in list: ! try: ! res.append((name, function(name))) ! except (os.error, IOError): ! res.append((name, None)) ! return res ! ! def sumlist(self, list = None): ! return self._list(self.sum, list) ! ! def statlist(self, list = None): ! return self._list(self.stat, list) ! ! def mtimelist(self, list = None): ! return self._list(self.mtime, list) ! ! def sizelist(self, list = None): ! return self._list(self.size, list) ! ! def infolist(self, list = None): ! return self._list(self.info, list) ! ! def _dict(self, function, list): ! if list is None: ! list = self.listfiles() ! dict = {} ! for name in list: ! try: ! dict[name] = function(name) ! except (os.error, IOError): ! pass ! return dict ! ! def sumdict(self, list = None): ! return self.dict(self.sum, list) ! ! def sizedict(self, list = None): ! return self.dict(self.size, list) ! ! def mtimedict(self, list = None): ! return self.dict(self.mtime, list) ! ! def statdict(self, list = None): ! return self.dict(self.stat, list) ! ! def infodict(self, list = None): ! return self._dict(self.info, list) ! ! def read(self, name, offset = 0, length = -1): ! self.checkfile(name) ! f = open(name) ! f.seek(offset) ! if length == 0: ! data = '' ! elif length < 0: ! data = f.read() ! else: ! data = f.read(length) ! f.close() ! return data ! ! def create(self, name): ! self.check(name) ! if os.path.exists(name): ! self.checkfile(name) ! bname = name + '~' ! try: ! os.unlink(bname) ! except os.error: ! pass ! os.rename(name, bname) ! f = open(name, 'w') ! f.close() ! ! def write(self, name, data, offset = 0): ! self.checkfile(name) ! f = open(name, 'r+') ! f.seek(offset) ! f.write(data) ! f.close() ! ! def mkdir(self, name): ! self.check(name) ! os.mkdir(name, 0777) ! ! def rmdir(self, name): ! self.check(name) ! os.rmdir(name) class FSProxyServer(FSProxyLocal, server.Server): ! ! def __init__(self, address, verbose = server.VERBOSE): ! FSProxyLocal.__init__(self) ! server.Server.__init__(self, address, verbose) ! ! def _close(self): ! server.Server._close(self) ! FSProxyLocal._close(self) ! ! def _serve(self): ! server.Server._serve(self) ! # Retreat into start directory ! while self._dirstack: self.back() class FSProxyClient(client.Client): ! ! def __init__(self, address, verbose = client.VERBOSE): ! client.Client.__init__(self, address, verbose) def test(): ! import string ! import sys ! if sys.argv[1:]: ! port = string.atoi(sys.argv[1]) ! else: ! port = 4127 ! proxy = FSProxyServer(('', port)) ! proxy._serverloop() if __name__ == '__main__': ! test() Index: client.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/pdist/client.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** client.py 12 Feb 2004 17:35:02 -0000 1.5 --- client.py 18 Jul 2004 05:56:08 -0000 1.6 *************** *** 13,128 **** class Client: ! ! """RPC Client class. No need to derive a class -- it's fully generic.""" ! ! def __init__(self, address, verbose = VERBOSE): ! self._pre_init(address, verbose) ! self._post_init() ! ! def _pre_init(self, address, verbose = VERBOSE): ! if type(address) == type(0): ! address = ('', address) ! self._address = address ! self._verbose = verbose ! if self._verbose: print "Connecting to %s ..." % repr(address) ! self._socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) ! self._socket.connect(address) ! if self._verbose: print "Connected." ! self._lastid = 0 # Last id for which a reply has been received ! self._nextid = 1 # Id of next request ! self._replies = {} # Unprocessed replies ! self._rf = self._socket.makefile('r') ! self._wf = self._socket.makefile('w') ! ! def _post_init(self): ! self._methods = self._call('.methods') ! ! def __del__(self): ! self._close() ! ! def _close(self): ! if self._rf: self._rf.close() ! self._rf = None ! if self._wf: self._wf.close() ! self._wf = None ! if self._socket: self._socket.close() ! self._socket = None ! ! def __getattr__(self, name): ! if name in self._methods: ! method = _stub(self, name) ! setattr(self, name, method) # XXX circular reference ! return method ! raise AttributeError, name ! ! def _setverbose(self, verbose): ! self._verbose = verbose ! ! def _call(self, name, *args): ! return self._vcall(name, args) ! ! def _vcall(self, name, args): ! return self._recv(self._vsend(name, args)) ! ! def _send(self, name, *args): ! return self._vsend(name, args) ! ! def _send_noreply(self, name, *args): ! return self._vsend(name, args, 0) ! ! def _vsend_noreply(self, name, args): ! return self._vsend(name, args, 0) ! ! def _vsend(self, name, args, wantreply = 1): ! id = self._nextid ! self._nextid = id+1 ! if not wantreply: id = -id ! request = (name, args, id) ! if self._verbose > 1: print "sending request: %s" % repr(request) ! wp = pickle.Pickler(self._wf) ! wp.dump(request) ! return id ! ! def _recv(self, id): ! exception, value, rid = self._vrecv(id) ! if rid != id: ! raise RuntimeError, "request/reply id mismatch: %d/%d" % (id, rid) ! if exception is None: ! return value ! x = exception ! if hasattr(__builtin__, exception): ! x = getattr(__builtin__, exception) ! elif exception in ('posix.error', 'mac.error'): ! x = os.error ! if x == exception: ! exception = x ! raise exception, value ! ! def _vrecv(self, id): ! self._flush() ! if self._replies.has_key(id): ! if self._verbose > 1: print "retrieving previous reply, id = %d" % id ! reply = self._replies[id] ! del self._replies[id] ! return reply ! aid = abs(id) ! while 1: ! if self._verbose > 1: print "waiting for reply, id = %d" % id ! rp = pickle.Unpickler(self._rf) ! reply = rp.load() ! del rp ! if self._verbose > 1: print "got reply: %s" % repr(reply) ! rid = reply[2] ! arid = abs(rid) ! if arid == aid: ! if self._verbose > 1: print "got it" ! return reply ! self._replies[rid] = reply ! if arid > aid: ! if self._verbose > 1: print "got higher id, assume all ok" ! return (None, None, id) ! ! def _flush(self): ! self._wf.flush() --- 13,128 ---- class Client: ! ! """RPC Client class. No need to derive a class -- it's fully generic.""" ! ! def __init__(self, address, verbose = VERBOSE): ! self._pre_init(address, verbose) ! self._post_init() ! ! def _pre_init(self, address, verbose = VERBOSE): ! if type(address) == type(0): ! address = ('', address) ! self._address = address ! self._verbose = verbose ! if self._verbose: print "Connecting to %s ..." % repr(address) ! self._socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) ! self._socket.connect(address) ! if self._verbose: print "Connected." ! self._lastid = 0 # Last id for which a reply has been received ! self._nextid = 1 # Id of next request ! self._replies = {} # Unprocessed replies ! self._rf = self._socket.makefile('r') ! self._wf = self._socket.makefile('w') ! ! def _post_init(self): ! self._methods = self._call('.methods') ! ! def __del__(self): ! self._close() ! ! def _close(self): ! if self._rf: self._rf.close() ! self._rf = None ! if self._wf: self._wf.close() ! self._wf = None ! if self._socket: self._socket.close() ! self._socket = None ! ! def __getattr__(self, name): ! if name in self._methods: ! method = _stub(self, name) ! setattr(self, name, method) # XXX circular reference ! return method ! raise AttributeError, name ! ! def _setverbose(self, verbose): ! self._verbose = verbose ! ! def _call(self, name, *args): ! return self._vcall(name, args) ! ! def _vcall(self, name, args): ! return self._recv(self._vsend(name, args)) ! ! def _send(self, name, *args): ! return self._vsend(name, args) ! ! def _send_noreply(self, name, *args): ! return self._vsend(name, args, 0) ! ! def _vsend_noreply(self, name, args): ! return self._vsend(name, args, 0) ! ! def _vsend(self, name, args, wantreply = 1): ! id = self._nextid ! self._nextid = id+1 ! if not wantreply: id = -id ! request = (name, args, id) ! if self._verbose > 1: print "sending request: %s" % repr(request) ! wp = pickle.Pickler(self._wf) ! wp.dump(request) ! return id ! ! def _recv(self, id): ! exception, value, rid = self._vrecv(id) ! if rid != id: ! raise RuntimeError, "request/reply id mismatch: %d/%d" % (id, rid) ! if exception is None: ! return value ! x = exception ! if hasattr(__builtin__, exception): ! x = getattr(__builtin__, exception) ! elif exception in ('posix.error', 'mac.error'): ! x = os.error ! if x == exception: ! exception = x ! raise exception, value ! ! def _vrecv(self, id): ! self._flush() ! if self._replies.has_key(id): ! if self._verbose > 1: print "retrieving previous reply, id = %d" % id ! reply = self._replies[id] ! del self._replies[id] ! return reply ! aid = abs(id) ! while 1: ! if self._verbose > 1: print "waiting for reply, id = %d" % id ! rp = pickle.Unpickler(self._rf) ! reply = rp.load() ! del rp ! if self._verbose > 1: print "got reply: %s" % repr(reply) ! rid = reply[2] ! arid = abs(rid) ! if arid == aid: ! if self._verbose > 1: print "got it" ! return reply ! self._replies[rid] = reply ! if arid > aid: ! if self._verbose > 1: print "got higher id, assume all ok" ! return (None, None, id) ! ! def _flush(self): ! self._wf.flush() *************** *** 132,158 **** class SecureClient(Client, Security): ! def __init__(self, *args): ! import string ! apply(self._pre_init, args) ! Security.__init__(self) ! self._wf.flush() ! line = self._rf.readline() ! challenge = string.atoi(string.strip(line)) ! response = self._encode_challenge(challenge) ! line = repr(long(response)) ! if line[-1] in 'Ll': line = line[:-1] ! self._wf.write(line + '\n') ! self._wf.flush() ! self._post_init() class _stub: - - """Helper class for Client -- each instance serves as a method of the client.""" - - def __init__(self, client, name): - self._client = client - self._name = name - - def __call__(self, *args): - return self._client._vcall(self._name, args) --- 132,157 ---- class SecureClient(Client, Security): ! def __init__(self, *args): ! import string ! apply(self._pre_init, args) ! Security.__init__(self) ! self._wf.flush() ! line = self._rf.readline() ! challenge = string.atoi(string.strip(line)) ! response = self._encode_challenge(challenge) ! line = repr(long(response)) ! if line[-1] in 'Ll': line = line[:-1] ! self._wf.write(line + '\n') ! self._wf.flush() ! self._post_init() class _stub: + """Helper class for Client -- each instance serves as a method of the client.""" + + def __init__(self, client, name): + self._client = client + self._name = name + + def __call__(self, *args): + return self._client._vcall(self._name, args) Index: cmdfw.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/pdist/cmdfw.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** cmdfw.py 12 Feb 2004 17:35:02 -0000 1.3 --- cmdfw.py 18 Jul 2004 05:56:08 -0000 1.4 *************** *** 4,144 **** class CommandFrameWork: ! """Framework class for command line interfaces like CVS. ! The general command line structure is ! command [flags] subcommand [subflags] [argument] ... ! There's a class variable GlobalFlags which specifies the ! global flags options. Subcommands are defined by defining ! methods named do_. Flags for the subcommand are ! defined by defining class or instance variables named ! flags_. If there's no command, method default() ! is called. The __doc__ strings for the do_ methods are used ! for the usage message, printed after the general usage message ! which is the class variable UsageMessage. The class variable ! PostUsageMessage is printed after all the do_ methods' __doc__ ! strings. The method's return value can be a suggested exit ! status. [XXX Need to rewrite this to clarify it.] ! Common usage is to derive a class, instantiate it, and then call its ! run() method; by default this takes its arguments from sys.argv[1:]. ! """ ! UsageMessage = \ ! "usage: (name)s [flags] subcommand [subflags] [argument] ..." ! PostUsageMessage = None ! GlobalFlags = '' ! def __init__(self): ! """Constructor, present for completeness.""" ! pass ! def run(self, args = None): ! """Process flags, subcommand and options, then run it.""" ! import getopt, sys ! if args is None: args = sys.argv[1:] ! try: ! opts, args = getopt.getopt(args, self.GlobalFlags) ! except getopt.error, msg: ! return self.usage(msg) ! self.options(opts) ! if not args: ! self.ready() ! return self.default() ! else: ! cmd = args[0] ! mname = 'do_' + cmd ! fname = 'flags_' + cmd ! try: ! method = getattr(self, mname) ! except AttributeError: ! return self.usage("command %r unknown" % (cmd,)) ! try: ! flags = getattr(self, fname) ! except AttributeError: ! flags = '' ! try: ! opts, args = getopt.getopt(args[1:], flags) ! except getopt.error, msg: ! return self.usage( ! "subcommand %s: " % cmd + str(msg)) ! self.ready() ! return method(opts, args) ! def options(self, opts): ! """Process the options retrieved by getopt. ! Override this if you have any options.""" ! if opts: ! print "-"*40 ! print "Options:" ! for o, a in opts: ! print 'option', o, 'value', repr(a) ! print "-"*40 ! def ready(self): ! """Called just before calling the subcommand.""" ! pass ! def usage(self, msg = None): ! """Print usage message. Return suitable exit code (2).""" ! if msg: print msg ! print self.UsageMessage % {'name': self.__class__.__name__} ! docstrings = {} ! c = self.__class__ ! while 1: ! for name in dir(c): ! if name[:3] == 'do_': ! if docstrings.has_key(name): ! continue ! try: ! doc = getattr(c, name).__doc__ ! except: ! doc = None ! if doc: ! docstrings[name] = doc ! if not c.__bases__: ! break ! c = c.__bases__[0] ! if docstrings: ! print "where subcommand can be:" ! names = docstrings.keys() ! names.sort() ! for name in names: ! print docstrings[name] ! if self.PostUsageMessage: ! print self.PostUsageMessage ! return 2 ! def default(self): ! """Default method, called when no subcommand is given. ! You should always override this.""" ! print "Nobody expects the Spanish Inquisition!" def test(): ! """Test script -- called when this module is run as a script.""" ! import sys ! class Hello(CommandFrameWork): ! def do_hello(self, opts, args): ! "hello -- print 'hello world', needs no arguments" ! print "Hello, world" ! x = Hello() ! tests = [ ! [], ! ['hello'], ! ['spam'], ! ['-x'], ! ['hello', '-x'], ! None, ! ] ! for t in tests: ! print '-'*10, t, '-'*10 ! sts = x.run(t) ! print "Exit status:", repr(sts) if __name__ == '__main__': ! test() --- 4,144 ---- class CommandFrameWork: ! """Framework class for command line interfaces like CVS. ! The general command line structure is ! command [flags] subcommand [subflags] [argument] ... ! There's a class variable GlobalFlags which specifies the ! global flags options. Subcommands are defined by defining ! methods named do_. Flags for the subcommand are ! defined by defining class or instance variables named ! flags_. If there's no command, method default() ! is called. The __doc__ strings for the do_ methods are used ! for the usage message, printed after the general usage message ! which is the class variable UsageMessage. The class variable ! PostUsageMessage is printed after all the do_ methods' __doc__ ! strings. The method's return value can be a suggested exit ! status. [XXX Need to rewrite this to clarify it.] ! Common usage is to derive a class, instantiate it, and then call its ! run() method; by default this takes its arguments from sys.argv[1:]. ! """ ! UsageMessage = \ ! "usage: (name)s [flags] subcommand [subflags] [argument] ..." ! PostUsageMessage = None ! GlobalFlags = '' ! def __init__(self): ! """Constructor, present for completeness.""" ! pass ! def run(self, args = None): ! """Process flags, subcommand and options, then run it.""" ! import getopt, sys ! if args is None: args = sys.argv[1:] ! try: ! opts, args = getopt.getopt(args, self.GlobalFlags) ! except getopt.error, msg: ! return self.usage(msg) ! self.options(opts) ! if not args: ! self.ready() ! return self.default() ! else: ! cmd = args[0] ! mname = 'do_' + cmd ! fname = 'flags_' + cmd ! try: ! method = getattr(self, mname) ! except AttributeError: ! return self.usage("command %r unknown" % (cmd,)) ! try: ! flags = getattr(self, fname) ! except AttributeError: ! flags = '' ! try: ! opts, args = getopt.getopt(args[1:], flags) ! except getopt.error, msg: ! return self.usage( ! "subcommand %s: " % cmd + str(msg)) ! self.ready() ! return method(opts, args) ! def options(self, opts): ! """Process the options retrieved by getopt. ! Override this if you have any options.""" ! if opts: ! print "-"*40 ! print "Options:" ! for o, a in opts: ! print 'option', o, 'value', repr(a) ! print "-"*40 ! def ready(self): ! """Called just before calling the subcommand.""" ! pass ! def usage(self, msg = None): ! """Print usage message. Return suitable exit code (2).""" ! if msg: print msg ! print self.UsageMessage % {'name': self.__class__.__name__} ! docstrings = {} ! c = self.__class__ ! while 1: ! for name in dir(c): ! if name[:3] == 'do_': ! if docstrings.has_key(name): ! continue ! try: ! doc = getattr(c, name).__doc__ ! except: ! doc = None ! if doc: ! docstrings[name] = doc ! if not c.__bases__: ! break ! c = c.__bases__[0] ! if docstrings: ! print "where subcommand can be:" ! names = docstrings.keys() ! names.sort() ! for name in names: ! print docstrings[name] ! if self.PostUsageMessage: ! print self.PostUsageMessage ! return 2 ! def default(self): ! """Default method, called when no subcommand is given. ! You should always override this.""" ! print "Nobody expects the Spanish Inquisition!" def test(): ! """Test script -- called when this module is run as a script.""" ! import sys ! class Hello(CommandFrameWork): ! def do_hello(self, opts, args): ! "hello -- print 'hello world', needs no arguments" ! print "Hello, world" ! x = Hello() ! tests = [ ! [], ! ['hello'], ! ['spam'], ! ['-x'], ! ['hello', '-x'], ! None, ! ] ! for t in tests: ! print '-'*10, t, '-'*10 ! sts = x.run(t) ! print "Exit status:", repr(sts) if __name__ == '__main__': ! test() From tim_one at users.sourceforge.net Sun Jul 18 07:56:27 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 07:56:35 2004 Subject: [Python-checkins] python/dist/src/Demo/sockets broadcast.py, 1.5, 1.6 echosvr.py, 1.7, 1.8 finger.py, 1.5, 1.6 ftp.py, 1.6, 1.7 gopher.py, 1.5, 1.6 mcast.py, 1.10, 1.11 radio.py, 1.4, 1.5 rpython.py, 1.2, 1.3 rpythond.py, 1.3, 1.4 telnet.py, 1.6, 1.7 throughput.py, 1.6, 1.7 udpecho.py, 1.6, 1.7 unicast.py, 1.2, 1.3 unixserver.py, 1.3, 1.4 Message-ID: Update of /cvsroot/python/python/dist/src/Demo/sockets In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28702/Demo/sockets Modified Files: broadcast.py echosvr.py finger.py ftp.py gopher.py mcast.py radio.py rpython.py rpythond.py telnet.py throughput.py udpecho.py unicast.py unixserver.py Log Message: Whitespace normalization. Ran reindent.py over the entire source tree. Index: broadcast.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/sockets/broadcast.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** broadcast.py 12 Feb 2004 17:35:03 -0000 1.5 --- broadcast.py 18 Jul 2004 05:56:09 -0000 1.6 *************** *** 11,17 **** while 1: ! data = repr(time.time()) + '\n' ! s.sendto(data, ('', MYPORT)) ! time.sleep(2) ! ! --- 11,15 ---- while 1: ! data = repr(time.time()) + '\n' ! s.sendto(data, ('', MYPORT)) ! time.sleep(2) Index: echosvr.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/sockets/echosvr.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** echosvr.py 25 Aug 2000 16:03:27 -0000 1.7 --- echosvr.py 18 Jul 2004 05:56:09 -0000 1.8 *************** *** 14,31 **** def main(): ! if len(sys.argv) > 1: ! port = int(eval(sys.argv[1])) ! else: ! port = ECHO_PORT ! s = socket(AF_INET, SOCK_STREAM) ! s.bind(('', port)) ! s.listen(1) ! conn, (remotehost, remoteport) = s.accept() ! print 'connected by', remotehost, remoteport ! while 1: ! data = conn.recv(BUFSIZE) ! if not data: ! break ! conn.send(data) main() --- 14,31 ---- def main(): ! if len(sys.argv) > 1: ! port = int(eval(sys.argv[1])) ! else: ! port = ECHO_PORT ! s = socket(AF_INET, SOCK_STREAM) ! s.bind(('', port)) ! s.listen(1) ! conn, (remotehost, remoteport) = s.accept() ! print 'connected by', remotehost, remoteport ! while 1: ! data = conn.recv(BUFSIZE) ! if not data: ! break ! conn.send(data) main() Index: finger.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/sockets/finger.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** finger.py 25 Aug 2000 15:38:41 -0000 1.5 --- finger.py 18 Jul 2004 05:56:09 -0000 1.6 *************** *** 23,34 **** # def finger(host, args): ! s = socket(AF_INET, SOCK_STREAM) ! s.connect((host, FINGER_PORT)) ! s.send(args + '\n') ! while 1: ! buf = s.recv(1024) ! if not buf: break ! sys.stdout.write(buf) ! sys.stdout.flush() --- 23,34 ---- # def finger(host, args): ! s = socket(AF_INET, SOCK_STREAM) ! s.connect((host, FINGER_PORT)) ! s.send(args + '\n') ! while 1: ! buf = s.recv(1024) ! if not buf: break ! sys.stdout.write(buf) ! sys.stdout.flush() *************** *** 36,55 **** # def main(): ! options = '' ! i = 1 ! while i < len(sys.argv) and sys.argv[i][:1] == '-': ! options = options + sys.argv[i] + ' ' ! i = i+1 ! args = sys.argv[i:] ! if not args: ! args = [''] ! for arg in args: ! if '@' in arg: ! at = string.index(arg, '@') ! host = arg[at+1:] ! arg = arg[:at] ! else: ! host = '' ! finger(host, options + arg) --- 36,55 ---- # def main(): ! options = '' ! i = 1 ! while i < len(sys.argv) and sys.argv[i][:1] == '-': ! options = options + sys.argv[i] + ' ' ! i = i+1 ! args = sys.argv[i:] ! if not args: ! args = [''] ! for arg in args: ! if '@' in arg: ! at = string.index(arg, '@') ! host = arg[at+1:] ! arg = arg[:at] ! else: ! host = '' ! finger(host, options + arg) Index: ftp.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/sockets/ftp.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** ftp.py 12 Feb 2004 17:35:03 -0000 1.6 --- ftp.py 18 Jul 2004 05:56:09 -0000 1.7 *************** *** 38,43 **** # def main(): ! hostname = sys.argv[1] ! control(hostname) --- 38,43 ---- # def main(): ! hostname = sys.argv[1] ! control(hostname) *************** *** 45,70 **** # def control(hostname): ! # ! # Create control connection ! # ! s = socket(AF_INET, SOCK_STREAM) ! s.connect((hostname, FTP_PORT)) ! f = s.makefile('r') # Reading the replies is easier from a file... ! # ! # Control loop ! # ! r = None ! while 1: ! code = getreply(f) ! if code in ('221', 'EOF'): break ! if code == '150': ! getdata(r) ! code = getreply(f) ! r = None ! if not r: ! r = newdataport(s, f) ! cmd = getcommand() ! if not cmd: break ! s.send(cmd + '\r\n') --- 45,70 ---- # def control(hostname): ! # ! # Create control connection ! # ! s = socket(AF_INET, SOCK_STREAM) ! s.connect((hostname, FTP_PORT)) ! f = s.makefile('r') # Reading the replies is easier from a file... ! # ! # Control loop ! # ! r = None ! while 1: ! code = getreply(f) ! if code in ('221', 'EOF'): break ! if code == '150': ! getdata(r) ! code = getreply(f) ! r = None ! if not r: ! r = newdataport(s, f) ! cmd = getcommand() ! if not cmd: break ! s.send(cmd + '\r\n') *************** *** 76,87 **** # def newdataport(s, f): ! global nextport ! port = nextport + FTP_DATA_PORT ! nextport = (nextport+1) % 16 ! r = socket(AF_INET, SOCK_STREAM) ! r.bind((gethostbyname(gethostname()), port)) ! r.listen(1) ! sendportcmd(s, f, port) ! return r --- 76,87 ---- # def newdataport(s, f): ! global nextport ! port = nextport + FTP_DATA_PORT ! nextport = (nextport+1) % 16 ! r = socket(AF_INET, SOCK_STREAM) ! r.bind((gethostbyname(gethostname()), port)) ! r.listen(1) ! sendportcmd(s, f, port) ! return r *************** *** 89,100 **** # def sendportcmd(s, f, port): ! hostname = gethostname() ! hostaddr = gethostbyname(hostname) ! hbytes = string.splitfields(hostaddr, '.') ! pbytes = [repr(port/256), repr(port%256)] ! bytes = hbytes + pbytes ! cmd = 'PORT ' + string.joinfields(bytes, ',') ! s.send(cmd + '\r\n') ! code = getreply(f) --- 89,100 ---- # def sendportcmd(s, f, port): ! hostname = gethostname() ! hostaddr = gethostbyname(hostname) ! hbytes = string.splitfields(hostaddr, '.') ! pbytes = [repr(port/256), repr(port%256)] ! bytes = hbytes + pbytes ! cmd = 'PORT ' + string.joinfields(bytes, ',') ! s.send(cmd + '\r\n') ! code = getreply(f) *************** *** 106,120 **** # def getreply(f): ! line = f.readline() ! if not line: return 'EOF' ! print line, ! code = line[:3] ! if line[3:4] == '-': ! while 1: ! line = f.readline() ! if not line: break # Really an error ! print line, ! if line[:3] == code and line[3:4] != '-': break ! return code --- 106,120 ---- # def getreply(f): ! line = f.readline() ! if not line: return 'EOF' ! print line, ! code = line[:3] ! if line[3:4] == '-': ! while 1: ! line = f.readline() ! if not line: break # Really an error ! print line, ! if line[:3] == code and line[3:4] != '-': break ! return code *************** *** 122,143 **** # def getdata(r): ! print '(accepting data connection)' ! conn, host = r.accept() ! print '(data connection accepted)' ! while 1: ! data = conn.recv(BUFSIZE) ! if not data: break ! sys.stdout.write(data) ! print '(end of data connection)' # Get a command from the user. # def getcommand(): ! try: ! while 1: ! line = raw_input('ftp.py> ') ! if line: return line ! except EOFError: ! return '' --- 122,143 ---- # def getdata(r): ! print '(accepting data connection)' ! conn, host = r.accept() ! print '(data connection accepted)' ! while 1: ! data = conn.recv(BUFSIZE) ! if not data: break ! sys.stdout.write(data) ! print '(end of data connection)' # Get a command from the user. # def getcommand(): ! try: ! while 1: ! line = raw_input('ftp.py> ') ! if line: return line ! except EOFError: ! return '' Index: gopher.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/sockets/gopher.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** gopher.py 12 Feb 2004 17:35:03 -0000 1.5 --- gopher.py 18 Jul 2004 05:56:09 -0000 1.6 *************** *** 31,36 **** # Dictionary mapping types to strings typename = {'0': '', '1': '

', '2': '', '3': '', \ ! '4': '', '5': '', '6': '', '7': '', \ ! '8': '', '9': '', '+': '', 's': ''} # Oft-used characters and strings --- 31,36 ---- # Dictionary mapping types to strings typename = {'0': '', '1': '', '2': '', '3': '', \ ! '4': '', '5': '', '6': '', '7': '', \ ! '8': '', '9': '', '+': '', 's': ''} # Oft-used characters and strings *************** *** 40,128 **** # Open a TCP connection to a given host and port def open_socket(host, port): ! if not port: ! port = DEF_PORT ! elif type(port) == type(''): ! port = string.atoi(port) ! s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) ! s.connect((host, port)) ! return s # Send a selector to a given host and port, return a file with the reply def send_request(selector, host, port): ! s = open_socket(host, port) ! s.send(selector + CRLF) ! s.shutdown(1) ! return s.makefile('r') # Get a menu in the form of a list of entries def get_menu(selector, host, port): ! f = send_request(selector, host, port) ! list = [] ! while 1: ! line = f.readline() ! if not line: ! print '(Unexpected EOF from server)' ! break ! if line[-2:] == CRLF: ! line = line[:-2] ! elif line[-1:] in CRLF: ! line = line[:-1] ! if line == '.': ! break ! if not line: ! print '(Empty line from server)' ! continue ! typechar = line[0] ! parts = string.splitfields(line[1:], TAB) ! if len(parts) < 4: ! print '(Bad line from server: %r)' % (line,) ! continue ! if len(parts) > 4: ! print '(Extra info from server: %r)' % (parts[4:],) ! parts.insert(0, typechar) ! list.append(parts) ! f.close() ! return list # Get a text file as a list of lines, with trailing CRLF stripped def get_textfile(selector, host, port): ! list = [] ! get_alt_textfile(selector, host, port, list.append) ! return list # Get a text file and pass each line to a function, with trailing CRLF stripped def get_alt_textfile(selector, host, port, func): ! f = send_request(selector, host, port) ! while 1: ! line = f.readline() ! if not line: ! print '(Unexpected EOF from server)' ! break ! if line[-2:] == CRLF: ! line = line[:-2] ! elif line[-1:] in CRLF: ! line = line[:-1] ! if line == '.': ! break ! if line[:2] == '..': ! line = line[1:] ! func(line) ! f.close() # Get a binary file as one solid data block def get_binary(selector, host, port): ! f = send_request(selector, host, port) ! data = f.read() ! f.close() ! return data # Get a binary file and pass each block to a function def get_alt_binary(selector, host, port, func, blocksize): ! f = send_request(selector, host, port) ! while 1: ! data = f.read(blocksize) ! if not data: ! break ! func(data) # A *very* simple interactive browser --- 40,128 ---- # Open a TCP connection to a given host and port def open_socket(host, port): ! if not port: ! port = DEF_PORT ! elif type(port) == type(''): ! port = string.atoi(port) ! s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) ! s.connect((host, port)) ! return s # Send a selector to a given host and port, return a file with the reply def send_request(selector, host, port): ! s = open_socket(host, port) ! s.send(selector + CRLF) ! s.shutdown(1) ! return s.makefile('r') # Get a menu in the form of a list of entries def get_menu(selector, host, port): ! f = send_request(selector, host, port) ! list = [] ! while 1: ! line = f.readline() ! if not line: ! print '(Unexpected EOF from server)' ! break ! if line[-2:] == CRLF: ! line = line[:-2] ! elif line[-1:] in CRLF: ! line = line[:-1] ! if line == '.': ! break ! if not line: ! print '(Empty line from server)' ! continue ! typechar = line[0] ! parts = string.splitfields(line[1:], TAB) ! if len(parts) < 4: ! print '(Bad line from server: %r)' % (line,) ! continue ! if len(parts) > 4: ! print '(Extra info from server: %r)' % (parts[4:],) ! parts.insert(0, typechar) ! list.append(parts) ! f.close() ! return list # Get a text file as a list of lines, with trailing CRLF stripped def get_textfile(selector, host, port): ! list = [] ! get_alt_textfile(selector, host, port, list.append) ! return list # Get a text file and pass each line to a function, with trailing CRLF stripped def get_alt_textfile(selector, host, port, func): ! f = send_request(selector, host, port) ! while 1: ! line = f.readline() ! if not line: ! print '(Unexpected EOF from server)' ! break ! if line[-2:] == CRLF: ! line = line[:-2] ! elif line[-1:] in CRLF: ! line = line[:-1] ! if line == '.': ! break ! if line[:2] == '..': ! line = line[1:] ! func(line) ! f.close() # Get a binary file as one solid data block def get_binary(selector, host, port): ! f = send_request(selector, host, port) ! data = f.read() ! f.close() ! return data # Get a binary file and pass each block to a function def get_alt_binary(selector, host, port, func, blocksize): ! f = send_request(selector, host, port) ! while 1: ! data = f.read(blocksize) ! if not data: ! break ! func(data) # A *very* simple interactive browser *************** *** 130,346 **** # Browser main command, has default arguments def browser(*args): ! selector = DEF_SELECTOR ! host = DEF_HOST ! port = DEF_PORT ! n = len(args) ! if n > 0 and args[0]: ! selector = args[0] ! if n > 1 and args[1]: ! host = args[1] ! if n > 2 and args[2]: ! port = args[2] ! if n > 3: ! raise RuntimeError, 'too many args' ! try: ! browse_menu(selector, host, port) ! except socket.error, msg: ! print 'Socket error:', msg ! sys.exit(1) ! except KeyboardInterrupt: ! print '\n[Goodbye]' # Browse a menu def browse_menu(selector, host, port): ! list = get_menu(selector, host, port) ! while 1: ! print '----- MENU -----' ! print 'Selector:', repr(selector) ! print 'Host:', host, ' Port:', port ! print ! for i in range(len(list)): ! item = list[i] ! typechar, description = item[0], item[1] ! print string.rjust(repr(i+1), 3) + ':', description, ! if typename.has_key(typechar): ! print typename[typechar] ! else: ! print '' ! print ! while 1: ! try: ! str = raw_input('Choice [CR == up a level]: ') ! except EOFError: ! print ! return ! if not str: ! return ! try: ! choice = string.atoi(str) ! except string.atoi_error: ! print 'Choice must be a number; try again:' ! continue ! if not 0 < choice <= len(list): ! print 'Choice out of range; try again:' ! continue ! break ! item = list[choice-1] ! typechar = item[0] ! [i_selector, i_host, i_port] = item[2:5] ! if typebrowser.has_key(typechar): ! browserfunc = typebrowser[typechar] ! try: ! browserfunc(i_selector, i_host, i_port) ! except (IOError, socket.error): ! print '***', sys.exc_type, ':', sys.exc_value ! else: ! print 'Unsupported object type' # Browse a text file def browse_textfile(selector, host, port): ! x = None ! try: ! p = os.popen('${PAGER-more}', 'w') ! x = SaveLines(p) ! get_alt_textfile(selector, host, port, x.writeln) ! except IOError, msg: ! print 'IOError:', msg ! if x: ! x.close() ! f = open_savefile() ! if not f: ! return ! x = SaveLines(f) ! try: ! get_alt_textfile(selector, host, port, x.writeln) ! print 'Done.' ! except IOError, msg: ! print 'IOError:', msg ! x.close() # Browse a search index def browse_search(selector, host, port): ! while 1: ! print '----- SEARCH -----' ! print 'Selector:', repr(selector) ! print 'Host:', host, ' Port:', port ! print ! try: ! query = raw_input('Query [CR == up a level]: ') ! except EOFError: ! print ! break ! query = string.strip(query) ! if not query: ! break ! if '\t' in query: ! print 'Sorry, queries cannot contain tabs' ! continue ! browse_menu(selector + TAB + query, host, port) # "Browse" telnet-based information, i.e. open a telnet session def browse_telnet(selector, host, port): ! if selector: ! print 'Log in as', repr(selector) ! if type(port) <> type(''): ! port = repr(port) ! sts = os.system('set -x; exec telnet ' + host + ' ' + port) ! if sts: ! print 'Exit status:', sts # "Browse" a binary file, i.e. save it to a file def browse_binary(selector, host, port): ! f = open_savefile() ! if not f: ! return ! x = SaveWithProgress(f) ! get_alt_binary(selector, host, port, x.write, 8*1024) ! x.close() # "Browse" a sound file, i.e. play it or save it def browse_sound(selector, host, port): ! browse_binary(selector, host, port) # Dictionary mapping types to browser functions typebrowser = {'0': browse_textfile, '1': browse_menu, \ ! '4': browse_binary, '5': browse_binary, '6': browse_textfile, \ ! '7': browse_search, \ ! '8': browse_telnet, '9': browse_binary, 's': browse_sound} # Class used to save lines, appending a newline to each line class SaveLines: ! def __init__(self, f): ! self.f = f ! def writeln(self, line): ! self.f.write(line + '\n') ! def close(self): ! sts = self.f.close() ! if sts: ! print 'Exit status:', sts # Class used to save data while showing progress class SaveWithProgress: ! def __init__(self, f): ! self.f = f ! def write(self, data): ! sys.stdout.write('#') ! sys.stdout.flush() ! self.f.write(data) ! def close(self): ! print ! sts = self.f.close() ! if sts: ! print 'Exit status:', sts # Ask for and open a save file, or return None if not to save def open_savefile(): ! try: ! savefile = raw_input( \ ! 'Save as file [CR == don\'t save; |pipeline or ~user/... OK]: ') ! except EOFError: ! print ! return None ! savefile = string.strip(savefile) ! if not savefile: ! return None ! if savefile[0] == '|': ! cmd = string.strip(savefile[1:]) ! try: ! p = os.popen(cmd, 'w') ! except IOError, msg: ! print repr(cmd), ':', msg ! return None ! print 'Piping through', repr(cmd), '...' ! return p ! if savefile[0] == '~': ! savefile = os.path.expanduser(savefile) ! try: ! f = open(savefile, 'w') ! except IOError, msg: ! print repr(savefile), ':', msg ! return None ! print 'Saving to', repr(savefile), '...' ! return f # Test program def test(): ! if sys.argv[4:]: ! print 'usage: gopher [ [selector] host [port] ]' ! sys.exit(2) ! elif sys.argv[3:]: ! browser(sys.argv[1], sys.argv[2], sys.argv[3]) ! elif sys.argv[2:]: ! try: ! port = string.atoi(sys.argv[2]) ! selector = '' ! host = sys.argv[1] ! except string.atoi_error: ! selector = sys.argv[1] ! host = sys.argv[2] ! port = '' ! browser(selector, host, port) ! elif sys.argv[1:]: ! browser('', sys.argv[1]) ! else: ! browser() # Call the test program as a main program --- 130,346 ---- # Browser main command, has default arguments def browser(*args): ! selector = DEF_SELECTOR ! host = DEF_HOST ! port = DEF_PORT ! n = len(args) ! if n > 0 and args[0]: ! selector = args[0] ! if n > 1 and args[1]: ! host = args[1] ! if n > 2 and args[2]: ! port = args[2] ! if n > 3: ! raise RuntimeError, 'too many args' ! try: ! browse_menu(selector, host, port) ! except socket.error, msg: ! print 'Socket error:', msg ! sys.exit(1) ! except KeyboardInterrupt: ! print '\n[Goodbye]' # Browse a menu def browse_menu(selector, host, port): ! list = get_menu(selector, host, port) ! while 1: ! print '----- MENU -----' ! print 'Selector:', repr(selector) ! print 'Host:', host, ' Port:', port ! print ! for i in range(len(list)): ! item = list[i] ! typechar, description = item[0], item[1] ! print string.rjust(repr(i+1), 3) + ':', description, ! if typename.has_key(typechar): ! print typename[typechar] ! else: ! print '' ! print ! while 1: ! try: ! str = raw_input('Choice [CR == up a level]: ') ! except EOFError: ! print ! return ! if not str: ! return ! try: ! choice = string.atoi(str) ! except string.atoi_error: ! print 'Choice must be a number; try again:' ! continue ! if not 0 < choice <= len(list): ! print 'Choice out of range; try again:' ! continue ! break ! item = list[choice-1] ! typechar = item[0] ! [i_selector, i_host, i_port] = item[2:5] ! if typebrowser.has_key(typechar): ! browserfunc = typebrowser[typechar] ! try: ! browserfunc(i_selector, i_host, i_port) ! except (IOError, socket.error): ! print '***', sys.exc_type, ':', sys.exc_value ! else: ! print 'Unsupported object type' # Browse a text file def browse_textfile(selector, host, port): ! x = None ! try: ! p = os.popen('${PAGER-more}', 'w') ! x = SaveLines(p) ! get_alt_textfile(selector, host, port, x.writeln) ! except IOError, msg: ! print 'IOError:', msg ! if x: ! x.close() ! f = open_savefile() ! if not f: ! return ! x = SaveLines(f) ! try: ! get_alt_textfile(selector, host, port, x.writeln) ! print 'Done.' ! except IOError, msg: ! print 'IOError:', msg ! x.close() # Browse a search index def browse_search(selector, host, port): ! while 1: ! print '----- SEARCH -----' ! print 'Selector:', repr(selector) ! print 'Host:', host, ' Port:', port ! print ! try: ! query = raw_input('Query [CR == up a level]: ') ! except EOFError: ! print ! break ! query = string.strip(query) ! if not query: ! break ! if '\t' in query: ! print 'Sorry, queries cannot contain tabs' ! continue ! browse_menu(selector + TAB + query, host, port) # "Browse" telnet-based information, i.e. open a telnet session def browse_telnet(selector, host, port): ! if selector: ! print 'Log in as', repr(selector) ! if type(port) <> type(''): ! port = repr(port) ! sts = os.system('set -x; exec telnet ' + host + ' ' + port) ! if sts: ! print 'Exit status:', sts # "Browse" a binary file, i.e. save it to a file def browse_binary(selector, host, port): ! f = open_savefile() ! if not f: ! return ! x = SaveWithProgress(f) ! get_alt_binary(selector, host, port, x.write, 8*1024) ! x.close() # "Browse" a sound file, i.e. play it or save it def browse_sound(selector, host, port): ! browse_binary(selector, host, port) # Dictionary mapping types to browser functions typebrowser = {'0': browse_textfile, '1': browse_menu, \ ! '4': browse_binary, '5': browse_binary, '6': browse_textfile, \ ! '7': browse_search, \ ! '8': browse_telnet, '9': browse_binary, 's': browse_sound} # Class used to save lines, appending a newline to each line class SaveLines: ! def __init__(self, f): ! self.f = f ! def writeln(self, line): ! self.f.write(line + '\n') ! def close(self): ! sts = self.f.close() ! if sts: ! print 'Exit status:', sts # Class used to save data while showing progress class SaveWithProgress: ! def __init__(self, f): ! self.f = f ! def write(self, data): ! sys.stdout.write('#') ! sys.stdout.flush() ! self.f.write(data) ! def close(self): ! print ! sts = self.f.close() ! if sts: ! print 'Exit status:', sts # Ask for and open a save file, or return None if not to save def open_savefile(): ! try: ! savefile = raw_input( \ ! 'Save as file [CR == don\'t save; |pipeline or ~user/... OK]: ') ! except EOFError: ! print ! return None ! savefile = string.strip(savefile) ! if not savefile: ! return None ! if savefile[0] == '|': ! cmd = string.strip(savefile[1:]) ! try: ! p = os.popen(cmd, 'w') ! except IOError, msg: ! print repr(cmd), ':', msg ! return None ! print 'Piping through', repr(cmd), '...' ! return p ! if savefile[0] == '~': ! savefile = os.path.expanduser(savefile) ! try: ! f = open(savefile, 'w') ! except IOError, msg: ! print repr(savefile), ':', msg ! return None ! print 'Saving to', repr(savefile), '...' ! return f # Test program def test(): ! if sys.argv[4:]: ! print 'usage: gopher [ [selector] host [port] ]' ! sys.exit(2) ! elif sys.argv[3:]: ! browser(sys.argv[1], sys.argv[2], sys.argv[3]) ! elif sys.argv[2:]: ! try: ! port = string.atoi(sys.argv[2]) ! selector = '' ! host = sys.argv[1] ! except string.atoi_error: ! selector = sys.argv[1] ! host = sys.argv[2] ! port = '' ! browser(selector, host, port) ! elif sys.argv[1:]: ! browser('', sys.argv[1]) ! else: ! browser() # Call the test program as a main program Index: mcast.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/sockets/mcast.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** mcast.py 12 Feb 2004 17:35:03 -0000 1.10 --- mcast.py 18 Jul 2004 05:56:09 -0000 1.11 *************** *** 20,93 **** # Main program def main(): ! flags = sys.argv[1:] ! # ! if flags: ! sender(flags[0]) ! else: ! receiver() # Sender subroutine (only one per local area network) def sender(flag): ! s = socket(AF_INET, SOCK_DGRAM) ! if flag == '-b': ! s.setsockopt(SOL_SOCKET, SO_BROADCAST, 1) ! mygroup = '' ! else: ! mygroup = MYGROUP ! ttl = struct.pack('b', 1) # Time-to-live ! s.setsockopt(IPPROTO_IP, IP_MULTICAST_TTL, ttl) ! while 1: ! data = repr(time.time()) ! ## data = data + (1400 - len(data)) * '\0' ! s.sendto(data, (mygroup, MYPORT)) ! time.sleep(1) # Receiver subroutine (as many as you like) def receiver(): ! # Open and initialize the socket ! s = openmcastsock(MYGROUP, MYPORT) ! # ! # Loop, printing any data we receive ! while 1: ! data, sender = s.recvfrom(1500) ! while data[-1:] == '\0': data = data[:-1] # Strip trailing \0's ! print sender, ':', repr(data) # Open a UDP socket, bind it to a port and select a multicast group def openmcastsock(group, port): ! # Import modules used only here ! import string ! import struct ! # ! # Create a socket ! s = socket(AF_INET, SOCK_DGRAM) ! # ! # Allow multiple copies of this program on one machine ! # (not strictly needed) ! s.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1) ! # ! # Bind it to the port ! s.bind(('', port)) ! # ! # Look up multicast group address in name server ! # (doesn't hurt if it is already in ddd.ddd.ddd.ddd format) ! group = gethostbyname(group) ! # ! # Construct binary group address ! bytes = map(int, string.split(group, ".")) ! grpaddr = 0 ! for byte in bytes: grpaddr = (grpaddr << 8) | byte ! # ! # Construct struct mreq from grpaddr and ifaddr ! ifaddr = INADDR_ANY ! mreq = struct.pack('ll', htonl(grpaddr), htonl(ifaddr)) ! # ! # Add group membership ! s.setsockopt(IPPROTO_IP, IP_ADD_MEMBERSHIP, mreq) ! # ! return s --- 20,93 ---- # Main program def main(): ! flags = sys.argv[1:] ! # ! if flags: ! sender(flags[0]) ! else: ! receiver() # Sender subroutine (only one per local area network) def sender(flag): ! s = socket(AF_INET, SOCK_DGRAM) ! if flag == '-b': ! s.setsockopt(SOL_SOCKET, SO_BROADCAST, 1) ! mygroup = '' ! else: ! mygroup = MYGROUP ! ttl = struct.pack('b', 1) # Time-to-live ! s.setsockopt(IPPROTO_IP, IP_MULTICAST_TTL, ttl) ! while 1: ! data = repr(time.time()) ! ## data = data + (1400 - len(data)) * '\0' ! s.sendto(data, (mygroup, MYPORT)) ! time.sleep(1) # Receiver subroutine (as many as you like) def receiver(): ! # Open and initialize the socket ! s = openmcastsock(MYGROUP, MYPORT) ! # ! # Loop, printing any data we receive ! while 1: ! data, sender = s.recvfrom(1500) ! while data[-1:] == '\0': data = data[:-1] # Strip trailing \0's ! print sender, ':', repr(data) # Open a UDP socket, bind it to a port and select a multicast group def openmcastsock(group, port): ! # Import modules used only here ! import string ! import struct ! # ! # Create a socket ! s = socket(AF_INET, SOCK_DGRAM) ! # ! # Allow multiple copies of this program on one machine ! # (not strictly needed) ! s.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1) ! # ! # Bind it to the port ! s.bind(('', port)) ! # ! # Look up multicast group address in name server ! # (doesn't hurt if it is already in ddd.ddd.ddd.ddd format) ! group = gethostbyname(group) ! # ! # Construct binary group address ! bytes = map(int, string.split(group, ".")) ! grpaddr = 0 ! for byte in bytes: grpaddr = (grpaddr << 8) | byte ! # ! # Construct struct mreq from grpaddr and ifaddr ! ifaddr = INADDR_ANY ! mreq = struct.pack('ll', htonl(grpaddr), htonl(ifaddr)) ! # ! # Add group membership ! s.setsockopt(IPPROTO_IP, IP_ADD_MEMBERSHIP, mreq) ! # ! return s Index: radio.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/sockets/radio.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** radio.py 12 Feb 2004 17:35:03 -0000 1.4 --- radio.py 18 Jul 2004 05:56:09 -0000 1.5 *************** *** 10,14 **** while 1: ! data, wherefrom = s.recvfrom(1500, 0) ! sys.stderr.write(repr(wherefrom) + '\n') ! sys.stdout.write(data) --- 10,14 ---- while 1: ! data, wherefrom = s.recvfrom(1500, 0) ! sys.stderr.write(repr(wherefrom) + '\n') ! sys.stdout.write(data) Index: rpython.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/sockets/rpython.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** rpython.py 27 Nov 1996 19:50:43 -0000 1.2 --- rpython.py 18 Jul 2004 05:56:09 -0000 1.3 *************** *** 12,35 **** def main(): ! if len(sys.argv) < 3: ! print "usage: rpython host command" ! sys.exit(2) ! host = sys.argv[1] ! port = PORT ! i = string.find(host, ':') ! if i >= 0: ! port = string.atoi(port[i+1:]) ! host = host[:i] ! command = string.join(sys.argv[2:]) ! s = socket(AF_INET, SOCK_STREAM) ! s.connect((host, port)) ! s.send(command) ! s.shutdown(1) ! reply = '' ! while 1: ! data = s.recv(BUFSIZE) ! if not data: break ! reply = reply + data ! print reply, main() --- 12,35 ---- def main(): ! if len(sys.argv) < 3: ! print "usage: rpython host command" ! sys.exit(2) ! host = sys.argv[1] ! port = PORT ! i = string.find(host, ':') ! if i >= 0: ! port = string.atoi(port[i+1:]) ! host = host[:i] ! command = string.join(sys.argv[2:]) ! s = socket(AF_INET, SOCK_STREAM) ! s.connect((host, port)) ! s.send(command) ! s.shutdown(1) ! reply = '' ! while 1: ! data = s.recv(BUFSIZE) ! if not data: break ! reply = reply + data ! print reply, main() Index: rpythond.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/sockets/rpythond.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** rpythond.py 25 Aug 2000 15:38:41 -0000 1.3 --- rpythond.py 18 Jul 2004 05:56:09 -0000 1.4 *************** *** 15,52 **** def main(): ! if len(sys.argv) > 1: ! port = int(eval(sys.argv[1])) ! else: ! port = PORT ! s = socket(AF_INET, SOCK_STREAM) ! s.bind(('', port)) ! s.listen(1) ! while 1: ! conn, (remotehost, remoteport) = s.accept() ! print 'connected by', remotehost, remoteport ! request = '' ! while 1: ! data = conn.recv(BUFSIZE) ! if not data: ! break ! request = request + data ! reply = execute(request) ! conn.send(reply) ! conn.close() def execute(request): ! stdout = sys.stdout ! stderr = sys.stderr ! sys.stdout = sys.stderr = fakefile = StringIO.StringIO() ! try: ! try: ! exec request in {}, {} ! except: ! print ! traceback.print_exc(100) ! finally: ! sys.stderr = stderr ! sys.stdout = stdout ! return fakefile.getvalue() main() --- 15,52 ---- def main(): ! if len(sys.argv) > 1: ! port = int(eval(sys.argv[1])) ! else: ! port = PORT ! s = socket(AF_INET, SOCK_STREAM) ! s.bind(('', port)) ! s.listen(1) ! while 1: ! conn, (remotehost, remoteport) = s.accept() ! print 'connected by', remotehost, remoteport ! request = '' ! while 1: ! data = conn.recv(BUFSIZE) ! if not data: ! break ! request = request + data ! reply = execute(request) ! conn.send(reply) ! conn.close() def execute(request): ! stdout = sys.stdout ! stderr = sys.stderr ! sys.stdout = sys.stderr = fakefile = StringIO.StringIO() ! try: ! try: ! exec request in {}, {} ! except: ! print ! traceback.print_exc(100) ! finally: ! sys.stderr = stderr ! sys.stdout = stdout ! return fakefile.getvalue() main() Index: telnet.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/sockets/telnet.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** telnet.py 12 Feb 2004 17:35:03 -0000 1.6 --- telnet.py 18 Jul 2004 05:56:09 -0000 1.7 *************** *** 21,25 **** # Telnet protocol characters ! IAC = chr(255) # Interpret as command DONT = chr(254) DO = chr(253) --- 21,25 ---- # Telnet protocol characters ! IAC = chr(255) # Interpret as command DONT = chr(254) DO = chr(253) *************** *** 28,109 **** def main(): ! host = sys.argv[1] ! try: ! hostaddr = gethostbyname(host) ! except error: ! sys.stderr.write(sys.argv[1] + ': bad host name\n') ! sys.exit(2) ! # ! if len(sys.argv) > 2: ! servname = sys.argv[2] ! else: ! servname = 'telnet' ! # ! if '0' <= servname[:1] <= '9': ! port = eval(servname) ! else: ! try: ! port = getservbyname(servname, 'tcp') ! except error: ! sys.stderr.write(servname + ': bad tcp service name\n') ! sys.exit(2) ! # ! s = socket(AF_INET, SOCK_STREAM) ! # ! try: ! s.connect((host, port)) ! except error, msg: ! sys.stderr.write('connect failed: ' + repr(msg) + '\n') ! sys.exit(1) ! # ! pid = posix.fork() ! # ! if pid == 0: ! # child -- read stdin, write socket ! while 1: ! line = sys.stdin.readline() ! s.send(line) ! else: ! # parent -- read socket, write stdout ! iac = 0 # Interpret next char as command ! opt = '' # Interpret next char as option ! while 1: ! data = s.recv(BUFSIZE) ! if not data: ! # EOF; kill child and exit ! sys.stderr.write( '(Closed by remote host)\n') ! posix.kill(pid, 9) ! sys.exit(1) ! cleandata = '' ! for c in data: ! if opt: ! print ord(c) ! s.send(opt + c) ! opt = '' ! elif iac: ! iac = 0 ! if c == IAC: ! cleandata = cleandata + c ! elif c in (DO, DONT): ! if c == DO: print '(DO)', ! else: print '(DONT)', ! opt = IAC + WONT ! elif c in (WILL, WONT): ! if c == WILL: print '(WILL)', ! else: print '(WONT)', ! opt = IAC + DONT ! else: ! print '(command)', ord(c) ! elif c == IAC: ! iac = 1 ! print '(IAC)', ! else: ! cleandata = cleandata + c ! sys.stdout.write(cleandata) ! sys.stdout.flush() try: ! main() except KeyboardInterrupt: ! pass --- 28,109 ---- def main(): ! host = sys.argv[1] ! try: ! hostaddr = gethostbyname(host) ! except error: ! sys.stderr.write(sys.argv[1] + ': bad host name\n') ! sys.exit(2) ! # ! if len(sys.argv) > 2: ! servname = sys.argv[2] ! else: ! servname = 'telnet' ! # ! if '0' <= servname[:1] <= '9': ! port = eval(servname) ! else: ! try: ! port = getservbyname(servname, 'tcp') ! except error: ! sys.stderr.write(servname + ': bad tcp service name\n') ! sys.exit(2) ! # ! s = socket(AF_INET, SOCK_STREAM) ! # ! try: ! s.connect((host, port)) ! except error, msg: ! sys.stderr.write('connect failed: ' + repr(msg) + '\n') ! sys.exit(1) ! # ! pid = posix.fork() ! # ! if pid == 0: ! # child -- read stdin, write socket ! while 1: ! line = sys.stdin.readline() ! s.send(line) ! else: ! # parent -- read socket, write stdout ! iac = 0 # Interpret next char as command ! opt = '' # Interpret next char as option ! while 1: ! data = s.recv(BUFSIZE) ! if not data: ! # EOF; kill child and exit ! sys.stderr.write( '(Closed by remote host)\n') ! posix.kill(pid, 9) ! sys.exit(1) ! cleandata = '' ! for c in data: ! if opt: ! print ord(c) ! s.send(opt + c) ! opt = '' ! elif iac: ! iac = 0 ! if c == IAC: ! cleandata = cleandata + c ! elif c in (DO, DONT): ! if c == DO: print '(DO)', ! else: print '(DONT)', ! opt = IAC + WONT ! elif c in (WILL, WONT): ! if c == WILL: print '(WILL)', ! else: print '(WONT)', ! opt = IAC + DONT ! else: ! print '(command)', ord(c) ! elif c == IAC: ! iac = 1 ! print '(IAC)', ! else: ! cleandata = cleandata + c ! sys.stdout.write(cleandata) ! sys.stdout.flush() try: ! main() except KeyboardInterrupt: ! pass Index: throughput.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/sockets/throughput.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** throughput.py 25 Aug 2000 15:38:41 -0000 1.6 --- throughput.py 18 Jul 2004 05:56:09 -0000 1.7 *************** *** 4,9 **** # # Usage: ! # 1) on host_A: throughput -s [port] # start a server ! # 2) on host_B: throughput -c count host_A [port] # start a client # # The server will service multiple clients until it is killed. --- 4,9 ---- # # Usage: ! # 1) on host_A: throughput -s [port] # start a server ! # 2) on host_B: throughput -c count host_A [port] # start a client # # The server will service multiple clients until it is killed. *************** *** 22,92 **** def main(): ! if len(sys.argv) < 2: ! usage() ! if sys.argv[1] == '-s': ! server() ! elif sys.argv[1] == '-c': ! client() ! else: ! usage() def usage(): ! sys.stdout = sys.stderr ! print 'Usage: (on host_A) throughput -s [port]' ! print 'and then: (on host_B) throughput -c count host_A [port]' ! sys.exit(2) def server(): ! if len(sys.argv) > 2: ! port = eval(sys.argv[2]) ! else: ! port = MY_PORT ! s = socket(AF_INET, SOCK_STREAM) ! s.bind(('', port)) ! s.listen(1) ! print 'Server ready...' ! while 1: ! conn, (host, remoteport) = s.accept() ! while 1: ! data = conn.recv(BUFSIZE) ! if not data: ! break ! del data ! conn.send('OK\n') ! conn.close() ! print 'Done with', host, 'port', remoteport def client(): ! if len(sys.argv) < 4: ! usage() ! count = int(eval(sys.argv[2])) ! host = sys.argv[3] ! if len(sys.argv) > 4: ! port = eval(sys.argv[4]) ! else: ! port = MY_PORT ! testdata = 'x' * (BUFSIZE-1) + '\n' ! t1 = time.time() ! s = socket(AF_INET, SOCK_STREAM) ! t2 = time.time() ! s.connect((host, port)) ! t3 = time.time() ! i = 0 ! while i < count: ! i = i+1 ! s.send(testdata) ! s.shutdown(1) # Send EOF ! t4 = time.time() ! data = s.recv(BUFSIZE) ! t5 = time.time() ! print data ! print 'Raw timers:', t1, t2, t3, t4, t5 ! print 'Intervals:', t2-t1, t3-t2, t4-t3, t5-t4 ! print 'Total:', t5-t1 ! print 'Throughput:', round((BUFSIZE*count*0.001) / (t5-t1), 3), ! print 'K/sec.' --- 22,92 ---- def main(): ! if len(sys.argv) < 2: ! usage() ! if sys.argv[1] == '-s': ! server() ! elif sys.argv[1] == '-c': ! client() ! else: ! usage() def usage(): ! sys.stdout = sys.stderr ! print 'Usage: (on host_A) throughput -s [port]' ! print 'and then: (on host_B) throughput -c count host_A [port]' ! sys.exit(2) def server(): ! if len(sys.argv) > 2: ! port = eval(sys.argv[2]) ! else: ! port = MY_PORT ! s = socket(AF_INET, SOCK_STREAM) ! s.bind(('', port)) ! s.listen(1) ! print 'Server ready...' ! while 1: ! conn, (host, remoteport) = s.accept() ! while 1: ! data = conn.recv(BUFSIZE) ! if not data: ! break ! del data ! conn.send('OK\n') ! conn.close() ! print 'Done with', host, 'port', remoteport def client(): ! if len(sys.argv) < 4: ! usage() ! count = int(eval(sys.argv[2])) ! host = sys.argv[3] ! if len(sys.argv) > 4: ! port = eval(sys.argv[4]) ! else: ! port = MY_PORT ! testdata = 'x' * (BUFSIZE-1) + '\n' ! t1 = time.time() ! s = socket(AF_INET, SOCK_STREAM) ! t2 = time.time() ! s.connect((host, port)) ! t3 = time.time() ! i = 0 ! while i < count: ! i = i+1 ! s.send(testdata) ! s.shutdown(1) # Send EOF ! t4 = time.time() ! data = s.recv(BUFSIZE) ! t5 = time.time() ! print data ! print 'Raw timers:', t1, t2, t3, t4, t5 ! print 'Intervals:', t2-t1, t3-t2, t4-t3, t5-t4 ! print 'Total:', t5-t1 ! print 'Throughput:', round((BUFSIZE*count*0.001) / (t5-t1), 3), ! print 'K/sec.' Index: udpecho.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/sockets/udpecho.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** udpecho.py 12 Feb 2004 17:35:03 -0000 1.6 --- udpecho.py 18 Jul 2004 05:56:09 -0000 1.7 *************** *** 13,63 **** def main(): ! if len(sys.argv) < 2: ! usage() ! if sys.argv[1] == '-s': ! server() ! elif sys.argv[1] == '-c': ! client() ! else: ! usage() def usage(): ! sys.stdout = sys.stderr ! print 'Usage: udpecho -s [port] (server)' ! print 'or: udpecho -c host [port] 2: ! port = eval(sys.argv[2]) ! else: ! port = ECHO_PORT ! s = socket(AF_INET, SOCK_DGRAM) ! s.bind(('', port)) ! print 'udp echo server ready' ! while 1: ! data, addr = s.recvfrom(BUFSIZE) ! print 'server received %r from %r' % (data, addr) ! s.sendto(data, addr) def client(): ! if len(sys.argv) < 3: ! usage() ! host = sys.argv[2] ! if len(sys.argv) > 3: ! port = eval(sys.argv[3]) ! else: ! port = ECHO_PORT ! addr = host, port ! s = socket(AF_INET, SOCK_DGRAM) ! s.bind(('', 0)) ! print 'udp echo client ready, reading stdin' ! while 1: ! line = sys.stdin.readline() ! if not line: ! break ! s.sendto(line, addr) ! data, fromaddr = s.recvfrom(BUFSIZE) ! print 'client received %r from %r' % (data, fromaddr) main() --- 13,63 ---- def main(): ! if len(sys.argv) < 2: ! usage() ! if sys.argv[1] == '-s': ! server() ! elif sys.argv[1] == '-c': ! client() ! else: ! usage() def usage(): ! sys.stdout = sys.stderr ! print 'Usage: udpecho -s [port] (server)' ! print 'or: udpecho -c host [port] 2: ! port = eval(sys.argv[2]) ! else: ! port = ECHO_PORT ! s = socket(AF_INET, SOCK_DGRAM) ! s.bind(('', port)) ! print 'udp echo server ready' ! while 1: ! data, addr = s.recvfrom(BUFSIZE) ! print 'server received %r from %r' % (data, addr) ! s.sendto(data, addr) def client(): ! if len(sys.argv) < 3: ! usage() ! host = sys.argv[2] ! if len(sys.argv) > 3: ! port = eval(sys.argv[3]) ! else: ! port = ECHO_PORT ! addr = host, port ! s = socket(AF_INET, SOCK_DGRAM) ! s.bind(('', 0)) ! print 'udp echo client ready, reading stdin' ! while 1: ! line = sys.stdin.readline() ! if not line: ! break ! s.sendto(line, addr) ! data, fromaddr = s.recvfrom(BUFSIZE) ! print 'client received %r from %r' % (data, fromaddr) main() From tim_one at users.sourceforge.net Sun Jul 18 07:56:39 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 07:56:41 2004 Subject: [Python-checkins] python/dist/src setup.py,1.192,1.193 Message-ID: Update of /cvsroot/python/python/dist/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28702 Modified Files: setup.py Log Message: Whitespace normalization. Ran reindent.py over the entire source tree. Index: setup.py =================================================================== RCS file: /cvsroot/python/python/dist/src/setup.py,v retrieving revision 1.192 retrieving revision 1.193 diff -C2 -d -r1.192 -r1.193 *** setup.py 18 Jul 2004 03:06:26 -0000 1.192 --- setup.py 18 Jul 2004 05:56:06 -0000 1.193 *************** *** 346,350 **** else: locale_extra_link_args = [] ! exts.append( Extension('_locale', ['_localemodule.c'], --- 346,350 ---- else: locale_extra_link_args = [] ! exts.append( Extension('_locale', ['_localemodule.c'], From tim_one at users.sourceforge.net Sun Jul 18 07:56:39 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 07:56:45 2004 Subject: [Python-checkins] python/dist/src/Demo/md5test md5driver.py, 1.4, 1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Demo/md5test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28702/Demo/md5test Modified Files: md5driver.py Log Message: Whitespace normalization. Ran reindent.py over the entire source tree. Index: md5driver.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/md5test/md5driver.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** md5driver.py 24 Apr 2003 17:27:53 -0000 1.4 --- md5driver.py 18 Jul 2004 05:56:07 -0000 1.5 *************** *** 7,12 **** for i in str: o = ord(i) ! outstr = (outstr ! + string.hexdigits[(o >> 4) & 0xF] + string.hexdigits[o & 0xF]) print outstr, --- 7,12 ---- for i in str: o = ord(i) ! outstr = (outstr ! + string.hexdigits[(o >> 4) & 0xF] + string.hexdigits[o & 0xF]) print outstr, *************** *** 98,103 **** MDString('message digest') MDString(makestr(ord('a'), ord('z'))) ! MDString(makestr(ord('A'), ord('Z')) ! + makestr(ord('a'), ord('z')) + makestr(ord('0'), ord('9'))) MDString((makestr(ord('1'), ord('9')) + '0') * 8) --- 98,103 ---- MDString('message digest') MDString(makestr(ord('a'), ord('z'))) ! MDString(makestr(ord('A'), ord('Z')) ! + makestr(ord('a'), ord('z')) + makestr(ord('0'), ord('9'))) MDString((makestr(ord('1'), ord('9')) + '0') * 8) From tim_one at users.sourceforge.net Sun Jul 18 07:56:40 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 07:56:46 2004 Subject: [Python-checkins] python/dist/src/Demo/metaclasses Eiffel.py, 1.4, 1.5 Meta.py, 1.5, 1.6 Synch.py, 1.2, 1.3 Trace.py, 1.4, 1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Demo/metaclasses In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28702/Demo/metaclasses Modified Files: Eiffel.py Meta.py Synch.py Trace.py Log Message: Whitespace normalization. Ran reindent.py over the entire source tree. Index: Eiffel.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/metaclasses/Eiffel.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Eiffel.py 11 Jul 2002 20:22:11 -0000 1.4 --- Eiffel.py 18 Jul 2004 05:56:07 -0000 1.5 *************** *** 88,92 **** apply(self.post, (Result,) + args, kw) return Result ! class EiffelHelper(MetaHelper): __methodwrapper__ = EiffelMethodWrapper --- 88,92 ---- apply(self.post, (Result,) + args, kw) return Result ! class EiffelHelper(MetaHelper): __methodwrapper__ = EiffelMethodWrapper From tim_one at users.sourceforge.net Sun Jul 18 07:56:39 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 07:56:47 2004 Subject: [Python-checkins] python/dist/src/Demo/curses life.py, 1.3, 1.4 ncurses.py, 1.2, 1.3 rain.py, 1.1, 1.2 tclock.py, 1.2, 1.3 xmas.py, 1.1, 1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Demo/curses In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28702/Demo/curses Modified Files: life.py ncurses.py rain.py tclock.py xmas.py Log Message: Whitespace normalization. Ran reindent.py over the entire source tree. Index: life.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/curses/life.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** life.py 10 Apr 2002 14:50:16 -0000 1.3 --- life.py 18 Jul 2004 05:56:07 -0000 1.4 *************** *** 12,16 **** # Space or Enter : Toggle the contents of the cursor's position # ! # TODO : # Support the mouse # Use colour if available --- 12,16 ---- # Space or Enter : Toggle the contents of the cursor's position # ! # TODO : # Support the mouse # Use colour if available *************** *** 27,35 **** X,Y : horizontal and vertical size of the board state : dictionary mapping (x,y) to 0 or 1 ! Methods: ! display(update_board) -- If update_board is true, compute the next generation. Then display the state ! of the board and refresh the screen. erase() -- clear the entire board makeRandom() -- fill the board randomly --- 27,35 ---- X,Y : horizontal and vertical size of the board state : dictionary mapping (x,y) to 0 or 1 ! Methods: ! display(update_board) -- If update_board is true, compute the next generation. Then display the state ! of the board and refresh the screen. erase() -- clear the entire board makeRandom() -- fill the board randomly *************** *** 40,127 **** """ def __init__(self, scr, char=ord('*')): ! """Create a new LifeBoard instance. ! scr -- curses screen object to use for display ! char -- character used to render live cells (default: '*') ! """ ! self.state={} ; self.scr=scr ! Y, X = self.scr.getmaxyx() ! self.X, self.Y = X-2, Y-2-1 ! self.char = char ! self.scr.clear() ! # Draw a border around the board ! border_line='+'+(self.X*'-')+'+' ! self.scr.addstr(0, 0, border_line) ! self.scr.addstr(self.Y+1,0, border_line) ! for y in range(0, self.Y): ! self.scr.addstr(1+y, 0, '|') ! self.scr.addstr(1+y, self.X+1, '|') ! self.scr.refresh() ! def set(self, y, x): ! """Set a cell to the live state""" ! if x<0 or self.X<=x or y<0 or self.Y<=y: ! raise ValueError, "Coordinates out of range %i,%i"% (y,x) ! self.state[x,y] = 1 ! def toggle(self, y, x): ! """Toggle a cell's state between live and dead""" ! if x<0 or self.X<=x or y<0 or self.Y<=y: ! raise ValueError, "Coordinates out of range %i,%i"% (y,x) ! if self.state.has_key( (x,y) ): ! del self.state[x,y] ! self.scr.addch(y+1, x+1, ' ') ! else: ! self.state[x,y]=1 ! self.scr.addch(y+1, x+1, self.char) ! self.scr.refresh() def erase(self): ! """Clear the entire board and update the board display""" ! self.state={} ! self.display(update_board=0) def display(self, update_board=1): ! """Display the whole board, optionally computing one generation""" ! M,N = self.X, self.Y ! if not update_board: ! for i in range(0, M): ! for j in range(0, N): ! if self.state.has_key( (i,j) ): ! self.scr.addch(j+1, i+1, self.char) ! else: ! self.scr.addch(j+1, i+1, ' ') ! self.scr.refresh() ! return ! d={} ; self.boring=1 ! for i in range(0, M): ! L=range( max(0, i-1), min(M, i+2) ) ! for j in range(0, N): ! s=0 ! live=self.state.has_key( (i,j) ) ! for k in range( max(0, j-1), min(N, j+2) ): ! for l in L: ! if self.state.has_key( (l,k) ): ! s=s+1 ! s=s-live ! if s==3: ! # Birth ! d[i,j]=1 ! self.scr.addch(j+1, i+1, self.char) ! if not live: self.boring=0 ! elif s==2 and live: d[i,j]=1 # Survival ! elif live: ! # Death ! self.scr.addch(j+1, i+1, ' ') ! self.boring=0 ! self.state=d ! self.scr.refresh() def makeRandom(self): ! "Fill the board with a random pattern" ! self.state={} ! for i in range(0, self.X): for j in range(0, self.Y): if random.random() > 0.5: self.set(j,i) --- 40,127 ---- """ def __init__(self, scr, char=ord('*')): ! """Create a new LifeBoard instance. ! scr -- curses screen object to use for display ! char -- character used to render live cells (default: '*') ! """ ! self.state={} ; self.scr=scr ! Y, X = self.scr.getmaxyx() ! self.X, self.Y = X-2, Y-2-1 ! self.char = char ! self.scr.clear() ! # Draw a border around the board ! border_line='+'+(self.X*'-')+'+' ! self.scr.addstr(0, 0, border_line) ! self.scr.addstr(self.Y+1,0, border_line) ! for y in range(0, self.Y): ! self.scr.addstr(1+y, 0, '|') ! self.scr.addstr(1+y, self.X+1, '|') ! self.scr.refresh() ! def set(self, y, x): ! """Set a cell to the live state""" ! if x<0 or self.X<=x or y<0 or self.Y<=y: ! raise ValueError, "Coordinates out of range %i,%i"% (y,x) ! self.state[x,y] = 1 ! def toggle(self, y, x): ! """Toggle a cell's state between live and dead""" ! if x<0 or self.X<=x or y<0 or self.Y<=y: ! raise ValueError, "Coordinates out of range %i,%i"% (y,x) ! if self.state.has_key( (x,y) ): ! del self.state[x,y] ! self.scr.addch(y+1, x+1, ' ') ! else: ! self.state[x,y]=1 ! self.scr.addch(y+1, x+1, self.char) ! self.scr.refresh() def erase(self): ! """Clear the entire board and update the board display""" ! self.state={} ! self.display(update_board=0) def display(self, update_board=1): ! """Display the whole board, optionally computing one generation""" ! M,N = self.X, self.Y ! if not update_board: ! for i in range(0, M): ! for j in range(0, N): ! if self.state.has_key( (i,j) ): ! self.scr.addch(j+1, i+1, self.char) ! else: ! self.scr.addch(j+1, i+1, ' ') ! self.scr.refresh() ! return ! d={} ; self.boring=1 ! for i in range(0, M): ! L=range( max(0, i-1), min(M, i+2) ) ! for j in range(0, N): ! s=0 ! live=self.state.has_key( (i,j) ) ! for k in range( max(0, j-1), min(N, j+2) ): ! for l in L: ! if self.state.has_key( (l,k) ): ! s=s+1 ! s=s-live ! if s==3: ! # Birth ! d[i,j]=1 ! self.scr.addch(j+1, i+1, self.char) ! if not live: self.boring=0 ! elif s==2 and live: d[i,j]=1 # Survival ! elif live: ! # Death ! self.scr.addch(j+1, i+1, ' ') ! self.boring=0 ! self.state=d ! self.scr.refresh() def makeRandom(self): ! "Fill the board with a random pattern" ! self.state={} ! for i in range(0, self.X): for j in range(0, self.Y): if random.random() > 0.5: self.set(j,i) *************** *** 150,154 **** # Allocate a subwindow for the Life board and create the board object ! subwin=stdscr.subwin(stdscr_y-3, stdscr_x, 0, 0) board=LifeBoard(subwin, char=ord('*')) board.display(update_board=0) --- 150,154 ---- # Allocate a subwindow for the Life board and create the board object ! subwin=stdscr.subwin(stdscr_y-3, stdscr_x, 0, 0) board=LifeBoard(subwin, char=ord('*')) board.display(update_board=0) *************** *** 159,223 **** # Main loop: while (1): ! stdscr.move(1+ypos, 1+xpos) # Move the cursor ! c=stdscr.getch() # Get a keystroke ! if 00: ypos=ypos-1 ! elif c==curses.KEY_DOWN and ypos0: xpos=xpos-1 ! elif c==curses.KEY_RIGHT and xpos0: ypos=ypos-1 ! elif c==curses.KEY_DOWN and ypos0: xpos=xpos-1 ! elif c==curses.KEY_RIGHT and xpos Update of /cvsroot/python/python/dist/src/Mac/Demo/applescript In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29056/Demo/applescript Modified Files: makedisk.py Log Message: Whitespace normalization, via reindent.py. Index: makedisk.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Demo/applescript/makedisk.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** makedisk.py 20 Aug 2000 21:57:30 -0000 1.1 --- makedisk.py 18 Jul 2004 05:58:04 -0000 1.2 *************** *** 7,15 **** filespec = macfs.FSSpec('my disk image.img') try: ! objref = talker.create('my disk image', saving_as=filespec, leave_image_mounted=1) except Disk_Copy.Error, arg: ! print "ERROR: my disk image:", arg else: ! print 'objref=', objref print 'Type return to exit-' sys.stdin.readline() --- 7,15 ---- filespec = macfs.FSSpec('my disk image.img') try: ! objref = talker.create('my disk image', saving_as=filespec, leave_image_mounted=1) except Disk_Copy.Error, arg: ! print "ERROR: my disk image:", arg else: ! print 'objref=', objref print 'Type return to exit-' sys.stdin.readline() From tim_one at users.sourceforge.net Sun Jul 18 07:58:37 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 07:58:43 2004 Subject: [Python-checkins] python/dist/src/Mac/Demo/example1 dnslookup-1.py, 1.4, 1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Demo/example1 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29056/Demo/example1 Modified Files: dnslookup-1.py Log Message: Whitespace normalization, via reindent.py. Index: dnslookup-1.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Demo/example1/dnslookup-1.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** dnslookup-1.py 27 Aug 2001 21:41:16 -0000 1.4 --- dnslookup-1.py 18 Jul 2004 05:58:05 -0000 1.5 *************** *** 33,37 **** tp, h, rect = my_dlg.GetDialogItem(ITEM_RESULT) ! Dlg.SetDialogItemText(h, dnslookup(txt)) elif n == ITEM_QUIT_BUTTON: break --- 33,37 ---- tp, h, rect = my_dlg.GetDialogItem(ITEM_RESULT) ! Dlg.SetDialogItemText(h, dnslookup(txt)) elif n == ITEM_QUIT_BUTTON: break *************** *** 55,57 **** main() - --- 55,56 ---- From tim_one at users.sourceforge.net Sun Jul 18 07:58:37 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 07:58:44 2004 Subject: [Python-checkins] python/dist/src/Mac/Demo/example0 checktext.py, 1.2, 1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Demo/example0 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29056/Demo/example0 Modified Files: checktext.py Log Message: Whitespace normalization, via reindent.py. Index: checktext.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Demo/example0/checktext.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** checktext.py 26 Jan 2003 20:35:37 -0000 1.2 --- checktext.py 18 Jul 2004 05:58:05 -0000 1.3 *************** *** 6,37 **** def main(): ! pathname = EasyDialogs.AskFileForOpen(message='File to check end-of-lines in:') ! if not pathname: ! sys.exit(0) ! fp = open(pathname, 'rb') ! try: ! data = fp.read() ! except MemoryError: ! EasyDialogs.Message('Sorry, file is too big.') ! sys.exit(0) ! if len(data) == 0: ! EasyDialogs.Message('File is empty.') ! sys.exit(0) ! number_cr = string.count(data, '\r') ! number_lf = string.count(data, '\n') ! if number_cr == number_lf == 0: ! EasyDialogs.Message('File contains no lines.') ! if number_cr == 0: ! EasyDialogs.Message('File has unix-style line endings') ! elif number_lf == 0: ! EasyDialogs.Message('File has mac-style line endings') ! elif number_cr == number_lf: ! EasyDialogs.Message('File probably has MSDOS-style line endings') ! else: ! EasyDialogs.Message('File has no recognizable line endings (binary file?)') ! sys.exit(0) ! if __name__ == '__main__': ! main() ! ! --- 6,35 ---- def main(): ! pathname = EasyDialogs.AskFileForOpen(message='File to check end-of-lines in:') ! if not pathname: ! sys.exit(0) ! fp = open(pathname, 'rb') ! try: ! data = fp.read() ! except MemoryError: ! EasyDialogs.Message('Sorry, file is too big.') ! sys.exit(0) ! if len(data) == 0: ! EasyDialogs.Message('File is empty.') ! sys.exit(0) ! number_cr = string.count(data, '\r') ! number_lf = string.count(data, '\n') ! if number_cr == number_lf == 0: ! EasyDialogs.Message('File contains no lines.') ! if number_cr == 0: ! EasyDialogs.Message('File has unix-style line endings') ! elif number_lf == 0: ! EasyDialogs.Message('File has mac-style line endings') ! elif number_cr == number_lf: ! EasyDialogs.Message('File probably has MSDOS-style line endings') ! else: ! EasyDialogs.Message('File has no recognizable line endings (binary file?)') ! sys.exit(0) ! if __name__ == '__main__': ! main() From tim_one at users.sourceforge.net Sun Jul 18 07:58:37 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 07:58:46 2004 Subject: [Python-checkins] python/dist/src/Mac/Demo/calldll testcalldll.py, 1.3, 1.4 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Demo/calldll In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29056/Demo/calldll Modified Files: testcalldll.py Log Message: Whitespace normalization, via reindent.py. Index: testcalldll.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Demo/calldll/testcalldll.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** testcalldll.py 12 Feb 2004 17:35:12 -0000 1.3 --- testcalldll.py 18 Jul 2004 05:58:04 -0000 1.4 *************** *** 9,22 **** lib = calldll.getdiskfragment(fss, 'calldll.ppc.slb') ! cdll_b_bbbbbbbb = calldll.newcall(lib.cdll_b_bbbbbbbb, 'Byte', 'InByte', 'InByte', ! 'InByte', 'InByte','InByte', 'InByte','InByte', 'InByte') ! cdll_h_hhhhhhhh = calldll.newcall(lib.cdll_h_hhhhhhhh, 'Short', 'InShort', 'InShort', ! 'InShort', 'InShort','InShort', 'InShort','InShort', 'InShort') ! cdll_l_llllllll = calldll.newcall(lib.cdll_l_llllllll, 'Long', 'InLong', 'InLong', ! 'InLong', 'InLong','InLong', 'InLong','InLong', 'InLong') ! cdll_N_ssssssss = calldll.newcall(lib.cdll_N_ssssssss, 'None', 'InString', 'InString', ! 'InString', 'InString', 'InString', 'InString', 'InString', 'InString') ! cdll_o_l = calldll.newcall(lib.cdll_o_l, 'OSErr', 'InLong') --- 9,22 ---- lib = calldll.getdiskfragment(fss, 'calldll.ppc.slb') ! cdll_b_bbbbbbbb = calldll.newcall(lib.cdll_b_bbbbbbbb, 'Byte', 'InByte', 'InByte', ! 'InByte', 'InByte','InByte', 'InByte','InByte', 'InByte') ! cdll_h_hhhhhhhh = calldll.newcall(lib.cdll_h_hhhhhhhh, 'Short', 'InShort', 'InShort', ! 'InShort', 'InShort','InShort', 'InShort','InShort', 'InShort') ! cdll_l_llllllll = calldll.newcall(lib.cdll_l_llllllll, 'Long', 'InLong', 'InLong', ! 'InLong', 'InLong','InLong', 'InLong','InLong', 'InLong') ! cdll_N_ssssssss = calldll.newcall(lib.cdll_N_ssssssss, 'None', 'InString', 'InString', ! 'InString', 'InString', 'InString', 'InString', 'InString', 'InString') ! cdll_o_l = calldll.newcall(lib.cdll_o_l, 'OSErr', 'InLong') *************** *** 31,125 **** rv = cdll_b_bbbbbbbb(1, 2, 3, 4, 5, 6, 7, 8) if rv == 36: ! print 'ok.' else: ! print 'Failed, returned', rv ! print 'Test cdll_b_bbbbbbbb negative' rv = cdll_b_bbbbbbbb(-1, -2, -3, -4, -5, -6, -7, -8) if rv == -36: ! print 'ok.' else: ! print 'Failed, returned', rv print 'Test cdll_h_hhhhhhhh' rv = cdll_h_hhhhhhhh(1, 2, 3, 4, 5, 6, 7, 8) if rv == 36: ! print 'ok.' else: ! print 'Failed, returned', rv ! print 'Test cdll_h_hhhhhhhh negative' rv = cdll_h_hhhhhhhh(-1, -2, -3, -4, -5, -6, -7, -8) if rv == -36: ! print 'ok.' else: ! print 'Failed, returned', rv print 'Test cdll_l_llllllll' rv = cdll_l_llllllll(1, 2, 3, 4, 5, 6, 7, 8) if rv == 36: ! print 'ok.' else: ! print 'Failed, returned', rv ! print 'Test cdll_l_llllllll negative' rv = cdll_l_llllllll(-1, -2, -3, -4, -5, -6, -7, -8) if rv == -36: ! print 'ok.' else: ! print 'Failed, returned', rv ! print 'Test cdll_N_ssssssss' print 'Should print one two three four five six seven eight' rv = cdll_N_ssssssss('one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight') if rv == None: ! print 'ok.' else: ! print 'Failed, returned', rv ! print 'Test cdll_o_l(0)' rv = cdll_o_l(0) if rv == None: ! print 'ok.' else: ! print 'Error, returned', rv ! print 'Test cdll_o_l(-100)' try: ! rv = cdll_o_l(-100) ! print 'Error, did not raise exception, returned', rv except MacOS.Error, arg: ! if arg[0] == -100: ! print 'ok.' ! else: ! print 'Error, returned incorrect exception arg:', arg[0] ! print 'Test cdll_N_pp' rv = cdll_N_pp('pascal string') if rv == 'Was: pascal string': ! print 'ok.' else: ! print 'Failed, returned', repr(rv) ! print 'Test cdll_N_bb' rv = cdll_N_bb(-100) if rv == -100: ! print 'ok.' else: ! print 'Failed, returned', rv ! print 'Test cdll_N_hh' rv = cdll_N_hh(-100) if rv == -100: ! print 'ok.' else: ! print 'Failed, returned', rv ! print 'Test cdll_N_ll' rv = cdll_N_ll(-100) if rv == -100: ! print 'ok.' else: ! print 'Failed, returned', rv print 'Test cdll_N_sH' --- 31,125 ---- rv = cdll_b_bbbbbbbb(1, 2, 3, 4, 5, 6, 7, 8) if rv == 36: ! print 'ok.' else: ! print 'Failed, returned', rv ! print 'Test cdll_b_bbbbbbbb negative' rv = cdll_b_bbbbbbbb(-1, -2, -3, -4, -5, -6, -7, -8) if rv == -36: ! print 'ok.' else: ! print 'Failed, returned', rv print 'Test cdll_h_hhhhhhhh' rv = cdll_h_hhhhhhhh(1, 2, 3, 4, 5, 6, 7, 8) if rv == 36: ! print 'ok.' else: ! print 'Failed, returned', rv ! print 'Test cdll_h_hhhhhhhh negative' rv = cdll_h_hhhhhhhh(-1, -2, -3, -4, -5, -6, -7, -8) if rv == -36: ! print 'ok.' else: ! print 'Failed, returned', rv print 'Test cdll_l_llllllll' rv = cdll_l_llllllll(1, 2, 3, 4, 5, 6, 7, 8) if rv == 36: ! print 'ok.' else: ! print 'Failed, returned', rv ! print 'Test cdll_l_llllllll negative' rv = cdll_l_llllllll(-1, -2, -3, -4, -5, -6, -7, -8) if rv == -36: ! print 'ok.' else: ! print 'Failed, returned', rv ! print 'Test cdll_N_ssssssss' print 'Should print one two three four five six seven eight' rv = cdll_N_ssssssss('one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight') if rv == None: ! print 'ok.' else: ! print 'Failed, returned', rv ! print 'Test cdll_o_l(0)' rv = cdll_o_l(0) if rv == None: ! print 'ok.' else: ! print 'Error, returned', rv ! print 'Test cdll_o_l(-100)' try: ! rv = cdll_o_l(-100) ! print 'Error, did not raise exception, returned', rv except MacOS.Error, arg: ! if arg[0] == -100: ! print 'ok.' ! else: ! print 'Error, returned incorrect exception arg:', arg[0] ! print 'Test cdll_N_pp' rv = cdll_N_pp('pascal string') if rv == 'Was: pascal string': ! print 'ok.' else: ! print 'Failed, returned', repr(rv) ! print 'Test cdll_N_bb' rv = cdll_N_bb(-100) if rv == -100: ! print 'ok.' else: ! print 'Failed, returned', rv ! print 'Test cdll_N_hh' rv = cdll_N_hh(-100) if rv == -100: ! print 'ok.' else: ! print 'Failed, returned', rv ! print 'Test cdll_N_ll' rv = cdll_N_ll(-100) if rv == -100: ! print 'ok.' else: ! print 'Failed, returned', rv print 'Test cdll_N_sH' *************** *** 127,132 **** rv = cdll_N_sH('new data', h) if rv == None and h.data == 'new data': ! print 'ok.' else: ! print 'Failed, rv is', rv, 'and handle data is', repr(rv.data) sys.exit(1) --- 127,132 ---- rv = cdll_N_sH('new data', h) if rv == None and h.data == 'new data': ! print 'ok.' else: ! print 'Failed, rv is', rv, 'and handle data is', repr(rv.data) sys.exit(1) From tim_one at users.sourceforge.net Sun Jul 18 07:58:37 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 07:58:47 2004 Subject: [Python-checkins] python/dist/src/Mac/Demo/example2 dnslookup-2.py, 1.5, 1.6 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Demo/example2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29056/Demo/example2 Modified Files: dnslookup-2.py Log Message: Whitespace normalization, via reindent.py. Index: dnslookup-2.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Demo/example2/dnslookup-2.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** dnslookup-2.py 27 Aug 2001 21:41:08 -0000 1.5 --- dnslookup-2.py 18 Jul 2004 05:58:05 -0000 1.6 *************** *** 19,26 **** macresource.need("DLOG", ID_MAIN, "dnslookup-2.rsrc") DNSLookup() ! class DNSLookup(FrameWork.Application): "Application class for DNS Lookup" ! def __init__(self): # First init menus, etc. --- 19,26 ---- macresource.need("DLOG", ID_MAIN, "dnslookup-2.rsrc") DNSLookup() ! class DNSLookup(FrameWork.Application): "Application class for DNS Lookup" ! def __init__(self): # First init menus, etc. *************** *** 32,43 **** # Finally, go into the event loop self.mainloop() ! def makeusermenus(self): self.filemenu = m = FrameWork.Menu(self.menubar, "File") self.quititem = FrameWork.MenuItem(m, "Quit", "Q", self.quit) ! def quit(self, *args): self._quit() ! def do_about(self, *args): f = Dlg.GetNewDialog(ID_ABOUT, -1) --- 32,43 ---- # Finally, go into the event loop self.mainloop() ! def makeusermenus(self): self.filemenu = m = FrameWork.Menu(self.menubar, "File") self.quititem = FrameWork.MenuItem(m, "Quit", "Q", self.quit) ! def quit(self, *args): self._quit() ! def do_about(self, *args): f = Dlg.GetNewDialog(ID_ABOUT, -1) *************** *** 46,50 **** if n == 1: return ! class MyDialog(FrameWork.DialogWindow): "Main dialog window for DNSLookup" --- 46,50 ---- if n == 1: return ! class MyDialog(FrameWork.DialogWindow): "Main dialog window for DNSLookup" *************** *** 52,56 **** FrameWork.DialogWindow.__init__(self, parent) self.parent = parent ! def do_itemhit(self, item, event): if item == ITEM_LOOKUP_BUTTON: --- 52,56 ---- FrameWork.DialogWindow.__init__(self, parent) self.parent = parent ! def do_itemhit(self, item, event): if item == ITEM_LOOKUP_BUTTON: *************** *** 65,69 **** tp, h, rect = self.dlg.GetDialogItem(ITEM_RESULT) Dlg.SetDialogItemText(h, self.dnslookup(txt)) ! def dnslookup(self, str): """ Perform DNS lookup on str. If first character of digit is numeric, --- 65,69 ---- tp, h, rect = self.dlg.GetDialogItem(ITEM_RESULT) Dlg.SetDialogItemText(h, self.dnslookup(txt)) ! def dnslookup(self, str): """ Perform DNS lookup on str. If first character of digit is numeric, From tim_one at users.sourceforge.net Sun Jul 18 07:58:37 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 07:58:49 2004 Subject: [Python-checkins] python/dist/src/Mac/Demo/PICTbrowse ICONbrowse.py, 1.10, 1.11 PICTbrowse.py, 1.11, 1.12 PICTbrowse2.py, 1.12, 1.13 cicnbrowse.py, 1.9, 1.10 oldPICTbrowse.py, 1.7, 1.8 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Demo/PICTbrowse In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29056/Demo/PICTbrowse Modified Files: ICONbrowse.py PICTbrowse.py PICTbrowse2.py cicnbrowse.py oldPICTbrowse.py Log Message: Whitespace normalization, via reindent.py. Index: ICONbrowse.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Demo/PICTbrowse/ICONbrowse.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** ICONbrowse.py 12 Feb 2004 17:35:12 -0000 1.10 --- ICONbrowse.py 18 Jul 2004 05:58:03 -0000 1.11 *************** *** 28,163 **** def main(): ! macresource.need('DLOG', ID_MAIN, "PICTbrowse.rsrc") ! ICONbrowse() class ICONbrowse(FrameWork.Application): ! def __init__(self): ! # First init menus, etc. ! FrameWork.Application.__init__(self) ! # Next create our dialog ! self.main_dialog = MyDialog(self) ! # Now open the dialog ! contents = self.findICONresources() ! self.main_dialog.open(ID_MAIN, contents) ! # Finally, go into the event loop ! self.mainloop() ! ! def makeusermenus(self): ! self.filemenu = m = FrameWork.Menu(self.menubar, "File") ! self.quititem = FrameWork.MenuItem(m, "Quit", "Q", self.quit) ! ! def quit(self, *args): ! self._quit() ! ! def showICON(self, resid): ! w = ICONwindow(self) ! w.open(resid) ! #EasyDialogs.Message('Show ICON %r' % (resid,)) ! ! def findICONresources(self): ! num = Res.CountResources('ICON') ! rv = [] ! for i in range(1, num+1): ! Res.SetResLoad(0) ! try: ! r = Res.GetIndResource('ICON', i) ! finally: ! Res.SetResLoad(1) ! id, type, name = r.GetResInfo() ! rv.append((id, name)) ! return rv ! class ICONwindow(FrameWork.Window): ! def open(self, (resid, resname)): ! if not resname: ! resname = '#%r' % (resid,) ! self.resid = resid ! self.picture = Icn.GetIcon(self.resid) ! l, t, r, b = 0, 0, 32, 32 ! self.pictrect = (l, t, r, b) ! width = r-l ! height = b-t ! if width < MINWIDTH: width = MINWIDTH ! elif width > MAXWIDTH: width = MAXWIDTH ! if height < MINHEIGHT: height = MINHEIGHT ! elif height > MAXHEIGHT: height = MAXHEIGHT ! bounds = (LEFT, TOP, LEFT+width, TOP+height) ! ! self.wid = Win.NewWindow(bounds, resname, 1, 0, -1, 1, 0) ! self.do_postopen() ! ! def do_update(self, *args): ! currect = self.fitrect() ! Icn.PlotIcon(currect, self.picture) ! ! def fitrect(self): ! """Return self.pictrect scaled to fit in window""" ! graf = self.wid.GetWindowPort() ! screenrect = graf.GetPortBounds() ! picwidth = self.pictrect[2] - self.pictrect[0] ! picheight = self.pictrect[3] - self.pictrect[1] ! if picwidth > screenrect[2] - screenrect[0]: ! factor = float(picwidth) / float(screenrect[2]-screenrect[0]) ! picwidth = picwidth / factor ! picheight = picheight / factor ! if picheight > screenrect[3] - screenrect[1]: ! factor = float(picheight) / float(screenrect[3]-screenrect[1]) ! picwidth = picwidth / factor ! picheight = picheight / factor ! return (screenrect[0], screenrect[1], screenrect[0]+int(picwidth), ! screenrect[1]+int(picheight)) ! class MyDialog(FrameWork.DialogWindow): ! "Main dialog window for ICONbrowse" ! def open(self, id, contents): ! self.id = id ! FrameWork.DialogWindow.open(self, ID_MAIN) ! self.dlg.SetDialogDefaultItem(MAIN_SHOW) ! self.contents = contents ! self.ctl = self.dlg.GetDialogItemAsControl(MAIN_LIST) ! h = self.ctl.GetControlData_Handle(Controls.kControlListBoxPart, ! Controls.kControlListBoxListHandleTag) ! self.list = List.as_List(h) ! self.setlist() ! def setlist(self): ! self.list.LDelRow(0, 0) ! self.list.LSetDrawingMode(0) ! if self.contents: ! self.list.LAddRow(len(self.contents), 0) ! for i in range(len(self.contents)): ! v = repr(self.contents[i][0]) ! if self.contents[i][1]: ! v = v + '"' + self.contents[i][1] + '"' ! self.list.LSetCell(v, (0, i)) ! self.list.LSetDrawingMode(1) ! self.list.LUpdate(self.wid.GetWindowPort().visRgn) ! ! def getselection(self): ! items = [] ! point = (0,0) ! while 1: ! ok, point = self.list.LGetSelect(1, point) ! if not ok: ! break ! items.append(point[1]) ! point = point[0], point[1]+1 ! values = [] ! for i in items: ! values.append(self.contents[i]) ! return values ! ! def do_show(self, *args): ! selection = self.getselection() ! for resid in selection: ! self.parent.showICON(resid) ! ! def do_close(self): ! self.close() ! ! def do_itemhit(self, item, event): ! if item == MAIN_SHOW: ! self.do_show() main() --- 28,163 ---- def main(): ! macresource.need('DLOG', ID_MAIN, "PICTbrowse.rsrc") ! ICONbrowse() class ICONbrowse(FrameWork.Application): ! def __init__(self): ! # First init menus, etc. ! FrameWork.Application.__init__(self) ! # Next create our dialog ! self.main_dialog = MyDialog(self) ! # Now open the dialog ! contents = self.findICONresources() ! self.main_dialog.open(ID_MAIN, contents) ! # Finally, go into the event loop ! self.mainloop() ! ! def makeusermenus(self): ! self.filemenu = m = FrameWork.Menu(self.menubar, "File") ! self.quititem = FrameWork.MenuItem(m, "Quit", "Q", self.quit) ! ! def quit(self, *args): ! self._quit() ! ! def showICON(self, resid): ! w = ICONwindow(self) ! w.open(resid) ! #EasyDialogs.Message('Show ICON %r' % (resid,)) ! ! def findICONresources(self): ! num = Res.CountResources('ICON') ! rv = [] ! for i in range(1, num+1): ! Res.SetResLoad(0) ! try: ! r = Res.GetIndResource('ICON', i) ! finally: ! Res.SetResLoad(1) ! id, type, name = r.GetResInfo() ! rv.append((id, name)) ! return rv ! class ICONwindow(FrameWork.Window): ! def open(self, (resid, resname)): ! if not resname: ! resname = '#%r' % (resid,) ! self.resid = resid ! self.picture = Icn.GetIcon(self.resid) ! l, t, r, b = 0, 0, 32, 32 ! self.pictrect = (l, t, r, b) ! width = r-l ! height = b-t ! if width < MINWIDTH: width = MINWIDTH ! elif width > MAXWIDTH: width = MAXWIDTH ! if height < MINHEIGHT: height = MINHEIGHT ! elif height > MAXHEIGHT: height = MAXHEIGHT ! bounds = (LEFT, TOP, LEFT+width, TOP+height) ! ! self.wid = Win.NewWindow(bounds, resname, 1, 0, -1, 1, 0) ! self.do_postopen() ! ! def do_update(self, *args): ! currect = self.fitrect() ! Icn.PlotIcon(currect, self.picture) ! ! def fitrect(self): ! """Return self.pictrect scaled to fit in window""" ! graf = self.wid.GetWindowPort() ! screenrect = graf.GetPortBounds() ! picwidth = self.pictrect[2] - self.pictrect[0] ! picheight = self.pictrect[3] - self.pictrect[1] ! if picwidth > screenrect[2] - screenrect[0]: ! factor = float(picwidth) / float(screenrect[2]-screenrect[0]) ! picwidth = picwidth / factor ! picheight = picheight / factor ! if picheight > screenrect[3] - screenrect[1]: ! factor = float(picheight) / float(screenrect[3]-screenrect[1]) ! picwidth = picwidth / factor ! picheight = picheight / factor ! return (screenrect[0], screenrect[1], screenrect[0]+int(picwidth), ! screenrect[1]+int(picheight)) ! class MyDialog(FrameWork.DialogWindow): ! "Main dialog window for ICONbrowse" ! def open(self, id, contents): ! self.id = id ! FrameWork.DialogWindow.open(self, ID_MAIN) ! self.dlg.SetDialogDefaultItem(MAIN_SHOW) ! self.contents = contents ! self.ctl = self.dlg.GetDialogItemAsControl(MAIN_LIST) ! h = self.ctl.GetControlData_Handle(Controls.kControlListBoxPart, ! Controls.kControlListBoxListHandleTag) ! self.list = List.as_List(h) ! self.setlist() ! def setlist(self): ! self.list.LDelRow(0, 0) ! self.list.LSetDrawingMode(0) ! if self.contents: ! self.list.LAddRow(len(self.contents), 0) ! for i in range(len(self.contents)): ! v = repr(self.contents[i][0]) ! if self.contents[i][1]: ! v = v + '"' + self.contents[i][1] + '"' ! self.list.LSetCell(v, (0, i)) ! self.list.LSetDrawingMode(1) ! self.list.LUpdate(self.wid.GetWindowPort().visRgn) ! ! def getselection(self): ! items = [] ! point = (0,0) ! while 1: ! ok, point = self.list.LGetSelect(1, point) ! if not ok: ! break ! items.append(point[1]) ! point = point[0], point[1]+1 ! values = [] ! for i in items: ! values.append(self.contents[i]) ! return values ! ! def do_show(self, *args): ! selection = self.getselection() ! for resid in selection: ! self.parent.showICON(resid) ! ! def do_close(self): ! self.close() ! ! def do_itemhit(self, item, event): ! if item == MAIN_SHOW: ! self.do_show() main() Index: PICTbrowse.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Demo/PICTbrowse/PICTbrowse.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** PICTbrowse.py 12 Feb 2004 17:35:12 -0000 1.11 --- PICTbrowse.py 18 Jul 2004 05:58:04 -0000 1.12 *************** *** 23,141 **** def main(): ! macresource.need('DLOG', ID_MAIN, "PICTbrowse.rsrc") ! PICTbrowse() class PICTbrowse(FrameWork.Application): ! def __init__(self): ! # First init menus, etc. ! FrameWork.Application.__init__(self) ! # Next create our dialog ! self.main_dialog = MyDialog(self) ! # Now open the dialog ! contents = self.findPICTresources() ! self.main_dialog.open(ID_MAIN, contents) ! # Finally, go into the event loop ! self.mainloop() ! ! def makeusermenus(self): ! self.filemenu = m = FrameWork.Menu(self.menubar, "File") ! self.quititem = FrameWork.MenuItem(m, "Quit", "Q", self.quit) ! ! def quit(self, *args): ! self._quit() ! ! def showPICT(self, resid): ! w = PICTwindow(self) ! w.open(resid) ! #EasyDialogs.Message('Show PICT %r' % (resid,)) ! ! def findPICTresources(self): ! num = Res.CountResources('PICT') ! rv = [] ! for i in range(1, num+1): ! Res.SetResLoad(0) ! try: ! r = Res.GetIndResource('PICT', i) ! finally: ! Res.SetResLoad(1) ! id, type, name = r.GetResInfo() ! rv.append((id, name)) ! return rv ! class PICTwindow(FrameWork.Window): ! def open(self, (resid, resname)): ! if not resname: ! resname = '#%r' % (resid,) ! self.resid = resid ! picture = Qd.GetPicture(self.resid) ! # Get rect for picture ! print repr(picture.data[:16]) ! sz, t, l, b, r = struct.unpack('hhhhh', picture.data[:10]) ! print 'pict:', t, l, b, r ! width = r-l ! height = b-t ! if width < 64: width = 64 ! elif width > 480: width = 480 ! if height < 64: height = 64 ! elif height > 320: height = 320 ! bounds = (LEFT, TOP, LEFT+width, TOP+height) ! print 'bounds:', bounds ! ! self.wid = Win.NewWindow(bounds, resname, 1, 0, -1, 1, 0) ! self.wid.SetWindowPic(picture) ! self.do_postopen() ! class MyDialog(FrameWork.DialogWindow): ! "Main dialog window for PICTbrowse" ! def open(self, id, contents): ! self.id = id ! FrameWork.DialogWindow.open(self, ID_MAIN) ! self.dlg.SetDialogDefaultItem(MAIN_SHOW) ! self.contents = contents ! self.ctl = self.dlg.GetDialogItemAsControl(MAIN_LIST) ! h = self.ctl.GetControlData_Handle(Controls.kControlListBoxPart, ! Controls.kControlListBoxListHandleTag) ! self.list = List.as_List(h) ! self.setlist() ! def setlist(self): ! self.list.LDelRow(0, 0) ! self.list.LSetDrawingMode(0) ! if self.contents: ! self.list.LAddRow(len(self.contents), 0) ! for i in range(len(self.contents)): ! v = repr(self.contents[i][0]) ! if self.contents[i][1]: ! v = v + '"' + self.contents[i][1] + '"' ! self.list.LSetCell(v, (0, i)) ! self.list.LSetDrawingMode(1) ! self.list.LUpdate(self.wid.GetWindowPort().visRgn) ! ! def getselection(self): ! items = [] ! point = (0,0) ! while 1: ! ok, point = self.list.LGetSelect(1, point) ! if not ok: ! break ! items.append(point[1]) ! point = point[0], point[1]+1 ! values = [] ! for i in items: ! values.append(self.contents[i]) ! return values ! ! def do_show(self, *args): ! selection = self.getselection() ! for resid in selection: ! self.parent.showPICT(resid) ! ! def do_close(self): ! self.close() ! ! def do_itemhit(self, item, event): ! if item == MAIN_SHOW: ! self.do_show() main() --- 23,141 ---- def main(): ! macresource.need('DLOG', ID_MAIN, "PICTbrowse.rsrc") ! PICTbrowse() class PICTbrowse(FrameWork.Application): ! def __init__(self): ! # First init menus, etc. ! FrameWork.Application.__init__(self) ! # Next create our dialog ! self.main_dialog = MyDialog(self) ! # Now open the dialog ! contents = self.findPICTresources() ! self.main_dialog.open(ID_MAIN, contents) ! # Finally, go into the event loop ! self.mainloop() ! ! def makeusermenus(self): ! self.filemenu = m = FrameWork.Menu(self.menubar, "File") ! self.quititem = FrameWork.MenuItem(m, "Quit", "Q", self.quit) ! ! def quit(self, *args): ! self._quit() ! ! def showPICT(self, resid): ! w = PICTwindow(self) ! w.open(resid) ! #EasyDialogs.Message('Show PICT %r' % (resid,)) ! ! def findPICTresources(self): ! num = Res.CountResources('PICT') ! rv = [] ! for i in range(1, num+1): ! Res.SetResLoad(0) ! try: ! r = Res.GetIndResource('PICT', i) ! finally: ! Res.SetResLoad(1) ! id, type, name = r.GetResInfo() ! rv.append((id, name)) ! return rv ! class PICTwindow(FrameWork.Window): ! def open(self, (resid, resname)): ! if not resname: ! resname = '#%r' % (resid,) ! self.resid = resid ! picture = Qd.GetPicture(self.resid) ! # Get rect for picture ! print repr(picture.data[:16]) ! sz, t, l, b, r = struct.unpack('hhhhh', picture.data[:10]) ! print 'pict:', t, l, b, r ! width = r-l ! height = b-t ! if width < 64: width = 64 ! elif width > 480: width = 480 ! if height < 64: height = 64 ! elif height > 320: height = 320 ! bounds = (LEFT, TOP, LEFT+width, TOP+height) ! print 'bounds:', bounds ! ! self.wid = Win.NewWindow(bounds, resname, 1, 0, -1, 1, 0) ! self.wid.SetWindowPic(picture) ! self.do_postopen() ! class MyDialog(FrameWork.DialogWindow): ! "Main dialog window for PICTbrowse" ! def open(self, id, contents): ! self.id = id ! FrameWork.DialogWindow.open(self, ID_MAIN) ! self.dlg.SetDialogDefaultItem(MAIN_SHOW) ! self.contents = contents ! self.ctl = self.dlg.GetDialogItemAsControl(MAIN_LIST) ! h = self.ctl.GetControlData_Handle(Controls.kControlListBoxPart, ! Controls.kControlListBoxListHandleTag) ! self.list = List.as_List(h) ! self.setlist() ! def setlist(self): ! self.list.LDelRow(0, 0) ! self.list.LSetDrawingMode(0) ! if self.contents: ! self.list.LAddRow(len(self.contents), 0) ! for i in range(len(self.contents)): ! v = repr(self.contents[i][0]) ! if self.contents[i][1]: ! v = v + '"' + self.contents[i][1] + '"' ! self.list.LSetCell(v, (0, i)) ! self.list.LSetDrawingMode(1) ! self.list.LUpdate(self.wid.GetWindowPort().visRgn) ! ! def getselection(self): ! items = [] ! point = (0,0) ! while 1: ! ok, point = self.list.LGetSelect(1, point) ! if not ok: ! break ! items.append(point[1]) ! point = point[0], point[1]+1 ! values = [] ! for i in items: ! values.append(self.contents[i]) ! return values ! ! def do_show(self, *args): ! selection = self.getselection() ! for resid in selection: ! self.parent.showPICT(resid) ! ! def do_close(self): ! self.close() ! ! def do_itemhit(self, item, event): ! if item == MAIN_SHOW: ! self.do_show() main() Index: PICTbrowse2.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Demo/PICTbrowse/PICTbrowse2.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** PICTbrowse2.py 12 Feb 2004 17:35:12 -0000 1.12 --- PICTbrowse2.py 18 Jul 2004 05:58:04 -0000 1.13 *************** *** 27,163 **** def main(): ! macresource.need('DLOG', ID_MAIN, "PICTbrowse.rsrc") ! PICTbrowse() class PICTbrowse(FrameWork.Application): ! def __init__(self): ! # First init menus, etc. ! FrameWork.Application.__init__(self) ! # Next create our dialog ! self.main_dialog = MyDialog(self) ! # Now open the dialog ! contents = self.findPICTresources() ! self.main_dialog.open(ID_MAIN, contents) ! # Finally, go into the event loop ! self.mainloop() ! ! def makeusermenus(self): ! self.filemenu = m = FrameWork.Menu(self.menubar, "File") ! self.quititem = FrameWork.MenuItem(m, "Quit", "Q", self.quit) ! ! def quit(self, *args): ! self._quit() ! ! def showPICT(self, resid): ! w = PICTwindow(self) ! w.open(resid) ! #EasyDialogs.Message('Show PICT %r' % (resid,)) ! ! def findPICTresources(self): ! num = Res.CountResources('PICT') ! rv = [] ! for i in range(1, num+1): ! Res.SetResLoad(0) ! try: ! r = Res.GetIndResource('PICT', i) ! finally: ! Res.SetResLoad(1) ! id, type, name = r.GetResInfo() ! rv.append((id, name)) ! return rv ! class PICTwindow(FrameWork.Window): ! def open(self, (resid, resname)): ! if not resname: ! resname = '#%r' % (resid,) ! self.resid = resid ! self.picture = Qd.GetPicture(self.resid) ! # Get rect for picture ! sz, t, l, b, r = struct.unpack('hhhhh', self.picture.data[:10]) ! self.pictrect = (l, t, r, b) ! width = r-l ! height = b-t ! if width < MINWIDTH: width = MINWIDTH ! elif width > MAXWIDTH: width = MAXWIDTH ! if height < MINHEIGHT: height = MINHEIGHT ! elif height > MAXHEIGHT: height = MAXHEIGHT ! bounds = (LEFT, TOP, LEFT+width, TOP+height) ! ! self.wid = Win.NewWindow(bounds, resname, 1, 0, -1, 1, 0) ! self.do_postopen() ! ! def do_update(self, *args): ! currect = self.fitrect() ! Qd.DrawPicture(self.picture, currect) ! ! def fitrect(self): ! """Return self.pictrect scaled to fit in window""" ! graf = self.dlg.GetWindowPort() ! screenrect = graf.GetPortBounds() ! picwidth = self.pictrect[2] - self.pictrect[0] ! picheight = self.pictrect[3] - self.pictrect[1] ! if picwidth > screenrect[2] - screenrect[0]: ! factor = float(picwidth) / float(screenrect[2]-screenrect[0]) ! picwidth = picwidth / factor ! picheight = picheight / factor ! if picheight > screenrect[3] - screenrect[1]: ! factor = float(picheight) / float(screenrect[3]-screenrect[1]) ! picwidth = picwidth / factor ! picheight = picheight / factor ! return (screenrect[0], screenrect[1], screenrect[0]+int(picwidth), ! screenrect[1]+int(picheight)) ! class MyDialog(FrameWork.DialogWindow): ! "Main dialog window for PICTbrowse" ! def open(self, id, contents): ! self.id = id ! FrameWork.DialogWindow.open(self, ID_MAIN) ! self.dlg.SetDialogDefaultItem(MAIN_SHOW) ! self.contents = contents ! self.ctl = self.dlg.GetDialogItemAsControl(MAIN_LIST) ! h = self.ctl.GetControlData_Handle(Controls.kControlListBoxPart, ! Controls.kControlListBoxListHandleTag) ! self.list = List.as_List(h) ! self.setlist() ! def setlist(self): ! self.list.LDelRow(0, 0) ! self.list.LSetDrawingMode(0) ! if self.contents: ! self.list.LAddRow(len(self.contents), 0) ! for i in range(len(self.contents)): ! v = repr(self.contents[i][0]) ! if self.contents[i][1]: ! v = v + '"' + self.contents[i][1] + '"' ! self.list.LSetCell(v, (0, i)) ! self.list.LSetDrawingMode(1) ! self.list.LUpdate(self.wid.GetWindowPort().visRgn) ! ! def getselection(self): ! items = [] ! point = (0,0) ! while 1: ! ok, point = self.list.LGetSelect(1, point) ! if not ok: ! break ! items.append(point[1]) ! point = point[0], point[1]+1 ! values = [] ! for i in items: ! values.append(self.contents[i]) ! return values ! ! def do_show(self, *args): ! selection = self.getselection() ! for resid in selection: ! self.parent.showPICT(resid) ! ! def do_close(self): ! self.close() ! ! def do_itemhit(self, item, event): ! if item == MAIN_SHOW: ! self.do_show() main() --- 27,163 ---- def main(): ! macresource.need('DLOG', ID_MAIN, "PICTbrowse.rsrc") ! PICTbrowse() class PICTbrowse(FrameWork.Application): ! def __init__(self): ! # First init menus, etc. ! FrameWork.Application.__init__(self) ! # Next create our dialog ! self.main_dialog = MyDialog(self) ! # Now open the dialog ! contents = self.findPICTresources() ! self.main_dialog.open(ID_MAIN, contents) ! # Finally, go into the event loop ! self.mainloop() ! ! def makeusermenus(self): ! self.filemenu = m = FrameWork.Menu(self.menubar, "File") ! self.quititem = FrameWork.MenuItem(m, "Quit", "Q", self.quit) ! ! def quit(self, *args): ! self._quit() ! ! def showPICT(self, resid): ! w = PICTwindow(self) ! w.open(resid) ! #EasyDialogs.Message('Show PICT %r' % (resid,)) ! ! def findPICTresources(self): ! num = Res.CountResources('PICT') ! rv = [] ! for i in range(1, num+1): ! Res.SetResLoad(0) ! try: ! r = Res.GetIndResource('PICT', i) ! finally: ! Res.SetResLoad(1) ! id, type, name = r.GetResInfo() ! rv.append((id, name)) ! return rv ! class PICTwindow(FrameWork.Window): ! def open(self, (resid, resname)): ! if not resname: ! resname = '#%r' % (resid,) ! self.resid = resid ! self.picture = Qd.GetPicture(self.resid) ! # Get rect for picture ! sz, t, l, b, r = struct.unpack('hhhhh', self.picture.data[:10]) ! self.pictrect = (l, t, r, b) ! width = r-l ! height = b-t ! if width < MINWIDTH: width = MINWIDTH ! elif width > MAXWIDTH: width = MAXWIDTH ! if height < MINHEIGHT: height = MINHEIGHT ! elif height > MAXHEIGHT: height = MAXHEIGHT ! bounds = (LEFT, TOP, LEFT+width, TOP+height) ! ! self.wid = Win.NewWindow(bounds, resname, 1, 0, -1, 1, 0) ! self.do_postopen() ! ! def do_update(self, *args): ! currect = self.fitrect() ! Qd.DrawPicture(self.picture, currect) ! ! def fitrect(self): ! """Return self.pictrect scaled to fit in window""" ! graf = self.dlg.GetWindowPort() ! screenrect = graf.GetPortBounds() ! picwidth = self.pictrect[2] - self.pictrect[0] ! picheight = self.pictrect[3] - self.pictrect[1] ! if picwidth > screenrect[2] - screenrect[0]: ! factor = float(picwidth) / float(screenrect[2]-screenrect[0]) ! picwidth = picwidth / factor ! picheight = picheight / factor ! if picheight > screenrect[3] - screenrect[1]: ! factor = float(picheight) / float(screenrect[3]-screenrect[1]) ! picwidth = picwidth / factor ! picheight = picheight / factor ! return (screenrect[0], screenrect[1], screenrect[0]+int(picwidth), ! screenrect[1]+int(picheight)) ! class MyDialog(FrameWork.DialogWindow): ! "Main dialog window for PICTbrowse" ! def open(self, id, contents): ! self.id = id ! FrameWork.DialogWindow.open(self, ID_MAIN) ! self.dlg.SetDialogDefaultItem(MAIN_SHOW) ! self.contents = contents ! self.ctl = self.dlg.GetDialogItemAsControl(MAIN_LIST) ! h = self.ctl.GetControlData_Handle(Controls.kControlListBoxPart, ! Controls.kControlListBoxListHandleTag) ! self.list = List.as_List(h) ! self.setlist() ! def setlist(self): ! self.list.LDelRow(0, 0) ! self.list.LSetDrawingMode(0) ! if self.contents: ! self.list.LAddRow(len(self.contents), 0) ! for i in range(len(self.contents)): ! v = repr(self.contents[i][0]) ! if self.contents[i][1]: ! v = v + '"' + self.contents[i][1] + '"' ! self.list.LSetCell(v, (0, i)) ! self.list.LSetDrawingMode(1) ! self.list.LUpdate(self.wid.GetWindowPort().visRgn) ! ! def getselection(self): ! items = [] ! point = (0,0) ! while 1: ! ok, point = self.list.LGetSelect(1, point) ! if not ok: ! break ! items.append(point[1]) ! point = point[0], point[1]+1 ! values = [] ! for i in items: ! values.append(self.contents[i]) ! return values ! ! def do_show(self, *args): ! selection = self.getselection() ! for resid in selection: ! self.parent.showPICT(resid) ! ! def do_close(self): ! self.close() ! ! def do_itemhit(self, item, event): ! if item == MAIN_SHOW: ! self.do_show() main() Index: cicnbrowse.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Demo/PICTbrowse/cicnbrowse.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** cicnbrowse.py 12 Feb 2004 17:35:12 -0000 1.9 --- cicnbrowse.py 18 Jul 2004 05:58:04 -0000 1.10 *************** *** 28,163 **** def main(): ! macresource.need('DLOG', ID_MAIN, "PICTbrowse.rsrc") ! CIconbrowse() class CIconbrowse(FrameWork.Application): ! def __init__(self): ! # First init menus, etc. ! FrameWork.Application.__init__(self) ! # Next create our dialog ! self.main_dialog = MyDialog(self) ! # Now open the dialog ! contents = self.findcicnresources() ! self.main_dialog.open(ID_MAIN, contents) ! # Finally, go into the event loop ! self.mainloop() ! ! def makeusermenus(self): ! self.filemenu = m = FrameWork.Menu(self.menubar, "File") ! self.quititem = FrameWork.MenuItem(m, "Quit", "Q", self.quit) ! ! def quit(self, *args): ! self._quit() ! ! def showCIcon(self, resid): ! w = CIconwindow(self) ! w.open(resid) ! #EasyDialogs.Message('Show cicn %r' % (resid,)) ! ! def findcicnresources(self): ! num = Res.CountResources('cicn') ! rv = [] ! for i in range(1, num+1): ! Res.SetResLoad(0) ! try: ! r = Res.GetIndResource('cicn', i) ! finally: ! Res.SetResLoad(1) ! id, type, name = r.GetResInfo() ! rv.append((id, name)) ! return rv ! class CIconwindow(FrameWork.Window): ! def open(self, (resid, resname)): ! if not resname: ! resname = '#%r' % (resid,) ! self.resid = resid ! self.picture = Icn.GetCIcon(self.resid) ! l, t, r, b = 0, 0, 32, 32 ! self.pictrect = (l, t, r, b) ! width = r-l ! height = b-t ! if width < MINWIDTH: width = MINWIDTH ! elif width > MAXWIDTH: width = MAXWIDTH ! if height < MINHEIGHT: height = MINHEIGHT ! elif height > MAXHEIGHT: height = MAXHEIGHT ! bounds = (LEFT, TOP, LEFT+width, TOP+height) ! ! self.wid = Win.NewWindow(bounds, resname, 1, 0, -1, 1, 0) ! self.do_postopen() ! ! def do_update(self, *args): ! currect = self.fitrect() ! Icn.PlotCIcon(currect, self.picture) ! ! def fitrect(self): ! """Return self.pictrect scaled to fit in window""" ! graf = self.wid.GetWindowPort() ! screenrect = graf.GetPortBounds() ! picwidth = self.pictrect[2] - self.pictrect[0] ! picheight = self.pictrect[3] - self.pictrect[1] ! if picwidth > screenrect[2] - screenrect[0]: ! factor = float(picwidth) / float(screenrect[2]-screenrect[0]) ! picwidth = picwidth / factor ! picheight = picheight / factor ! if picheight > screenrect[3] - screenrect[1]: ! factor = float(picheight) / float(screenrect[3]-screenrect[1]) ! picwidth = picwidth / factor ! picheight = picheight / factor ! return (screenrect[0], screenrect[1], screenrect[0]+int(picwidth), ! screenrect[1]+int(picheight)) ! class MyDialog(FrameWork.DialogWindow): ! "Main dialog window for cicnbrowse" ! def open(self, id, contents): ! self.id = id ! FrameWork.DialogWindow.open(self, ID_MAIN) ! self.dlg.SetDialogDefaultItem(MAIN_SHOW) ! self.contents = contents ! self.ctl = self.dlg.GetDialogItemAsControl(MAIN_LIST) ! h = self.ctl.GetControlData_Handle(Controls.kControlListBoxPart, ! Controls.kControlListBoxListHandleTag) ! self.list = List.as_List(h) ! self.setlist() ! def setlist(self): ! self.list.LDelRow(0, 0) ! self.list.LSetDrawingMode(0) ! if self.contents: ! self.list.LAddRow(len(self.contents), 0) ! for i in range(len(self.contents)): ! v = repr(self.contents[i][0]) ! if self.contents[i][1]: ! v = v + '"' + self.contents[i][1] + '"' ! self.list.LSetCell(v, (0, i)) ! self.list.LSetDrawingMode(1) ! self.list.LUpdate(self.wid.GetWindowPort().visRgn) ! ! def getselection(self): ! items = [] ! point = (0,0) ! while 1: ! ok, point = self.list.LGetSelect(1, point) ! if not ok: ! break ! items.append(point[1]) ! point = point[0], point[1]+1 ! values = [] ! for i in items: ! values.append(self.contents[i]) ! return values ! ! def do_show(self, *args): ! selection = self.getselection() ! for resid in selection: ! self.parent.showCIcon(resid) ! ! def do_close(self): ! self.close() ! ! def do_itemhit(self, item, event): ! if item == MAIN_SHOW: ! self.do_show() main() --- 28,163 ---- def main(): ! macresource.need('DLOG', ID_MAIN, "PICTbrowse.rsrc") ! CIconbrowse() class CIconbrowse(FrameWork.Application): ! def __init__(self): ! # First init menus, etc. ! FrameWork.Application.__init__(self) ! # Next create our dialog ! self.main_dialog = MyDialog(self) ! # Now open the dialog ! contents = self.findcicnresources() ! self.main_dialog.open(ID_MAIN, contents) ! # Finally, go into the event loop ! self.mainloop() ! ! def makeusermenus(self): ! self.filemenu = m = FrameWork.Menu(self.menubar, "File") ! self.quititem = FrameWork.MenuItem(m, "Quit", "Q", self.quit) ! ! def quit(self, *args): ! self._quit() ! ! def showCIcon(self, resid): ! w = CIconwindow(self) ! w.open(resid) ! #EasyDialogs.Message('Show cicn %r' % (resid,)) ! ! def findcicnresources(self): ! num = Res.CountResources('cicn') ! rv = [] ! for i in range(1, num+1): ! Res.SetResLoad(0) ! try: ! r = Res.GetIndResource('cicn', i) ! finally: ! Res.SetResLoad(1) ! id, type, name = r.GetResInfo() ! rv.append((id, name)) ! return rv ! class CIconwindow(FrameWork.Window): ! def open(self, (resid, resname)): ! if not resname: ! resname = '#%r' % (resid,) ! self.resid = resid ! self.picture = Icn.GetCIcon(self.resid) ! l, t, r, b = 0, 0, 32, 32 ! self.pictrect = (l, t, r, b) ! width = r-l ! height = b-t ! if width < MINWIDTH: width = MINWIDTH ! elif width > MAXWIDTH: width = MAXWIDTH ! if height < MINHEIGHT: height = MINHEIGHT ! elif height > MAXHEIGHT: height = MAXHEIGHT ! bounds = (LEFT, TOP, LEFT+width, TOP+height) ! ! self.wid = Win.NewWindow(bounds, resname, 1, 0, -1, 1, 0) ! self.do_postopen() ! ! def do_update(self, *args): ! currect = self.fitrect() ! Icn.PlotCIcon(currect, self.picture) ! ! def fitrect(self): ! """Return self.pictrect scaled to fit in window""" ! graf = self.wid.GetWindowPort() ! screenrect = graf.GetPortBounds() ! picwidth = self.pictrect[2] - self.pictrect[0] ! picheight = self.pictrect[3] - self.pictrect[1] ! if picwidth > screenrect[2] - screenrect[0]: ! factor = float(picwidth) / float(screenrect[2]-screenrect[0]) ! picwidth = picwidth / factor ! picheight = picheight / factor ! if picheight > screenrect[3] - screenrect[1]: ! factor = float(picheight) / float(screenrect[3]-screenrect[1]) ! picwidth = picwidth / factor ! picheight = picheight / factor ! return (screenrect[0], screenrect[1], screenrect[0]+int(picwidth), ! screenrect[1]+int(picheight)) ! class MyDialog(FrameWork.DialogWindow): ! "Main dialog window for cicnbrowse" ! def open(self, id, contents): ! self.id = id ! FrameWork.DialogWindow.open(self, ID_MAIN) ! self.dlg.SetDialogDefaultItem(MAIN_SHOW) ! self.contents = contents ! self.ctl = self.dlg.GetDialogItemAsControl(MAIN_LIST) ! h = self.ctl.GetControlData_Handle(Controls.kControlListBoxPart, ! Controls.kControlListBoxListHandleTag) ! self.list = List.as_List(h) ! self.setlist() ! def setlist(self): ! self.list.LDelRow(0, 0) ! self.list.LSetDrawingMode(0) ! if self.contents: ! self.list.LAddRow(len(self.contents), 0) ! for i in range(len(self.contents)): ! v = repr(self.contents[i][0]) ! if self.contents[i][1]: ! v = v + '"' + self.contents[i][1] + '"' ! self.list.LSetCell(v, (0, i)) ! self.list.LSetDrawingMode(1) ! self.list.LUpdate(self.wid.GetWindowPort().visRgn) ! ! def getselection(self): ! items = [] ! point = (0,0) ! while 1: ! ok, point = self.list.LGetSelect(1, point) ! if not ok: ! break ! items.append(point[1]) ! point = point[0], point[1]+1 ! values = [] ! for i in items: ! values.append(self.contents[i]) ! return values ! ! def do_show(self, *args): ! selection = self.getselection() ! for resid in selection: ! self.parent.showCIcon(resid) ! ! def do_close(self): ! self.close() ! ! def do_itemhit(self, item, event): ! if item == MAIN_SHOW: ! self.do_show() main() Index: oldPICTbrowse.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Demo/PICTbrowse/oldPICTbrowse.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** oldPICTbrowse.py 12 Feb 2004 17:35:12 -0000 1.7 --- oldPICTbrowse.py 18 Jul 2004 05:58:04 -0000 1.8 *************** *** 22,159 **** def main(): ! macresource.need('DLOG', ID_MAIN, "oldPICTbrowse.rsrc") ! PICTbrowse() class PICTbrowse(FrameWork.Application): ! def __init__(self): ! # First init menus, etc. ! FrameWork.Application.__init__(self) ! # Next create our dialog ! self.main_dialog = MyDialog(self) ! # Now open the dialog ! contents = self.findPICTresources() ! self.main_dialog.open(ID_MAIN, contents) ! # Finally, go into the event loop ! self.mainloop() ! ! def makeusermenus(self): ! self.filemenu = m = FrameWork.Menu(self.menubar, "File") ! self.quititem = FrameWork.MenuItem(m, "Quit", "Q", self.quit) ! ! def quit(self, *args): ! self._quit() ! ! def showPICT(self, resid): ! w = PICTwindow(self) ! w.open(resid) ! #EasyDialogs.Message('Show PICT %r' % (resid,)) ! ! def findPICTresources(self): ! num = Res.CountResources('PICT') ! rv = [] ! for i in range(1, num+1): ! Res.SetResLoad(0) ! try: ! r = Res.GetIndResource('PICT', i) ! finally: ! Res.SetResLoad(1) ! id, type, name = r.GetResInfo() ! rv.append((id, name)) ! return rv ! class PICTwindow(FrameWork.Window): ! def open(self, (resid, resname)): ! if not resname: ! resname = '#%r' % (resid,) ! self.resid = resid ! picture = Qd.GetPicture(self.resid) ! # Get rect for picture ! print repr(picture.data[:16]) ! sz, t, l, b, r = struct.unpack('hhhhh', picture.data[:10]) ! print 'pict:', t, l, b, r ! width = r-l ! height = b-t ! if width < 64: width = 64 ! elif width > 480: width = 480 ! if height < 64: height = 64 ! elif height > 320: height = 320 ! bounds = (LEFT, TOP, LEFT+width, TOP+height) ! print 'bounds:', bounds ! ! self.wid = Win.NewWindow(bounds, resname, 1, 0, -1, 1, 0) ! self.wid.SetWindowPic(picture) ! self.do_postopen() ! class MyDialog(FrameWork.DialogWindow): ! "Main dialog window for PICTbrowse" ! def open(self, id, contents): ! self.id = id ! FrameWork.DialogWindow.open(self, ID_MAIN) ! self.dlg.SetDialogDefaultItem(MAIN_SHOW) ! tp, h, rect = self.dlg.GetDialogItem(MAIN_LIST) ! rect2 = rect[0]+1, rect[1]+1, rect[2]-17, rect[3]-17 # Scroll bar space ! self.list = List.LNew(rect2, (0, 0, 1, len(contents)), (0,0), 0, self.wid, ! 0, 1, 1, 1) ! self.contents = contents ! self.setlist() ! def setlist(self): ! self.list.LDelRow(0, 0) ! self.list.LSetDrawingMode(0) ! if self.contents: ! self.list.LAddRow(len(self.contents), 0) ! for i in range(len(self.contents)): ! v = repr(self.contents[i][0]) ! if self.contents[i][1]: ! v = v + '"' + self.contents[i][1] + '"' ! self.list.LSetCell(v, (0, i)) ! self.list.LSetDrawingMode(1) ! self.list.LUpdate(self.wid.GetWindowPort().visRgn) ! ! def do_listhit(self, event): ! (what, message, when, where, modifiers) = event ! Qd.SetPort(self.wid) ! where = Qd.GlobalToLocal(where) ! print 'LISTHIT', where ! if self.list.LClick(where, modifiers): ! self.do_show() ! ! def getselection(self): ! items = [] ! point = (0,0) ! while 1: ! ok, point = self.list.LGetSelect(1, point) ! if not ok: ! break ! items.append(point[1]) ! point = point[0], point[1]+1 ! values = [] ! for i in items: ! values.append(self.contents[i]) ! return values ! ! def do_show(self, *args): ! selection = self.getselection() ! for resid in selection: ! self.parent.showPICT(resid) ! ! def do_rawupdate(self, window, event): ! tp, h, rect = self.dlg.GetDialogItem(MAIN_LIST) ! Qd.SetPort(self.wid) ! Qd.FrameRect(rect) ! self.list.LUpdate(self.wid.GetWindowPort().visRgn) ! ! def do_activate(self, activate, event): ! self.list.LActivate(activate) ! ! def do_close(self): ! self.close() ! ! def do_itemhit(self, item, event): ! if item == MAIN_LIST: ! self.do_listhit(event) ! if item == MAIN_SHOW: ! self.do_show() main() --- 22,159 ---- def main(): ! macresource.need('DLOG', ID_MAIN, "oldPICTbrowse.rsrc") ! PICTbrowse() class PICTbrowse(FrameWork.Application): ! def __init__(self): ! # First init menus, etc. ! FrameWork.Application.__init__(self) ! # Next create our dialog ! self.main_dialog = MyDialog(self) ! # Now open the dialog ! contents = self.findPICTresources() ! self.main_dialog.open(ID_MAIN, contents) ! # Finally, go into the event loop ! self.mainloop() ! ! def makeusermenus(self): ! self.filemenu = m = FrameWork.Menu(self.menubar, "File") ! self.quititem = FrameWork.MenuItem(m, "Quit", "Q", self.quit) ! ! def quit(self, *args): ! self._quit() ! ! def showPICT(self, resid): ! w = PICTwindow(self) ! w.open(resid) ! #EasyDialogs.Message('Show PICT %r' % (resid,)) ! ! def findPICTresources(self): ! num = Res.CountResources('PICT') ! rv = [] ! for i in range(1, num+1): ! Res.SetResLoad(0) ! try: ! r = Res.GetIndResource('PICT', i) ! finally: ! Res.SetResLoad(1) ! id, type, name = r.GetResInfo() ! rv.append((id, name)) ! return rv ! class PICTwindow(FrameWork.Window): ! def open(self, (resid, resname)): ! if not resname: ! resname = '#%r' % (resid,) ! self.resid = resid ! picture = Qd.GetPicture(self.resid) ! # Get rect for picture ! print repr(picture.data[:16]) ! sz, t, l, b, r = struct.unpack('hhhhh', picture.data[:10]) ! print 'pict:', t, l, b, r ! width = r-l ! height = b-t ! if width < 64: width = 64 ! elif width > 480: width = 480 ! if height < 64: height = 64 ! elif height > 320: height = 320 ! bounds = (LEFT, TOP, LEFT+width, TOP+height) ! print 'bounds:', bounds ! ! self.wid = Win.NewWindow(bounds, resname, 1, 0, -1, 1, 0) ! self.wid.SetWindowPic(picture) ! self.do_postopen() ! class MyDialog(FrameWork.DialogWindow): ! "Main dialog window for PICTbrowse" ! def open(self, id, contents): ! self.id = id ! FrameWork.DialogWindow.open(self, ID_MAIN) ! self.dlg.SetDialogDefaultItem(MAIN_SHOW) ! tp, h, rect = self.dlg.GetDialogItem(MAIN_LIST) ! rect2 = rect[0]+1, rect[1]+1, rect[2]-17, rect[3]-17 # Scroll bar space ! self.list = List.LNew(rect2, (0, 0, 1, len(contents)), (0,0), 0, self.wid, ! 0, 1, 1, 1) ! self.contents = contents ! self.setlist() ! def setlist(self): ! self.list.LDelRow(0, 0) ! self.list.LSetDrawingMode(0) ! if self.contents: ! self.list.LAddRow(len(self.contents), 0) ! for i in range(len(self.contents)): ! v = repr(self.contents[i][0]) ! if self.contents[i][1]: ! v = v + '"' + self.contents[i][1] + '"' ! self.list.LSetCell(v, (0, i)) ! self.list.LSetDrawingMode(1) ! self.list.LUpdate(self.wid.GetWindowPort().visRgn) ! ! def do_listhit(self, event): ! (what, message, when, where, modifiers) = event ! Qd.SetPort(self.wid) ! where = Qd.GlobalToLocal(where) ! print 'LISTHIT', where ! if self.list.LClick(where, modifiers): ! self.do_show() ! ! def getselection(self): ! items = [] ! point = (0,0) ! while 1: ! ok, point = self.list.LGetSelect(1, point) ! if not ok: ! break ! items.append(point[1]) ! point = point[0], point[1]+1 ! values = [] ! for i in items: ! values.append(self.contents[i]) ! return values ! ! def do_show(self, *args): ! selection = self.getselection() ! for resid in selection: ! self.parent.showPICT(resid) ! ! def do_rawupdate(self, window, event): ! tp, h, rect = self.dlg.GetDialogItem(MAIN_LIST) ! Qd.SetPort(self.wid) ! Qd.FrameRect(rect) ! self.list.LUpdate(self.wid.GetWindowPort().visRgn) ! ! def do_activate(self, activate, event): ! self.list.LActivate(activate) ! ! def do_close(self): ! self.close() ! ! def do_itemhit(self, item, event): ! if item == MAIN_LIST: ! self.do_listhit(event) ! if item == MAIN_SHOW: ! self.do_show() main() From tim_one at users.sourceforge.net Sun Jul 18 07:58:38 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 07:58:51 2004 Subject: [Python-checkins] python/dist/src/Mac/Demo/resources copyres.py, 1.2, 1.3 listres.py, 1.3, 1.4 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Demo/resources In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29056/Demo/resources Modified Files: copyres.py listres.py Log Message: Whitespace normalization, via reindent.py. Index: copyres.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Demo/resources/copyres.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** copyres.py 25 Aug 2001 12:02:25 -0000 1.2 --- copyres.py 18 Jul 2004 05:58:06 -0000 1.3 *************** *** 8,57 **** def copyres(src, dst): ! """Copy resource from src file to dst file.""" ! ! cur = CurResFile() ! ctor, type = MacOS.GetCreatorAndType(src) ! input = FSpOpenResFile(src, READ) ! try: ! FSpCreateResFile(dst, ctor, type, smAllScripts) ! except: ! raw_input("%s already exists... CR to write anyway! " % dst) ! output = FSpOpenResFile(dst, WRITE) ! UseResFile(input) ! ntypes = Count1Types() ! for itype in range(1, 1+ntypes): ! type = Get1IndType(itype) ! nresources = Count1Resources(type) ! for ires in range(1, 1+nresources): ! res = Get1IndResource(type, ires) ! res.LoadResource() ! id, type, name = res.GetResInfo() ! size = res.SizeResource() ! attrs = res.GetResAttrs() ! print id, type, name, size, hex(attrs) ! res.DetachResource() ! UseResFile(output) ! try: ! res2 = Get1Resource(type, id) ! except (RuntimeError, Res.Error), msg: ! res2 = None ! if res2: ! print "Duplicate type+id, not copied" ! print (res2.size, res2.data) ! print res2.GetResInfo() ! if res2.HomeResFile() == output: ! 'OK' ! elif res2.HomeResFile() == input: ! 'BAD!' ! else: ! print 'Home:', res2.HomeResFile() ! else: ! res.AddResource(type, id, name) ! #res.SetResAttrs(attrs) ! res.WriteResource() ! UseResFile(input) ! UseResFile(cur) ! CloseResFile(output) ! CloseResFile(input) copyres('::python.¹.rsrc', '::foo.rsrc') --- 8,57 ---- def copyres(src, dst): ! """Copy resource from src file to dst file.""" ! ! cur = CurResFile() ! ctor, type = MacOS.GetCreatorAndType(src) ! input = FSpOpenResFile(src, READ) ! try: ! FSpCreateResFile(dst, ctor, type, smAllScripts) ! except: ! raw_input("%s already exists... CR to write anyway! " % dst) ! output = FSpOpenResFile(dst, WRITE) ! UseResFile(input) ! ntypes = Count1Types() ! for itype in range(1, 1+ntypes): ! type = Get1IndType(itype) ! nresources = Count1Resources(type) ! for ires in range(1, 1+nresources): ! res = Get1IndResource(type, ires) ! res.LoadResource() ! id, type, name = res.GetResInfo() ! size = res.SizeResource() ! attrs = res.GetResAttrs() ! print id, type, name, size, hex(attrs) ! res.DetachResource() ! UseResFile(output) ! try: ! res2 = Get1Resource(type, id) ! except (RuntimeError, Res.Error), msg: ! res2 = None ! if res2: ! print "Duplicate type+id, not copied" ! print (res2.size, res2.data) ! print res2.GetResInfo() ! if res2.HomeResFile() == output: ! 'OK' ! elif res2.HomeResFile() == input: ! 'BAD!' ! else: ! print 'Home:', res2.HomeResFile() ! else: ! res.AddResource(type, id, name) ! #res.SetResAttrs(attrs) ! res.WriteResource() ! UseResFile(input) ! UseResFile(cur) ! CloseResFile(output) ! CloseResFile(input) copyres('::python.¹.rsrc', '::foo.rsrc') Index: listres.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Demo/resources/listres.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** listres.py 12 Feb 2004 17:35:13 -0000 1.3 --- listres.py 18 Jul 2004 05:58:06 -0000 1.4 *************** *** 5,60 **** def list1resources(): ! ntypes = Res.Count1Types() ! for itype in range(1, 1+ntypes): ! type = Res.Get1IndType(itype) ! print "Type:", repr(type) ! nresources = Res.Count1Resources(type) ! for i in range(1, 1 + nresources): ! Res.SetResLoad(0) ! res = Res.Get1IndResource(type, i) ! Res.SetResLoad(1) ! info(res) def listresources(): ! ntypes = Res.CountTypes() ! for itype in range(1, 1+ntypes): ! type = Res.GetIndType(itype) ! print "Type:", repr(type) ! nresources = Res.CountResources(type) ! for i in range(1, 1 + nresources): ! Res.SetResLoad(0) ! res = Res.GetIndResource(type, i) ! Res.SetResLoad(1) ! info(res) def info(res): ! print res.GetResInfo(), res.SizeResource(), decodeattrs(res.GetResAttrs()) attrnames = { ! resChanged: 'Changed', ! resPreload: 'Preload', ! resProtected: 'Protected', ! resLocked: 'Locked', ! resPurgeable: 'Purgeable', ! resSysHeap: 'SysHeap', } def decodeattrs(attrs): ! names = [] ! for bit in range(16): ! mask = 1< Update of /cvsroot/python/python/dist/src/Mac/Demo/imgbrowse In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29056/Demo/imgbrowse Modified Files: imgbrowse.py mac_image.py Log Message: Whitespace normalization, via reindent.py. Index: imgbrowse.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Demo/imgbrowse/imgbrowse.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** imgbrowse.py 12 Feb 2004 17:35:12 -0000 1.8 --- imgbrowse.py 18 Jul 2004 05:58:05 -0000 1.9 *************** *** 26,117 **** def main(): ! print 'hello world' ! imgbrowse() class imgbrowse(FrameWork.Application): ! def __init__(self): ! # First init menus, etc. ! FrameWork.Application.__init__(self) ! self.lastwin = None ! # Finally, go into the event loop ! self.mainloop() ! ! def makeusermenus(self): ! self.filemenu = m = FrameWork.Menu(self.menubar, "File") ! self.openitem = FrameWork.MenuItem(m, "Open...", "O", self.opendoc) ! self.infoitem = FrameWork.MenuItem(m, "Info", "I", self.info) ! self.quititem = FrameWork.MenuItem(m, "Quit", "Q", self.quit) ! ! def quit(self, *args): ! self._quit() ! ! def opendoc(self, *args): ! pathname = EasyDialogs.AskFileForOpen() # Any file type ! if not pathname: ! return ! bar = EasyDialogs.ProgressBar('Reading and converting...') ! try: ! rdr = img.reader(imgformat.macrgb16, pathname) ! except img.error, arg: ! EasyDialogs.Message(repr(arg)) ! return ! w, h = rdr.width, rdr.height ! bar.set(10) ! data = rdr.read() ! del bar ! pixmap = mac_image.mkpixmap(w, h, imgformat.macrgb16, data) ! self.showimg(w, h, pixmap, data) ! ! def showimg(self, w, h, pixmap, data): ! win = imgwindow(self) ! win.open(w, h, pixmap, data) ! self.lastwin = win - def info(self, *args): - if self.lastwin: - self.lastwin.info() - class imgwindow(FrameWork.Window): ! def open(self, width, height, pixmap, data): ! self.pixmap = pixmap ! self.data = data ! self.pictrect = (0, 0, width, height) ! bounds = (LEFT, TOP, LEFT+width, TOP+height) ! ! self.wid = Win.NewCWindow(bounds, "Picture", 1, 0, -1, 1, 0) ! self.do_postopen() ! ! def do_update(self, *args): ! pass ! currect = self.fitrect() ! print 'PICT:', self.pictrect ! print 'WIND:', currect ! print 'ARGS:', (self.pixmap, self.wid.GetWindowPort().GetPortBitMapForCopyBits(), self.pictrect, ! currect, QuickDraw.srcCopy, None) ! self.info() ! Qd.CopyBits(self.pixmap, self.wid.GetWindowPort().GetPortBitMapForCopyBits(), self.pictrect, ! currect, QuickDraw.srcCopy, None) ! ! def fitrect(self): ! """Return self.pictrect scaled to fit in window""" ! graf = self.wid.GetWindowPort() ! screenrect = graf.GetPortBounds() ! picwidth = self.pictrect[2] - self.pictrect[0] ! picheight = self.pictrect[3] - self.pictrect[1] ! if picwidth > screenrect[2] - screenrect[0]: ! factor = float(picwidth) / float(screenrect[2]-screenrect[0]) ! picwidth = picwidth / factor ! picheight = picheight / factor ! if picheight > screenrect[3] - screenrect[1]: ! factor = float(picheight) / float(screenrect[3]-screenrect[1]) ! picwidth = picwidth / factor ! picheight = picheight / factor ! return (screenrect[0], screenrect[1], screenrect[0]+int(picwidth), ! screenrect[1]+int(picheight)) ! ! def info(self): ! graf = self.wid.GetWindowPort() ! bits = graf.GetPortBitMapForCopyBits() ! mac_image.dumppixmap(bits.pixmap_data) main() --- 26,117 ---- def main(): ! print 'hello world' ! imgbrowse() class imgbrowse(FrameWork.Application): ! def __init__(self): ! # First init menus, etc. ! FrameWork.Application.__init__(self) ! self.lastwin = None ! # Finally, go into the event loop ! self.mainloop() ! ! def makeusermenus(self): ! self.filemenu = m = FrameWork.Menu(self.menubar, "File") ! self.openitem = FrameWork.MenuItem(m, "Open...", "O", self.opendoc) ! self.infoitem = FrameWork.MenuItem(m, "Info", "I", self.info) ! self.quititem = FrameWork.MenuItem(m, "Quit", "Q", self.quit) ! ! def quit(self, *args): ! self._quit() ! ! def opendoc(self, *args): ! pathname = EasyDialogs.AskFileForOpen() # Any file type ! if not pathname: ! return ! bar = EasyDialogs.ProgressBar('Reading and converting...') ! try: ! rdr = img.reader(imgformat.macrgb16, pathname) ! except img.error, arg: ! EasyDialogs.Message(repr(arg)) ! return ! w, h = rdr.width, rdr.height ! bar.set(10) ! data = rdr.read() ! del bar ! pixmap = mac_image.mkpixmap(w, h, imgformat.macrgb16, data) ! self.showimg(w, h, pixmap, data) ! ! def showimg(self, w, h, pixmap, data): ! win = imgwindow(self) ! win.open(w, h, pixmap, data) ! self.lastwin = win ! ! def info(self, *args): ! if self.lastwin: ! self.lastwin.info() class imgwindow(FrameWork.Window): ! def open(self, width, height, pixmap, data): ! self.pixmap = pixmap ! self.data = data ! self.pictrect = (0, 0, width, height) ! bounds = (LEFT, TOP, LEFT+width, TOP+height) ! ! self.wid = Win.NewCWindow(bounds, "Picture", 1, 0, -1, 1, 0) ! self.do_postopen() ! ! def do_update(self, *args): ! pass ! currect = self.fitrect() ! print 'PICT:', self.pictrect ! print 'WIND:', currect ! print 'ARGS:', (self.pixmap, self.wid.GetWindowPort().GetPortBitMapForCopyBits(), self.pictrect, ! currect, QuickDraw.srcCopy, None) ! self.info() ! Qd.CopyBits(self.pixmap, self.wid.GetWindowPort().GetPortBitMapForCopyBits(), self.pictrect, ! currect, QuickDraw.srcCopy, None) ! ! def fitrect(self): ! """Return self.pictrect scaled to fit in window""" ! graf = self.wid.GetWindowPort() ! screenrect = graf.GetPortBounds() ! picwidth = self.pictrect[2] - self.pictrect[0] ! picheight = self.pictrect[3] - self.pictrect[1] ! if picwidth > screenrect[2] - screenrect[0]: ! factor = float(picwidth) / float(screenrect[2]-screenrect[0]) ! picwidth = picwidth / factor ! picheight = picheight / factor ! if picheight > screenrect[3] - screenrect[1]: ! factor = float(picheight) / float(screenrect[3]-screenrect[1]) ! picwidth = picwidth / factor ! picheight = picheight / factor ! return (screenrect[0], screenrect[1], screenrect[0]+int(picwidth), ! screenrect[1]+int(picheight)) ! ! def info(self): ! graf = self.wid.GetWindowPort() ! bits = graf.GetPortBitMapForCopyBits() ! mac_image.dumppixmap(bits.pixmap_data) main() Index: mac_image.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Demo/imgbrowse/mac_image.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** mac_image.py 25 Aug 2001 12:06:15 -0000 1.4 --- mac_image.py 18 Jul 2004 05:58:05 -0000 1.5 *************** *** 7,56 **** _fmt_to_mac = { ! imgformat.macrgb16 : (16, 16, 3, 5), } def mkpixmap(w, h, fmt, data): ! """kludge a pixmap together""" ! fmtinfo = _fmt_to_mac[fmt] ! ! rv = struct.pack("lHhhhhhhlllhhhhlll", ! id(data)+MacOS.string_id_to_buffer, # HACK HACK!! ! w*2 + 0x8000, ! 0, 0, h, w, ! 0, ! 0, 0, # XXXX? ! 72<<16, 72<<16, ! fmtinfo[0], fmtinfo[1], ! fmtinfo[2], fmtinfo[3], ! 0, 0, 0) ! ## print 'Our pixmap, size %d:'%len(rv) ! ## dumppixmap(rv) ! return Qd.RawBitMap(rv) def dumppixmap(data): ! baseAddr, \ ! rowBytes, \ ! t, l, b, r, \ ! pmVersion, \ ! packType, packSize, \ ! hRes, vRes, \ ! pixelType, pixelSize, \ ! cmpCount, cmpSize, \ ! planeBytes, pmTable, pmReserved \ ! = struct.unpack("lhhhhhhhlllhhhhlll", data) ! print 'Base: 0x%x'%baseAddr ! print 'rowBytes: %d (0x%x)'%(rowBytes&0x3fff, rowBytes) ! print 'rect: %d, %d, %d, %d'%(t, l, b, r) ! print 'pmVersion: 0x%x'%pmVersion ! print 'packing: %d %d'%(packType, packSize) ! print 'resolution: %f x %f'%(float(hRes)/0x10000, float(vRes)/0x10000) ! print 'pixeltype: %d, size %d'%(pixelType, pixelSize) ! print 'components: %d, size %d'%(cmpCount, cmpSize) ! print 'planeBytes: %d (0x%x)'%(planeBytes, planeBytes) ! print 'pmTable: 0x%x'%pmTable ! print 'pmReserved: 0x%x'%pmReserved ! for i in range(0, len(data), 16): ! for j in range(16): ! if i + j < len(data): ! print '%02.2x'%ord(data[i+j]), ! print --- 7,56 ---- _fmt_to_mac = { ! imgformat.macrgb16 : (16, 16, 3, 5), } def mkpixmap(w, h, fmt, data): ! """kludge a pixmap together""" ! fmtinfo = _fmt_to_mac[fmt] ! ! rv = struct.pack("lHhhhhhhlllhhhhlll", ! id(data)+MacOS.string_id_to_buffer, # HACK HACK!! ! w*2 + 0x8000, ! 0, 0, h, w, ! 0, ! 0, 0, # XXXX? ! 72<<16, 72<<16, ! fmtinfo[0], fmtinfo[1], ! fmtinfo[2], fmtinfo[3], ! 0, 0, 0) ! ## print 'Our pixmap, size %d:'%len(rv) ! ## dumppixmap(rv) ! return Qd.RawBitMap(rv) def dumppixmap(data): ! baseAddr, \ ! rowBytes, \ ! t, l, b, r, \ ! pmVersion, \ ! packType, packSize, \ ! hRes, vRes, \ ! pixelType, pixelSize, \ ! cmpCount, cmpSize, \ ! planeBytes, pmTable, pmReserved \ ! = struct.unpack("lhhhhhhhlllhhhhlll", data) ! print 'Base: 0x%x'%baseAddr ! print 'rowBytes: %d (0x%x)'%(rowBytes&0x3fff, rowBytes) ! print 'rect: %d, %d, %d, %d'%(t, l, b, r) ! print 'pmVersion: 0x%x'%pmVersion ! print 'packing: %d %d'%(packType, packSize) ! print 'resolution: %f x %f'%(float(hRes)/0x10000, float(vRes)/0x10000) ! print 'pixeltype: %d, size %d'%(pixelType, pixelSize) ! print 'components: %d, size %d'%(cmpCount, cmpSize) ! print 'planeBytes: %d (0x%x)'%(planeBytes, planeBytes) ! print 'pmTable: 0x%x'%pmTable ! print 'pmReserved: 0x%x'%pmReserved ! for i in range(0, len(data), 16): ! for j in range(16): ! if i + j < len(data): ! print '%02.2x'%ord(data[i+j]), ! print From tim_one at users.sourceforge.net Sun Jul 18 07:58:38 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 07:58:53 2004 Subject: [Python-checkins] python/dist/src/Mac/Demo/mlte mlted.py,1.7,1.8 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Demo/mlte In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29056/Demo/mlte Modified Files: mlted.py Log Message: Whitespace normalization, via reindent.py. Index: mlted.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Demo/mlte/mlted.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** mlted.py 12 Feb 2004 17:35:12 -0000 1.7 --- mlted.py 18 Jul 2004 05:58:05 -0000 1.8 *************** *** 16,375 **** UNDOLABELS = [ # Indexed by MLTECanUndo() value ! "Typing", "Cut", "Paste", "Clear", "Font Change", "Color Change", "Size Change", ! "Style Change", "Align Left", "Align Center", "Align Right", "Drop", "Move"] ! class MlteWindow(Window): ! def open(self, path, name, data): ! self.path = path ! self.name = name ! r = windowbounds(400, 400) ! w = Win.NewWindow(r, name, 1, 0, -1, 1, 0) ! self.wid = w ! flags = MacTextEditor.kTXNDrawGrowIconMask|MacTextEditor.kTXNWantHScrollBarMask| \ ! MacTextEditor.kTXNWantVScrollBarMask ! self.ted, self.frameid = Mlte.TXNNewObject(None, w, None, flags, MacTextEditor.kTXNTextEditStyleFrameType, ! MacTextEditor.kTXNTextFile, MacTextEditor.kTXNMacOSEncoding) ! self.ted.TXNSetData(MacTextEditor.kTXNTextData, data, 0, 0x7fffffff) ! self.changed = 0 ! self.do_postopen() ! self.do_activate(1, None) ! ! def do_idle(self, event): ! self.ted.TXNIdle() ! self.ted.TXNAdjustCursor(None) ! ! ! def do_activate(self, onoff, evt): ! if onoff: ! ## self.ted.TXNActivate(self.frameid, 0) ! self.ted.TXNFocus(1) ! self.parent.active = self ! else: ! self.ted.TXNFocus(0) ! self.parent.active = None ! self.parent.updatemenubar() - def do_update(self, wid, event): - self.ted.TXNDraw(None) - - def do_postresize(self, width, height, window): - self.ted.TXNResizeFrame(width, height, self.frameid) - - def do_contentclick(self, local, modifiers, evt): - self.ted.TXNClick(evt) - self.parent.updatemenubar() - - def do_char(self, ch, event): - self.ted.TXNKeyDown(event) - self.parent.updatemenubar() - - def close(self): - if self.changed: - save = EasyDialogs.AskYesNoCancel('Save window "%s" before closing?'%self.name, 1) - if save > 0: - self.menu_save() - elif save < 0: - return - if self.parent.active == self: - self.parent.active = None - self.ted.TXNDeleteObject() - del self.ted - ## del self.tedtexthandle - self.do_postclose() - - def menu_save(self): - if not self.path: - self.menu_save_as() - return # Will call us recursively - dhandle = self.ted.TXNGetData(0, 0x7fffffff) - data = dhandle.data - fp = open(self.path, 'wb') # NOTE: wb, because data has CR for end-of-line - fp.write(data) - if data[-1] <> '\r': fp.write('\r') - fp.close() - self.changed = 0 - - def menu_save_as(self): - path = EasyDialogs.AskFileForSave(message='Save as:') - if not path: return - self.path = path - self.name = os.path.split(self.path)[-1] - self.wid.SetWTitle(self.name) - self.menu_save() - - def menu_cut(self): - ## self.ted.WESelView() - self.ted.TXNCut() - ### Mlte.ConvertToPublicScrap() - ## Scrap.ZeroScrap() - ## self.ted.WECut() - ## self.updatescrollbars() - self.parent.updatemenubar() - self.changed = 1 - - def menu_copy(self): - ## Scrap.ZeroScrap() - self.ted.TXNCopy() - ### Mlte.ConvertToPublicScrap() - ## self.updatescrollbars() - self.parent.updatemenubar() - - def menu_paste(self): - ### Mlte.ConvertFromPublicScrap() - self.ted.TXNPaste() - ## self.updatescrollbars() - self.parent.updatemenubar() - self.changed = 1 - - def menu_clear(self): - ## self.ted.WESelView() - self.ted.TXNClear() - ## self.updatescrollbars() - self.parent.updatemenubar() - self.changed = 1 - def menu_undo(self): - self.ted.TXNUndo() - ## self.updatescrollbars() - self.parent.updatemenubar() - - def menu_redo(self): - self.ted.TXNRedo() - ## self.updatescrollbars() - self.parent.updatemenubar() - - def have_selection(self): - start, stop = self.ted.TXNGetSelection() - return start < stop - - def can_paste(self): - return Mlte.TXNIsScrapPastable() - - def can_undo(self): - can, which = self.ted.TXNCanUndo() - if not can: - return None - if which >= len(UNDOLABELS): - # Unspecified undo - return "Undo" - which = UNDOLABELS[which] - - return "Undo "+which ! def can_redo(self): ! can, which = self.ted.TXNCanRedo() ! if not can: ! return None ! if which >= len(UNDOLABELS): ! # Unspecified undo ! return "Redo" ! which = UNDOLABELS[which] ! ! return "Redo "+which class Mlted(Application): ! def __init__(self): ! Application.__init__(self) ! self.num = 0 ! self.active = None ! self.updatemenubar() ! ! def makeusermenus(self): ! self.filemenu = m = Menu(self.menubar, "File") ! self.newitem = MenuItem(m, "New window", "N", self.open) ! self.openitem = MenuItem(m, "Open...", "O", self.openfile) ! self.closeitem = MenuItem(m, "Close", "W", self.closewin) ! m.addseparator() ! self.saveitem = MenuItem(m, "Save", "S", self.save) ! self.saveasitem = MenuItem(m, "Save as...", "", self.saveas) ! m.addseparator() ! self.quititem = MenuItem(m, "Quit", "Q", self.quit) ! ! self.editmenu = m = Menu(self.menubar, "Edit") ! self.undoitem = MenuItem(m, "Undo", "Z", self.undo) ! self.redoitem = MenuItem(m, "Redo", None, self.redo) ! m.addseparator() ! self.cutitem = MenuItem(m, "Cut", "X", self.cut) ! self.copyitem = MenuItem(m, "Copy", "C", self.copy) ! self.pasteitem = MenuItem(m, "Paste", "V", self.paste) ! self.clearitem = MenuItem(m, "Clear", "", self.clear) ! ! # Groups of items enabled together: ! self.windowgroup = [self.closeitem, self.saveitem, self.saveasitem, self.editmenu] ! self.focusgroup = [self.cutitem, self.copyitem, self.clearitem] ! self.windowgroup_on = -1 ! self.focusgroup_on = -1 ! self.pastegroup_on = -1 ! self.undo_label = "never" ! self.redo_label = "never" ! ! def updatemenubar(self): ! changed = 0 ! on = (self.active <> None) ! if on <> self.windowgroup_on: ! for m in self.windowgroup: ! m.enable(on) ! self.windowgroup_on = on ! changed = 1 ! if on: ! # only if we have an edit menu ! on = self.active.have_selection() ! if on <> self.focusgroup_on: ! for m in self.focusgroup: ! m.enable(on) ! self.focusgroup_on = on ! changed = 1 ! on = self.active.can_paste() ! if on <> self.pastegroup_on: ! self.pasteitem.enable(on) ! self.pastegroup_on = on ! changed = 1 ! on = self.active.can_undo() ! if on <> self.undo_label: ! if on: ! self.undoitem.enable(1) ! self.undoitem.settext(on) ! self.undo_label = on ! else: ! self.undoitem.settext("Nothing to undo") ! self.undoitem.enable(0) ! changed = 1 ! on = self.active.can_redo() ! if on <> self.redo_label: ! if on: ! self.redoitem.enable(1) ! self.redoitem.settext(on) ! self.redo_label = on ! else: ! self.redoitem.settext("Nothing to redo") ! self.redoitem.enable(0) ! changed = 1 ! if changed: ! DrawMenuBar() ! # ! # Apple menu ! # ! ! def do_about(self, id, item, window, event): ! EasyDialogs.Message("A simple single-font text editor based on MacTextEditor") ! ! # ! # File menu ! # ! def open(self, *args): ! self._open(0) ! ! def openfile(self, *args): ! self._open(1) ! def _open(self, askfile): ! if askfile: ! path = EasyDialogs.AskFileForOpen(typeList=('TEXT',)) ! if not path: ! return ! name = os.path.split(path)[-1] ! try: ! fp = open(path, 'rb') # NOTE binary, we need cr as end-of-line ! data = fp.read() ! fp.close() ! except IOError, arg: ! EasyDialogs.Message("IOERROR: %r" % (arg,)) ! return ! else: ! path = None ! name = "Untitled %d"%self.num ! data = '' ! w = MlteWindow(self) ! w.open(path, name, data) ! self.num = self.num + 1 ! ! def closewin(self, *args): ! if self.active: ! self.active.close() ! else: ! EasyDialogs.Message("No active window?") ! ! def save(self, *args): ! if self.active: ! self.active.menu_save() ! else: ! EasyDialogs.Message("No active window?") ! ! def saveas(self, *args): ! if self.active: ! self.active.menu_save_as() ! else: ! EasyDialogs.Message("No active window?") ! ! ! def quit(self, *args): ! for w in self._windows.values(): ! w.close() ! if self._windows: ! return ! self._quit() ! ! # ! # Edit menu ! # ! ! def undo(self, *args): ! if self.active: ! self.active.menu_undo() ! else: ! EasyDialogs.Message("No active window?") ! ! def redo(self, *args): ! if self.active: ! self.active.menu_redo() ! else: ! EasyDialogs.Message("No active window?") ! ! def cut(self, *args): ! if self.active: ! self.active.menu_cut() ! else: ! EasyDialogs.Message("No active window?") ! ! def copy(self, *args): ! if self.active: ! self.active.menu_copy() ! else: ! EasyDialogs.Message("No active window?") ! ! def paste(self, *args): ! if self.active: ! self.active.menu_paste() ! else: ! EasyDialogs.Message("No active window?") ! def clear(self, *args): ! if self.active: ! self.active.menu_clear() ! else: ! EasyDialogs.Message("No active window?") ! ! # ! # Other stuff ! # ! def idle(self, event): ! if self.active: ! self.active.do_idle(event) ! else: ! Qd.SetCursor(Qd.GetQDGlobalsArrow()) def main(): ! Mlte.TXNInitTextension(0) ! try: ! App = Mlted() ! App.mainloop() ! finally: ! Mlte.TXNTerminateTextension() ! if __name__ == '__main__': ! main() ! --- 16,374 ---- UNDOLABELS = [ # Indexed by MLTECanUndo() value ! "Typing", "Cut", "Paste", "Clear", "Font Change", "Color Change", "Size Change", ! "Style Change", "Align Left", "Align Center", "Align Right", "Drop", "Move"] ! class MlteWindow(Window): ! def open(self, path, name, data): ! self.path = path ! self.name = name ! r = windowbounds(400, 400) ! w = Win.NewWindow(r, name, 1, 0, -1, 1, 0) ! self.wid = w ! flags = MacTextEditor.kTXNDrawGrowIconMask|MacTextEditor.kTXNWantHScrollBarMask| \ ! MacTextEditor.kTXNWantVScrollBarMask ! self.ted, self.frameid = Mlte.TXNNewObject(None, w, None, flags, MacTextEditor.kTXNTextEditStyleFrameType, ! MacTextEditor.kTXNTextFile, MacTextEditor.kTXNMacOSEncoding) ! self.ted.TXNSetData(MacTextEditor.kTXNTextData, data, 0, 0x7fffffff) ! self.changed = 0 ! self.do_postopen() ! self.do_activate(1, None) ! def do_idle(self, event): ! self.ted.TXNIdle() ! self.ted.TXNAdjustCursor(None) ! def do_activate(self, onoff, evt): ! if onoff: ! ## self.ted.TXNActivate(self.frameid, 0) ! self.ted.TXNFocus(1) ! self.parent.active = self ! else: ! self.ted.TXNFocus(0) ! self.parent.active = None ! self.parent.updatemenubar() ! ! def do_update(self, wid, event): ! self.ted.TXNDraw(None) ! ! def do_postresize(self, width, height, window): ! self.ted.TXNResizeFrame(width, height, self.frameid) ! ! def do_contentclick(self, local, modifiers, evt): ! self.ted.TXNClick(evt) ! self.parent.updatemenubar() ! ! def do_char(self, ch, event): ! self.ted.TXNKeyDown(event) ! self.parent.updatemenubar() ! ! def close(self): ! if self.changed: ! save = EasyDialogs.AskYesNoCancel('Save window "%s" before closing?'%self.name, 1) ! if save > 0: ! self.menu_save() ! elif save < 0: ! return ! if self.parent.active == self: ! self.parent.active = None ! self.ted.TXNDeleteObject() ! del self.ted ! ## del self.tedtexthandle ! self.do_postclose() ! ! def menu_save(self): ! if not self.path: ! self.menu_save_as() ! return # Will call us recursively ! dhandle = self.ted.TXNGetData(0, 0x7fffffff) ! data = dhandle.data ! fp = open(self.path, 'wb') # NOTE: wb, because data has CR for end-of-line ! fp.write(data) ! if data[-1] <> '\r': fp.write('\r') ! fp.close() ! self.changed = 0 ! ! def menu_save_as(self): ! path = EasyDialogs.AskFileForSave(message='Save as:') ! if not path: return ! self.path = path ! self.name = os.path.split(self.path)[-1] ! self.wid.SetWTitle(self.name) ! self.menu_save() ! ! def menu_cut(self): ! ## self.ted.WESelView() ! self.ted.TXNCut() ! ### Mlte.ConvertToPublicScrap() ! ## Scrap.ZeroScrap() ! ## self.ted.WECut() ! ## self.updatescrollbars() ! self.parent.updatemenubar() ! self.changed = 1 ! ! def menu_copy(self): ! ## Scrap.ZeroScrap() ! self.ted.TXNCopy() ! ### Mlte.ConvertToPublicScrap() ! ## self.updatescrollbars() ! self.parent.updatemenubar() ! ! def menu_paste(self): ! ### Mlte.ConvertFromPublicScrap() ! self.ted.TXNPaste() ! ## self.updatescrollbars() ! self.parent.updatemenubar() ! self.changed = 1 ! ! def menu_clear(self): ! ## self.ted.WESelView() ! self.ted.TXNClear() ! ## self.updatescrollbars() ! self.parent.updatemenubar() ! self.changed = 1 ! ! def menu_undo(self): ! self.ted.TXNUndo() ! ## self.updatescrollbars() ! self.parent.updatemenubar() ! ! def menu_redo(self): ! self.ted.TXNRedo() ! ## self.updatescrollbars() ! self.parent.updatemenubar() ! ! def have_selection(self): ! start, stop = self.ted.TXNGetSelection() ! return start < stop ! ! def can_paste(self): ! return Mlte.TXNIsScrapPastable() ! ! def can_undo(self): ! can, which = self.ted.TXNCanUndo() ! if not can: ! return None ! if which >= len(UNDOLABELS): ! # Unspecified undo ! return "Undo" ! which = UNDOLABELS[which] ! ! return "Undo "+which ! ! def can_redo(self): ! can, which = self.ted.TXNCanRedo() ! if not can: ! return None ! if which >= len(UNDOLABELS): ! # Unspecified undo ! return "Redo" ! which = UNDOLABELS[which] ! ! return "Redo "+which class Mlted(Application): ! def __init__(self): ! Application.__init__(self) ! self.num = 0 ! self.active = None ! self.updatemenubar() ! def makeusermenus(self): ! self.filemenu = m = Menu(self.menubar, "File") ! self.newitem = MenuItem(m, "New window", "N", self.open) ! self.openitem = MenuItem(m, "Open...", "O", self.openfile) ! self.closeitem = MenuItem(m, "Close", "W", self.closewin) ! m.addseparator() ! self.saveitem = MenuItem(m, "Save", "S", self.save) ! self.saveasitem = MenuItem(m, "Save as...", "", self.saveas) ! m.addseparator() ! self.quititem = MenuItem(m, "Quit", "Q", self.quit) ! self.editmenu = m = Menu(self.menubar, "Edit") ! self.undoitem = MenuItem(m, "Undo", "Z", self.undo) ! self.redoitem = MenuItem(m, "Redo", None, self.redo) ! m.addseparator() ! self.cutitem = MenuItem(m, "Cut", "X", self.cut) ! self.copyitem = MenuItem(m, "Copy", "C", self.copy) ! self.pasteitem = MenuItem(m, "Paste", "V", self.paste) ! self.clearitem = MenuItem(m, "Clear", "", self.clear) ! # Groups of items enabled together: ! self.windowgroup = [self.closeitem, self.saveitem, self.saveasitem, self.editmenu] ! self.focusgroup = [self.cutitem, self.copyitem, self.clearitem] ! self.windowgroup_on = -1 ! self.focusgroup_on = -1 ! self.pastegroup_on = -1 ! self.undo_label = "never" ! self.redo_label = "never" ! def updatemenubar(self): ! changed = 0 ! on = (self.active <> None) ! if on <> self.windowgroup_on: ! for m in self.windowgroup: ! m.enable(on) ! self.windowgroup_on = on ! changed = 1 ! if on: ! # only if we have an edit menu ! on = self.active.have_selection() ! if on <> self.focusgroup_on: ! for m in self.focusgroup: ! m.enable(on) ! self.focusgroup_on = on ! changed = 1 ! on = self.active.can_paste() ! if on <> self.pastegroup_on: ! self.pasteitem.enable(on) ! self.pastegroup_on = on ! changed = 1 ! on = self.active.can_undo() ! if on <> self.undo_label: ! if on: ! self.undoitem.enable(1) ! self.undoitem.settext(on) ! self.undo_label = on ! else: ! self.undoitem.settext("Nothing to undo") ! self.undoitem.enable(0) ! changed = 1 ! on = self.active.can_redo() ! if on <> self.redo_label: ! if on: ! self.redoitem.enable(1) ! self.redoitem.settext(on) ! self.redo_label = on ! else: ! self.redoitem.settext("Nothing to redo") ! self.redoitem.enable(0) ! changed = 1 ! if changed: ! DrawMenuBar() ! # ! # Apple menu ! # ! ! def do_about(self, id, item, window, event): ! EasyDialogs.Message("A simple single-font text editor based on MacTextEditor") ! ! # ! # File menu ! # ! ! def open(self, *args): ! self._open(0) ! ! def openfile(self, *args): ! self._open(1) ! ! def _open(self, askfile): ! if askfile: ! path = EasyDialogs.AskFileForOpen(typeList=('TEXT',)) ! if not path: ! return ! name = os.path.split(path)[-1] ! try: ! fp = open(path, 'rb') # NOTE binary, we need cr as end-of-line ! data = fp.read() ! fp.close() ! except IOError, arg: ! EasyDialogs.Message("IOERROR: %r" % (arg,)) ! return ! else: ! path = None ! name = "Untitled %d"%self.num ! data = '' ! w = MlteWindow(self) ! w.open(path, name, data) ! self.num = self.num + 1 ! ! def closewin(self, *args): ! if self.active: ! self.active.close() ! else: ! EasyDialogs.Message("No active window?") ! ! def save(self, *args): ! if self.active: ! self.active.menu_save() ! else: ! EasyDialogs.Message("No active window?") ! ! def saveas(self, *args): ! if self.active: ! self.active.menu_save_as() ! else: ! EasyDialogs.Message("No active window?") ! ! ! def quit(self, *args): ! for w in self._windows.values(): ! w.close() ! if self._windows: ! return ! self._quit() ! ! # ! # Edit menu ! # ! ! def undo(self, *args): ! if self.active: ! self.active.menu_undo() ! else: ! EasyDialogs.Message("No active window?") ! ! def redo(self, *args): ! if self.active: ! self.active.menu_redo() ! else: ! EasyDialogs.Message("No active window?") ! ! def cut(self, *args): ! if self.active: ! self.active.menu_cut() ! else: ! EasyDialogs.Message("No active window?") ! ! def copy(self, *args): ! if self.active: ! self.active.menu_copy() ! else: ! EasyDialogs.Message("No active window?") ! ! def paste(self, *args): ! if self.active: ! self.active.menu_paste() ! else: ! EasyDialogs.Message("No active window?") ! ! def clear(self, *args): ! if self.active: ! self.active.menu_clear() ! else: ! EasyDialogs.Message("No active window?") ! ! # ! # Other stuff ! # ! ! def idle(self, event): ! if self.active: ! self.active.do_idle(event) ! else: ! Qd.SetCursor(Qd.GetQDGlobalsArrow()) def main(): ! Mlte.TXNInitTextension(0) ! try: ! App = Mlted() ! App.mainloop() ! finally: ! Mlte.TXNTerminateTextension() ! if __name__ == '__main__': ! main() From tim_one at users.sourceforge.net Sun Jul 18 07:58:38 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 07:58:55 2004 Subject: [Python-checkins] python/dist/src/Mac/Demo/quicktime MovieInWindow.py, 1.8, 1.9 VerySimplePlayer.py, 1.7, 1.8 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Demo/quicktime In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29056/Demo/quicktime Modified Files: MovieInWindow.py VerySimplePlayer.py Log Message: Whitespace normalization, via reindent.py. Index: MovieInWindow.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Demo/quicktime/MovieInWindow.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** MovieInWindow.py 26 Mar 2003 14:36:25 -0000 1.8 --- MovieInWindow.py 18 Jul 2004 05:58:05 -0000 1.9 *************** *** 19,71 **** def main(): ! # skip the toolbox initializations, already done ! # XXXX Should use gestalt here to check for quicktime version ! Qt.EnterMovies() ! ! # Get the movie file ! if len(sys.argv) > 1: ! filename = sys.argv[1] ! else: ! filename = EasyDialogs.AskFileForOpen() # Was: QuickTime.MovieFileType ! if not filename: ! sys.exit(0) ! ! # Open the window ! bounds = (175, 75, 175+160, 75+120) ! theWindow = Win.NewCWindow(bounds, os.path.split(filename)[1], 1, 0, -1, 0, 0) ! Qd.SetPort(theWindow) ! # XXXX Needed? SetGWorld((CGrafPtr)theWindow, nil) ! ! playMovieInWindow(theWindow, filename, theWindow.GetWindowPort().GetPortBounds()) ! def playMovieInWindow(theWindow, theFile, movieBox): ! """Play a movie in a window""" ! # XXXX Needed? SetGWorld((CGrafPtr)theWindow, nil); ! ! # Get the movie ! theMovie = loadMovie(theFile) ! ! # Set where we want it ! theMovie.SetMovieBox(movieBox) ! ! # Start at the beginning ! theMovie.GoToBeginningOfMovie() ! ! # Give a little time to preroll ! theMovie.MoviesTask(0) ! ! # Start playing ! theMovie.StartMovie() ! ! while not theMovie.IsMovieDone() and not Evt.Button(): ! theMovie.MoviesTask(0) ! def loadMovie(theFile): ! """Load a movie given an fsspec. Return the movie object""" ! movieResRef = Qt.OpenMovieFile(theFile, 1) ! movie, d1, d2 = Qt.NewMovieFromFile(movieResRef, 0, QuickTime.newMovieActive) ! return movie ! if __name__ == '__main__': ! main() ! --- 19,70 ---- def main(): ! # skip the toolbox initializations, already done ! # XXXX Should use gestalt here to check for quicktime version ! Qt.EnterMovies() ! ! # Get the movie file ! if len(sys.argv) > 1: ! filename = sys.argv[1] ! else: ! filename = EasyDialogs.AskFileForOpen() # Was: QuickTime.MovieFileType ! if not filename: ! sys.exit(0) ! ! # Open the window ! bounds = (175, 75, 175+160, 75+120) ! theWindow = Win.NewCWindow(bounds, os.path.split(filename)[1], 1, 0, -1, 0, 0) ! Qd.SetPort(theWindow) ! # XXXX Needed? SetGWorld((CGrafPtr)theWindow, nil) ! ! playMovieInWindow(theWindow, filename, theWindow.GetWindowPort().GetPortBounds()) ! def playMovieInWindow(theWindow, theFile, movieBox): ! """Play a movie in a window""" ! # XXXX Needed? SetGWorld((CGrafPtr)theWindow, nil); ! ! # Get the movie ! theMovie = loadMovie(theFile) ! ! # Set where we want it ! theMovie.SetMovieBox(movieBox) ! ! # Start at the beginning ! theMovie.GoToBeginningOfMovie() ! ! # Give a little time to preroll ! theMovie.MoviesTask(0) ! ! # Start playing ! theMovie.StartMovie() ! ! while not theMovie.IsMovieDone() and not Evt.Button(): ! theMovie.MoviesTask(0) ! def loadMovie(theFile): ! """Load a movie given an fsspec. Return the movie object""" ! movieResRef = Qt.OpenMovieFile(theFile, 1) ! movie, d1, d2 = Qt.NewMovieFromFile(movieResRef, 0, QuickTime.newMovieActive) ! return movie ! if __name__ == '__main__': ! main() Index: VerySimplePlayer.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Demo/quicktime/VerySimplePlayer.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** VerySimplePlayer.py 26 Jan 2003 21:36:06 -0000 1.7 --- VerySimplePlayer.py 18 Jul 2004 05:58:05 -0000 1.8 *************** *** 19,93 **** def main(): ! print 'hello world' # XXXX ! # skip the toolbox initializations, already done ! # XXXX Should use gestalt here to check for quicktime version ! Qt.EnterMovies() ! ! # Get the movie file ! fss = EasyDialogs.AskFileForOpen(wanted=File.FSSpec) # Was: QuickTime.MovieFileType ! if not fss: ! sys.exit(0) ! ! # Open the window ! bounds = (175, 75, 175+160, 75+120) ! theWindow = Win.NewCWindow(bounds, fss.as_tuple()[2], 0, 0, -1, 1, 0) ! # XXXX Needed? SetGWorld((CGrafPtr)theWindow, nil) ! Qd.SetPort(theWindow) ! ! # Get the movie ! theMovie = loadMovie(fss) ! ! # Relocate to (0, 0) ! bounds = theMovie.GetMovieBox() ! bounds = 0, 0, bounds[2]-bounds[0], bounds[3]-bounds[1] ! theMovie.SetMovieBox(bounds) ! ! # Create a controller ! theController = theMovie.NewMovieController(bounds, QuickTime.mcTopLeftMovie) ! ! # Get movie size and update window parameters ! rv, bounds = theController.MCGetControllerBoundsRect() ! theWindow.SizeWindow(bounds[2], bounds[3], 0) # XXXX or [3] [2]? ! Qt.AlignWindow(theWindow, 0) ! theWindow.ShowWindow() ! ! # XXXX MCDoAction(theController, mcActionSetGrowBoxBounds, &maxBounds) ! theController.MCDoAction(QuickTime.mcActionSetKeysEnabled, '1') ! ! # XXXX MCSetActionFilterWithRefCon(theController, movieControllerEventFilter, (long)theWindow) ! ! done = 0 ! while not done: ! gotone, evt = Evt.WaitNextEvent(0xffff, 0) ! (what, message, when, where, modifiers) = evt ! ## print what, message, when, where, modifiers # XXXX ! ! if theController.MCIsPlayerEvent(evt): ! continue ! ! if what == Events.mouseDown: ! part, whichWindow = Win.FindWindow(where) ! if part == Windows.inGoAway: ! done = whichWindow.TrackGoAway(where) ! elif part == Windows.inDrag: ! Qt.DragAlignedWindow(whichWindow, where, (0, 0, 4000, 4000)) ! elif what == Events.updateEvt: ! whichWindow = Win.WhichWindow(message) ! if not whichWindow: ! # Probably the console window. Print something, hope it helps. ! print 'update' ! else: ! Qd.SetPort(whichWindow) ! whichWindow.BeginUpdate() ! Qd.EraseRect(whichWindow.GetWindowPort().GetPortBounds()) ! whichWindow.EndUpdate() ! def loadMovie(theFile): ! """Load a movie given an fsspec. Return the movie object""" ! movieResRef = Qt.OpenMovieFile(theFile, 1) ! movie, d1, d2 = Qt.NewMovieFromFile(movieResRef, 0, QuickTime.newMovieActive) ! return movie ! if __name__ == '__main__': ! main() ! --- 19,92 ---- def main(): ! print 'hello world' # XXXX ! # skip the toolbox initializations, already done ! # XXXX Should use gestalt here to check for quicktime version ! Qt.EnterMovies() ! ! # Get the movie file ! fss = EasyDialogs.AskFileForOpen(wanted=File.FSSpec) # Was: QuickTime.MovieFileType ! if not fss: ! sys.exit(0) ! ! # Open the window ! bounds = (175, 75, 175+160, 75+120) ! theWindow = Win.NewCWindow(bounds, fss.as_tuple()[2], 0, 0, -1, 1, 0) ! # XXXX Needed? SetGWorld((CGrafPtr)theWindow, nil) ! Qd.SetPort(theWindow) ! ! # Get the movie ! theMovie = loadMovie(fss) ! ! # Relocate to (0, 0) ! bounds = theMovie.GetMovieBox() ! bounds = 0, 0, bounds[2]-bounds[0], bounds[3]-bounds[1] ! theMovie.SetMovieBox(bounds) ! ! # Create a controller ! theController = theMovie.NewMovieController(bounds, QuickTime.mcTopLeftMovie) ! ! # Get movie size and update window parameters ! rv, bounds = theController.MCGetControllerBoundsRect() ! theWindow.SizeWindow(bounds[2], bounds[3], 0) # XXXX or [3] [2]? ! Qt.AlignWindow(theWindow, 0) ! theWindow.ShowWindow() ! ! # XXXX MCDoAction(theController, mcActionSetGrowBoxBounds, &maxBounds) ! theController.MCDoAction(QuickTime.mcActionSetKeysEnabled, '1') ! ! # XXXX MCSetActionFilterWithRefCon(theController, movieControllerEventFilter, (long)theWindow) ! ! done = 0 ! while not done: ! gotone, evt = Evt.WaitNextEvent(0xffff, 0) ! (what, message, when, where, modifiers) = evt ! ## print what, message, when, where, modifiers # XXXX ! ! if theController.MCIsPlayerEvent(evt): ! continue ! ! if what == Events.mouseDown: ! part, whichWindow = Win.FindWindow(where) ! if part == Windows.inGoAway: ! done = whichWindow.TrackGoAway(where) ! elif part == Windows.inDrag: ! Qt.DragAlignedWindow(whichWindow, where, (0, 0, 4000, 4000)) ! elif what == Events.updateEvt: ! whichWindow = Win.WhichWindow(message) ! if not whichWindow: ! # Probably the console window. Print something, hope it helps. ! print 'update' ! else: ! Qd.SetPort(whichWindow) ! whichWindow.BeginUpdate() ! Qd.EraseRect(whichWindow.GetWindowPort().GetPortBounds()) ! whichWindow.EndUpdate() ! def loadMovie(theFile): ! """Load a movie given an fsspec. Return the movie object""" ! movieResRef = Qt.OpenMovieFile(theFile, 1) ! movie, d1, d2 = Qt.NewMovieFromFile(movieResRef, 0, QuickTime.newMovieActive) ! return movie ! if __name__ == '__main__': ! main() From tim_one at users.sourceforge.net Sun Jul 18 07:58:37 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 07:58:56 2004 Subject: [Python-checkins] python/dist/src/Mac/Demo/applescript/Disk_Copy Special_Events.py, 1.2, 1.3 Standard_Suite.py, 1.2, 1.3 Utility_Events.py, 1.1, 1.2 __init__.py, 1.1, 1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Demo/applescript/Disk_Copy In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29056/Demo/applescript/Disk_Copy Modified Files: Special_Events.py Standard_Suite.py Utility_Events.py __init__.py Log Message: Whitespace normalization, via reindent.py. Index: Special_Events.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Demo/applescript/Disk_Copy/Special_Events.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Special_Events.py 17 May 2001 12:45:13 -0000 1.2 --- Special_Events.py 18 Jul 2004 05:58:04 -0000 1.3 *************** *** 13,395 **** class Special_Events_Events: ! _argmap_mount = { ! 'access_mode' : 'Acss', ! 'checksum_verification' : 'VChk', ! 'signature_verification' : 'VSig', ! 'RAM_caching' : 'Cach', ! } ! def mount(self, _object, _attributes={}, **_arguments): ! """mount: Mounts an Disk Copy image as a disk volume ! Required argument: a reference to the disk image to be mounted ! Keyword argument access_mode: the access mode for mounted volume (default is "any", i.e. best possible) ! Keyword argument checksum_verification: Verify the checksum before mounting? ! Keyword argument signature_verification: Verify the DigiSignŽ signature before mounting? ! Keyword argument RAM_caching: Cache the disk image in RAM? (if omitted, don't cache) ! Keyword argument _attributes: AppleEvent attribute dictionary ! Returns: a reference to mounted disk ! """ ! _code = 'ddsk' ! _subcode = 'Moun' ! aetools.keysubst(_arguments, self._argmap_mount) ! _arguments['----'] = _object ! aetools.enumsubst(_arguments, 'Acss', _Enum_Acss) ! aetools.enumsubst(_arguments, 'VChk', _Enum_bool) ! aetools.enumsubst(_arguments, 'VSig', _Enum_bool) ! aetools.enumsubst(_arguments, 'Cach', _Enum_bool) ! _reply, _arguments, _attributes = self.send(_code, _subcode, ! _arguments, _attributes) ! if _arguments.has_key('errn'): ! raise aetools.Error, aetools.decodeerror(_arguments) ! # XXXX Optionally decode result ! if _arguments.has_key('----'): ! return _arguments['----'] ! _argmap_execute_DiskScript = { ! 'checksum_verification' : 'VChk', ! 'signature_verification' : 'VSig', ! } ! def execute_DiskScript(self, _object, _attributes={}, **_arguments): ! """execute DiskScript: Executes a Disk Copy-specific DiskScript ! Required argument: a reference to the DiskScript to execute ! Keyword argument checksum_verification: Should checksums be verified when mounting images referenced in the DiskScript? ! Keyword argument signature_verification: Should the DigiSignŽ signature of the DiskScript and the images it references be verified? ! Keyword argument _attributes: AppleEvent attribute dictionary ! """ ! _code = 'ddsk' ! _subcode = 'XEQd' ! aetools.keysubst(_arguments, self._argmap_execute_DiskScript) ! _arguments['----'] = _object ! aetools.enumsubst(_arguments, 'VChk', _Enum_bool) ! aetools.enumsubst(_arguments, 'VSig', _Enum_bool) ! _reply, _arguments, _attributes = self.send(_code, _subcode, ! _arguments, _attributes) ! if _arguments.has_key('errn'): ! raise aetools.Error, aetools.decodeerror(_arguments) ! # XXXX Optionally decode result ! if _arguments.has_key('----'): ! return _arguments['----'] ! def unmount(self, _object, _attributes={}, **_arguments): ! """unmount: Unmount and eject (if necessary) a volume ! Required argument: a reference to disk to be unmounted (and ejected) ! Keyword argument _attributes: AppleEvent attribute dictionary ! """ ! _code = 'ddsk' ! _subcode = 'Umnt' ! if _arguments: raise TypeError, 'No optional args expected' ! _arguments['----'] = _object ! _reply, _arguments, _attributes = self.send(_code, _subcode, ! _arguments, _attributes) ! if _arguments.has_key('errn'): ! raise aetools.Error, aetools.decodeerror(_arguments) ! # XXXX Optionally decode result ! if _arguments.has_key('----'): ! return _arguments['----'] ! _argmap_create = { ! 'saving_as' : 'SvAs', ! 'logical_blocks' : 'Blks', ! 'zeroing' : 'Zero', ! 'leave_image_mounted' : 'Moun', ! 'filesystem' : 'Fsys', ! } ! def create(self, _object, _attributes={}, **_arguments): ! """create: Create a new Disk Copy document ! Required argument: the name of the volume to create ! Keyword argument saving_as: the disk image to be created ! Keyword argument logical_blocks: the number of logical blocks ! Keyword argument zeroing: Should all blocks on the disk be set to zero? ! Keyword argument leave_image_mounted: Should the image be mounted after it is created? ! Keyword argument filesystem: file system to use (Mac OS Standard/compatible, Mac OS Enhanced) ! Keyword argument _attributes: AppleEvent attribute dictionary ! Returns: a reference to newly created disk image (or newly mounted disk) ! """ ! _code = 'ddsk' ! _subcode = 'Crea' ! aetools.keysubst(_arguments, self._argmap_create) ! _arguments['----'] = _object ! aetools.enumsubst(_arguments, 'SvAs', _Enum_fss_) ! aetools.enumsubst(_arguments, 'Blks', _Enum_long) ! aetools.enumsubst(_arguments, 'Zero', _Enum_bool) ! aetools.enumsubst(_arguments, 'Moun', _Enum_bool) ! aetools.enumsubst(_arguments, 'Fsys', _Enum_Fsys) ! _reply, _arguments, _attributes = self.send(_code, _subcode, ! _arguments, _attributes) ! if _arguments.has_key('errn'): ! raise aetools.Error, aetools.decodeerror(_arguments) ! # XXXX Optionally decode result ! if _arguments.has_key('----'): ! return _arguments['----'] ! def verify_checksum(self, _object, _attributes={}, **_arguments): ! """verify checksum: Verify the checksum of a Disk Copy 4.2 or a Disk Copy 6.0 read-only document ! Required argument: the disk image to be verified ! Keyword argument _attributes: AppleEvent attribute dictionary ! Returns: the result of the checksum verification ! """ ! _code = 'ddsk' ! _subcode = 'Vcrc' ! if _arguments: raise TypeError, 'No optional args expected' ! _arguments['----'] = _object ! _reply, _arguments, _attributes = self.send(_code, _subcode, ! _arguments, _attributes) ! if _arguments.has_key('errn'): ! raise aetools.Error, aetools.decodeerror(_arguments) ! # XXXX Optionally decode result ! if _arguments.has_key('----'): ! return _arguments['----'] ! def verify_signature(self, _object, _attributes={}, **_arguments): ! """verify signature: Verify the DigiSignŽ signature for a Disk Copy document ! Required argument: the disk image to be verified ! Keyword argument _attributes: AppleEvent attribute dictionary ! Returns: Is the DigiSignŽ signature valid? ! """ ! _code = 'ddsk' ! _subcode = 'Vsig' ! if _arguments: raise TypeError, 'No optional args expected' ! _arguments['----'] = _object ! _reply, _arguments, _attributes = self.send(_code, _subcode, ! _arguments, _attributes) ! if _arguments.has_key('errn'): ! raise aetools.Error, aetools.decodeerror(_arguments) ! # XXXX Optionally decode result ! if _arguments.has_key('----'): ! return _arguments['----'] ! _argmap_sign_image = { ! 'using_signer' : 'Sinr', ! } ! def sign_image(self, _object, _attributes={}, **_arguments): ! """sign image: Add a DigiSignŽ signature to a Disk Copy document ! Required argument: the disk image to be signed ! Keyword argument using_signer: a reference to signer file to use ! Keyword argument _attributes: AppleEvent attribute dictionary ! """ ! _code = 'ddsk' ! _subcode = 'Asig' ! aetools.keysubst(_arguments, self._argmap_sign_image) ! _arguments['----'] = _object ! aetools.enumsubst(_arguments, 'Sinr', _Enum_alis) ! _reply, _arguments, _attributes = self.send(_code, _subcode, ! _arguments, _attributes) ! if _arguments.has_key('errn'): ! raise aetools.Error, aetools.decodeerror(_arguments) ! # XXXX Optionally decode result ! if _arguments.has_key('----'): ! return _arguments['----'] ! _argmap_create_a_floppy_from = { ! 'signature_verification' : 'VSig', ! 'erase_confirmation' : 'Cfrm', ! 'make_multiple_floppies' : 'Mult', ! } ! def create_a_floppy_from(self, _object, _attributes={}, **_arguments): ! """create a floppy from: create a floppy disk from a Disk Copy document ! Required argument: the disk image to make a floppy from ! Keyword argument signature_verification: Should the DigiSignŽ signature be verified before creating a floppy disk? ! Keyword argument erase_confirmation: Should the user be asked to confirm the erasure of the previous contents of floppy disks? ! Keyword argument make_multiple_floppies: Should the user be prompted to create multiple floppy disks? ! Keyword argument _attributes: AppleEvent attribute dictionary ! """ ! _code = 'ddsk' ! _subcode = 'Bfpy' ! aetools.keysubst(_arguments, self._argmap_create_a_floppy_from) ! _arguments['----'] = _object ! aetools.enumsubst(_arguments, 'VSig', _Enum_bool) ! aetools.enumsubst(_arguments, 'Cfrm', _Enum_bool) ! aetools.enumsubst(_arguments, 'Mult', _Enum_bool) ! _reply, _arguments, _attributes = self.send(_code, _subcode, ! _arguments, _attributes) ! if _arguments.has_key('errn'): ! raise aetools.Error, aetools.decodeerror(_arguments) ! # XXXX Optionally decode result ! if _arguments.has_key('----'): ! return _arguments['----'] ! _argmap_check_image = { ! 'details' : 'ChDe', ! } ! def check_image(self, _object, _attributes={}, **_arguments): ! """check image: Check the disk imageÕs internal data structures for any inconsistencies. Works on NDIF, Disk Copy 4.2, DARTŽ, or DiskSet images. ! Required argument: the disk image to be verified ! Keyword argument details: Should the disk image details be displayed? ! Keyword argument _attributes: AppleEvent attribute dictionary ! Returns: a record containing a boolean (true/false) value if the image passes consistency tests, and the numbers of warnings and errors ! """ ! _code = 'ddsk' ! _subcode = 'Chek' ! aetools.keysubst(_arguments, self._argmap_check_image) ! _arguments['----'] = _object ! aetools.enumsubst(_arguments, 'ChDe', _Enum_bool) ! _reply, _arguments, _attributes = self.send(_code, _subcode, ! _arguments, _attributes) ! if _arguments.has_key('errn'): ! raise aetools.Error, aetools.decodeerror(_arguments) ! # XXXX Optionally decode result ! if _arguments.has_key('----'): ! return _arguments['----'] ! _argmap_segment_image = { ! 'segment_count' : 'SGCT', ! 'segment_size' : 'SGSZ', ! 'segment_name' : 'SGNM', ! 'image_ID' : 'SGID', ! } ! def segment_image(self, _object, _attributes={}, **_arguments): ! """segment image: Segment a NDIF R/W or R/O image into smaller pieces ! Required argument: the disk image to be segmented ! Keyword argument segment_count: the number of image segments to create ! Keyword argument segment_size: the size of image segments (in blocks) to create ! Keyword argument segment_name: the root name for each image segment file ! Keyword argument image_ID: string used to generate a unique image ID to group the segments ! Keyword argument _attributes: AppleEvent attribute dictionary ! Returns: a list of references to the image segments created ! """ ! _code = 'ddsk' ! _subcode = 'SGMT' ! aetools.keysubst(_arguments, self._argmap_segment_image) ! _arguments['----'] = _object ! _reply, _arguments, _attributes = self.send(_code, _subcode, ! _arguments, _attributes) ! if _arguments.has_key('errn'): ! raise aetools.Error, aetools.decodeerror(_arguments) ! # XXXX Optionally decode result ! if _arguments.has_key('----'): ! return _arguments['----'] ! _argmap_create_SMI = { ! 'source_images' : 'SMI1', ! 'launching_application' : 'SMI2', ! 'launching_document' : 'SMI3', ! 'version_string' : 'SMI4', ! 'checksum_verification' : 'VChk', ! 'signature_verification' : 'VSig', ! 'image_signing' : 'SImg', ! } ! def create_SMI(self, _object, _attributes={}, **_arguments): ! """create SMI: Creates a self-mounting image (SMI) from a list of NDIF disk images ! Required argument: the self-mounting image to create ! Keyword argument source_images: a list of references to sources images ! Keyword argument launching_application: the path to an application to launch ! Keyword argument launching_document: the path to a document to open ! Keyword argument version_string: sets the 'vers' 1 resource of the self-mounting image ! Keyword argument checksum_verification: Should the checksum of the source images be verified before creating the SMI? ! Keyword argument signature_verification: Should the DigiSignŽ signature of the source images be verified before creating the SMI? ! Keyword argument image_signing: Should the SMI be given a digital signature when it is created? ! Keyword argument _attributes: AppleEvent attribute dictionary ! Returns: a reference to the self-mounting image created ! """ ! _code = 'ddsk' ! _subcode = 'MSMI' ! aetools.keysubst(_arguments, self._argmap_create_SMI) ! _arguments['----'] = _object ! aetools.enumsubst(_arguments, 'VChk', _Enum_bool) ! aetools.enumsubst(_arguments, 'VSig', _Enum_bool) ! aetools.enumsubst(_arguments, 'SImg', _Enum_bool) ! _reply, _arguments, _attributes = self.send(_code, _subcode, ! _arguments, _attributes) ! if _arguments.has_key('errn'): ! raise aetools.Error, aetools.decodeerror(_arguments) ! # XXXX Optionally decode result ! if _arguments.has_key('----'): ! return _arguments['----'] class Verify_Checksum_reply_record(aetools.ComponentItem): ! """Verify Checksum reply record - """ ! want = 'Rcrc' class validity(aetools.NProperty): ! """validity - true if checksum is valid """ ! which = 'Vlid' ! want = 'bool' class expected_checksum(aetools.NProperty): ! """expected checksum - checksum value stored in the image header (in hexadecimal) """ ! which = 'crcE' ! want = 'TEXT' class calculated_checksum(aetools.NProperty): ! """calculated checksum - checksum value actually calculated (in hexadecimal) """ ! which = 'crcA' ! want = 'TEXT' class Check_Image_reply_record(aetools.ComponentItem): ! """Check Image reply record - """ ! want = 'Rchk' class consistency(aetools.NProperty): ! """consistency - Does the image pass consistency checks? """ ! which = 'Rch1' ! want = 'bool' class error_count(aetools.NProperty): ! """error count - the number of errors recorded """ ! which = 'Rch2' ! want = 'long' class warning_count(aetools.NProperty): ! """warning count - the number of warnings recorded """ ! which = 'Rch3' ! want = 'long' Verify_Checksum_reply_record._propdict = { ! 'validity' : validity, ! 'expected_checksum' : expected_checksum, ! 'calculated_checksum' : calculated_checksum, } Verify_Checksum_reply_record._elemdict = { } Check_Image_reply_record._propdict = { ! 'consistency' : consistency, ! 'error_count' : error_count, ! 'warning_count' : warning_count, } Check_Image_reply_record._elemdict = { } _Enum_Acss = { ! 'read_and_write' : 'RdWr', # read/write access ! 'read_only' : 'Rdxx', # read-only access ! 'any' : 'Anyx', # best possible access } _Enum_Fsys = { ! 'Mac_OS_Standard' : 'Fhfs', # classic HFS file system ! 'compatible_Mac_OS_Extended' : 'Fhf+', # new HFS+ file system } --- 13,395 ---- class Special_Events_Events: ! _argmap_mount = { ! 'access_mode' : 'Acss', ! 'checksum_verification' : 'VChk', ! 'signature_verification' : 'VSig', ! 'RAM_caching' : 'Cach', ! } ! def mount(self, _object, _attributes={}, **_arguments): ! """mount: Mounts an Disk Copy image as a disk volume ! Required argument: a reference to the disk image to be mounted ! Keyword argument access_mode: the access mode for mounted volume (default is "any", i.e. best possible) ! Keyword argument checksum_verification: Verify the checksum before mounting? ! Keyword argument signature_verification: Verify the DigiSignŽ signature before mounting? ! Keyword argument RAM_caching: Cache the disk image in RAM? (if omitted, don't cache) ! Keyword argument _attributes: AppleEvent attribute dictionary ! Returns: a reference to mounted disk ! """ ! _code = 'ddsk' ! _subcode = 'Moun' ! aetools.keysubst(_arguments, self._argmap_mount) ! _arguments['----'] = _object ! aetools.enumsubst(_arguments, 'Acss', _Enum_Acss) ! aetools.enumsubst(_arguments, 'VChk', _Enum_bool) ! aetools.enumsubst(_arguments, 'VSig', _Enum_bool) ! aetools.enumsubst(_arguments, 'Cach', _Enum_bool) ! _reply, _arguments, _attributes = self.send(_code, _subcode, ! _arguments, _attributes) ! if _arguments.has_key('errn'): ! raise aetools.Error, aetools.decodeerror(_arguments) ! # XXXX Optionally decode result ! if _arguments.has_key('----'): ! return _arguments['----'] ! _argmap_execute_DiskScript = { ! 'checksum_verification' : 'VChk', ! 'signature_verification' : 'VSig', ! } ! def execute_DiskScript(self, _object, _attributes={}, **_arguments): ! """execute DiskScript: Executes a Disk Copy-specific DiskScript ! Required argument: a reference to the DiskScript to execute ! Keyword argument checksum_verification: Should checksums be verified when mounting images referenced in the DiskScript? ! Keyword argument signature_verification: Should the DigiSignŽ signature of the DiskScript and the images it references be verified? ! Keyword argument _attributes: AppleEvent attribute dictionary ! """ ! _code = 'ddsk' ! _subcode = 'XEQd' ! aetools.keysubst(_arguments, self._argmap_execute_DiskScript) ! _arguments['----'] = _object ! aetools.enumsubst(_arguments, 'VChk', _Enum_bool) ! aetools.enumsubst(_arguments, 'VSig', _Enum_bool) ! _reply, _arguments, _attributes = self.send(_code, _subcode, ! _arguments, _attributes) ! if _arguments.has_key('errn'): ! raise aetools.Error, aetools.decodeerror(_arguments) ! # XXXX Optionally decode result ! if _arguments.has_key('----'): ! return _arguments['----'] ! def unmount(self, _object, _attributes={}, **_arguments): ! """unmount: Unmount and eject (if necessary) a volume ! Required argument: a reference to disk to be unmounted (and ejected) ! Keyword argument _attributes: AppleEvent attribute dictionary ! """ ! _code = 'ddsk' ! _subcode = 'Umnt' ! if _arguments: raise TypeError, 'No optional args expected' ! _arguments['----'] = _object ! _reply, _arguments, _attributes = self.send(_code, _subcode, ! _arguments, _attributes) ! if _arguments.has_key('errn'): ! raise aetools.Error, aetools.decodeerror(_arguments) ! # XXXX Optionally decode result ! if _arguments.has_key('----'): ! return _arguments['----'] ! _argmap_create = { ! 'saving_as' : 'SvAs', ! 'logical_blocks' : 'Blks', ! 'zeroing' : 'Zero', ! 'leave_image_mounted' : 'Moun', ! 'filesystem' : 'Fsys', ! } ! def create(self, _object, _attributes={}, **_arguments): ! """create: Create a new Disk Copy document ! Required argument: the name of the volume to create ! Keyword argument saving_as: the disk image to be created ! Keyword argument logical_blocks: the number of logical blocks ! Keyword argument zeroing: Should all blocks on the disk be set to zero? ! Keyword argument leave_image_mounted: Should the image be mounted after it is created? ! Keyword argument filesystem: file system to use (Mac OS Standard/compatible, Mac OS Enhanced) ! Keyword argument _attributes: AppleEvent attribute dictionary ! Returns: a reference to newly created disk image (or newly mounted disk) ! """ ! _code = 'ddsk' ! _subcode = 'Crea' ! aetools.keysubst(_arguments, self._argmap_create) ! _arguments['----'] = _object ! aetools.enumsubst(_arguments, 'SvAs', _Enum_fss_) ! aetools.enumsubst(_arguments, 'Blks', _Enum_long) ! aetools.enumsubst(_arguments, 'Zero', _Enum_bool) ! aetools.enumsubst(_arguments, 'Moun', _Enum_bool) ! aetools.enumsubst(_arguments, 'Fsys', _Enum_Fsys) ! _reply, _arguments, _attributes = self.send(_code, _subcode, ! _arguments, _attributes) ! if _arguments.has_key('errn'): ! raise aetools.Error, aetools.decodeerror(_arguments) ! # XXXX Optionally decode result ! if _arguments.has_key('----'): ! return _arguments['----'] ! def verify_checksum(self, _object, _attributes={}, **_arguments): ! """verify checksum: Verify the checksum of a Disk Copy 4.2 or a Disk Copy 6.0 read-only document ! Required argument: the disk image to be verified ! Keyword argument _attributes: AppleEvent attribute dictionary ! Returns: the result of the checksum verification ! """ ! _code = 'ddsk' ! _subcode = 'Vcrc' ! if _arguments: raise TypeError, 'No optional args expected' ! _arguments['----'] = _object ! _reply, _arguments, _attributes = self.send(_code, _subcode, ! _arguments, _attributes) ! if _arguments.has_key('errn'): ! raise aetools.Error, aetools.decodeerror(_arguments) ! # XXXX Optionally decode result ! if _arguments.has_key('----'): ! return _arguments['----'] ! def verify_signature(self, _object, _attributes={}, **_arguments): ! """verify signature: Verify the DigiSignŽ signature for a Disk Copy document ! Required argument: the disk image to be verified ! Keyword argument _attributes: AppleEvent attribute dictionary ! Returns: Is the DigiSignŽ signature valid? ! """ ! _code = 'ddsk' ! _subcode = 'Vsig' ! if _arguments: raise TypeError, 'No optional args expected' ! _arguments['----'] = _object ! _reply, _arguments, _attributes = self.send(_code, _subcode, ! _arguments, _attributes) ! if _arguments.has_key('errn'): ! raise aetools.Error, aetools.decodeerror(_arguments) ! # XXXX Optionally decode result ! if _arguments.has_key('----'): ! return _arguments['----'] ! _argmap_sign_image = { ! 'using_signer' : 'Sinr', ! } ! def sign_image(self, _object, _attributes={}, **_arguments): ! """sign image: Add a DigiSignŽ signature to a Disk Copy document ! Required argument: the disk image to be signed ! Keyword argument using_signer: a reference to signer file to use ! Keyword argument _attributes: AppleEvent attribute dictionary ! """ ! _code = 'ddsk' ! _subcode = 'Asig' ! aetools.keysubst(_arguments, self._argmap_sign_image) ! _arguments['----'] = _object ! aetools.enumsubst(_arguments, 'Sinr', _Enum_alis) ! _reply, _arguments, _attributes = self.send(_code, _subcode, ! _arguments, _attributes) ! if _arguments.has_key('errn'): ! raise aetools.Error, aetools.decodeerror(_arguments) ! # XXXX Optionally decode result ! if _arguments.has_key('----'): ! return _arguments['----'] ! _argmap_create_a_floppy_from = { ! 'signature_verification' : 'VSig', ! 'erase_confirmation' : 'Cfrm', ! 'make_multiple_floppies' : 'Mult', ! } ! def create_a_floppy_from(self, _object, _attributes={}, **_arguments): ! """create a floppy from: create a floppy disk from a Disk Copy document ! Required argument: the disk image to make a floppy from ! Keyword argument signature_verification: Should the DigiSignŽ signature be verified before creating a floppy disk? ! Keyword argument erase_confirmation: Should the user be asked to confirm the erasure of the previous contents of floppy disks? ! Keyword argument make_multiple_floppies: Should the user be prompted to create multiple floppy disks? ! Keyword argument _attributes: AppleEvent attribute dictionary ! """ ! _code = 'ddsk' ! _subcode = 'Bfpy' ! aetools.keysubst(_arguments, self._argmap_create_a_floppy_from) ! _arguments['----'] = _object ! aetools.enumsubst(_arguments, 'VSig', _Enum_bool) ! aetools.enumsubst(_arguments, 'Cfrm', _Enum_bool) ! aetools.enumsubst(_arguments, 'Mult', _Enum_bool) ! _reply, _arguments, _attributes = self.send(_code, _subcode, ! _arguments, _attributes) ! if _arguments.has_key('errn'): ! raise aetools.Error, aetools.decodeerror(_arguments) ! # XXXX Optionally decode result ! if _arguments.has_key('----'): ! return _arguments['----'] ! _argmap_check_image = { ! 'details' : 'ChDe', ! } ! def check_image(self, _object, _attributes={}, **_arguments): ! """check image: Check the disk imageÕs internal data structures for any inconsistencies. Works on NDIF, Disk Copy 4.2, DARTŽ, or DiskSet images. ! Required argument: the disk image to be verified ! Keyword argument details: Should the disk image details be displayed? ! Keyword argument _attributes: AppleEvent attribute dictionary ! Returns: a record containing a boolean (true/false) value if the image passes consistency tests, and the numbers of warnings and errors ! """ ! _code = 'ddsk' ! _subcode = 'Chek' ! aetools.keysubst(_arguments, self._argmap_check_image) ! _arguments['----'] = _object ! aetools.enumsubst(_arguments, 'ChDe', _Enum_bool) ! _reply, _arguments, _attributes = self.send(_code, _subcode, ! _arguments, _attributes) ! if _arguments.has_key('errn'): ! raise aetools.Error, aetools.decodeerror(_arguments) ! # XXXX Optionally decode result ! if _arguments.has_key('----'): ! return _arguments['----'] ! _argmap_segment_image = { ! 'segment_count' : 'SGCT', ! 'segment_size' : 'SGSZ', ! 'segment_name' : 'SGNM', ! 'image_ID' : 'SGID', ! } ! def segment_image(self, _object, _attributes={}, **_arguments): ! """segment image: Segment a NDIF R/W or R/O image into smaller pieces ! Required argument: the disk image to be segmented ! Keyword argument segment_count: the number of image segments to create ! Keyword argument segment_size: the size of image segments (in blocks) to create ! Keyword argument segment_name: the root name for each image segment file ! Keyword argument image_ID: string used to generate a unique image ID to group the segments ! Keyword argument _attributes: AppleEvent attribute dictionary ! Returns: a list of references to the image segments created ! """ ! _code = 'ddsk' ! _subcode = 'SGMT' ! aetools.keysubst(_arguments, self._argmap_segment_image) ! _arguments['----'] = _object ! _reply, _arguments, _attributes = self.send(_code, _subcode, ! _arguments, _attributes) ! if _arguments.has_key('errn'): ! raise aetools.Error, aetools.decodeerror(_arguments) ! # XXXX Optionally decode result ! if _arguments.has_key('----'): ! return _arguments['----'] ! _argmap_create_SMI = { ! 'source_images' : 'SMI1', ! 'launching_application' : 'SMI2', ! 'launching_document' : 'SMI3', ! 'version_string' : 'SMI4', ! 'checksum_verification' : 'VChk', ! 'signature_verification' : 'VSig', ! 'image_signing' : 'SImg', ! } ! def create_SMI(self, _object, _attributes={}, **_arguments): ! """create SMI: Creates a self-mounting image (SMI) from a list of NDIF disk images ! Required argument: the self-mounting image to create ! Keyword argument source_images: a list of references to sources images ! Keyword argument launching_application: the path to an application to launch ! Keyword argument launching_document: the path to a document to open ! Keyword argument version_string: sets the 'vers' 1 resource of the self-mounting image ! Keyword argument checksum_verification: Should the checksum of the source images be verified before creating the SMI? ! Keyword argument signature_verification: Should the DigiSignŽ signature of the source images be verified before creating the SMI? ! Keyword argument image_signing: Should the SMI be given a digital signature when it is created? ! Keyword argument _attributes: AppleEvent attribute dictionary ! Returns: a reference to the self-mounting image created ! """ ! _code = 'ddsk' ! _subcode = 'MSMI' ! aetools.keysubst(_arguments, self._argmap_create_SMI) ! _arguments['----'] = _object ! aetools.enumsubst(_arguments, 'VChk', _Enum_bool) ! aetools.enumsubst(_arguments, 'VSig', _Enum_bool) ! aetools.enumsubst(_arguments, 'SImg', _Enum_bool) ! _reply, _arguments, _attributes = self.send(_code, _subcode, ! _arguments, _attributes) ! if _arguments.has_key('errn'): ! raise aetools.Error, aetools.decodeerror(_arguments) ! # XXXX Optionally decode result ! if _arguments.has_key('----'): ! return _arguments['----'] class Verify_Checksum_reply_record(aetools.ComponentItem): ! """Verify Checksum reply record - """ ! want = 'Rcrc' class validity(aetools.NProperty): ! """validity - true if checksum is valid """ ! which = 'Vlid' ! want = 'bool' class expected_checksum(aetools.NProperty): ! """expected checksum - checksum value stored in the image header (in hexadecimal) """ ! which = 'crcE' ! want = 'TEXT' class calculated_checksum(aetools.NProperty): ! """calculated checksum - checksum value actually calculated (in hexadecimal) """ ! which = 'crcA' ! want = 'TEXT' class Check_Image_reply_record(aetools.ComponentItem): ! """Check Image reply record - """ ! want = 'Rchk' class consistency(aetools.NProperty): ! """consistency - Does the image pass consistency checks? """ ! which = 'Rch1' ! want = 'bool' class error_count(aetools.NProperty): ! """error count - the number of errors recorded """ ! which = 'Rch2' ! want = 'long' class warning_count(aetools.NProperty): ! """warning count - the number of warnings recorded """ ! which = 'Rch3' ! want = 'long' Verify_Checksum_reply_record._propdict = { ! 'validity' : validity, ! 'expected_checksum' : expected_checksum, ! 'calculated_checksum' : calculated_checksum, } Verify_Checksum_reply_record._elemdict = { } Check_Image_reply_record._propdict = { ! 'consistency' : consistency, ! 'error_count' : error_count, ! 'warning_count' : warning_count, } Check_Image_reply_record._elemdict = { } _Enum_Acss = { ! 'read_and_write' : 'RdWr', # read/write access ! 'read_only' : 'Rdxx', # read-only access ! 'any' : 'Anyx', # best possible access } _Enum_Fsys = { ! 'Mac_OS_Standard' : 'Fhfs', # classic HFS file system ! 'compatible_Mac_OS_Extended' : 'Fhf+', # new HFS+ file system } *************** *** 403,417 **** # _classdeclarations = { ! 'Rchk' : Check_Image_reply_record, ! 'Rcrc' : Verify_Checksum_reply_record, } _propdeclarations = { ! 'crcE' : expected_checksum, ! 'Rch2' : error_count, ! 'crcA' : calculated_checksum, ! 'Rch3' : warning_count, ! 'Vlid' : validity, ! 'Rch1' : consistency, } --- 403,417 ---- # _classdeclarations = { ! 'Rchk' : Check_Image_reply_record, ! 'Rcrc' : Verify_Checksum_reply_record, } _propdeclarations = { ! 'crcE' : expected_checksum, ! 'Rch2' : error_count, ! 'crcA' : calculated_checksum, ! 'Rch3' : warning_count, ! 'Vlid' : validity, ! 'Rch1' : consistency, } *************** *** 420,424 **** _enumdeclarations = { ! 'Acss' : _Enum_Acss, ! 'Fsys' : _Enum_Fsys, } --- 420,424 ---- _enumdeclarations = { ! 'Acss' : _Enum_Acss, ! 'Fsys' : _Enum_Fsys, } Index: Standard_Suite.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Demo/applescript/Disk_Copy/Standard_Suite.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Standard_Suite.py 17 May 2001 12:44:45 -0000 1.2 --- Standard_Suite.py 18 Jul 2004 05:58:04 -0000 1.3 *************** *** 13,199 **** class Standard_Suite_Events: ! _argmap_save = { ! '_in' : 'kfil', ! 'using_format' : 'SvAs', ! 'checksum_verification' : 'VChk', ! 'signature_verification' : 'VSig', ! 'image_signing' : 'SImg', ! 'leave_image_mounted' : 'Moun', ! 'percent_free_space' : 'Slop', ! 'logical_blocks' : 'Blks', ! 'zeroing' : 'Zero', ! } ! def save(self, _object, _attributes={}, **_arguments): ! """save: Save an object ! Required argument: the source object ! Keyword argument _in: the target object ! Keyword argument using_format: the format for the target ! Keyword argument checksum_verification: Should the checksum be verified before saving? ! Keyword argument signature_verification: Should the DigiSignŽ signature be verified before saving? ! Keyword argument image_signing: Should the image be signed? ! Keyword argument leave_image_mounted: Should the image be mounted after saving? ! Keyword argument percent_free_space: percent free space to reserve (for image folder operation, 0-255%) ! Keyword argument logical_blocks: number of logical blocks in the image (for image folder operation) ! Keyword argument zeroing: Should all the blocks in the image be set to zeros? (for image folder operation) ! Keyword argument _attributes: AppleEvent attribute dictionary ! Returns: the result of the save operation ! """ ! _code = 'core' ! _subcode = 'save' ! aetools.keysubst(_arguments, self._argmap_save) ! _arguments['----'] = _object ! aetools.enumsubst(_arguments, 'kfil', _Enum_obj_) ! aetools.enumsubst(_arguments, 'SvAs', _Enum_SvAs) ! aetools.enumsubst(_arguments, 'VChk', _Enum_bool) ! aetools.enumsubst(_arguments, 'VSig', _Enum_bool) ! aetools.enumsubst(_arguments, 'SImg', _Enum_bool) ! aetools.enumsubst(_arguments, 'Moun', _Enum_bool) ! aetools.enumsubst(_arguments, 'Slop', _Enum_long) ! aetools.enumsubst(_arguments, 'Blks', _Enum_long) ! aetools.enumsubst(_arguments, 'Zero', _Enum_bool) ! _reply, _arguments, _attributes = self.send(_code, _subcode, ! _arguments, _attributes) ! if _arguments.has_key('errn'): ! raise aetools.Error, aetools.decodeerror(_arguments) ! # XXXX Optionally decode result ! if _arguments.has_key('----'): ! return _arguments['----'] ! def do_script(self, _object, _attributes={}, **_arguments): ! """do script: Execute an attached script located in the folder "Scripts" ! Required argument: the script to be executed ! Keyword argument _attributes: AppleEvent attribute dictionary ! """ ! _code = 'core' ! _subcode = 'dosc' ! if _arguments: raise TypeError, 'No optional args expected' ! _arguments['----'] = _object ! _reply, _arguments, _attributes = self.send(_code, _subcode, ! _arguments, _attributes) ! if _arguments.has_key('errn'): ! raise aetools.Error, aetools.decodeerror(_arguments) ! # XXXX Optionally decode result ! if _arguments.has_key('----'): ! return _arguments['----'] class application(aetools.ComponentItem): ! """application - The Disk Copy application """ ! want = 'capp' class version(aetools.NProperty): ! """version - the version of this application """ ! which = 'vers' ! want = 'vers' class name(aetools.NProperty): ! """name - the name of this application """ ! which = 'pnam' ! want = 'TEXT' class comment(aetools.NProperty): ! """comment - the comment associated with the application """ ! which = 'comt' ! want = 'TEXT' class driver_version(aetools.NProperty): ! """driver version - the version of the disk image driver """ ! which = 'dVer' ! want = 'vers' class nonejectable_mode(aetools.NProperty): ! """nonejectable mode - Should mounted images be non-ejectable? """ ! which = 'otto' ! want = 'bool' class save_log_file(aetools.NProperty): ! """save log file - Should the log file be saved on disk? """ ! which = 'PSaL' ! want = 'bool' class use_speech(aetools.NProperty): ! """use speech - Should Disk Copy use spoken feedback? """ ! which = 'PTlk' ! want = 'bool' class smart_Save_As(aetools.NProperty): ! """smart Save As - Should the Save As... dialog box automatically go to the right folder? """ ! which = 'PSSP' ! want = 'bool' class checksum_verification(aetools.NProperty): ! """checksum verification - Should image checksums be verified? """ ! which = 'PVeC' ! want = 'bool' class signature_verification(aetools.NProperty): ! """signature verification - Should digital signatures be verified? """ ! which = 'PVeS' ! want = 'bool' class exclude_DiskScripts(aetools.NProperty): ! """exclude DiskScripts - Should images referenced in DiskScripts/DiskSets be excluded from verification? """ ! which = 'PExD' ! want = 'bool' class exclude_remote_images(aetools.NProperty): ! """exclude remote images - Should images that are located on network volumes be excluded from verification? """ ! which = 'PExR' ! want = 'bool' class image_signing(aetools.NProperty): ! """image signing - Should images be signed with a digital signature? """ ! which = 'PSiI' ! want = 'bool' class leave_image_mounted(aetools.NProperty): ! """leave image mounted - Should images be mounted after they are created? """ ! which = 'PMoA' ! want = 'bool' class erase_confirmation(aetools.NProperty): ! """erase confirmation - Should the user be required to confirm commands that erase disks? """ ! which = 'PCoE' ! want = 'bool' class zeroing(aetools.NProperty): ! """zeroing - Should all blocks of a new image be set to zero? """ ! which = 'PZeB' ! want = 'bool' class default_create_size(aetools.NProperty): ! """default create size - the default size for a new image, in blocks (512 bytes per block) """ ! which = 'PDeS' ! want = 'long' class default_create_name(aetools.NProperty): ! """default create name - the default volume name for a new image """ ! which = 'PDeN' ! want = 'TEXT' class make_multiple_floppies(aetools.NProperty): ! """make multiple floppies - Should the user be prompted to make multiple floppy disk images at a time? """ ! which = 'PBuM' ! want = 'bool' class auto_image_upon_insert(aetools.NProperty): ! """auto image upon insert - Should a newly-inserted disk automatically be processed into an image? """ ! which = 'Paim' ! want = 'bool' class eject_after_auto_image(aetools.NProperty): ! """eject after auto image - Should auto-imaged disks be ejected afterwards? """ ! which = 'Pejc' ! want = 'bool' class auto_copy_upon_floppy_insert(aetools.NProperty): ! """auto copy upon floppy insert - Instead of auto-imaging, should newly-inserted floppy disks be copied? """ ! which = 'Pcpf' ! want = 'bool' class volume_suffix(aetools.NProperty): ! """volume suffix - the default volume name suffix """ ! which = 'PDiE' ! want = 'TEXT' class image_suffix(aetools.NProperty): ! """image suffix - the default image name suffix """ ! which = 'PImE' ! want = 'TEXT' class default_file_system(aetools.NProperty): ! """default file system - the default file system type for new blank images """ ! which = 'Pfsy' ! want = 'Fsys' class default_image_format(aetools.NProperty): ! """default image format - the default image file format """ ! which = 'Pdfm' ! want = 'SvAs' class disk(aetools.ComponentItem): ! """disk - A mounted volume """ ! want = 'Disk' name = name --- 13,199 ---- class Standard_Suite_Events: ! _argmap_save = { ! '_in' : 'kfil', ! 'using_format' : 'SvAs', ! 'checksum_verification' : 'VChk', ! 'signature_verification' : 'VSig', ! 'image_signing' : 'SImg', ! 'leave_image_mounted' : 'Moun', ! 'percent_free_space' : 'Slop', ! 'logical_blocks' : 'Blks', ! 'zeroing' : 'Zero', ! } ! def save(self, _object, _attributes={}, **_arguments): ! """save: Save an object ! Required argument: the source object ! Keyword argument _in: the target object ! Keyword argument using_format: the format for the target ! Keyword argument checksum_verification: Should the checksum be verified before saving? ! Keyword argument signature_verification: Should the DigiSignŽ signature be verified before saving? ! Keyword argument image_signing: Should the image be signed? ! Keyword argument leave_image_mounted: Should the image be mounted after saving? ! Keyword argument percent_free_space: percent free space to reserve (for image folder operation, 0-255%) ! Keyword argument logical_blocks: number of logical blocks in the image (for image folder operation) ! Keyword argument zeroing: Should all the blocks in the image be set to zeros? (for image folder operation) ! Keyword argument _attributes: AppleEvent attribute dictionary ! Returns: the result of the save operation ! """ ! _code = 'core' ! _subcode = 'save' ! aetools.keysubst(_arguments, self._argmap_save) ! _arguments['----'] = _object ! aetools.enumsubst(_arguments, 'kfil', _Enum_obj_) ! aetools.enumsubst(_arguments, 'SvAs', _Enum_SvAs) ! aetools.enumsubst(_arguments, 'VChk', _Enum_bool) ! aetools.enumsubst(_arguments, 'VSig', _Enum_bool) ! aetools.enumsubst(_arguments, 'SImg', _Enum_bool) ! aetools.enumsubst(_arguments, 'Moun', _Enum_bool) ! aetools.enumsubst(_arguments, 'Slop', _Enum_long) ! aetools.enumsubst(_arguments, 'Blks', _Enum_long) ! aetools.enumsubst(_arguments, 'Zero', _Enum_bool) ! _reply, _arguments, _attributes = self.send(_code, _subcode, ! _arguments, _attributes) ! if _arguments.has_key('errn'): ! raise aetools.Error, aetools.decodeerror(_arguments) ! # XXXX Optionally decode result ! if _arguments.has_key('----'): ! return _arguments['----'] ! def do_script(self, _object, _attributes={}, **_arguments): ! """do script: Execute an attached script located in the folder "Scripts" ! Required argument: the script to be executed ! Keyword argument _attributes: AppleEvent attribute dictionary ! """ ! _code = 'core' ! _subcode = 'dosc' ! if _arguments: raise TypeError, 'No optional args expected' ! _arguments['----'] = _object ! _reply, _arguments, _attributes = self.send(_code, _subcode, ! _arguments, _attributes) ! if _arguments.has_key('errn'): ! raise aetools.Error, aetools.decodeerror(_arguments) ! # XXXX Optionally decode result ! if _arguments.has_key('----'): ! return _arguments['----'] class application(aetools.ComponentItem): ! """application - The Disk Copy application """ ! want = 'capp' class version(aetools.NProperty): ! """version - the version of this application """ ! which = 'vers' ! want = 'vers' class name(aetools.NProperty): ! """name - the name of this application """ ! which = 'pnam' ! want = 'TEXT' class comment(aetools.NProperty): ! """comment - the comment associated with the application """ ! which = 'comt' ! want = 'TEXT' class driver_version(aetools.NProperty): ! """driver version - the version of the disk image driver """ ! which = 'dVer' ! want = 'vers' class nonejectable_mode(aetools.NProperty): ! """nonejectable mode - Should mounted images be non-ejectable? """ ! which = 'otto' ! want = 'bool' class save_log_file(aetools.NProperty): ! """save log file - Should the log file be saved on disk? """ ! which = 'PSaL' ! want = 'bool' class use_speech(aetools.NProperty): ! """use speech - Should Disk Copy use spoken feedback? """ ! which = 'PTlk' ! want = 'bool' class smart_Save_As(aetools.NProperty): ! """smart Save As - Should the Save As... dialog box automatically go to the right folder? """ ! which = 'PSSP' ! want = 'bool' class checksum_verification(aetools.NProperty): ! """checksum verification - Should image checksums be verified? """ ! which = 'PVeC' ! want = 'bool' class signature_verification(aetools.NProperty): ! """signature verification - Should digital signatures be verified? """ ! which = 'PVeS' ! want = 'bool' class exclude_DiskScripts(aetools.NProperty): ! """exclude DiskScripts - Should images referenced in DiskScripts/DiskSets be excluded from verification? """ ! which = 'PExD' ! want = 'bool' class exclude_remote_images(aetools.NProperty): ! """exclude remote images - Should images that are located on network volumes be excluded from verification? """ ! which = 'PExR' ! want = 'bool' class image_signing(aetools.NProperty): ! """image signing - Should images be signed with a digital signature? """ ! which = 'PSiI' ! want = 'bool' class leave_image_mounted(aetools.NProperty): ! """leave image mounted - Should images be mounted after they are created? """ ! which = 'PMoA' ! want = 'bool' class erase_confirmation(aetools.NProperty): ! """erase confirmation - Should the user be required to confirm commands that erase disks? """ ! which = 'PCoE' ! want = 'bool' class zeroing(aetools.NProperty): ! """zeroing - Should all blocks of a new image be set to zero? """ ! which = 'PZeB' ! want = 'bool' class default_create_size(aetools.NProperty): ! """default create size - the default size for a new image, in blocks (512 bytes per block) """ ! which = 'PDeS' ! want = 'long' class default_create_name(aetools.NProperty): ! """default create name - the default volume name for a new image """ ! which = 'PDeN' ! want = 'TEXT' class make_multiple_floppies(aetools.NProperty): ! """make multiple floppies - Should the user be prompted to make multiple floppy disk images at a time? """ ! which = 'PBuM' ! want = 'bool' class auto_image_upon_insert(aetools.NProperty): ! """auto image upon insert - Should a newly-inserted disk automatically be processed into an image? """ ! which = 'Paim' ! want = 'bool' class eject_after_auto_image(aetools.NProperty): ! """eject after auto image - Should auto-imaged disks be ejected afterwards? """ ! which = 'Pejc' ! want = 'bool' class auto_copy_upon_floppy_insert(aetools.NProperty): ! """auto copy upon floppy insert - Instead of auto-imaging, should newly-inserted floppy disks be copied? """ ! which = 'Pcpf' ! want = 'bool' class volume_suffix(aetools.NProperty): ! """volume suffix - the default volume name suffix """ ! which = 'PDiE' ! want = 'TEXT' class image_suffix(aetools.NProperty): ! """image suffix - the default image name suffix """ ! which = 'PImE' ! want = 'TEXT' class default_file_system(aetools.NProperty): ! """default file system - the default file system type for new blank images """ ! which = 'Pfsy' ! want = 'Fsys' class default_image_format(aetools.NProperty): ! """default image format - the default image file format """ ! which = 'Pdfm' ! want = 'SvAs' class disk(aetools.ComponentItem): ! """disk - A mounted volume """ ! want = 'Disk' name = name *************** *** 201,235 **** comment = comment class locked(aetools.NProperty): ! """locked - Is the disk locked? """ ! which = 'islk' ! want = 'bool' class creation_date(aetools.NProperty): ! """creation date - the creation date of disk """ ! which = 'ascd' ! want = 'ldt ' class modification_date(aetools.NProperty): ! """modification date - the modification date of disk """ ! which = 'asmo' ! want = 'ldt ' class crc32_checksum(aetools.NProperty): ! """crc32 checksum - the crc-32 checksum of the disk """ ! which = 'Xcrc' ! want = 'TEXT' class disk_copy_4_2e_2_checksum(aetools.NProperty): ! """disk copy 4.2 checksum - the Disk Copy 4.2 checksum of the disk """ ! which = 'Xc42' ! want = 'TEXT' class block_count(aetools.NProperty): ! """block count - the number of blocks on disk """ ! which = 'Xblk' ! want = 'long' class file_system(aetools.NProperty): ! """file system - the file system used on disk """ ! which = 'Xfsi' ! want = 'TEXT' class folder(aetools.ComponentItem): ! """folder - A folder or directory on a disk """ ! want = 'Fold' name = name --- 201,235 ---- comment = comment class locked(aetools.NProperty): ! """locked - Is the disk locked? """ ! which = 'islk' ! want = 'bool' class creation_date(aetools.NProperty): ! """creation date - the creation date of disk """ ! which = 'ascd' ! want = 'ldt ' class modification_date(aetools.NProperty): ! """modification date - the modification date of disk """ ! which = 'asmo' ! want = 'ldt ' class crc32_checksum(aetools.NProperty): ! """crc32 checksum - the crc-32 checksum of the disk """ ! which = 'Xcrc' ! want = 'TEXT' class disk_copy_4_2e_2_checksum(aetools.NProperty): ! """disk copy 4.2 checksum - the Disk Copy 4.2 checksum of the disk """ ! which = 'Xc42' ! want = 'TEXT' class block_count(aetools.NProperty): ! """block count - the number of blocks on disk """ ! which = 'Xblk' ! want = 'long' class file_system(aetools.NProperty): ! """file system - the file system used on disk """ ! which = 'Xfsi' ! want = 'TEXT' class folder(aetools.ComponentItem): ! """folder - A folder or directory on a disk """ ! want = 'Fold' name = name *************** *** 242,247 **** class disk_image(aetools.ComponentItem): ! """disk image - A disk image file """ ! want = 'DImg' name = name --- 242,247 ---- class disk_image(aetools.ComponentItem): ! """disk image - A disk image file """ ! want = 'DImg' name = name *************** *** 255,281 **** modification_date = modification_date class file_format(aetools.NProperty): ! """file format - the format of the disk image file """ ! which = 'Ifmt' ! want = 'TEXT' class signed(aetools.NProperty): ! """signed - Does the disk image have a DigiSignŽ signature? """ ! which = 'Isin' ! want = 'bool' class compressed(aetools.NProperty): ! """compressed - Is the disk image compressed? """ ! which = 'Icom' ! want = 'bool' class segmented(aetools.NProperty): ! """segmented - Is the disk image segmented? """ ! which = 'Iseg' ! want = 'bool' class segments(aetools.NProperty): ! """segments - a list of references to other segments that make up a complete image """ ! which = 'Isg#' ! want = 'fss ' class disk_name(aetools.NProperty): ! """disk name - the name of the disk this image represents """ ! which = 'Idnm' ! want = 'TEXT' crc32_checksum = crc32_checksum --- 255,281 ---- modification_date = modification_date class file_format(aetools.NProperty): ! """file format - the format of the disk image file """ ! which = 'Ifmt' ! want = 'TEXT' class signed(aetools.NProperty): ! """signed - Does the disk image have a DigiSignŽ signature? """ ! which = 'Isin' ! want = 'bool' class compressed(aetools.NProperty): ! """compressed - Is the disk image compressed? """ ! which = 'Icom' ! want = 'bool' class segmented(aetools.NProperty): ! """segmented - Is the disk image segmented? """ ! which = 'Iseg' ! want = 'bool' class segments(aetools.NProperty): ! """segments - a list of references to other segments that make up a complete image """ ! which = 'Isg#' ! want = 'fss ' class disk_name(aetools.NProperty): ! """disk name - the name of the disk this image represents """ ! which = 'Idnm' ! want = 'TEXT' crc32_checksum = crc32_checksum *************** *** 287,408 **** file_system = file_system class data_fork_size(aetools.NProperty): ! """data fork size - the size (in bytes) of the data fork of the disk image """ ! which = 'Idfk' ! want = 'long' class resource_fork_size(aetools.NProperty): ! """resource fork size - the size (in bytes) of the resource fork of the disk image """ ! which = 'Irfk' ! want = 'long' class Save_reply_record(aetools.ComponentItem): ! """Save reply record - Result from the save operation """ ! want = 'cpyR' class resulting_target_object(aetools.NProperty): ! """resulting target object - a reference to the target object after it has been saved """ ! which = 'rcpO' ! want = 'obj ' class copy_type(aetools.NProperty): ! """copy type - the way in which the target object was saved """ ! which = 'rcpT' ! want = 'rcpT' application._propdict = { ! 'version' : version, ! 'name' : name, ! 'comment' : comment, ! 'driver_version' : driver_version, ! 'nonejectable_mode' : nonejectable_mode, ! 'save_log_file' : save_log_file, ! 'use_speech' : use_speech, ! 'smart_Save_As' : smart_Save_As, ! 'checksum_verification' : checksum_verification, ! 'signature_verification' : signature_verification, ! 'exclude_DiskScripts' : exclude_DiskScripts, ! 'exclude_remote_images' : exclude_remote_images, ! 'image_signing' : image_signing, ! 'leave_image_mounted' : leave_image_mounted, ! 'erase_confirmation' : erase_confirmation, ! 'zeroing' : zeroing, ! 'default_create_size' : default_create_size, ! 'default_create_name' : default_create_name, ! 'make_multiple_floppies' : make_multiple_floppies, ! 'auto_image_upon_insert' : auto_image_upon_insert, ! 'eject_after_auto_image' : eject_after_auto_image, ! 'auto_copy_upon_floppy_insert' : auto_copy_upon_floppy_insert, ! 'volume_suffix' : volume_suffix, ! 'image_suffix' : image_suffix, ! 'default_file_system' : default_file_system, ! 'default_image_format' : default_image_format, } application._elemdict = { } disk._propdict = { ! 'name' : name, ! 'comment' : comment, ! 'locked' : locked, ! 'creation_date' : creation_date, ! 'modification_date' : modification_date, ! 'crc32_checksum' : crc32_checksum, ! 'disk_copy_4_2e_2_checksum' : disk_copy_4_2e_2_checksum, ! 'block_count' : block_count, ! 'file_system' : file_system, } disk._elemdict = { } folder._propdict = { ! 'name' : name, ! 'comment' : comment, ! 'creation_date' : creation_date, ! 'modification_date' : modification_date, } folder._elemdict = { } disk_image._propdict = { ! 'name' : name, ! 'comment' : comment, ! 'locked' : locked, ! 'creation_date' : creation_date, ! 'modification_date' : modification_date, ! 'file_format' : file_format, ! 'signed' : signed, ! 'compressed' : compressed, ! 'segmented' : segmented, ! 'segments' : segments, ! 'disk_name' : disk_name, ! 'crc32_checksum' : crc32_checksum, ! 'disk_copy_4_2e_2_checksum' : disk_copy_4_2e_2_checksum, ! 'block_count' : block_count, ! 'file_system' : file_system, ! 'data_fork_size' : data_fork_size, ! 'resource_fork_size' : resource_fork_size, } disk_image._elemdict = { } Save_reply_record._propdict = { ! 'resulting_target_object' : resulting_target_object, ! 'copy_type' : copy_type, } Save_reply_record._elemdict = { } _Enum_UIAc = { ! 'never_interact' : 'eNvr', # DonÕt allow any interaction at all ! 'interact_with_self' : 'eInS', # Only allow interaction from internal events ! 'interact_with_local' : 'eInL', # Allow interaction from any event originating on this machine ! 'interact_with_all' : 'eInA', # Allow interaction from network events } _Enum_SvAs = { ! 'NDIF_RW' : 'RdWr', # read/write NDIF disk image ! 'NDIF_RO' : 'Rdxx', # read-only NDIF disk image ! 'NDIF_Compressed' : 'ROCo', # compressed NDIF disk image ! 'Disk_Copy_4_2e_2' : 'DC42', # Disk Copy 4.2 disk image } _Enum_rcpT = { ! 'block_disk_copy' : 'cpBl', # block-by-block disk-level copy ! 'files_and_file_ID_copy' : 'cpID', # all files including desktop databases and file IDÕs ! 'files_and_desktop_info' : 'cpDT', # all files and most desktop information ! 'files_only' : 'cpFI', # all files but no desktop information ! 'disk_image_conversion' : 'cpCV', # disk image format conversion ! 'disk_image_creation' : 'cpCR', # disk image creation } --- 287,408 ---- file_system = file_system class data_fork_size(aetools.NProperty): ! """data fork size - the size (in bytes) of the data fork of the disk image """ ! which = 'Idfk' ! want = 'long' class resource_fork_size(aetools.NProperty): ! """resource fork size - the size (in bytes) of the resource fork of the disk image """ ! which = 'Irfk' ! want = 'long' class Save_reply_record(aetools.ComponentItem): ! """Save reply record - Result from the save operation """ ! want = 'cpyR' class resulting_target_object(aetools.NProperty): ! """resulting target object - a reference to the target object after it has been saved """ ! which = 'rcpO' ! want = 'obj ' class copy_type(aetools.NProperty): ! """copy type - the way in which the target object was saved """ ! which = 'rcpT' ! want = 'rcpT' application._propdict = { ! 'version' : version, ! 'name' : name, ! 'comment' : comment, ! 'driver_version' : driver_version, ! 'nonejectable_mode' : nonejectable_mode, ! 'save_log_file' : save_log_file, ! 'use_speech' : use_speech, ! 'smart_Save_As' : smart_Save_As, ! 'checksum_verification' : checksum_verification, ! 'signature_verification' : signature_verification, ! 'exclude_DiskScripts' : exclude_DiskScripts, ! 'exclude_remote_images' : exclude_remote_images, ! 'image_signing' : image_signing, ! 'leave_image_mounted' : leave_image_mounted, ! 'erase_confirmation' : erase_confirmation, ! 'zeroing' : zeroing, ! 'default_create_size' : default_create_size, ! 'default_create_name' : default_create_name, ! 'make_multiple_floppies' : make_multiple_floppies, ! 'auto_image_upon_insert' : auto_image_upon_insert, ! 'eject_after_auto_image' : eject_after_auto_image, ! 'auto_copy_upon_floppy_insert' : auto_copy_upon_floppy_insert, ! 'volume_suffix' : volume_suffix, ! 'image_suffix' : image_suffix, ! 'default_file_system' : default_file_system, ! 'default_image_format' : default_image_format, } application._elemdict = { } disk._propdict = { ! 'name' : name, ! 'comment' : comment, ! 'locked' : locked, ! 'creation_date' : creation_date, ! 'modification_date' : modification_date, ! 'crc32_checksum' : crc32_checksum, ! 'disk_copy_4_2e_2_checksum' : disk_copy_4_2e_2_checksum, ! 'block_count' : block_count, ! 'file_system' : file_system, } disk._elemdict = { } folder._propdict = { ! 'name' : name, ! 'comment' : comment, ! 'creation_date' : creation_date, ! 'modification_date' : modification_date, } folder._elemdict = { } disk_image._propdict = { ! 'name' : name, ! 'comment' : comment, ! 'locked' : locked, ! 'creation_date' : creation_date, ! 'modification_date' : modification_date, ! 'file_format' : file_format, ! 'signed' : signed, ! 'compressed' : compressed, ! 'segmented' : segmented, ! 'segments' : segments, ! 'disk_name' : disk_name, ! 'crc32_checksum' : crc32_checksum, ! 'disk_copy_4_2e_2_checksum' : disk_copy_4_2e_2_checksum, ! 'block_count' : block_count, ! 'file_system' : file_system, ! 'data_fork_size' : data_fork_size, ! 'resource_fork_size' : resource_fork_size, } disk_image._elemdict = { } Save_reply_record._propdict = { ! 'resulting_target_object' : resulting_target_object, ! 'copy_type' : copy_type, } Save_reply_record._elemdict = { } _Enum_UIAc = { ! 'never_interact' : 'eNvr', # DonÕt allow any interaction at all ! 'interact_with_self' : 'eInS', # Only allow interaction from internal events ! 'interact_with_local' : 'eInL', # Allow interaction from any event originating on this machine ! 'interact_with_all' : 'eInA', # Allow interaction from network events } _Enum_SvAs = { ! 'NDIF_RW' : 'RdWr', # read/write NDIF disk image ! 'NDIF_RO' : 'Rdxx', # read-only NDIF disk image ! 'NDIF_Compressed' : 'ROCo', # compressed NDIF disk image ! 'Disk_Copy_4_2e_2' : 'DC42', # Disk Copy 4.2 disk image } _Enum_rcpT = { ! 'block_disk_copy' : 'cpBl', # block-by-block disk-level copy ! 'files_and_file_ID_copy' : 'cpID', # all files including desktop databases and file IDÕs ! 'files_and_desktop_info' : 'cpDT', # all files and most desktop information ! 'files_only' : 'cpFI', # all files but no desktop information ! 'disk_image_conversion' : 'cpCV', # disk image format conversion ! 'disk_image_creation' : 'cpCR', # disk image creation } *************** *** 415,469 **** # _classdeclarations = { ! 'DImg' : disk_image, ! 'capp' : application, ! 'Disk' : disk, ! 'Fold' : folder, ! 'cpyR' : Save_reply_record, } _propdeclarations = { ! 'Xcrc' : crc32_checksum, ! 'PDeS' : default_create_size, ! 'Idnm' : disk_name, ! 'PSSP' : smart_Save_As, ! 'Pcpf' : auto_copy_upon_floppy_insert, ! 'pnam' : name, ! 'Isin' : signed, ! 'otto' : nonejectable_mode, ! 'PExD' : exclude_DiskScripts, ! 'Iseg' : segmented, ! 'islk' : locked, ! 'asmo' : modification_date, ! 'PTlk' : use_speech, ! 'Pfsy' : default_file_system, ! 'PVeC' : checksum_verification, ! 'Xc42' : disk_copy_4_2e_2_checksum, ! 'rcpO' : resulting_target_object, ! 'Paim' : auto_image_upon_insert, ! 'comt' : comment, ! 'PCoE' : erase_confirmation, ! 'dVer' : driver_version, ! 'PDeN' : default_create_name, ! 'PBuM' : make_multiple_floppies, ! 'rcpT' : copy_type, ! 'PDiE' : volume_suffix, ! 'Ifmt' : file_format, ! 'Pdfm' : default_image_format, ! 'ascd' : creation_date, ! 'Pejc' : eject_after_auto_image, ! 'PZeB' : zeroing, ! 'PExR' : exclude_remote_images, ! 'PImE' : image_suffix, ! 'PVeS' : signature_verification, ! 'PSaL' : save_log_file, ! 'Xblk' : block_count, ! 'PMoA' : leave_image_mounted, ! 'Isg#' : segments, ! 'Irfk' : resource_fork_size, ! 'Icom' : compressed, ! 'Xfsi' : file_system, ! 'Idfk' : data_fork_size, ! 'vers' : version, ! 'PSiI' : image_signing, } --- 415,469 ---- # _classdeclarations = { ! 'DImg' : disk_image, ! 'capp' : application, ! 'Disk' : disk, ! 'Fold' : folder, ! 'cpyR' : Save_reply_record, } _propdeclarations = { ! 'Xcrc' : crc32_checksum, ! 'PDeS' : default_create_size, ! 'Idnm' : disk_name, ! 'PSSP' : smart_Save_As, ! 'Pcpf' : auto_copy_upon_floppy_insert, ! 'pnam' : name, ! 'Isin' : signed, ! 'otto' : nonejectable_mode, ! 'PExD' : exclude_DiskScripts, ! 'Iseg' : segmented, ! 'islk' : locked, ! 'asmo' : modification_date, ! 'PTlk' : use_speech, ! 'Pfsy' : default_file_system, ! 'PVeC' : checksum_verification, ! 'Xc42' : disk_copy_4_2e_2_checksum, ! 'rcpO' : resulting_target_object, ! 'Paim' : auto_image_upon_insert, ! 'comt' : comment, ! 'PCoE' : erase_confirmation, ! 'dVer' : driver_version, ! 'PDeN' : default_create_name, ! 'PBuM' : make_multiple_floppies, ! 'rcpT' : copy_type, ! 'PDiE' : volume_suffix, ! 'Ifmt' : file_format, ! 'Pdfm' : default_image_format, ! 'ascd' : creation_date, ! 'Pejc' : eject_after_auto_image, ! 'PZeB' : zeroing, ! 'PExR' : exclude_remote_images, ! 'PImE' : image_suffix, ! 'PVeS' : signature_verification, ! 'PSaL' : save_log_file, ! 'Xblk' : block_count, ! 'PMoA' : leave_image_mounted, ! 'Isg#' : segments, ! 'Irfk' : resource_fork_size, ! 'Icom' : compressed, ! 'Xfsi' : file_system, ! 'Idfk' : data_fork_size, ! 'vers' : version, ! 'PSiI' : image_signing, } *************** *** 472,477 **** _enumdeclarations = { ! 'SvAs' : _Enum_SvAs, ! 'UIAc' : _Enum_UIAc, ! 'rcpT' : _Enum_rcpT, } --- 472,477 ---- _enumdeclarations = { ! 'SvAs' : _Enum_SvAs, ! 'UIAc' : _Enum_UIAc, ! 'rcpT' : _Enum_rcpT, } Index: Utility_Events.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Demo/applescript/Disk_Copy/Utility_Events.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Utility_Events.py 20 Aug 2000 21:57:30 -0000 1.1 --- Utility_Events.py 18 Jul 2004 05:58:04 -0000 1.2 *************** *** 13,197 **** class Utility_Events_Events: ! _argmap_select_disk_image = { ! 'with_prompt' : 'SELp', ! } ! def select_disk_image(self, _no_object=None, _attributes={}, **_arguments): ! """select disk image: Prompt the user to select a disk image ! Keyword argument with_prompt: the prompt string to be displayed ! Keyword argument _attributes: AppleEvent attribute dictionary ! Returns: a reference to a disk image ! """ ! _code = 'UTIL' ! _subcode = 'SEL1' ! aetools.keysubst(_arguments, self._argmap_select_disk_image) ! if _no_object != None: raise TypeError, 'No direct arg expected' ! aetools.enumsubst(_arguments, 'SELp', _Enum_TEXT) ! _reply, _arguments, _attributes = self.send(_code, _subcode, ! _arguments, _attributes) ! if _arguments.has_key('errn'): ! raise aetools.Error, aetools.decodeerror(_arguments) ! # XXXX Optionally decode result ! if _arguments.has_key('----'): ! return _arguments['----'] ! _argmap_select_DiskScript = { ! 'with_prompt' : 'SELp', ! } ! def select_DiskScript(self, _no_object=None, _attributes={}, **_arguments): ! """select DiskScript: Prompt the user to select a DiskScript ! Keyword argument with_prompt: the prompt string to be displayed ! Keyword argument _attributes: AppleEvent attribute dictionary ! Returns: a reference to a DiskScript ! """ ! _code = 'UTIL' ! _subcode = 'SEL2' ! aetools.keysubst(_arguments, self._argmap_select_DiskScript) ! if _no_object != None: raise TypeError, 'No direct arg expected' ! aetools.enumsubst(_arguments, 'SELp', _Enum_TEXT) ! _reply, _arguments, _attributes = self.send(_code, _subcode, ! _arguments, _attributes) ! if _arguments.has_key('errn'): ! raise aetools.Error, aetools.decodeerror(_arguments) ! # XXXX Optionally decode result ! if _arguments.has_key('----'): ! return _arguments['----'] ! _argmap_select_disk_image_or_DiskScript = { ! 'with_prompt' : 'SELp', ! } ! def select_disk_image_or_DiskScript(self, _no_object=None, _attributes={}, **_arguments): ! """select disk image or DiskScript: Prompt the user to select a disk image or DiskScript ! Keyword argument with_prompt: the prompt string to be displayed ! Keyword argument _attributes: AppleEvent attribute dictionary ! Returns: a reference to disk image or a DiskScript ! """ ! _code = 'UTIL' ! _subcode = 'SEL3' ! aetools.keysubst(_arguments, self._argmap_select_disk_image_or_DiskScript) ! if _no_object != None: raise TypeError, 'No direct arg expected' ! aetools.enumsubst(_arguments, 'SELp', _Enum_TEXT) ! _reply, _arguments, _attributes = self.send(_code, _subcode, ! _arguments, _attributes) ! if _arguments.has_key('errn'): ! raise aetools.Error, aetools.decodeerror(_arguments) ! # XXXX Optionally decode result ! if _arguments.has_key('----'): ! return _arguments['----'] ! _argmap_select_floppy_disk_image = { ! 'with_prompt' : 'SELp', ! } ! def select_floppy_disk_image(self, _no_object=None, _attributes={}, **_arguments): ! """select floppy disk image: Prompt the user to select a floppy disk image ! Keyword argument with_prompt: the prompt string to be displayed ! Keyword argument _attributes: AppleEvent attribute dictionary ! Returns: a reference to a floppy disk image ! """ ! _code = 'UTIL' ! _subcode = 'SEL4' ! aetools.keysubst(_arguments, self._argmap_select_floppy_disk_image) ! if _no_object != None: raise TypeError, 'No direct arg expected' ! aetools.enumsubst(_arguments, 'SELp', _Enum_TEXT) ! _reply, _arguments, _attributes = self.send(_code, _subcode, ! _arguments, _attributes) ! if _arguments.has_key('errn'): ! raise aetools.Error, aetools.decodeerror(_arguments) ! # XXXX Optionally decode result ! if _arguments.has_key('----'): ! return _arguments['----'] ! _argmap_select_disk = { ! 'with_prompt' : 'SELp', ! } ! def select_disk(self, _no_object=None, _attributes={}, **_arguments): ! """select disk: Prompt the user to select a disk volume ! Keyword argument with_prompt: the prompt string to be displayed ! Keyword argument _attributes: AppleEvent attribute dictionary ! Returns: a reference to the disk ! """ ! _code = 'UTIL' ! _subcode = 'SEL5' ! aetools.keysubst(_arguments, self._argmap_select_disk) ! if _no_object != None: raise TypeError, 'No direct arg expected' ! aetools.enumsubst(_arguments, 'SELp', _Enum_TEXT) ! _reply, _arguments, _attributes = self.send(_code, _subcode, ! _arguments, _attributes) ! if _arguments.has_key('errn'): ! raise aetools.Error, aetools.decodeerror(_arguments) ! # XXXX Optionally decode result ! if _arguments.has_key('----'): ! return _arguments['----'] ! _argmap_select_folder = { ! 'with_prompt' : 'SELp', ! } ! def select_folder(self, _no_object=None, _attributes={}, **_arguments): ! """select folder: Prompt the user to select a folder ! Keyword argument with_prompt: the prompt string to be displayed ! Keyword argument _attributes: AppleEvent attribute dictionary ! Returns: a reference to the folder ! """ ! _code = 'UTIL' ! _subcode = 'SEL6' ! aetools.keysubst(_arguments, self._argmap_select_folder) ! if _no_object != None: raise TypeError, 'No direct arg expected' ! aetools.enumsubst(_arguments, 'SELp', _Enum_TEXT) ! _reply, _arguments, _attributes = self.send(_code, _subcode, ! _arguments, _attributes) ! if _arguments.has_key('errn'): ! raise aetools.Error, aetools.decodeerror(_arguments) ! # XXXX Optionally decode result ! if _arguments.has_key('----'): ! return _arguments['----'] ! _argmap_log = { ! 'time_stamp' : 'TSMP', ! } ! def log(self, _object, _attributes={}, **_arguments): ! """log: Add a string to the log window ! Required argument: the string to add to the log window ! Keyword argument time_stamp: Should the log entry be time-stamped? (false if not supplied) ! Keyword argument _attributes: AppleEvent attribute dictionary ! """ ! _code = 'UTIL' ! _subcode = 'LOG ' ! aetools.keysubst(_arguments, self._argmap_log) ! _arguments['----'] = _object ! aetools.enumsubst(_arguments, 'TSMP', _Enum_bool) ! _reply, _arguments, _attributes = self.send(_code, _subcode, ! _arguments, _attributes) ! if _arguments.has_key('errn'): ! raise aetools.Error, aetools.decodeerror(_arguments) ! # XXXX Optionally decode result ! if _arguments.has_key('----'): ! return _arguments['----'] _Enum_TEXT = None # XXXX enum TEXT not found!! --- 13,197 ---- class Utility_Events_Events: ! _argmap_select_disk_image = { ! 'with_prompt' : 'SELp', ! } ! def select_disk_image(self, _no_object=None, _attributes={}, **_arguments): ! """select disk image: Prompt the user to select a disk image ! Keyword argument with_prompt: the prompt string to be displayed ! Keyword argument _attributes: AppleEvent attribute dictionary ! Returns: a reference to a disk image ! """ ! _code = 'UTIL' ! _subcode = 'SEL1' ! aetools.keysubst(_arguments, self._argmap_select_disk_image) ! if _no_object != None: raise TypeError, 'No direct arg expected' ! aetools.enumsubst(_arguments, 'SELp', _Enum_TEXT) ! _reply, _arguments, _attributes = self.send(_code, _subcode, ! _arguments, _attributes) ! if _arguments.has_key('errn'): ! raise aetools.Error, aetools.decodeerror(_arguments) ! # XXXX Optionally decode result ! if _arguments.has_key('----'): ! return _arguments['----'] ! _argmap_select_DiskScript = { ! 'with_prompt' : 'SELp', ! } ! def select_DiskScript(self, _no_object=None, _attributes={}, **_arguments): ! """select DiskScript: Prompt the user to select a DiskScript ! Keyword argument with_prompt: the prompt string to be displayed ! Keyword argument _attributes: AppleEvent attribute dictionary ! Returns: a reference to a DiskScript ! """ ! _code = 'UTIL' ! _subcode = 'SEL2' ! aetools.keysubst(_arguments, self._argmap_select_DiskScript) ! if _no_object != None: raise TypeError, 'No direct arg expected' ! aetools.enumsubst(_arguments, 'SELp', _Enum_TEXT) ! _reply, _arguments, _attributes = self.send(_code, _subcode, ! _arguments, _attributes) ! if _arguments.has_key('errn'): ! raise aetools.Error, aetools.decodeerror(_arguments) ! # XXXX Optionally decode result ! if _arguments.has_key('----'): ! return _arguments['----'] ! _argmap_select_disk_image_or_DiskScript = { ! 'with_prompt' : 'SELp', ! } ! def select_disk_image_or_DiskScript(self, _no_object=None, _attributes={}, **_arguments): ! """select disk image or DiskScript: Prompt the user to select a disk image or DiskScript ! Keyword argument with_prompt: the prompt string to be displayed ! Keyword argument _attributes: AppleEvent attribute dictionary ! Returns: a reference to disk image or a DiskScript ! """ ! _code = 'UTIL' ! _subcode = 'SEL3' ! aetools.keysubst(_arguments, self._argmap_select_disk_image_or_DiskScript) ! if _no_object != None: raise TypeError, 'No direct arg expected' ! aetools.enumsubst(_arguments, 'SELp', _Enum_TEXT) ! _reply, _arguments, _attributes = self.send(_code, _subcode, ! _arguments, _attributes) ! if _arguments.has_key('errn'): ! raise aetools.Error, aetools.decodeerror(_arguments) ! # XXXX Optionally decode result ! if _arguments.has_key('----'): ! return _arguments['----'] ! _argmap_select_floppy_disk_image = { ! 'with_prompt' : 'SELp', ! } ! def select_floppy_disk_image(self, _no_object=None, _attributes={}, **_arguments): ! """select floppy disk image: Prompt the user to select a floppy disk image ! Keyword argument with_prompt: the prompt string to be displayed ! Keyword argument _attributes: AppleEvent attribute dictionary ! Returns: a reference to a floppy disk image ! """ ! _code = 'UTIL' ! _subcode = 'SEL4' ! aetools.keysubst(_arguments, self._argmap_select_floppy_disk_image) ! if _no_object != None: raise TypeError, 'No direct arg expected' ! aetools.enumsubst(_arguments, 'SELp', _Enum_TEXT) ! _reply, _arguments, _attributes = self.send(_code, _subcode, ! _arguments, _attributes) ! if _arguments.has_key('errn'): ! raise aetools.Error, aetools.decodeerror(_arguments) ! # XXXX Optionally decode result ! if _arguments.has_key('----'): ! return _arguments['----'] ! _argmap_select_disk = { ! 'with_prompt' : 'SELp', ! } ! def select_disk(self, _no_object=None, _attributes={}, **_arguments): ! """select disk: Prompt the user to select a disk volume ! Keyword argument with_prompt: the prompt string to be displayed ! Keyword argument _attributes: AppleEvent attribute dictionary ! Returns: a reference to the disk ! """ ! _code = 'UTIL' ! _subcode = 'SEL5' ! aetools.keysubst(_arguments, self._argmap_select_disk) ! if _no_object != None: raise TypeError, 'No direct arg expected' ! aetools.enumsubst(_arguments, 'SELp', _Enum_TEXT) ! _reply, _arguments, _attributes = self.send(_code, _subcode, ! _arguments, _attributes) ! if _arguments.has_key('errn'): ! raise aetools.Error, aetools.decodeerror(_arguments) ! # XXXX Optionally decode result ! if _arguments.has_key('----'): ! return _arguments['----'] ! _argmap_select_folder = { ! 'with_prompt' : 'SELp', ! } ! def select_folder(self, _no_object=None, _attributes={}, **_arguments): ! """select folder: Prompt the user to select a folder ! Keyword argument with_prompt: the prompt string to be displayed ! Keyword argument _attributes: AppleEvent attribute dictionary ! Returns: a reference to the folder ! """ ! _code = 'UTIL' ! _subcode = 'SEL6' ! aetools.keysubst(_arguments, self._argmap_select_folder) ! if _no_object != None: raise TypeError, 'No direct arg expected' ! aetools.enumsubst(_arguments, 'SELp', _Enum_TEXT) ! _reply, _arguments, _attributes = self.send(_code, _subcode, ! _arguments, _attributes) ! if _arguments.has_key('errn'): ! raise aetools.Error, aetools.decodeerror(_arguments) ! # XXXX Optionally decode result ! if _arguments.has_key('----'): ! return _arguments['----'] ! _argmap_log = { ! 'time_stamp' : 'TSMP', ! } ! def log(self, _object, _attributes={}, **_arguments): ! """log: Add a string to the log window ! Required argument: the string to add to the log window ! Keyword argument time_stamp: Should the log entry be time-stamped? (false if not supplied) ! Keyword argument _attributes: AppleEvent attribute dictionary ! """ ! _code = 'UTIL' ! _subcode = 'LOG ' ! aetools.keysubst(_arguments, self._argmap_log) ! _arguments['----'] = _object ! aetools.enumsubst(_arguments, 'TSMP', _Enum_bool) ! _reply, _arguments, _attributes = self.send(_code, _subcode, ! _arguments, _attributes) ! if _arguments.has_key('errn'): ! raise aetools.Error, aetools.decodeerror(_arguments) ! # XXXX Optionally decode result ! if _arguments.has_key('----'): ! return _arguments['----'] _Enum_TEXT = None # XXXX enum TEXT not found!! Index: __init__.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Demo/applescript/Disk_Copy/__init__.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** __init__.py 20 Aug 2000 21:57:30 -0000 1.1 --- __init__.py 18 Jul 2004 05:58:04 -0000 1.2 *************** *** 1,5 **** """ Package generated from Macintosh HD:Hulpprogramma's:Disk Copy ! Resource aete resid 0 """ import aetools --- 1,5 ---- """ Package generated from Macintosh HD:Hulpprogramma's:Disk Copy ! Resource aete resid 0 """ import aetools *************** *** 11,17 **** _code_to_module = { ! 'Core' : Standard_Suite, ! 'ddsk' : Special_Events, ! 'ddsk' : Utility_Events, } --- 11,17 ---- _code_to_module = { ! 'Core' : Standard_Suite, ! 'ddsk' : Special_Events, ! 'ddsk' : Utility_Events, } *************** *** 19,25 **** _code_to_fullname = { ! 'Core' : ('Disk_Copy.Standard_Suite', 'Standard_Suite'), ! 'ddsk' : ('Disk_Copy.Special_Events', 'Special_Events'), ! 'ddsk' : ('Disk_Copy.Utility_Events', 'Utility_Events'), } --- 19,25 ---- _code_to_fullname = { ! 'Core' : ('Disk_Copy.Standard_Suite', 'Standard_Suite'), ! 'ddsk' : ('Disk_Copy.Special_Events', 'Special_Events'), ! 'ddsk' : ('Disk_Copy.Utility_Events', 'Utility_Events'), } *************** *** 30,36 **** class Disk_Copy(Standard_Suite_Events, ! Special_Events_Events, ! Utility_Events_Events, ! aetools.TalkTo): ! _signature = 'ddsk' ! --- 30,35 ---- class Disk_Copy(Standard_Suite_Events, ! Special_Events_Events, ! Utility_Events_Events, ! aetools.TalkTo): ! _signature = 'ddsk' From tim_one at users.sourceforge.net Sun Jul 18 07:58:39 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 07:58:57 2004 Subject: [Python-checkins] python/dist/src/Mac/Demo/sound morse.py, 1.1, 1.2 morselib.py, 1.1, 1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Demo/sound In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29056/Demo/sound Modified Files: morse.py morselib.py Log Message: Whitespace normalization, via reindent.py. Index: morse.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Demo/sound/morse.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** morse.py 30 Jan 1995 11:52:48 -0000 1.1 --- morse.py 18 Jul 2004 05:58:06 -0000 1.2 *************** *** 3,7 **** DOT = 30 DAH = 80 ! OCTAVE = 2 # 1 == 441 Hz, 2 == 882 Hz, ... SAMPWIDTH = 2 FRAMERATE = 44100 --- 3,7 ---- DOT = 30 DAH = 80 ! OCTAVE = 2 # 1 == 441 Hz, 2 == 882 Hz, ... SAMPWIDTH = 2 FRAMERATE = 44100 *************** *** 10,61 **** morsetab = { ! 'A': '.-', 'a': '.-', ! 'B': '-...', 'b': '-...', ! 'C': '-.-.', 'c': '-.-.', ! 'D': '-..', 'd': '-..', ! 'E': '.', 'e': '.', ! 'F': '..-.', 'f': '..-.', ! 'G': '--.', 'g': '--.', ! 'H': '....', 'h': '....', ! 'I': '..', 'i': '..', ! 'J': '.---', 'j': '.---', ! 'K': '-.-', 'k': '-.-', ! 'L': '.-..', 'l': '.-..', ! 'M': '--', 'm': '--', ! 'N': '-.', 'n': '-.', ! 'O': '---', 'o': '---', ! 'P': '.--.', 'p': '.--.', ! 'Q': '--.-', 'q': '--.-', ! 'R': '.-.', 'r': '.-.', ! 'S': '...', 's': '...', ! 'T': '-', 't': '-', ! 'U': '..-', 'u': '..-', ! 'V': '...-', 'v': '...-', ! 'W': '.--', 'w': '.--', ! 'X': '-..-', 'x': '-..-', ! 'Y': '-.--', 'y': '-.--', ! 'Z': '--..', 'z': '--..', ! '0': '-----', ! '1': '.----', ! '2': '..---', ! '3': '...--', ! '4': '....-', ! '5': '.....', ! '6': '-....', ! '7': '--...', ! '8': '---..', ! '9': '----.', ! ',': '--..--', ! '.': '.-.-.-', ! '?': '..--..', ! ';': '-.-.-.', ! ':': '---...', ! "'": '.----.', ! '-': '-....-', ! '/': '-..-.', ! '(': '-.--.-', ! ')': '-.--.-', ! '_': '..--.-', ! ' ': ' ' } --- 10,61 ---- morsetab = { ! 'A': '.-', 'a': '.-', ! 'B': '-...', 'b': '-...', ! 'C': '-.-.', 'c': '-.-.', ! 'D': '-..', 'd': '-..', ! 'E': '.', 'e': '.', ! 'F': '..-.', 'f': '..-.', ! 'G': '--.', 'g': '--.', ! 'H': '....', 'h': '....', ! 'I': '..', 'i': '..', ! 'J': '.---', 'j': '.---', ! 'K': '-.-', 'k': '-.-', ! 'L': '.-..', 'l': '.-..', ! 'M': '--', 'm': '--', ! 'N': '-.', 'n': '-.', ! 'O': '---', 'o': '---', ! 'P': '.--.', 'p': '.--.', ! 'Q': '--.-', 'q': '--.-', ! 'R': '.-.', 'r': '.-.', ! 'S': '...', 's': '...', ! 'T': '-', 't': '-', ! 'U': '..-', 'u': '..-', ! 'V': '...-', 'v': '...-', ! 'W': '.--', 'w': '.--', ! 'X': '-..-', 'x': '-..-', ! 'Y': '-.--', 'y': '-.--', ! 'Z': '--..', 'z': '--..', ! '0': '-----', ! '1': '.----', ! '2': '..---', ! '3': '...--', ! '4': '....-', ! '5': '.....', ! '6': '-....', ! '7': '--...', ! '8': '---..', ! '9': '----.', ! ',': '--..--', ! '.': '.-.-.-', ! '?': '..--..', ! ';': '-.-.-.', ! ':': '---...', ! "'": '.----.', ! '-': '-....-', ! '/': '-..-.', ! '(': '-.--.-', ! ')': '-.--.-', ! '_': '..--.-', ! ' ': ' ' } *************** *** 65,180 **** # appears to be a nice one for playing morse code. def mkwave(octave): ! global sinewave, nowave ! sinewave = '' ! n = int(FRAMERATE / BASEFREQ) ! for i in range(n): ! val = int(math.sin(2 * math.pi * i * octave / n) * 0x7fff) ! sample = chr((val >> 8) & 255) + chr(val & 255) ! sinewave = sinewave + sample[:SAMPWIDTH] ! nowave = '\0' * (n*SAMPWIDTH) mkwave(OCTAVE) class BufferedAudioDev: ! def __init__(self, *args): ! import audiodev ! self._base = apply(audiodev.AudioDev, args) ! self._buffer = [] ! self._filled = 0 ! self._addmethods(self._base, self._base.__class__) ! def _addmethods(self, inst, cls): ! for name in cls.__dict__.keys(): ! if not hasattr(self, name): ! try: ! setattr(self, name, getattr(inst, name)) ! except: ! pass ! for basecls in cls.__bases__: ! self._addmethods(self, inst, basecls) ! def writeframesraw(self, frames): ! self._buffer.append(frames) ! self._filled = self._filled + len(frames) ! if self._filled >= QSIZE: ! self.flush() ! def wait(self): ! self.flush() ! self._base.wait() ! def flush(self): ! print 'flush: %d blocks, %d bytes' % (len(self._buffer), self._filled) ! if self._buffer: ! import string ! self._base.writeframes(string.joinfields(self._buffer, '')) ! self._buffer = [] ! self._filled = 0 def main(args = sys.argv[1:]): ! import getopt, string ! try: ! opts, args = getopt.getopt(args, 'o:p:') ! except getopt.error: ! sys.stderr.write('Usage ' + sys.argv[0] + ! ' [ -o outfile ] [ args ] ...\n') ! sys.exit(1) ! dev = None ! for o, a in opts: ! if o == '-o': ! import aifc ! dev = aifc.open(a, 'w') ! dev.setframerate(FRAMERATE) ! dev.setsampwidth(SAMPWIDTH) ! dev.setnchannels(1) ! if o == '-p': ! mkwave(string.atoi(a)) ! if not dev: ! dev = BufferedAudioDev() ! dev.setoutrate(FRAMERATE) ! dev.setsampwidth(SAMPWIDTH) ! dev.setnchannels(1) ! dev.close = dev.stop ! if args: ! line = string.join(args) ! else: ! line = sys.stdin.readline() ! while line: ! print line ! mline = morse(line) ! print mline ! play(mline, dev) ! if hasattr(dev, 'wait'): ! dev.wait() ! if not args: ! line = sys.stdin.readline() ! else: ! line = '' ! dev.close() # Convert a string to morse code with \001 between the characters in # the string. def morse(line): ! res = '' ! for c in line: ! try: ! res = res + morsetab[c] + '\001' ! except KeyError: ! pass ! return res # Play a line of morse code. def play(line, dev): ! for c in line: ! if c == '.': ! sine(dev, DOT) ! elif c == '-': ! sine(dev, DAH) ! else: ! pause(dev, DAH) ! pause(dev, DOT) def sine(dev, length): ! dev.writeframesraw(sinewave*length) def pause(dev, length): ! dev.writeframesraw(nowave*length) if __name__ == '__main__' or sys.argv[0] == __name__: ! main() --- 65,180 ---- # appears to be a nice one for playing morse code. def mkwave(octave): ! global sinewave, nowave ! sinewave = '' ! n = int(FRAMERATE / BASEFREQ) ! for i in range(n): ! val = int(math.sin(2 * math.pi * i * octave / n) * 0x7fff) ! sample = chr((val >> 8) & 255) + chr(val & 255) ! sinewave = sinewave + sample[:SAMPWIDTH] ! nowave = '\0' * (n*SAMPWIDTH) mkwave(OCTAVE) class BufferedAudioDev: ! def __init__(self, *args): ! import audiodev ! self._base = apply(audiodev.AudioDev, args) ! self._buffer = [] ! self._filled = 0 ! self._addmethods(self._base, self._base.__class__) ! def _addmethods(self, inst, cls): ! for name in cls.__dict__.keys(): ! if not hasattr(self, name): ! try: ! setattr(self, name, getattr(inst, name)) ! except: ! pass ! for basecls in cls.__bases__: ! self._addmethods(self, inst, basecls) ! def writeframesraw(self, frames): ! self._buffer.append(frames) ! self._filled = self._filled + len(frames) ! if self._filled >= QSIZE: ! self.flush() ! def wait(self): ! self.flush() ! self._base.wait() ! def flush(self): ! print 'flush: %d blocks, %d bytes' % (len(self._buffer), self._filled) ! if self._buffer: ! import string ! self._base.writeframes(string.joinfields(self._buffer, '')) ! self._buffer = [] ! self._filled = 0 def main(args = sys.argv[1:]): ! import getopt, string ! try: ! opts, args = getopt.getopt(args, 'o:p:') ! except getopt.error: ! sys.stderr.write('Usage ' + sys.argv[0] + ! ' [ -o outfile ] [ args ] ...\n') ! sys.exit(1) ! dev = None ! for o, a in opts: ! if o == '-o': ! import aifc ! dev = aifc.open(a, 'w') ! dev.setframerate(FRAMERATE) ! dev.setsampwidth(SAMPWIDTH) ! dev.setnchannels(1) ! if o == '-p': ! mkwave(string.atoi(a)) ! if not dev: ! dev = BufferedAudioDev() ! dev.setoutrate(FRAMERATE) ! dev.setsampwidth(SAMPWIDTH) ! dev.setnchannels(1) ! dev.close = dev.stop ! if args: ! line = string.join(args) ! else: ! line = sys.stdin.readline() ! while line: ! print line ! mline = morse(line) ! print mline ! play(mline, dev) ! if hasattr(dev, 'wait'): ! dev.wait() ! if not args: ! line = sys.stdin.readline() ! else: ! line = '' ! dev.close() # Convert a string to morse code with \001 between the characters in # the string. def morse(line): ! res = '' ! for c in line: ! try: ! res = res + morsetab[c] + '\001' ! except KeyError: ! pass ! return res # Play a line of morse code. def play(line, dev): ! for c in line: ! if c == '.': ! sine(dev, DOT) ! elif c == '-': ! sine(dev, DAH) ! else: ! pause(dev, DAH) ! pause(dev, DOT) def sine(dev, length): ! dev.writeframesraw(sinewave*length) def pause(dev, length): ! dev.writeframesraw(nowave*length) if __name__ == '__main__' or sys.argv[0] == __name__: ! main() Index: morselib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Demo/sound/morselib.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** morselib.py 10 Mar 1995 14:47:05 -0000 1.1 --- morselib.py 18 Jul 2004 05:58:06 -0000 1.2 *************** *** 11,188 **** morsetab = { ! 'a': '.-', ! 'b': '-...', ! 'c': '-.-.', ! 'd': '-..', ! 'e': '.', ! 'f': '..-.', ! 'g': '--.', ! 'h': '....', ! 'i': '..', ! 'j': '.---', ! 'k': '-.-', ! 'l': '.-..', ! 'm': '--', ! 'n': '-.', ! 'o': '---', ! 'p': '.--.', ! 'q': '--.-', ! 'r': '.-.', ! 's': '...', ! 't': '-', ! 'u': '..-', ! 'v': '...-', ! 'w': '.--', ! 'x': '-..-', ! 'y': '-.--', ! 'z': '--..', ! '0': '-----', ! '1': '.----', ! '2': '..---', ! '3': '...--', ! '4': '....-', ! '5': '.....', ! '6': '-....', ! '7': '--...', ! '8': '---..', ! '9': '----.', ! ',': '--..--', ! '.': '.-.-.-', ! '?': '..--..', ! ';': '-.-.-.', ! ':': '---...', ! "'": '.----.', ! '-': '-....-', ! '/': '-..-.', ! '(': '-.--.-', ! ')': '-.--.-', # XXX same as code for '(' ??? ! '_': '..--.-', ! ' ': ' ' } def morsecode(s): ! from string import lower ! m = '' ! for c in s: ! c = lower(c) ! if morsetab.has_key(c): ! c = morsetab[c] + ' ' ! else: ! c = '? ' ! m = m + c ! return m class BaseMorse: ! "base class for morse transmissions" ! ! def __init__(self): ! "constructor" ! self.dots = DOT ! self.dahs = DAH ! ! def noise(self, duration): ! "beep for given duration" ! pass ! ! def pause(self, duration): ! "pause for given duration" ! pass ! ! def dot(self): ! "short beep" ! self.noise(self.dots) ! ! def dah(self): ! "long beep" ! self.noise(self.dahs) ! ! def pdot(self): ! "pause as long as a dot" ! self.pause(self.dots) ! ! def pdah(self): ! "pause as long as a dah" ! self.pause(self.dahs) ! ! def sendmorse(self, s): ! for c in s: ! if c == '.': self.dot() ! elif c == '-': self.dah() ! else: self.pdah() ! self.pdot() ! ! def sendascii(self, s): ! self.sendmorse(morsecode(s)) ! ! def send(self, s): ! self.sendascii(s) import Audio_mac class MyAudio(Audio_mac.Play_Audio_mac): ! def _callback(self, *args): ! if hasattr(self, 'usercallback'): self.usercallback() ! apply(Audio_mac.Play_Audio_mac._callback, (self,) + args) class MacMorse(BaseMorse): ! "Mac specific class to play Morse code" ! ! def __init__(self): ! BaseMorse.__init__(self) ! self.dev = MyAudio() ! self.dev.setoutrate(FRAMERATE) ! self.dev.setsampwidth(SAMPWIDTH) ! self.dev.setnchannels(1) ! self.dev.usercallback = self.usercallback ! sinewave = '' ! n = int(FRAMERATE / BASEFREQ) ! octave = OCTAVE ! from math import sin, pi ! for i in range(n): ! val = int(sin(2 * pi * i * octave / n) * 0x7fff) ! sample = chr((val >> 8) & 255) + chr(val & 255) ! sinewave = sinewave + sample[:SAMPWIDTH] ! self.sinewave = sinewave ! self.silence = '\0' * (n*SAMPWIDTH) ! self.morsequeue = '' ! ! def __del__(self): ! self.close() ! ! def close(self): ! self.dev = None ! ! def pause(self, duration): ! self.dev.writeframes(self.silence * duration) ! ! def noise(self, duration): ! self.dev.writeframes(self.sinewave * duration) ! ! def sendmorse(self, s): ! self.morsequeue = self.morsequeue + s ! self.dev.usercallback() ! self.dev.usercallback() ! self.dev.usercallback() ! ! def usercallback(self): ! if self.morsequeue: ! c, self.morsequeue = self.morsequeue[0], self.morsequeue[1:] ! if c == '.': self.dot() ! elif c == '-': self.dah() ! else: self.pdah() ! self.pdot() def test(): ! m = MacMorse() ! while 1: ! try: ! line = raw_input('Morse line: ') ! except (EOFError, KeyboardInterrupt): ! break ! m.send(line) ! while m.morsequeue: pass test() --- 11,188 ---- morsetab = { ! 'a': '.-', ! 'b': '-...', ! 'c': '-.-.', ! 'd': '-..', ! 'e': '.', ! 'f': '..-.', ! 'g': '--.', ! 'h': '....', ! 'i': '..', ! 'j': '.---', ! 'k': '-.-', ! 'l': '.-..', ! 'm': '--', ! 'n': '-.', ! 'o': '---', ! 'p': '.--.', ! 'q': '--.-', ! 'r': '.-.', ! 's': '...', ! 't': '-', ! 'u': '..-', ! 'v': '...-', ! 'w': '.--', ! 'x': '-..-', ! 'y': '-.--', ! 'z': '--..', ! '0': '-----', ! '1': '.----', ! '2': '..---', ! '3': '...--', ! '4': '....-', ! '5': '.....', ! '6': '-....', ! '7': '--...', ! '8': '---..', ! '9': '----.', ! ',': '--..--', ! '.': '.-.-.-', ! '?': '..--..', ! ';': '-.-.-.', ! ':': '---...', ! "'": '.----.', ! '-': '-....-', ! '/': '-..-.', ! '(': '-.--.-', ! ')': '-.--.-', # XXX same as code for '(' ??? ! '_': '..--.-', ! ' ': ' ' } def morsecode(s): ! from string import lower ! m = '' ! for c in s: ! c = lower(c) ! if morsetab.has_key(c): ! c = morsetab[c] + ' ' ! else: ! c = '? ' ! m = m + c ! return m class BaseMorse: ! "base class for morse transmissions" ! ! def __init__(self): ! "constructor" ! self.dots = DOT ! self.dahs = DAH ! ! def noise(self, duration): ! "beep for given duration" ! pass ! ! def pause(self, duration): ! "pause for given duration" ! pass ! ! def dot(self): ! "short beep" ! self.noise(self.dots) ! ! def dah(self): ! "long beep" ! self.noise(self.dahs) ! ! def pdot(self): ! "pause as long as a dot" ! self.pause(self.dots) ! ! def pdah(self): ! "pause as long as a dah" ! self.pause(self.dahs) ! ! def sendmorse(self, s): ! for c in s: ! if c == '.': self.dot() ! elif c == '-': self.dah() ! else: self.pdah() ! self.pdot() ! ! def sendascii(self, s): ! self.sendmorse(morsecode(s)) ! ! def send(self, s): ! self.sendascii(s) import Audio_mac class MyAudio(Audio_mac.Play_Audio_mac): ! def _callback(self, *args): ! if hasattr(self, 'usercallback'): self.usercallback() ! apply(Audio_mac.Play_Audio_mac._callback, (self,) + args) class MacMorse(BaseMorse): ! "Mac specific class to play Morse code" ! ! def __init__(self): ! BaseMorse.__init__(self) ! self.dev = MyAudio() ! self.dev.setoutrate(FRAMERATE) ! self.dev.setsampwidth(SAMPWIDTH) ! self.dev.setnchannels(1) ! self.dev.usercallback = self.usercallback ! sinewave = '' ! n = int(FRAMERATE / BASEFREQ) ! octave = OCTAVE ! from math import sin, pi ! for i in range(n): ! val = int(sin(2 * pi * i * octave / n) * 0x7fff) ! sample = chr((val >> 8) & 255) + chr(val & 255) ! sinewave = sinewave + sample[:SAMPWIDTH] ! self.sinewave = sinewave ! self.silence = '\0' * (n*SAMPWIDTH) ! self.morsequeue = '' ! ! def __del__(self): ! self.close() ! ! def close(self): ! self.dev = None ! ! def pause(self, duration): ! self.dev.writeframes(self.silence * duration) ! ! def noise(self, duration): ! self.dev.writeframes(self.sinewave * duration) ! ! def sendmorse(self, s): ! self.morsequeue = self.morsequeue + s ! self.dev.usercallback() ! self.dev.usercallback() ! self.dev.usercallback() ! ! def usercallback(self): ! if self.morsequeue: ! c, self.morsequeue = self.morsequeue[0], self.morsequeue[1:] ! if c == '.': self.dot() ! elif c == '-': self.dah() ! else: self.pdah() ! self.pdot() def test(): ! m = MacMorse() ! while 1: ! try: ! line = raw_input('Morse line: ') ! except (EOFError, KeyboardInterrupt): ! break ! m.send(line) ! while m.morsequeue: pass test() From tim_one at users.sourceforge.net Sun Jul 18 07:58:39 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 07:58:59 2004 Subject: [Python-checkins] python/dist/src/Mac/Demo/textedit ped.py, 1.12, 1.13 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Demo/textedit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29056/Demo/textedit Modified Files: ped.py Log Message: Whitespace normalization, via reindent.py. Index: ped.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Demo/textedit/ped.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** ped.py 12 Feb 2004 17:35:13 -0000 1.12 --- ped.py 18 Jul 2004 05:58:06 -0000 1.13 *************** *** 16,360 **** class TEWindow(ScrolledWindow): ! def open(self, path, name, data): ! self.path = path ! self.name = name ! r = windowbounds(400, 400) ! w = Win.NewWindow(r, name, 1, 0, -1, 1, 0) ! self.wid = w ! x0, y0, x1, y1 = self.wid.GetWindowPort().GetPortBounds() ! x0 = x0 + 4 ! y0 = y0 + 4 ! x1 = x1 - 20 ! y1 = y1 - 20 ! vr = dr = x0, y0, x1, y1 ! ##vr = 4, 0, r[2]-r[0]-15, r[3]-r[1]-15 ! ##dr = (0, 0, vr[2], 0) ! Qd.SetPort(w) ! Qd.TextFont(4) ! Qd.TextSize(9) ! self.ted = TE.TENew(dr, vr) ! self.ted.TEAutoView(1) ! self.ted.TESetText(data) ! w.DrawGrowIcon() ! self.scrollbars() ! self.changed = 0 ! self.do_postopen() ! self.do_activate(1, None) ! ! def do_idle(self): ! self.ted.TEIdle() ! ! def getscrollbarvalues(self): ! dr = self.ted.destRect ! vr = self.ted.viewRect ! height = self.ted.nLines * self.ted.lineHeight ! vx = self.scalebarvalue(dr[0], dr[2]-dr[0], vr[0], vr[2]) ! vy = self.scalebarvalue(dr[1], dr[1]+height, vr[1], vr[3]) ! print dr, vr, height, vx, vy ! return None, vy ! ! def scrollbar_callback(self, which, what, value): ! if which == 'y': ! if what == 'set': ! height = self.ted.nLines * self.ted.lineHeight ! cur = self.getscrollbarvalues()[1] ! delta = (cur-value)*height/32767 ! if what == '-': ! delta = self.ted.lineHeight ! elif what == '--': ! delta = (self.ted.viewRect[3]-self.ted.lineHeight) ! if delta <= 0: ! delta = self.ted.lineHeight ! elif what == '+': ! delta = -self.ted.lineHeight ! elif what == '++': ! delta = -(self.ted.viewRect[3]-self.ted.lineHeight) ! if delta >= 0: ! delta = -self.ted.lineHeight ! self.ted.TEPinScroll(0, delta) ! print 'SCROLL Y', delta ! else: ! pass # No horizontal scrolling ! ! def do_activate(self, onoff, evt): ! print "ACTIVATE", onoff ! ScrolledWindow.do_activate(self, onoff, evt) ! if onoff: ! self.ted.TEActivate() ! self.parent.active = self ! self.parent.updatemenubar() ! else: ! self.ted.TEDeactivate() ! def do_update(self, wid, event): ! Qd.EraseRect(wid.GetWindowPort().GetPortBounds()) ! self.ted.TEUpdate(wid.GetWindowPort().GetPortBounds()) ! self.updatescrollbars() ! ! def do_contentclick(self, local, modifiers, evt): ! shifted = (modifiers & 0x200) ! self.ted.TEClick(local, shifted) ! self.updatescrollbars() ! self.parent.updatemenubar() ! def do_char(self, ch, event): ! self.ted.TESelView() ! self.ted.TEKey(ord(ch)) ! self.changed = 1 ! self.updatescrollbars() ! self.parent.updatemenubar() ! ! def close(self): ! if self.changed: ! save = EasyDialogs.AskYesNoCancel('Save window "%s" before closing?'%self.name, 1) ! if save > 0: ! self.menu_save() ! elif save < 0: ! return ! if self.parent.active == self: ! self.parent.active = None ! self.parent.updatemenubar() ! del self.ted ! self.do_postclose() ! ! def menu_save(self): ! if not self.path: ! self.menu_save_as() ! return # Will call us recursively ! print 'Saving to ', self.path ! dhandle = self.ted.TEGetText() ! data = dhandle.data ! fp = open(self.path, 'wb') # NOTE: wb, because data has CR for end-of-line ! fp.write(data) ! if data[-1] <> '\r': fp.write('\r') ! fp.close() ! self.changed = 0 ! ! def menu_save_as(self): ! path = EasyDialogs.AskFileForSave(message='Save as:') ! if not path: return ! self.path = path ! self.name = os.path.split(self.path)[-1] ! self.wid.SetWTitle(self.name) ! self.menu_save() ! ! def menu_cut(self): ! self.ted.TESelView() ! self.ted.TECut() ! if hasattr(Scrap, 'ZeroScrap'): ! Scrap.ZeroScrap() ! else: ! Scrap.ClearCurrentScrap() ! TE.TEToScrap() ! self.updatescrollbars() ! self.parent.updatemenubar() ! self.changed = 1 ! ! def menu_copy(self): ! self.ted.TECopy() ! if hasattr(Scrap, 'ZeroScrap'): ! Scrap.ZeroScrap() ! else: ! Scrap.ClearCurrentScrap() ! TE.TEToScrap() ! self.updatescrollbars() ! self.parent.updatemenubar() ! ! def menu_paste(self): ! TE.TEFromScrap() ! self.ted.TESelView() ! self.ted.TEPaste() ! self.updatescrollbars() ! self.parent.updatemenubar() ! self.changed = 1 ! ! def menu_clear(self): ! self.ted.TESelView() ! self.ted.TEDelete() ! self.updatescrollbars() ! self.parent.updatemenubar() ! self.changed = 1 ! ! def have_selection(self): ! return (self.ted.selStart < self.ted.selEnd) class Ped(Application): ! def __init__(self): ! Application.__init__(self) ! self.num = 0 ! self.active = None ! self.updatemenubar() ! ! def makeusermenus(self): ! self.filemenu = m = Menu(self.menubar, "File") ! self.newitem = MenuItem(m, "New window", "N", self.open) ! self.openitem = MenuItem(m, "Open...", "O", self.openfile) ! self.closeitem = MenuItem(m, "Close", "W", self.closewin) ! m.addseparator() ! self.saveitem = MenuItem(m, "Save", "S", self.save) ! self.saveasitem = MenuItem(m, "Save as...", "", self.saveas) ! m.addseparator() ! self.quititem = MenuItem(m, "Quit", "Q", self.quit) ! ! self.editmenu = m = Menu(self.menubar, "Edit") ! self.undoitem = MenuItem(m, "Undo", "Z", self.undo) ! self.cutitem = MenuItem(m, "Cut", "X", self.cut) ! self.copyitem = MenuItem(m, "Copy", "C", self.copy) ! self.pasteitem = MenuItem(m, "Paste", "V", self.paste) ! self.clearitem = MenuItem(m, "Clear", "", self.clear) ! ! # Not yet implemented: ! self.undoitem.enable(0) ! ! # Groups of items enabled together: ! self.windowgroup = [self.closeitem, self.saveitem, self.saveasitem, self.editmenu] ! self.focusgroup = [self.cutitem, self.copyitem, self.clearitem] ! self.windowgroup_on = -1 ! self.focusgroup_on = -1 ! self.pastegroup_on = -1 ! ! def updatemenubar(self): ! changed = 0 ! on = (self.active <> None) ! if on <> self.windowgroup_on: ! for m in self.windowgroup: ! m.enable(on) ! self.windowgroup_on = on ! changed = 1 ! if on: ! # only if we have an edit menu ! on = self.active.have_selection() ! if on <> self.focusgroup_on: ! for m in self.focusgroup: ! m.enable(on) ! self.focusgroup_on = on ! changed = 1 ! if hasattr(Scrap, 'InfoScrap'): ! on = (Scrap.InfoScrap()[0] <> 0) ! else: ! flavors = Scrap.GetCurrentScrap().GetScrapFlavorInfoList() ! for tp, info in flavors: ! if tp == 'TEXT': ! on = 1 ! break ! else: ! on = 0 ! if on <> self.pastegroup_on: ! self.pasteitem.enable(on) ! self.pastegroup_on = on ! changed = 1 ! if changed: ! DrawMenuBar() ! # ! # Apple menu ! # ! ! def do_about(self, id, item, window, event): ! EasyDialogs.Message("A simple single-font text editor") ! ! # ! # File menu ! # ! def open(self, *args): ! self._open(0) ! ! def openfile(self, *args): ! self._open(1) ! def _open(self, askfile): ! if askfile: ! path = EasyDialogs.AskFileForOpen(typeList=('TEXT',)) ! if not path: ! return ! name = os.path.split(path)[-1] ! try: ! fp = open(path, 'rb') # NOTE binary, we need cr as end-of-line ! data = fp.read() ! fp.close() ! except IOError, arg: ! EasyDialogs.Message("IOERROR: %r" % (arg,)) ! return ! else: ! path = None ! name = "Untitled %d"%self.num ! data = '' ! w = TEWindow(self) ! w.open(path, name, data) ! self.num = self.num + 1 ! ! def closewin(self, *args): ! if self.active: ! self.active.close() ! else: ! EasyDialogs.Message("No active window?") ! ! def save(self, *args): ! if self.active: ! self.active.menu_save() ! else: ! EasyDialogs.Message("No active window?") ! ! def saveas(self, *args): ! if self.active: ! self.active.menu_save_as() ! else: ! EasyDialogs.Message("No active window?") ! ! ! def quit(self, *args): ! for w in self._windows.values(): ! w.close() ! if self._windows: ! return ! self._quit() ! ! # ! # Edit menu ! # ! ! def undo(self, *args): ! pass ! ! def cut(self, *args): ! if self.active: ! self.active.menu_cut() ! else: ! EasyDialogs.Message("No active window?") ! ! def copy(self, *args): ! if self.active: ! self.active.menu_copy() ! else: ! EasyDialogs.Message("No active window?") ! ! def paste(self, *args): ! if self.active: ! self.active.menu_paste() ! else: ! EasyDialogs.Message("No active window?") ! def clear(self, *args): ! if self.active: ! self.active.menu_clear() ! else: ! EasyDialogs.Message("No active window?") ! ! # ! # Other stuff ! # ! def idle(self, *args): ! if self.active: ! self.active.do_idle() ! else: ! Qd.SetCursor(Qd.GetQDGlobalsArrow()) def main(): ! App = Ped() ! App.mainloop() ! if __name__ == '__main__': ! main() ! --- 16,359 ---- class TEWindow(ScrolledWindow): ! def open(self, path, name, data): ! self.path = path ! self.name = name ! r = windowbounds(400, 400) ! w = Win.NewWindow(r, name, 1, 0, -1, 1, 0) ! self.wid = w ! x0, y0, x1, y1 = self.wid.GetWindowPort().GetPortBounds() ! x0 = x0 + 4 ! y0 = y0 + 4 ! x1 = x1 - 20 ! y1 = y1 - 20 ! vr = dr = x0, y0, x1, y1 ! ##vr = 4, 0, r[2]-r[0]-15, r[3]-r[1]-15 ! ##dr = (0, 0, vr[2], 0) ! Qd.SetPort(w) ! Qd.TextFont(4) ! Qd.TextSize(9) ! self.ted = TE.TENew(dr, vr) ! self.ted.TEAutoView(1) ! self.ted.TESetText(data) ! w.DrawGrowIcon() ! self.scrollbars() ! self.changed = 0 ! self.do_postopen() ! self.do_activate(1, None) ! def do_idle(self): ! self.ted.TEIdle() ! def getscrollbarvalues(self): ! dr = self.ted.destRect ! vr = self.ted.viewRect ! height = self.ted.nLines * self.ted.lineHeight ! vx = self.scalebarvalue(dr[0], dr[2]-dr[0], vr[0], vr[2]) ! vy = self.scalebarvalue(dr[1], dr[1]+height, vr[1], vr[3]) ! print dr, vr, height, vx, vy ! return None, vy ! ! def scrollbar_callback(self, which, what, value): ! if which == 'y': ! if what == 'set': ! height = self.ted.nLines * self.ted.lineHeight ! cur = self.getscrollbarvalues()[1] ! delta = (cur-value)*height/32767 ! if what == '-': ! delta = self.ted.lineHeight ! elif what == '--': ! delta = (self.ted.viewRect[3]-self.ted.lineHeight) ! if delta <= 0: ! delta = self.ted.lineHeight ! elif what == '+': ! delta = -self.ted.lineHeight ! elif what == '++': ! delta = -(self.ted.viewRect[3]-self.ted.lineHeight) ! if delta >= 0: ! delta = -self.ted.lineHeight ! self.ted.TEPinScroll(0, delta) ! print 'SCROLL Y', delta ! else: ! pass # No horizontal scrolling ! ! def do_activate(self, onoff, evt): ! print "ACTIVATE", onoff ! ScrolledWindow.do_activate(self, onoff, evt) ! if onoff: ! self.ted.TEActivate() ! self.parent.active = self ! self.parent.updatemenubar() ! else: ! self.ted.TEDeactivate() ! ! def do_update(self, wid, event): ! Qd.EraseRect(wid.GetWindowPort().GetPortBounds()) ! self.ted.TEUpdate(wid.GetWindowPort().GetPortBounds()) ! self.updatescrollbars() ! ! def do_contentclick(self, local, modifiers, evt): ! shifted = (modifiers & 0x200) ! self.ted.TEClick(local, shifted) ! self.updatescrollbars() ! self.parent.updatemenubar() ! ! def do_char(self, ch, event): ! self.ted.TESelView() ! self.ted.TEKey(ord(ch)) ! self.changed = 1 ! self.updatescrollbars() ! self.parent.updatemenubar() ! ! def close(self): ! if self.changed: ! save = EasyDialogs.AskYesNoCancel('Save window "%s" before closing?'%self.name, 1) ! if save > 0: ! self.menu_save() ! elif save < 0: ! return ! if self.parent.active == self: ! self.parent.active = None ! self.parent.updatemenubar() ! del self.ted ! self.do_postclose() ! ! def menu_save(self): ! if not self.path: ! self.menu_save_as() ! return # Will call us recursively ! print 'Saving to ', self.path ! dhandle = self.ted.TEGetText() ! data = dhandle.data ! fp = open(self.path, 'wb') # NOTE: wb, because data has CR for end-of-line ! fp.write(data) ! if data[-1] <> '\r': fp.write('\r') ! fp.close() ! self.changed = 0 ! ! def menu_save_as(self): ! path = EasyDialogs.AskFileForSave(message='Save as:') ! if not path: return ! self.path = path ! self.name = os.path.split(self.path)[-1] ! self.wid.SetWTitle(self.name) ! self.menu_save() ! ! def menu_cut(self): ! self.ted.TESelView() ! self.ted.TECut() ! if hasattr(Scrap, 'ZeroScrap'): ! Scrap.ZeroScrap() ! else: ! Scrap.ClearCurrentScrap() ! TE.TEToScrap() ! self.updatescrollbars() ! self.parent.updatemenubar() ! self.changed = 1 ! ! def menu_copy(self): ! self.ted.TECopy() ! if hasattr(Scrap, 'ZeroScrap'): ! Scrap.ZeroScrap() ! else: ! Scrap.ClearCurrentScrap() ! TE.TEToScrap() ! self.updatescrollbars() ! self.parent.updatemenubar() ! ! def menu_paste(self): ! TE.TEFromScrap() ! self.ted.TESelView() ! self.ted.TEPaste() ! self.updatescrollbars() ! self.parent.updatemenubar() ! self.changed = 1 ! ! def menu_clear(self): ! self.ted.TESelView() ! self.ted.TEDelete() ! self.updatescrollbars() ! self.parent.updatemenubar() ! self.changed = 1 ! ! def have_selection(self): ! return (self.ted.selStart < self.ted.selEnd) class Ped(Application): ! def __init__(self): ! Application.__init__(self) ! self.num = 0 ! self.active = None ! self.updatemenubar() ! def makeusermenus(self): ! self.filemenu = m = Menu(self.menubar, "File") ! self.newitem = MenuItem(m, "New window", "N", self.open) ! self.openitem = MenuItem(m, "Open...", "O", self.openfile) ! self.closeitem = MenuItem(m, "Close", "W", self.closewin) ! m.addseparator() ! self.saveitem = MenuItem(m, "Save", "S", self.save) ! self.saveasitem = MenuItem(m, "Save as...", "", self.saveas) ! m.addseparator() ! self.quititem = MenuItem(m, "Quit", "Q", self.quit) ! self.editmenu = m = Menu(self.menubar, "Edit") ! self.undoitem = MenuItem(m, "Undo", "Z", self.undo) ! self.cutitem = MenuItem(m, "Cut", "X", self.cut) ! self.copyitem = MenuItem(m, "Copy", "C", self.copy) ! self.pasteitem = MenuItem(m, "Paste", "V", self.paste) ! self.clearitem = MenuItem(m, "Clear", "", self.clear) ! # Not yet implemented: ! self.undoitem.enable(0) ! # Groups of items enabled together: ! self.windowgroup = [self.closeitem, self.saveitem, self.saveasitem, self.editmenu] ! self.focusgroup = [self.cutitem, self.copyitem, self.clearitem] ! self.windowgroup_on = -1 ! self.focusgroup_on = -1 ! self.pastegroup_on = -1 ! def updatemenubar(self): ! changed = 0 ! on = (self.active <> None) ! if on <> self.windowgroup_on: ! for m in self.windowgroup: ! m.enable(on) ! self.windowgroup_on = on ! changed = 1 ! if on: ! # only if we have an edit menu ! on = self.active.have_selection() ! if on <> self.focusgroup_on: ! for m in self.focusgroup: ! m.enable(on) ! self.focusgroup_on = on ! changed = 1 ! if hasattr(Scrap, 'InfoScrap'): ! on = (Scrap.InfoScrap()[0] <> 0) ! else: ! flavors = Scrap.GetCurrentScrap().GetScrapFlavorInfoList() ! for tp, info in flavors: ! if tp == 'TEXT': ! on = 1 ! break ! else: ! on = 0 ! if on <> self.pastegroup_on: ! self.pasteitem.enable(on) ! self.pastegroup_on = on ! changed = 1 ! if changed: ! DrawMenuBar() ! ! # ! # Apple menu ! # ! ! def do_about(self, id, item, window, event): ! EasyDialogs.Message("A simple single-font text editor") ! ! # ! # File menu ! # ! ! def open(self, *args): ! self._open(0) ! ! def openfile(self, *args): ! self._open(1) ! ! def _open(self, askfile): ! if askfile: ! path = EasyDialogs.AskFileForOpen(typeList=('TEXT',)) ! if not path: ! return ! name = os.path.split(path)[-1] ! try: ! fp = open(path, 'rb') # NOTE binary, we need cr as end-of-line ! data = fp.read() ! fp.close() ! except IOError, arg: ! EasyDialogs.Message("IOERROR: %r" % (arg,)) ! return ! else: ! path = None ! name = "Untitled %d"%self.num ! data = '' ! w = TEWindow(self) ! w.open(path, name, data) ! self.num = self.num + 1 ! ! def closewin(self, *args): ! if self.active: ! self.active.close() ! else: ! EasyDialogs.Message("No active window?") ! ! def save(self, *args): ! if self.active: ! self.active.menu_save() ! else: ! EasyDialogs.Message("No active window?") ! ! def saveas(self, *args): ! if self.active: ! self.active.menu_save_as() ! else: ! EasyDialogs.Message("No active window?") ! ! ! def quit(self, *args): ! for w in self._windows.values(): ! w.close() ! if self._windows: ! return ! self._quit() ! ! # ! # Edit menu ! # ! ! def undo(self, *args): ! pass ! ! def cut(self, *args): ! if self.active: ! self.active.menu_cut() ! else: ! EasyDialogs.Message("No active window?") ! ! def copy(self, *args): ! if self.active: ! self.active.menu_copy() ! else: ! EasyDialogs.Message("No active window?") ! ! def paste(self, *args): ! if self.active: ! self.active.menu_paste() ! else: ! EasyDialogs.Message("No active window?") ! ! def clear(self, *args): ! if self.active: ! self.active.menu_clear() ! else: ! EasyDialogs.Message("No active window?") ! ! # ! # Other stuff ! # ! ! def idle(self, *args): ! if self.active: ! self.active.do_idle() ! else: ! Qd.SetCursor(Qd.GetQDGlobalsArrow()) def main(): ! App = Ped() ! App.mainloop() ! if __name__ == '__main__': ! main() From tim_one at users.sourceforge.net Sun Jul 18 07:58:40 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 07:59:03 2004 Subject: [Python-checkins] python/dist/src/Mac/IDE scripts/Widget demos ActivateWindowDemo.py, 1.1, 1.2 KeyTester.py, 1.2, 1.3 ListWindow.py, 1.1, 1.2 TwoLists.py, 1.1, 1.2 WidgetTest.py, 1.3, 1.4 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/IDE scripts/Widget demos In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29056/IDE scripts/Widget demos Modified Files: ActivateWindowDemo.py KeyTester.py ListWindow.py TwoLists.py WidgetTest.py Log Message: Whitespace normalization, via reindent.py. Index: KeyTester.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/IDE scripts/Widget demos/KeyTester.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** KeyTester.py 12 Feb 2004 17:35:13 -0000 1.2 --- KeyTester.py 18 Jul 2004 05:58:07 -0000 1.3 *************** *** 5,14 **** # key callback function def tester(char, event): ! text = "%r\r%d\r%s\r%s" % (char, ord(char), hex(ord(chart)), oct(ord(char))) ! window.keys.set(text) # close callback def close(): ! window.close() # new window --- 5,14 ---- # key callback function def tester(char, event): ! text = "%r\r%d\r%s\r%s" % (char, ord(char), hex(ord(chart)), oct(ord(char))) ! window.keys.set(text) # close callback def close(): ! window.close() # new window Index: ListWindow.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/IDE scripts/Widget demos/ListWindow.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ListWindow.py 26 Sep 1999 12:24:57 -0000 1.1 --- ListWindow.py 18 Jul 2004 05:58:07 -0000 1.2 *************** *** 2,9 **** def listhit(isdbl): ! if isdbl: ! print "double-click in list!" ! else: ! print "click in list." window = W.Window((200, 400), "Window with List", minsize = (150, 200)) --- 2,9 ---- def listhit(isdbl): ! if isdbl: ! print "double-click in list!" ! else: ! print "click in list." window = W.Window((200, 400), "Window with List", minsize = (150, 200)) Index: TwoLists.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/IDE scripts/Widget demos/TwoLists.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TwoLists.py 26 Sep 1999 12:24:57 -0000 1.1 --- TwoLists.py 18 Jul 2004 05:58:07 -0000 1.2 *************** *** 2,15 **** def twothird(width, height): ! return (8, 8, width - 8, 2*height/3 - 4) def onethird(width, height): ! return (8, 2*height/3 + 4, width - 8, height - 22) def halfbounds1(width, height): ! return (0, 0, width/2 - 4, height) def halfbounds2(width, height): ! return (width/2 + 4, 0, width, height) window = W.Window((400, 400), "Sizable window with two lists", minsize = (200, 200)) --- 2,15 ---- def twothird(width, height): ! return (8, 8, width - 8, 2*height/3 - 4) def onethird(width, height): ! return (8, 2*height/3 + 4, width - 8, height - 22) def halfbounds1(width, height): ! return (0, 0, width/2 - 4, height) def halfbounds2(width, height): ! return (width/2 + 4, 0, width, height) window = W.Window((400, 400), "Sizable window with two lists", minsize = (200, 200)) Index: WidgetTest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/IDE scripts/Widget demos/WidgetTest.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** WidgetTest.py 12 Feb 2004 17:35:13 -0000 1.3 --- WidgetTest.py 18 Jul 2004 05:58:07 -0000 1.4 *************** *** 3,34 **** # define some callbacks def callback(): ! window.close() def checkcallback(value): ! print "hit the checkbox", value def radiocallback(value): ! print "hit radiobutton #3", value def scrollcallback(value): ! widget = window.hbar ! if value == "+": ! widget.set(widget.get() - 1) ! elif value == "-": ! widget.set(widget.get() + 1) ! elif value == "++": ! widget.set(widget.get() - 10) ! elif value == "--": ! widget.set(widget.get() + 10) ! else: # in thumb ! widget.set(value) ! print "scroll...", widget.get() def textcallback(): ! window.et3.set(window.et1.get()) def cancel(): ! import EasyDialogs ! EasyDialogs.Message("Cancel!") # make a non-sizable window --- 3,34 ---- # define some callbacks def callback(): ! window.close() def checkcallback(value): ! print "hit the checkbox", value def radiocallback(value): ! print "hit radiobutton #3", value def scrollcallback(value): ! widget = window.hbar ! if value == "+": ! widget.set(widget.get() - 1) ! elif value == "-": ! widget.set(widget.get() + 1) ! elif value == "++": ! widget.set(widget.get() - 10) ! elif value == "--": ! widget.set(widget.get() + 10) ! else: # in thumb ! widget.set(value) ! print "scroll...", widget.get() def textcallback(): ! window.et3.set(window.et1.get()) def cancel(): ! import EasyDialogs ! EasyDialogs.Message("Cancel!") # make a non-sizable window *************** *** 78,85 **** if 0: ! import time ! for i in range(20): ! window.et2.set(repr(i)) ! #window.et2.SetPort() ! #window.et2.draw() ! time.sleep(0.1) --- 78,85 ---- if 0: ! import time ! for i in range(20): ! window.et2.set(repr(i)) ! #window.et2.SetPort() ! #window.et2.draw() ! time.sleep(0.1) From tim_one at users.sourceforge.net Sun Jul 18 07:58:40 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 07:59:04 2004 Subject: [Python-checkins] python/dist/src/Mac/Modules/ah ahscan.py, 1.1, 1.2 ahsupport.py, 1.3, 1.4 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/ah In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29056/Modules/ah Modified Files: ahscan.py ahsupport.py Log Message: Whitespace normalization, via reindent.py. Index: ahscan.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/ah/ahscan.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ahscan.py 22 Aug 2002 23:31:37 -0000 1.1 --- ahscan.py 18 Jul 2004 05:58:07 -0000 1.2 *************** *** 12,52 **** def main(): ! input = LONG + ".h" ! output = SHORT + "gen.py" ! defsoutput = TOOLBOXDIR + LONG + ".py" ! scanner = MyScanner(input, output, defsoutput) ! scanner.scan() ! scanner.close() ! print "=== Testing definitions output code ===" ! execfile(defsoutput, {}, {}) ! print "=== Done scanning and generating, now importing the generated code... ===" ! exec "import " + SHORT + "support" ! print "=== Done. It's up to you to compile it now! ===" class MyScanner(Scanner_OSX): ! def destination(self, type, name, arglist): ! classname = "Function" ! listname = "functions" ! if arglist: ! t, n, m = arglist[0] ! # This is non-functional today ! if t == OBJECT and m == "InMode": ! classname = "Method" ! listname = "methods" ! return classname, listname ! def makeblacklistnames(self): ! return [ ! ] ! def makeblacklisttypes(self): ! return [ ! ] - def makerepairinstructions(self): - return [ - ] - if __name__ == "__main__": ! main() --- 12,52 ---- def main(): ! input = LONG + ".h" ! output = SHORT + "gen.py" ! defsoutput = TOOLBOXDIR + LONG + ".py" ! scanner = MyScanner(input, output, defsoutput) ! scanner.scan() ! scanner.close() ! print "=== Testing definitions output code ===" ! execfile(defsoutput, {}, {}) ! print "=== Done scanning and generating, now importing the generated code... ===" ! exec "import " + SHORT + "support" ! print "=== Done. It's up to you to compile it now! ===" class MyScanner(Scanner_OSX): ! def destination(self, type, name, arglist): ! classname = "Function" ! listname = "functions" ! if arglist: ! t, n, m = arglist[0] ! # This is non-functional today ! if t == OBJECT and m == "InMode": ! classname = "Method" ! listname = "methods" ! return classname, listname ! def makeblacklistnames(self): ! return [ ! ] ! def makeblacklisttypes(self): ! return [ ! ] ! ! def makerepairinstructions(self): ! return [ ! ] if __name__ == "__main__": ! main() Index: ahsupport.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/ah/ahsupport.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ahsupport.py 19 Nov 2003 16:13:23 -0000 1.3 --- ahsupport.py 18 Jul 2004 05:58:07 -0000 1.4 *************** *** 7,17 **** # Declarations that change for each manager ! MACHEADERFILE = 'AppleHelp.h' # The Apple header file ! MODNAME = '_AH' # The name of the module # The following is *usually* unchanged but may still require tuning ! MODPREFIX = 'Ah' # The prefix for module-wide routines INPUTFILE = string.lower(MODPREFIX) + 'gen.py' # The file generated by the scanner ! OUTPUTFILE = MODNAME + "module.c" # The file generated by this program from macsupport import * --- 7,17 ---- # Declarations that change for each manager ! MACHEADERFILE = 'AppleHelp.h' # The Apple header file ! MODNAME = '_AH' # The name of the module # The following is *usually* unchanged but may still require tuning ! MODPREFIX = 'Ah' # The prefix for module-wide routines INPUTFILE = string.lower(MODPREFIX) + 'gen.py' # The file generated by the scanner ! OUTPUTFILE = MODNAME + "module.c" # The file generated by this program from macsupport import * *************** *** 44,46 **** SetOutputFileName(OUTPUTFILE) module.generate() - --- 44,45 ---- From tim_one at users.sourceforge.net Sun Jul 18 07:58:40 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 07:59:06 2004 Subject: [Python-checkins] python/dist/src/Mac/Modules/ae aescan.py, 1.16, 1.17 aesupport.py, 1.33, 1.34 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/ae In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29056/Modules/ae Modified Files: aescan.py aesupport.py Log Message: Whitespace normalization, via reindent.py. Index: aescan.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/ae/aescan.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** aescan.py 12 Dec 2002 10:31:50 -0000 1.16 --- aescan.py 18 Jul 2004 05:58:07 -0000 1.17 *************** *** 14,99 **** def main(): ! print "=== Scanning AEDataModel.h, AppleEvents.h, AERegistry.h, AEObjects.h ===" ! input = ["AEDataModel.h", "AEInteraction.h", "AppleEvents.h", "AERegistry.h", "AEObjects.h"] ! output = "aegen.py" ! defsoutput = TOOLBOXDIR + "AppleEvents.py" ! scanner = AppleEventsScanner(input, output, defsoutput) ! scanner.scan() ! scanner.close() ! print "=== Testing definitions output code ===" ! execfile(defsoutput, {}, {}) ! print "=== Done Scanning and Generating, now doing 'import aesupport' ===" ! import aesupport ! print "=== Done 'import aesupport'. It's up to you to compile AEmodule.c ===" class AppleEventsScanner(Scanner): ! def destination(self, type, name, arglist): ! classname = "AEFunction" ! listname = "functions" ! if arglist: ! t, n, m = arglist[0] ! if t[-4:] == "_ptr" and m == "InMode" and \ ! t[:-4] in ("AEDesc", "AEAddressDesc", "AEDescList", ! "AERecord", "AppleEvent"): ! classname = "AEMethod" ! listname = "aedescmethods" ! return classname, listname ! def makeblacklistnames(self): ! return [ ! "AEDisposeDesc", ! # "AEGetEventHandler", ! "AEGetDescData", # Use object.data ! "AEGetSpecialHandler", ! # Constants with funny definitions ! "kAEDontDisposeOnResume", ! "kAEUseStandardDispatch", ! ] ! def makeblacklisttypes(self): ! return [ ! "ProcPtr", ! "AEArrayType", ! "AECoercionHandlerUPP", ! "UniversalProcPtr", ! "OSLCompareUPP", ! "OSLAccessorUPP", ! ] ! def makerepairinstructions(self): ! return [ ! ([("Boolean", "isSysHandler", "InMode")], ! [("AlwaysFalse", "*", "*")]), ! ! ([("void_ptr", "*", "InMode"), ("Size", "*", "InMode")], ! [("InBuffer", "*", "*")]), ! ! ([("EventHandlerProcPtr", "*", "InMode"), ("long", "*", "InMode")], ! [("EventHandler", "*", "*")]), ! ! ([("EventHandlerProcPtr", "*", "OutMode"), ("long", "*", "OutMode")], ! [("EventHandler", "*", "*")]), ! ! ([("AEEventHandlerUPP", "*", "InMode"), ("long", "*", "InMode")], ! [("EventHandler", "*", "*")]), ! ! ([("AEEventHandlerUPP", "*", "OutMode"), ("long", "*", "OutMode")], ! [("EventHandler", "*", "*")]), ! ! ([("void", "*", "OutMode"), ("Size", "*", "InMode"), ! ("Size", "*", "OutMode")], ! [("VarVarOutBuffer", "*", "InOutMode")]), ! ! ([("AppleEvent", "theAppleEvent", "OutMode")], ! [("AppleEvent_ptr", "*", "InMode")]), ! ! ([("AEDescList", "theAEDescList", "OutMode")], ! [("AEDescList_ptr", "*", "InMode")]), ! ] ! def writeinitialdefs(self): ! self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n") if __name__ == "__main__": ! main() --- 14,99 ---- def main(): ! print "=== Scanning AEDataModel.h, AppleEvents.h, AERegistry.h, AEObjects.h ===" ! input = ["AEDataModel.h", "AEInteraction.h", "AppleEvents.h", "AERegistry.h", "AEObjects.h"] ! output = "aegen.py" ! defsoutput = TOOLBOXDIR + "AppleEvents.py" ! scanner = AppleEventsScanner(input, output, defsoutput) ! scanner.scan() ! scanner.close() ! print "=== Testing definitions output code ===" ! execfile(defsoutput, {}, {}) ! print "=== Done Scanning and Generating, now doing 'import aesupport' ===" ! import aesupport ! print "=== Done 'import aesupport'. It's up to you to compile AEmodule.c ===" class AppleEventsScanner(Scanner): ! def destination(self, type, name, arglist): ! classname = "AEFunction" ! listname = "functions" ! if arglist: ! t, n, m = arglist[0] ! if t[-4:] == "_ptr" and m == "InMode" and \ ! t[:-4] in ("AEDesc", "AEAddressDesc", "AEDescList", ! "AERecord", "AppleEvent"): ! classname = "AEMethod" ! listname = "aedescmethods" ! return classname, listname ! def makeblacklistnames(self): ! return [ ! "AEDisposeDesc", ! # "AEGetEventHandler", ! "AEGetDescData", # Use object.data ! "AEGetSpecialHandler", ! # Constants with funny definitions ! "kAEDontDisposeOnResume", ! "kAEUseStandardDispatch", ! ] ! def makeblacklisttypes(self): ! return [ ! "ProcPtr", ! "AEArrayType", ! "AECoercionHandlerUPP", ! "UniversalProcPtr", ! "OSLCompareUPP", ! "OSLAccessorUPP", ! ] ! def makerepairinstructions(self): ! return [ ! ([("Boolean", "isSysHandler", "InMode")], ! [("AlwaysFalse", "*", "*")]), ! ([("void_ptr", "*", "InMode"), ("Size", "*", "InMode")], ! [("InBuffer", "*", "*")]), ! ! ([("EventHandlerProcPtr", "*", "InMode"), ("long", "*", "InMode")], ! [("EventHandler", "*", "*")]), ! ! ([("EventHandlerProcPtr", "*", "OutMode"), ("long", "*", "OutMode")], ! [("EventHandler", "*", "*")]), ! ! ([("AEEventHandlerUPP", "*", "InMode"), ("long", "*", "InMode")], ! [("EventHandler", "*", "*")]), ! ! ([("AEEventHandlerUPP", "*", "OutMode"), ("long", "*", "OutMode")], ! [("EventHandler", "*", "*")]), ! ! ([("void", "*", "OutMode"), ("Size", "*", "InMode"), ! ("Size", "*", "OutMode")], ! [("VarVarOutBuffer", "*", "InOutMode")]), ! ! ([("AppleEvent", "theAppleEvent", "OutMode")], ! [("AppleEvent_ptr", "*", "InMode")]), ! ! ([("AEDescList", "theAEDescList", "OutMode")], ! [("AEDescList_ptr", "*", "InMode")]), ! ] ! ! def writeinitialdefs(self): ! self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n") if __name__ == "__main__": ! main() Index: aesupport.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/ae/aesupport.py,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** aesupport.py 19 Nov 2003 16:34:03 -0000 1.33 --- aesupport.py 18 Jul 2004 05:58:07 -0000 1.34 *************** *** 40,66 **** class EHType(Type): ! def __init__(self, name = 'EventHandler', format = ''): ! Type.__init__(self, name, format) ! def declare(self, name): ! Output("AEEventHandlerUPP %s__proc__ = upp_GenericEventHandler;", name) ! Output("PyObject *%s;", name) ! def getargsFormat(self): ! return "O" ! def getargsArgs(self, name): ! return "&%s" % name ! def passInput(self, name): ! return "%s__proc__, (long)%s" % (name, name) ! def passOutput(self, name): ! return "&%s__proc__, (long *)&%s" % (name, name) ! def mkvalueFormat(self): ! return "O" ! def mkvalueArgs(self, name): ! return name ! def cleanup(self, name): ! Output("Py_INCREF(%s); /* XXX leak, but needed */", name) class EHNoRefConType(EHType): ! def passInput(self, name): ! return "upp_GenericEventHandler" EventHandler = EHType() --- 40,66 ---- class EHType(Type): ! def __init__(self, name = 'EventHandler', format = ''): ! Type.__init__(self, name, format) ! def declare(self, name): ! Output("AEEventHandlerUPP %s__proc__ = upp_GenericEventHandler;", name) ! Output("PyObject *%s;", name) ! def getargsFormat(self): ! return "O" ! def getargsArgs(self, name): ! return "&%s" % name ! def passInput(self, name): ! return "%s__proc__, (long)%s" % (name, name) ! def passOutput(self, name): ! return "&%s__proc__, (long *)&%s" % (name, name) ! def mkvalueFormat(self): ! return "O" ! def mkvalueArgs(self, name): ! return name ! def cleanup(self, name): ! Output("Py_INCREF(%s); /* XXX leak, but needed */", name) class EHNoRefConType(EHType): ! def passInput(self, name): ! return "upp_GenericEventHandler" EventHandler = EHType() *************** *** 102,108 **** static pascal Boolean AEIdleProc(EventRecord *theEvent, long *sleepTime, RgnHandle *mouseRgn) { ! if ( PyOS_InterruptOccurred() ) ! return 1; ! return 0; } --- 102,108 ---- static pascal Boolean AEIdleProc(EventRecord *theEvent, long *sleepTime, RgnHandle *mouseRgn) { ! if ( PyOS_InterruptOccurred() ) ! return 1; ! return 0; } *************** *** 114,155 **** GenericEventHandler(const AppleEvent *request, AppleEvent *reply, refcontype refcon) { ! PyObject *handler = (PyObject *)refcon; ! AEDescObject *requestObject, *replyObject; ! PyObject *args, *res; ! if ((requestObject = (AEDescObject *)AEDesc_New((AppleEvent *)request)) == NULL) { ! return -1; ! } ! if ((replyObject = (AEDescObject *)AEDesc_New(reply)) == NULL) { ! Py_DECREF(requestObject); ! return -1; ! } ! if ((args = Py_BuildValue("OO", requestObject, replyObject)) == NULL) { ! Py_DECREF(requestObject); ! Py_DECREF(replyObject); ! return -1; ! } ! res = PyEval_CallObject(handler, args); ! requestObject->ob_itself.descriptorType = 'null'; ! requestObject->ob_itself.dataHandle = NULL; ! replyObject->ob_itself.descriptorType = 'null'; ! replyObject->ob_itself.dataHandle = NULL; ! Py_DECREF(args); ! if (res == NULL) { ! PySys_WriteStderr("Exception in AE event handler function\\n"); ! PyErr_Print(); ! return -1; ! } ! Py_DECREF(res); ! return noErr; } PyObject *AEDesc_NewBorrowed(AEDesc *itself) { ! PyObject *it; ! ! it = AEDesc_New(itself); ! if (it) ! ((AEDescObject *)it)->ob_owned = 0; ! return (PyObject *)it; } --- 114,155 ---- GenericEventHandler(const AppleEvent *request, AppleEvent *reply, refcontype refcon) { ! PyObject *handler = (PyObject *)refcon; ! AEDescObject *requestObject, *replyObject; ! PyObject *args, *res; ! if ((requestObject = (AEDescObject *)AEDesc_New((AppleEvent *)request)) == NULL) { ! return -1; ! } ! if ((replyObject = (AEDescObject *)AEDesc_New(reply)) == NULL) { ! Py_DECREF(requestObject); ! return -1; ! } ! if ((args = Py_BuildValue("OO", requestObject, replyObject)) == NULL) { ! Py_DECREF(requestObject); ! Py_DECREF(replyObject); ! return -1; ! } ! res = PyEval_CallObject(handler, args); ! requestObject->ob_itself.descriptorType = 'null'; ! requestObject->ob_itself.dataHandle = NULL; ! replyObject->ob_itself.descriptorType = 'null'; ! replyObject->ob_itself.dataHandle = NULL; ! Py_DECREF(args); ! if (res == NULL) { ! PySys_WriteStderr("Exception in AE event handler function\\n"); ! PyErr_Print(); ! return -1; ! } ! Py_DECREF(res); ! return noErr; } PyObject *AEDesc_NewBorrowed(AEDesc *itself) { ! PyObject *it; ! ! it = AEDesc_New(itself); ! if (it) ! ((AEDescObject *)it)->ob_owned = 0; ! return (PyObject *)it; } *************** *** 157,165 **** initstuff = initstuff + """ ! upp_AEIdleProc = NewAEIdleUPP(AEIdleProc); ! upp_GenericEventHandler = NewAEEventHandlerUPP(GenericEventHandler); ! PyMac_INIT_TOOLBOX_OBJECT_NEW(AEDesc *, AEDesc_New); ! PyMac_INIT_TOOLBOX_OBJECT_NEW(AEDesc *, AEDesc_NewBorrowed); ! PyMac_INIT_TOOLBOX_OBJECT_CONVERT(AEDesc, AEDesc_Convert); """ --- 157,165 ---- initstuff = initstuff + """ ! upp_AEIdleProc = NewAEIdleUPP(AEIdleProc); ! upp_GenericEventHandler = NewAEEventHandlerUPP(GenericEventHandler); ! PyMac_INIT_TOOLBOX_OBJECT_NEW(AEDesc *, AEDesc_New); ! PyMac_INIT_TOOLBOX_OBJECT_NEW(AEDesc *, AEDesc_NewBorrowed); ! PyMac_INIT_TOOLBOX_OBJECT_CONVERT(AEDesc, AEDesc_Convert); """ *************** *** 167,210 **** class AEDescDefinition(PEP253Mixin, GlobalObjectDefinition): ! getsetlist = [( ! 'type', ! 'return PyMac_BuildOSType(self->ob_itself.descriptorType);', ! None, ! 'Type of this AEDesc' ! ), ( ! 'data', ! """ ! PyObject *res; ! Size size; ! char *ptr; ! OSErr err; ! ! size = AEGetDescDataSize(&self->ob_itself); ! if ( (res = PyString_FromStringAndSize(NULL, size)) == NULL ) ! return NULL; ! if ( (ptr = PyString_AsString(res)) == NULL ) ! return NULL; ! if ( (err=AEGetDescData(&self->ob_itself, ptr, size)) < 0 ) ! return PyMac_Error(err); ! return res; ! """, ! None, ! 'The raw data in this AEDesc' ! )] ! def __init__(self, name, prefix = None, itselftype = None): ! GlobalObjectDefinition.__init__(self, name, prefix or name, itselftype or name) ! self.argref = "*" ! def outputStructMembers(self): ! GlobalObjectDefinition.outputStructMembers(self) ! Output("int ob_owned;") ! ! def outputInitStructMembers(self): ! GlobalObjectDefinition.outputInitStructMembers(self) ! Output("it->ob_owned = 1;") ! ! def outputCleanupStructMembers(self): ! Output("if (self->ob_owned) AEDisposeDesc(&self->ob_itself);") aedescobject = AEDescDefinition('AEDesc') --- 167,210 ---- class AEDescDefinition(PEP253Mixin, GlobalObjectDefinition): ! getsetlist = [( ! 'type', ! 'return PyMac_BuildOSType(self->ob_itself.descriptorType);', ! None, ! 'Type of this AEDesc' ! ), ( ! 'data', ! """ ! PyObject *res; ! Size size; ! char *ptr; ! OSErr err; ! size = AEGetDescDataSize(&self->ob_itself); ! if ( (res = PyString_FromStringAndSize(NULL, size)) == NULL ) ! return NULL; ! if ( (ptr = PyString_AsString(res)) == NULL ) ! return NULL; ! if ( (err=AEGetDescData(&self->ob_itself, ptr, size)) < 0 ) ! return PyMac_Error(err); ! return res; ! """, ! None, ! 'The raw data in this AEDesc' ! )] ! def __init__(self, name, prefix = None, itselftype = None): ! GlobalObjectDefinition.__init__(self, name, prefix or name, itselftype or name) ! self.argref = "*" ! ! def outputStructMembers(self): ! GlobalObjectDefinition.outputStructMembers(self) ! Output("int ob_owned;") ! ! def outputInitStructMembers(self): ! GlobalObjectDefinition.outputInitStructMembers(self) ! Output("it->ob_owned = 1;") ! ! def outputCleanupStructMembers(self): ! Output("if (self->ob_owned) AEDisposeDesc(&self->ob_itself);") aedescobject = AEDescDefinition('AEDesc') From tim_one at users.sourceforge.net Sun Jul 18 07:58:40 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 07:59:07 2004 Subject: [Python-checkins] python/dist/src/Mac/Modules/app appscan.py, 1.11, 1.12 appsupport.py, 1.18, 1.19 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/app In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29056/Modules/app Modified Files: appscan.py appsupport.py Log Message: Whitespace normalization, via reindent.py. Index: appscan.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/app/appscan.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** appscan.py 12 Dec 2002 10:31:50 -0000 1.11 --- appscan.py 18 Jul 2004 05:58:08 -0000 1.12 *************** *** 12,81 **** def main(): ! input = LONG + ".h" ! output = SHORT + "gen.py" ! defsoutput = TOOLBOXDIR + LONG + ".py" ! scanner = MyScanner(input, output, defsoutput) ! scanner.scan() ! scanner.close() ! print "=== Testing definitions output code ===" ! execfile(defsoutput, {}, {}) ! print "=== Done scanning and generating, now importing the generated code... ===" ! exec "import " + SHORT + "support" ! print "=== Done. It's up to you to compile it now! ===" class MyScanner(Scanner): ! def destination(self, type, name, arglist): ! classname = "Function" ! listname = "functions" ! if arglist: ! t, n, m = arglist[0] ! # This is non-functional today ! if t == OBJECT and m == "InMode": ! classname = "Method" ! listname = "methods" ! return classname, listname ! def writeinitialdefs(self): ! self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n") ! def makeblacklistnames(self): ! return [ ! "GetThemeFont", # Funny stringbuffer in/out parameter, I think... ! # Constants with funny definitions ! "appearanceBadBrushIndexErr", ! "appearanceProcessRegisteredErr", ! "appearanceProcessNotRegisteredErr", ! "appearanceBadTextColorIndexErr", ! "appearanceThemeHasNoAccents", ! "appearanceBadCursorIndexErr", ! ] ! def makeblacklisttypes(self): ! return [ ! "MenuTitleDrawingUPP", ! "MenuItemDrawingUPP", ! "ThemeIteratorUPP", ! "ThemeTabTitleDrawUPP", ! # "ThemeEraseUPP", ! # "ThemeButtonDrawUPP", ! "WindowTitleDrawingUPP", ! "ProcessSerialNumber_ptr", # Too much work for now. ! "ThemeTrackDrawInfo_ptr", # Too much work ! # "ThemeButtonDrawInfo_ptr", # ditto ! "ThemeWindowMetrics_ptr", # ditto ! # "ThemeDrawingState", # This is an opaque pointer, so it should be simple. Later. ! "Collection", # No interface to collection mgr yet. ! "BytePtr", # Not yet. ! ] - def makerepairinstructions(self): - return [ - ([("void", 'inContext', "OutMode")], - [("NULL", 'inContext', "InMode")]), - ([("Point", 'ioBounds', "OutMode")], - [("Point", 'ioBounds', "InOutMode")]), - ] - if __name__ == "__main__": ! main() --- 12,81 ---- def main(): ! input = LONG + ".h" ! output = SHORT + "gen.py" ! defsoutput = TOOLBOXDIR + LONG + ".py" ! scanner = MyScanner(input, output, defsoutput) ! scanner.scan() ! scanner.close() ! print "=== Testing definitions output code ===" ! execfile(defsoutput, {}, {}) ! print "=== Done scanning and generating, now importing the generated code... ===" ! exec "import " + SHORT + "support" ! print "=== Done. It's up to you to compile it now! ===" class MyScanner(Scanner): ! def destination(self, type, name, arglist): ! classname = "Function" ! listname = "functions" ! if arglist: ! t, n, m = arglist[0] ! # This is non-functional today ! if t == OBJECT and m == "InMode": ! classname = "Method" ! listname = "methods" ! return classname, listname ! def writeinitialdefs(self): ! self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n") ! def makeblacklistnames(self): ! return [ ! "GetThemeFont", # Funny stringbuffer in/out parameter, I think... ! # Constants with funny definitions ! "appearanceBadBrushIndexErr", ! "appearanceProcessRegisteredErr", ! "appearanceProcessNotRegisteredErr", ! "appearanceBadTextColorIndexErr", ! "appearanceThemeHasNoAccents", ! "appearanceBadCursorIndexErr", ! ] ! def makeblacklisttypes(self): ! return [ ! "MenuTitleDrawingUPP", ! "MenuItemDrawingUPP", ! "ThemeIteratorUPP", ! "ThemeTabTitleDrawUPP", ! # "ThemeEraseUPP", ! # "ThemeButtonDrawUPP", ! "WindowTitleDrawingUPP", ! "ProcessSerialNumber_ptr", # Too much work for now. ! "ThemeTrackDrawInfo_ptr", # Too much work ! # "ThemeButtonDrawInfo_ptr", # ditto ! "ThemeWindowMetrics_ptr", # ditto ! # "ThemeDrawingState", # This is an opaque pointer, so it should be simple. Later. ! "Collection", # No interface to collection mgr yet. ! "BytePtr", # Not yet. ! ] ! ! def makerepairinstructions(self): ! return [ ! ([("void", 'inContext', "OutMode")], ! [("NULL", 'inContext', "InMode")]), ! ([("Point", 'ioBounds', "OutMode")], ! [("Point", 'ioBounds', "InOutMode")]), ! ] if __name__ == "__main__": ! main() Index: appsupport.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/app/appsupport.py,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** appsupport.py 19 Nov 2003 16:13:23 -0000 1.18 --- appsupport.py 18 Jul 2004 05:58:08 -0000 1.19 *************** *** 7,21 **** # Declarations that change for each manager ! MACHEADERFILE = 'Appearance.h' # The Apple header file ! MODNAME = '_App' # The name of the module ! OBJECTNAME = 'ThemeDrawingState' # The basic name of the objects used here ! KIND = '' # Usually 'Ptr' or 'Handle' # The following is *usually* unchanged but may still require tuning ! MODPREFIX = 'App' # The prefix for module-wide routines ! OBJECTTYPE = OBJECTNAME + KIND # The C type used to represent them ! OBJECTPREFIX = OBJECTNAME + 'Obj' # The prefix for object methods INPUTFILE = string.lower(MODPREFIX) + 'gen.py' # The file generated by the scanner ! OUTPUTFILE = MODNAME + "module.c" # The file generated by this program from macsupport import * --- 7,21 ---- # Declarations that change for each manager ! MACHEADERFILE = 'Appearance.h' # The Apple header file ! MODNAME = '_App' # The name of the module ! OBJECTNAME = 'ThemeDrawingState' # The basic name of the objects used here ! KIND = '' # Usually 'Ptr' or 'Handle' # The following is *usually* unchanged but may still require tuning ! MODPREFIX = 'App' # The prefix for module-wide routines ! OBJECTTYPE = OBJECTNAME + KIND # The C type used to represent them ! OBJECTPREFIX = OBJECTNAME + 'Obj' # The prefix for object methods INPUTFILE = string.lower(MODPREFIX) + 'gen.py' # The file generated by the scanner ! OUTPUTFILE = MODNAME + "module.c" # The file generated by this program from macsupport import * *************** *** 85,89 **** int ThemeButtonDrawInfo_Convert(PyObject *v, ThemeButtonDrawInfo *p_itself) { ! return PyArg_Parse(v, "(iHH)", &p_itself->state, &p_itself->value, &p_itself->adornment); } --- 85,89 ---- int ThemeButtonDrawInfo_Convert(PyObject *v, ThemeButtonDrawInfo *p_itself) { ! return PyArg_Parse(v, "(iHH)", &p_itself->state, &p_itself->value, &p_itself->adornment); } *************** *** 91,106 **** class MyObjectDefinition(PEP253Mixin, GlobalObjectDefinition): ! pass ! ## def outputCheckNewArg(self): ! ## Output("if (itself == NULL) return PyMac_Error(resNotFound);") ! ## def outputCheckConvertArg(self): ! ## OutLbrace("if (DlgObj_Check(v))") ! ## Output("*p_itself = ((WindowObject *)v)->ob_itself;") ! ## Output("return 1;") ! ## OutRbrace() ! ## Out(""" ! ## if (v == Py_None) { *p_itself = NULL; return 1; } ! ## if (PyInt_Check(v)) { *p_itself = (WindowPtr)PyInt_AsLong(v); return 1; } ! ## """) # From here on it's basically all boiler plate... --- 91,106 ---- class MyObjectDefinition(PEP253Mixin, GlobalObjectDefinition): ! pass ! ## def outputCheckNewArg(self): ! ## Output("if (itself == NULL) return PyMac_Error(resNotFound);") ! ## def outputCheckConvertArg(self): ! ## OutLbrace("if (DlgObj_Check(v))") ! ## Output("*p_itself = ((WindowObject *)v)->ob_itself;") ! ## Output("return 1;") ! ## OutRbrace() ! ## Out(""" ! ## if (v == Py_None) { *p_itself = NULL; return 1; } ! ## if (PyInt_Check(v)) { *p_itself = (WindowPtr)PyInt_AsLong(v); return 1; } ! ## """) # From here on it's basically all boiler plate... *************** *** 132,134 **** SetOutputFileName(OUTPUTFILE) module.generate() - --- 132,133 ---- From tim_one at users.sourceforge.net Sun Jul 18 07:58:39 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 07:59:09 2004 Subject: [Python-checkins] python/dist/src/Mac/Demo/waste htmled.py, 1.14, 1.15 swed.py, 1.15, 1.16 wed.py, 1.11, 1.12 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Demo/waste In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29056/Demo/waste Modified Files: htmled.py swed.py wed.py Log Message: Whitespace normalization, via reindent.py. Index: htmled.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Demo/waste/htmled.py,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** htmled.py 12 Feb 2004 17:35:13 -0000 1.14 --- htmled.py 18 Jul 2004 05:58:06 -0000 1.15 *************** *** 24,831 **** UNDOLABELS = [ # Indexed by WEGetUndoInfo() value ! None, "", "typing", "Cut", "Paste", "Clear", "Drag", "Style"] ! # Style and size menu. Note that style order is important (tied to bit values) STYLES = [ ! ("Bold", "B"), ("Italic", "I"), ("Underline", "U"), ("Outline", "O"), ! ("Shadow", ""), ("Condensed", ""), ("Extended", "") ! ] SIZES = [ 9, 10, 12, 14, 18, 24] [...1586 lines suppressed...] ! n = Fm.GetFontName(i) ! if n: names.append(n) ! return names ! def getfontsizes(name, sizes): ! exist = [] ! num = Fm.GetFNum(name) ! for sz in sizes: ! if Fm.RealFont(num, sz): ! exist.append(1) ! else: ! exist.append(0) ! return exist def main(): ! App = Wed() ! App.mainloop() ! if __name__ == '__main__': ! main() Index: swed.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Demo/waste/swed.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** swed.py 12 Feb 2004 17:35:13 -0000 1.15 --- swed.py 18 Jul 2004 05:58:06 -0000 1.16 *************** *** 17,635 **** UNDOLABELS = [ # Indexed by WEGetUndoInfo() value ! None, "", "typing", "Cut", "Paste", "Clear", "Drag", "Style"] ! # Style and size menu. Note that style order is important (tied to bit values) STYLES = [ ! ("Bold", "B"), ("Italic", "I"), ("Underline", "U"), ("Outline", "O"), ! ("Shadow", ""), ("Condensed", ""), ("Extended", "") ! ] SIZES = [ 9, 10, 12, 14, 18, 24] [...1208 lines suppressed...] ! n = Fm.GetFontName(i) ! if n: names.append(n) ! return names ! def getfontsizes(name, sizes): ! exist = [] ! num = Fm.GetFNum(name) ! for sz in sizes: ! if Fm.RealFont(num, sz): ! exist.append(1) ! else: ! exist.append(0) ! return exist def main(): ! App = Wed() ! App.mainloop() ! if __name__ == '__main__': ! main() Index: wed.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Demo/waste/wed.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** wed.py 12 Feb 2004 17:35:13 -0000 1.11 --- wed.py 18 Jul 2004 05:58:06 -0000 1.12 *************** *** 16,427 **** UNDOLABELS = [ # Indexed by WEGetUndoInfo() value ! None, "", "typing", "Cut", "Paste", "Clear", "Drag", "Style"] ! BIGREGION=Qd.NewRgn() Qd.SetRectRgn(BIGREGION, -16000, -16000, 16000, 16000) class WasteWindow(ScrolledWindow): ! def open(self, path, name, data): ! self.path = path ! self.name = name ! r = windowbounds(400, 400) ! w = Win.NewWindow(r, name, 1, 0, -1, 1, 0) ! self.wid = w ! vr = 0, 0, r[2]-r[0]-15, r[3]-r[1]-15 ! dr = (0, 0, 10240, 0) ! Qd.SetPort(w) ! Qd.TextFont(4) ! Qd.TextSize(9) ! flags = WASTEconst.weDoAutoScroll | WASTEconst.weDoOutlineHilite | \ ! WASTEconst.weDoMonoStyled | WASTEconst.weDoUndo ! self.ted = waste.WENew(dr, vr, flags) ! self.tedtexthandle = Res.Resource(data) ! self.ted.WEUseText(self.tedtexthandle) ! self.ted.WECalText() ! w.DrawGrowIcon() ! self.scrollbars() ! self.changed = 0 ! self.do_postopen() ! self.do_activate(1, None) ! ! def do_idle(self, event): ! (what, message, when, where, modifiers) = event ! Qd.SetPort(self.wid) ! self.ted.WEIdle() ! if self.ted.WEAdjustCursor(where, BIGREGION): ! return ! Qd.SetCursor(Qd.GetQDGlobalsArrow()) ! ! def getscrollbarvalues(self): ! dr = self.ted.WEGetDestRect() ! vr = self.ted.WEGetViewRect() ! vx = self.scalebarvalue(dr[0], dr[2], vr[0], vr[2]) ! vy = self.scalebarvalue(dr[1], dr[3], vr[1], vr[3]) ! ## print dr, vr, vx, vy ! return vx, vy ! ! def scrollbar_callback(self, which, what, value): ! if which == 'y': ! if what == 'set': ! height = self.ted.WEGetHeight(0, 0x3fffffff) ! cur = self.getscrollbarvalues()[1] ! delta = (cur-value)*height/32767 ! if what == '-': ! topline_off,dummy = self.ted.WEGetOffset((1,1)) ! topline_num = self.ted.WEOffsetToLine(topline_off) ! delta = self.ted.WEGetHeight(topline_num, topline_num+1) ! elif what == '--': ! delta = (self.ted.WEGetViewRect()[3]-10) ! if delta <= 0: ! delta = 10 # Random value ! elif what == '+': ! # XXXX Wrong: should be bottom line size ! topline_off,dummy = self.ted.WEGetOffset((1,1)) ! topline_num = self.ted.WEOffsetToLine(topline_off) ! delta = -self.ted.WEGetHeight(topline_num, topline_num+1) ! elif what == '++': ! delta = -(self.ted.WEGetViewRect()[3]-10) ! if delta >= 0: ! delta = -10 ! self.ted.WEScroll(0, delta) ! ## print 'SCROLL Y', delta ! else: ! if what == 'set': ! return # XXXX ! vr = self.ted.WEGetViewRect() ! winwidth = vr[2]-vr[0] ! if what == '-': ! delta = winwidth/10 ! elif what == '--': ! delta = winwidth/2 ! elif what == '+': ! delta = -winwidth/10 ! elif what == '++': ! delta = -winwidth/2 ! self.ted.WEScroll(delta, 0) ! # Pin the scroll ! l, t, r, b = self.ted.WEGetDestRect() ! vl, vt, vr, vb = self.ted.WEGetViewRect() ! if t > 0 or l > 0: ! dx = dy = 0 ! if t > 0: dy = -t ! if l > 0: dx = -l ! ## print 'Extra scroll', dx, dy ! self.ted.WEScroll(dx, dy) ! elif b < vb: ! ## print 'Extra downscroll', b-vb ! self.ted.WEScroll(0, b-vb) ! ! def do_activate(self, onoff, evt): ! ## print "ACTIVATE", onoff ! Qd.SetPort(self.wid) ! ScrolledWindow.do_activate(self, onoff, evt) ! if onoff: ! self.ted.WEActivate() ! self.parent.active = self ! self.parent.updatemenubar() ! else: ! self.ted.WEDeactivate() ! def do_update(self, wid, event): ! region = wid.GetWindowPort().visRgn ! if Qd.EmptyRgn(region): ! return ! Qd.EraseRgn(region) ! self.ted.WEUpdate(region) ! self.updatescrollbars() ! ! def do_postresize(self, width, height, window): ! l, t, r, b = self.ted.WEGetViewRect() ! vr = (l, t, l+width-15, t+height-15) ! self.ted.WESetViewRect(vr) ! self.wid.InvalWindowRect(vr) ! ScrolledWindow.do_postresize(self, width, height, window) ! ! def do_contentclick(self, local, modifiers, evt): ! (what, message, when, where, modifiers) = evt ! self.ted.WEClick(local, modifiers, when) ! self.updatescrollbars() ! self.parent.updatemenubar() ! def do_char(self, ch, event): ! self.ted.WESelView() ! (what, message, when, where, modifiers) = event ! self.ted.WEKey(ord(ch), modifiers) ! self.changed = 1 ! self.updatescrollbars() ! self.parent.updatemenubar() ! ! def close(self): ! if self.changed: ! save = EasyDialogs.AskYesNoCancel('Save window "%s" before closing?'%self.name, 1) ! if save > 0: ! self.menu_save() ! elif save < 0: ! return ! if self.parent.active == self: ! self.parent.active = None ! self.parent.updatemenubar() ! del self.ted ! del self.tedtexthandle ! self.do_postclose() ! ! def menu_save(self): ! if not self.path: ! self.menu_save_as() ! return # Will call us recursively ! ## print 'Saving to ', self.path ! dhandle = self.ted.WEGetText() ! data = dhandle.data ! fp = open(self.path, 'wb') # NOTE: wb, because data has CR for end-of-line ! fp.write(data) ! if data[-1] <> '\r': fp.write('\r') ! fp.close() ! self.changed = 0 ! ! def menu_save_as(self): ! path = EasyDialogs.AskFileForSave(message='Save as:') ! if not path: return ! self.path = path ! self.name = os.path.split(self.path)[-1] ! self.wid.SetWTitle(self.name) ! self.menu_save() ! ! def menu_cut(self): ! self.ted.WESelView() ! if hasattr(Scrap, 'ZeroScrap'): ! Scrap.ZeroScrap() ! else: ! Scrap.ClearCurrentScrap() ! self.ted.WECut() ! self.updatescrollbars() ! self.parent.updatemenubar() ! self.changed = 1 ! ! def menu_copy(self): ! if hasattr(Scrap, 'ZeroScrap'): ! Scrap.ZeroScrap() ! else: ! Scrap.ClearCurrentScrap() ! self.ted.WECopy() ! self.updatescrollbars() ! self.parent.updatemenubar() ! ! def menu_paste(self): ! self.ted.WESelView() ! self.ted.WEPaste() ! self.updatescrollbars() ! self.parent.updatemenubar() ! self.changed = 1 ! ! def menu_clear(self): ! self.ted.WESelView() ! self.ted.WEDelete() ! self.updatescrollbars() ! self.parent.updatemenubar() ! self.changed = 1 ! def menu_undo(self): ! self.ted.WEUndo() ! self.updatescrollbars() ! self.parent.updatemenubar() ! ! def have_selection(self): ! start, stop = self.ted.WEGetSelection() ! return start < stop ! ! def can_paste(self): ! return self.ted.WECanPaste() ! ! def can_undo(self): ! which, redo = self.ted.WEGetUndoInfo() ! which = UNDOLABELS[which] ! if which == None: return None ! if redo: ! return "Redo "+which ! else: ! return "Undo "+which class Wed(Application): ! def __init__(self): ! Application.__init__(self) ! self.num = 0 ! self.active = None ! self.updatemenubar() ! ! def makeusermenus(self): ! self.filemenu = m = Menu(self.menubar, "File") ! self.newitem = MenuItem(m, "New window", "N", self.open) ! self.openitem = MenuItem(m, "Open...", "O", self.openfile) ! self.closeitem = MenuItem(m, "Close", "W", self.closewin) ! m.addseparator() ! self.saveitem = MenuItem(m, "Save", "S", self.save) ! self.saveasitem = MenuItem(m, "Save as...", "", self.saveas) ! m.addseparator() ! self.quititem = MenuItem(m, "Quit", "Q", self.quit) ! ! self.editmenu = m = Menu(self.menubar, "Edit") ! self.undoitem = MenuItem(m, "Undo", "Z", self.undo) ! self.cutitem = MenuItem(m, "Cut", "X", self.cut) ! self.copyitem = MenuItem(m, "Copy", "C", self.copy) ! self.pasteitem = MenuItem(m, "Paste", "V", self.paste) ! self.clearitem = MenuItem(m, "Clear", "", self.clear) ! ! # Groups of items enabled together: ! self.windowgroup = [self.closeitem, self.saveitem, self.saveasitem, self.editmenu] ! self.focusgroup = [self.cutitem, self.copyitem, self.clearitem] ! self.windowgroup_on = -1 ! self.focusgroup_on = -1 ! self.pastegroup_on = -1 ! self.undo_label = "never" ! ! def updatemenubar(self): ! changed = 0 ! on = (self.active <> None) ! if on <> self.windowgroup_on: ! for m in self.windowgroup: ! m.enable(on) ! self.windowgroup_on = on ! changed = 1 ! if on: ! # only if we have an edit menu ! on = self.active.have_selection() ! if on <> self.focusgroup_on: ! for m in self.focusgroup: ! m.enable(on) ! self.focusgroup_on = on ! changed = 1 ! on = self.active.can_paste() ! if on <> self.pastegroup_on: ! self.pasteitem.enable(on) ! self.pastegroup_on = on ! changed = 1 ! on = self.active.can_undo() ! if on <> self.undo_label: ! if on: ! self.undoitem.enable(1) ! self.undoitem.settext(on) ! self.undo_label = on ! else: ! self.undoitem.settext("Nothing to undo") ! self.undoitem.enable(0) ! changed = 1 ! if changed: ! DrawMenuBar() ! # ! # Apple menu ! # ! ! def do_about(self, id, item, window, event): ! EasyDialogs.Message("A simple single-font text editor based on WASTE") ! ! # ! # File menu ! # ! def open(self, *args): ! self._open(0) ! ! def openfile(self, *args): ! self._open(1) ! def _open(self, askfile): ! if askfile: ! path = EasyDialogs.AskFileForOpen(typeList=('TEXT',)) ! if not path: ! return ! name = os.path.split(path)[-1] ! try: ! fp = open(path, 'rb') # NOTE binary, we need cr as end-of-line ! data = fp.read() ! fp.close() ! except IOError, arg: ! EasyDialogs.Message("IOERROR: %r" % (arg,)) ! return ! else: ! path = None ! name = "Untitled %d"%self.num ! data = '' ! w = WasteWindow(self) ! w.open(path, name, data) ! self.num = self.num + 1 ! ! def closewin(self, *args): ! if self.active: ! self.active.close() ! else: ! EasyDialogs.Message("No active window?") ! ! def save(self, *args): ! if self.active: ! self.active.menu_save() ! else: ! EasyDialogs.Message("No active window?") ! ! def saveas(self, *args): ! if self.active: ! self.active.menu_save_as() ! else: ! EasyDialogs.Message("No active window?") ! ! ! def quit(self, *args): ! for w in self._windows.values(): ! w.close() ! if self._windows: ! return ! self._quit() ! ! # ! # Edit menu ! # ! ! def undo(self, *args): ! if self.active: ! self.active.menu_undo() ! else: ! EasyDialogs.Message("No active window?") ! ! def cut(self, *args): ! if self.active: ! self.active.menu_cut() ! else: ! EasyDialogs.Message("No active window?") ! ! def copy(self, *args): ! if self.active: ! self.active.menu_copy() ! else: ! EasyDialogs.Message("No active window?") ! ! def paste(self, *args): ! if self.active: ! self.active.menu_paste() ! else: ! EasyDialogs.Message("No active window?") ! def clear(self, *args): ! if self.active: ! self.active.menu_clear() ! else: ! EasyDialogs.Message("No active window?") ! ! # ! # Other stuff ! # ! def idle(self, event): ! if self.active: ! self.active.do_idle(event) ! else: ! Qd.SetCursor(Qd.GetQDGlobalsArrow()) def main(): ! App = Wed() ! App.mainloop() ! if __name__ == '__main__': ! main() ! --- 16,426 ---- UNDOLABELS = [ # Indexed by WEGetUndoInfo() value ! None, "", "typing", "Cut", "Paste", "Clear", "Drag", "Style"] ! BIGREGION=Qd.NewRgn() Qd.SetRectRgn(BIGREGION, -16000, -16000, 16000, 16000) class WasteWindow(ScrolledWindow): ! def open(self, path, name, data): ! self.path = path ! self.name = name ! r = windowbounds(400, 400) ! w = Win.NewWindow(r, name, 1, 0, -1, 1, 0) ! self.wid = w ! vr = 0, 0, r[2]-r[0]-15, r[3]-r[1]-15 ! dr = (0, 0, 10240, 0) ! Qd.SetPort(w) ! Qd.TextFont(4) ! Qd.TextSize(9) ! flags = WASTEconst.weDoAutoScroll | WASTEconst.weDoOutlineHilite | \ ! WASTEconst.weDoMonoStyled | WASTEconst.weDoUndo ! self.ted = waste.WENew(dr, vr, flags) ! self.tedtexthandle = Res.Resource(data) ! self.ted.WEUseText(self.tedtexthandle) ! self.ted.WECalText() ! w.DrawGrowIcon() ! self.scrollbars() ! self.changed = 0 ! self.do_postopen() ! self.do_activate(1, None) ! def do_idle(self, event): ! (what, message, when, where, modifiers) = event ! Qd.SetPort(self.wid) ! self.ted.WEIdle() ! if self.ted.WEAdjustCursor(where, BIGREGION): ! return ! Qd.SetCursor(Qd.GetQDGlobalsArrow()) ! def getscrollbarvalues(self): ! dr = self.ted.WEGetDestRect() ! vr = self.ted.WEGetViewRect() ! vx = self.scalebarvalue(dr[0], dr[2], vr[0], vr[2]) ! vy = self.scalebarvalue(dr[1], dr[3], vr[1], vr[3]) ! ## print dr, vr, vx, vy ! return vx, vy ! def scrollbar_callback(self, which, what, value): ! if which == 'y': ! if what == 'set': ! height = self.ted.WEGetHeight(0, 0x3fffffff) ! cur = self.getscrollbarvalues()[1] ! delta = (cur-value)*height/32767 ! if what == '-': ! topline_off,dummy = self.ted.WEGetOffset((1,1)) ! topline_num = self.ted.WEOffsetToLine(topline_off) ! delta = self.ted.WEGetHeight(topline_num, topline_num+1) ! elif what == '--': ! delta = (self.ted.WEGetViewRect()[3]-10) ! if delta <= 0: ! delta = 10 # Random value ! elif what == '+': ! # XXXX Wrong: should be bottom line size ! topline_off,dummy = self.ted.WEGetOffset((1,1)) ! topline_num = self.ted.WEOffsetToLine(topline_off) ! delta = -self.ted.WEGetHeight(topline_num, topline_num+1) ! elif what == '++': ! delta = -(self.ted.WEGetViewRect()[3]-10) ! if delta >= 0: ! delta = -10 ! self.ted.WEScroll(0, delta) ! ## print 'SCROLL Y', delta ! else: ! if what == 'set': ! return # XXXX ! vr = self.ted.WEGetViewRect() ! winwidth = vr[2]-vr[0] ! if what == '-': ! delta = winwidth/10 ! elif what == '--': ! delta = winwidth/2 ! elif what == '+': ! delta = -winwidth/10 ! elif what == '++': ! delta = -winwidth/2 ! self.ted.WEScroll(delta, 0) ! # Pin the scroll ! l, t, r, b = self.ted.WEGetDestRect() ! vl, vt, vr, vb = self.ted.WEGetViewRect() ! if t > 0 or l > 0: ! dx = dy = 0 ! if t > 0: dy = -t ! if l > 0: dx = -l ! ## print 'Extra scroll', dx, dy ! self.ted.WEScroll(dx, dy) ! elif b < vb: ! ## print 'Extra downscroll', b-vb ! self.ted.WEScroll(0, b-vb) ! ! def do_activate(self, onoff, evt): ! ## print "ACTIVATE", onoff ! Qd.SetPort(self.wid) ! ScrolledWindow.do_activate(self, onoff, evt) ! if onoff: ! self.ted.WEActivate() ! self.parent.active = self ! self.parent.updatemenubar() ! else: ! self.ted.WEDeactivate() ! ! def do_update(self, wid, event): ! region = wid.GetWindowPort().visRgn ! if Qd.EmptyRgn(region): ! return ! Qd.EraseRgn(region) ! self.ted.WEUpdate(region) ! self.updatescrollbars() ! ! def do_postresize(self, width, height, window): ! l, t, r, b = self.ted.WEGetViewRect() ! vr = (l, t, l+width-15, t+height-15) ! self.ted.WESetViewRect(vr) ! self.wid.InvalWindowRect(vr) ! ScrolledWindow.do_postresize(self, width, height, window) ! ! def do_contentclick(self, local, modifiers, evt): ! (what, message, when, where, modifiers) = evt ! self.ted.WEClick(local, modifiers, when) ! self.updatescrollbars() ! self.parent.updatemenubar() ! ! def do_char(self, ch, event): ! self.ted.WESelView() ! (what, message, when, where, modifiers) = event ! self.ted.WEKey(ord(ch), modifiers) ! self.changed = 1 ! self.updatescrollbars() ! self.parent.updatemenubar() ! ! def close(self): ! if self.changed: ! save = EasyDialogs.AskYesNoCancel('Save window "%s" before closing?'%self.name, 1) ! if save > 0: ! self.menu_save() ! elif save < 0: ! return ! if self.parent.active == self: ! self.parent.active = None ! self.parent.updatemenubar() ! del self.ted ! del self.tedtexthandle ! self.do_postclose() ! ! def menu_save(self): ! if not self.path: ! self.menu_save_as() ! return # Will call us recursively ! ## print 'Saving to ', self.path ! dhandle = self.ted.WEGetText() ! data = dhandle.data ! fp = open(self.path, 'wb') # NOTE: wb, because data has CR for end-of-line ! fp.write(data) ! if data[-1] <> '\r': fp.write('\r') ! fp.close() ! self.changed = 0 ! ! def menu_save_as(self): ! path = EasyDialogs.AskFileForSave(message='Save as:') ! if not path: return ! self.path = path ! self.name = os.path.split(self.path)[-1] ! self.wid.SetWTitle(self.name) ! self.menu_save() ! ! def menu_cut(self): ! self.ted.WESelView() ! if hasattr(Scrap, 'ZeroScrap'): ! Scrap.ZeroScrap() ! else: ! Scrap.ClearCurrentScrap() ! self.ted.WECut() ! self.updatescrollbars() ! self.parent.updatemenubar() ! self.changed = 1 ! ! def menu_copy(self): ! if hasattr(Scrap, 'ZeroScrap'): ! Scrap.ZeroScrap() ! else: ! Scrap.ClearCurrentScrap() ! self.ted.WECopy() ! self.updatescrollbars() ! self.parent.updatemenubar() ! ! def menu_paste(self): ! self.ted.WESelView() ! self.ted.WEPaste() ! self.updatescrollbars() ! self.parent.updatemenubar() ! self.changed = 1 ! ! def menu_clear(self): ! self.ted.WESelView() ! self.ted.WEDelete() ! self.updatescrollbars() ! self.parent.updatemenubar() ! self.changed = 1 ! ! def menu_undo(self): ! self.ted.WEUndo() ! self.updatescrollbars() ! self.parent.updatemenubar() ! ! def have_selection(self): ! start, stop = self.ted.WEGetSelection() ! return start < stop ! ! def can_paste(self): ! return self.ted.WECanPaste() ! ! def can_undo(self): ! which, redo = self.ted.WEGetUndoInfo() ! which = UNDOLABELS[which] ! if which == None: return None ! if redo: ! return "Redo "+which ! else: ! return "Undo "+which class Wed(Application): ! def __init__(self): ! Application.__init__(self) ! self.num = 0 ! self.active = None ! self.updatemenubar() ! def makeusermenus(self): ! self.filemenu = m = Menu(self.menubar, "File") ! self.newitem = MenuItem(m, "New window", "N", self.open) ! self.openitem = MenuItem(m, "Open...", "O", self.openfile) ! self.closeitem = MenuItem(m, "Close", "W", self.closewin) ! m.addseparator() ! self.saveitem = MenuItem(m, "Save", "S", self.save) ! self.saveasitem = MenuItem(m, "Save as...", "", self.saveas) ! m.addseparator() ! self.quititem = MenuItem(m, "Quit", "Q", self.quit) ! self.editmenu = m = Menu(self.menubar, "Edit") ! self.undoitem = MenuItem(m, "Undo", "Z", self.undo) ! self.cutitem = MenuItem(m, "Cut", "X", self.cut) ! self.copyitem = MenuItem(m, "Copy", "C", self.copy) ! self.pasteitem = MenuItem(m, "Paste", "V", self.paste) ! self.clearitem = MenuItem(m, "Clear", "", self.clear) ! # Groups of items enabled together: ! self.windowgroup = [self.closeitem, self.saveitem, self.saveasitem, self.editmenu] ! self.focusgroup = [self.cutitem, self.copyitem, self.clearitem] ! self.windowgroup_on = -1 ! self.focusgroup_on = -1 ! self.pastegroup_on = -1 ! self.undo_label = "never" ! def updatemenubar(self): ! changed = 0 ! on = (self.active <> None) ! if on <> self.windowgroup_on: ! for m in self.windowgroup: ! m.enable(on) ! self.windowgroup_on = on ! changed = 1 ! if on: ! # only if we have an edit menu ! on = self.active.have_selection() ! if on <> self.focusgroup_on: ! for m in self.focusgroup: ! m.enable(on) ! self.focusgroup_on = on ! changed = 1 ! on = self.active.can_paste() ! if on <> self.pastegroup_on: ! self.pasteitem.enable(on) ! self.pastegroup_on = on ! changed = 1 ! on = self.active.can_undo() ! if on <> self.undo_label: ! if on: ! self.undoitem.enable(1) ! self.undoitem.settext(on) ! self.undo_label = on ! else: ! self.undoitem.settext("Nothing to undo") ! self.undoitem.enable(0) ! changed = 1 ! if changed: ! DrawMenuBar() ! # ! # Apple menu ! # ! ! def do_about(self, id, item, window, event): ! EasyDialogs.Message("A simple single-font text editor based on WASTE") ! ! # ! # File menu ! # ! ! def open(self, *args): ! self._open(0) ! ! def openfile(self, *args): ! self._open(1) ! ! def _open(self, askfile): ! if askfile: ! path = EasyDialogs.AskFileForOpen(typeList=('TEXT',)) ! if not path: ! return ! name = os.path.split(path)[-1] ! try: ! fp = open(path, 'rb') # NOTE binary, we need cr as end-of-line ! data = fp.read() ! fp.close() ! except IOError, arg: ! EasyDialogs.Message("IOERROR: %r" % (arg,)) ! return ! else: ! path = None ! name = "Untitled %d"%self.num ! data = '' ! w = WasteWindow(self) ! w.open(path, name, data) ! self.num = self.num + 1 ! ! def closewin(self, *args): ! if self.active: ! self.active.close() ! else: ! EasyDialogs.Message("No active window?") ! ! def save(self, *args): ! if self.active: ! self.active.menu_save() ! else: ! EasyDialogs.Message("No active window?") ! ! def saveas(self, *args): ! if self.active: ! self.active.menu_save_as() ! else: ! EasyDialogs.Message("No active window?") ! ! ! def quit(self, *args): ! for w in self._windows.values(): ! w.close() ! if self._windows: ! return ! self._quit() ! ! # ! # Edit menu ! # ! ! def undo(self, *args): ! if self.active: ! self.active.menu_undo() ! else: ! EasyDialogs.Message("No active window?") ! ! def cut(self, *args): ! if self.active: ! self.active.menu_cut() ! else: ! EasyDialogs.Message("No active window?") ! ! def copy(self, *args): ! if self.active: ! self.active.menu_copy() ! else: ! EasyDialogs.Message("No active window?") ! ! def paste(self, *args): ! if self.active: ! self.active.menu_paste() ! else: ! EasyDialogs.Message("No active window?") ! ! def clear(self, *args): ! if self.active: ! self.active.menu_clear() ! else: ! EasyDialogs.Message("No active window?") ! ! # ! # Other stuff ! # ! ! def idle(self, event): ! if self.active: ! self.active.do_idle(event) ! else: ! Qd.SetCursor(Qd.GetQDGlobalsArrow()) def main(): ! App = Wed() ! App.mainloop() ! if __name__ == '__main__': ! main() From tim_one at users.sourceforge.net Sun Jul 18 07:58:40 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 07:59:10 2004 Subject: [Python-checkins] python/dist/src/Mac/Modules/carbonevt CarbonEvtscan.py, 1.10, 1.11 CarbonEvtsupport.py, 1.15, 1.16 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/carbonevt In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29056/Modules/carbonevt Modified Files: CarbonEvtscan.py CarbonEvtsupport.py Log Message: Whitespace normalization, via reindent.py. Index: CarbonEvtscan.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/carbonevt/CarbonEvtscan.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** CarbonEvtscan.py 20 Nov 2003 13:30:55 -0000 1.10 --- CarbonEvtscan.py 18 Jul 2004 05:58:08 -0000 1.11 *************** *** 13,117 **** def main(): ! print "---Scanning CarbonEvents.h---" ! input = ["CarbonEvents.h"] ! output = "CarbonEventsgen.py" ! defsoutput = TOOLBOXDIR + "CarbonEvents.py" ! scanner = CarbonEvents_Scanner(input, output, defsoutput) ! scanner.scan() ! scanner.close() ! print "=== Testing definitions output code ===" ! execfile(defsoutput, {}, {}) ! print "--done scanning, importing--" ! import CarbonEvtsupport ! print "done" ! RefObjectTypes = ["EventRef", ! "EventQueueRef", ! "EventLoopRef", ! "EventLoopTimerRef", ! "EventHandlerRef", ! "EventHandlerCallRef", ! "EventTargetRef", ! "EventHotKeyRef", ! ] class CarbonEvents_Scanner(Scanner_OSX): ! def destination(self, type, name, arglist): ! classname = "CarbonEventsFunction" ! listname = "functions" ! if arglist: ! t, n, m = arglist[0] ! if t in RefObjectTypes and m == "InMode": ! if t == "EventHandlerRef": ! classname = "EventHandlerRefMethod" ! else: ! classname = "CarbonEventsMethod" ! listname = t + "methods" ! #else: ! # print "not method" ! return classname, listname ! def writeinitialdefs(self): ! self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n") ! self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n") ! self.defsfile.write("false = 0\n") ! self.defsfile.write("true = 1\n") ! self.defsfile.write("keyAEEventClass = FOUR_CHAR_CODE('evcl')\n") ! self.defsfile.write("keyAEEventID = FOUR_CHAR_CODE('evti')\n") ! ! def makeblacklistnames(self): ! return [ ! "sHandler", ! "MacCreateEvent", ! # "TrackMouseLocationWithOptions", ! # "TrackMouseLocation", ! # "TrackMouseRegion", ! "RegisterToolboxObjectClass", ! "UnregisterToolboxObjectClass", ! "ProcessHICommand", ! "GetCFRunLoopFromEventLoop", ! ! "InvokeEventHandlerUPP", ! "InvokeEventComparatorUPP", ! "InvokeEventLoopTimerUPP", ! "NewEventComparatorUPP", ! "NewEventLoopTimerUPP", ! "NewEventHandlerUPP", ! "DisposeEventComparatorUPP", ! "DisposeEventLoopTimerUPP", ! "DisposeEventHandlerUPP", ! # Wrote by hand ! "InstallEventHandler", ! "RemoveEventHandler", ! ! # Write by hand? ! "GetEventParameter", ! "FlushSpecificEventsFromQueue", ! "FindSpecificEventInQueue", ! "InstallEventLoopTimer", ! # Don't do these because they require a CFRelease ! "CreateTypeStringWithOSType", ! "CopyEvent", ! ] ! # def makeblacklisttypes(self): ! # return ["EventComparatorUPP", ! # "EventLoopTimerUPP", ! # #"EventHandlerUPP", ! # "EventComparatorProcPtr", ! # "EventLoopTimerProcPtr", ! # "EventHandlerProcPtr", ! # ] ! def makerepairinstructions(self): ! return [ ! ([("UInt32", 'inSize', "InMode"), ("void_ptr", 'inDataPtr', "InMode")], ! [("MyInBuffer", 'inDataPtr', "InMode")]), ! ([("Boolean", 'ioWasInRgn', "OutMode")], ! [("Boolean", 'ioWasInRgn', "InOutMode")]), ! ] if __name__ == "__main__": ! main() --- 13,117 ---- def main(): ! print "---Scanning CarbonEvents.h---" ! input = ["CarbonEvents.h"] ! output = "CarbonEventsgen.py" ! defsoutput = TOOLBOXDIR + "CarbonEvents.py" ! scanner = CarbonEvents_Scanner(input, output, defsoutput) ! scanner.scan() ! scanner.close() ! print "=== Testing definitions output code ===" ! execfile(defsoutput, {}, {}) ! print "--done scanning, importing--" ! import CarbonEvtsupport ! print "done" ! RefObjectTypes = ["EventRef", ! "EventQueueRef", ! "EventLoopRef", ! "EventLoopTimerRef", ! "EventHandlerRef", ! "EventHandlerCallRef", ! "EventTargetRef", ! "EventHotKeyRef", ! ] class CarbonEvents_Scanner(Scanner_OSX): ! def destination(self, type, name, arglist): ! classname = "CarbonEventsFunction" ! listname = "functions" ! if arglist: ! t, n, m = arglist[0] ! if t in RefObjectTypes and m == "InMode": ! if t == "EventHandlerRef": ! classname = "EventHandlerRefMethod" ! else: ! classname = "CarbonEventsMethod" ! listname = t + "methods" ! #else: ! # print "not method" ! return classname, listname ! def writeinitialdefs(self): ! self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n") ! self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n") ! self.defsfile.write("false = 0\n") ! self.defsfile.write("true = 1\n") ! self.defsfile.write("keyAEEventClass = FOUR_CHAR_CODE('evcl')\n") ! self.defsfile.write("keyAEEventID = FOUR_CHAR_CODE('evti')\n") ! def makeblacklistnames(self): ! return [ ! "sHandler", ! "MacCreateEvent", ! # "TrackMouseLocationWithOptions", ! # "TrackMouseLocation", ! # "TrackMouseRegion", ! "RegisterToolboxObjectClass", ! "UnregisterToolboxObjectClass", ! "ProcessHICommand", ! "GetCFRunLoopFromEventLoop", ! "InvokeEventHandlerUPP", ! "InvokeEventComparatorUPP", ! "InvokeEventLoopTimerUPP", ! "NewEventComparatorUPP", ! "NewEventLoopTimerUPP", ! "NewEventHandlerUPP", ! "DisposeEventComparatorUPP", ! "DisposeEventLoopTimerUPP", ! "DisposeEventHandlerUPP", ! # Wrote by hand ! "InstallEventHandler", ! "RemoveEventHandler", ! # Write by hand? ! "GetEventParameter", ! "FlushSpecificEventsFromQueue", ! "FindSpecificEventInQueue", ! "InstallEventLoopTimer", ! ! # Don't do these because they require a CFRelease ! "CreateTypeStringWithOSType", ! "CopyEvent", ! ] ! ! # def makeblacklisttypes(self): ! # return ["EventComparatorUPP", ! # "EventLoopTimerUPP", ! # #"EventHandlerUPP", ! # "EventComparatorProcPtr", ! # "EventLoopTimerProcPtr", ! # "EventHandlerProcPtr", ! # ] ! ! def makerepairinstructions(self): ! return [ ! ([("UInt32", 'inSize', "InMode"), ("void_ptr", 'inDataPtr', "InMode")], ! [("MyInBuffer", 'inDataPtr', "InMode")]), ! ([("Boolean", 'ioWasInRgn', "OutMode")], ! [("Boolean", 'ioWasInRgn', "InOutMode")]), ! ] if __name__ == "__main__": ! main() Index: CarbonEvtsupport.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/carbonevt/CarbonEvtsupport.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** CarbonEvtsupport.py 20 Nov 2003 13:30:55 -0000 1.15 --- CarbonEvtsupport.py 18 Jul 2004 05:58:08 -0000 1.16 *************** *** 9,29 **** for typ in RefObjectTypes: ! execstr = "%(name)s = OpaqueByValueType('%(name)s')" % {"name": typ} ! exec execstr if 0: ! # these types will have no methods and will merely be opaque blobs ! # should write getattr and setattr for them? ! StructObjectTypes = ["EventTypeSpec", ! "HIPoint", ! "HICommand", ! "EventHotKeyID", ! ] ! for typ in StructObjectTypes: ! execstr = "%(name)s = OpaqueType('%(name)s')" % {"name": typ} ! exec execstr EventHotKeyID = OpaqueByValueType("EventHotKeyID", "EventHotKeyID") --- 9,29 ---- for typ in RefObjectTypes: ! execstr = "%(name)s = OpaqueByValueType('%(name)s')" % {"name": typ} ! exec execstr if 0: ! # these types will have no methods and will merely be opaque blobs ! # should write getattr and setattr for them? ! StructObjectTypes = ["EventTypeSpec", ! "HIPoint", ! "HICommand", ! "EventHotKeyID", ! ] ! for typ in StructObjectTypes: ! execstr = "%(name)s = OpaqueType('%(name)s')" % {"name": typ} ! exec execstr EventHotKeyID = OpaqueByValueType("EventHotKeyID", "EventHotKeyID") *************** *** 36,43 **** class MyVarInputBufferType(VarInputBufferType): ! def passInput(self, name): ! return "%s__len__, %s__in__" % (name, name) ! MyInBuffer = MyVarInputBufferType('char', 'long', 'l') # (buf, len) EventTime = double --- 36,43 ---- class MyVarInputBufferType(VarInputBufferType): ! def passInput(self, name): ! return "%s__len__, %s__in__" % (name, name) ! MyInBuffer = MyVarInputBufferType('char', 'long', 'l') # (buf, len) EventTime = double *************** *** 62,70 **** class EventHandlerRefMethod(OSErrMethodGenerator): ! def precheck(self): ! OutLbrace('if (_self->ob_itself == NULL)') ! Output('PyErr_SetString(CarbonEvents_Error, "Handler has been removed");') ! Output('return NULL;') ! OutRbrace() --- 62,70 ---- class EventHandlerRefMethod(OSErrMethodGenerator): ! def precheck(self): ! OutLbrace('if (_self->ob_itself == NULL)') ! Output('PyErr_SetString(CarbonEvents_Error, "Handler has been removed");') ! Output('return NULL;') ! OutRbrace() *************** *** 90,94 **** EventTypeSpec_New(EventTypeSpec *in) { ! return Py_BuildValue("ll", in->eventClass, in->eventKind); } --- 90,94 ---- EventTypeSpec_New(EventTypeSpec *in) { ! return Py_BuildValue("ll", in->eventClass, in->eventKind); } *************** *** 96,104 **** EventTypeSpec_Convert(PyObject *v, EventTypeSpec *out) { ! if (PyArg_Parse(v, "(O&l)", ! PyMac_GetOSType, &(out->eventClass), ! &(out->eventKind))) ! return 1; ! return NULL; } --- 96,104 ---- EventTypeSpec_Convert(PyObject *v, EventTypeSpec *out) { ! if (PyArg_Parse(v, "(O&l)", ! PyMac_GetOSType, &(out->eventClass), ! &(out->eventKind))) ! return 1; ! return NULL; } *************** *** 111,115 **** HIPoint_New(HIPoint *in) { ! return Py_BuildValue("ff", in->x, in->y); } --- 111,115 ---- HIPoint_New(HIPoint *in) { ! return Py_BuildValue("ff", in->x, in->y); } *************** *** 117,123 **** HIPoint_Convert(PyObject *v, HIPoint *out) { ! if (PyArg_ParseTuple(v, "ff", &(out->x), &(out->y))) ! return 1; ! return NULL; } #endif --- 117,123 ---- HIPoint_Convert(PyObject *v, HIPoint *out) { ! if (PyArg_ParseTuple(v, "ff", &(out->x), &(out->y))) ! return 1; ! return NULL; } #endif *************** *** 130,134 **** EventHotKeyID_New(EventHotKeyID *in) { ! return Py_BuildValue("ll", in->signature, in->id); } --- 130,134 ---- EventHotKeyID_New(EventHotKeyID *in) { ! return Py_BuildValue("ll", in->signature, in->id); } *************** *** 136,142 **** EventHotKeyID_Convert(PyObject *v, EventHotKeyID *out) { ! if (PyArg_ParseTuple(v, "ll", &out->signature, &out->id)) ! return 1; ! return NULL; } --- 136,142 ---- EventHotKeyID_Convert(PyObject *v, EventHotKeyID *out) { ! if (PyArg_ParseTuple(v, "ll", &out->signature, &out->id)) ! return 1; ! return NULL; } *************** *** 149,173 **** static pascal OSStatus myEventHandler(EventHandlerCallRef handlerRef, EventRef event, void *outPyObject) { ! PyObject *retValue; ! int status; ! retValue = PyObject_CallFunction((PyObject *)outPyObject, "O&O&", ! EventHandlerCallRef_New, handlerRef, ! EventRef_New, event); ! if (retValue == NULL) { ! PySys_WriteStderr("Error in event handler callback:\n"); ! PyErr_Print(); /* this also clears the error */ ! status = noErr; /* complain? how? */ ! } else { ! if (retValue == Py_None) ! status = noErr; ! else if (PyInt_Check(retValue)) { ! status = PyInt_AsLong(retValue); ! } else ! status = noErr; /* wrong object type, complain? */ ! Py_DECREF(retValue); ! } ! return status; } --- 149,173 ---- static pascal OSStatus myEventHandler(EventHandlerCallRef handlerRef, EventRef event, void *outPyObject) { ! PyObject *retValue; ! int status; ! retValue = PyObject_CallFunction((PyObject *)outPyObject, "O&O&", ! EventHandlerCallRef_New, handlerRef, ! EventRef_New, event); ! if (retValue == NULL) { ! PySys_WriteStderr("Error in event handler callback:\n"); ! PyErr_Print(); /* this also clears the error */ ! status = noErr; /* complain? how? */ ! } else { ! if (retValue == Py_None) ! status = noErr; ! else if (PyInt_Check(retValue)) { ! status = PyInt_AsLong(retValue); ! } else ! status = noErr; /* wrong object type, complain? */ ! Py_DECREF(retValue); ! } ! return status; } *************** *** 185,217 **** class EventHandlerRefObjectDefinition(PEP253Mixin, GlobalObjectDefinition): ! def outputStructMembers(self): ! Output("%s ob_itself;", self.itselftype) ! Output("PyObject *ob_callback;") ! def outputInitStructMembers(self): ! Output("it->ob_itself = %sitself;", self.argref) ! Output("it->ob_callback = NULL;") ! def outputFreeIt(self, name): ! OutLbrace("if (self->ob_itself != NULL)") ! Output("RemoveEventHandler(self->ob_itself);") ! Output("Py_DECREF(self->ob_callback);") ! OutRbrace() ! class MyGlobalObjectDefinition(PEP253Mixin, GlobalObjectDefinition): ! pass for typ in RefObjectTypes: ! if typ == 'EventHandlerRef': ! EventHandlerRefobject = EventHandlerRefObjectDefinition('EventHandlerRef') ! else: ! execstr = typ + 'object = MyGlobalObjectDefinition(typ)' ! exec execstr ! module.addobject(eval(typ + 'object')) functions = [] for typ in RefObjectTypes: ## go thru all ObjectTypes as defined in CarbonEventsscan.py ! # initialize the lists for carbongen to fill ! execstr = typ + 'methods = []' ! exec execstr execfile('CarbonEventsgen.py') --- 185,217 ---- class EventHandlerRefObjectDefinition(PEP253Mixin, GlobalObjectDefinition): ! def outputStructMembers(self): ! Output("%s ob_itself;", self.itselftype) ! Output("PyObject *ob_callback;") ! def outputInitStructMembers(self): ! Output("it->ob_itself = %sitself;", self.argref) ! Output("it->ob_callback = NULL;") ! def outputFreeIt(self, name): ! OutLbrace("if (self->ob_itself != NULL)") ! Output("RemoveEventHandler(self->ob_itself);") ! Output("Py_DECREF(self->ob_callback);") ! OutRbrace() ! class MyGlobalObjectDefinition(PEP253Mixin, GlobalObjectDefinition): ! pass for typ in RefObjectTypes: ! if typ == 'EventHandlerRef': ! EventHandlerRefobject = EventHandlerRefObjectDefinition('EventHandlerRef') ! else: ! execstr = typ + 'object = MyGlobalObjectDefinition(typ)' ! exec execstr ! module.addobject(eval(typ + 'object')) functions = [] for typ in RefObjectTypes: ## go thru all ObjectTypes as defined in CarbonEventsscan.py ! # initialize the lists for carbongen to fill ! execstr = typ + 'methods = []' ! exec execstr execfile('CarbonEventsgen.py') *************** *** 219,228 **** ! for f in functions: module.add(f) # add all the functions carboneventsgen put in the list ! for typ in RefObjectTypes: ## go thru all ObjectTypes as defined in CarbonEventsscan.py ! methods = eval(typ + 'methods') ## get a reference to the method list from the main namespace ! obj = eval(typ + 'object') ## get a reference to the object ! for m in methods: obj.add(m) ## add each method in the list to the object --- 219,228 ---- ! for f in functions: module.add(f) # add all the functions carboneventsgen put in the list ! for typ in RefObjectTypes: ## go thru all ObjectTypes as defined in CarbonEventsscan.py ! methods = eval(typ + 'methods') ## get a reference to the method list from the main namespace ! obj = eval(typ + 'object') ## get a reference to the object ! for m in methods: obj.add(m) ## add each method in the list to the object *************** *** 230,238 **** OSStatus _err; if (_self->ob_itself == NULL) { ! PyErr_SetString(CarbonEvents_Error, "Handler has been removed"); ! return NULL; } if (!PyArg_ParseTuple(_args, "")) ! return NULL; _err = RemoveEventHandler(_self->ob_itself); if (_err != noErr) return PyMac_Error(_err); --- 230,238 ---- OSStatus _err; if (_self->ob_itself == NULL) { ! PyErr_SetString(CarbonEvents_Error, "Handler has been removed"); ! return NULL; } if (!PyArg_ParseTuple(_args, "")) ! return NULL; _err = RemoveEventHandler(_self->ob_itself); if (_err != noErr) return PyMac_Error(_err); *************** *** 256,260 **** if (!PyArg_ParseTuple(_args, "O&O", EventTypeSpec_Convert, &inSpec, &callback)) ! return NULL; _err = InstallEventHandler(_self->ob_itself, myEventHandlerUPP, 1, &inSpec, (void *)callback, &outRef); --- 256,260 ---- if (!PyArg_ParseTuple(_args, "O&O", EventTypeSpec_Convert, &inSpec, &callback)) ! return NULL; _err = InstallEventHandler(_self->ob_itself, myEventHandlerUPP, 1, &inSpec, (void *)callback, &outRef); *************** *** 263,268 **** _res = EventHandlerRef_New(outRef); if (_res != NULL) { ! ((EventHandlerRefObject*)_res)->ob_callback = callback; ! Py_INCREF(callback); } return _res;""" --- 263,268 ---- _res = EventHandlerRef_New(outRef); if (_res != NULL) { ! ((EventHandlerRefObject*)_res)->ob_callback = callback; ! Py_INCREF(callback); } return _res;""" From tim_one at users.sourceforge.net Sun Jul 18 07:58:41 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 07:59:12 2004 Subject: [Python-checkins] python/dist/src/Mac/Modules/cf cfscan.py, 1.12, 1.13 cfsupport.py, 1.27, 1.28 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/cf In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29056/Modules/cf Modified Files: cfscan.py cfsupport.py Log Message: Whitespace normalization, via reindent.py. Index: cfscan.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/cf/cfscan.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** cfscan.py 15 Aug 2002 21:48:13 -0000 1.12 --- cfscan.py 18 Jul 2004 05:58:08 -0000 1.13 *************** *** 9,142 **** LONG = "CoreFoundation" SHORT = "cf" ! OBJECTS = ("CFTypeRef", ! "CFArrayRef", "CFMutableArrayRef", ! "CFDataRef", "CFMutableDataRef", ! "CFDictionaryRef", "CFMutableDictionaryRef", ! "CFStringRef", "CFMutableStringRef", ! "CFURLRef", ! ## "CFPropertyListRef", ! ) # ADD object typenames here def main(): ! input = [ ! "CFBase.h", ! "CFArray.h", ! ## "CFBag.h", ! ## "CFBundle.h", ! ## "CFCharacterSet.h", ! "CFData.h", ! ## "CFDate.h", ! "CFDictionary.h", ! ## "CFNumber.h", ! ## "CFPlugIn.h", ! "CFPreferences.h", ! "CFPropertyList.h", ! ## "CFSet.h", ! "CFString.h", ! ## "CFStringEncodingExt.h", ! ## "CFTimeZone.h", ! "CFURL.h", ! ] ! output = SHORT + "gen.py" ! defsoutput = TOOLBOXDIR + LONG + ".py" ! scanner = MyScanner(input, output, defsoutput) ! scanner.scan() ! scanner.gentypetest(SHORT+"typetest.py") ! scanner.close() ! print "=== Testing definitions output code ===" ! execfile(defsoutput, {}, {}) ! print "=== Done scanning and generating, now importing the generated code... ===" ! exec "import " + SHORT + "support" ! print "=== Done. It's up to you to compile it now! ===" class MyScanner(Scanner_OSX): ! def destination(self, type, name, arglist): ! classname = "Function" ! listname = "functions" ! if arglist and name[:13] != 'CFPreferences': ! t, n, m = arglist[0] ! if t in OBJECTS and m == "InMode": ! classname = "Method" ! listname = t + "_methods" ! # Special case for the silly first AllocatorRef argument ! if t == 'CFAllocatorRef' and m == 'InMode' and len(arglist) > 1: ! t, n, m = arglist[1] ! if t in OBJECTS and m == "InMode": ! classname = "MethodSkipArg1" ! listname = t + "_methods" ! return classname, listname ! def writeinitialdefs(self): ! self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n") ! def makeblacklistnames(self): ! return [ ! # Memory allocator functions ! "CFAllocatorGetDefault", ! "CFAllocatorSetDefault", ! "CFAllocatorAllocate", ! "CFAllocatorReallocate", ! "CFAllocatorDeallocate", ! "CFGetAllocator", ! # Array functions we skip for now. ! "CFArrayGetValueAtIndex", ! # Data pointer functions. Skip for now. ! "CFDataGetBytePtr", ! "CFDataGetMutableBytePtr", ! "CFDataGetBytes", # XXXX Should support this one ! # String functions ! "CFStringGetPascalString", # Use the C-string methods. ! "CFStringGetPascalStringPtr", # TBD automatically ! "CFStringGetCStringPtr", ! "CFStringGetCharactersPtr", ! "CFStringGetCString", ! "CFStringGetCharacters", ! "CFURLCreateStringWithFileSystemPath", # Gone in later releases ! "CFStringCreateMutableWithExternalCharactersNoCopy", # Not a clue... ! "CFStringSetExternalCharactersNoCopy", ! "CFStringGetCharacterAtIndex", # No format for single unichars yet. ! "kCFStringEncodingInvalidId", # incompatible constant declaration ! "CFPropertyListCreateFromXMLData", # Manually generated ! ] ! def makegreylist(self): ! return [] ! def makeblacklisttypes(self): ! return [ ! "CFComparatorFunction", # Callback function pointer ! "CFAllocatorContext", # Not interested in providing our own allocator ! "void_ptr_ptr", # Tricky. This is the initializer for arrays... ! "void_ptr", # Ditto for various array lookup methods ! "CFArrayApplierFunction", # Callback function pointer ! "CFDictionaryApplierFunction", # Callback function pointer ! "va_list", # For printf-to-a-cfstring. Use Python. ! "const_CFStringEncoding_ptr", # To be done, I guess ! ] ! def makerepairinstructions(self): ! return [ ! # Buffers in CF seem to be passed as UInt8 * normally. ! ([("UInt8_ptr", "*", "InMode"), ("CFIndex", "*", "InMode")], ! [("UcharInBuffer", "*", "*")]), ! ! ([("UniChar_ptr", "*", "InMode"), ("CFIndex", "*", "InMode")], ! [("UnicodeInBuffer", "*", "*")]), - # Some functions return a const char *. Don't worry, we won't modify it. - ([("const_char_ptr", "*", "ReturnMode")], - [("return_stringptr", "*", "*")]), - - # base URLs are optional (pass None for NULL) - ([("CFURLRef", "baseURL", "InMode")], - [("OptionalCFURLRef", "*", "*")]), - - # We handle CFPropertyListRef objects as plain CFTypeRef - ([("CFPropertyListRef", "*", "*")], - [("CFTypeRef", "*", "*")]), - ] - if __name__ == "__main__": ! main() --- 9,142 ---- LONG = "CoreFoundation" SHORT = "cf" ! OBJECTS = ("CFTypeRef", ! "CFArrayRef", "CFMutableArrayRef", ! "CFDataRef", "CFMutableDataRef", ! "CFDictionaryRef", "CFMutableDictionaryRef", ! "CFStringRef", "CFMutableStringRef", ! "CFURLRef", ! ## "CFPropertyListRef", ! ) # ADD object typenames here def main(): ! input = [ ! "CFBase.h", ! "CFArray.h", ! ## "CFBag.h", ! ## "CFBundle.h", ! ## "CFCharacterSet.h", ! "CFData.h", ! ## "CFDate.h", ! "CFDictionary.h", ! ## "CFNumber.h", ! ## "CFPlugIn.h", ! "CFPreferences.h", ! "CFPropertyList.h", ! ## "CFSet.h", ! "CFString.h", ! ## "CFStringEncodingExt.h", ! ## "CFTimeZone.h", ! "CFURL.h", ! ] ! output = SHORT + "gen.py" ! defsoutput = TOOLBOXDIR + LONG + ".py" ! scanner = MyScanner(input, output, defsoutput) ! scanner.scan() ! scanner.gentypetest(SHORT+"typetest.py") ! scanner.close() ! print "=== Testing definitions output code ===" ! execfile(defsoutput, {}, {}) ! print "=== Done scanning and generating, now importing the generated code... ===" ! exec "import " + SHORT + "support" ! print "=== Done. It's up to you to compile it now! ===" class MyScanner(Scanner_OSX): ! def destination(self, type, name, arglist): ! classname = "Function" ! listname = "functions" ! if arglist and name[:13] != 'CFPreferences': ! t, n, m = arglist[0] ! if t in OBJECTS and m == "InMode": ! classname = "Method" ! listname = t + "_methods" ! # Special case for the silly first AllocatorRef argument ! if t == 'CFAllocatorRef' and m == 'InMode' and len(arglist) > 1: ! t, n, m = arglist[1] ! if t in OBJECTS and m == "InMode": ! classname = "MethodSkipArg1" ! listname = t + "_methods" ! return classname, listname ! def writeinitialdefs(self): ! self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n") ! def makeblacklistnames(self): ! return [ ! # Memory allocator functions ! "CFAllocatorGetDefault", ! "CFAllocatorSetDefault", ! "CFAllocatorAllocate", ! "CFAllocatorReallocate", ! "CFAllocatorDeallocate", ! "CFGetAllocator", ! # Array functions we skip for now. ! "CFArrayGetValueAtIndex", ! # Data pointer functions. Skip for now. ! "CFDataGetBytePtr", ! "CFDataGetMutableBytePtr", ! "CFDataGetBytes", # XXXX Should support this one ! # String functions ! "CFStringGetPascalString", # Use the C-string methods. ! "CFStringGetPascalStringPtr", # TBD automatically ! "CFStringGetCStringPtr", ! "CFStringGetCharactersPtr", ! "CFStringGetCString", ! "CFStringGetCharacters", ! "CFURLCreateStringWithFileSystemPath", # Gone in later releases ! "CFStringCreateMutableWithExternalCharactersNoCopy", # Not a clue... ! "CFStringSetExternalCharactersNoCopy", ! "CFStringGetCharacterAtIndex", # No format for single unichars yet. ! "kCFStringEncodingInvalidId", # incompatible constant declaration ! "CFPropertyListCreateFromXMLData", # Manually generated ! ] ! def makegreylist(self): ! return [] ! def makeblacklisttypes(self): ! return [ ! "CFComparatorFunction", # Callback function pointer ! "CFAllocatorContext", # Not interested in providing our own allocator ! "void_ptr_ptr", # Tricky. This is the initializer for arrays... ! "void_ptr", # Ditto for various array lookup methods ! "CFArrayApplierFunction", # Callback function pointer ! "CFDictionaryApplierFunction", # Callback function pointer ! "va_list", # For printf-to-a-cfstring. Use Python. ! "const_CFStringEncoding_ptr", # To be done, I guess ! ] ! def makerepairinstructions(self): ! return [ ! # Buffers in CF seem to be passed as UInt8 * normally. ! ([("UInt8_ptr", "*", "InMode"), ("CFIndex", "*", "InMode")], ! [("UcharInBuffer", "*", "*")]), ! ! ([("UniChar_ptr", "*", "InMode"), ("CFIndex", "*", "InMode")], ! [("UnicodeInBuffer", "*", "*")]), ! ! # Some functions return a const char *. Don't worry, we won't modify it. ! ([("const_char_ptr", "*", "ReturnMode")], ! [("return_stringptr", "*", "*")]), ! ! # base URLs are optional (pass None for NULL) ! ([("CFURLRef", "baseURL", "InMode")], ! [("OptionalCFURLRef", "*", "*")]), ! ! # We handle CFPropertyListRef objects as plain CFTypeRef ! ([("CFPropertyListRef", "*", "*")], ! [("CFTypeRef", "*", "*")]), ! ] if __name__ == "__main__": ! main() Index: cfsupport.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/cf/cfsupport.py,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** cfsupport.py 15 Jul 2004 14:25:48 -0000 1.27 --- cfsupport.py 18 Jul 2004 05:58:08 -0000 1.28 *************** *** 9,18 **** # Declarations that change for each manager ! MODNAME = '_CF' # The name of the module # The following is *usually* unchanged but may still require tuning ! MODPREFIX = 'CF' # The prefix for module-wide routines INPUTFILE = string.lower(MODPREFIX) + 'gen.py' # The file generated by the scanner ! OUTPUTFILE = MODNAME + "module.c" # The file generated by this program from macsupport import * --- 9,18 ---- # Declarations that change for each manager ! MODNAME = '_CF' # The name of the module # The following is *usually* unchanged but may still require tuning ! MODPREFIX = 'CF' # The prefix for module-wide routines INPUTFILE = string.lower(MODPREFIX) + 'gen.py' # The file generated by the scanner ! OUTPUTFILE = MODNAME + "module.c" # The file generated by this program from macsupport import * *************** *** 21,41 **** # which we skip anyway, and the object as the second arg. class MethodSkipArg1(MethodGenerator): ! """Similar to MethodGenerator, but has self as last argument""" ! def parseArgumentList(self, args): ! if len(args) < 2: ! raise ValueError, "MethodSkipArg1 expects at least 2 args" ! a0, a1, args = args[0], args[1], args[2:] ! t0, n0, m0 = a0 ! if t0 != "CFAllocatorRef" and m0 != InMode: ! raise ValueError, "MethodSkipArg1 should have dummy AllocatorRef first arg" ! t1, n1, m1 = a1 ! if m1 != InMode: ! raise ValueError, "method's 'self' must be 'InMode'" ! dummy = Variable(t0, n0, m0) ! self.argumentList.append(dummy) ! self.itself = Variable(t1, "_self->ob_itself", SelfMode) ! self.argumentList.append(self.itself) ! FunctionGenerator.parseArgumentList(self, args) --- 21,41 ---- # which we skip anyway, and the object as the second arg. class MethodSkipArg1(MethodGenerator): ! """Similar to MethodGenerator, but has self as last argument""" ! def parseArgumentList(self, args): ! if len(args) < 2: ! raise ValueError, "MethodSkipArg1 expects at least 2 args" ! a0, a1, args = args[0], args[1], args[2:] ! t0, n0, m0 = a0 ! if t0 != "CFAllocatorRef" and m0 != InMode: ! raise ValueError, "MethodSkipArg1 should have dummy AllocatorRef first arg" ! t1, n1, m1 = a1 ! if m1 != InMode: ! raise ValueError, "method's 'self' must be 'InMode'" ! dummy = Variable(t0, n0, m0) ! self.argumentList.append(dummy) ! self.itself = Variable(t1, "_self->ob_itself", SelfMode) ! self.argumentList.append(self.itself) ! FunctionGenerator.parseArgumentList(self, args) *************** *** 112,116 **** { ! return Py_BuildValue("ll", (long)itself->location, (long)itself->length); } --- 112,116 ---- { ! return Py_BuildValue("ll", (long)itself->location, (long)itself->length); } *************** *** 118,128 **** CFRange_Convert(PyObject *v, CFRange *p_itself) { ! long location, length; ! ! if( !PyArg_ParseTuple(v, "ll", &location, &length) ) ! return 0; ! p_itself->location = (CFIndex)location; ! p_itself->length = (CFIndex)length; ! return 1; } --- 118,128 ---- CFRange_Convert(PyObject *v, CFRange *p_itself) { ! long location, length; ! ! if( !PyArg_ParseTuple(v, "ll", &location, &length) ) ! return 0; ! p_itself->location = (CFIndex)location; ! p_itself->length = (CFIndex)length; ! return 1; } *************** *** 132,137 **** { if ( v == Py_None ) { ! p_itself = NULL; ! return 1; } return CFURLRefObj_Convert(v, p_itself); --- 132,137 ---- { if ( v == Py_None ) { ! p_itself = NULL; ! return 1; } return CFURLRefObj_Convert(v, p_itself); *************** *** 144,183 **** PyObject *CFObj_New(CFTypeRef itself) { ! if (itself == NULL) ! { ! PyErr_SetString(PyExc_RuntimeError, "cannot wrap NULL"); ! return NULL; ! } ! if (CFGetTypeID(itself) == CFArrayGetTypeID()) return CFArrayRefObj_New((CFArrayRef)itself); ! if (CFGetTypeID(itself) == CFDictionaryGetTypeID()) return CFDictionaryRefObj_New((CFDictionaryRef)itself); ! if (CFGetTypeID(itself) == CFDataGetTypeID()) return CFDataRefObj_New((CFDataRef)itself); ! if (CFGetTypeID(itself) == CFStringGetTypeID()) return CFStringRefObj_New((CFStringRef)itself); ! if (CFGetTypeID(itself) == CFURLGetTypeID()) return CFURLRefObj_New((CFURLRef)itself); ! /* XXXX Or should we use PyCF_CF2Python here?? */ ! return CFTypeRefObj_New(itself); } int CFObj_Convert(PyObject *v, CFTypeRef *p_itself) { ! if (v == Py_None) { *p_itself = NULL; return 1; } ! /* Check for other CF objects here */ ! if (!CFTypeRefObj_Check(v) && ! !CFArrayRefObj_Check(v) && ! !CFMutableArrayRefObj_Check(v) && ! !CFDictionaryRefObj_Check(v) && ! !CFMutableDictionaryRefObj_Check(v) && ! !CFDataRefObj_Check(v) && ! !CFMutableDataRefObj_Check(v) && ! !CFStringRefObj_Check(v) && ! !CFMutableStringRefObj_Check(v) && ! !CFURLRefObj_Check(v) ) ! { ! /* XXXX Or should we use PyCF_Python2CF here?? */ ! PyErr_SetString(PyExc_TypeError, "CF object required"); ! return 0; ! } ! *p_itself = ((CFTypeRefObject *)v)->ob_itself; ! return 1; } """ --- 144,183 ---- PyObject *CFObj_New(CFTypeRef itself) { ! if (itself == NULL) ! { ! PyErr_SetString(PyExc_RuntimeError, "cannot wrap NULL"); ! return NULL; ! } ! if (CFGetTypeID(itself) == CFArrayGetTypeID()) return CFArrayRefObj_New((CFArrayRef)itself); ! if (CFGetTypeID(itself) == CFDictionaryGetTypeID()) return CFDictionaryRefObj_New((CFDictionaryRef)itself); ! if (CFGetTypeID(itself) == CFDataGetTypeID()) return CFDataRefObj_New((CFDataRef)itself); ! if (CFGetTypeID(itself) == CFStringGetTypeID()) return CFStringRefObj_New((CFStringRef)itself); ! if (CFGetTypeID(itself) == CFURLGetTypeID()) return CFURLRefObj_New((CFURLRef)itself); ! /* XXXX Or should we use PyCF_CF2Python here?? */ ! return CFTypeRefObj_New(itself); } int CFObj_Convert(PyObject *v, CFTypeRef *p_itself) { ! if (v == Py_None) { *p_itself = NULL; return 1; } ! /* Check for other CF objects here */ ! if (!CFTypeRefObj_Check(v) && ! !CFArrayRefObj_Check(v) && ! !CFMutableArrayRefObj_Check(v) && ! !CFDictionaryRefObj_Check(v) && ! !CFMutableDictionaryRefObj_Check(v) && ! !CFDataRefObj_Check(v) && ! !CFMutableDataRefObj_Check(v) && ! !CFStringRefObj_Check(v) && ! !CFMutableStringRefObj_Check(v) && ! !CFURLRefObj_Check(v) ) ! { ! /* XXXX Or should we use PyCF_Python2CF here?? */ ! PyErr_SetString(PyExc_TypeError, "CF object required"); ! return 0; ! } ! *p_itself = ((CFTypeRefObject *)v)->ob_itself; ! return 1; } """ *************** *** 226,230 **** char_ptr = stringptr ! return_stringptr = Type("char *", "s") # ONLY FOR RETURN VALUES!! CFAllocatorRef = FakeType("(CFAllocatorRef)NULL") --- 226,230 ---- char_ptr = stringptr ! return_stringptr = Type("char *", "s") # ONLY FOR RETURN VALUES!! CFAllocatorRef = FakeType("(CFAllocatorRef)NULL") *************** *** 252,482 **** class MyGlobalObjectDefinition(PEP253Mixin, GlobalObjectDefinition): ! def outputCheckNewArg(self): ! Output('if (itself == NULL)') ! OutLbrace() ! Output('PyErr_SetString(PyExc_RuntimeError, "cannot wrap NULL");') ! Output('return NULL;') ! OutRbrace() ! def outputStructMembers(self): ! GlobalObjectDefinition.outputStructMembers(self) ! Output("void (*ob_freeit)(CFTypeRef ptr);") ! def outputInitStructMembers(self): ! GlobalObjectDefinition.outputInitStructMembers(self) ! ## Output("it->ob_freeit = NULL;") ! Output("it->ob_freeit = CFRelease;") ! def outputCheckConvertArg(self): ! Out(""" ! if (v == Py_None) { *p_itself = NULL; return 1; } ! /* Check for other CF objects here */ ! """) ! def outputCleanupStructMembers(self): ! Output("if (self->ob_freeit && self->ob_itself)") ! OutLbrace() ! Output("self->ob_freeit((CFTypeRef)self->ob_itself);") ! Output("self->ob_itself = NULL;") ! OutRbrace() ! ! def outputCompare(self): ! Output() ! Output("static int %s_compare(%s *self, %s *other)", self.prefix, self.objecttype, self.objecttype) ! OutLbrace() ! Output("/* XXXX Or should we use CFEqual?? */") ! Output("if ( self->ob_itself > other->ob_itself ) return 1;") ! Output("if ( self->ob_itself < other->ob_itself ) return -1;") ! Output("return 0;") ! OutRbrace() ! ! def outputHash(self): ! Output() ! Output("static int %s_hash(%s *self)", self.prefix, self.objecttype) ! OutLbrace() ! Output("/* XXXX Or should we use CFHash?? */") ! Output("return (int)self->ob_itself;") ! OutRbrace() ! ! def outputRepr(self): ! Output() ! Output("static PyObject * %s_repr(%s *self)", self.prefix, self.objecttype) ! OutLbrace() ! Output("char buf[100];") ! Output("""sprintf(buf, "", (int)CFGetTypeID(self->ob_itself), (unsigned)self, (unsigned)self->ob_itself);""") ! Output("return PyString_FromString(buf);") ! OutRbrace() ! def output_tp_newBody(self): ! Output("PyObject *self;") ! Output ! Output("if ((self = type->tp_alloc(type, 0)) == NULL) return NULL;") ! Output("((%s *)self)->ob_itself = NULL;", self.objecttype) ! Output("((%s *)self)->ob_freeit = CFRelease;", self.objecttype) ! Output("return self;") ! ! def output_tp_initBody(self): ! Output("%s itself;", self.itselftype) ! Output("char *kw[] = {\"itself\", 0};") ! Output() ! Output("if (PyArg_ParseTupleAndKeywords(args, kwds, \"O&\", kw, %s_Convert, &itself))", ! self.prefix) ! OutLbrace() ! Output("((%s *)self)->ob_itself = itself;", self.objecttype) ! Output("return 0;") ! OutRbrace() ! if self.prefix != 'CFTypeRefObj': ! Output() ! Output("/* Any CFTypeRef descendent is allowed as initializer too */") ! Output("if (PyArg_ParseTupleAndKeywords(args, kwds, \"O&\", kw, CFTypeRefObj_Convert, &itself))") ! OutLbrace() ! Output("((%s *)self)->ob_itself = itself;", self.objecttype) ! Output("return 0;") ! OutRbrace() ! Output("return -1;") class CFTypeRefObjectDefinition(MyGlobalObjectDefinition): ! pass ! class CFArrayRefObjectDefinition(MyGlobalObjectDefinition): ! basetype = "CFTypeRef_Type" ! ! def outputRepr(self): ! Output() ! Output("static PyObject * %s_repr(%s *self)", self.prefix, self.objecttype) ! OutLbrace() ! Output("char buf[100];") ! Output("""sprintf(buf, "", (unsigned)self, (unsigned)self->ob_itself);""") ! Output("return PyString_FromString(buf);") ! OutRbrace() ! class CFMutableArrayRefObjectDefinition(MyGlobalObjectDefinition): ! basetype = "CFArrayRef_Type" ! ! def outputRepr(self): ! Output() ! Output("static PyObject * %s_repr(%s *self)", self.prefix, self.objecttype) ! OutLbrace() ! Output("char buf[100];") ! Output("""sprintf(buf, "", (unsigned)self, (unsigned)self->ob_itself);""") ! Output("return PyString_FromString(buf);") ! OutRbrace() ! class CFDictionaryRefObjectDefinition(MyGlobalObjectDefinition): ! basetype = "CFTypeRef_Type" ! ! def outputRepr(self): ! Output() ! Output("static PyObject * %s_repr(%s *self)", self.prefix, self.objecttype) ! OutLbrace() ! Output("char buf[100];") ! Output("""sprintf(buf, "", (unsigned)self, (unsigned)self->ob_itself);""") ! Output("return PyString_FromString(buf);") ! OutRbrace() ! class CFMutableDictionaryRefObjectDefinition(MyGlobalObjectDefinition): ! basetype = "CFDictionaryRef_Type" ! ! def outputRepr(self): ! Output() ! Output("static PyObject * %s_repr(%s *self)", self.prefix, self.objecttype) ! OutLbrace() ! Output("char buf[100];") ! Output("""sprintf(buf, "", (unsigned)self, (unsigned)self->ob_itself);""") ! Output("return PyString_FromString(buf);") ! OutRbrace() ! class CFDataRefObjectDefinition(MyGlobalObjectDefinition): ! basetype = "CFTypeRef_Type" ! ! def outputCheckConvertArg(self): ! Out(""" ! if (v == Py_None) { *p_itself = NULL; return 1; } ! if (PyString_Check(v)) { ! char *cStr; ! int cLen; ! if( PyString_AsStringAndSize(v, &cStr, &cLen) < 0 ) return 0; ! *p_itself = CFDataCreate((CFAllocatorRef)NULL, (unsigned char *)cStr, cLen); ! return 1; ! } ! """) - def outputRepr(self): - Output() - Output("static PyObject * %s_repr(%s *self)", self.prefix, self.objecttype) - OutLbrace() - Output("char buf[100];") - Output("""sprintf(buf, "", (unsigned)self, (unsigned)self->ob_itself);""") - Output("return PyString_FromString(buf);") - OutRbrace() - class CFMutableDataRefObjectDefinition(MyGlobalObjectDefinition): ! basetype = "CFDataRef_Type" ! ! def outputRepr(self): ! Output() ! Output("static PyObject * %s_repr(%s *self)", self.prefix, self.objecttype) ! OutLbrace() ! Output("char buf[100];") ! Output("""sprintf(buf, "", (unsigned)self, (unsigned)self->ob_itself);""") ! Output("return PyString_FromString(buf);") ! OutRbrace() class CFStringRefObjectDefinition(MyGlobalObjectDefinition): ! basetype = "CFTypeRef_Type" ! ! def outputCheckConvertArg(self): ! Out(""" ! if (v == Py_None) { *p_itself = NULL; return 1; } ! if (PyString_Check(v)) { ! char *cStr; ! if (!PyArg_Parse(v, "es", "ascii", &cStr)) ! return NULL; ! *p_itself = CFStringCreateWithCString((CFAllocatorRef)NULL, cStr, kCFStringEncodingASCII); ! return 1; ! } ! if (PyUnicode_Check(v)) { ! /* We use the CF types here, if Python was configured differently that will give an error */ ! CFIndex size = PyUnicode_GetSize(v); ! UniChar *unichars = PyUnicode_AsUnicode(v); ! if (!unichars) return 0; ! *p_itself = CFStringCreateWithCharacters((CFAllocatorRef)NULL, unichars, size); ! return 1; ! } ! ! """) ! def outputRepr(self): ! Output() ! Output("static PyObject * %s_repr(%s *self)", self.prefix, self.objecttype) ! OutLbrace() ! Output("char buf[100];") ! Output("""sprintf(buf, "", (unsigned)self, (unsigned)self->ob_itself);""") ! Output("return PyString_FromString(buf);") ! OutRbrace() class CFMutableStringRefObjectDefinition(CFStringRefObjectDefinition): ! basetype = "CFStringRef_Type" ! ! def outputCheckConvertArg(self): ! # Mutable, don't allow Python strings ! return MyGlobalObjectDefinition.outputCheckConvertArg(self) ! ! def outputRepr(self): ! Output() ! Output("static PyObject * %s_repr(%s *self)", self.prefix, self.objecttype) ! OutLbrace() ! Output("char buf[100];") ! Output("""sprintf(buf, "", (unsigned)self, (unsigned)self->ob_itself);""") ! Output("return PyString_FromString(buf);") ! OutRbrace() class CFURLRefObjectDefinition(MyGlobalObjectDefinition): ! basetype = "CFTypeRef_Type" ! ! def outputRepr(self): ! Output() ! Output("static PyObject * %s_repr(%s *self)", self.prefix, self.objecttype) ! OutLbrace() ! Output("char buf[100];") ! Output("""sprintf(buf, "", (unsigned)self, (unsigned)self->ob_itself);""") ! Output("return PyString_FromString(buf);") ! OutRbrace() --- 252,482 ---- class MyGlobalObjectDefinition(PEP253Mixin, GlobalObjectDefinition): ! def outputCheckNewArg(self): ! Output('if (itself == NULL)') ! OutLbrace() ! Output('PyErr_SetString(PyExc_RuntimeError, "cannot wrap NULL");') ! Output('return NULL;') ! OutRbrace() ! def outputStructMembers(self): ! GlobalObjectDefinition.outputStructMembers(self) ! Output("void (*ob_freeit)(CFTypeRef ptr);") ! def outputInitStructMembers(self): ! GlobalObjectDefinition.outputInitStructMembers(self) ! ## Output("it->ob_freeit = NULL;") ! Output("it->ob_freeit = CFRelease;") ! def outputCheckConvertArg(self): ! Out(""" ! if (v == Py_None) { *p_itself = NULL; return 1; } ! /* Check for other CF objects here */ ! """) ! def outputCleanupStructMembers(self): ! Output("if (self->ob_freeit && self->ob_itself)") ! OutLbrace() ! Output("self->ob_freeit((CFTypeRef)self->ob_itself);") ! Output("self->ob_itself = NULL;") ! OutRbrace() ! def outputCompare(self): ! Output() ! Output("static int %s_compare(%s *self, %s *other)", self.prefix, self.objecttype, self.objecttype) ! OutLbrace() ! Output("/* XXXX Or should we use CFEqual?? */") ! Output("if ( self->ob_itself > other->ob_itself ) return 1;") ! Output("if ( self->ob_itself < other->ob_itself ) return -1;") ! Output("return 0;") ! OutRbrace() ! ! def outputHash(self): ! Output() ! Output("static int %s_hash(%s *self)", self.prefix, self.objecttype) ! OutLbrace() ! Output("/* XXXX Or should we use CFHash?? */") ! Output("return (int)self->ob_itself;") ! OutRbrace() ! ! def outputRepr(self): ! Output() ! Output("static PyObject * %s_repr(%s *self)", self.prefix, self.objecttype) ! OutLbrace() ! Output("char buf[100];") ! Output("""sprintf(buf, "", (int)CFGetTypeID(self->ob_itself), (unsigned)self, (unsigned)self->ob_itself);""") ! Output("return PyString_FromString(buf);") ! OutRbrace() ! ! def output_tp_newBody(self): ! Output("PyObject *self;") ! Output ! Output("if ((self = type->tp_alloc(type, 0)) == NULL) return NULL;") ! Output("((%s *)self)->ob_itself = NULL;", self.objecttype) ! Output("((%s *)self)->ob_freeit = CFRelease;", self.objecttype) ! Output("return self;") ! ! def output_tp_initBody(self): ! Output("%s itself;", self.itselftype) ! Output("char *kw[] = {\"itself\", 0};") ! Output() ! Output("if (PyArg_ParseTupleAndKeywords(args, kwds, \"O&\", kw, %s_Convert, &itself))", ! self.prefix) ! OutLbrace() ! Output("((%s *)self)->ob_itself = itself;", self.objecttype) ! Output("return 0;") ! OutRbrace() ! if self.prefix != 'CFTypeRefObj': ! Output() ! Output("/* Any CFTypeRef descendent is allowed as initializer too */") ! Output("if (PyArg_ParseTupleAndKeywords(args, kwds, \"O&\", kw, CFTypeRefObj_Convert, &itself))") ! OutLbrace() ! Output("((%s *)self)->ob_itself = itself;", self.objecttype) ! Output("return 0;") ! OutRbrace() ! Output("return -1;") class CFTypeRefObjectDefinition(MyGlobalObjectDefinition): ! pass ! class CFArrayRefObjectDefinition(MyGlobalObjectDefinition): ! basetype = "CFTypeRef_Type" ! ! def outputRepr(self): ! Output() ! Output("static PyObject * %s_repr(%s *self)", self.prefix, self.objecttype) ! OutLbrace() ! Output("char buf[100];") ! Output("""sprintf(buf, "", (unsigned)self, (unsigned)self->ob_itself);""") ! Output("return PyString_FromString(buf);") ! OutRbrace() ! class CFMutableArrayRefObjectDefinition(MyGlobalObjectDefinition): ! basetype = "CFArrayRef_Type" ! ! def outputRepr(self): ! Output() ! Output("static PyObject * %s_repr(%s *self)", self.prefix, self.objecttype) ! OutLbrace() ! Output("char buf[100];") ! Output("""sprintf(buf, "", (unsigned)self, (unsigned)self->ob_itself);""") ! Output("return PyString_FromString(buf);") ! OutRbrace() ! class CFDictionaryRefObjectDefinition(MyGlobalObjectDefinition): ! basetype = "CFTypeRef_Type" ! ! def outputRepr(self): ! Output() ! Output("static PyObject * %s_repr(%s *self)", self.prefix, self.objecttype) ! OutLbrace() ! Output("char buf[100];") ! Output("""sprintf(buf, "", (unsigned)self, (unsigned)self->ob_itself);""") ! Output("return PyString_FromString(buf);") ! OutRbrace() ! class CFMutableDictionaryRefObjectDefinition(MyGlobalObjectDefinition): ! basetype = "CFDictionaryRef_Type" ! ! def outputRepr(self): ! Output() ! Output("static PyObject * %s_repr(%s *self)", self.prefix, self.objecttype) ! OutLbrace() ! Output("char buf[100];") ! Output("""sprintf(buf, "", (unsigned)self, (unsigned)self->ob_itself);""") ! Output("return PyString_FromString(buf);") ! OutRbrace() ! class CFDataRefObjectDefinition(MyGlobalObjectDefinition): ! basetype = "CFTypeRef_Type" ! ! def outputCheckConvertArg(self): ! Out(""" ! if (v == Py_None) { *p_itself = NULL; return 1; } ! if (PyString_Check(v)) { ! char *cStr; ! int cLen; ! if( PyString_AsStringAndSize(v, &cStr, &cLen) < 0 ) return 0; ! *p_itself = CFDataCreate((CFAllocatorRef)NULL, (unsigned char *)cStr, cLen); ! return 1; ! } ! """) ! ! def outputRepr(self): ! Output() ! Output("static PyObject * %s_repr(%s *self)", self.prefix, self.objecttype) ! OutLbrace() ! Output("char buf[100];") ! Output("""sprintf(buf, "", (unsigned)self, (unsigned)self->ob_itself);""") ! Output("return PyString_FromString(buf);") ! OutRbrace() class CFMutableDataRefObjectDefinition(MyGlobalObjectDefinition): ! basetype = "CFDataRef_Type" ! ! def outputRepr(self): ! Output() ! Output("static PyObject * %s_repr(%s *self)", self.prefix, self.objecttype) ! OutLbrace() ! Output("char buf[100];") ! Output("""sprintf(buf, "", (unsigned)self, (unsigned)self->ob_itself);""") ! Output("return PyString_FromString(buf);") ! OutRbrace() class CFStringRefObjectDefinition(MyGlobalObjectDefinition): ! basetype = "CFTypeRef_Type" ! def outputCheckConvertArg(self): ! Out(""" ! if (v == Py_None) { *p_itself = NULL; return 1; } ! if (PyString_Check(v)) { ! char *cStr; ! if (!PyArg_Parse(v, "es", "ascii", &cStr)) ! return NULL; ! *p_itself = CFStringCreateWithCString((CFAllocatorRef)NULL, cStr, kCFStringEncodingASCII); ! return 1; ! } ! if (PyUnicode_Check(v)) { ! /* We use the CF types here, if Python was configured differently that will give an error */ ! CFIndex size = PyUnicode_GetSize(v); ! UniChar *unichars = PyUnicode_AsUnicode(v); ! if (!unichars) return 0; ! *p_itself = CFStringCreateWithCharacters((CFAllocatorRef)NULL, unichars, size); ! return 1; ! } ! ! """) ! ! def outputRepr(self): ! Output() ! Output("static PyObject * %s_repr(%s *self)", self.prefix, self.objecttype) ! OutLbrace() ! Output("char buf[100];") ! Output("""sprintf(buf, "", (unsigned)self, (unsigned)self->ob_itself);""") ! Output("return PyString_FromString(buf);") ! OutRbrace() class CFMutableStringRefObjectDefinition(CFStringRefObjectDefinition): ! basetype = "CFStringRef_Type" ! ! def outputCheckConvertArg(self): ! # Mutable, don't allow Python strings ! return MyGlobalObjectDefinition.outputCheckConvertArg(self) ! ! def outputRepr(self): ! Output() ! Output("static PyObject * %s_repr(%s *self)", self.prefix, self.objecttype) ! OutLbrace() ! Output("char buf[100];") ! Output("""sprintf(buf, "", (unsigned)self, (unsigned)self->ob_itself);""") ! Output("return PyString_FromString(buf);") ! OutRbrace() class CFURLRefObjectDefinition(MyGlobalObjectDefinition): ! basetype = "CFTypeRef_Type" ! ! def outputRepr(self): ! Output() ! Output("static PyObject * %s_repr(%s *self)", self.prefix, self.objecttype) ! OutLbrace() ! Output("char buf[100];") ! Output("""sprintf(buf, "", (unsigned)self, (unsigned)self->ob_itself);""") ! Output("return PyString_FromString(buf);") ! OutRbrace() *************** *** 555,562 **** if( data == NULL ) return PyErr_NoMemory(); if ( CFStringGetCString(_self->ob_itself, data, size, 0) ) { ! _res = (PyObject *)PyString_FromString(data); } else { ! PyErr_SetString(PyExc_RuntimeError, "CFStringGetCString could not fit the string"); ! _res = NULL; } free(data); --- 555,562 ---- if( data == NULL ) return PyErr_NoMemory(); if ( CFStringGetCString(_self->ob_itself, data, size, 0) ) { ! _res = (PyObject *)PyString_FromString(data); } else { ! PyErr_SetString(PyExc_RuntimeError, "CFStringGetCString could not fit the string"); ! _res = NULL; } free(data); *************** *** 606,610 **** if (!PyArg_ParseTuple(_args, "l", &mutabilityOption)) ! return NULL; _rv = CFPropertyListCreateFromXMLData((CFAllocatorRef)NULL, _self->ob_itself, --- 606,610 ---- if (!PyArg_ParseTuple(_args, "l", &mutabilityOption)) ! return NULL; _rv = CFPropertyListCreateFromXMLData((CFAllocatorRef)NULL, _self->ob_itself, *************** *** 612,619 **** &errorString); if (errorString) ! CFRelease(errorString); if (_rv == NULL) { ! PyErr_SetString(PyExc_RuntimeError, "Parse error in XML data"); ! return NULL; } _res = Py_BuildValue("O&", --- 612,619 ---- &errorString); if (errorString) ! CFRelease(errorString); if (_rv == NULL) { ! PyErr_SetString(PyExc_RuntimeError, "Parse error in XML data"); ! return NULL; } _res = Py_BuildValue("O&", *************** *** 640,654 **** if (!PyArg_ParseTuple(_args, "O&", PyCF_Python2CF, &rv)) ! return NULL; typeid = CFGetTypeID(rv); if (typeid == CFStringGetTypeID()) ! return Py_BuildValue("O&", CFStringRefObj_New, rv); if (typeid == CFArrayGetTypeID()) ! return Py_BuildValue("O&", CFArrayRefObj_New, rv); if (typeid == CFDictionaryGetTypeID()) ! return Py_BuildValue("O&", CFDictionaryRefObj_New, rv); if (typeid == CFURLGetTypeID()) ! return Py_BuildValue("O&", CFURLRefObj_New, rv); _res = Py_BuildValue("O&", CFTypeRefObj_New, rv); --- 640,654 ---- if (!PyArg_ParseTuple(_args, "O&", PyCF_Python2CF, &rv)) ! return NULL; typeid = CFGetTypeID(rv); if (typeid == CFStringGetTypeID()) ! return Py_BuildValue("O&", CFStringRefObj_New, rv); if (typeid == CFArrayGetTypeID()) ! return Py_BuildValue("O&", CFArrayRefObj_New, rv); if (typeid == CFDictionaryGetTypeID()) ! return Py_BuildValue("O&", CFDictionaryRefObj_New, rv); if (typeid == CFURLGetTypeID()) ! return Py_BuildValue("O&", CFURLRefObj_New, rv); _res = Py_BuildValue("O&", CFTypeRefObj_New, rv); *************** *** 664,666 **** SetOutputFileName(OUTPUTFILE) module.generate() - --- 664,665 ---- From tim_one at users.sourceforge.net Sun Jul 18 08:02:07 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 08:02:10 2004 Subject: [Python-checkins] python/dist/src/Tools/i18n msgfmt.py,1.3,1.4 Message-ID: Update of /cvsroot/python/python/dist/src/Tools/i18n In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29862/i18n Modified Files: msgfmt.py Log Message: Whitespace normalization, via reindent.py. Index: msgfmt.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/i18n/msgfmt.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** msgfmt.py 9 May 2003 08:59:17 -0000 1.3 --- msgfmt.py 18 Jul 2004 06:02:04 -0000 1.4 *************** *** 114,118 **** print >> sys.stderr, msg sys.exit(1) ! section = None fuzzy = 0 --- 114,118 ---- print >> sys.stderr, msg sys.exit(1) ! section = None fuzzy = 0 *************** *** 170,174 **** except IOError,msg: print >> sys.stderr, msg ! --- 170,174 ---- except IOError,msg: print >> sys.stderr, msg ! From tim_one at users.sourceforge.net Sun Jul 18 08:02:07 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 08:02:11 2004 Subject: [Python-checkins] python/dist/src/Tools/framer/framer __init__.py, 1.1, 1.2 bases.py, 1.1, 1.2 function.py, 1.1, 1.2 struct.py, 1.1, 1.2 structparse.py, 1.1, 1.2 template.py, 1.2, 1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Tools/framer/framer In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29862/framer/framer Modified Files: __init__.py bases.py function.py struct.py structparse.py template.py Log Message: Whitespace normalization, via reindent.py. Index: __init__.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/framer/framer/__init__.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** __init__.py 5 Aug 2002 18:29:45 -0000 1.1 --- __init__.py 18 Jul 2004 06:02:03 -0000 1.2 *************** *** 5,8 **** takes a more declarative approach to generating code. """ - - --- 5,6 ---- Index: bases.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/framer/framer/bases.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** bases.py 5 Aug 2002 18:29:45 -0000 1.1 --- bases.py 18 Jul 2004 06:02:03 -0000 1.2 *************** *** 65,69 **** if obj.has_members(): self.__members = True ! def initvars(self): v = self.__vars = {} --- 65,69 ---- if obj.has_members(): self.__members = True ! def initvars(self): v = self.__vars = {} *************** *** 84,88 **** p(template.member_include) print >> f ! if self.__doc__: p(template.module_doc) --- 84,88 ---- p(template.member_include) print >> f ! if self.__doc__: p(template.module_doc) *************** *** 99,103 **** for name, type in sortitems(self.__types): type.dump_init(f) ! p("}") --- 99,103 ---- for name, type in sortitems(self.__types): type.dump_init(f) ! p("}") *************** *** 122,126 **** for name, func in sortitems(self.__methods): func.dump(f) ! self.dump_methoddef(f, self.__methods, self.__vars) self.dump_memberdef(f) --- 122,126 ---- for name, func in sortitems(self.__methods): func.dump(f) ! self.dump_methoddef(f, self.__methods, self.__vars) self.dump_memberdef(f) *************** *** 200,204 **** if self.struct: ! p(template.dealloc_func, {"name" : self.__slots[TP_DEALLOC]}) p(template.type_struct_start) --- 200,204 ---- if self.struct: ! p(template.dealloc_func, {"name" : self.__slots[TP_DEALLOC]}) p(template.type_struct_start) *************** *** 219,221 **** class Type: __metaclass__ = TypeMetaclass - --- 219,220 ---- Index: function.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/framer/framer/function.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** function.py 5 Aug 2002 18:29:45 -0000 1.1 --- function.py 18 Jul 2004 06:02:03 -0000 1.2 *************** *** 56,60 **** def dump_decls(self, f): pass ! class NoArgs(_ArgumentList): --- 56,60 ---- def dump_decls(self, f): pass ! class NoArgs(_ArgumentList): *************** *** 68,72 **** class OneArg(_ArgumentList): ! def __init__(self, args): assert len(args) == 1 --- 68,72 ---- class OneArg(_ArgumentList): ! def __init__(self, args): assert len(args) == 1 *************** *** 140,144 **** if self.__doc__: p(template.docstring) ! d = {"name" : self.vars["CName"], "args" : self.args.c_args(), --- 140,144 ---- if self.__doc__: p(template.docstring) ! d = {"name" : self.vars["CName"], "args" : self.args.c_args(), *************** *** 150,154 **** if self.args.ml_meth == METH_VARARGS: p(template.varargs) ! p(template.funcdef_end) --- 150,154 ---- if self.args.ml_meth == METH_VARARGS: p(template.varargs) ! p(template.funcdef_end) *************** *** 156,160 **** self.__doc__ = self._func.__doc__ self.args = ArgumentList(self._func, self.method) ! def initvars(self): v = self.vars = {} --- 156,160 ---- self.__doc__ = self._func.__doc__ self.args = ArgumentList(self._func, self.method) ! def initvars(self): v = self.vars = {} Index: struct.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/framer/framer/struct.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** struct.py 5 Aug 2002 18:29:45 -0000 1.1 --- struct.py 18 Jul 2004 06:02:03 -0000 1.2 *************** *** 36,40 **** if line.startswith("}"): break ! assert line.endswith(";") line = line[:-1] --- 36,40 ---- if line.startswith("}"): break ! assert line.endswith(";") line = line[:-1] Index: structparse.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/framer/framer/structparse.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** structparse.py 5 Aug 2002 18:29:45 -0000 1.1 --- structparse.py 18 Jul 2004 06:02:03 -0000 1.2 *************** *** 30,34 **** if line.startswith("}"): break ! assert line.endswith(";") line = line[:-1] --- 30,34 ---- if line.startswith("}"): break ! assert line.endswith(";") line = line[:-1] Index: template.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/framer/framer/template.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** template.py 24 Oct 2003 20:09:23 -0000 1.2 --- template.py 18 Jul 2004 06:02:03 -0000 1.3 *************** *** 21,29 **** methoddef_def = """\ {"%(PythonName)s", (PyCFunction)%(CName)s, %(MethType)s},""" ! methoddef_def_doc = """\ {"%(PythonName)s", (PyCFunction)%(CName)s, %(MethType)s, %(DocstringVar)s},""" ! methoddef_end = """\ {NULL, NULL} --- 21,29 ---- methoddef_def = """\ {"%(PythonName)s", (PyCFunction)%(CName)s, %(MethType)s},""" ! methoddef_def_doc = """\ {"%(PythonName)s", (PyCFunction)%(CName)s, %(MethType)s, %(DocstringVar)s},""" ! methoddef_end = """\ {NULL, NULL} *************** *** 97,101 **** static PyTypeObject %(CTypeName)s = { PyObject_HEAD_INIT(0)""" ! type_struct_end = """\ }; --- 97,101 ---- static PyTypeObject %(CTypeName)s = { PyObject_HEAD_INIT(0)""" ! type_struct_end = """\ }; From tim_one at users.sourceforge.net Sun Jul 18 08:02:07 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 08:02:13 2004 Subject: [Python-checkins] python/dist/src/Tools/modulator Tkextra.py, 1.3, 1.4 genmodule.py, 1.5, 1.6 modulator.py, 1.11, 1.12 varsubst.py, 1.4, 1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Tools/modulator In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29862/modulator Modified Files: Tkextra.py genmodule.py modulator.py varsubst.py Log Message: Whitespace normalization, via reindent.py. Index: Tkextra.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/modulator/Tkextra.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Tkextra.py 10 Apr 1998 19:15:22 -0000 1.3 --- Tkextra.py 18 Jul 2004 06:02:04 -0000 1.4 *************** *** 106,110 **** 'text': text, 'font': '-Adobe-Times-Medium-R-Normal-*-180-*', ! Pack: {'side': 'left', 'fill': 'both', 'padx': '3m', 'pady': '3m'}}) --- 106,110 ---- 'text': text, 'font': '-Adobe-Times-Medium-R-Normal-*-180-*', ! Pack: {'side': 'left', 'fill': 'both', 'padx': '3m', 'pady': '3m'}}) *************** *** 188,192 **** i = strdialog(mainWidget, 'Question', str, '', 0) return i ! # The rest is the test program. --- 188,192 ---- i = strdialog(mainWidget, 'Question', str, '', 0) return i ! # The rest is the test program. Index: genmodule.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/modulator/genmodule.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** genmodule.py 11 Sep 2002 20:36:01 -0000 1.5 --- genmodule.py 18 Jul 2004 06:02:04 -0000 1.6 *************** *** 66,70 **** raise error, 'Template '+name+' not found for '+self._type+' '+ \ self.name ! class module(writer): _type = 'module' --- 66,70 ---- raise error, 'Template '+name+' not found for '+self._type+' '+ \ self.name ! class module(writer): _type = 'module' *************** *** 117,121 **** if self.methodlist and not 'tp_getattr' in self.funclist: self.funclist.insert(0, 'tp_getattr') ! for fn in FUNCLIST: setattr(self, fn, '0') --- 117,121 ---- if self.methodlist and not 'tp_getattr' in self.funclist: self.funclist.insert(0, 'tp_getattr') ! for fn in FUNCLIST: setattr(self, fn, '0') Index: modulator.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/modulator/modulator.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** modulator.py 12 Feb 2004 17:35:31 -0000 1.11 --- modulator.py 18 Jul 2004 06:02:04 -0000 1.12 *************** *** 50,54 **** rv.append(list.get(i)) return rv ! class UI: def __init__(self): --- 50,54 ---- rv.append(list.get(i)) return rv ! class UI: def __init__(self): *************** *** 98,102 **** except oops: pass ! def cb_save(self, *args): try: --- 98,102 ---- except oops: pass ! def cb_save(self, *args): try: *************** *** 178,187 **** Pack:{'side':'left', 'padx':'0.5m'}}) ! def cb_delmethod(self, *args): list = self.method_list.curselection() for i in list: self.method_list.delete(i) ! def cb_newobj(self, *arg): self.parent.objects.append(UI_object(self.parent)) --- 178,187 ---- Pack:{'side':'left', 'padx':'0.5m'}}) ! def cb_delmethod(self, *args): list = self.method_list.curselection() for i in list: self.method_list.delete(i) ! def cb_newobj(self, *arg): self.parent.objects.append(UI_object(self.parent)) *************** *** 209,213 **** message('Method name not an identifier:\n'+n) raise oops ! def gencode(self, name, objects): rv = '' --- 209,213 ---- message('Method name not an identifier:\n'+n) raise oops ! def gencode(self, name, objects): rv = '' *************** *** 227,231 **** rv = rv + '\n' return rv ! object_number = 0 --- 227,231 ---- rv = rv + '\n' return rv ! object_number = 0 *************** *** 251,255 **** self.f4 = Frame(self.frame, {Pack:{'side':'top', 'pady':'0.5m', 'fill':'x'}}) ! self.l1 = Label(self.f1, {'text':'Object:', Pack:{'side':'left', --- 251,255 ---- self.f4 = Frame(self.frame, {Pack:{'side':'top', 'pady':'0.5m', 'fill':'x'}}) ! self.l1 = Label(self.f1, {'text':'Object:', Pack:{'side':'left', *************** *** 306,310 **** 'anchor':'w'}}) self.types[i] = b ! def cb_method(self, *arg): name = self.method_entry.get() --- 306,310 ---- 'anchor':'w'}}) self.types[i] = b ! def cb_method(self, *arg): name = self.method_entry.get() *************** *** 318,322 **** for i in list: self.method_list.delete(i) ! def synchronize(self): n = self.name_entry.get() --- 318,322 ---- for i in list: self.method_list.delete(i) ! def synchronize(self): n = self.name_entry.get() *************** *** 338,342 **** self.f5.setvar(self.vpref+'tp_getattr', 1) pass ! def gencode(self, name): rv = '' --- 338,342 ---- self.f5.setvar(self.vpref+'tp_getattr', 1) pass ! def gencode(self, name): rv = '' *************** *** 357,366 **** if self.f5.getvar(vname) == '1': fl.append(fn) ! rv = rv + '%s.typelist = %r\n' % (name, fl) rv = rv + '\n' return rv ! def main(): --- 357,366 ---- if self.f5.getvar(vname) == '1': fl.append(fn) ! rv = rv + '%s.typelist = %r\n' % (name, fl) rv = rv + '\n' return rv ! def main(): *************** *** 380,383 **** sys.stderr.write('Usage: modulator [file]\n') sys.exit(1) ! main() --- 380,383 ---- sys.stderr.write('Usage: modulator [file]\n') sys.exit(1) ! main() Index: varsubst.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/modulator/varsubst.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** varsubst.py 11 Sep 2002 20:36:01 -0000 1.4 --- varsubst.py 18 Jul 2004 06:02:04 -0000 1.5 *************** *** 14,18 **** def useindent(self, onoff): self.do_useindent = onoff ! def subst(self, s): rv = '' --- 14,18 ---- def useindent(self, onoff): self.do_useindent = onoff ! def subst(self, s): rv = '' From tim_one at users.sourceforge.net Sun Jul 18 08:02:07 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 08:02:14 2004 Subject: [Python-checkins] python/dist/src/Tools/pynche ChipViewer.py, 2.10, 2.11 DetailsViewer.py, 2.10, 2.11 StripViewer.py, 2.16, 2.17 Message-ID: Update of /cvsroot/python/python/dist/src/Tools/pynche In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29862/pynche Modified Files: ChipViewer.py DetailsViewer.py StripViewer.py Log Message: Whitespace normalization, via reindent.py. Index: ChipViewer.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/pynche/ChipViewer.py,v retrieving revision 2.10 retrieving revision 2.11 diff -C2 -d -r2.10 -r2.11 *** ChipViewer.py 23 Aug 2001 16:14:45 -0000 2.10 --- ChipViewer.py 18 Jul 2004 06:02:04 -0000 2.11 *************** *** 102,106 **** # an exact match be indicated in some way? # ! # Always use the #rrggbb style to actually set the color, since we may # not be using X color names (e.g. "web-safe" names) colordb = self.__sb.colordb() --- 102,106 ---- # an exact match be indicated in some way? # ! # Always use the #rrggbb style to actually set the color, since we may # not be using X color names (e.g. "web-safe" names) colordb = self.__sb.colordb() Index: DetailsViewer.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/pynche/DetailsViewer.py,v retrieving revision 2.10 retrieving revision 2.11 diff -C2 -d -r2.10 -r2.11 *** DetailsViewer.py 10 Jul 2001 21:39:18 -0000 2.10 --- DetailsViewer.py 18 Jul 2004 06:02:04 -0000 2.11 *************** *** 3,7 **** This class implements a pure input window which allows you to meticulously edit the current color. You have both mouse control of the color (via the ! buttons along the bottom row), and there are keyboard bindings for each of the increment/decrement buttons. --- 3,7 ---- This class implements a pure input window which allows you to meticulously edit the current color. You have both mouse control of the color (via the ! buttons along the bottom row), and there are keyboard bindings for each of the increment/decrement buttons. *************** *** 9,13 **** variations are tied together when incrementing and decrementing. Red, green, and blue are self evident. By tying together red and green, you can modify ! the yellow level of the color. By tying together red and blue, you can modify the magenta level of the color. By tying together green and blue, you can modify the cyan level, and by tying all three together, you can modify the --- 9,13 ---- variations are tied together when incrementing and decrementing. Red, green, and blue are self evident. By tying together red and green, you can modify ! the yellow level of the color. By tying together red and blue, you can modify the magenta level of the color. By tying together green and blue, you can modify the cyan level, and by tying all three together, you can modify the Index: StripViewer.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/pynche/StripViewer.py,v retrieving revision 2.16 retrieving revision 2.17 diff -C2 -d -r2.16 -r2.17 *** StripViewer.py 24 Oct 2003 20:09:23 -0000 2.16 --- StripViewer.py 18 Jul 2004 06:02:04 -0000 2.17 *************** *** 1,5 **** """Strip viewer and related widgets. ! The classes in this file implement the StripViewer shown in the top two thirds of the main Pynche window. It consists of three StripWidgets which display the variations in red, green, and blue respectively of the currently selected --- 1,5 ---- """Strip viewer and related widgets. ! The classes in this file implement the StripViewer shown in the top two thirds of the main Pynche window. It consists of three StripWidgets which display the variations in red, green, and blue respectively of the currently selected *************** *** 183,187 **** self.__lastchip = None self.__sb = switchboard ! canvaswidth = numchips * (chipwidth + 1) canvasheight = chipheight + 43 # BAW: Kludge --- 183,187 ---- self.__lastchip = None self.__sb = switchboard ! canvaswidth = numchips * (chipwidth + 1) canvasheight = chipheight + 43 # BAW: Kludge *************** *** 373,377 **** # XXX: ignore this feature for now; it doesn't work quite right yet ! ## gentypevar = self.__gentypevar = IntVar() ## self.__variations = Radiobutton(frame, --- 373,377 ---- # XXX: ignore this feature for now; it doesn't work quite right yet ! ## gentypevar = self.__gentypevar = IntVar() ## self.__variations = Radiobutton(frame, From tim_one at users.sourceforge.net Sun Jul 18 08:02:07 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 08:02:17 2004 Subject: [Python-checkins] python/dist/src/Tools/unicode mkstringprep.py, 1.2, 1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Tools/unicode In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29862/unicode Modified Files: mkstringprep.py Log Message: Whitespace normalization, via reindent.py. Index: mkstringprep.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/unicode/mkstringprep.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** mkstringprep.py 19 May 2004 19:10:18 -0000 1.2 --- mkstringprep.py 18 Jul 2004 06:02:05 -0000 1.3 *************** *** 430,432 **** return unicodedata.bidirectional(code) == "L" """ - --- 430,431 ---- From tim_one at users.sourceforge.net Sun Jul 18 08:02:07 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 08:02:19 2004 Subject: [Python-checkins] python/dist/src/Tools/versioncheck checkversions.py, 1.4, 1.5 pyversioncheck.py, 1.5, 1.6 Message-ID: Update of /cvsroot/python/python/dist/src/Tools/versioncheck In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29862/versioncheck Modified Files: checkversions.py pyversioncheck.py Log Message: Whitespace normalization, via reindent.py. Index: checkversions.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/versioncheck/checkversions.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** checkversions.py 24 Oct 2003 20:09:23 -0000 1.4 --- checkversions.py 18 Jul 2004 06:02:05 -0000 1.5 *************** *** 1,3 **** ! """Checkversions - recursively search a directory (default: sys.prefix) for _checkversion.py files, and run each of them. This will tell you of new versions available for any packages you have installed.""" --- 1,3 ---- ! """Checkversions - recursively search a directory (default: sys.prefix) for _checkversion.py files, and run each of them. This will tell you of new versions available for any packages you have installed.""" *************** *** 30,34 **** except: print '** Exception in', fullname ! def walk1tree(tree): os.path.walk(tree, check1dir, None) --- 30,34 ---- except: print '** Exception in', fullname ! def walk1tree(tree): os.path.walk(tree, check1dir, None) *************** *** 51,54 **** if __name__ == '__main__': main() - - --- 51,52 ---- Index: pyversioncheck.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/versioncheck/pyversioncheck.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** pyversioncheck.py 24 Oct 2003 20:09:23 -0000 1.5 --- pyversioncheck.py 18 Jul 2004 06:02:05 -0000 1.6 *************** *** 97,99 **** if __name__ == '__main__': _test() - --- 97,98 ---- From tim_one at users.sourceforge.net Sun Jul 18 08:02:08 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 08:02:20 2004 Subject: [Python-checkins] python/dist/src/Tools/webchecker wcgui.py, 1.9, 1.10 webchecker.py, 1.31, 1.32 Message-ID: Update of /cvsroot/python/python/dist/src/Tools/webchecker In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29862/webchecker Modified Files: wcgui.py webchecker.py Log Message: Whitespace normalization, via reindent.py. Index: wcgui.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/webchecker/wcgui.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** wcgui.py 11 Sep 2002 20:36:02 -0000 1.9 --- wcgui.py 18 Jul 2004 06:02:05 -0000 1.10 *************** *** 11,25 **** User interface: ! Enter a root to check in the text entry box. To enter more than one root, enter them one at a time and press for each one. ! Command buttons Start, Stop and "Check one" govern the checking process in ! the obvious way. Start and "Check one" also enter the root from the text entry box if one is present. There's also a check box (enabled by default) to decide whether actually to follow external links (since this can slow the checking down considerably). Finally there's a Quit button. ! A series of checkbuttons determines whether the corresponding output panel ! is shown. List panels are also automatically shown or hidden when their status changes between empty to non-empty. There are six panels: --- 11,25 ---- User interface: ! Enter a root to check in the text entry box. To enter more than one root, enter them one at a time and press for each one. ! Command buttons Start, Stop and "Check one" govern the checking process in ! the obvious way. Start and "Check one" also enter the root from the text entry box if one is present. There's also a check box (enabled by default) to decide whether actually to follow external links (since this can slow the checking down considerably). Finally there's a Quit button. ! A series of checkbuttons determines whether the corresponding output panel ! is shown. List panels are also automatically shown or hidden when their status changes between empty to non-empty. There are six panels: Index: webchecker.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/webchecker/webchecker.py,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** webchecker.py 21 Mar 2004 19:07:23 -0000 1.31 --- webchecker.py 18 Jul 2004 06:02:05 -0000 1.32 *************** *** 298,302 **** if args: format = format%args ! print format def __getstate__(self): --- 298,302 ---- if args: format = format%args ! print format def __getstate__(self): *************** *** 381,385 **** # of the "source" variable comes from the list of # origins, and is a URL, not a pair. ! for url, rawlink, msg in triples: if rawlink != self.format_url(url): s = " (%s)" % rawlink else: s = "" --- 381,385 ---- # of the "source" variable comes from the list of # origins, and is a URL, not a pair. ! for url, rawlink, msg in triples: if rawlink != self.format_url(url): s = " (%s)" % rawlink else: s = "" *************** *** 463,467 **** self.note(3, " New todo link %s", self.format_url(url)) ! def format_url(self, url): link, fragment = url if fragment: return link + "#" + fragment --- 463,467 ---- self.note(3, " New todo link %s", self.format_url(url)) ! def format_url(self, url): link, fragment = url if fragment: return link + "#" + fragment *************** *** 717,721 **** rawlink = urlparse.urlunparse(t) link = urlparse.urljoin(base, rawlink) ! infos.append((link, rawlink, fragment)) return infos --- 717,721 ---- rawlink = urlparse.urlunparse(t) link = urlparse.urljoin(base, rawlink) ! infos.append((link, rawlink, fragment)) return infos From tim_one at users.sourceforge.net Sun Jul 18 08:02:08 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 08:02:22 2004 Subject: [Python-checkins] python/dist/src/Tools/freeze bkfile.py, 1.2, 1.3 checkextensions.py, 1.5, 1.6 checkextensions_win32.py, 1.8, 1.9 freeze.py, 1.46, 1.47 makeconfig.py, 1.6, 1.7 makefreeze.py, 1.15, 1.16 makemakefile.py, 1.7, 1.8 parsesetup.py, 1.4, 1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Tools/freeze In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29862/freeze Modified Files: bkfile.py checkextensions.py checkextensions_win32.py freeze.py makeconfig.py makefreeze.py makemakefile.py parsesetup.py Log Message: Whitespace normalization, via reindent.py. Index: bkfile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/freeze/bkfile.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** bkfile.py 28 Apr 2000 13:31:52 -0000 1.2 --- bkfile.py 18 Jul 2004 06:02:03 -0000 1.3 *************** *** 2,47 **** class _BkFile: ! def __init__(self, file, mode, bufsize): ! import os ! self.__filename = file ! self.__backup = file + '~' ! try: ! os.unlink(self.__backup) ! except os.error: ! pass ! try: ! os.rename(file, self.__backup) ! except os.error: ! self.__backup = None ! self.__file = _orig_open(file, mode, bufsize) ! self.closed = self.__file.closed ! self.fileno = self.__file.fileno ! self.flush = self.__file.flush ! self.isatty = self.__file.isatty ! self.mode = self.__file.mode ! self.name = self.__file.name ! self.read = self.__file.read ! self.readinto = self.__file.readinto ! self.readline = self.__file.readline ! self.readlines = self.__file.readlines ! self.seek = self.__file.seek ! self.softspace = self.__file.softspace ! self.tell = self.__file.tell ! self.truncate = self.__file.truncate ! self.write = self.__file.write ! self.writelines = self.__file.writelines ! def close(self): ! self.__file.close() ! if self.__backup is None: ! return ! import filecmp ! if filecmp.cmp(self.__backup, self.__filename, shallow = 0): ! import os ! os.unlink(self.__filename) ! os.rename(self.__backup, self.__filename) def open(file, mode = 'r', bufsize = -1): ! if 'w' not in mode: ! return _orig_open(file, mode, bufsize) ! return _BkFile(file, mode, bufsize) --- 2,47 ---- class _BkFile: ! def __init__(self, file, mode, bufsize): ! import os ! self.__filename = file ! self.__backup = file + '~' ! try: ! os.unlink(self.__backup) ! except os.error: ! pass ! try: ! os.rename(file, self.__backup) ! except os.error: ! self.__backup = None ! self.__file = _orig_open(file, mode, bufsize) ! self.closed = self.__file.closed ! self.fileno = self.__file.fileno ! self.flush = self.__file.flush ! self.isatty = self.__file.isatty ! self.mode = self.__file.mode ! self.name = self.__file.name ! self.read = self.__file.read ! self.readinto = self.__file.readinto ! self.readline = self.__file.readline ! self.readlines = self.__file.readlines ! self.seek = self.__file.seek ! self.softspace = self.__file.softspace ! self.tell = self.__file.tell ! self.truncate = self.__file.truncate ! self.write = self.__file.write ! self.writelines = self.__file.writelines ! def close(self): ! self.__file.close() ! if self.__backup is None: ! return ! import filecmp ! if filecmp.cmp(self.__backup, self.__filename, shallow = 0): ! import os ! os.unlink(self.__filename) ! os.rename(self.__backup, self.__filename) def open(file, mode = 'r', bufsize = -1): ! if 'w' not in mode: ! return _orig_open(file, mode, bufsize) ! return _BkFile(file, mode, bufsize) Index: checkextensions.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/freeze/checkextensions.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** checkextensions.py 11 Sep 2002 20:36:00 -0000 1.5 --- checkextensions.py 18 Jul 2004 06:02:03 -0000 1.6 *************** *** 7,57 **** def checkextensions(unknown, extensions): ! files = [] ! modules = [] ! edict = {} ! for e in extensions: ! setup = os.path.join(e, 'Setup') ! liba = os.path.join(e, 'lib.a') ! if not os.path.isfile(liba): ! liba = None ! edict[e] = parsesetup.getsetupinfo(setup), liba ! for mod in unknown: ! for e in extensions: ! (mods, vars), liba = edict[e] ! if not mods.has_key(mod): ! continue ! modules.append(mod) ! if liba: ! # If we find a lib.a, use it, ignore the ! # .o files, and use *all* libraries for ! # *all* modules in the Setup file ! if liba in files: ! break ! files.append(liba) ! for m in mods.keys(): ! files = files + select(e, mods, vars, ! m, 1) ! break ! files = files + select(e, mods, vars, mod, 0) ! break ! return files, modules def select(e, mods, vars, mod, skipofiles): ! files = [] ! for w in mods[mod]: ! w = treatword(w) ! if not w: ! continue ! w = expandvars(w, vars) ! for w in w.split(): ! if skipofiles and w[-2:] == '.o': ! continue ! # Assume $var expands to absolute pathname ! if w[0] not in ('-', '$') and w[-2:] in ('.o', '.a'): ! w = os.path.join(e, w) ! if w[:2] in ('-L', '-R') and w[2:3] != '$': ! w = w[:2] + os.path.join(e, w[2:]) ! files.append(w) ! return files cc_flags = ['-I', '-D', '-U'] --- 7,57 ---- def checkextensions(unknown, extensions): ! files = [] ! modules = [] ! edict = {} ! for e in extensions: ! setup = os.path.join(e, 'Setup') ! liba = os.path.join(e, 'lib.a') ! if not os.path.isfile(liba): ! liba = None ! edict[e] = parsesetup.getsetupinfo(setup), liba ! for mod in unknown: ! for e in extensions: ! (mods, vars), liba = edict[e] ! if not mods.has_key(mod): ! continue ! modules.append(mod) ! if liba: ! # If we find a lib.a, use it, ignore the ! # .o files, and use *all* libraries for ! # *all* modules in the Setup file ! if liba in files: ! break ! files.append(liba) ! for m in mods.keys(): ! files = files + select(e, mods, vars, ! m, 1) ! break ! files = files + select(e, mods, vars, mod, 0) ! break ! return files, modules def select(e, mods, vars, mod, skipofiles): ! files = [] ! for w in mods[mod]: ! w = treatword(w) ! if not w: ! continue ! w = expandvars(w, vars) ! for w in w.split(): ! if skipofiles and w[-2:] == '.o': ! continue ! # Assume $var expands to absolute pathname ! if w[0] not in ('-', '$') and w[-2:] in ('.o', '.a'): ! w = os.path.join(e, w) ! if w[:2] in ('-L', '-R') and w[2:3] != '$': ! w = w[:2] + os.path.join(e, w[2:]) ! files.append(w) ! return files cc_flags = ['-I', '-D', '-U'] *************** *** 59,90 **** def treatword(w): ! if w[:2] in cc_flags: ! return None ! if w[:1] == '-': ! return w # Assume loader flag ! head, tail = os.path.split(w) ! base, ext = os.path.splitext(tail) ! if ext in cc_exts: ! tail = base + '.o' ! w = os.path.join(head, tail) ! return w def expandvars(str, vars): ! i = 0 ! while i < len(str): ! i = k = str.find('$', i) ! if i < 0: ! break ! i = i+1 ! var = str[i:i+1] ! i = i+1 ! if var == '(': ! j = str.find(')', i) ! if j < 0: ! break ! var = str[i:j] ! i = j+1 ! if vars.has_key(var): ! str = str[:k] + vars[var] + str[i:] ! i = k ! return str --- 59,90 ---- def treatword(w): ! if w[:2] in cc_flags: ! return None ! if w[:1] == '-': ! return w # Assume loader flag ! head, tail = os.path.split(w) ! base, ext = os.path.splitext(tail) ! if ext in cc_exts: ! tail = base + '.o' ! w = os.path.join(head, tail) ! return w def expandvars(str, vars): ! i = 0 ! while i < len(str): ! i = k = str.find('$', i) ! if i < 0: ! break ! i = i+1 ! var = str[i:i+1] ! i = i+1 ! if var == '(': ! j = str.find(')', i) ! if j < 0: ! break ! var = str[i:j] ! i = j+1 ! if vars.has_key(var): ! str = str[:k] + vars[var] + str[i:] ! i = k ! return str Index: checkextensions_win32.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/freeze/checkextensions_win32.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** checkextensions_win32.py 20 Sep 2003 11:05:01 -0000 1.8 --- checkextensions_win32.py 18 Jul 2004 06:02:03 -0000 1.9 *************** *** 25,164 **** import os, sys try: ! import win32api except ImportError: ! win32api = None # User has already been warned class CExtension: ! """An abstraction of an extension implemented in C/C++ ! """ ! def __init__(self, name, sourceFiles): ! self.name = name ! # A list of strings defining additional compiler options. ! self.sourceFiles = sourceFiles ! # A list of special compiler options to be applied to ! # all source modules in this extension. ! self.compilerOptions = [] ! # A list of .lib files the final .EXE will need. ! self.linkerLibs = [] ! def GetSourceFiles(self): ! return self.sourceFiles ! def AddCompilerOption(self, option): ! self.compilerOptions.append(option) ! def GetCompilerOptions(self): ! return self.compilerOptions ! def AddLinkerLib(self, lib): ! self.linkerLibs.append(lib) ! def GetLinkerLibs(self): ! return self.linkerLibs def checkextensions(unknown, extra_inis, prefix): ! # Create a table of frozen extensions ! defaultMapName = os.path.join( os.path.split(sys.argv[0])[0], "extensions_win32.ini") ! if not os.path.isfile(defaultMapName): ! sys.stderr.write("WARNING: %s can not be found - standard extensions may not be found\n" % defaultMapName) ! else: ! # must go on end, so other inis can override. ! extra_inis.append(defaultMapName) ! ret = [] ! for mod in unknown: ! for ini in extra_inis: ! # print "Looking for", mod, "in", win32api.GetFullPathName(ini),"...", ! defn = get_extension_defn( mod, ini, prefix ) ! if defn is not None: ! # print "Yay - found it!" ! ret.append( defn ) ! break ! # print "Nope!" ! else: # For not broken! ! sys.stderr.write("No definition of module %s in any specified map file.\n" % (mod)) ! ! return ret def get_extension_defn(moduleName, mapFileName, prefix): ! if win32api is None: return None ! os.environ['PYTHONPREFIX'] = prefix ! dsp = win32api.GetProfileVal(moduleName, "dsp", "", mapFileName) ! if dsp=="": ! return None ! # We allow environment variables in the file name ! dsp = win32api.ExpandEnvironmentStrings(dsp) ! # If the path to the .DSP file is not absolute, assume it is relative ! # to the description file. ! if not os.path.isabs(dsp): ! dsp = os.path.join( os.path.split(mapFileName)[0], dsp) ! # Parse it to extract the source files. ! sourceFiles = parse_dsp(dsp) ! if sourceFiles is None: ! return None ! module = CExtension(moduleName, sourceFiles) ! # Put the path to the DSP into the environment so entries can reference it. ! os.environ['dsp_path'] = os.path.split(dsp)[0] ! os.environ['ini_path'] = os.path.split(mapFileName)[0] ! cl_options = win32api.GetProfileVal(moduleName, "cl", "", mapFileName) ! if cl_options: ! module.AddCompilerOption(win32api.ExpandEnvironmentStrings(cl_options)) ! exclude = win32api.GetProfileVal(moduleName, "exclude", "", mapFileName) ! exclude = exclude.split() ! if win32api.GetProfileVal(moduleName, "Unicode", 0, mapFileName): ! module.AddCompilerOption('/D UNICODE /D _UNICODE') ! libs = win32api.GetProfileVal(moduleName, "libs", "", mapFileName).split() ! for lib in libs: ! module.AddLinkerLib(win32api.ExpandEnvironmentStrings(lib)) ! for exc in exclude: ! if exc in module.sourceFiles: ! modules.sourceFiles.remove(exc) ! return module # Given an MSVC DSP file, locate C source files it uses # returns a list of source files. def parse_dsp(dsp): ! # print "Processing", dsp ! # For now, only support ! ret = [] ! dsp_path, dsp_name = os.path.split(dsp) ! try: ! lines = open(dsp, "r").readlines() ! except IOError, msg: ! sys.stderr.write("%s: %s\n" % (dsp, msg)) ! return None ! for line in lines: ! fields = line.strip().split("=", 2) ! if fields[0]=="SOURCE": ! if os.path.splitext(fields[1])[1].lower() in ['.cpp', '.c']: ! ret.append( win32api.GetFullPathName(os.path.join(dsp_path, fields[1] ) ) ) ! return ret def write_extension_table(fname, modules): ! fp = open(fname, "w") ! try: ! fp.write (ext_src_header) ! # Write fn protos ! for module in modules: ! # bit of a hack for .pyd's as part of packages. ! name = module.name.split('.')[-1] ! fp.write('extern void init%s(void);\n' % (name) ) ! # Write the table ! fp.write (ext_tab_header) ! for module in modules: ! name = module.name.split('.')[-1] ! fp.write('\t{"%s", init%s},\n' % (name, name) ) ! fp.write (ext_tab_footer) ! fp.write(ext_src_footer) ! finally: ! fp.close() --- 25,164 ---- import os, sys try: ! import win32api except ImportError: ! win32api = None # User has already been warned class CExtension: ! """An abstraction of an extension implemented in C/C++ ! """ ! def __init__(self, name, sourceFiles): ! self.name = name ! # A list of strings defining additional compiler options. ! self.sourceFiles = sourceFiles ! # A list of special compiler options to be applied to ! # all source modules in this extension. ! self.compilerOptions = [] ! # A list of .lib files the final .EXE will need. ! self.linkerLibs = [] ! def GetSourceFiles(self): ! return self.sourceFiles ! def AddCompilerOption(self, option): ! self.compilerOptions.append(option) ! def GetCompilerOptions(self): ! return self.compilerOptions ! def AddLinkerLib(self, lib): ! self.linkerLibs.append(lib) ! def GetLinkerLibs(self): ! return self.linkerLibs def checkextensions(unknown, extra_inis, prefix): ! # Create a table of frozen extensions ! defaultMapName = os.path.join( os.path.split(sys.argv[0])[0], "extensions_win32.ini") ! if not os.path.isfile(defaultMapName): ! sys.stderr.write("WARNING: %s can not be found - standard extensions may not be found\n" % defaultMapName) ! else: ! # must go on end, so other inis can override. ! extra_inis.append(defaultMapName) ! ret = [] ! for mod in unknown: ! for ini in extra_inis: ! # print "Looking for", mod, "in", win32api.GetFullPathName(ini),"...", ! defn = get_extension_defn( mod, ini, prefix ) ! if defn is not None: ! # print "Yay - found it!" ! ret.append( defn ) ! break ! # print "Nope!" ! else: # For not broken! ! sys.stderr.write("No definition of module %s in any specified map file.\n" % (mod)) ! ! return ret def get_extension_defn(moduleName, mapFileName, prefix): ! if win32api is None: return None ! os.environ['PYTHONPREFIX'] = prefix ! dsp = win32api.GetProfileVal(moduleName, "dsp", "", mapFileName) ! if dsp=="": ! return None ! # We allow environment variables in the file name ! dsp = win32api.ExpandEnvironmentStrings(dsp) ! # If the path to the .DSP file is not absolute, assume it is relative ! # to the description file. ! if not os.path.isabs(dsp): ! dsp = os.path.join( os.path.split(mapFileName)[0], dsp) ! # Parse it to extract the source files. ! sourceFiles = parse_dsp(dsp) ! if sourceFiles is None: ! return None ! module = CExtension(moduleName, sourceFiles) ! # Put the path to the DSP into the environment so entries can reference it. ! os.environ['dsp_path'] = os.path.split(dsp)[0] ! os.environ['ini_path'] = os.path.split(mapFileName)[0] ! cl_options = win32api.GetProfileVal(moduleName, "cl", "", mapFileName) ! if cl_options: ! module.AddCompilerOption(win32api.ExpandEnvironmentStrings(cl_options)) ! exclude = win32api.GetProfileVal(moduleName, "exclude", "", mapFileName) ! exclude = exclude.split() ! if win32api.GetProfileVal(moduleName, "Unicode", 0, mapFileName): ! module.AddCompilerOption('/D UNICODE /D _UNICODE') ! libs = win32api.GetProfileVal(moduleName, "libs", "", mapFileName).split() ! for lib in libs: ! module.AddLinkerLib(win32api.ExpandEnvironmentStrings(lib)) ! for exc in exclude: ! if exc in module.sourceFiles: ! modules.sourceFiles.remove(exc) ! return module # Given an MSVC DSP file, locate C source files it uses # returns a list of source files. def parse_dsp(dsp): ! # print "Processing", dsp ! # For now, only support ! ret = [] ! dsp_path, dsp_name = os.path.split(dsp) ! try: ! lines = open(dsp, "r").readlines() ! except IOError, msg: ! sys.stderr.write("%s: %s\n" % (dsp, msg)) ! return None ! for line in lines: ! fields = line.strip().split("=", 2) ! if fields[0]=="SOURCE": ! if os.path.splitext(fields[1])[1].lower() in ['.cpp', '.c']: ! ret.append( win32api.GetFullPathName(os.path.join(dsp_path, fields[1] ) ) ) ! return ret def write_extension_table(fname, modules): ! fp = open(fname, "w") ! try: ! fp.write (ext_src_header) ! # Write fn protos ! for module in modules: ! # bit of a hack for .pyd's as part of packages. ! name = module.name.split('.')[-1] ! fp.write('extern void init%s(void);\n' % (name) ) ! # Write the table ! fp.write (ext_tab_header) ! for module in modules: ! name = module.name.split('.')[-1] ! fp.write('\t{"%s", init%s},\n' % (name, name) ) ! fp.write (ext_tab_footer) ! fp.write(ext_src_footer) ! finally: ! fp.close() *************** *** 183,190 **** int PyInitFrozenExtensions() { ! return PyImport_ExtendInittab(extensions); } """ - - --- 183,188 ---- int PyInitFrozenExtensions() { ! return PyImport_ExtendInittab(extensions); } """ Index: freeze.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/freeze/freeze.py,v retrieving revision 1.46 retrieving revision 1.47 diff -C2 -d -r1.46 -r1.47 *** freeze.py 8 May 2004 17:59:43 -0000 1.46 --- freeze.py 18 Jul 2004 06:02:04 -0000 1.47 *************** *** 58,64 **** params (note - quoting args in this file is NOT supported) ! -s subsystem: Specify the subsystem (For Windows only.); 'console' (default), 'windows', 'service' or 'com_dll' ! -w: Toggle Windows (NT or 95) behavior. (For debugging only -- on a win32 platform, win32 behavior --- 58,64 ---- params (note - quoting args in this file is NOT supported) ! -s subsystem: Specify the subsystem (For Windows only.); 'console' (default), 'windows', 'service' or 'com_dll' ! -w: Toggle Windows (NT or 95) behavior. (For debugging only -- on a win32 platform, win32 behavior *************** *** 66,70 **** -r prefix=f: Replace path prefix. ! Replace prefix with f in the source path references contained in the resulting binary. --- 66,70 ---- -r prefix=f: Replace path prefix. ! Replace prefix with f in the source path references contained in the resulting binary. *************** *** 336,340 **** except ValueError, why: usage(why) ! # Actual work starts here... --- 336,340 ---- except ValueError, why: usage(why) ! # Actual work starts here... *************** *** 344,348 **** path[0] = dir mf = modulefinder.ModuleFinder(path, debug, exclude, replace_paths) ! if win and subsystem=='service': # If a Windows service, then add the "built-in" module. --- 344,348 ---- path[0] = dir mf = modulefinder.ModuleFinder(path, debug, exclude, replace_paths) ! if win and subsystem=='service': # If a Windows service, then add the "built-in" module. *************** *** 412,416 **** # Do the windows thang... import checkextensions_win32 ! # Get a list of CExtension instances, each describing a module # (including its source files) frozen_extensions = checkextensions_win32.checkextensions( --- 412,416 ---- # Do the windows thang... import checkextensions_win32 ! # Get a list of CExtension instances, each describing a module # (including its source files) frozen_extensions = checkextensions_win32.checkextensions( Index: makeconfig.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/freeze/makeconfig.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** makeconfig.py 4 Apr 2002 16:15:41 -0000 1.6 --- makeconfig.py 18 Jul 2004 06:02:04 -0000 1.7 *************** *** 7,37 **** def makeconfig(infp, outfp, modules, with_ifdef=0): ! m1 = re.compile('-- ADDMODULE MARKER 1 --') ! m2 = re.compile('-- ADDMODULE MARKER 2 --') ! while 1: ! line = infp.readline() ! if not line: break ! outfp.write(line) ! if m1 and m1.search(line): ! m1 = None ! for mod in modules: ! if mod in never: ! continue ! if with_ifdef: ! outfp.write("#ifndef init%s\n"%mod) ! outfp.write('extern void init%s(void);\n' % mod) ! if with_ifdef: ! outfp.write("#endif\n") ! elif m2 and m2.search(line): ! m2 = None ! for mod in modules: ! if mod in never: ! continue ! outfp.write('\t{"%s", init%s},\n' % ! (mod, mod)) ! if m1: ! sys.stderr.write('MARKER 1 never found\n') ! elif m2: ! sys.stderr.write('MARKER 2 never found\n') --- 7,37 ---- def makeconfig(infp, outfp, modules, with_ifdef=0): ! m1 = re.compile('-- ADDMODULE MARKER 1 --') ! m2 = re.compile('-- ADDMODULE MARKER 2 --') ! while 1: ! line = infp.readline() ! if not line: break ! outfp.write(line) ! if m1 and m1.search(line): ! m1 = None ! for mod in modules: ! if mod in never: ! continue ! if with_ifdef: ! outfp.write("#ifndef init%s\n"%mod) ! outfp.write('extern void init%s(void);\n' % mod) ! if with_ifdef: ! outfp.write("#endif\n") ! elif m2 and m2.search(line): ! m2 = None ! for mod in modules: ! if mod in never: ! continue ! outfp.write('\t{"%s", init%s},\n' % ! (mod, mod)) ! if m1: ! sys.stderr.write('MARKER 1 never found\n') ! elif m2: ! sys.stderr.write('MARKER 2 never found\n') *************** *** 39,61 **** def test(): ! import sys ! if not sys.argv[3:]: ! print 'usage: python makeconfig.py config.c.in outputfile', ! print 'modulename ...' ! sys.exit(2) ! if sys.argv[1] == '-': ! infp = sys.stdin ! else: ! infp = open(sys.argv[1]) ! if sys.argv[2] == '-': ! outfp = sys.stdout ! else: ! outfp = open(sys.argv[2], 'w') ! makeconfig(infp, outfp, sys.argv[3:]) ! if outfp != sys.stdout: ! outfp.close() ! if infp != sys.stdin: ! infp.close() if __name__ == '__main__': ! test() --- 39,61 ---- def test(): ! import sys ! if not sys.argv[3:]: ! print 'usage: python makeconfig.py config.c.in outputfile', ! print 'modulename ...' ! sys.exit(2) ! if sys.argv[1] == '-': ! infp = sys.stdin ! else: ! infp = open(sys.argv[1]) ! if sys.argv[2] == '-': ! outfp = sys.stdout ! else: ! outfp = open(sys.argv[2], 'w') ! makeconfig(infp, outfp, sys.argv[3:]) ! if outfp != sys.stdout: ! outfp.close() ! if infp != sys.stdin: ! infp.close() if __name__ == '__main__': ! test() Index: makefreeze.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/freeze/makefreeze.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** makefreeze.py 12 Feb 2004 17:35:30 -0000 1.15 --- makefreeze.py 18 Jul 2004 06:02:04 -0000 1.16 *************** *** 20,24 **** main(int argc, char **argv) { ! extern int Py_FrozenMain(int, char **); """ + ((not __debug__ and """ Py_OptimizeFlag++; --- 20,24 ---- main(int argc, char **argv) { ! extern int Py_FrozenMain(int, char **); """ + ((not __debug__ and """ Py_OptimizeFlag++; Index: makemakefile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/freeze/makemakefile.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** makemakefile.py 11 Sep 2002 20:36:00 -0000 1.7 --- makemakefile.py 18 Jul 2004 06:02:04 -0000 1.8 *************** *** 24,28 **** outfp.write("\n%s: %s\n" % (target, ' '.join(deps))) ! outfp.write("\t$(LINKCC) $(LDFLAGS) $(LINKFORSHARED) %s -o %s $(LDLAST)\n" % (' '.join(files), target)) --- 24,28 ---- outfp.write("\n%s: %s\n" % (target, ' '.join(deps))) ! outfp.write("\t$(LINKCC) $(LDFLAGS) $(LINKFORSHARED) %s -o %s $(LDLAST)\n" % (' '.join(files), target)) Index: parsesetup.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/freeze/parsesetup.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** parsesetup.py 11 Sep 2002 20:36:00 -0000 1.4 --- parsesetup.py 18 Jul 2004 06:02:04 -0000 1.5 *************** *** 11,40 **** def getmakevars(filename): ! variables = {} ! fp = open(filename) ! pendingline = "" ! try: ! while 1: ! line = fp.readline() ! if pendingline: ! line = pendingline + line ! pendingline = "" ! if not line: ! break ! if line.endswith('\\\n'): ! pendingline = line[:-2] ! matchobj = makevardef.match(line) ! if not matchobj: ! continue ! (name, value) = matchobj.group(1, 2) ! # Strip trailing comment ! i = value.find('#') ! if i >= 0: ! value = value[:i] ! value = value.strip() ! variables[name] = value ! finally: ! fp.close() ! return variables --- 11,40 ---- def getmakevars(filename): ! variables = {} ! fp = open(filename) ! pendingline = "" ! try: ! while 1: ! line = fp.readline() ! if pendingline: ! line = pendingline + line ! pendingline = "" ! if not line: ! break ! if line.endswith('\\\n'): ! pendingline = line[:-2] ! matchobj = makevardef.match(line) ! if not matchobj: ! continue ! (name, value) = matchobj.group(1, 2) ! # Strip trailing comment ! i = value.find('#') ! if i >= 0: ! value = value[:i] ! value = value.strip() ! variables[name] = value ! finally: ! fp.close() ! return variables *************** *** 47,80 **** def getsetupinfo(filename): ! modules = {} ! variables = {} ! fp = open(filename) ! pendingline = "" ! try: ! while 1: ! line = fp.readline() ! if pendingline: ! line = pendingline + line ! pendingline = "" ! if not line: ! break ! # Strip comments ! i = line.find('#') ! if i >= 0: ! line = line[:i] ! if line.endswith('\\\n'): ! pendingline = line[:-2] ! continue ! matchobj = setupvardef.match(line) ! if matchobj: ! (name, value) = matchobj.group(1, 2) ! variables[name] = value.strip() ! else: ! words = line.split() ! if words: ! modules[words[0]] = words[1:] ! finally: ! fp.close() ! return modules, variables --- 47,80 ---- def getsetupinfo(filename): ! modules = {} ! variables = {} ! fp = open(filename) ! pendingline = "" ! try: ! while 1: ! line = fp.readline() ! if pendingline: ! line = pendingline + line ! pendingline = "" ! if not line: ! break ! # Strip comments ! i = line.find('#') ! if i >= 0: ! line = line[:i] ! if line.endswith('\\\n'): ! pendingline = line[:-2] ! continue ! matchobj = setupvardef.match(line) ! if matchobj: ! (name, value) = matchobj.group(1, 2) ! variables[name] = value.strip() ! else: ! words = line.split() ! if words: ! modules[words[0]] = words[1:] ! finally: ! fp.close() ! return modules, variables *************** *** 82,112 **** def test(): ! import sys ! import os ! if not sys.argv[1:]: ! print 'usage: python parsesetup.py Makefile*|Setup* ...' ! sys.exit(2) ! for arg in sys.argv[1:]: ! base = os.path.basename(arg) ! if base[:8] == 'Makefile': ! print 'Make style parsing:', arg ! v = getmakevars(arg) ! prdict(v) ! elif base[:5] == 'Setup': ! print 'Setup style parsing:', arg ! m, v = getsetupinfo(arg) ! prdict(m) ! prdict(v) ! else: ! print arg, 'is neither a Makefile nor a Setup file' ! print '(name must begin with "Makefile" or "Setup")' def prdict(d): ! keys = d.keys() ! keys.sort() ! for key in keys: ! value = d[key] ! print "%-15s" % key, str(value) if __name__ == '__main__': ! test() --- 82,112 ---- def test(): ! import sys ! import os ! if not sys.argv[1:]: ! print 'usage: python parsesetup.py Makefile*|Setup* ...' ! sys.exit(2) ! for arg in sys.argv[1:]: ! base = os.path.basename(arg) ! if base[:8] == 'Makefile': ! print 'Make style parsing:', arg ! v = getmakevars(arg) ! prdict(v) ! elif base[:5] == 'Setup': ! print 'Setup style parsing:', arg ! m, v = getsetupinfo(arg) ! prdict(m) ! prdict(v) ! else: ! print arg, 'is neither a Makefile nor a Setup file' ! print '(name must begin with "Makefile" or "Setup")' def prdict(d): ! keys = d.keys() ! keys.sort() ! for key in keys: ! value = d[key] ! print "%-15s" % key, str(value) if __name__ == '__main__': ! test() From tim_one at users.sourceforge.net Sun Jul 18 08:02:35 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 08:02:38 2004 Subject: [Python-checkins] python/dist/src/Tools/framer example.py,1.1,1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Tools/framer In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29862/framer Modified Files: example.py Log Message: Whitespace normalization, via reindent.py. Index: example.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/framer/example.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** example.py 5 Aug 2002 18:29:45 -0000 1.1 --- example.py 18 Jul 2004 06:02:03 -0000 1.2 *************** *** 12,16 **** applications and is especially useful in conjunction with the pickle module. ! Usage: --- 12,16 ---- applications and is especially useful in conjunction with the pickle module. ! Usage: *************** *** 21,25 **** ... value = an_output_stream.getvalue() ! an_input_stream = StringIO(a_string) spam = an_input_stream.readline() --- 21,25 ---- ... value = an_output_stream.getvalue() ! an_input_stream = StringIO(a_string) spam = an_input_stream.readline() *************** *** 37,41 **** class InputType(Type): "Simple type for treating strings as input file streams" ! abbrev = "input" --- 37,41 ---- class InputType(Type): "Simple type for treating strings as input file streams" ! abbrev = "input" *************** *** 122,127 **** def writelines(self, lines): """Write each string in lines.""" - - cStringIO.gen() --- 122,126 ---- def writelines(self, lines): """Write each string in lines.""" + cStringIO.gen() From tim_one at users.sourceforge.net Sun Jul 18 08:02:35 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 08:02:40 2004 Subject: [Python-checkins] python/dist/src/Tools/faqwiz faqconf.py, 1.25, 1.26 faqwiz.py, 1.29, 1.30 Message-ID: Update of /cvsroot/python/python/dist/src/Tools/faqwiz In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29862/faqwiz Modified Files: faqconf.py faqwiz.py Log Message: Whitespace normalization, via reindent.py. Index: faqconf.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/faqwiz/faqconf.py,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** faqconf.py 24 Oct 2003 20:09:23 -0000 1.25 --- faqconf.py 18 Jul 2004 06:02:02 -0000 1.26 *************** *** 31,39 **** # (28*24*3600 = 28 days = 4 weeks) PROCESS_PREFORMAT = 1 # toggle whether preformatted text ! # will replace urls and emails with # HTML links # Markers appended to title to indicate recently change ! # (may contain HTML, e.g. ); and corresponding MARK_VERY_RECENT = " **" # Changed very recently --- 31,39 ---- # (28*24*3600 = 28 days = 4 weeks) PROCESS_PREFORMAT = 1 # toggle whether preformatted text ! # will replace urls and emails with # HTML links # Markers appended to title to indicate recently change ! # (may contain HTML, e.g. ); and corresponding MARK_VERY_RECENT = " **" # Changed very recently Index: faqwiz.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/faqwiz/faqwiz.py,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** faqwiz.py 12 Feb 2004 17:35:14 -0000 1.29 --- faqwiz.py 18 Jul 2004 06:02:02 -0000 1.30 *************** *** 584,588 **** import random files = self.dir.list() ! if not files: self.error("No entries.") return --- 584,588 ---- import random files = self.dir.list() ! if not files: self.error("No entries.") return *************** *** 733,737 **** return commit_ok = ((not PASSWORD ! or self.ui.password == PASSWORD) and self.ui.author and '@' in self.ui.email --- 733,737 ---- return commit_ok = ((not PASSWORD ! or self.ui.password == PASSWORD) and self.ui.author and '@' in self.ui.email *************** *** 821,825 **** log("done: " + str(sts)) log("TempFile:\n" + tf.read() + "end") ! if not sts: self.prologue(T_COMMITTED) --- 821,825 ---- log("done: " + str(sts)) log("TempFile:\n" + tf.read() + "end") ! if not sts: self.prologue(T_COMMITTED) From tim_one at users.sourceforge.net Sun Jul 18 08:02:36 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 08:02:41 2004 Subject: [Python-checkins] python/dist/src/Tools/compiler astgen.py, 1.6, 1.7 compile.py, 1.7, 1.8 demo.py, 1.1, 1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Tools/compiler In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29862/compiler Modified Files: astgen.py compile.py demo.py Log Message: Whitespace normalization, via reindent.py. Index: astgen.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/compiler/astgen.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** astgen.py 17 Sep 2001 20:16:30 -0000 1.6 --- astgen.py 18 Jul 2004 06:02:02 -0000 1.7 *************** *** 89,93 **** self.args = self.args.replace('!', '') self.args = self.args.replace('&', '') ! return d --- 89,93 ---- self.args = self.args.replace('!', '') self.args = self.args.replace('&', '') ! return d *************** *** 159,163 **** for name in self.argnames: if self.argprops[name] == P_NONE: ! tmp = (" if self.%s is not None:" " nodes.append(self.%s)") print >> buf, tmp % (name, name) --- 159,163 ---- for name in self.argnames: if self.argprops[name] == P_NONE: ! tmp = (" if self.%s is not None:" " nodes.append(self.%s)") print >> buf, tmp % (name, name) Index: compile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/compiler/compile.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** compile.py 12 Feb 2004 17:35:14 -0000 1.7 --- compile.py 18 Jul 2004 06:02:02 -0000 1.8 *************** *** 40,44 **** else: compileFile(filename, DISPLAY) ! except SyntaxError, err: print err --- 40,44 ---- else: compileFile(filename, DISPLAY) ! except SyntaxError, err: print err Index: demo.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/compiler/demo.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** demo.py 25 Jul 2000 16:43:23 -0000 1.1 --- demo.py 18 Jul 2004 06:02:02 -0000 1.2 *************** *** 15,19 **** scope. The scope is the name of the current class or None. """ ! def visitClass(self, node, scope=None): self.visit(node.code, node.name) --- 15,19 ---- scope. The scope is the name of the current class or None. """ ! def visitClass(self, node, scope=None): self.visit(node.code, node.name) *************** *** 23,27 **** print "%s.%s" % (scope, node.name) self.visit(node.code, None) ! def main(files): mf = MethodFinder() --- 23,27 ---- print "%s.%s" % (scope, node.name) self.visit(node.code, None) ! def main(files): mf = MethodFinder() *************** *** 35,38 **** if __name__ == "__main__": import sys ! main(sys.argv[1:]) --- 35,38 ---- if __name__ == "__main__": import sys ! main(sys.argv[1:]) From tim_one at users.sourceforge.net Sun Jul 18 08:02:36 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 08:02:43 2004 Subject: [Python-checkins] python/dist/src/Tools/bgen/bgen bgenBuffer.py, 1.8, 1.9 bgenGenerator.py, 1.15, 1.16 bgenHeapBuffer.py, 1.4, 1.5 bgenModule.py, 1.12, 1.13 bgenObjectDefinition.py, 1.26, 1.27 bgenOutput.py, 1.6, 1.7 bgenStringBuffer.py, 1.2, 1.3 bgenType.py, 1.11, 1.12 macsupport.py, 1.30, 1.31 scantools.py, 1.34, 1.35 Message-ID: Update of /cvsroot/python/python/dist/src/Tools/bgen/bgen In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29862/bgen/bgen Modified Files: bgenBuffer.py bgenGenerator.py bgenHeapBuffer.py bgenModule.py bgenObjectDefinition.py bgenOutput.py bgenStringBuffer.py bgenType.py macsupport.py scantools.py Log Message: Whitespace normalization, via reindent.py. Index: bgenBuffer.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/bgen/bgen/bgenBuffer.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** bgenBuffer.py 19 Jan 2003 21:53:55 -0000 1.8 --- bgenBuffer.py 18 Jul 2004 06:02:01 -0000 1.9 *************** *** 28,32 **** class FixedInputOutputBufferType(InputOnlyType): ! """Fixed buffer -- passed as (inbuffer, outbuffer).""" --- 28,32 ---- class FixedInputOutputBufferType(InputOnlyType): ! """Fixed buffer -- passed as (inbuffer, outbuffer).""" *************** *** 42,53 **** self.declareBuffer(name) self.declareSize(name) ! def declareBuffer(self, name): self.declareInputBuffer(name) self.declareOutputBuffer(name) ! def declareInputBuffer(self, name): Output("%s *%s__in__;", self.datatype, name) ! def declareOutputBuffer(self, name): Output("%s %s__out__[%s];", self.datatype, name, self.size) --- 42,53 ---- self.declareBuffer(name) self.declareSize(name) ! def declareBuffer(self, name): self.declareInputBuffer(name) self.declareOutputBuffer(name) ! def declareInputBuffer(self, name): Output("%s *%s__in__;", self.datatype, name) ! def declareOutputBuffer(self, name): Output("%s %s__out__[%s];", self.datatype, name, self.size) *************** *** 62,66 **** def getargsArgs(self, name): return "&%s__in__, &%s__in_len__" % (name, name) ! def getargsCheck(self, name): Output("if (%s__in_len__ != %s)", name, self.size) --- 62,66 ---- def getargsArgs(self, name): return "&%s__in__, &%s__in_len__" % (name, name) ! def getargsCheck(self, name): Output("if (%s__in_len__ != %s)", name, self.size) *************** *** 72,76 **** OutRbrace() self.transferSize(name) ! def transferSize(self, name): Output("%s__len__ = %s__in_len__;", name, name) --- 72,76 ---- OutRbrace() self.transferSize(name) ! def transferSize(self, name): Output("%s__len__ = %s__in_len__;", name, name) *************** *** 78,82 **** def passOutput(self, name): return "%s__in__, %s__out__" % (name, name) ! def mkvalueFormat(self): return "s#" --- 78,82 ---- def passOutput(self, name): return "%s__in__, %s__out__" % (name, name) ! def mkvalueFormat(self): return "s#" *************** *** 84,88 **** def mkvalueArgs(self, name): return "%s__out__, (int)%s" % (name, self.size) ! def cleanup(self, name): if self.label_needed: --- 84,88 ---- def mkvalueArgs(self, name): return "%s__out__, (int)%s" % (name, self.size) ! def cleanup(self, name): if self.label_needed: *************** *** 93,99 **** class FixedCombinedInputOutputBufferType(FixedInputOutputBufferType): ! """Like fixed buffer -- but same parameter is input and output.""" ! def passOutput(self, name): return "(%s *)memcpy(%s__out__, %s__in__, %s)" % \ --- 93,99 ---- class FixedCombinedInputOutputBufferType(FixedInputOutputBufferType): ! """Like fixed buffer -- but same parameter is input and output.""" ! def passOutput(self, name): return "(%s *)memcpy(%s__out__, %s__in__, %s)" % \ *************** *** 113,120 **** class OptionalInputBufferMixIn: ! """Add to input buffers if the buffer may be omitted: pass None in Python and the C code will get a NULL pointer and zero size""" ! def getargsFormat(self): return "z#" --- 113,120 ---- class OptionalInputBufferMixIn: ! """Add to input buffers if the buffer may be omitted: pass None in Python and the C code will get a NULL pointer and zero size""" ! def getargsFormat(self): return "z#" *************** *** 148,208 **** """Variable size input buffer -- passed as (buffer, size). ! Instantiate without size parameter. """ ! def __init__(self, datatype = 'char', sizetype = 'int', sizeformat = None): FixedInputBufferType.__init__(self, "0", datatype, sizetype, sizeformat) ! def getargsCheck(self, name): Output("%s__len__ = %s__in_len__;", name, name) ! def passInput(self, name): return "%s__in__, %s__len__" % (name, name) ! class ReverseInputBufferMixin: """ Mixin for input buffers that are passed as (size, buffer) """ ! def passInput(self, name): return "%s__len__, %s__in__" % (name, name) ! class OptionalVarInputBufferType(OptionalInputBufferMixIn, VarInputBufferType): pass ! # ----- PART 2: Structure buffers ----- class StructInputOutputBufferType(FixedInputOutputBufferType): ! """Structure buffer -- passed as a structure pointer. Instantiate with the struct type as parameter. """ ! def __init__(self, type): FixedInputOutputBufferType.__init__(self, "sizeof(%s)" % type) self.typeName = self.type = type ! def declareInputBuffer(self, name): Output("%s *%s__in__;", self.type, name) ! def declareSize(self, name): Output("int %s__in_len__;", name) ! def declareOutputBuffer(self, name): Output("%s %s__out__;", self.type, name) ! def getargsArgs(self, name): return "(char **)&%s__in__, &%s__in_len__" % (name, name) ! def transferSize(self, name): pass ! def passInput(self, name): return "%s__in__" % name ! def passOutput(self, name): return "%s__in__, &%s__out__" % (name, name) ! def mkvalueArgs(self, name): return "(char *)&%s__out__, (int)%s" % (name, self.size) --- 148,208 ---- """Variable size input buffer -- passed as (buffer, size). ! Instantiate without size parameter. """ ! def __init__(self, datatype = 'char', sizetype = 'int', sizeformat = None): FixedInputBufferType.__init__(self, "0", datatype, sizetype, sizeformat) ! def getargsCheck(self, name): Output("%s__len__ = %s__in_len__;", name, name) ! def passInput(self, name): return "%s__in__, %s__len__" % (name, name) ! class ReverseInputBufferMixin: """ Mixin for input buffers that are passed as (size, buffer) """ ! def passInput(self, name): return "%s__len__, %s__in__" % (name, name) ! class OptionalVarInputBufferType(OptionalInputBufferMixIn, VarInputBufferType): pass ! # ----- PART 2: Structure buffers ----- class StructInputOutputBufferType(FixedInputOutputBufferType): ! """Structure buffer -- passed as a structure pointer. Instantiate with the struct type as parameter. """ ! def __init__(self, type): FixedInputOutputBufferType.__init__(self, "sizeof(%s)" % type) self.typeName = self.type = type ! def declareInputBuffer(self, name): Output("%s *%s__in__;", self.type, name) ! def declareSize(self, name): Output("int %s__in_len__;", name) ! def declareOutputBuffer(self, name): Output("%s %s__out__;", self.type, name) ! def getargsArgs(self, name): return "(char **)&%s__in__, &%s__in_len__" % (name, name) ! def transferSize(self, name): pass ! def passInput(self, name): return "%s__in__" % name ! def passOutput(self, name): return "%s__in__, &%s__out__" % (name, name) ! def mkvalueArgs(self, name): return "(char *)&%s__out__, (int)%s" % (name, self.size) *************** *** 212,216 **** """Like structure buffer -- but same parameter is input and output.""" ! def passOutput(self, name): return "(%s *)memcpy((char *)%s__out__, (char *)%s__in__, %s)" % \ --- 212,216 ---- """Like structure buffer -- but same parameter is input and output.""" ! def passOutput(self, name): return "(%s *)memcpy((char *)%s__out__, (char *)%s__in__, %s)" % \ *************** *** 243,247 **** Instantiate with the struct type as parameter. """ ! def declareSize(self, name): pass --- 243,247 ---- Instantiate with the struct type as parameter. """ ! def declareSize(self, name): pass *************** *** 257,261 **** Instantiate with the struct type as parameter. """ ! def declareSize(self, name): pass --- 257,261 ---- Instantiate with the struct type as parameter. """ ! def declareSize(self, name): pass Index: bgenGenerator.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/bgen/bgen/bgenGenerator.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** bgenGenerator.py 19 Jan 2003 21:53:56 -0000 1.15 --- bgenGenerator.py 18 Jul 2004 06:02:01 -0000 1.16 *************** *** 56,60 **** if self.condition: Output() ! Output(self.condition) Output("{\"%s\", (PyCFunction)%s_%s, 1,", name, self.prefix, self.name) Output(" PyDoc_STR(%s)},", stringify(docstring)) --- 56,60 ---- if self.condition: Output() ! Output(self.condition) Output("{\"%s\", (PyCFunction)%s_%s, 1,", name, self.prefix, self.name) Output(" PyDoc_STR(%s)},", stringify(docstring)) *************** *** 92,96 **** def functionbody(self): Output("%s", self.body) ! def setselftype(self, selftype, itselftype): self.objecttype = selftype --- 92,96 ---- def functionbody(self): Output("%s", self.body) ! def setselftype(self, selftype, itselftype): self.objecttype = selftype *************** *** 115,119 **** else: self.rv = None ! def makereturnvar(self): return Variable(self.returntype, "_rv", OutMode) --- 115,119 ---- else: self.rv = None ! def makereturnvar(self): return Variable(self.returntype, "_rv", OutMode) *************** *** 130,134 **** arg = Variable(type, name, mode) self.argumentList.append(arg) ! def docstring(self): input = [] --- 130,134 ---- arg = Variable(type, name, mode) self.argumentList.append(arg) ! def docstring(self): input = [] *************** *** 147,151 **** typeName = "?" print "Nameless type", arg.type ! str = typeName + ' ' + arg.name if arg.mode in (InMode, InOutMode): --- 147,151 ---- typeName = "?" print "Nameless type", arg.type ! str = typeName + ' ' + arg.name if arg.mode in (InMode, InOutMode): *************** *** 162,166 **** outstr = "(%s)" % ", ".join(output) return instr + " -> " + outstr ! def functionbody(self): self.declarations() --- 162,166 ---- outstr = "(%s)" % ", ".join(output) return instr + " -> " + outstr ! def functionbody(self): self.declarations() *************** *** 196,200 **** if arg.mode in (InMode, InOutMode): arg.getargsCheck() ! def precheck(self): pass --- 196,200 ---- if arg.mode in (InMode, InOutMode): arg.getargsCheck() ! def precheck(self): pass Index: bgenHeapBuffer.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/bgen/bgen/bgenHeapBuffer.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** bgenHeapBuffer.py 19 Jan 2003 21:53:56 -0000 1.4 --- bgenHeapBuffer.py 18 Jul 2004 06:02:01 -0000 1.5 *************** *** 44,48 **** """same as base class, but passed as (inbuffer, outbuffer, &size)""" ! def passOutput(self, name): return "%s__in__, %s__out__, &%s__len__" % (name, name, name) --- 44,48 ---- """same as base class, but passed as (inbuffer, outbuffer, &size)""" ! def passOutput(self, name): return "%s__in__, %s__out__, &%s__len__" % (name, name, name) *************** *** 52,56 **** """same as base class, but passed as (inoutbuffer, size)""" ! def passOutput(self, name): return "(%s *)memcpy(%s__out__, %s__in__, %s__len__)" % \ --- 52,56 ---- """same as base class, but passed as (inoutbuffer, size)""" ! def passOutput(self, name): return "(%s *)memcpy(%s__out__, %s__in__, %s__len__)" % \ *************** *** 61,65 **** """same as base class, but passed as (inoutbuffer, &size)""" ! def passOutput(self, name): return "(%s *)memcpy(%s__out__, %s__in__, &%s__len__)" % \ --- 61,65 ---- """same as base class, but passed as (inoutbuffer, &size)""" ! def passOutput(self, name): return "(%s *)memcpy(%s__out__, %s__in__, &%s__len__)" % \ *************** *** 74,87 **** Call from Python with buffer size. """ ! def declareInputBuffer(self, name): pass ! def getargsFormat(self): return "i" ! def getargsArgs(self, name): return "&%s__in_len__" % name ! def passOutput(self, name): return "%s__out__, %s__len__" % (name, name) --- 74,87 ---- Call from Python with buffer size. """ ! def declareInputBuffer(self, name): pass ! def getargsFormat(self): return "i" ! def getargsArgs(self, name): return "&%s__in_len__" % name ! def passOutput(self, name): return "%s__out__, %s__len__" % (name, name) Index: bgenModule.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/bgen/bgen/bgenModule.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** bgenModule.py 19 Jan 2003 21:53:56 -0000 1.12 --- bgenModule.py 18 Jul 2004 06:02:01 -0000 1.13 *************** *** 39,43 **** GeneratorGroup.generate(self) ! if self.finalstuff: Output() --- 39,43 ---- GeneratorGroup.generate(self) ! if self.finalstuff: Output() Index: bgenObjectDefinition.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/bgen/bgen/bgenObjectDefinition.py,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** bgenObjectDefinition.py 15 Jul 2004 21:24:07 -0000 1.26 --- bgenObjectDefinition.py 18 Jul 2004 06:02:01 -0000 1.27 *************** *** 10,21 **** def __init__(self, name, prefix, itselftype): """ObjectDefinition constructor. May be extended, but do not override. ! - name: the object's official name, e.g. 'SndChannel'. - prefix: the prefix used for the object's functions and data, e.g. 'SndCh'. - itselftype: the C type actually contained in the object, e.g. 'SndChannelPtr'. ! XXX For official Python data types, rules for the 'Py' prefix are a problem. """ ! GeneratorGroup.__init__(self, prefix or name) self.name = name --- 10,21 ---- def __init__(self, name, prefix, itselftype): """ObjectDefinition constructor. May be extended, but do not override. ! - name: the object's official name, e.g. 'SndChannel'. - prefix: the prefix used for the object's functions and data, e.g. 'SndCh'. - itselftype: the C type actually contained in the object, e.g. 'SndChannelPtr'. ! XXX For official Python data types, rules for the 'Py' prefix are a problem. """ ! GeneratorGroup.__init__(self, prefix or name) self.name = name *************** *** 36,40 **** # In case we are referenced from a module pass ! def setmodulename(self, name): self.modulename = name --- 36,40 ---- # In case we are referenced from a module pass ! def setmodulename(self, name): self.modulename = name *************** *** 59,63 **** self.outputNew() ! self.outputConvert() --- 59,63 ---- self.outputNew() ! self.outputConvert() *************** *** 72,88 **** self.outputSetattr() ! self.outputCompare() ! self.outputRepr() ! self.outputHash() ! self.outputPEP253Hooks() ! self.outputTypeObject() OutHeader2("End object type " + self.name) ! def outputMethodChain(self): Output("%sPyMethodChain %s_chain = { %s_methods, %s };", --- 72,88 ---- self.outputSetattr() ! self.outputCompare() ! self.outputRepr() ! self.outputHash() ! self.outputPEP253Hooks() ! self.outputTypeObject() OutHeader2("End object type " + self.name) ! def outputMethodChain(self): Output("%sPyMethodChain %s_chain = { %s_methods, %s };", *************** *** 109,116 **** def outputInitStructMembers(self): Output("it->ob_itself = %sitself;", self.argref) ! def outputCheckNewArg(self): ! "Override this method to apply additional checks/conversions" ! def outputConvert(self): Output("%sint %s_Convert(PyObject *v, %s *p_itself)", self.static, self.prefix, --- 109,116 ---- def outputInitStructMembers(self): Output("it->ob_itself = %sitself;", self.argref) ! def outputCheckNewArg(self): ! "Override this method to apply additional checks/conversions" ! def outputConvert(self): Output("%sint %s_Convert(PyObject *v, %s *p_itself)", self.static, self.prefix, *************** *** 207,211 **** DedentLevel() Output("};") ! def outputTypeObjectInitializer(self): Output("""%s.ob_type = &PyType_Type;""", self.typename) --- 207,211 ---- DedentLevel() Output("};") ! def outputTypeObjectInitializer(self): Output("""%s.ob_type = &PyType_Type;""", self.typename) *************** *** 221,228 **** def outputPEP253Hooks(self): pass ! class PEP252Mixin: getsetlist = [] ! def assertions(self): # Check that various things aren't overridden. If they are it could --- 221,228 ---- def outputPEP253Hooks(self): pass ! class PEP252Mixin: getsetlist = [] ! def assertions(self): # Check that various things aren't overridden. If they are it could *************** *** 233,240 **** assert self.outputGetattrHook == None assert self.basechain == "NULL" ! def outputGetattr(self): pass ! outputGetattrBody = None --- 233,240 ---- assert self.outputGetattrHook == None assert self.basechain == "NULL" ! def outputGetattr(self): pass ! outputGetattrBody = None *************** *** 243,251 **** def outputSetattr(self): pass ! def outputMethodChain(self): # This is a good place to output the getters and setters self.outputGetSetList() ! def outputHook(self, name): methodname = "outputHook_" + name --- 243,251 ---- def outputSetattr(self): pass ! def outputMethodChain(self): # This is a good place to output the getters and setters self.outputGetSetList() ! def outputHook(self, name): methodname = "outputHook_" + name *************** *** 255,259 **** else: Output("0, /*%s*/", name) ! def outputTypeObject(self): sf = self.static and "static " --- 255,259 ---- else: Output("0, /*%s*/", name) ! def outputTypeObject(self): sf = self.static and "static " *************** *** 269,273 **** Output("sizeof(%s), /*tp_basicsize*/", self.objecttype) Output("0, /*tp_itemsize*/") ! Output("/* methods */") Output("(destructor) %s_dealloc, /*tp_dealloc*/", self.prefix) --- 269,273 ---- Output("sizeof(%s), /*tp_basicsize*/", self.objecttype) Output("0, /*tp_itemsize*/") ! Output("/* methods */") Output("(destructor) %s_dealloc, /*tp_dealloc*/", self.prefix) *************** *** 277,285 **** Output("(cmpfunc) %s_compare, /*tp_compare*/", self.prefix) Output("(reprfunc) %s_repr, /*tp_repr*/", self.prefix) ! Output("(PyNumberMethods *)0, /* tp_as_number */") Output("(PySequenceMethods *)0, /* tp_as_sequence */") Output("(PyMappingMethods *)0, /* tp_as_mapping */") ! Output("(hashfunc) %s_hash, /*tp_hash*/", self.prefix) self.outputHook("tp_call") --- 277,285 ---- Output("(cmpfunc) %s_compare, /*tp_compare*/", self.prefix) Output("(reprfunc) %s_repr, /*tp_repr*/", self.prefix) ! Output("(PyNumberMethods *)0, /* tp_as_number */") Output("(PySequenceMethods *)0, /* tp_as_sequence */") Output("(PyMappingMethods *)0, /* tp_as_mapping */") ! Output("(hashfunc) %s_hash, /*tp_hash*/", self.prefix) self.outputHook("tp_call") *************** *** 287,291 **** Output("PyObject_GenericGetAttr, /*tp_getattro*/") Output("PyObject_GenericSetAttr, /*tp_setattro */") ! self.outputHook("tp_as_buffer") Output("%s, /* tp_flags */", self.tp_flags) --- 287,291 ---- Output("PyObject_GenericGetAttr, /*tp_getattro*/") Output("PyObject_GenericSetAttr, /*tp_setattro */") ! self.outputHook("tp_as_buffer") Output("%s, /* tp_flags */", self.tp_flags) *************** *** 311,315 **** DedentLevel() Output("};") ! def outputGetSetList(self): if self.getsetlist: --- 311,315 ---- DedentLevel() Output("};") ! def outputGetSetList(self): if self.getsetlist: *************** *** 325,329 **** Output("#define %s_set_%s NULL", self.prefix, name) Output() ! Output("static PyGetSetDef %s_getsetlist[] = {", self.prefix) IndentLevel() --- 325,329 ---- Output("#define %s_set_%s NULL", self.prefix, name) Output() ! Output("static PyGetSetDef %s_getsetlist[] = {", self.prefix) IndentLevel() *************** *** 333,337 **** else: doc = "NULL" ! Output("{\"%s\", (getter)%s_get_%s, (setter)%s_set_%s, %s},", name, self.prefix, name, self.prefix, name, doc) Output("{NULL, NULL, NULL, NULL},") --- 333,337 ---- else: doc = "NULL" ! Output("{\"%s\", (getter)%s_get_%s, (setter)%s_set_%s, %s},", name, self.prefix, name, self.prefix, name, doc) Output("{NULL, NULL, NULL, NULL},") *************** *** 341,345 **** Output("#define %s_getsetlist NULL", self.prefix) Output() ! def outputGetter(self, name, code): Output("static PyObject *%s_get_%s(%s *self, void *closure)", --- 341,345 ---- Output("#define %s_getsetlist NULL", self.prefix) Output() ! def outputGetter(self, name, code): Output("static PyObject *%s_get_%s(%s *self, void *closure)", *************** *** 349,353 **** OutRbrace() Output() ! def outputSetter(self, name, code): Output("static int %s_set_%s(%s *self, PyObject *v, void *closure)", --- 349,353 ---- OutRbrace() Output() ! def outputSetter(self, name, code): Output("static int %s_set_%s(%s *self, PyObject *v, void *closure)", *************** *** 358,379 **** OutRbrace() Output() ! class PEP253Mixin(PEP252Mixin): tp_flags = "Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE" ! def outputHook_tp_init(self): Output("%s_tp_init, /* tp_init */", self.prefix) ! def outputHook_tp_alloc(self): Output("%s_tp_alloc, /* tp_alloc */", self.prefix) ! def outputHook_tp_new(self): Output("%s_tp_new, /* tp_new */", self.prefix) ! def outputHook_tp_free(self): Output("%s_tp_free, /* tp_free */", self.prefix) ! output_tp_initBody = None ! def output_tp_init(self): if self.output_tp_initBody: --- 358,379 ---- OutRbrace() Output() ! class PEP253Mixin(PEP252Mixin): tp_flags = "Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE" ! def outputHook_tp_init(self): Output("%s_tp_init, /* tp_init */", self.prefix) ! def outputHook_tp_alloc(self): Output("%s_tp_alloc, /* tp_alloc */", self.prefix) ! def outputHook_tp_new(self): Output("%s_tp_new, /* tp_new */", self.prefix) ! def outputHook_tp_free(self): Output("%s_tp_free, /* tp_free */", self.prefix) ! output_tp_initBody = None ! def output_tp_init(self): if self.output_tp_initBody: *************** *** 385,391 **** Output("#define %s_tp_init 0", self.prefix) Output() ! output_tp_allocBody = None ! def output_tp_alloc(self): if self.output_tp_allocBody: --- 385,391 ---- Output("#define %s_tp_init 0", self.prefix) Output() ! output_tp_allocBody = None ! def output_tp_alloc(self): if self.output_tp_allocBody: *************** *** 398,402 **** Output("#define %s_tp_alloc PyType_GenericAlloc", self.prefix) Output() ! def output_tp_newBody(self): Output("PyObject *self;"); --- 398,402 ---- Output("#define %s_tp_alloc PyType_GenericAlloc", self.prefix) Output() ! def output_tp_newBody(self): Output("PyObject *self;"); *************** *** 409,413 **** Output("((%s *)self)->ob_itself = itself;", self.objecttype) Output("return self;") ! def output_tp_new(self): if self.output_tp_newBody: --- 409,413 ---- Output("((%s *)self)->ob_itself = itself;", self.objecttype) Output("return self;") ! def output_tp_new(self): if self.output_tp_newBody: *************** *** 419,425 **** Output("#define %s_tp_new PyType_GenericNew", self.prefix) Output() ! output_tp_freeBody = None ! def output_tp_free(self): if self.output_tp_freeBody: --- 419,425 ---- Output("#define %s_tp_new PyType_GenericNew", self.prefix) Output() ! output_tp_freeBody = None ! def output_tp_free(self): if self.output_tp_freeBody: *************** *** 431,435 **** Output("#define %s_tp_free PyObject_Del", self.prefix) Output() ! def outputPEP253Hooks(self): self.output_tp_init() --- 431,435 ---- Output("#define %s_tp_free PyObject_Del", self.prefix) Output() ! def outputPEP253Hooks(self): self.output_tp_init() *************** *** 440,444 **** class GlobalObjectDefinition(ObjectDefinition): """Like ObjectDefinition but exports some parts. ! XXX Should also somehow generate a .h file for them. """ --- 440,444 ---- class GlobalObjectDefinition(ObjectDefinition): """Like ObjectDefinition but exports some parts. ! XXX Should also somehow generate a .h file for them. """ *************** *** 454,458 **** the corresponding Python objects. With this you can create Python object wrappers on the fly""" ! def outputCompare(self): Output() --- 454,458 ---- the corresponding Python objects. With this you can create Python object wrappers on the fly""" ! def outputCompare(self): Output() *************** *** 476,480 **** Output("return 0;") OutRbrace() ! def outputHash(self): Output() --- 476,480 ---- Output("return 0;") OutRbrace() ! def outputHash(self): Output() *************** *** 483,486 **** Output("return (long)self->ob_itself;") OutRbrace() - - --- 483,484 ---- Index: bgenOutput.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/bgen/bgen/bgenOutput.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** bgenOutput.py 20 Oct 2003 14:01:55 -0000 1.6 --- bgenOutput.py 18 Jul 2004 06:02:01 -0000 1.7 *************** *** 31,35 **** def SetOutputFileName(filename = None): """Call this with a filename to make it the output file. ! Call it without arguments to close the current file (if necessary) and reset it to sys.stdout. --- 31,35 ---- def SetOutputFileName(filename = None): """Call this with a filename to make it the output file. ! Call it without arguments to close the current file (if necessary) and reset it to sys.stdout. *************** *** 96,100 **** def OutIndent(format = "", *args): """Combine Output() followed by IndentLevel(). ! If no text is given, acts like lone IndentLevel(). """ --- 96,100 ---- def OutIndent(format = "", *args): """Combine Output() followed by IndentLevel(). ! If no text is given, acts like lone IndentLevel(). """ *************** *** 104,108 **** def OutDedent(format = "", *args): """Combine Output() followed by DedentLevel(). ! If no text is given, acts like loneDedentLevel(). """ --- 104,108 ---- def OutDedent(format = "", *args): """Combine Output() followed by DedentLevel(). ! If no text is given, acts like loneDedentLevel(). """ *************** *** 112,116 **** def OutLbrace(format = "", *args): """Like Output, but add a '{' and increase the indentation level. ! If no text is given a lone '{' is output. """ --- 112,116 ---- def OutLbrace(format = "", *args): """Like Output, but add a '{' and increase the indentation level. ! If no text is given a lone '{' is output. """ *************** *** 144,148 **** def Out(text): """Output multiline text that's internally indented. ! Pass this a multiline character string. The whitespace before the first nonblank line of the string will be subtracted from all lines. --- 144,148 ---- def Out(text): """Output multiline text that's internally indented. ! Pass this a multiline character string. The whitespace before the first nonblank line of the string will be subtracted from all lines. *************** *** 150,154 **** of formatting (if you need formatting you can do it before the call). Recommended use: ! Out(''' int main(argc, argv) --- 150,154 ---- of formatting (if you need formatting you can do it before the call). Recommended use: ! Out(''' int main(argc, argv) *************** *** 160,164 **** } ''') ! Caveat: the indentation must be consistent -- if you use three tabs in the first line, (up to) three tabs are removed from following lines, --- 160,164 ---- } ''') ! Caveat: the indentation must be consistent -- if you use three tabs in the first line, (up to) three tabs are removed from following lines, *************** *** 167,171 **** """ # (Don't you love using triple quotes *inside* triple quotes? :-) ! lines = text.split('\n') indent = "" --- 167,171 ---- """ # (Don't you love using triple quotes *inside* triple quotes? :-) ! lines = text.split('\n') indent = "" *************** *** 194,198 **** #include #include ! main(argc, argv) int argc; --- 194,198 ---- #include #include ! main(argc, argv) int argc; Index: bgenStringBuffer.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/bgen/bgen/bgenStringBuffer.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** bgenStringBuffer.py 19 Jan 2003 21:53:57 -0000 1.2 --- bgenStringBuffer.py 18 Jul 2004 06:02:01 -0000 1.3 *************** *** 23,33 **** less common. I'll write the classes when there is demand.) """ ! def declareSize(self, name): pass ! def getargsFormat(self): return "s" ! def getargsArgs(self, name): return "&%s__in__" % name --- 23,33 ---- less common. I'll write the classes when there is demand.) """ ! def declareSize(self, name): pass ! def getargsFormat(self): return "s" ! def getargsArgs(self, name): return "&%s__in__" % name Index: bgenType.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/bgen/bgen/bgenType.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** bgenType.py 24 Jan 2003 09:23:13 -0000 1.11 --- bgenType.py 18 Jul 2004 06:02:01 -0000 1.12 *************** *** 205,210 **** else: # Three arguments (name, new, convert) ! self.new = arg ! self.convert = extra def getargsFormat(self): --- 205,210 ---- else: # Three arguments (name, new, convert) ! self.new = arg ! self.convert = extra def getargsFormat(self): *************** *** 237,241 **** def mkvalueArgs(self, name): return "%s, %s" % (self.new, name) ! class OpaqueByValueStructType(OpaqueByValueType): """Similar to OpaqueByValueType, but we also pass this to mkvalue by --- 237,241 ---- def mkvalueArgs(self, name): return "%s, %s" % (self.new, name) ! class OpaqueByValueStructType(OpaqueByValueType): """Similar to OpaqueByValueType, but we also pass this to mkvalue by Index: macsupport.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/bgen/bgen/macsupport.py,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** macsupport.py 20 Nov 2003 13:31:00 -0000 1.30 --- macsupport.py 18 Jul 2004 06:02:01 -0000 1.31 *************** *** 130,137 **** def getargsFormat(self): return "u#" ! class VarUnicodeReverseInputBufferType(ReverseInputBufferMixin, VarUnicodeInputBufferType): pass ! UnicodeInBuffer = VarUnicodeInputBufferType('UniChar', 'UniCharCount', 'l') UnicodeReverseInBuffer = VarUnicodeReverseInputBufferType('UniChar', 'UniCharCount', 'l') --- 130,137 ---- def getargsFormat(self): return "u#" ! class VarUnicodeReverseInputBufferType(ReverseInputBufferMixin, VarUnicodeInputBufferType): pass ! UnicodeInBuffer = VarUnicodeInputBufferType('UniChar', 'UniCharCount', 'l') UnicodeReverseInBuffer = VarUnicodeReverseInputBufferType('UniChar', 'UniCharCount', 'l') *************** *** 181,185 **** class WeakLinkMixIn: "Mix-in to test the function actually exists (!= NULL) before calling" ! def precheck(self): Output('#ifndef %s', self.name) --- 181,185 ---- class WeakLinkMixIn: "Mix-in to test the function actually exists (!= NULL) before calling" ! def precheck(self): Output('#ifndef %s', self.name) Index: scantools.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/bgen/bgen/scantools.py,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** scantools.py 12 Feb 2004 17:35:14 -0000 1.34 --- scantools.py 18 Jul 2004 06:02:01 -0000 1.35 *************** *** 52,64 **** if input: self.setinput(input) ! def initusedtypes(self): self.usedtypes = {} ! def typeused(self, type, mode): if not self.usedtypes.has_key(type): self.usedtypes[type] = {} self.usedtypes[type][mode] = None ! def reportusedtypes(self): types = self.usedtypes.keys() --- 52,64 ---- if input: self.setinput(input) ! def initusedtypes(self): self.usedtypes = {} ! def typeused(self, type, mode): if not self.usedtypes.has_key(type): self.usedtypes[type] = {} self.usedtypes[type][mode] = None ! def reportusedtypes(self): types = self.usedtypes.keys() *************** *** 101,110 **** def writeinitialdefs(self): pass ! def initblacklists(self): self.blacklistnames = self.makeblacklistnames() self.blacklisttypes = ["unknown", "-"] + self.makeblacklisttypes() self.greydictnames = self.greylist2dict(self.makegreylist()) ! def greylist2dict(self, list): rv = {} --- 101,110 ---- def writeinitialdefs(self): pass ! def initblacklists(self): self.blacklistnames = self.makeblacklistnames() self.blacklisttypes = ["unknown", "-"] + self.makeblacklisttypes() self.greydictnames = self.greylist2dict(self.makegreylist()) ! def greylist2dict(self, list): rv = {} *************** *** 119,123 **** def makeblacklisttypes(self): return [] ! def makegreylist(self): return [] --- 119,123 ---- def makeblacklisttypes(self): return [] ! def makegreylist(self): return [] *************** *** 129,133 **** def makerepairinstructions(self): """Parse the repair file into repair instructions. ! The file format is simple: 1) use \ to split a long logical line in multiple physical lines --- 129,133 ---- def makerepairinstructions(self): """Parse the repair file into repair instructions. ! The file format is simple: 1) use \ to split a long logical line in multiple physical lines *************** *** 217,224 **** list.append((fpat, patterns, replacements)) return list ! def makeinherentpointertypes(self): return [] ! def openrepairfile(self, filename = "REPAIR"): try: --- 217,224 ---- list.append((fpat, patterns, replacements)) return list ! def makeinherentpointertypes(self): return [] ! def openrepairfile(self, filename = "REPAIR"): try: *************** *** 338,342 **** self.allscaninputs = scan self._nextinput() ! def _nextinput(self): if not self.allscaninputs: --- 338,342 ---- self.allscaninputs = scan self._nextinput() ! def _nextinput(self): if not self.allscaninputs: *************** *** 527,531 **** type = re.sub("[ \t]+", "_", type) return self.modifyarg(type, name, mode) ! def modifyarg(self, type, name, mode): if type[:6] == "const_": --- 527,531 ---- type = re.sub("[ \t]+", "_", type) return self.modifyarg(type, name, mode) ! def modifyarg(self, type, name, mode): if type[:6] == "const_": *************** *** 568,572 **** i = i+1 return arglist ! def matcharg(self, patarg, arg): return len(filter(None, map(fnmatch.fnmatchcase, arg, patarg))) == 3 --- 568,572 ---- i = i+1 return arglist ! def matcharg(self, patarg, arg): return len(filter(None, map(fnmatch.fnmatchcase, arg, patarg))) == 3 *************** *** 667,669 **** if __name__ == '__main__': test() - --- 667,668 ---- From tim_one at users.sourceforge.net Sun Jul 18 08:04:38 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 08:04:42 2004 Subject: [Python-checkins] python/dist/src/Misc BeOS-setup.py, 1.5, 1.6 find_recursionlimit.py, 1.1, 1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30209 Modified Files: BeOS-setup.py find_recursionlimit.py Log Message: Whitespace normalization, via reindent.py. Index: BeOS-setup.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/BeOS-setup.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** BeOS-setup.py 2 Jun 2004 17:42:56 -0000 1.5 --- BeOS-setup.py 18 Jul 2004 06:04:36 -0000 1.6 *************** *** 94,98 **** # Parse Modules/Setup to figure out which modules are turned ! # on in the file. input = text_file.TextFile('Modules/Setup', join_lines=1) remove_modules = [] --- 94,98 ---- # Parse Modules/Setup to figure out which modules are turned ! # on in the file. input = text_file.TextFile('Modules/Setup', join_lines=1) remove_modules = [] *************** *** 103,111 **** remove_modules.append( line[0] ) input.close() ! for ext in self.extensions[:]: if ext.name in remove_modules: self.extensions.remove(ext) ! # When you run "make CC=altcc" or something similar, you really want # those environment variables passed into the setup.py phase. Here's --- 103,111 ---- remove_modules.append( line[0] ) input.close() ! for ext in self.extensions[:]: if ext.name in remove_modules: self.extensions.remove(ext) ! # When you run "make CC=altcc" or something similar, you really want # those environment variables passed into the setup.py phase. Here's *************** *** 143,158 **** def detect_modules(self): ! try: ! belibs = os.environ['BELIBRARIES'].split(';') ! except KeyError: ! belibs = ['/boot/beos/system/lib'] ! belibs.append('/boot/home/config/lib') ! self.compiler.library_dirs.append('/boot/home/config/lib') ! try: ! beincl = os.environ['BEINCLUDES'].split(';') ! except KeyError: ! beincl = [] ! beincl.append('/boot/home/config/include') ! self.compiler.include_dirs.append('/boot/home/config/include') # lib_dirs and inc_dirs are used to search for files; # if a file is found in one of those directories, it can --- 143,158 ---- def detect_modules(self): ! try: ! belibs = os.environ['BELIBRARIES'].split(';') ! except KeyError: ! belibs = ['/boot/beos/system/lib'] ! belibs.append('/boot/home/config/lib') ! self.compiler.library_dirs.append('/boot/home/config/lib') ! try: ! beincl = os.environ['BEINCLUDES'].split(';') ! except KeyError: ! beincl = [] ! beincl.append('/boot/home/config/include') ! self.compiler.include_dirs.append('/boot/home/config/include') # lib_dirs and inc_dirs are used to search for files; # if a file is found in one of those directories, it can *************** *** 163,167 **** platform = self.get_platform() ! # Check for MacOS X, which doesn't need libm.a at all math_libs = ['m'] --- 163,167 ---- platform = self.get_platform() ! # Check for MacOS X, which doesn't need libm.a at all math_libs = ['m'] *************** *** 348,352 **** if self.compiler.find_library_file(lib_dirs, 'db'): dblib = ['db'] ! db185_incs = find_file('db_185.h', inc_dirs, ['/usr/include/db3', '/usr/include/db2']) --- 348,352 ---- if self.compiler.find_library_file(lib_dirs, 'db'): dblib = ['db'] ! db185_incs = find_file('db_185.h', inc_dirs, ['/usr/include/db3', '/usr/include/db2']) *************** *** 389,393 **** # Generic dynamic loading module #exts.append( Extension('dl', ['dlmodule.c']) ) ! # Sun yellow pages. Some systems have the functions in libc. if platform not in ['cygwin']: --- 389,393 ---- # Generic dynamic loading module #exts.append( Extension('dl', ['dlmodule.c']) ) ! # Sun yellow pages. Some systems have the functions in libc. if platform not in ['cygwin']: *************** *** 500,512 **** def detect_tkinter(self, inc_dirs, lib_dirs): # The _tkinter module. ! # Assume we haven't found any of the libraries or include files tcllib = tklib = tcl_includes = tk_includes = None for version in ['8.4', '8.3', '8.2', '8.1', '8.0']: ! tklib = self.compiler.find_library_file(lib_dirs, ! 'tk' + version ) ! tcllib = self.compiler.find_library_file(lib_dirs, ! 'tcl' + version ) ! if tklib and tcllib: # Exit the loop when we've found the Tcl/Tk libraries break --- 500,512 ---- def detect_tkinter(self, inc_dirs, lib_dirs): # The _tkinter module. ! # Assume we haven't found any of the libraries or include files tcllib = tklib = tcl_includes = tk_includes = None for version in ['8.4', '8.3', '8.2', '8.1', '8.0']: ! tklib = self.compiler.find_library_file(lib_dirs, ! 'tk' + version ) ! tcllib = self.compiler.find_library_file(lib_dirs, ! 'tcl' + version ) ! if tklib and tcllib: # Exit the loop when we've found the Tcl/Tk libraries break Index: find_recursionlimit.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/find_recursionlimit.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** find_recursionlimit.py 31 Aug 2000 19:24:17 -0000 1.1 --- find_recursionlimit.py 18 Jul 2004 06:04:36 -0000 1.2 *************** *** 58,62 **** def test_getitem(): return RecursiveBlowup6()[5] ! def test_recurse(): return test_recurse() --- 58,62 ---- def test_getitem(): return RecursiveBlowup6()[5] ! def test_recurse(): return test_recurse() *************** *** 86,88 **** print "Limit of %d is fine" % limit limit = limit + 100 - --- 86,87 ---- From tim_one at users.sourceforge.net Sun Jul 18 08:09:14 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 08:09:19 2004 Subject: [Python-checkins] python/dist/src/Demo/tkinter/guido AttrDialog.py, 1.8, 1.9 ManPage.py, 1.9, 1.10 MimeViewer.py, 1.3, 1.4 ShellWindow.py, 1.3, 1.4 canvasevents.py, 1.1, 1.2 dialog.py, 1.6, 1.7 electrons.py, 1.9, 1.10 hanoi.py, 1.3, 1.4 hello.py, 1.1, 1.2 kill.py, 1.5, 1.6 listtree.py, 1.3, 1.4 mbox.py, 1.5, 1.6 newmenubardemo.py, 1.2, 1.3 paint.py, 1.1, 1.2 rmt.py, 1.6, 1.7 solitaire.py, 1.5, 1.6 sortvisu.py, 1.1, 1.2 ss1.py, 1.4, 1.5 svkill.py, 1.6, 1.7 tkman.py, 1.10, 1.11 wish.py, 1.4, 1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Demo/tkinter/guido In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30561/guido Modified Files: AttrDialog.py ManPage.py MimeViewer.py ShellWindow.py canvasevents.py dialog.py electrons.py hanoi.py hello.py kill.py listtree.py mbox.py newmenubardemo.py paint.py rmt.py solitaire.py sortvisu.py ss1.py svkill.py tkman.py wish.py Log Message: Whitespace normalization, via reindent.py. Index: AttrDialog.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/guido/AttrDialog.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** AttrDialog.py 8 Oct 1998 15:24:01 -0000 1.8 --- AttrDialog.py 18 Jul 2004 06:09:08 -0000 1.9 *************** *** 17,452 **** class Option: ! varclass = StringVar # May be overridden ! def __init__(self, dialog, option): ! self.dialog = dialog ! self.option = option ! self.master = dialog.top ! self.default, self.klass = dialog.options[option] ! self.var = self.varclass(self.master) ! self.frame = Frame(self.master) ! self.frame.pack(fill=X) ! self.label = Label(self.frame, text=(option + ":")) ! self.label.pack(side=LEFT) ! self.update() ! self.addoption() ! def refresh(self): ! self.dialog.refresh() ! self.update() ! def update(self): ! try: ! self.current = self.dialog.current[self.option] ! except KeyError: ! self.current = self.default ! self.var.set(self.current) ! def set(self, e=None): # Should be overridden ! pass class BooleanOption(Option): ! varclass = BooleanVar ! def addoption(self): ! self.button = Checkbutton(self.frame, ! text='on/off', ! onvalue=1, ! offvalue=0, ! variable=self.var, ! relief=RAISED, ! borderwidth=2, ! command=self.set) ! self.button.pack(side=RIGHT) class EnumOption(Option): ! def addoption(self): ! self.button = Menubutton(self.frame, ! textvariable=self.var, ! relief=RAISED, borderwidth=2) ! self.button.pack(side=RIGHT) ! self.menu = Menu(self.button) ! self.button['menu'] = self.menu ! for v in self.dialog.classes[self.klass]: ! self.menu.add_radiobutton( ! label=v, ! variable=self.var, ! value=v, ! command=self.set) class StringOption(Option): ! def addoption(self): ! self.entry = Entry(self.frame, ! textvariable=self.var, ! width=10, ! relief=SUNKEN, ! borderwidth=2) ! self.entry.pack(side=RIGHT, fill=X, expand=1) ! self.entry.bind('', self.set) class ReadonlyOption(Option): ! def addoption(self): ! self.label = Label(self.frame, textvariable=self.var, ! anchor=E) ! self.label.pack(side=RIGHT) class Dialog: ! def __init__(self, master): ! self.master = master ! self.fixclasses() ! self.refresh() ! self.top = Toplevel(self.master) ! self.top.title(self.__class__.__name__) ! self.top.minsize(1, 1) ! self.addchoices() ! def refresh(self): pass # Must override ! def fixclasses(self): pass # May override ! def addchoices(self): ! self.choices = {} ! list = [] ! for k, dc in self.options.items(): ! list.append((k, dc)) ! list.sort() ! for k, (d, c) in list: ! try: ! cl = self.classes[c] ! except KeyError: ! cl = 'unknown' ! if type(cl) == TupleType: ! cl = self.enumoption ! elif cl == 'boolean': ! cl = self.booleanoption ! elif cl == 'readonly': ! cl = self.readonlyoption ! else: ! cl = self.stringoption ! self.choices[k] = cl(self, k) ! # Must override: ! options = {} ! classes = {} ! # May override: ! booleanoption = BooleanOption ! stringoption = StringOption ! enumoption = EnumOption ! readonlyoption = ReadonlyOption class PackDialog(Dialog): ! def __init__(self, widget): ! self.widget = widget ! Dialog.__init__(self, widget) ! def refresh(self): ! self.current = self.widget.info() ! self.current['.class'] = self.widget.winfo_class() ! self.current['.name'] = self.widget._w ! class packoption: # Mix-in class ! def set(self, e=None): ! self.current = self.var.get() ! try: ! apply(self.dialog.widget.pack, (), ! {self.option: self.current}) ! except TclError, msg: ! print msg ! self.refresh() ! class booleanoption(packoption, BooleanOption): pass ! class enumoption(packoption, EnumOption): pass ! class stringoption(packoption, StringOption): pass ! class readonlyoption(packoption, ReadonlyOption): pass ! options = { ! '.class': (None, 'Class'), ! '.name': (None, 'Name'), ! 'after': (None, 'Widget'), ! 'anchor': ('center', 'Anchor'), ! 'before': (None, 'Widget'), ! 'expand': ('no', 'Boolean'), ! 'fill': ('none', 'Fill'), ! 'in': (None, 'Widget'), ! 'ipadx': (0, 'Pad'), ! 'ipady': (0, 'Pad'), ! 'padx': (0, 'Pad'), ! 'pady': (0, 'Pad'), ! 'side': ('top', 'Side'), ! } ! classes = { ! 'Anchor': (N, NE, E, SE, S, SW, W, NW, CENTER), ! 'Boolean': 'boolean', ! 'Class': 'readonly', ! 'Expand': 'boolean', ! 'Fill': (NONE, X, Y, BOTH), ! 'Name': 'readonly', ! 'Pad': 'pixel', ! 'Side': (TOP, RIGHT, BOTTOM, LEFT), ! 'Widget': 'readonly', ! } class RemotePackDialog(PackDialog): ! def __init__(self, master, app, widget): ! self.master = master ! self.app = app ! self.widget = widget ! self.refresh() ! self.top = Toplevel(self.master) ! self.top.title(self.app + ' PackDialog') ! self.top.minsize(1, 1) ! self.addchoices() ! def refresh(self): ! try: ! words = self.master.tk.splitlist( ! self.master.send(self.app, ! 'pack', ! 'info', ! self.widget)) ! except TclError, msg: ! print msg ! return ! dict = {} ! for i in range(0, len(words), 2): ! key = words[i][1:] ! value = words[i+1] ! dict[key] = value ! dict['.class'] = self.master.send(self.app, ! 'winfo', ! 'class', ! self.widget) ! dict['.name'] = self.widget ! self.current = dict ! class remotepackoption: # Mix-in class ! def set(self, e=None): ! self.current = self.var.get() ! try: ! self.dialog.master.send( ! self.dialog.app, ! 'pack', ! 'config', ! self.dialog.widget, ! '-'+self.option, ! self.dialog.master.tk.merge( ! self.current)) ! except TclError, msg: ! print msg ! self.refresh() ! class booleanoption(remotepackoption, BooleanOption): pass ! class enumoption(remotepackoption, EnumOption): pass ! class stringoption(remotepackoption, StringOption): pass ! class readonlyoption(remotepackoption, ReadonlyOption): pass class WidgetDialog(Dialog): ! def __init__(self, widget): ! self.widget = widget ! self.klass = widget.winfo_class() ! Dialog.__init__(self, widget) ! def fixclasses(self): ! if self.addclasses.has_key(self.klass): ! classes = {} ! for c in (self.classes, ! self.addclasses[self.klass]): ! for k in c.keys(): ! classes[k] = c[k] ! self.classes = classes ! def refresh(self): ! self.configuration = self.widget.config() ! self.update() ! self.current['.class'] = self.widget.winfo_class() ! self.current['.name'] = self.widget._w ! def update(self): ! self.current = {} ! self.options = {} ! for k, v in self.configuration.items(): ! if len(v) > 4: ! self.current[k] = v[4] ! self.options[k] = v[3], v[2] # default, klass ! self.options['.class'] = (None, 'Class') ! self.options['.name'] = (None, 'Name') ! class widgetoption: # Mix-in class ! def set(self, e=None): ! self.current = self.var.get() ! try: ! self.dialog.widget[self.option] = self.current ! except TclError, msg: ! print msg ! self.refresh() ! class booleanoption(widgetoption, BooleanOption): pass ! class enumoption(widgetoption, EnumOption): pass ! class stringoption(widgetoption, StringOption): pass ! class readonlyoption(widgetoption, ReadonlyOption): pass ! # Universal classes ! classes = { ! 'Anchor': (N, NE, E, SE, S, SW, W, NW, CENTER), ! 'Aspect': 'integer', ! 'Background': 'color', ! 'Bitmap': 'bitmap', ! 'BorderWidth': 'pixel', ! 'Class': 'readonly', ! 'CloseEnough': 'double', ! 'Command': 'command', ! 'Confine': 'boolean', ! 'Cursor': 'cursor', ! 'CursorWidth': 'pixel', ! 'DisabledForeground': 'color', ! 'ExportSelection': 'boolean', ! 'Font': 'font', ! 'Foreground': 'color', ! 'From': 'integer', ! 'Geometry': 'geometry', ! 'Height': 'pixel', ! 'InsertWidth': 'time', ! 'Justify': (LEFT, CENTER, RIGHT), ! 'Label': 'string', ! 'Length': 'pixel', ! 'MenuName': 'widget', ! 'Name': 'readonly', ! 'OffTime': 'time', ! 'OnTime': 'time', ! 'Orient': (HORIZONTAL, VERTICAL), ! 'Pad': 'pixel', ! 'Relief': (RAISED, SUNKEN, FLAT, RIDGE, GROOVE), ! 'RepeatDelay': 'time', ! 'RepeatInterval': 'time', ! 'ScrollCommand': 'command', ! 'ScrollIncrement': 'pixel', ! 'ScrollRegion': 'rectangle', ! 'ShowValue': 'boolean', ! 'SetGrid': 'boolean', ! 'Sliderforeground': 'color', ! 'SliderLength': 'pixel', ! 'Text': 'string', ! 'TickInterval': 'integer', ! 'To': 'integer', ! 'Underline': 'index', ! 'Variable': 'variable', ! 'Value': 'string', ! 'Width': 'pixel', ! 'Wrap': (NONE, CHAR, WORD), ! } ! # Classes that (may) differ per widget type ! _tristate = {'State': (NORMAL, ACTIVE, DISABLED)} ! _bistate = {'State': (NORMAL, DISABLED)} ! addclasses = { ! 'Button': _tristate, ! 'Radiobutton': _tristate, ! 'Checkbutton': _tristate, ! 'Entry': _bistate, ! 'Text': _bistate, ! 'Menubutton': _tristate, ! 'Slider': _bistate, ! } class RemoteWidgetDialog(WidgetDialog): ! def __init__(self, master, app, widget): ! self.app = app ! self.widget = widget ! self.klass = master.send(self.app, ! 'winfo', ! 'class', ! self.widget) ! Dialog.__init__(self, master) ! def refresh(self): ! try: ! items = self.master.tk.splitlist( ! self.master.send(self.app, ! self.widget, ! 'config')) ! except TclError, msg: ! print msg ! return ! dict = {} ! for item in items: ! words = self.master.tk.splitlist(item) ! key = words[0][1:] ! value = (key,) + words[1:] ! dict[key] = value ! self.configuration = dict ! self.update() ! self.current['.class'] = self.klass ! self.current['.name'] = self.widget ! class remotewidgetoption: # Mix-in class ! def set(self, e=None): ! self.current = self.var.get() ! try: ! self.dialog.master.send( ! self.dialog.app, ! self.dialog.widget, ! 'config', ! '-'+self.option, ! self.current) ! except TclError, msg: ! print msg ! self.refresh() ! class booleanoption(remotewidgetoption, BooleanOption): pass ! class enumoption(remotewidgetoption, EnumOption): pass ! class stringoption(remotewidgetoption, StringOption): pass ! class readonlyoption(remotewidgetoption, ReadonlyOption): pass def test(): ! import sys ! root = Tk() ! root.minsize(1, 1) ! if sys.argv[1:]: ! remotetest(root, sys.argv[1]) ! else: ! frame = Frame(root, name='frame') ! frame.pack(expand=1, fill=BOTH) ! button = Button(frame, name='button', text='button') ! button.pack(expand=1) ! canvas = Canvas(frame, name='canvas') ! canvas.pack() ! fpd = PackDialog(frame) ! fwd = WidgetDialog(frame) ! bpd = PackDialog(button) ! bwd = WidgetDialog(button) ! cpd = PackDialog(canvas) ! cwd = WidgetDialog(canvas) ! root.mainloop() def remotetest(root, app): ! from listtree import listtree ! list = listtree(root, app) ! list.bind('', opendialogs) ! list.app = app # Pass it on to handler def opendialogs(e): ! import string ! list = e.widget ! sel = list.curselection() ! for i in sel: ! item = list.get(i) ! widget = string.split(item)[0] ! RemoteWidgetDialog(list, list.app, widget) ! if widget == '.': continue ! try: ! RemotePackDialog(list, list.app, widget) ! except TclError, msg: ! print msg test() --- 17,452 ---- class Option: ! varclass = StringVar # May be overridden ! def __init__(self, dialog, option): ! self.dialog = dialog ! self.option = option ! self.master = dialog.top ! self.default, self.klass = dialog.options[option] ! self.var = self.varclass(self.master) ! self.frame = Frame(self.master) ! self.frame.pack(fill=X) ! self.label = Label(self.frame, text=(option + ":")) ! self.label.pack(side=LEFT) ! self.update() ! self.addoption() ! def refresh(self): ! self.dialog.refresh() ! self.update() ! def update(self): ! try: ! self.current = self.dialog.current[self.option] ! except KeyError: ! self.current = self.default ! self.var.set(self.current) ! def set(self, e=None): # Should be overridden ! pass class BooleanOption(Option): ! varclass = BooleanVar ! def addoption(self): ! self.button = Checkbutton(self.frame, ! text='on/off', ! onvalue=1, ! offvalue=0, ! variable=self.var, ! relief=RAISED, ! borderwidth=2, ! command=self.set) ! self.button.pack(side=RIGHT) class EnumOption(Option): ! def addoption(self): ! self.button = Menubutton(self.frame, ! textvariable=self.var, ! relief=RAISED, borderwidth=2) ! self.button.pack(side=RIGHT) ! self.menu = Menu(self.button) ! self.button['menu'] = self.menu ! for v in self.dialog.classes[self.klass]: ! self.menu.add_radiobutton( ! label=v, ! variable=self.var, ! value=v, ! command=self.set) class StringOption(Option): ! def addoption(self): ! self.entry = Entry(self.frame, ! textvariable=self.var, ! width=10, ! relief=SUNKEN, ! borderwidth=2) ! self.entry.pack(side=RIGHT, fill=X, expand=1) ! self.entry.bind('', self.set) class ReadonlyOption(Option): ! def addoption(self): ! self.label = Label(self.frame, textvariable=self.var, ! anchor=E) ! self.label.pack(side=RIGHT) class Dialog: ! def __init__(self, master): ! self.master = master ! self.fixclasses() ! self.refresh() ! self.top = Toplevel(self.master) ! self.top.title(self.__class__.__name__) ! self.top.minsize(1, 1) ! self.addchoices() ! def refresh(self): pass # Must override ! def fixclasses(self): pass # May override ! def addchoices(self): ! self.choices = {} ! list = [] ! for k, dc in self.options.items(): ! list.append((k, dc)) ! list.sort() ! for k, (d, c) in list: ! try: ! cl = self.classes[c] ! except KeyError: ! cl = 'unknown' ! if type(cl) == TupleType: ! cl = self.enumoption ! elif cl == 'boolean': ! cl = self.booleanoption ! elif cl == 'readonly': ! cl = self.readonlyoption ! else: ! cl = self.stringoption ! self.choices[k] = cl(self, k) ! # Must override: ! options = {} ! classes = {} ! # May override: ! booleanoption = BooleanOption ! stringoption = StringOption ! enumoption = EnumOption ! readonlyoption = ReadonlyOption class PackDialog(Dialog): ! def __init__(self, widget): ! self.widget = widget ! Dialog.__init__(self, widget) ! def refresh(self): ! self.current = self.widget.info() ! self.current['.class'] = self.widget.winfo_class() ! self.current['.name'] = self.widget._w ! class packoption: # Mix-in class ! def set(self, e=None): ! self.current = self.var.get() ! try: ! apply(self.dialog.widget.pack, (), ! {self.option: self.current}) ! except TclError, msg: ! print msg ! self.refresh() ! class booleanoption(packoption, BooleanOption): pass ! class enumoption(packoption, EnumOption): pass ! class stringoption(packoption, StringOption): pass ! class readonlyoption(packoption, ReadonlyOption): pass ! options = { ! '.class': (None, 'Class'), ! '.name': (None, 'Name'), ! 'after': (None, 'Widget'), ! 'anchor': ('center', 'Anchor'), ! 'before': (None, 'Widget'), ! 'expand': ('no', 'Boolean'), ! 'fill': ('none', 'Fill'), ! 'in': (None, 'Widget'), ! 'ipadx': (0, 'Pad'), ! 'ipady': (0, 'Pad'), ! 'padx': (0, 'Pad'), ! 'pady': (0, 'Pad'), ! 'side': ('top', 'Side'), ! } ! classes = { ! 'Anchor': (N, NE, E, SE, S, SW, W, NW, CENTER), ! 'Boolean': 'boolean', ! 'Class': 'readonly', ! 'Expand': 'boolean', ! 'Fill': (NONE, X, Y, BOTH), ! 'Name': 'readonly', ! 'Pad': 'pixel', ! 'Side': (TOP, RIGHT, BOTTOM, LEFT), ! 'Widget': 'readonly', ! } class RemotePackDialog(PackDialog): ! def __init__(self, master, app, widget): ! self.master = master ! self.app = app ! self.widget = widget ! self.refresh() ! self.top = Toplevel(self.master) ! self.top.title(self.app + ' PackDialog') ! self.top.minsize(1, 1) ! self.addchoices() ! def refresh(self): ! try: ! words = self.master.tk.splitlist( ! self.master.send(self.app, ! 'pack', ! 'info', ! self.widget)) ! except TclError, msg: ! print msg ! return ! dict = {} ! for i in range(0, len(words), 2): ! key = words[i][1:] ! value = words[i+1] ! dict[key] = value ! dict['.class'] = self.master.send(self.app, ! 'winfo', ! 'class', ! self.widget) ! dict['.name'] = self.widget ! self.current = dict ! class remotepackoption: # Mix-in class ! def set(self, e=None): ! self.current = self.var.get() ! try: ! self.dialog.master.send( ! self.dialog.app, ! 'pack', ! 'config', ! self.dialog.widget, ! '-'+self.option, ! self.dialog.master.tk.merge( ! self.current)) ! except TclError, msg: ! print msg ! self.refresh() ! class booleanoption(remotepackoption, BooleanOption): pass ! class enumoption(remotepackoption, EnumOption): pass ! class stringoption(remotepackoption, StringOption): pass ! class readonlyoption(remotepackoption, ReadonlyOption): pass class WidgetDialog(Dialog): ! def __init__(self, widget): ! self.widget = widget ! self.klass = widget.winfo_class() ! Dialog.__init__(self, widget) ! def fixclasses(self): ! if self.addclasses.has_key(self.klass): ! classes = {} ! for c in (self.classes, ! self.addclasses[self.klass]): ! for k in c.keys(): ! classes[k] = c[k] ! self.classes = classes ! def refresh(self): ! self.configuration = self.widget.config() ! self.update() ! self.current['.class'] = self.widget.winfo_class() ! self.current['.name'] = self.widget._w ! def update(self): ! self.current = {} ! self.options = {} ! for k, v in self.configuration.items(): ! if len(v) > 4: ! self.current[k] = v[4] ! self.options[k] = v[3], v[2] # default, klass ! self.options['.class'] = (None, 'Class') ! self.options['.name'] = (None, 'Name') ! class widgetoption: # Mix-in class ! def set(self, e=None): ! self.current = self.var.get() ! try: ! self.dialog.widget[self.option] = self.current ! except TclError, msg: ! print msg ! self.refresh() ! class booleanoption(widgetoption, BooleanOption): pass ! class enumoption(widgetoption, EnumOption): pass ! class stringoption(widgetoption, StringOption): pass ! class readonlyoption(widgetoption, ReadonlyOption): pass ! # Universal classes ! classes = { ! 'Anchor': (N, NE, E, SE, S, SW, W, NW, CENTER), ! 'Aspect': 'integer', ! 'Background': 'color', ! 'Bitmap': 'bitmap', ! 'BorderWidth': 'pixel', ! 'Class': 'readonly', ! 'CloseEnough': 'double', ! 'Command': 'command', ! 'Confine': 'boolean', ! 'Cursor': 'cursor', ! 'CursorWidth': 'pixel', ! 'DisabledForeground': 'color', ! 'ExportSelection': 'boolean', ! 'Font': 'font', ! 'Foreground': 'color', ! 'From': 'integer', ! 'Geometry': 'geometry', ! 'Height': 'pixel', ! 'InsertWidth': 'time', ! 'Justify': (LEFT, CENTER, RIGHT), ! 'Label': 'string', ! 'Length': 'pixel', ! 'MenuName': 'widget', ! 'Name': 'readonly', ! 'OffTime': 'time', ! 'OnTime': 'time', ! 'Orient': (HORIZONTAL, VERTICAL), ! 'Pad': 'pixel', ! 'Relief': (RAISED, SUNKEN, FLAT, RIDGE, GROOVE), ! 'RepeatDelay': 'time', ! 'RepeatInterval': 'time', ! 'ScrollCommand': 'command', ! 'ScrollIncrement': 'pixel', ! 'ScrollRegion': 'rectangle', ! 'ShowValue': 'boolean', ! 'SetGrid': 'boolean', ! 'Sliderforeground': 'color', ! 'SliderLength': 'pixel', ! 'Text': 'string', ! 'TickInterval': 'integer', ! 'To': 'integer', ! 'Underline': 'index', ! 'Variable': 'variable', ! 'Value': 'string', ! 'Width': 'pixel', ! 'Wrap': (NONE, CHAR, WORD), ! } ! # Classes that (may) differ per widget type ! _tristate = {'State': (NORMAL, ACTIVE, DISABLED)} ! _bistate = {'State': (NORMAL, DISABLED)} ! addclasses = { ! 'Button': _tristate, ! 'Radiobutton': _tristate, ! 'Checkbutton': _tristate, ! 'Entry': _bistate, ! 'Text': _bistate, ! 'Menubutton': _tristate, ! 'Slider': _bistate, ! } class RemoteWidgetDialog(WidgetDialog): ! def __init__(self, master, app, widget): ! self.app = app ! self.widget = widget ! self.klass = master.send(self.app, ! 'winfo', ! 'class', ! self.widget) ! Dialog.__init__(self, master) ! def refresh(self): ! try: ! items = self.master.tk.splitlist( ! self.master.send(self.app, ! self.widget, ! 'config')) ! except TclError, msg: ! print msg ! return ! dict = {} ! for item in items: ! words = self.master.tk.splitlist(item) ! key = words[0][1:] ! value = (key,) + words[1:] ! dict[key] = value ! self.configuration = dict ! self.update() ! self.current['.class'] = self.klass ! self.current['.name'] = self.widget ! class remotewidgetoption: # Mix-in class ! def set(self, e=None): ! self.current = self.var.get() ! try: ! self.dialog.master.send( ! self.dialog.app, ! self.dialog.widget, ! 'config', ! '-'+self.option, ! self.current) ! except TclError, msg: ! print msg ! self.refresh() ! class booleanoption(remotewidgetoption, BooleanOption): pass ! class enumoption(remotewidgetoption, EnumOption): pass ! class stringoption(remotewidgetoption, StringOption): pass ! class readonlyoption(remotewidgetoption, ReadonlyOption): pass def test(): ! import sys ! root = Tk() ! root.minsize(1, 1) ! if sys.argv[1:]: ! remotetest(root, sys.argv[1]) ! else: ! frame = Frame(root, name='frame') ! frame.pack(expand=1, fill=BOTH) ! button = Button(frame, name='button', text='button') ! button.pack(expand=1) ! canvas = Canvas(frame, name='canvas') ! canvas.pack() ! fpd = PackDialog(frame) ! fwd = WidgetDialog(frame) ! bpd = PackDialog(button) ! bwd = WidgetDialog(button) ! cpd = PackDialog(canvas) ! cwd = WidgetDialog(canvas) ! root.mainloop() def remotetest(root, app): ! from listtree import listtree ! list = listtree(root, app) ! list.bind('', opendialogs) ! list.app = app # Pass it on to handler def opendialogs(e): ! import string ! list = e.widget ! sel = list.curselection() ! for i in sel: ! item = list.get(i) ! widget = string.split(item)[0] ! RemoteWidgetDialog(list, list.app, widget) ! if widget == '.': continue ! try: ! RemotePackDialog(list, list.app, widget) ! except TclError, msg: ! print msg test() Index: ManPage.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/guido/ManPage.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** ManPage.py 30 Jul 1996 18:56:03 -0000 1.9 --- ManPage.py 18 Jul 2004 06:09:08 -0000 1.10 *************** *** 13,17 **** # (This one works for IRIX 5.2 and Solaris 2.2) footerprog = regex.compile( ! '^ Page [1-9][0-9]*[ \t]+\|^.*Last change:.*[1-9][0-9]*\n') emptyprog = regex.compile('^[ \t]*\n') ulprog = regex.compile('^[ \t]*[Xv!_][Xv!_ \t]*\n') --- 13,17 ---- # (This one works for IRIX 5.2 and Solaris 2.2) footerprog = regex.compile( ! '^ Page [1-9][0-9]*[ \t]+\|^.*Last change:.*[1-9][0-9]*\n') emptyprog = regex.compile('^[ \t]*\n') ulprog = regex.compile('^[ \t]*[Xv!_][Xv!_ \t]*\n') *************** *** 20,183 **** class EditableManPage(ScrolledText): ! # Initialize instance ! def __init__(self, master=None, **cnf): ! # Initialize base class ! apply(ScrolledText.__init__, (self, master), cnf) ! # Define tags for formatting styles ! self.tag_config('X', underline=1) ! self.tag_config('!', font=BOLDFONT) ! self.tag_config('_', font=ITALICFONT) ! # Set state to idle ! self.fp = None ! self.lineno = 0 ! # Test whether we are busy parsing a file ! def busy(self): ! return self.fp != None ! # Ensure we're not busy ! def kill(self): ! if self.busy(): ! self._endparser() ! # Parse a file, in the background ! def asyncparsefile(self, fp): ! self._startparser(fp) ! self.tk.createfilehandler(fp, _tkinter.READABLE, ! self._filehandler) ! parsefile = asyncparsefile # Alias ! # I/O handler used by background parsing ! def _filehandler(self, fp, mask): ! nextline = self.fp.readline() ! if not nextline: ! self._endparser() ! return ! self._parseline(nextline) ! # Parse a file, now (cannot be aborted) ! def syncparsefile(self, fp): ! from select import select ! def avail(fp=fp, tout=0.0, select=select): ! return select([fp], [], [], tout)[0] ! height = self.getint(self['height']) ! self._startparser(fp) ! while 1: ! nextline = fp.readline() ! if not nextline: ! break ! self._parseline(nextline) ! self._endparser() ! # Initialize parsing from a particular file -- must not be busy ! def _startparser(self, fp): ! if self.busy(): ! raise RuntimeError, 'startparser: still busy' ! fp.fileno() # Test for file-ness ! self.fp = fp ! self.lineno = 0 ! self.ok = 0 ! self.empty = 0 ! self.buffer = None ! savestate = self['state'] ! self['state'] = NORMAL ! self.delete('1.0', END) ! self['state'] = savestate ! # End parsing -- must be busy, need not be at EOF ! def _endparser(self): ! if not self.busy(): ! raise RuntimeError, 'endparser: not busy' ! if self.buffer: ! self._parseline('') ! try: ! self.tk.deletefilehandler(self.fp) ! except TclError, msg: ! pass ! self.fp.close() ! self.fp = None ! del self.ok, self.empty, self.buffer ! # Parse a single line ! def _parseline(self, nextline): ! if not self.buffer: ! # Save this line -- we need one line read-ahead ! self.buffer = nextline ! return ! if emptyprog.match(self.buffer) >= 0: ! # Buffered line was empty -- set a flag ! self.empty = 1 ! self.buffer = nextline ! return ! textline = self.buffer ! if ulprog.match(nextline) >= 0: ! # Next line is properties for buffered line ! propline = nextline ! self.buffer = None ! else: ! # Next line is read-ahead ! propline = None ! self.buffer = nextline ! if not self.ok: ! # First non blank line after footer must be header ! # -- skip that too ! self.ok = 1 ! self.empty = 0 ! return ! if footerprog.match(textline) >= 0: ! # Footer -- start skipping until next non-blank line ! self.ok = 0 ! self.empty = 0 ! return ! savestate = self['state'] ! self['state'] = NORMAL ! if TkVersion >= 4.0: ! self.mark_set('insert', 'end-1c') ! else: ! self.mark_set('insert', END) ! if self.empty: ! # One or more previous lines were empty ! # -- insert one blank line in the text ! self._insert_prop('\n') ! self.lineno = self.lineno + 1 ! self.empty = 0 ! if not propline: ! # No properties ! self._insert_prop(textline) ! else: ! # Search for properties ! p = '' ! j = 0 ! for i in range(min(len(propline), len(textline))): ! if propline[i] != p: ! if j < i: ! self._insert_prop(textline[j:i], p) ! j = i ! p = propline[i] ! self._insert_prop(textline[j:]) ! self.lineno = self.lineno + 1 ! self['state'] = savestate ! # Insert a string at the end, with at most one property (tag) ! def _insert_prop(self, str, prop = ' '): ! here = self.index(AtInsert()) ! self.insert(AtInsert(), str) ! if TkVersion <= 4.0: ! tags = self.tag_names(here) ! for tag in tags: ! self.tag_remove(tag, here, AtInsert()) ! if prop != ' ': ! self.tag_add(prop, here, AtInsert()) # Readonly Man Page class -- disables editing, otherwise the same class ReadonlyManPage(EditableManPage): ! # Initialize instance ! def __init__(self, master=None, **cnf): ! cnf['state'] = DISABLED ! apply(EditableManPage.__init__, (self, master), cnf) # Alias --- 20,183 ---- class EditableManPage(ScrolledText): ! # Initialize instance ! def __init__(self, master=None, **cnf): ! # Initialize base class ! apply(ScrolledText.__init__, (self, master), cnf) ! # Define tags for formatting styles ! self.tag_config('X', underline=1) ! self.tag_config('!', font=BOLDFONT) ! self.tag_config('_', font=ITALICFONT) ! # Set state to idle ! self.fp = None ! self.lineno = 0 ! # Test whether we are busy parsing a file ! def busy(self): ! return self.fp != None ! # Ensure we're not busy ! def kill(self): ! if self.busy(): ! self._endparser() ! # Parse a file, in the background ! def asyncparsefile(self, fp): ! self._startparser(fp) ! self.tk.createfilehandler(fp, _tkinter.READABLE, ! self._filehandler) ! parsefile = asyncparsefile # Alias ! # I/O handler used by background parsing ! def _filehandler(self, fp, mask): ! nextline = self.fp.readline() ! if not nextline: ! self._endparser() ! return ! self._parseline(nextline) ! # Parse a file, now (cannot be aborted) ! def syncparsefile(self, fp): ! from select import select ! def avail(fp=fp, tout=0.0, select=select): ! return select([fp], [], [], tout)[0] ! height = self.getint(self['height']) ! self._startparser(fp) ! while 1: ! nextline = fp.readline() ! if not nextline: ! break ! self._parseline(nextline) ! self._endparser() ! # Initialize parsing from a particular file -- must not be busy ! def _startparser(self, fp): ! if self.busy(): ! raise RuntimeError, 'startparser: still busy' ! fp.fileno() # Test for file-ness ! self.fp = fp ! self.lineno = 0 ! self.ok = 0 ! self.empty = 0 ! self.buffer = None ! savestate = self['state'] ! self['state'] = NORMAL ! self.delete('1.0', END) ! self['state'] = savestate ! # End parsing -- must be busy, need not be at EOF ! def _endparser(self): ! if not self.busy(): ! raise RuntimeError, 'endparser: not busy' ! if self.buffer: ! self._parseline('') ! try: ! self.tk.deletefilehandler(self.fp) ! except TclError, msg: ! pass ! self.fp.close() ! self.fp = None ! del self.ok, self.empty, self.buffer ! # Parse a single line ! def _parseline(self, nextline): ! if not self.buffer: ! # Save this line -- we need one line read-ahead ! self.buffer = nextline ! return ! if emptyprog.match(self.buffer) >= 0: ! # Buffered line was empty -- set a flag ! self.empty = 1 ! self.buffer = nextline ! return ! textline = self.buffer ! if ulprog.match(nextline) >= 0: ! # Next line is properties for buffered line ! propline = nextline ! self.buffer = None ! else: ! # Next line is read-ahead ! propline = None ! self.buffer = nextline ! if not self.ok: ! # First non blank line after footer must be header ! # -- skip that too ! self.ok = 1 ! self.empty = 0 ! return ! if footerprog.match(textline) >= 0: ! # Footer -- start skipping until next non-blank line ! self.ok = 0 ! self.empty = 0 ! return ! savestate = self['state'] ! self['state'] = NORMAL ! if TkVersion >= 4.0: ! self.mark_set('insert', 'end-1c') ! else: ! self.mark_set('insert', END) ! if self.empty: ! # One or more previous lines were empty ! # -- insert one blank line in the text ! self._insert_prop('\n') ! self.lineno = self.lineno + 1 ! self.empty = 0 ! if not propline: ! # No properties ! self._insert_prop(textline) ! else: ! # Search for properties ! p = '' ! j = 0 ! for i in range(min(len(propline), len(textline))): ! if propline[i] != p: ! if j < i: ! self._insert_prop(textline[j:i], p) ! j = i ! p = propline[i] ! self._insert_prop(textline[j:]) ! self.lineno = self.lineno + 1 ! self['state'] = savestate ! # Insert a string at the end, with at most one property (tag) ! def _insert_prop(self, str, prop = ' '): ! here = self.index(AtInsert()) ! self.insert(AtInsert(), str) ! if TkVersion <= 4.0: ! tags = self.tag_names(here) ! for tag in tags: ! self.tag_remove(tag, here, AtInsert()) ! if prop != ' ': ! self.tag_add(prop, here, AtInsert()) # Readonly Man Page class -- disables editing, otherwise the same class ReadonlyManPage(EditableManPage): ! # Initialize instance ! def __init__(self, master=None, **cnf): ! cnf['state'] = DISABLED ! apply(EditableManPage.__init__, (self, master), cnf) # Alias *************** *** 188,220 **** # -f means that the file is nroff -man output run through ul -i def test(): ! import os ! import sys ! # XXX This directory may be different on your system ! MANDIR = '/usr/local/man/mann' ! DEFAULTPAGE = 'Tcl' ! formatted = 0 ! if sys.argv[1:] and sys.argv[1] == '-f': ! formatted = 1 ! del sys.argv[1] ! if sys.argv[1:]: ! name = sys.argv[1] ! else: ! name = DEFAULTPAGE ! if not formatted: ! if name[-2:-1] != '.': ! name = name + '.n' ! name = os.path.join(MANDIR, name) ! root = Tk() ! root.minsize(1, 1) ! manpage = ManPage(root, relief=SUNKEN, borderwidth=2) ! manpage.pack(expand=1, fill=BOTH) ! if formatted: ! fp = open(name, 'r') ! else: ! fp = os.popen('nroff -man %s | ul -i' % name, 'r') ! manpage.parsefile(fp) ! root.mainloop() # Run the test program when called as a script if __name__ == '__main__': ! test() --- 188,220 ---- # -f means that the file is nroff -man output run through ul -i def test(): ! import os ! import sys ! # XXX This directory may be different on your system ! MANDIR = '/usr/local/man/mann' ! DEFAULTPAGE = 'Tcl' ! formatted = 0 ! if sys.argv[1:] and sys.argv[1] == '-f': ! formatted = 1 ! del sys.argv[1] ! if sys.argv[1:]: ! name = sys.argv[1] ! else: ! name = DEFAULTPAGE ! if not formatted: ! if name[-2:-1] != '.': ! name = name + '.n' ! name = os.path.join(MANDIR, name) ! root = Tk() ! root.minsize(1, 1) ! manpage = ManPage(root, relief=SUNKEN, borderwidth=2) ! manpage.pack(expand=1, fill=BOTH) ! if formatted: ! fp = open(name, 'r') ! else: ! fp = os.popen('nroff -man %s | ul -i' % name, 'r') ! manpage.parsefile(fp) ! root.mainloop() # Run the test program when called as a script if __name__ == '__main__': ! test() Index: MimeViewer.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/guido/MimeViewer.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** MimeViewer.py 27 Nov 1996 19:51:20 -0000 1.3 --- MimeViewer.py 18 Jul 2004 06:09:08 -0000 1.4 *************** *** 10,143 **** class MimeViewer: ! def __init__(self, parent, title, msg): ! self.title = title ! self.msg = msg ! self.frame = Frame(parent, {'relief': 'raised', 'bd': 2}) ! self.frame.packing = {'expand': 0, 'fill': 'both'} ! self.button = Checkbutton(self.frame, ! {'text': title, ! 'command': self.toggle}) ! self.button.pack({'anchor': 'w'}) ! headertext = msg.getheadertext( ! lambda x: x != 'received' and x[:5] != 'x400-') ! height = countlines(headertext, 4) ! if height: ! self.htext = ScrolledText(self.frame, ! {'height': height, ! 'width': 80, ! 'wrap': 'none', ! 'relief': 'raised', ! 'bd': 2}) ! self.htext.packing = {'expand': 1, 'fill': 'both', ! 'after': self.button} ! self.htext.insert('end', headertext) ! else: ! self.htext = Frame(self.frame, ! {'relief': 'raised', 'bd': 2}) ! self.htext.packing = {'side': 'top', ! 'ipady': 2, ! 'fill': 'x', ! 'after': self.button} ! body = msg.getbody() ! if type(body) == StringType: ! self.pad = None ! height = countlines(body, 10) ! if height: ! self.btext = ScrolledText(self.frame, ! {'height': height, ! 'width': 80, ! 'wrap': 'none', ! 'relief': 'raised', ! 'bd': 2}) ! self.btext.packing = {'expand': 1, ! 'fill': 'both'} ! self.btext.insert('end', body) ! else: ! self.btext = None ! self.parts = None ! else: ! self.pad = Frame(self.frame, ! {'relief': 'flat', 'bd': 2}) ! self.pad.packing = {'side': 'left', 'ipadx': 10, ! 'fill': 'y', 'after': self.htext} ! self.parts = [] ! for i in range(len(body)): ! p = MimeViewer(self.frame, ! '%s.%d' % (title, i+1), ! body[i]) ! self.parts.append(p) ! self.btext = None ! self.collapsed = 1 ! def pack(self): ! self.frame.pack(self.frame.packing) ! def destroy(self): ! self.frame.destroy() ! def show(self): ! if self.collapsed: ! self.button.invoke() ! def toggle(self): ! if self.collapsed: ! self.explode() ! else: ! self.collapse() ! def collapse(self): ! self.collapsed = 1 ! for comp in self.htext, self.btext, self.pad: ! if comp: ! comp.forget() ! if self.parts: ! for part in self.parts: ! part.frame.forget() ! self.frame.pack({'expand': 0}) ! def explode(self): ! self.collapsed = 0 ! for comp in self.htext, self.btext, self.pad: ! if comp: comp.pack(comp.packing) ! if self.parts: ! for part in self.parts: ! part.pack() ! self.frame.pack({'expand': 1}) def countlines(str, limit): ! i = 0 ! n = 0 ! while n < limit: ! i = string.find(str, '\n', i) ! if i < 0: break ! n = n+1 ! i = i+1 ! return n def main(): ! import sys ! import getopt ! import mhlib ! opts, args = getopt.getopt(sys.argv[1:], '') ! for o, a in opts: ! pass ! message = None ! folder = 'inbox' ! for arg in args: ! if arg[:1] == '+': ! folder = arg[1:] ! else: ! message = string.atoi(arg) ! mh = mhlib.MH() ! f = mh.openfolder(folder) ! if not message: ! message = f.getcurrent() ! m = f.openmessage(message) ! root = Tk() ! tk = root.tk ! top = MimeViewer(root, '+%s/%d' % (folder, message), m) ! top.pack() ! top.show() ! root.minsize(1, 1) ! tk.mainloop() if __name__ == '__main__': main() --- 10,143 ---- class MimeViewer: ! def __init__(self, parent, title, msg): ! self.title = title ! self.msg = msg ! self.frame = Frame(parent, {'relief': 'raised', 'bd': 2}) ! self.frame.packing = {'expand': 0, 'fill': 'both'} ! self.button = Checkbutton(self.frame, ! {'text': title, ! 'command': self.toggle}) ! self.button.pack({'anchor': 'w'}) ! headertext = msg.getheadertext( ! lambda x: x != 'received' and x[:5] != 'x400-') ! height = countlines(headertext, 4) ! if height: ! self.htext = ScrolledText(self.frame, ! {'height': height, ! 'width': 80, ! 'wrap': 'none', ! 'relief': 'raised', ! 'bd': 2}) ! self.htext.packing = {'expand': 1, 'fill': 'both', ! 'after': self.button} ! self.htext.insert('end', headertext) ! else: ! self.htext = Frame(self.frame, ! {'relief': 'raised', 'bd': 2}) ! self.htext.packing = {'side': 'top', ! 'ipady': 2, ! 'fill': 'x', ! 'after': self.button} ! body = msg.getbody() ! if type(body) == StringType: ! self.pad = None ! height = countlines(body, 10) ! if height: ! self.btext = ScrolledText(self.frame, ! {'height': height, ! 'width': 80, ! 'wrap': 'none', ! 'relief': 'raised', ! 'bd': 2}) ! self.btext.packing = {'expand': 1, ! 'fill': 'both'} ! self.btext.insert('end', body) ! else: ! self.btext = None ! self.parts = None ! else: ! self.pad = Frame(self.frame, ! {'relief': 'flat', 'bd': 2}) ! self.pad.packing = {'side': 'left', 'ipadx': 10, ! 'fill': 'y', 'after': self.htext} ! self.parts = [] ! for i in range(len(body)): ! p = MimeViewer(self.frame, ! '%s.%d' % (title, i+1), ! body[i]) ! self.parts.append(p) ! self.btext = None ! self.collapsed = 1 ! def pack(self): ! self.frame.pack(self.frame.packing) ! def destroy(self): ! self.frame.destroy() ! def show(self): ! if self.collapsed: ! self.button.invoke() ! def toggle(self): ! if self.collapsed: ! self.explode() ! else: ! self.collapse() ! def collapse(self): ! self.collapsed = 1 ! for comp in self.htext, self.btext, self.pad: ! if comp: ! comp.forget() ! if self.parts: ! for part in self.parts: ! part.frame.forget() ! self.frame.pack({'expand': 0}) ! def explode(self): ! self.collapsed = 0 ! for comp in self.htext, self.btext, self.pad: ! if comp: comp.pack(comp.packing) ! if self.parts: ! for part in self.parts: ! part.pack() ! self.frame.pack({'expand': 1}) def countlines(str, limit): ! i = 0 ! n = 0 ! while n < limit: ! i = string.find(str, '\n', i) ! if i < 0: break ! n = n+1 ! i = i+1 ! return n def main(): ! import sys ! import getopt ! import mhlib ! opts, args = getopt.getopt(sys.argv[1:], '') ! for o, a in opts: ! pass ! message = None ! folder = 'inbox' ! for arg in args: ! if arg[:1] == '+': ! folder = arg[1:] ! else: ! message = string.atoi(arg) ! mh = mhlib.MH() ! f = mh.openfolder(folder) ! if not message: ! message = f.getcurrent() ! m = f.openmessage(message) ! root = Tk() ! tk = root.tk ! top = MimeViewer(root, '+%s/%d' % (folder, message), m) ! top.pack() ! top.show() ! root.minsize(1, 1) ! tk.mainloop() if __name__ == '__main__': main() Index: ShellWindow.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/guido/ShellWindow.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ShellWindow.py 7 Oct 1997 14:37:31 -0000 1.3 --- ShellWindow.py 18 Jul 2004 06:09:08 -0000 1.4 *************** *** 11,151 **** class ShellWindow(ScrolledText): ! def __init__(self, master=None, shell=None, **cnf): ! if not shell: ! try: ! shell = os.environ['SHELL'] ! except KeyError: ! shell = '/bin/sh' ! shell = shell + ' -i' ! args = string.split(shell) ! shell = args[0] ! apply(ScrolledText.__init__, (self, master), cnf) ! self.pos = '1.0' ! self.bind('', self.inputhandler) ! self.bind('', self.sigint) ! self.bind('', self.sigterm) ! self.bind('', self.sigkill) ! self.bind('', self.sendeof) ! self.pid, self.fromchild, self.tochild = spawn(shell, args) ! self.tk.createfilehandler(self.fromchild, READABLE, ! self.outputhandler) ! def outputhandler(self, file, mask): ! data = os.read(file, BUFSIZE) ! if not data: ! self.tk.deletefilehandler(file) ! pid, sts = os.waitpid(self.pid, 0) ! print 'pid', pid, 'status', sts ! self.pid = None ! detail = sts>>8 ! cause = sts & 0xff ! if cause == 0: ! msg = "exit status %d" % detail ! else: ! msg = "killed by signal %d" % (cause & 0x7f) ! if cause & 0x80: ! msg = msg + " -- core dumped" ! Dialog(self.master, ! text=msg, ! title="Exit status", ! bitmap='warning', ! default=0, ! strings=('OK',)) ! return ! self.insert(END, data) ! self.pos = self.index("end - 1 char") ! self.yview_pickplace(END) ! def inputhandler(self, *args): ! if not self.pid: ! self.no_process() ! return "break" ! self.insert(END, "\n") ! line = self.get(self.pos, "end - 1 char") ! self.pos = self.index(END) ! os.write(self.tochild, line) ! return "break" ! def sendeof(self, *args): ! if not self.pid: ! self.no_process() ! return "break" ! os.close(self.tochild) ! return "break" ! def sendsig(self, sig): ! if not self.pid: ! self.no_process() ! return "break" ! os.kill(self.pid, sig) ! return "break" ! def sigint(self, *args): ! return self.sendsig(signal.SIGINT) ! def sigquit(self, *args): ! return self.sendsig(signal.SIGQUIT) ! def sigterm(self, *args): ! return self.sendsig(signal.SIGTERM) ! def sigkill(self, *args): ! return self.sendsig(signal.SIGKILL) ! def no_process(self): ! Dialog(self.master, ! text="No active process", ! title="No process", ! bitmap='error', ! default=0, ! strings=('OK',)) ! MAXFD = 100 # Max number of file descriptors (os.getdtablesize()???) def spawn(prog, args): ! p2cread, p2cwrite = os.pipe() ! c2pread, c2pwrite = os.pipe() ! pid = os.fork() ! if pid == 0: ! # Child ! for i in 0, 1, 2: ! try: ! os.close(i) ! except os.error: ! pass ! if os.dup(p2cread) <> 0: ! sys.stderr.write('popen2: bad read dup\n') ! if os.dup(c2pwrite) <> 1: ! sys.stderr.write('popen2: bad write dup\n') ! if os.dup(c2pwrite) <> 2: ! sys.stderr.write('popen2: bad write dup\n') ! for i in range(3, MAXFD): ! try: ! os.close(i) ! except: ! pass ! try: ! os.execvp(prog, args) ! finally: ! sys.stderr.write('execvp failed\n') ! os._exit(1) ! os.close(p2cread) ! os.close(c2pwrite) ! return pid, c2pread, p2cwrite def test(): ! shell = string.join(sys.argv[1:]) ! root = Tk() ! root.minsize(1, 1) ! if shell: ! w = ShellWindow(root, shell=shell) ! else: ! w = ShellWindow(root) ! w.pack(expand=1, fill=BOTH) ! w.focus_set() ! w.tk.mainloop() if __name__ == '__main__': ! test() --- 11,151 ---- class ShellWindow(ScrolledText): ! def __init__(self, master=None, shell=None, **cnf): ! if not shell: ! try: ! shell = os.environ['SHELL'] ! except KeyError: ! shell = '/bin/sh' ! shell = shell + ' -i' ! args = string.split(shell) ! shell = args[0] ! apply(ScrolledText.__init__, (self, master), cnf) ! self.pos = '1.0' ! self.bind('', self.inputhandler) ! self.bind('', self.sigint) ! self.bind('', self.sigterm) ! self.bind('', self.sigkill) ! self.bind('', self.sendeof) ! self.pid, self.fromchild, self.tochild = spawn(shell, args) ! self.tk.createfilehandler(self.fromchild, READABLE, ! self.outputhandler) ! def outputhandler(self, file, mask): ! data = os.read(file, BUFSIZE) ! if not data: ! self.tk.deletefilehandler(file) ! pid, sts = os.waitpid(self.pid, 0) ! print 'pid', pid, 'status', sts ! self.pid = None ! detail = sts>>8 ! cause = sts & 0xff ! if cause == 0: ! msg = "exit status %d" % detail ! else: ! msg = "killed by signal %d" % (cause & 0x7f) ! if cause & 0x80: ! msg = msg + " -- core dumped" ! Dialog(self.master, ! text=msg, ! title="Exit status", ! bitmap='warning', ! default=0, ! strings=('OK',)) ! return ! self.insert(END, data) ! self.pos = self.index("end - 1 char") ! self.yview_pickplace(END) ! def inputhandler(self, *args): ! if not self.pid: ! self.no_process() ! return "break" ! self.insert(END, "\n") ! line = self.get(self.pos, "end - 1 char") ! self.pos = self.index(END) ! os.write(self.tochild, line) ! return "break" ! def sendeof(self, *args): ! if not self.pid: ! self.no_process() ! return "break" ! os.close(self.tochild) ! return "break" ! def sendsig(self, sig): ! if not self.pid: ! self.no_process() ! return "break" ! os.kill(self.pid, sig) ! return "break" ! def sigint(self, *args): ! return self.sendsig(signal.SIGINT) ! def sigquit(self, *args): ! return self.sendsig(signal.SIGQUIT) ! def sigterm(self, *args): ! return self.sendsig(signal.SIGTERM) ! def sigkill(self, *args): ! return self.sendsig(signal.SIGKILL) ! def no_process(self): ! Dialog(self.master, ! text="No active process", ! title="No process", ! bitmap='error', ! default=0, ! strings=('OK',)) ! MAXFD = 100 # Max number of file descriptors (os.getdtablesize()???) def spawn(prog, args): ! p2cread, p2cwrite = os.pipe() ! c2pread, c2pwrite = os.pipe() ! pid = os.fork() ! if pid == 0: ! # Child ! for i in 0, 1, 2: ! try: ! os.close(i) ! except os.error: ! pass ! if os.dup(p2cread) <> 0: ! sys.stderr.write('popen2: bad read dup\n') ! if os.dup(c2pwrite) <> 1: ! sys.stderr.write('popen2: bad write dup\n') ! if os.dup(c2pwrite) <> 2: ! sys.stderr.write('popen2: bad write dup\n') ! for i in range(3, MAXFD): ! try: ! os.close(i) ! except: ! pass ! try: ! os.execvp(prog, args) ! finally: ! sys.stderr.write('execvp failed\n') ! os._exit(1) ! os.close(p2cread) ! os.close(c2pwrite) ! return pid, c2pread, p2cwrite def test(): ! shell = string.join(sys.argv[1:]) ! root = Tk() ! root.minsize(1, 1) ! if shell: ! w = ShellWindow(root, shell=shell) ! else: ! w = ShellWindow(root) ! w.pack(expand=1, fill=BOTH) ! w.focus_set() ! w.tk.mainloop() if __name__ == '__main__': ! test() Index: canvasevents.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/guido/canvasevents.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** canvasevents.py 3 Apr 1997 00:04:43 -0000 1.1 --- canvasevents.py 18 Jul 2004 06:09:08 -0000 1.2 *************** *** 10,14 **** class Group(Group): def bind(self, sequence=None, command=None): ! return self.canvas.tag_bind(self.id, sequence, command) class Object: --- 10,14 ---- class Group(Group): def bind(self, sequence=None, command=None): ! return self.canvas.tag_bind(self.id, sequence, command) class Object: *************** *** 34,76 **** def __init__(self, canvas, x=0, y=0, fill='red', text='object'): ! self.canvas = canvas ! self.x = x ! self.y = y ! self.pile = None ! self.group = Group(self.canvas) ! self.createitems(fill, text) def __str__(self): ! return str(self.group) def createitems(self, fill, text): ! self.__oval = Oval(self.canvas, ! self.x-20, self.y-10, self.x+20, self.y+10, ! fill=fill, width=3) ! self.group.addtag_withtag(self.__oval) ! self.__text = CanvasText(self.canvas, ! self.x, self.y, text=text) ! self.group.addtag_withtag(self.__text) def moveby(self, dx, dy): ! if dx == dy == 0: ! return ! self.group.move(dx, dy) ! self.x = self.x + dx ! self.y = self.y + dy def moveto(self, x, y): ! self.moveby(x - self.x, y - self.y) def transfer(self, pile): ! if self.pile: ! self.pile.delete(self) ! self.pile = None ! self.pile = pile ! if self.pile: ! self.pile.add(self) def tkraise(self): ! self.group.tkraise() --- 34,76 ---- def __init__(self, canvas, x=0, y=0, fill='red', text='object'): ! self.canvas = canvas ! self.x = x ! self.y = y ! self.pile = None ! self.group = Group(self.canvas) ! self.createitems(fill, text) def __str__(self): ! return str(self.group) def createitems(self, fill, text): ! self.__oval = Oval(self.canvas, ! self.x-20, self.y-10, self.x+20, self.y+10, ! fill=fill, width=3) ! self.group.addtag_withtag(self.__oval) ! self.__text = CanvasText(self.canvas, ! self.x, self.y, text=text) ! self.group.addtag_withtag(self.__text) def moveby(self, dx, dy): ! if dx == dy == 0: ! return ! self.group.move(dx, dy) ! self.x = self.x + dx ! self.y = self.y + dy def moveto(self, x, y): ! self.moveby(x - self.x, y - self.y) def transfer(self, pile): ! if self.pile: ! self.pile.delete(self) ! self.pile = None ! self.pile = pile ! if self.pile: ! self.pile.add(self) def tkraise(self): ! self.group.tkraise() *************** *** 80,87 **** def createitems(self, *args): ! self.__oval = Oval(self.canvas, ! self.x-20, self.y-10, self.x+20, self.y+10, ! fill='gray', outline='') ! self.group.addtag_withtag(self.__oval) --- 80,87 ---- def createitems(self, *args): ! self.__oval = Oval(self.canvas, ! self.x-20, self.y-10, self.x+20, self.y+10, ! fill='gray', outline='') ! self.group.addtag_withtag(self.__oval) *************** *** 91,126 **** def __init__(self, canvas, x, y, tag=None): ! self.canvas = canvas ! self.x = x ! self.y = y ! self.objects = [] ! self.bottom = Bottom(self.canvas, self.x, self.y) ! self.group = Group(self.canvas, tag=tag) ! self.group.addtag_withtag(self.bottom.group) ! self.bindhandlers() def bindhandlers(self): ! self.group.bind('<1>', self.clickhandler) ! self.group.bind('', self.doubleclickhandler) def add(self, object): ! self.objects.append(object) ! self.group.addtag_withtag(object.group) ! self.position(object) def delete(self, object): ! object.group.dtag(self.group) ! self.objects.remove(object) def position(self, object): ! object.tkraise() ! i = self.objects.index(object) ! object.moveto(self.x + i*4, self.y + i*8) def clickhandler(self, event): ! pass def doubleclickhandler(self, event): ! pass --- 91,126 ---- def __init__(self, canvas, x, y, tag=None): ! self.canvas = canvas ! self.x = x ! self.y = y ! self.objects = [] ! self.bottom = Bottom(self.canvas, self.x, self.y) ! self.group = Group(self.canvas, tag=tag) ! self.group.addtag_withtag(self.bottom.group) ! self.bindhandlers() def bindhandlers(self): ! self.group.bind('<1>', self.clickhandler) ! self.group.bind('', self.doubleclickhandler) def add(self, object): ! self.objects.append(object) ! self.group.addtag_withtag(object.group) ! self.position(object) def delete(self, object): ! object.group.dtag(self.group) ! self.objects.remove(object) def position(self, object): ! object.tkraise() ! i = self.objects.index(object) ! object.moveto(self.x + i*4, self.y + i*8) def clickhandler(self, event): ! pass def doubleclickhandler(self, event): ! pass *************** *** 128,174 **** def bindhandlers(self): ! Pile.bindhandlers(self) ! self.group.bind('', self.motionhandler) ! self.group.bind('', self.releasehandler) movethis = None def clickhandler(self, event): ! tags = self.canvas.gettags('current') ! for i in range(len(self.objects)): ! o = self.objects[i] ! if o.group.tag in tags: ! break ! else: ! self.movethis = None ! return ! self.movethis = self.objects[i:] ! for o in self.movethis: ! o.tkraise() ! self.lastx = event.x ! self.lasty = event.y doubleclickhandler = clickhandler def motionhandler(self, event): ! if not self.movethis: ! return ! dx = event.x - self.lastx ! dy = event.y - self.lasty ! self.lastx = event.x ! self.lasty = event.y ! for o in self.movethis: ! o.moveby(dx, dy) def releasehandler(self, event): ! objects = self.movethis ! if not objects: ! return ! self.movethis = None ! self.finishmove(objects) def finishmove(self, objects): ! for o in objects: ! self.position(o) --- 128,174 ---- def bindhandlers(self): ! Pile.bindhandlers(self) ! self.group.bind('', self.motionhandler) ! self.group.bind('', self.releasehandler) movethis = None def clickhandler(self, event): ! tags = self.canvas.gettags('current') ! for i in range(len(self.objects)): ! o = self.objects[i] ! if o.group.tag in tags: ! break ! else: ! self.movethis = None ! return ! self.movethis = self.objects[i:] ! for o in self.movethis: ! o.tkraise() ! self.lastx = event.x ! self.lasty = event.y doubleclickhandler = clickhandler def motionhandler(self, event): ! if not self.movethis: ! return ! dx = event.x - self.lastx ! dy = event.y - self.lasty ! self.lastx = event.x ! self.lasty = event.y ! for o in self.movethis: ! o.moveby(dx, dy) def releasehandler(self, event): ! objects = self.movethis ! if not objects: ! return ! self.movethis = None ! self.finishmove(objects) def finishmove(self, objects): ! for o in objects: ! self.position(o) *************** *** 180,206 **** def __init__(self, demo): ! self.demo = demo ! MovingPile.__init__(self, self.demo.canvas, self.x, self.y, self.tag) def doubleclickhandler(self, event): ! try: ! o = self.objects[-1] ! except IndexError: ! return ! o.transfer(self.other()) ! MovingPile.doubleclickhandler(self, event) def other(self): ! return self.demo.p2 def finishmove(self, objects): ! o = objects[0] ! p = self.other() ! x, y = o.x, o.y ! if (x-p.x)**2 + (y-p.y)**2 < (x-self.x)**2 + (y-self.y)**2: ! for o in objects: ! o.transfer(p) ! else: ! MovingPile.finishmove(self, objects) class Pile2(Pile1): --- 180,206 ---- def __init__(self, demo): ! self.demo = demo ! MovingPile.__init__(self, self.demo.canvas, self.x, self.y, self.tag) def doubleclickhandler(self, event): ! try: ! o = self.objects[-1] ! except IndexError: ! return ! o.transfer(self.other()) ! MovingPile.doubleclickhandler(self, event) def other(self): ! return self.demo.p2 def finishmove(self, objects): ! o = objects[0] ! p = self.other() ! x, y = o.x, o.y ! if (x-p.x)**2 + (y-p.y)**2 < (x-self.x)**2 + (y-self.y)**2: ! for o in objects: ! o.transfer(p) ! else: ! MovingPile.finishmove(self, objects) class Pile2(Pile1): *************** *** 211,215 **** def other(self): ! return self.demo.p1 --- 211,215 ---- def other(self): ! return self.demo.p1 *************** *** 217,234 **** def __init__(self, master): ! self.master = master ! self.canvas = Canvas(master, ! width=200, height=200, ! background='yellow', ! relief=SUNKEN, borderwidth=2) ! self.canvas.pack(expand=1, fill=BOTH) ! self.p1 = Pile1(self) ! self.p2 = Pile2(self) ! o1 = Object(self.canvas, fill='red', text='o1') ! o2 = Object(self.canvas, fill='green', text='o2') ! o3 = Object(self.canvas, fill='light blue', text='o3') ! o1.transfer(self.p1) ! o2.transfer(self.p1) ! o3.transfer(self.p2) --- 217,234 ---- def __init__(self, master): ! self.master = master ! self.canvas = Canvas(master, ! width=200, height=200, ! background='yellow', ! relief=SUNKEN, borderwidth=2) ! self.canvas.pack(expand=1, fill=BOTH) ! self.p1 = Pile1(self) ! self.p2 = Pile2(self) ! o1 = Object(self.canvas, fill='red', text='o1') ! o2 = Object(self.canvas, fill='green', text='o2') ! o3 = Object(self.canvas, fill='light blue', text='o3') ! o1.transfer(self.p1) ! o2.transfer(self.p1) ! o3.transfer(self.p2) Index: dialog.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/guido/dialog.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** dialog.py 7 Oct 1997 14:37:58 -0000 1.6 --- dialog.py 18 Jul 2004 06:09:08 -0000 1.7 *************** *** 26,34 **** msg = Message(top, width='3i', text=text, ! font='-Adobe-Times-Medium-R-Normal-*-180-*') msg.pack(side=RIGHT, expand=1, fill=BOTH, padx='3m', pady='3m') if bitmap: ! bm = Label(top, bitmap=bitmap) ! bm.pack(side=LEFT, padx='3m', pady='3m') # 3. Create a row of buttons at the bottom of the dialog. --- 26,34 ---- msg = Message(top, width='3i', text=text, ! font='-Adobe-Times-Medium-R-Normal-*-180-*') msg.pack(side=RIGHT, expand=1, fill=BOTH, padx='3m', pady='3m') if bitmap: ! bm = Label(top, bitmap=bitmap) ! bm.pack(side=LEFT, padx='3m', pady='3m') # 3. Create a row of buttons at the bottom of the dialog. *************** *** 38,53 **** i = 0 for but in args: ! b = Button(bot, text=but, command=lambda v=var,i=i: v.set(i)) ! buttons.append(b) ! if i == default: ! bd = Frame(bot, relief=SUNKEN, borderwidth=1) ! bd.pack(side=LEFT, expand=1, padx='3m', pady='2m') ! b.lift() ! b.pack (in_=bd, side=LEFT, ! padx='2m', pady='2m', ipadx='2m', ipady='1m') ! else: ! b.pack (side=LEFT, expand=1, ! padx='3m', pady='3m', ipadx='2m', ipady='1m') ! i = i+1 # 4. Set up a binding for , if there's a default, --- 38,53 ---- i = 0 for but in args: ! b = Button(bot, text=but, command=lambda v=var,i=i: v.set(i)) ! buttons.append(b) ! if i == default: ! bd = Frame(bot, relief=SUNKEN, borderwidth=1) ! bd.pack(side=LEFT, expand=1, padx='3m', pady='2m') ! b.lift() ! b.pack (in_=bd, side=LEFT, ! padx='2m', pady='2m', ipadx='2m', ipady='1m') ! else: ! b.pack (side=LEFT, expand=1, ! padx='3m', pady='3m', ipadx='2m', ipady='1m') ! i = i+1 # 4. Set up a binding for , if there's a default, *************** *** 55,62 **** if default >= 0: ! w.bind('', ! lambda e, b=buttons[default], v=var, i=default: ! (b.flash(), ! v.set(i))) oldFocus = w.focus_get() --- 55,62 ---- if default >= 0: ! w.bind('', ! lambda e, b=buttons[default], v=var, i=default: ! (b.flash(), ! v.set(i))) oldFocus = w.focus_get() *************** *** 76,96 **** def go(): i = dialog(mainWidget, ! 'Not Responding', ! "The file server isn't responding right now; " ! "I'll keep trying.", ! '', ! -1, ! 'OK') print 'pressed button', i i = dialog(mainWidget, ! 'File Modified', ! 'File "tcl.h" has been modified since ' ! 'the last time it was saved. ' ! 'Do you want to save it before exiting the application?', ! 'warning', ! 0, ! 'Save File', ! 'Discard Changes', ! 'Return To Editor') print 'pressed button', i --- 76,96 ---- def go(): i = dialog(mainWidget, ! 'Not Responding', ! "The file server isn't responding right now; " ! "I'll keep trying.", ! '', ! -1, ! 'OK') print 'pressed button', i i = dialog(mainWidget, ! 'File Modified', ! 'File "tcl.h" has been modified since ' ! 'the last time it was saved. ' ! 'Do you want to save it before exiting the application?', ! 'warning', ! 0, ! 'Save File', ! 'Discard Changes', ! 'Return To Editor') print 'pressed button', i Index: electrons.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/guido/electrons.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** electrons.py 26 May 1998 21:43:44 -0000 1.9 --- electrons.py 18 Jul 2004 06:09:08 -0000 1.10 *************** *** 1,5 **** #! /usr/bin/env python ! # Simulate "electrons" migrating across the screen. # An optional bitmap file in can be in the background. # --- 1,5 ---- #! /usr/bin/env python ! # Simulate "electrons" migrating across the screen. # An optional bitmap file in can be in the background. # *************** *** 19,91 **** class Electrons: ! # Create our objects ! def __init__(self, n, bitmap = None): ! self.n = n ! self.tk = tk = Tk() ! self.canvas = c = Canvas(tk) ! c.pack() ! width, height = tk.getint(c['width']), tk.getint(c['height']) ! # Add background bitmap ! if bitmap: ! self.bitmap = c.create_bitmap(width/2, height/2, ! bitmap=bitmap, ! foreground='blue') ! self.pieces = [] ! x1, y1, x2, y2 = 10,70,14,74 ! for i in range(n): ! p = c.create_oval(x1, y1, x2, y2, fill='red') ! self.pieces.append(p) ! y1, y2 = y1 +2, y2 + 2 ! self.tk.update() ! def random_move(self, n): ! c = self.canvas ! for p in self.pieces: ! x = random.choice(range(-2,4)) ! y = random.choice(range(-3,4)) ! c.move(p, x, y) ! self.tk.update() ! # Run -- allow 500 movemens ! def run(self): ! try: ! for i in range(500): ! self.random_move(self.n) ! except TclError: ! try: ! self.tk.destroy() ! except TclError: ! pass # Main program def main(): ! import sys, string ! # First argument is number of electrons, default 30 ! if sys.argv[1:]: ! n = string.atoi(sys.argv[1]) ! else: ! n = 30 ! # Second argument is bitmap file, default none ! if sys.argv[2:]: ! bitmap = sys.argv[2] ! # Reverse meaning of leading '@' compared to Tk ! if bitmap[0] == '@': bitmap = bitmap[1:] ! else: bitmap = '@' + bitmap ! else: ! bitmap = None ! # Create the graphical objects... ! h = Electrons(n, bitmap) ! # ...and run! ! h.run() # Call main when run as script if __name__ == '__main__': ! main() --- 19,91 ---- class Electrons: ! # Create our objects ! def __init__(self, n, bitmap = None): ! self.n = n ! self.tk = tk = Tk() ! self.canvas = c = Canvas(tk) ! c.pack() ! width, height = tk.getint(c['width']), tk.getint(c['height']) ! # Add background bitmap ! if bitmap: ! self.bitmap = c.create_bitmap(width/2, height/2, ! bitmap=bitmap, ! foreground='blue') ! self.pieces = [] ! x1, y1, x2, y2 = 10,70,14,74 ! for i in range(n): ! p = c.create_oval(x1, y1, x2, y2, fill='red') ! self.pieces.append(p) ! y1, y2 = y1 +2, y2 + 2 ! self.tk.update() ! def random_move(self, n): ! c = self.canvas ! for p in self.pieces: ! x = random.choice(range(-2,4)) ! y = random.choice(range(-3,4)) ! c.move(p, x, y) ! self.tk.update() ! # Run -- allow 500 movemens ! def run(self): ! try: ! for i in range(500): ! self.random_move(self.n) ! except TclError: ! try: ! self.tk.destroy() ! except TclError: ! pass # Main program def main(): ! import sys, string ! # First argument is number of electrons, default 30 ! if sys.argv[1:]: ! n = string.atoi(sys.argv[1]) ! else: ! n = 30 ! # Second argument is bitmap file, default none ! if sys.argv[2:]: ! bitmap = sys.argv[2] ! # Reverse meaning of leading '@' compared to Tk ! if bitmap[0] == '@': bitmap = bitmap[1:] ! else: bitmap = '@' + bitmap ! else: ! bitmap = None ! # Create the graphical objects... ! h = Electrons(n, bitmap) ! # ...and run! ! h.run() # Call main when run as script if __name__ == '__main__': ! main() Index: hanoi.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/guido/hanoi.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** hanoi.py 22 Aug 1997 20:56:07 -0000 1.3 --- hanoi.py 18 Jul 2004 06:09:08 -0000 1.4 *************** *** 17,24 **** # as temporary. For each move, call report() def hanoi(n, a, b, c, report): ! if n <= 0: return ! hanoi(n-1, a, c, b, report) ! report(n, a, b) ! hanoi(n-1, c, b, a, report) --- 17,24 ---- # as temporary. For each move, call report() def hanoi(n, a, b, c, report): ! if n <= 0: return ! hanoi(n-1, a, c, b, report) ! report(n, a, b) ! hanoi(n-1, c, b, a, report) *************** *** 26,154 **** class Tkhanoi: ! # Create our objects ! def __init__(self, n, bitmap = None): ! self.n = n ! self.tk = tk = Tk() ! self.canvas = c = Canvas(tk) ! c.pack() ! width, height = tk.getint(c['width']), tk.getint(c['height']) ! # Add background bitmap ! if bitmap: ! self.bitmap = c.create_bitmap(width/2, height/2, ! bitmap=bitmap, ! foreground='blue') ! # Generate pegs ! pegwidth = 10 ! pegheight = height/2 ! pegdist = width/3 ! x1, y1 = (pegdist-pegwidth)/2, height*1/3 ! x2, y2 = x1+pegwidth, y1+pegheight ! self.pegs = [] ! p = c.create_rectangle(x1, y1, x2, y2, fill='black') ! self.pegs.append(p) ! x1, x2 = x1+pegdist, x2+pegdist ! p = c.create_rectangle(x1, y1, x2, y2, fill='black') ! self.pegs.append(p) ! x1, x2 = x1+pegdist, x2+pegdist ! p = c.create_rectangle(x1, y1, x2, y2, fill='black') ! self.pegs.append(p) ! self.tk.update() ! # Generate pieces ! pieceheight = pegheight/16 ! maxpiecewidth = pegdist*2/3 ! minpiecewidth = 2*pegwidth ! self.pegstate = [[], [], []] ! self.pieces = {} ! x1, y1 = (pegdist-maxpiecewidth)/2, y2-pieceheight-2 ! x2, y2 = x1+maxpiecewidth, y1+pieceheight ! dx = (maxpiecewidth-minpiecewidth) / (2*max(1, n-1)) ! for i in range(n, 0, -1): ! p = c.create_rectangle(x1, y1, x2, y2, fill='red') ! self.pieces[i] = p ! self.pegstate[0].append(i) ! x1, x2 = x1 + dx, x2-dx ! y1, y2 = y1 - pieceheight-2, y2-pieceheight-2 ! self.tk.update() ! self.tk.after(25) ! # Run -- never returns ! def run(self): ! while 1: ! hanoi(self.n, 0, 1, 2, self.report) ! hanoi(self.n, 1, 2, 0, self.report) ! hanoi(self.n, 2, 0, 1, self.report) ! hanoi(self.n, 0, 2, 1, self.report) ! hanoi(self.n, 2, 1, 0, self.report) ! hanoi(self.n, 1, 0, 2, self.report) ! # Reporting callback for the actual hanoi function ! def report(self, i, a, b): ! if self.pegstate[a][-1] != i: raise RuntimeError # Assertion ! del self.pegstate[a][-1] ! p = self.pieces[i] ! c = self.canvas ! # Lift the piece above peg a ! ax1, ay1, ax2, ay2 = c.bbox(self.pegs[a]) ! while 1: ! x1, y1, x2, y2 = c.bbox(p) ! if y2 < ay1: break ! c.move(p, 0, -1) ! self.tk.update() ! # Move it towards peg b ! bx1, by1, bx2, by2 = c.bbox(self.pegs[b]) ! newcenter = (bx1+bx2)/2 ! while 1: ! x1, y1, x2, y2 = c.bbox(p) ! center = (x1+x2)/2 ! if center == newcenter: break ! if center > newcenter: c.move(p, -1, 0) ! else: c.move(p, 1, 0) ! self.tk.update() ! # Move it down on top of the previous piece ! pieceheight = y2-y1 ! newbottom = by2 - pieceheight*len(self.pegstate[b]) - 2 ! while 1: ! x1, y1, x2, y2 = c.bbox(p) ! if y2 >= newbottom: break ! c.move(p, 0, 1) ! self.tk.update() ! # Update peg state ! self.pegstate[b].append(i) # Main program def main(): ! import sys, string ! # First argument is number of pegs, default 4 ! if sys.argv[1:]: ! n = string.atoi(sys.argv[1]) ! else: ! n = 4 ! # Second argument is bitmap file, default none ! if sys.argv[2:]: ! bitmap = sys.argv[2] ! # Reverse meaning of leading '@' compared to Tk ! if bitmap[0] == '@': bitmap = bitmap[1:] ! else: bitmap = '@' + bitmap ! else: ! bitmap = None ! # Create the graphical objects... ! h = Tkhanoi(n, bitmap) ! # ...and run! ! h.run() # Call main when run as script if __name__ == '__main__': ! main() --- 26,154 ---- class Tkhanoi: ! # Create our objects ! def __init__(self, n, bitmap = None): ! self.n = n ! self.tk = tk = Tk() ! self.canvas = c = Canvas(tk) ! c.pack() ! width, height = tk.getint(c['width']), tk.getint(c['height']) ! # Add background bitmap ! if bitmap: ! self.bitmap = c.create_bitmap(width/2, height/2, ! bitmap=bitmap, ! foreground='blue') ! # Generate pegs ! pegwidth = 10 ! pegheight = height/2 ! pegdist = width/3 ! x1, y1 = (pegdist-pegwidth)/2, height*1/3 ! x2, y2 = x1+pegwidth, y1+pegheight ! self.pegs = [] ! p = c.create_rectangle(x1, y1, x2, y2, fill='black') ! self.pegs.append(p) ! x1, x2 = x1+pegdist, x2+pegdist ! p = c.create_rectangle(x1, y1, x2, y2, fill='black') ! self.pegs.append(p) ! x1, x2 = x1+pegdist, x2+pegdist ! p = c.create_rectangle(x1, y1, x2, y2, fill='black') ! self.pegs.append(p) ! self.tk.update() ! # Generate pieces ! pieceheight = pegheight/16 ! maxpiecewidth = pegdist*2/3 ! minpiecewidth = 2*pegwidth ! self.pegstate = [[], [], []] ! self.pieces = {} ! x1, y1 = (pegdist-maxpiecewidth)/2, y2-pieceheight-2 ! x2, y2 = x1+maxpiecewidth, y1+pieceheight ! dx = (maxpiecewidth-minpiecewidth) / (2*max(1, n-1)) ! for i in range(n, 0, -1): ! p = c.create_rectangle(x1, y1, x2, y2, fill='red') ! self.pieces[i] = p ! self.pegstate[0].append(i) ! x1, x2 = x1 + dx, x2-dx ! y1, y2 = y1 - pieceheight-2, y2-pieceheight-2 ! self.tk.update() ! self.tk.after(25) ! # Run -- never returns ! def run(self): ! while 1: ! hanoi(self.n, 0, 1, 2, self.report) ! hanoi(self.n, 1, 2, 0, self.report) ! hanoi(self.n, 2, 0, 1, self.report) ! hanoi(self.n, 0, 2, 1, self.report) ! hanoi(self.n, 2, 1, 0, self.report) ! hanoi(self.n, 1, 0, 2, self.report) ! # Reporting callback for the actual hanoi function ! def report(self, i, a, b): ! if self.pegstate[a][-1] != i: raise RuntimeError # Assertion ! del self.pegstate[a][-1] ! p = self.pieces[i] ! c = self.canvas ! # Lift the piece above peg a ! ax1, ay1, ax2, ay2 = c.bbox(self.pegs[a]) ! while 1: ! x1, y1, x2, y2 = c.bbox(p) ! if y2 < ay1: break ! c.move(p, 0, -1) ! self.tk.update() ! # Move it towards peg b ! bx1, by1, bx2, by2 = c.bbox(self.pegs[b]) ! newcenter = (bx1+bx2)/2 ! while 1: ! x1, y1, x2, y2 = c.bbox(p) ! center = (x1+x2)/2 ! if center == newcenter: break ! if center > newcenter: c.move(p, -1, 0) ! else: c.move(p, 1, 0) ! self.tk.update() ! # Move it down on top of the previous piece ! pieceheight = y2-y1 ! newbottom = by2 - pieceheight*len(self.pegstate[b]) - 2 ! while 1: ! x1, y1, x2, y2 = c.bbox(p) ! if y2 >= newbottom: break ! c.move(p, 0, 1) ! self.tk.update() ! # Update peg state ! self.pegstate[b].append(i) # Main program def main(): ! import sys, string ! # First argument is number of pegs, default 4 ! if sys.argv[1:]: ! n = string.atoi(sys.argv[1]) ! else: ! n = 4 ! # Second argument is bitmap file, default none ! if sys.argv[2:]: ! bitmap = sys.argv[2] ! # Reverse meaning of leading '@' compared to Tk ! if bitmap[0] == '@': bitmap = bitmap[1:] ! else: bitmap = '@' + bitmap ! else: ! bitmap = None ! # Create the graphical objects... ! h = Tkhanoi(n, bitmap) ! # ...and run! ! h.run() # Call main when run as script if __name__ == '__main__': ! main() Index: hello.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/guido/hello.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** hello.py 10 Apr 1995 11:46:37 -0000 1.1 --- hello.py 18 Jul 2004 06:09:08 -0000 1.2 *************** *** 5,17 **** def main(): ! root = Tk() ! button = Button(root) ! button['text'] = 'Hello, world' ! button['command'] = quit_callback # See below ! button.pack() ! root.mainloop() def quit_callback(): ! sys.exit(0) main() --- 5,17 ---- def main(): ! root = Tk() ! button = Button(root) ! button['text'] = 'Hello, world' ! button['command'] = quit_callback # See below ! button.pack() ! root.mainloop() def quit_callback(): ! sys.exit(0) main() Index: kill.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/guido/kill.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** kill.py 27 Nov 1996 19:51:26 -0000 1.5 --- kill.py 18 Jul 2004 06:09:08 -0000 1.6 *************** *** 9,99 **** class BarButton(Menubutton): ! def __init__(self, master=None, **cnf): ! apply(Menubutton.__init__, (self, master), cnf) ! self.pack(side=LEFT) ! self.menu = Menu(self, name='menu') ! self['menu'] = self.menu class Kill(Frame): ! # List of (name, option, pid_column) ! format_list = [('Default', '', 0), ! ('Long', '-l', 2), ! ('User', '-u', 1), ! ('Jobs', '-j', 1), ! ('Signal', '-s', 1), ! ('Memory', '-m', 0), ! ('VM', '-v', 0), ! ('Hex', '-X', 0)] ! def kill(self, selected): ! c = self.format_list[self.format.get()][2] ! pid = split(selected)[c] ! os.system('kill -9 ' + pid) ! self.do_update() ! def do_update(self): ! name, option, column = self.format_list[self.format.get()] ! s = commands.getoutput('ps -w ' + option) ! list = splitfields(s, '\n') ! self.header.set(list[0]) ! del list[0] ! y = self.frame.vscroll.get()[0] ! self.frame.list.delete(0, AtEnd()) ! for line in list: ! self.frame.list.insert(0, line) ! self.frame.list.yview(int(y)) ! def do_motion(self, e): ! e.widget.select_clear(0, END) ! e.widget.select_set(e.widget.nearest(e.y)) ! def do_leave(self, e): ! e.widget.select_clear(0, END) ! def do_1(self, e): ! self.kill(e.widget.get(e.widget.nearest(e.y))) ! def __init__(self, master=None, **cnf): ! Frame.__init__(self, master, cnf) ! self.pack(expand=1, fill=BOTH) ! self.bar = Frame(self, name='bar', relief=RAISED, ! borderwidth=2) ! self.bar.pack(fill=X) ! self.bar.file = BarButton(self.bar, text='File') ! self.bar.file.menu.add_command( ! label='Quit', command=self.quit) ! self.bar.view = BarButton(self.bar, text='View') ! self.format = IntVar(self) ! self.format.set(2) ! for num in range(len(self.format_list)): ! self.bar.view.menu.add_radiobutton( ! label=self.format_list[num][0], ! command=self.do_update, ! variable=self.format, ! value=num) ! #self.bar.view.menu.add_separator() ! #XXX ... ! self.bar.tk_menuBar(self.bar.file, self.bar.view) ! self.frame = Frame(self, relief=RAISED, borderwidth=2) ! self.frame.pack(expand=1, fill=BOTH) ! self.header = StringVar(self) ! self.frame.label = Label(self.frame, relief=FLAT, anchor=NW, ! borderwidth=0, ! textvariable=self.header) ! self.frame.label.pack(fill=X) ! self.frame.vscroll = Scrollbar(self.frame, orient=VERTICAL) ! self.frame.list = Listbox(self.frame, relief=SUNKEN, ! selectbackground='#eed5b7', ! selectborderwidth=0, ! yscroll=self.frame.vscroll.set) ! self.frame.vscroll['command'] = self.frame.list.yview ! self.frame.vscroll.pack(side=RIGHT, fill=Y) ! self.frame.list.pack(expand=1, fill=BOTH) ! self.update = Button(self, text="Update", ! command=self.do_update) ! self.update.pack(expand=1, fill=X) ! self.frame.list.bind('', self.do_motion) ! self.frame.list.bind('', self.do_leave) ! self.frame.list.bind('<1>', self.do_1) ! self.do_update() if __name__ == '__main__': ! kill = Kill(None, borderwidth=5) ! kill.winfo_toplevel().title('Tkinter Process Killer') ! kill.winfo_toplevel().minsize(1, 1) ! kill.mainloop() ! --- 9,98 ---- class BarButton(Menubutton): ! def __init__(self, master=None, **cnf): ! apply(Menubutton.__init__, (self, master), cnf) ! self.pack(side=LEFT) ! self.menu = Menu(self, name='menu') ! self['menu'] = self.menu class Kill(Frame): ! # List of (name, option, pid_column) ! format_list = [('Default', '', 0), ! ('Long', '-l', 2), ! ('User', '-u', 1), ! ('Jobs', '-j', 1), ! ('Signal', '-s', 1), ! ('Memory', '-m', 0), ! ('VM', '-v', 0), ! ('Hex', '-X', 0)] ! def kill(self, selected): ! c = self.format_list[self.format.get()][2] ! pid = split(selected)[c] ! os.system('kill -9 ' + pid) ! self.do_update() ! def do_update(self): ! name, option, column = self.format_list[self.format.get()] ! s = commands.getoutput('ps -w ' + option) ! list = splitfields(s, '\n') ! self.header.set(list[0]) ! del list[0] ! y = self.frame.vscroll.get()[0] ! self.frame.list.delete(0, AtEnd()) ! for line in list: ! self.frame.list.insert(0, line) ! self.frame.list.yview(int(y)) ! def do_motion(self, e): ! e.widget.select_clear(0, END) ! e.widget.select_set(e.widget.nearest(e.y)) ! def do_leave(self, e): ! e.widget.select_clear(0, END) ! def do_1(self, e): ! self.kill(e.widget.get(e.widget.nearest(e.y))) ! def __init__(self, master=None, **cnf): ! Frame.__init__(self, master, cnf) ! self.pack(expand=1, fill=BOTH) ! self.bar = Frame(self, name='bar', relief=RAISED, ! borderwidth=2) ! self.bar.pack(fill=X) ! self.bar.file = BarButton(self.bar, text='File') ! self.bar.file.menu.add_command( ! label='Quit', command=self.quit) ! self.bar.view = BarButton(self.bar, text='View') ! self.format = IntVar(self) ! self.format.set(2) ! for num in range(len(self.format_list)): ! self.bar.view.menu.add_radiobutton( ! label=self.format_list[num][0], ! command=self.do_update, ! variable=self.format, ! value=num) ! #self.bar.view.menu.add_separator() ! #XXX ... ! self.bar.tk_menuBar(self.bar.file, self.bar.view) ! self.frame = Frame(self, relief=RAISED, borderwidth=2) ! self.frame.pack(expand=1, fill=BOTH) ! self.header = StringVar(self) ! self.frame.label = Label(self.frame, relief=FLAT, anchor=NW, ! borderwidth=0, ! textvariable=self.header) ! self.frame.label.pack(fill=X) ! self.frame.vscroll = Scrollbar(self.frame, orient=VERTICAL) ! self.frame.list = Listbox(self.frame, relief=SUNKEN, ! selectbackground='#eed5b7', ! selectborderwidth=0, ! yscroll=self.frame.vscroll.set) ! self.frame.vscroll['command'] = self.frame.list.yview ! self.frame.vscroll.pack(side=RIGHT, fill=Y) ! self.frame.list.pack(expand=1, fill=BOTH) ! self.update = Button(self, text="Update", ! command=self.do_update) ! self.update.pack(expand=1, fill=X) ! self.frame.list.bind('', self.do_motion) ! self.frame.list.bind('', self.do_leave) ! self.frame.list.bind('<1>', self.do_1) ! self.do_update() if __name__ == '__main__': ! kill = Kill(None, borderwidth=5) ! kill.winfo_toplevel().title('Tkinter Process Killer') ! kill.winfo_toplevel().minsize(1, 1) ! kill.mainloop() Index: listtree.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/guido/listtree.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** listtree.py 30 Jul 1996 18:56:11 -0000 1.3 --- listtree.py 18 Jul 2004 06:09:08 -0000 1.4 *************** *** 7,37 **** def listtree(master, app): ! list = Listbox(master, name='list') ! list.pack(expand=1, fill=BOTH) ! listnodes(list, app, '.', 0) ! return list def listnodes(list, app, widget, level): ! klass = list.send(app, 'winfo', 'class', widget) ! ## i = string.rindex(widget, '.') ! ## list.insert(END, '%s%s (%s)' % ((level-1)*'. ', widget[i:], klass)) ! list.insert(END, '%s (%s)' % (widget, klass)) ! children = list.tk.splitlist( ! list.send(app, 'winfo', 'children', widget)) ! for c in children: ! listnodes(list, app, c, level+1) def main(): ! if not sys.argv[1:]: ! sys.stderr.write('Usage: listtree appname\n') ! sys.exit(2) ! app = sys.argv[1] ! tk = Tk() ! tk.minsize(1, 1) ! f = Frame(tk, name='f') ! f.pack(expand=1, fill=BOTH) ! list = listtree(f, app) ! tk.mainloop() if __name__ == '__main__': ! main() --- 7,37 ---- def listtree(master, app): ! list = Listbox(master, name='list') ! list.pack(expand=1, fill=BOTH) ! listnodes(list, app, '.', 0) ! return list def listnodes(list, app, widget, level): ! klass = list.send(app, 'winfo', 'class', widget) ! ## i = string.rindex(widget, '.') ! ## list.insert(END, '%s%s (%s)' % ((level-1)*'. ', widget[i:], klass)) ! list.insert(END, '%s (%s)' % (widget, klass)) ! children = list.tk.splitlist( ! list.send(app, 'winfo', 'children', widget)) ! for c in children: ! listnodes(list, app, c, level+1) def main(): ! if not sys.argv[1:]: ! sys.stderr.write('Usage: listtree appname\n') ! sys.exit(2) ! app = sys.argv[1] ! tk = Tk() ! tk.minsize(1, 1) ! f = Frame(tk, name='f') ! f.pack(expand=1, fill=BOTH) ! list = listtree(f, app) ! tk.mainloop() if __name__ == '__main__': ! main() Index: mbox.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/guido/mbox.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** mbox.py 12 Feb 2004 17:35:04 -0000 1.5 --- mbox.py 18 Jul 2004 06:09:08 -0000 1.6 *************** *** 17,285 **** def main(): ! global root, tk, top, mid, bot ! global folderbox, foldermenu, scanbox, scanmenu, viewer ! global folder, seq ! global mh, mhf ! # Parse command line options ! folder = 'inbox' ! seq = 'all' ! try: ! opts, args = getopt.getopt(sys.argv[1:], '') ! except getopt.error, msg: ! print msg ! sys.exit(2) ! for arg in args: ! if arg[:1] == '+': ! folder = arg[1:] ! else: ! seq = arg ! # Initialize MH ! mh = mhlib.MH() ! mhf = mh.openfolder(folder) ! # Build widget hierarchy ! root = Tk() ! tk = root.tk ! top = Frame(root) ! top.pack({'expand': 1, 'fill': 'both'}) ! # Build right part: folder list ! right = Frame(top) ! right.pack({'fill': 'y', 'side': 'right'}) ! folderbar = Scrollbar(right, {'relief': 'sunken', 'bd': 2}) ! folderbar.pack({'fill': 'y', 'side': 'right'}) ! folderbox = Listbox(right, {'exportselection': 0}) ! folderbox.pack({'expand': 1, 'fill': 'both', 'side': 'left'}) ! foldermenu = Menu(root) ! foldermenu.add('command', ! {'label': 'Open Folder', ! 'command': open_folder}) ! foldermenu.add('separator') ! foldermenu.add('command', ! {'label': 'Quit', ! 'command': 'exit'}) ! foldermenu.bind('', folder_unpost) ! folderbox['yscrollcommand'] = (folderbar, 'set') ! folderbar['command'] = (folderbox, 'yview') ! folderbox.bind('', open_folder, 1) ! folderbox.bind('<3>', folder_post) ! # Build left part: scan list ! left = Frame(top) ! left.pack({'expand': 1, 'fill': 'both', 'side': 'left'}) ! scanbar = Scrollbar(left, {'relief': 'sunken', 'bd': 2}) ! scanbar.pack({'fill': 'y', 'side': 'right'}) ! scanbox = Listbox(left, {'font': 'fixed'}) ! scanbox.pack({'expand': 1, 'fill': 'both', 'side': 'left'}) ! scanmenu = Menu(root) ! scanmenu.add('command', ! {'label': 'Open Message', ! 'command': open_message}) ! scanmenu.add('command', ! {'label': 'Remove Message', ! 'command': remove_message}) ! scanmenu.add('command', ! {'label': 'Refile Message', ! 'command': refile_message}) ! scanmenu.add('separator') ! scanmenu.add('command', ! {'label': 'Quit', ! 'command': 'exit'}) ! scanmenu.bind('', scan_unpost) ! scanbox['yscrollcommand'] = (scanbar, 'set') ! scanbar['command'] = (scanbox, 'yview') ! scanbox.bind('', open_message) ! scanbox.bind('<3>', scan_post) ! # Separator between middle and bottom part ! rule2 = Frame(root, {'bg': 'black'}) ! rule2.pack({'fill': 'x'}) ! # Build bottom part: current message ! bot = Frame(root) ! bot.pack({'expand': 1, 'fill': 'both'}) ! # ! viewer = None ! # Window manager commands ! root.minsize(800, 1) # Make window resizable ! # Fill folderbox with text ! setfolders() ! # Fill scanbox with text ! rescan() ! # Enter mainloop ! root.mainloop() def folder_post(e): ! x, y = e.x_root, e.y_root ! foldermenu.post(x - 10, y - 10) ! foldermenu.grab_set() def folder_unpost(e): ! tk.call('update', 'idletasks') ! foldermenu.grab_release() ! foldermenu.unpost() ! foldermenu.invoke('active') def scan_post(e): ! x, y = e.x_root, e.y_root ! scanmenu.post(x - 10, y - 10) ! scanmenu.grab_set() def scan_unpost(e): ! tk.call('update', 'idletasks') ! scanmenu.grab_release() ! scanmenu.unpost() ! scanmenu.invoke('active') scanparser = regex.compile('^ *\([0-9]+\)') def open_folder(e=None): ! global folder, mhf ! sel = folderbox.curselection() ! if len(sel) != 1: ! if len(sel) > 1: ! msg = "Please open one folder at a time" ! else: ! msg = "Please select a folder to open" ! dialog(root, "Can't Open Folder", msg, "", 0, "OK") ! return ! i = sel[0] ! folder = folderbox.get(i) ! mhf = mh.openfolder(folder) ! rescan() def open_message(e=None): ! global viewer ! sel = scanbox.curselection() ! if len(sel) != 1: ! if len(sel) > 1: ! msg = "Please open one message at a time" ! else: ! msg = "Please select a message to open" ! dialog(root, "Can't Open Message", msg, "", 0, "OK") ! return ! cursor = scanbox['cursor'] ! scanbox['cursor'] = 'watch' ! tk.call('update', 'idletasks') ! i = sel[0] ! line = scanbox.get(i) ! if scanparser.match(line) >= 0: ! num = string.atoi(scanparser.group(1)) ! m = mhf.openmessage(num) ! if viewer: viewer.destroy() ! from MimeViewer import MimeViewer ! viewer = MimeViewer(bot, '+%s/%d' % (folder, num), m) ! viewer.pack() ! viewer.show() ! scanbox['cursor'] = cursor def interestingheader(header): ! return header != 'received' def remove_message(e=None): ! itop = scanbox.nearest(0) ! sel = scanbox.curselection() ! if not sel: ! dialog(root, "No Message To Remove", ! "Please select a message to remove", "", 0, "OK") ! return ! todo = [] ! for i in sel: ! line = scanbox.get(i) ! if scanparser.match(line) >= 0: ! todo.append(string.atoi(scanparser.group(1))) ! mhf.removemessages(todo) ! rescan() ! fixfocus(min(todo), itop) lastrefile = '' tofolder = None def refile_message(e=None): ! global lastrefile, tofolder ! itop = scanbox.nearest(0) ! sel = scanbox.curselection() ! if not sel: ! dialog(root, "No Message To Refile", ! "Please select a message to refile", "", 0, "OK") ! return ! foldersel = folderbox.curselection() ! if len(foldersel) != 1: ! if not foldersel: ! msg = "Please select a folder to refile to" ! else: ! msg = "Please select exactly one folder to refile to" ! dialog(root, "No Folder To Refile", msg, "", 0, "OK") ! return ! refileto = folderbox.get(foldersel[0]) ! todo = [] ! for i in sel: ! line = scanbox.get(i) ! if scanparser.match(line) >= 0: ! todo.append(string.atoi(scanparser.group(1))) ! if lastrefile != refileto or not tofolder: ! lastrefile = refileto ! tofolder = None ! tofolder = mh.openfolder(lastrefile) ! mhf.refilemessages(todo, tofolder) ! rescan() ! fixfocus(min(todo), itop) def fixfocus(near, itop): ! n = scanbox.size() ! for i in range(n): ! line = scanbox.get(repr(i)) ! if scanparser.match(line) >= 0: ! num = string.atoi(scanparser.group(1)) ! if num >= near: ! break ! else: ! i = 'end' ! scanbox.select_from(i) ! scanbox.yview(itop) def setfolders(): ! folderbox.delete(0, 'end') ! for fn in mh.listallfolders(): ! folderbox.insert('end', fn) def rescan(): ! global viewer ! if viewer: ! viewer.destroy() ! viewer = None ! scanbox.delete(0, 'end') ! for line in scanfolder(folder, seq): ! scanbox.insert('end', line) def scanfolder(folder = 'inbox', sequence = 'all'): ! return map( ! lambda line: line[:-1], ! os.popen('scan +%s %s' % (folder, sequence), 'r').readlines()) main() --- 17,285 ---- def main(): ! global root, tk, top, mid, bot ! global folderbox, foldermenu, scanbox, scanmenu, viewer ! global folder, seq ! global mh, mhf ! # Parse command line options ! folder = 'inbox' ! seq = 'all' ! try: ! opts, args = getopt.getopt(sys.argv[1:], '') ! except getopt.error, msg: ! print msg ! sys.exit(2) ! for arg in args: ! if arg[:1] == '+': ! folder = arg[1:] ! else: ! seq = arg ! # Initialize MH ! mh = mhlib.MH() ! mhf = mh.openfolder(folder) ! # Build widget hierarchy ! root = Tk() ! tk = root.tk ! top = Frame(root) ! top.pack({'expand': 1, 'fill': 'both'}) ! # Build right part: folder list ! right = Frame(top) ! right.pack({'fill': 'y', 'side': 'right'}) ! folderbar = Scrollbar(right, {'relief': 'sunken', 'bd': 2}) ! folderbar.pack({'fill': 'y', 'side': 'right'}) ! folderbox = Listbox(right, {'exportselection': 0}) ! folderbox.pack({'expand': 1, 'fill': 'both', 'side': 'left'}) ! foldermenu = Menu(root) ! foldermenu.add('command', ! {'label': 'Open Folder', ! 'command': open_folder}) ! foldermenu.add('separator') ! foldermenu.add('command', ! {'label': 'Quit', ! 'command': 'exit'}) ! foldermenu.bind('', folder_unpost) ! folderbox['yscrollcommand'] = (folderbar, 'set') ! folderbar['command'] = (folderbox, 'yview') ! folderbox.bind('', open_folder, 1) ! folderbox.bind('<3>', folder_post) ! # Build left part: scan list ! left = Frame(top) ! left.pack({'expand': 1, 'fill': 'both', 'side': 'left'}) ! scanbar = Scrollbar(left, {'relief': 'sunken', 'bd': 2}) ! scanbar.pack({'fill': 'y', 'side': 'right'}) ! scanbox = Listbox(left, {'font': 'fixed'}) ! scanbox.pack({'expand': 1, 'fill': 'both', 'side': 'left'}) ! scanmenu = Menu(root) ! scanmenu.add('command', ! {'label': 'Open Message', ! 'command': open_message}) ! scanmenu.add('command', ! {'label': 'Remove Message', ! 'command': remove_message}) ! scanmenu.add('command', ! {'label': 'Refile Message', ! 'command': refile_message}) ! scanmenu.add('separator') ! scanmenu.add('command', ! {'label': 'Quit', ! 'command': 'exit'}) ! scanmenu.bind('', scan_unpost) ! scanbox['yscrollcommand'] = (scanbar, 'set') ! scanbar['command'] = (scanbox, 'yview') ! scanbox.bind('', open_message) ! scanbox.bind('<3>', scan_post) ! # Separator between middle and bottom part ! rule2 = Frame(root, {'bg': 'black'}) ! rule2.pack({'fill': 'x'}) ! # Build bottom part: current message ! bot = Frame(root) ! bot.pack({'expand': 1, 'fill': 'both'}) ! # ! viewer = None ! # Window manager commands ! root.minsize(800, 1) # Make window resizable ! # Fill folderbox with text ! setfolders() ! # Fill scanbox with text ! rescan() ! # Enter mainloop ! root.mainloop() def folder_post(e): ! x, y = e.x_root, e.y_root ! foldermenu.post(x - 10, y - 10) ! foldermenu.grab_set() def folder_unpost(e): ! tk.call('update', 'idletasks') ! foldermenu.grab_release() ! foldermenu.unpost() ! foldermenu.invoke('active') def scan_post(e): ! x, y = e.x_root, e.y_root ! scanmenu.post(x - 10, y - 10) ! scanmenu.grab_set() def scan_unpost(e): ! tk.call('update', 'idletasks') ! scanmenu.grab_release() ! scanmenu.unpost() ! scanmenu.invoke('active') scanparser = regex.compile('^ *\([0-9]+\)') def open_folder(e=None): ! global folder, mhf ! sel = folderbox.curselection() ! if len(sel) != 1: ! if len(sel) > 1: ! msg = "Please open one folder at a time" ! else: ! msg = "Please select a folder to open" ! dialog(root, "Can't Open Folder", msg, "", 0, "OK") ! return ! i = sel[0] ! folder = folderbox.get(i) ! mhf = mh.openfolder(folder) ! rescan() def open_message(e=None): ! global viewer ! sel = scanbox.curselection() ! if len(sel) != 1: ! if len(sel) > 1: ! msg = "Please open one message at a time" ! else: ! msg = "Please select a message to open" ! dialog(root, "Can't Open Message", msg, "", 0, "OK") ! return ! cursor = scanbox['cursor'] ! scanbox['cursor'] = 'watch' ! tk.call('update', 'idletasks') ! i = sel[0] ! line = scanbox.get(i) ! if scanparser.match(line) >= 0: ! num = string.atoi(scanparser.group(1)) ! m = mhf.openmessage(num) ! if viewer: viewer.destroy() ! from MimeViewer import MimeViewer ! viewer = MimeViewer(bot, '+%s/%d' % (folder, num), m) ! viewer.pack() ! viewer.show() ! scanbox['cursor'] = cursor def interestingheader(header): ! return header != 'received' def remove_message(e=None): ! itop = scanbox.nearest(0) ! sel = scanbox.curselection() ! if not sel: ! dialog(root, "No Message To Remove", ! "Please select a message to remove", "", 0, "OK") ! return ! todo = [] ! for i in sel: ! line = scanbox.get(i) ! if scanparser.match(line) >= 0: ! todo.append(string.atoi(scanparser.group(1))) ! mhf.removemessages(todo) ! rescan() ! fixfocus(min(todo), itop) lastrefile = '' tofolder = None def refile_message(e=None): ! global lastrefile, tofolder ! itop = scanbox.nearest(0) ! sel = scanbox.curselection() ! if not sel: ! dialog(root, "No Message To Refile", ! "Please select a message to refile", "", 0, "OK") ! return ! foldersel = folderbox.curselection() ! if len(foldersel) != 1: ! if not foldersel: ! msg = "Please select a folder to refile to" ! else: ! msg = "Please select exactly one folder to refile to" ! dialog(root, "No Folder To Refile", msg, "", 0, "OK") ! return ! refileto = folderbox.get(foldersel[0]) ! todo = [] ! for i in sel: ! line = scanbox.get(i) ! if scanparser.match(line) >= 0: ! todo.append(string.atoi(scanparser.group(1))) ! if lastrefile != refileto or not tofolder: ! lastrefile = refileto ! tofolder = None ! tofolder = mh.openfolder(lastrefile) ! mhf.refilemessages(todo, tofolder) ! rescan() ! fixfocus(min(todo), itop) def fixfocus(near, itop): ! n = scanbox.size() ! for i in range(n): ! line = scanbox.get(repr(i)) ! if scanparser.match(line) >= 0: ! num = string.atoi(scanparser.group(1)) ! if num >= near: ! break ! else: ! i = 'end' ! scanbox.select_from(i) ! scanbox.yview(itop) def setfolders(): ! folderbox.delete(0, 'end') ! for fn in mh.listallfolders(): ! folderbox.insert('end', fn) def rescan(): ! global viewer ! if viewer: ! viewer.destroy() ! viewer = None ! scanbox.delete(0, 'end') ! for line in scanfolder(folder, seq): ! scanbox.insert('end', line) def scanfolder(folder = 'inbox', sequence = 'all'): ! return map( ! lambda line: line[:-1], ! os.popen('scan +%s %s' % (folder, sequence), 'r').readlines()) main() Index: newmenubardemo.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/guido/newmenubardemo.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** newmenubardemo.py 6 Oct 1998 19:37:20 -0000 1.2 --- newmenubardemo.py 18 Jul 2004 06:09:09 -0000 1.3 *************** *** 8,28 **** def __init__(self, master): ! self.master = master ! self.menubar = Menu(self.master) ! self.filemenu = Menu(self.menubar) ! ! self.filemenu.add_command(label="New") ! self.filemenu.add_command(label="Open...") ! self.filemenu.add_command(label="Close") ! self.filemenu.add_separator() ! self.filemenu.add_command(label="Quit", command=self.master.quit) ! self.editmenu = Menu(self.menubar) ! self.editmenu.add_command(label="Cut") ! self.editmenu.add_command(label="Copy") ! self.editmenu.add_command(label="Paste") self.helpmenu = Menu(self.menubar, name='help') --- 8,28 ---- def __init__(self, master): ! self.master = master ! self.menubar = Menu(self.master) ! self.filemenu = Menu(self.menubar) ! self.filemenu.add_command(label="New") ! self.filemenu.add_command(label="Open...") ! self.filemenu.add_command(label="Close") ! self.filemenu.add_separator() ! self.filemenu.add_command(label="Quit", command=self.master.quit) ! self.editmenu = Menu(self.menubar) ! ! self.editmenu.add_command(label="Cut") ! self.editmenu.add_command(label="Copy") ! self.editmenu.add_command(label="Paste") self.helpmenu = Menu(self.menubar, name='help') *************** *** 30,40 **** self.helpmenu.add_command(label="About...") ! self.menubar.add_cascade(label="File", menu=self.filemenu) ! self.menubar.add_cascade(label="Edit", menu=self.editmenu) ! self.menubar.add_cascade(label="Help", menu=self.helpmenu) ! self.top = Toplevel(menu=self.menubar) ! # Rest of app goes here... def main(): --- 30,40 ---- self.helpmenu.add_command(label="About...") ! self.menubar.add_cascade(label="File", menu=self.filemenu) ! self.menubar.add_cascade(label="Edit", menu=self.editmenu) ! self.menubar.add_cascade(label="Help", menu=self.helpmenu) ! self.top = Toplevel(menu=self.menubar) ! # Rest of app goes here... def main(): Index: paint.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/guido/paint.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** paint.py 26 Jan 1998 16:47:30 -0000 1.1 --- paint.py 18 Jul 2004 06:09:09 -0000 1.2 *************** *** 13,22 **** All this does is put up a canvas and draw a smooth black line whenever you have the mouse button down, but hopefully it will ! be enough to start with.. It would be easy enough to add some options like other shapes or colors... ! yours, ! dave mitchell ! davem@magnet.com """ --- 13,22 ---- All this does is put up a canvas and draw a smooth black line whenever you have the mouse button down, but hopefully it will ! be enough to start with.. It would be easy enough to add some options like other shapes or colors... ! yours, ! dave mitchell ! davem@magnet.com """ *************** *** 29,60 **** def main(): ! root = Tk() ! drawing_area = Canvas(root) ! drawing_area.pack() ! drawing_area.bind("", motion) ! drawing_area.bind("", b1down) ! drawing_area.bind("", b1up) ! root.mainloop() def b1down(event): ! global b1 ! b1 = "down" # you only want to draw when the button is down ! # because "Motion" events happen -all the time- def b1up(event): ! global b1, xold, yold ! b1 = "up" ! xold = None # reset the line when you let go of the button ! yold = None def motion(event): ! if b1 == "down": ! global xold, yold ! if xold != None and yold != None: ! event.widget.create_line(xold,yold,event.x,event.y,smooth=TRUE) ! # here's where you draw it. smooth. neat. ! xold = event.x ! yold = event.y if __name__ == "__main__": ! main() --- 29,60 ---- def main(): ! root = Tk() ! drawing_area = Canvas(root) ! drawing_area.pack() ! drawing_area.bind("", motion) ! drawing_area.bind("", b1down) ! drawing_area.bind("", b1up) ! root.mainloop() def b1down(event): ! global b1 ! b1 = "down" # you only want to draw when the button is down ! # because "Motion" events happen -all the time- def b1up(event): ! global b1, xold, yold ! b1 = "up" ! xold = None # reset the line when you let go of the button ! yold = None def motion(event): ! if b1 == "down": ! global xold, yold ! if xold != None and yold != None: ! event.widget.create_line(xold,yold,event.x,event.y,smooth=TRUE) ! # here's where you draw it. smooth. neat. ! xold = event.x ! yold = event.y if __name__ == "__main__": ! main() Index: rmt.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/guido/rmt.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** rmt.py 27 Nov 1996 19:51:30 -0000 1.6 --- rmt.py 18 Jul 2004 06:09:09 -0000 1.7 *************** *** 29,33 **** t = Text(f, relief=RAISED, borderwidth=2, yscrollcommand=s.set, setgrid=1) t.pack(side=LEFT, fill=BOTH, expand=1) ! t.tag_config('bold', font='-Adobe-Courier-Bold-R-Normal-*-120-*') s['command'] = t.yview --- 29,33 ---- t = Text(f, relief=RAISED, borderwidth=2, yscrollcommand=s.set, setgrid=1) t.pack(side=LEFT, fill=BOTH, expand=1) ! t.tag_config('bold', font='-Adobe-Courier-Bold-R-Normal-*-120-*') s['command'] = t.yview *************** *** 43,47 **** file_m_apps = Menu(file_m, tearoff=0) file_m.add_cascade(label='Select Application', underline=0, ! menu=file_m_apps) file_m.add_command(label='Quit', underline=0, command=sys.exit) --- 43,47 ---- file_m_apps = Menu(file_m, tearoff=0) file_m.add_cascade(label='Select Application', underline=0, ! menu=file_m_apps) file_m.add_command(label='Quit', underline=0, command=sys.exit) *************** *** 52,86 **** def single1(e): ! x = e.x ! y = e.y ! t.setvar('tk_priv(selectMode)', 'char') ! t.mark_set('anchor', At(x, y)) ! # Should focus W t.bind('<1>', single1) def double1(e): ! x = e.x ! y = e.y ! t.setvar('tk_priv(selectMode)', 'word') ! t.tk_textSelectTo(At(x, y)) t.bind('', double1) def triple1(e): ! x = e.x ! y = e.y ! t.setvar('tk_priv(selectMode)', 'line') ! t.tk_textSelectTo(At(x, y)) t.bind('', triple1) def returnkey(e): ! t.insert(AtInsert(), '\n') ! invoke() t.bind('', returnkey) def controlv(e): ! t.insert(AtInsert(), t.selection_get()) ! t.yview_pickplace(AtInsert()) ! if t.index(AtInsert())[-2:] == '.0': ! invoke() t.bind('', controlv) --- 52,86 ---- def single1(e): ! x = e.x ! y = e.y ! t.setvar('tk_priv(selectMode)', 'char') ! t.mark_set('anchor', At(x, y)) ! # Should focus W t.bind('<1>', single1) def double1(e): ! x = e.x ! y = e.y ! t.setvar('tk_priv(selectMode)', 'word') ! t.tk_textSelectTo(At(x, y)) t.bind('', double1) def triple1(e): ! x = e.x ! y = e.y ! t.setvar('tk_priv(selectMode)', 'line') ! t.tk_textSelectTo(At(x, y)) t.bind('', triple1) def returnkey(e): ! t.insert(AtInsert(), '\n') ! invoke() t.bind('', returnkey) def controlv(e): ! t.insert(AtInsert(), t.selection_get()) ! t.yview_pickplace(AtInsert()) ! if t.index(AtInsert())[-2:] == '.0': ! invoke() t.bind('', controlv) *************** *** 89,95 **** def backspace(e): ! if t.index('promptEnd') != t.index('insert - 1 char'): ! t.delete('insert - 1 char', AtInsert()) ! t.yview_pickplace(AtInsert()) t.bind('', backspace) t.bind('', backspace) --- 89,95 ---- def backspace(e): ! if t.index('promptEnd') != t.index('insert - 1 char'): ! t.delete('insert - 1 char', AtInsert()) ! t.yview_pickplace(AtInsert()) t.bind('', backspace) t.bind('', backspace) *************** *** 104,122 **** def invoke(): ! cmd = t.get('promptEnd + 1 char', AtInsert()) ! if t.getboolean(tk.call('info', 'complete', cmd)): # XXX ! if app == root.winfo_name(): ! msg = tk.call('eval', cmd) # XXX ! else: ! msg = t.send(app, cmd) ! if msg: ! t.insert(AtInsert(), msg + '\n') ! prompt() ! t.yview_pickplace(AtInsert()) def prompt(): ! t.insert(AtInsert(), app + ': ') ! t.mark_set('promptEnd', 'insert - 1 char') ! t.tag_add('bold', 'insert linestart', 'promptEnd') # 6. Procedure to select a new application. Also changes --- 104,122 ---- def invoke(): ! cmd = t.get('promptEnd + 1 char', AtInsert()) ! if t.getboolean(tk.call('info', 'complete', cmd)): # XXX ! if app == root.winfo_name(): ! msg = tk.call('eval', cmd) # XXX ! else: ! msg = t.send(app, cmd) ! if msg: ! t.insert(AtInsert(), msg + '\n') ! prompt() ! t.yview_pickplace(AtInsert()) def prompt(): ! t.insert(AtInsert(), app + ': ') ! t.mark_set('promptEnd', 'insert - 1 char') ! t.tag_add('bold', 'insert linestart', 'promptEnd') # 6. Procedure to select a new application. Also changes *************** *** 125,150 **** def newApp(appName): ! global app ! app = appName ! t.delete('promptEnd linestart', 'promptEnd') ! t.insert('promptEnd', appName + ':') ! t.tag_add('bold', 'promptEnd linestart', 'promptEnd') def fillAppsMenu(): ! file_m_apps.add('command') ! file_m_apps.delete(0, 'last') ! names = root.winfo_interps() ! names = map(None, names) # convert tuple to list ! names.sort() ! for name in names: ! try: ! root.send(name, 'winfo name .') ! except TclError: ! # Inoperative window -- ignore it ! pass ! else: ! file_m_apps.add_command( ! label=name, ! command=lambda name=name: newApp(name)) file_m_apps['postcommand'] = fillAppsMenu --- 125,150 ---- def newApp(appName): ! global app ! app = appName ! t.delete('promptEnd linestart', 'promptEnd') ! t.insert('promptEnd', appName + ':') ! t.tag_add('bold', 'promptEnd linestart', 'promptEnd') def fillAppsMenu(): ! file_m_apps.add('command') ! file_m_apps.delete(0, 'last') ! names = root.winfo_interps() ! names = map(None, names) # convert tuple to list ! names.sort() ! for name in names: ! try: ! root.send(name, 'winfo name .') ! except TclError: ! # Inoperative window -- ignore it ! pass ! else: ! file_m_apps.add_command( ! label=name, ! command=lambda name=name: newApp(name)) file_m_apps['postcommand'] = fillAppsMenu Index: solitaire.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/guido/solitaire.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** solitaire.py 12 Feb 2004 17:35:04 -0000 1.5 --- solitaire.py 18 Jul 2004 06:09:09 -0000 1.6 *************** *** 12,16 **** - Less fancy animation when you win. - The determination of which stack you drag to is more relaxed. ! Apology: --- 12,16 ---- - Less fancy animation when you win. - The determination of which stack you drag to is more relaxed. ! Apology: *************** *** 36,40 **** class Group(Group): def bind(self, sequence=None, command=None): ! return self.canvas.tag_bind(self.id, sequence, command) --- 36,40 ---- class Group(Group): def bind(self, sequence=None, command=None): ! return self.canvas.tag_bind(self.id, sequence, command) *************** *** 136,140 **** Semi-public read-only instance variables (XXX should be made private): ! group -- the Canvas.Group representing the card x, y -- the position of the card's top left corner --- 136,140 ---- Semi-public read-only instance variables (XXX should be made private): ! group -- the Canvas.Group representing the card x, y -- the position of the card's top left corner *************** *** 151,216 **** def __init__(self, suit, value, canvas): ! """Card constructor. ! Arguments are the card's suit and value, and the canvas widget. ! The card is created at position (0, 0), with its face down ! (adding it to a stack will position it according to that ! stack's rules). ! """ ! self.suit = suit ! self.value = value ! self.color = COLOR[suit] ! self.face_shown = 0 ! self.x = self.y = 0 ! self.group = Group(canvas) ! text = "%s %s" % (VALNAMES[value], suit) ! self.__text = CanvasText(canvas, CARDWIDTH/2, 0, ! anchor=N, fill=self.color, text=text) ! self.group.addtag_withtag(self.__text) ! self.__rect = Rectangle(canvas, 0, 0, CARDWIDTH, CARDHEIGHT, ! outline='black', fill='white') ! self.group.addtag_withtag(self.__rect) ! self.__back = Rectangle(canvas, MARGIN, MARGIN, ! CARDWIDTH-MARGIN, CARDHEIGHT-MARGIN, ! outline='black', fill='blue') ! self.group.addtag_withtag(self.__back) def __repr__(self): ! """Return a string for debug print statements.""" ! return "Card(%r, %r)" % (self.suit, self.value) def moveto(self, x, y): ! """Move the card to absolute position (x, y).""" ! self.moveby(x - self.x, y - self.y) def moveby(self, dx, dy): ! """Move the card by (dx, dy).""" ! self.x = self.x + dx ! self.y = self.y + dy ! self.group.move(dx, dy) def tkraise(self): ! """Raise the card above all other objects in its canvas.""" ! self.group.tkraise() def showface(self): ! """Turn the card's face up.""" ! self.tkraise() ! self.__rect.tkraise() ! self.__text.tkraise() ! self.face_shown = 1 def showback(self): ! """Turn the card's face down.""" ! self.tkraise() ! self.__rect.tkraise() ! self.__back.tkraise() ! self.face_shown = 0 --- 151,216 ---- def __init__(self, suit, value, canvas): ! """Card constructor. ! Arguments are the card's suit and value, and the canvas widget. ! The card is created at position (0, 0), with its face down ! (adding it to a stack will position it according to that ! stack's rules). ! """ ! self.suit = suit ! self.value = value ! self.color = COLOR[suit] ! self.face_shown = 0 ! self.x = self.y = 0 ! self.group = Group(canvas) ! text = "%s %s" % (VALNAMES[value], suit) ! self.__text = CanvasText(canvas, CARDWIDTH/2, 0, ! anchor=N, fill=self.color, text=text) ! self.group.addtag_withtag(self.__text) ! self.__rect = Rectangle(canvas, 0, 0, CARDWIDTH, CARDHEIGHT, ! outline='black', fill='white') ! self.group.addtag_withtag(self.__rect) ! self.__back = Rectangle(canvas, MARGIN, MARGIN, ! CARDWIDTH-MARGIN, CARDHEIGHT-MARGIN, ! outline='black', fill='blue') ! self.group.addtag_withtag(self.__back) def __repr__(self): ! """Return a string for debug print statements.""" ! return "Card(%r, %r)" % (self.suit, self.value) def moveto(self, x, y): ! """Move the card to absolute position (x, y).""" ! self.moveby(x - self.x, y - self.y) def moveby(self, dx, dy): ! """Move the card by (dx, dy).""" ! self.x = self.x + dx ! self.y = self.y + dy ! self.group.move(dx, dy) def tkraise(self): ! """Raise the card above all other objects in its canvas.""" ! self.group.tkraise() def showface(self): ! """Turn the card's face up.""" ! self.tkraise() ! self.__rect.tkraise() ! self.__text.tkraise() ! self.face_shown = 1 def showback(self): ! """Turn the card's face down.""" ! self.tkraise() ! self.__rect.tkraise() ! self.__back.tkraise() ! self.face_shown = 0 *************** *** 241,245 **** The default user (single) click handler shows the top card face up. The default user double click handler calls the user ! single click handler. usermovehandler(cards) -- called to complete a subpile move --- 241,245 ---- The default user (single) click handler shows the top card face up. The default user double click handler calls the user ! single click handler. usermovehandler(cards) -- called to complete a subpile move *************** *** 256,260 **** its face up on a (single or double) click, and also support moving a subpile around. ! startmoving(event) -- begin a move operation finishmoving() -- finish a move operation --- 256,260 ---- its face up on a (single or double) click, and also support moving a subpile around. ! startmoving(event) -- begin a move operation finishmoving() -- finish a move operation *************** *** 263,348 **** def __init__(self, x, y, game=None): ! """Stack constructor. ! Arguments are the stack's nominal x and y position (the top ! left corner of the first card placed in the stack), and the ! game object (which is used to get the canvas; subclasses use ! the game object to find other stacks). ! """ ! self.x = x ! self.y = y ! self.game = game ! self.cards = [] ! self.group = Group(self.game.canvas) ! self.group.bind('<1>', self.clickhandler) ! self.group.bind('', self.doubleclickhandler) ! self.group.bind('', self.motionhandler) ! self.group.bind('', self.releasehandler) ! self.makebottom() def makebottom(self): ! pass def __repr__(self): ! """Return a string for debug print statements.""" ! return "%s(%d, %d)" % (self.__class__.__name__, self.x, self.y) # Public methods def add(self, card): ! self.cards.append(card) ! card.tkraise() ! self.position(card) ! self.group.addtag_withtag(card.group) def delete(self, card): ! self.cards.remove(card) ! card.group.dtag(self.group) def showtop(self): ! if self.cards: ! self.cards[-1].showface() def deal(self): ! if not self.cards: ! return None ! card = self.cards[-1] ! self.delete(card) ! return card # Subclass overridable methods def position(self, card): ! card.moveto(self.x, self.y) def userclickhandler(self): ! self.showtop() def userdoubleclickhandler(self): ! self.userclickhandler() def usermovehandler(self, cards): ! for card in cards: ! self.position(card) # Event handlers def clickhandler(self, event): ! self.finishmoving() # In case we lost an event ! self.userclickhandler() ! self.startmoving(event) def motionhandler(self, event): ! self.keepmoving(event) def releasehandler(self, event): ! self.keepmoving(event) ! self.finishmoving() def doubleclickhandler(self, event): ! self.finishmoving() # In case we lost an event ! self.userdoubleclickhandler() ! self.startmoving(event) # Move internals --- 263,348 ---- def __init__(self, x, y, game=None): ! """Stack constructor. ! Arguments are the stack's nominal x and y position (the top ! left corner of the first card placed in the stack), and the ! game object (which is used to get the canvas; subclasses use ! the game object to find other stacks). ! """ ! self.x = x ! self.y = y ! self.game = game ! self.cards = [] ! self.group = Group(self.game.canvas) ! self.group.bind('<1>', self.clickhandler) ! self.group.bind('', self.doubleclickhandler) ! self.group.bind('', self.motionhandler) ! self.group.bind('', self.releasehandler) ! self.makebottom() def makebottom(self): ! pass def __repr__(self): ! """Return a string for debug print statements.""" ! return "%s(%d, %d)" % (self.__class__.__name__, self.x, self.y) # Public methods def add(self, card): ! self.cards.append(card) ! card.tkraise() ! self.position(card) ! self.group.addtag_withtag(card.group) def delete(self, card): ! self.cards.remove(card) ! card.group.dtag(self.group) def showtop(self): ! if self.cards: ! self.cards[-1].showface() def deal(self): ! if not self.cards: ! return None ! card = self.cards[-1] ! self.delete(card) ! return card # Subclass overridable methods def position(self, card): ! card.moveto(self.x, self.y) def userclickhandler(self): ! self.showtop() def userdoubleclickhandler(self): ! self.userclickhandler() def usermovehandler(self, cards): ! for card in cards: ! self.position(card) # Event handlers def clickhandler(self, event): ! self.finishmoving() # In case we lost an event ! self.userclickhandler() ! self.startmoving(event) def motionhandler(self, event): ! self.keepmoving(event) def releasehandler(self, event): ! self.keepmoving(event) ! self.finishmoving() def doubleclickhandler(self, event): ! self.finishmoving() # In case we lost an event ! self.userdoubleclickhandler() ! self.startmoving(event) # Move internals *************** *** 351,386 **** def startmoving(self, event): ! self.moving = None ! tags = self.game.canvas.gettags('current') ! for i in range(len(self.cards)): ! card = self.cards[i] ! if card.group.tag in tags: ! break ! else: ! return ! if not card.face_shown: ! return ! self.moving = self.cards[i:] ! self.lastx = event.x ! self.lasty = event.y ! for card in self.moving: ! card.tkraise() def keepmoving(self, event): ! if not self.moving: ! return ! dx = event.x - self.lastx ! dy = event.y - self.lasty ! self.lastx = event.x ! self.lasty = event.y ! if dx or dy: ! for card in self.moving: ! card.moveby(dx, dy) def finishmoving(self): ! cards = self.moving ! self.moving = None ! if cards: ! self.usermovehandler(cards) --- 351,386 ---- def startmoving(self, event): ! self.moving = None ! tags = self.game.canvas.gettags('current') ! for i in range(len(self.cards)): ! card = self.cards[i] ! if card.group.tag in tags: ! break ! else: ! return ! if not card.face_shown: ! return ! self.moving = self.cards[i:] ! self.lastx = event.x ! self.lasty = event.y ! for card in self.moving: ! card.tkraise() def keepmoving(self, event): ! if not self.moving: ! return ! dx = event.x - self.lastx ! dy = event.y - self.lasty ! self.lastx = event.x ! self.lasty = event.y ! if dx or dy: ! for card in self.moving: ! card.moveby(dx, dy) def finishmoving(self): ! cards = self.moving ! self.moving = None ! if cards: ! self.usermovehandler(cards) *************** *** 401,435 **** def makebottom(self): ! bottom = Rectangle(self.game.canvas, ! self.x, self.y, ! self.x+CARDWIDTH, self.y+CARDHEIGHT, ! outline='black', fill=BACKGROUND) ! self.group.addtag_withtag(bottom) def fill(self): ! for suit in ALLSUITS: ! for value in ALLVALUES: ! self.add(Card(suit, value, self.game.canvas)) def shuffle(self): ! n = len(self.cards) ! newcards = [] ! for i in randperm(n): ! newcards.append(self.cards[i]) ! self.cards = newcards def userclickhandler(self): ! opendeck = self.game.opendeck ! card = self.deal() ! if not card: ! while 1: ! card = opendeck.deal() ! if not card: ! break ! self.add(card) ! card.showback() ! else: ! self.game.opendeck.add(card) ! card.showface() --- 401,435 ---- def makebottom(self): ! bottom = Rectangle(self.game.canvas, ! self.x, self.y, ! self.x+CARDWIDTH, self.y+CARDHEIGHT, ! outline='black', fill=BACKGROUND) ! self.group.addtag_withtag(bottom) def fill(self): ! for suit in ALLSUITS: ! for value in ALLVALUES: ! self.add(Card(suit, value, self.game.canvas)) def shuffle(self): ! n = len(self.cards) ! newcards = [] ! for i in randperm(n): ! newcards.append(self.cards[i]) ! self.cards = newcards def userclickhandler(self): ! opendeck = self.game.opendeck ! card = self.deal() ! if not card: ! while 1: ! card = opendeck.deal() ! if not card: ! break ! self.add(card) ! card.showback() ! else: ! self.game.opendeck.add(card) ! card.showface() *************** *** 439,445 **** x = [] while r: ! i = random.choice(r) ! x.append(i) ! r.remove(i) return x --- 439,445 ---- x = [] while r: ! i = random.choice(r) ! x.append(i) ! r.remove(i) return x *************** *** 448,477 **** def acceptable(self, cards): ! return 0 def usermovehandler(self, cards): ! card = cards[0] ! stack = self.game.closeststack(card) ! if not stack or stack is self or not stack.acceptable(cards): ! Stack.usermovehandler(self, cards) ! else: ! for card in cards: ! self.delete(card) ! stack.add(card) ! self.game.wincheck() def userdoubleclickhandler(self): ! if not self.cards: ! return ! card = self.cards[-1] ! if not card.face_shown: ! self.userclickhandler() ! return ! for s in self.game.suits: ! if s.acceptable([card]): ! self.delete(card) ! s.add(card) ! self.game.wincheck() ! break --- 448,477 ---- def acceptable(self, cards): ! return 0 def usermovehandler(self, cards): ! card = cards[0] ! stack = self.game.closeststack(card) ! if not stack or stack is self or not stack.acceptable(cards): ! Stack.usermovehandler(self, cards) ! else: ! for card in cards: ! self.delete(card) ! stack.add(card) ! self.game.wincheck() def userdoubleclickhandler(self): ! if not self.cards: ! return ! card = self.cards[-1] ! if not card.face_shown: ! self.userclickhandler() ! return ! for s in self.game.suits: ! if s.acceptable([card]): ! self.delete(card) ! s.add(card) ! self.game.wincheck() ! break *************** *** 479,501 **** def makebottom(self): ! bottom = Rectangle(self.game.canvas, ! self.x, self.y, ! self.x+CARDWIDTH, self.y+CARDHEIGHT, ! outline='black', fill='') def userclickhandler(self): ! pass def userdoubleclickhandler(self): ! pass def acceptable(self, cards): ! if len(cards) != 1: ! return 0 ! card = cards[0] ! if not self.cards: ! return card.value == ACE ! topcard = self.cards[-1] ! return card.suit == topcard.suit and card.value == topcard.value + 1 --- 479,501 ---- def makebottom(self): ! bottom = Rectangle(self.game.canvas, ! self.x, self.y, ! self.x+CARDWIDTH, self.y+CARDHEIGHT, ! outline='black', fill='') def userclickhandler(self): ! pass def userdoubleclickhandler(self): ! pass def acceptable(self, cards): ! if len(cards) != 1: ! return 0 ! card = cards[0] ! if not self.cards: ! return card.value == ACE ! topcard = self.cards[-1] ! return card.suit == topcard.suit and card.value == topcard.value + 1 *************** *** 503,524 **** def acceptable(self, cards): ! card = cards[0] ! if not self.cards: ! return card.value == KING ! topcard = self.cards[-1] ! if not topcard.face_shown: ! return 0 ! return card.color != topcard.color and card.value == topcard.value - 1 def position(self, card): ! y = self.y ! for c in self.cards: ! if c == card: ! break ! if c.face_shown: ! y = y + 2*MARGIN ! else: ! y = y + OFFSET ! card.moveto(self.x, y) --- 503,524 ---- def acceptable(self, cards): ! card = cards[0] ! if not self.cards: ! return card.value == KING ! topcard = self.cards[-1] ! if not topcard.face_shown: ! return 0 ! return card.color != topcard.color and card.value == topcard.value - 1 def position(self, card): ! y = self.y ! for c in self.cards: ! if c == card: ! break ! if c.face_shown: ! y = y + 2*MARGIN ! else: ! y = y + OFFSET ! card.moveto(self.x, y) *************** *** 526,627 **** def __init__(self, master): ! self.master = master ! self.canvas = Canvas(self.master, ! background=BACKGROUND, ! highlightthickness=0, ! width=NROWS*XSPACING, ! height=3*YSPACING + 20 + MARGIN) ! self.canvas.pack(fill=BOTH, expand=TRUE) ! self.dealbutton = Button(self.canvas, ! text="Deal", ! highlightthickness=0, ! background=BACKGROUND, ! activebackground="green", ! command=self.deal) ! Window(self.canvas, MARGIN, 3*YSPACING + 20, ! window=self.dealbutton, anchor=SW) ! x = MARGIN ! y = MARGIN ! self.deck = Deck(x, y, self) ! x = x + XSPACING ! self.opendeck = OpenStack(x, y, self) ! ! x = x + XSPACING ! self.suits = [] ! for i in range(NSUITS): ! x = x + XSPACING ! self.suits.append(SuitStack(x, y, self)) ! x = MARGIN ! y = y + YSPACING ! self.rows = [] ! for i in range(NROWS): ! self.rows.append(RowStack(x, y, self)) ! x = x + XSPACING ! self.openstacks = [self.opendeck] + self.suits + self.rows ! ! self.deck.fill() ! self.deal() def wincheck(self): ! for s in self.suits: ! if len(s.cards) != NVALUES: ! return ! self.win() ! self.deal() def win(self): ! """Stupid animation when you win.""" ! cards = [] ! for s in self.openstacks: ! cards = cards + s.cards ! while cards: ! card = random.choice(cards) ! cards.remove(card) ! self.animatedmoveto(card, self.deck) def animatedmoveto(self, card, dest): ! for i in range(10, 0, -1): ! dx, dy = (dest.x-card.x)/i, (dest.y-card.y)/i ! card.moveby(dx, dy) ! self.master.update_idletasks() def closeststack(self, card): ! closest = None ! cdist = 999999999 ! # Since we only compare distances, ! # we don't bother to take the square root. ! for stack in self.openstacks: ! dist = (stack.x - card.x)**2 + (stack.y - card.y)**2 ! if dist < cdist: ! closest = stack ! cdist = dist ! return closest def deal(self): ! self.reset() ! self.deck.shuffle() ! for i in range(NROWS): ! for r in self.rows[i:]: ! card = self.deck.deal() ! r.add(card) ! for r in self.rows: ! r.showtop() def reset(self): ! for stack in self.openstacks: ! while 1: ! card = stack.deal() ! if not card: ! break ! self.deck.add(card) ! card.showback() --- 526,627 ---- def __init__(self, master): ! self.master = master ! self.canvas = Canvas(self.master, ! background=BACKGROUND, ! highlightthickness=0, ! width=NROWS*XSPACING, ! height=3*YSPACING + 20 + MARGIN) ! self.canvas.pack(fill=BOTH, expand=TRUE) ! self.dealbutton = Button(self.canvas, ! text="Deal", ! highlightthickness=0, ! background=BACKGROUND, ! activebackground="green", ! command=self.deal) ! Window(self.canvas, MARGIN, 3*YSPACING + 20, ! window=self.dealbutton, anchor=SW) ! x = MARGIN ! y = MARGIN ! self.deck = Deck(x, y, self) ! x = x + XSPACING ! self.opendeck = OpenStack(x, y, self) ! x = x + XSPACING ! self.suits = [] ! for i in range(NSUITS): ! x = x + XSPACING ! self.suits.append(SuitStack(x, y, self)) ! x = MARGIN ! y = y + YSPACING ! self.rows = [] ! for i in range(NROWS): ! self.rows.append(RowStack(x, y, self)) ! x = x + XSPACING ! ! self.openstacks = [self.opendeck] + self.suits + self.rows ! ! self.deck.fill() ! self.deal() def wincheck(self): ! for s in self.suits: ! if len(s.cards) != NVALUES: ! return ! self.win() ! self.deal() def win(self): ! """Stupid animation when you win.""" ! cards = [] ! for s in self.openstacks: ! cards = cards + s.cards ! while cards: ! card = random.choice(cards) ! cards.remove(card) ! self.animatedmoveto(card, self.deck) def animatedmoveto(self, card, dest): ! for i in range(10, 0, -1): ! dx, dy = (dest.x-card.x)/i, (dest.y-card.y)/i ! card.moveby(dx, dy) ! self.master.update_idletasks() def closeststack(self, card): ! closest = None ! cdist = 999999999 ! # Since we only compare distances, ! # we don't bother to take the square root. ! for stack in self.openstacks: ! dist = (stack.x - card.x)**2 + (stack.y - card.y)**2 ! if dist < cdist: ! closest = stack ! cdist = dist ! return closest def deal(self): ! self.reset() ! self.deck.shuffle() ! for i in range(NROWS): ! for r in self.rows[i:]: ! card = self.deck.deal() ! r.add(card) ! for r in self.rows: ! r.showtop() def reset(self): ! for stack in self.openstacks: ! while 1: ! card = stack.deal() ! if not card: ! break ! self.deck.add(card) ! card.showback() Index: sortvisu.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/guido/sortvisu.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** sortvisu.py 3 Apr 1997 00:04:51 -0000 1.1 --- sortvisu.py 18 Jul 2004 06:09:09 -0000 1.2 *************** *** 33,73 **** def __init__(self, master, data=None): ! self.master = master ! self.frame = Frame(self.master) ! self.frame.pack(fill=X) ! self.label = Label(self.frame) ! self.label.pack() ! self.canvas = Canvas(self.frame) ! self.canvas.pack() ! self.report = Label(self.frame) [...1120 lines suppressed...] def c_cancel(self): ! if not self.busy: ! self.master.bell() ! return ! self.array.cancel() def c_step(self): ! if not self.busy: ! self.master.bell() ! return ! self.v_speed.set("single-step") ! self.array.setspeed("single-step") ! self.array.step() def c_quit(self): ! if self.busy: ! self.array.cancel() ! self.master.after_idle(self.master.quit) Index: ss1.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/guido/ss1.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ss1.py 2 Nov 2002 22:18:46 -0000 1.4 --- ss1.py 18 Jul 2004 06:09:09 -0000 1.5 *************** *** 316,320 **** Subclasses may but needn't provide the following APIs: ! cell.reset() -- prepare for recalculation cell.recalc(rexec) -> value -- recalculate formula --- 316,320 ---- Subclasses may but needn't provide the following APIs: ! cell.reset() -- prepare for recalculation cell.recalc(rexec) -> value -- recalculate formula Index: svkill.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/guido/svkill.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** svkill.py 27 Nov 1996 19:51:32 -0000 1.6 --- svkill.py 18 Jul 2004 06:09:09 -0000 1.7 *************** *** 6,10 **** if TkVersion < 4.0: ! raise ImportError, "This version of svkill requires Tk 4.0 or later" from string import splitfields --- 6,10 ---- if TkVersion < 4.0: ! raise ImportError, "This version of svkill requires Tk 4.0 or later" from string import splitfields *************** *** 16,128 **** class BarButton(Menubutton): ! def __init__(self, master=None, **cnf): ! apply(Menubutton.__init__, (self, master), cnf) ! self.pack(side=LEFT) ! self.menu = Menu(self, name='menu') ! self['menu'] = self.menu class Kill(Frame): ! # List of (name, option, pid_column) ! view_list = [ ! ('Default', ''), ! ('Every (-e)', '-e'), ! ('Non process group leaders (-d)', '-d'), ! ('Non leaders with tty (-a)', '-a'), ! ('For this user (-u %s)' % user, '-u %s' % user), ! ] ! format_list = [ ! ('Default', '', 0), ! ('Long (-l)', '-l', 3), ! ('Full (-f)', '-f', 1), ! ('Full Long (-f -l)', '-l -f', 3), ! ('Session and group ID (-j)', '-j', 0), ! ('Scheduler properties (-c)', '-c', 0), ! ] ! def kill(self, selected): ! c = self.format_list[self.format.get()][2] ! pid = split(selected)[c] ! os.system('kill -9 ' + pid) ! self.do_update() ! def do_update(self): ! format = self.format_list[self.format.get()][1] ! view = self.view_list[self.view.get()][1] ! s = commands.getoutput('ps %s %s' % (view, format)) ! list = splitfields(s, '\n') ! self.header.set(list[0] + ' ') ! del list[0] ! self.frame.list.delete(0, AtEnd()) ! for line in list: ! self.frame.list.insert(0, line) ! def do_motion(self, e): ! e.widget.select_clear('0', 'end') ! e.widget.select_set(e.widget.nearest(e.y)) ! def do_leave(self, e): ! e.widget.select_clear('0', 'end') ! def do_1(self, e): ! self.kill(e.widget.get(e.widget.nearest(e.y))) ! def __init__(self, master=None, **cnf): ! apply(Frame.__init__, (self, master), cnf) ! self.pack(expand=1, fill=BOTH) ! self.bar = Frame(self, name='bar', relief=RAISED, ! borderwidth=2) ! self.bar.pack(fill=X) ! self.bar.file = BarButton(self.bar, text='File') ! self.bar.file.menu.add_command( ! label='Quit', command=self.quit) ! self.bar.view = BarButton(self.bar, text='View') ! self.bar.format = BarButton(self.bar, text='Format') ! self.view = IntVar(self) ! self.view.set(0) ! self.format = IntVar(self) ! self.format.set(0) ! for num in range(len(self.view_list)): ! label, option = self.view_list[num] ! self.bar.view.menu.add_radiobutton( ! label=label, ! command=self.do_update, ! variable=self.view, ! value=num) ! for num in range(len(self.format_list)): ! label, option, col = self.format_list[num] ! self.bar.format.menu.add_radiobutton( ! label=label, ! command=self.do_update, ! variable=self.format, ! value=num) ! self.bar.tk_menuBar(self.bar.file, ! self.bar.view, ! self.bar.format) ! self.frame = Frame(self, relief=RAISED, borderwidth=2) ! self.frame.pack(expand=1, fill=BOTH) ! self.header = StringVar(self) ! self.frame.label = Label( ! self.frame, relief=FLAT, anchor=NW, borderwidth=0, ! font='*-Courier-Bold-R-Normal-*-120-*', ! textvariable=self.header) ! self.frame.label.pack(fill=Y, anchor=W) ! self.frame.vscroll = Scrollbar(self.frame, orient=VERTICAL) ! self.frame.list = Listbox( ! self.frame, ! relief=SUNKEN, ! font='*-Courier-Medium-R-Normal-*-120-*', ! width=40, height=10, ! selectbackground='#eed5b7', ! selectborderwidth=0, ! selectmode=BROWSE, ! yscroll=self.frame.vscroll.set) ! self.frame.vscroll['command'] = self.frame.list.yview ! self.frame.vscroll.pack(side=RIGHT, fill=Y) ! self.frame.list.pack(expand=1, fill=BOTH) ! self.update = Button(self, text='Update', ! command=self.do_update) ! self.update.pack(fill=X) ! self.frame.list.bind('', self.do_motion) ! self.frame.list.bind('', self.do_leave) ! self.frame.list.bind('<1>', self.do_1) ! self.do_update() if __name__ == '__main__': ! kill = Kill(None, borderwidth=5) ! kill.winfo_toplevel().title('Tkinter Process Killer (SYSV)') ! kill.winfo_toplevel().minsize(1, 1) ! kill.mainloop() --- 16,128 ---- class BarButton(Menubutton): ! def __init__(self, master=None, **cnf): ! apply(Menubutton.__init__, (self, master), cnf) ! self.pack(side=LEFT) ! self.menu = Menu(self, name='menu') ! self['menu'] = self.menu class Kill(Frame): ! # List of (name, option, pid_column) ! view_list = [ ! ('Default', ''), ! ('Every (-e)', '-e'), ! ('Non process group leaders (-d)', '-d'), ! ('Non leaders with tty (-a)', '-a'), ! ('For this user (-u %s)' % user, '-u %s' % user), ! ] ! format_list = [ ! ('Default', '', 0), ! ('Long (-l)', '-l', 3), ! ('Full (-f)', '-f', 1), ! ('Full Long (-f -l)', '-l -f', 3), ! ('Session and group ID (-j)', '-j', 0), ! ('Scheduler properties (-c)', '-c', 0), ! ] ! def kill(self, selected): ! c = self.format_list[self.format.get()][2] ! pid = split(selected)[c] ! os.system('kill -9 ' + pid) ! self.do_update() ! def do_update(self): ! format = self.format_list[self.format.get()][1] ! view = self.view_list[self.view.get()][1] ! s = commands.getoutput('ps %s %s' % (view, format)) ! list = splitfields(s, '\n') ! self.header.set(list[0] + ' ') ! del list[0] ! self.frame.list.delete(0, AtEnd()) ! for line in list: ! self.frame.list.insert(0, line) ! def do_motion(self, e): ! e.widget.select_clear('0', 'end') ! e.widget.select_set(e.widget.nearest(e.y)) ! def do_leave(self, e): ! e.widget.select_clear('0', 'end') ! def do_1(self, e): ! self.kill(e.widget.get(e.widget.nearest(e.y))) ! def __init__(self, master=None, **cnf): ! apply(Frame.__init__, (self, master), cnf) ! self.pack(expand=1, fill=BOTH) ! self.bar = Frame(self, name='bar', relief=RAISED, ! borderwidth=2) ! self.bar.pack(fill=X) ! self.bar.file = BarButton(self.bar, text='File') ! self.bar.file.menu.add_command( ! label='Quit', command=self.quit) ! self.bar.view = BarButton(self.bar, text='View') ! self.bar.format = BarButton(self.bar, text='Format') ! self.view = IntVar(self) ! self.view.set(0) ! self.format = IntVar(self) ! self.format.set(0) ! for num in range(len(self.view_list)): ! label, option = self.view_list[num] ! self.bar.view.menu.add_radiobutton( ! label=label, ! command=self.do_update, ! variable=self.view, ! value=num) ! for num in range(len(self.format_list)): ! label, option, col = self.format_list[num] ! self.bar.format.menu.add_radiobutton( ! label=label, ! command=self.do_update, ! variable=self.format, ! value=num) ! self.bar.tk_menuBar(self.bar.file, ! self.bar.view, ! self.bar.format) ! self.frame = Frame(self, relief=RAISED, borderwidth=2) ! self.frame.pack(expand=1, fill=BOTH) ! self.header = StringVar(self) ! self.frame.label = Label( ! self.frame, relief=FLAT, anchor=NW, borderwidth=0, ! font='*-Courier-Bold-R-Normal-*-120-*', ! textvariable=self.header) ! self.frame.label.pack(fill=Y, anchor=W) ! self.frame.vscroll = Scrollbar(self.frame, orient=VERTICAL) ! self.frame.list = Listbox( ! self.frame, ! relief=SUNKEN, ! font='*-Courier-Medium-R-Normal-*-120-*', ! width=40, height=10, ! selectbackground='#eed5b7', ! selectborderwidth=0, ! selectmode=BROWSE, ! yscroll=self.frame.vscroll.set) ! self.frame.vscroll['command'] = self.frame.list.yview ! self.frame.vscroll.pack(side=RIGHT, fill=Y) ! self.frame.list.pack(expand=1, fill=BOTH) ! self.update = Button(self, text='Update', ! command=self.do_update) ! self.update.pack(fill=X) ! self.frame.list.bind('', self.do_motion) ! self.frame.list.bind('', self.do_leave) ! self.frame.list.bind('<1>', self.do_1) ! self.do_update() if __name__ == '__main__': ! kill = Kill(None, borderwidth=5) ! kill.winfo_toplevel().title('Tkinter Process Killer (SYSV)') ! kill.winfo_toplevel().minsize(1, 1) ! kill.mainloop() Index: tkman.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/guido/tkman.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** tkman.py 15 Sep 1997 15:39:11 -0000 1.10 --- tkman.py 18 Jul 2004 06:09:09 -0000 1.11 *************** *** 16,44 **** for dir in MANNDIRLIST: if os.path.exists(dir): ! MANNDIR = dir ! foundmanndir = 1 foundman3dir = 0 for dir in MAN3DIRLIST: if os.path.exists(dir): ! MAN3DIR = dir ! foundman3dir = 1 if not foundmanndir or not foundman3dir: sys.stderr.write('\n') if not foundmanndir: ! msg = """\ Failed to find mann directory. ! Please add the correct entry to the MANNDIRLIST at the top of %s script.""" % \ sys.argv[0] ! sys.stderr.write("%s\n\n" % msg) if not foundman3dir: ! msg = """\ Failed to find man3 directory. ! Please add the correct entry to the MAN3DIRLIST at the top of %s script.""" % \ sys.argv[0] ! sys.stderr.write("%s\n\n" % msg) sys.exit(1) --- 16,44 ---- for dir in MANNDIRLIST: if os.path.exists(dir): ! MANNDIR = dir ! foundmanndir = 1 foundman3dir = 0 for dir in MAN3DIRLIST: if os.path.exists(dir): ! MAN3DIR = dir ! foundman3dir = 1 if not foundmanndir or not foundman3dir: sys.stderr.write('\n') if not foundmanndir: ! msg = """\ Failed to find mann directory. ! Please add the correct entry to the MANNDIRLIST at the top of %s script.""" % \ sys.argv[0] ! sys.stderr.write("%s\n\n" % msg) if not foundman3dir: ! msg = """\ Failed to find man3 directory. ! Please add the correct entry to the MAN3DIRLIST at the top of %s script.""" % \ sys.argv[0] ! sys.stderr.write("%s\n\n" % msg) sys.exit(1) *************** *** 47,267 **** def listmanpages(mandir): ! files = os.listdir(mandir) ! names = [] ! for file in files: ! if file[-2:-1] == '.' and (file[-1] in 'ln123456789'): ! names.append(file[:-2]) ! names.sort() ! return names class SelectionBox: ! def __init__(self, master=None): ! self.choices = [] ! self.frame = Frame(master, name="frame") ! self.frame.pack(expand=1, fill=BOTH) ! self.master = self.frame.master ! self.subframe = Frame(self.frame, name="subframe") ! self.subframe.pack(expand=0, fill=BOTH) ! self.leftsubframe = Frame(self.subframe, name='leftsubframe') ! self.leftsubframe.pack(side=LEFT, expand=1, fill=BOTH) ! self.rightsubframe = Frame(self.subframe, name='rightsubframe') ! self.rightsubframe.pack(side=RIGHT, expand=1, fill=BOTH) ! self.chaptervar = StringVar(master) ! self.chapter = Menubutton(self.rightsubframe, name='chapter', ! text='Directory', relief=RAISED, ! borderwidth=2) ! self.chapter.pack(side=TOP) ! self.chaptermenu = Menu(self.chapter, name='chaptermenu') ! self.chaptermenu.add_radiobutton(label='C functions', ! value=MAN3DIR, ! variable=self.chaptervar, ! command=self.newchapter) ! self.chaptermenu.add_radiobutton(label='Tcl/Tk functions', ! value=MANNDIR, ! variable=self.chaptervar, ! command=self.newchapter) ! self.chapter['menu'] = self.chaptermenu ! self.listbox = Listbox(self.rightsubframe, name='listbox', ! relief=SUNKEN, borderwidth=2, ! width=20, height=5) ! self.listbox.pack(expand=1, fill=BOTH) ! self.l1 = Button(self.leftsubframe, name='l1', ! text='Display manual page named:', ! command=self.entry_cb) ! self.l1.pack(side=TOP) ! self.entry = Entry(self.leftsubframe, name='entry', ! relief=SUNKEN, borderwidth=2, ! width=20) ! self.entry.pack(expand=0, fill=X) ! self.l2frame = Frame(self.leftsubframe, name='l2frame') ! self.l2frame.pack(expand=0, fill=NONE) ! self.l2 = Button(self.l2frame, name='l2', ! text='Search regexp:', ! command=self.search_cb) ! self.l2.pack(side=LEFT) ! self.casevar = BooleanVar() ! self.casesense = Checkbutton(self.l2frame, name='casesense', ! text='Case sensitive', ! variable=self.casevar, ! relief=FLAT) ! self.casesense.pack(side=LEFT) ! self.search = Entry(self.leftsubframe, name='search', ! relief=SUNKEN, borderwidth=2, ! width=20) ! self.search.pack(expand=0, fill=X) ! self.title = Label(self.leftsubframe, name='title', ! text='(none)') ! self.title.pack(side=BOTTOM) ! self.text = ManPage(self.frame, name='text', ! relief=SUNKEN, borderwidth=2, ! wrap=NONE, width=72, ! selectbackground='pink') ! self.text.pack(expand=1, fill=BOTH) ! self.entry.bind('', self.entry_cb) ! self.search.bind('', self.search_cb) ! self.listbox.bind('', self.listbox_cb) ! self.entry.bind('', self.entry_tab) ! self.search.bind('', self.search_tab) ! self.text.bind('', self.text_tab) ! self.entry.focus_set() ! self.chaptervar.set(MANNDIR) ! self.newchapter() ! def newchapter(self): ! mandir = self.chaptervar.get() ! self.choices = [] ! self.addlist(listmanpages(mandir)) ! def addchoice(self, choice): ! if choice not in self.choices: ! self.choices.append(choice) ! self.choices.sort() ! self.update() ! def addlist(self, list): ! self.choices[len(self.choices):] = list ! self.choices.sort() ! self.update() ! def entry_cb(self, *e): ! self.update() ! def listbox_cb(self, e): ! selection = self.listbox.curselection() ! if selection and len(selection) == 1: ! name = self.listbox.get(selection[0]) ! self.show_page(name) ! def search_cb(self, *e): ! self.search_string(self.search.get()) ! def entry_tab(self, e): ! self.search.focus_set() ! def search_tab(self, e): ! self.entry.focus_set() ! def text_tab(self, e): ! self.entry.focus_set() ! def updatelist(self): ! key = self.entry.get() ! ok = filter(lambda name, key=key, n=len(key): name[:n]==key, ! self.choices) ! if not ok: ! self.frame.bell() ! self.listbox.delete(0, AtEnd()) ! exactmatch = 0 ! for item in ok: ! if item == key: exactmatch = 1 ! self.listbox.insert(AtEnd(), item) ! if exactmatch: ! return key ! n = self.listbox.size() ! if n == 1: ! return self.listbox.get(0) ! # Else return None, meaning not a unique selection ! def update(self): ! name = self.updatelist() ! if name: ! self.show_page(name) ! self.entry.delete(0, AtEnd()) ! self.updatelist() ! def show_page(self, name): ! file = '%s/%s.?' % (self.chaptervar.get(), name) ! fp = os.popen('nroff -man %s | ul -i' % file, 'r') ! self.text.kill() ! self.title['text'] = name ! self.text.parsefile(fp) ! def search_string(self, search): ! if not search: ! self.frame.bell() ! print 'Empty search string' ! return ! if not self.casevar.get(): ! map = regex.casefold ! else: ! map = None ! try: ! if map: ! prog = regex.compile(search, map) ! else: ! prog = regex.compile(search) ! except regex.error, msg: ! self.frame.bell() ! print 'Regex error:', msg ! return ! here = self.text.index(AtInsert()) ! lineno = string.atoi(here[:string.find(here, '.')]) ! end = self.text.index(AtEnd()) ! endlineno = string.atoi(end[:string.find(end, '.')]) ! wraplineno = lineno ! found = 0 ! while 1: ! lineno = lineno + 1 ! if lineno > endlineno: ! if wraplineno <= 0: ! break ! endlineno = wraplineno ! lineno = 0 ! wraplineno = 0 ! line = self.text.get('%d.0 linestart' % lineno, ! '%d.0 lineend' % lineno) ! i = prog.search(line) ! if i >= 0: ! found = 1 ! n = max(1, len(prog.group(0))) ! try: ! self.text.tag_remove('sel', ! AtSelFirst(), ! AtSelLast()) ! except TclError: ! pass ! self.text.tag_add('sel', ! '%d.%d' % (lineno, i), ! '%d.%d' % (lineno, i+n)) ! self.text.mark_set(AtInsert(), ! '%d.%d' % (lineno, i)) ! self.text.yview_pickplace(AtInsert()) ! break ! if not found: ! self.frame.bell() def main(): ! root = Tk() ! sb = SelectionBox(root) ! if sys.argv[1:]: ! sb.show_page(sys.argv[1]) ! root.minsize(1, 1) ! root.mainloop() main() --- 47,267 ---- def listmanpages(mandir): ! files = os.listdir(mandir) ! names = [] ! for file in files: ! if file[-2:-1] == '.' and (file[-1] in 'ln123456789'): ! names.append(file[:-2]) ! names.sort() ! return names class SelectionBox: ! def __init__(self, master=None): ! self.choices = [] ! self.frame = Frame(master, name="frame") ! self.frame.pack(expand=1, fill=BOTH) ! self.master = self.frame.master ! self.subframe = Frame(self.frame, name="subframe") ! self.subframe.pack(expand=0, fill=BOTH) ! self.leftsubframe = Frame(self.subframe, name='leftsubframe') ! self.leftsubframe.pack(side=LEFT, expand=1, fill=BOTH) ! self.rightsubframe = Frame(self.subframe, name='rightsubframe') ! self.rightsubframe.pack(side=RIGHT, expand=1, fill=BOTH) ! self.chaptervar = StringVar(master) ! self.chapter = Menubutton(self.rightsubframe, name='chapter', ! text='Directory', relief=RAISED, ! borderwidth=2) ! self.chapter.pack(side=TOP) ! self.chaptermenu = Menu(self.chapter, name='chaptermenu') ! self.chaptermenu.add_radiobutton(label='C functions', ! value=MAN3DIR, ! variable=self.chaptervar, ! command=self.newchapter) ! self.chaptermenu.add_radiobutton(label='Tcl/Tk functions', ! value=MANNDIR, ! variable=self.chaptervar, ! command=self.newchapter) ! self.chapter['menu'] = self.chaptermenu ! self.listbox = Listbox(self.rightsubframe, name='listbox', ! relief=SUNKEN, borderwidth=2, ! width=20, height=5) ! self.listbox.pack(expand=1, fill=BOTH) ! self.l1 = Button(self.leftsubframe, name='l1', ! text='Display manual page named:', ! command=self.entry_cb) ! self.l1.pack(side=TOP) ! self.entry = Entry(self.leftsubframe, name='entry', ! relief=SUNKEN, borderwidth=2, ! width=20) ! self.entry.pack(expand=0, fill=X) ! self.l2frame = Frame(self.leftsubframe, name='l2frame') ! self.l2frame.pack(expand=0, fill=NONE) ! self.l2 = Button(self.l2frame, name='l2', ! text='Search regexp:', ! command=self.search_cb) ! self.l2.pack(side=LEFT) ! self.casevar = BooleanVar() ! self.casesense = Checkbutton(self.l2frame, name='casesense', ! text='Case sensitive', ! variable=self.casevar, ! relief=FLAT) ! self.casesense.pack(side=LEFT) ! self.search = Entry(self.leftsubframe, name='search', ! relief=SUNKEN, borderwidth=2, ! width=20) ! self.search.pack(expand=0, fill=X) ! self.title = Label(self.leftsubframe, name='title', ! text='(none)') ! self.title.pack(side=BOTTOM) ! self.text = ManPage(self.frame, name='text', ! relief=SUNKEN, borderwidth=2, ! wrap=NONE, width=72, ! selectbackground='pink') ! self.text.pack(expand=1, fill=BOTH) ! self.entry.bind('', self.entry_cb) ! self.search.bind('', self.search_cb) ! self.listbox.bind('', self.listbox_cb) ! self.entry.bind('', self.entry_tab) ! self.search.bind('', self.search_tab) ! self.text.bind('', self.text_tab) ! self.entry.focus_set() ! self.chaptervar.set(MANNDIR) ! self.newchapter() ! def newchapter(self): ! mandir = self.chaptervar.get() ! self.choices = [] ! self.addlist(listmanpages(mandir)) ! def addchoice(self, choice): ! if choice not in self.choices: ! self.choices.append(choice) ! self.choices.sort() ! self.update() ! def addlist(self, list): ! self.choices[len(self.choices):] = list ! self.choices.sort() ! self.update() ! def entry_cb(self, *e): ! self.update() ! def listbox_cb(self, e): ! selection = self.listbox.curselection() ! if selection and len(selection) == 1: ! name = self.listbox.get(selection[0]) ! self.show_page(name) ! def search_cb(self, *e): ! self.search_string(self.search.get()) ! def entry_tab(self, e): ! self.search.focus_set() ! def search_tab(self, e): ! self.entry.focus_set() ! def text_tab(self, e): ! self.entry.focus_set() ! def updatelist(self): ! key = self.entry.get() ! ok = filter(lambda name, key=key, n=len(key): name[:n]==key, ! self.choices) ! if not ok: ! self.frame.bell() ! self.listbox.delete(0, AtEnd()) ! exactmatch = 0 ! for item in ok: ! if item == key: exactmatch = 1 ! self.listbox.insert(AtEnd(), item) ! if exactmatch: ! return key ! n = self.listbox.size() ! if n == 1: ! return self.listbox.get(0) ! # Else return None, meaning not a unique selection ! def update(self): ! name = self.updatelist() ! if name: ! self.show_page(name) ! self.entry.delete(0, AtEnd()) ! self.updatelist() ! def show_page(self, name): ! file = '%s/%s.?' % (self.chaptervar.get(), name) ! fp = os.popen('nroff -man %s | ul -i' % file, 'r') ! self.text.kill() ! self.title['text'] = name ! self.text.parsefile(fp) ! def search_string(self, search): ! if not search: ! self.frame.bell() ! print 'Empty search string' ! return ! if not self.casevar.get(): ! map = regex.casefold ! else: ! map = None ! try: ! if map: ! prog = regex.compile(search, map) ! else: ! prog = regex.compile(search) ! except regex.error, msg: ! self.frame.bell() ! print 'Regex error:', msg ! return ! here = self.text.index(AtInsert()) ! lineno = string.atoi(here[:string.find(here, '.')]) ! end = self.text.index(AtEnd()) ! endlineno = string.atoi(end[:string.find(end, '.')]) ! wraplineno = lineno ! found = 0 ! while 1: ! lineno = lineno + 1 ! if lineno > endlineno: ! if wraplineno <= 0: ! break ! endlineno = wraplineno ! lineno = 0 ! wraplineno = 0 ! line = self.text.get('%d.0 linestart' % lineno, ! '%d.0 lineend' % lineno) ! i = prog.search(line) ! if i >= 0: ! found = 1 ! n = max(1, len(prog.group(0))) ! try: ! self.text.tag_remove('sel', ! AtSelFirst(), ! AtSelLast()) ! except TclError: ! pass ! self.text.tag_add('sel', ! '%d.%d' % (lineno, i), ! '%d.%d' % (lineno, i+n)) ! self.text.mark_set(AtInsert(), ! '%d.%d' % (lineno, i)) ! self.text.yview_pickplace(AtInsert()) ! break ! if not found: ! self.frame.bell() def main(): ! root = Tk() ! sb = SelectionBox(root) ! if sys.argv[1:]: ! sb.show_page(sys.argv[1]) ! root.minsize(1, 1) ! root.mainloop() main() Index: wish.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/guido/wish.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** wish.py 23 Oct 1995 14:31:46 -0000 1.4 --- wish.py 18 Jul 2004 06:09:09 -0000 1.5 *************** *** 10,27 **** while 1: ! if cmd: prompt = '' ! else: prompt = '% ' ! try: ! line = raw_input(prompt) ! except EOFError: ! break ! cmd = cmd + (line + '\n') ! if tk.getboolean(tk.call('info', 'complete', cmd)): ! tk.record(line) ! try: ! result = tk.call('eval', cmd) ! except _tkinter.TclError, msg: ! print 'TclError:', msg ! else: ! if result: print result ! cmd = '' --- 10,27 ---- while 1: ! if cmd: prompt = '' ! else: prompt = '% ' ! try: ! line = raw_input(prompt) ! except EOFError: ! break ! cmd = cmd + (line + '\n') ! if tk.getboolean(tk.call('info', 'complete', cmd)): ! tk.record(line) ! try: ! result = tk.call('eval', cmd) ! except _tkinter.TclError, msg: ! print 'TclError:', msg ! else: ! if result: print result ! cmd = '' From tim_one at users.sourceforge.net Sun Jul 18 08:09:16 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 08:09:22 2004 Subject: [Python-checkins] python/dist/src/Demo/tkinter/matt 00-HELLO-WORLD.py, 1.2, 1.3 animation-simple.py, 1.2, 1.3 animation-w-velocity-ctrl.py, 1.3, 1.4 bind-w-mult-calls-p-type.py, 1.2, 1.3 canvas-demo-simple.py, 1.2, 1.3 canvas-gridding.py, 1.2, 1.3 canvas-moving-or-creating.py, 1.3, 1.4 canvas-moving-w-mouse.py, 1.3, 1.4 canvas-mult-item-sel.py, 1.2, 1.3 canvas-reading-tag-info.py, 1.2, 1.3 canvas-w-widget-draw-el.py, 1.2, 1.3 canvas-with-scrollbars.py, 1.3, 1.4 dialog-box.py, 1.2, 1.3 entry-simple.py, 1.1, 1.2 entry-with-shared-variable.py, 1.3, 1.4 killing-window-w-wm.py, 1.2, 1.3 menu-all-types-of-entries.py, 1.2, 1.3 menu-simple.py, 1.4, 1.5 not-what-you-might-think-1.py, 1.2, 1.3 not-what-you-might-think-2.py, 1.2, 1.3 packer-and-placer-together.py, 1.2, 1.3 packer-simple.py, 1.2, 1.3 placer-simple.py, 1.2, 1.3 pong-demo-1.py, 1.3, 1.4 printing-coords-of-items.py, 1.2, 1.3 radiobutton-simple.py, 1.2, 1.3 rubber-band-box-demo-1.py, 1.2, 1.3 rubber-line-demo-1.py, 1.2, 1.3 slider-demo-1.py, 1.2, 1.3 subclass-existing-widgets.py, 1.2, 1.3 two-radio-groups.py, 1.2, 1.3 window-creation-more.py, 1.2, 1.3 window-creation-simple.py, 1.2, 1.3 window-creation-w-location.py, 1.3, 1.4 Message-ID: Update of /cvsroot/python/python/dist/src/Demo/tkinter/matt In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30561/matt Modified Files: 00-HELLO-WORLD.py animation-simple.py animation-w-velocity-ctrl.py bind-w-mult-calls-p-type.py canvas-demo-simple.py canvas-gridding.py canvas-moving-or-creating.py canvas-moving-w-mouse.py canvas-mult-item-sel.py canvas-reading-tag-info.py canvas-w-widget-draw-el.py canvas-with-scrollbars.py dialog-box.py entry-simple.py entry-with-shared-variable.py killing-window-w-wm.py menu-all-types-of-entries.py menu-simple.py not-what-you-might-think-1.py not-what-you-might-think-2.py packer-and-placer-together.py packer-simple.py placer-simple.py pong-demo-1.py printing-coords-of-items.py radiobutton-simple.py rubber-band-box-demo-1.py rubber-line-demo-1.py slider-demo-1.py subclass-existing-widgets.py two-radio-groups.py window-creation-more.py window-creation-simple.py window-creation-w-location.py Log Message: Whitespace normalization, via reindent.py. Index: 00-HELLO-WORLD.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/matt/00-HELLO-WORLD.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** 00-HELLO-WORLD.py 30 Jul 1996 18:56:28 -0000 1.2 --- 00-HELLO-WORLD.py 18 Jul 2004 06:09:09 -0000 1.3 *************** *** 1,26 **** from Tkinter import * ! # note that there is no explicit call to start Tk. ! # Tkinter is smart enough to start the system if it's not already going. class Test(Frame): def printit(self): ! print "hi" def createWidgets(self): ! self.QUIT = Button(self, text='QUIT', foreground='red', ! command=self.quit) ! ! self.QUIT.pack(side=LEFT, fill=BOTH) ! # a hello button ! self.hi_there = Button(self, text='Hello', ! command=self.printit) ! self.hi_there.pack(side=LEFT) def __init__(self, master=None): ! Frame.__init__(self, master) ! Pack.config(self) ! self.createWidgets() test = Test() --- 1,26 ---- from Tkinter import * ! # note that there is no explicit call to start Tk. ! # Tkinter is smart enough to start the system if it's not already going. class Test(Frame): def printit(self): ! print "hi" def createWidgets(self): ! self.QUIT = Button(self, text='QUIT', foreground='red', ! command=self.quit) ! self.QUIT.pack(side=LEFT, fill=BOTH) ! ! # a hello button ! self.hi_there = Button(self, text='Hello', ! command=self.printit) ! self.hi_there.pack(side=LEFT) def __init__(self, master=None): ! Frame.__init__(self, master) ! Pack.config(self) ! self.createWidgets() test = Test() Index: animation-simple.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/matt/animation-simple.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** animation-simple.py 30 Jul 1996 18:56:30 -0000 1.2 --- animation-simple.py 18 Jul 2004 06:09:09 -0000 1.3 *************** *** 5,32 **** class Test(Frame): def printit(self): ! print "hi" def createWidgets(self): ! self.QUIT = Button(self, text='QUIT', foreground='red', ! command=self.quit) ! self.QUIT.pack(side=LEFT, fill=BOTH) ! self.draw = Canvas(self, width="5i", height="5i") ! # all of these work.. ! self.draw.create_rectangle(0, 0, 10, 10, tags="thing", fill="blue") ! self.draw.pack(side=LEFT) def moveThing(self, *args): ! # move 1/10 of an inch every 1/10 sec (1" per second, smoothly) ! self.draw.move("thing", "0.01i", "0.01i") ! self.after(10, self.moveThing) def __init__(self, master=None): ! Frame.__init__(self, master) ! Pack.config(self) ! self.createWidgets() ! self.after(10, self.moveThing) --- 5,32 ---- class Test(Frame): def printit(self): ! print "hi" def createWidgets(self): ! self.QUIT = Button(self, text='QUIT', foreground='red', ! command=self.quit) ! self.QUIT.pack(side=LEFT, fill=BOTH) ! self.draw = Canvas(self, width="5i", height="5i") ! # all of these work.. ! self.draw.create_rectangle(0, 0, 10, 10, tags="thing", fill="blue") ! self.draw.pack(side=LEFT) def moveThing(self, *args): ! # move 1/10 of an inch every 1/10 sec (1" per second, smoothly) ! self.draw.move("thing", "0.01i", "0.01i") ! self.after(10, self.moveThing) def __init__(self, master=None): ! Frame.__init__(self, master) ! Pack.config(self) ! self.createWidgets() ! self.after(10, self.moveThing) Index: animation-w-velocity-ctrl.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/matt/animation-w-velocity-ctrl.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** animation-w-velocity-ctrl.py 12 Feb 2004 17:35:04 -0000 1.3 --- animation-w-velocity-ctrl.py 18 Jul 2004 06:09:09 -0000 1.4 *************** *** 1,41 **** from Tkinter import * ! # this is the same as simple-demo-1.py, but uses ! # subclassing. ! # note that there is no explicit call to start Tk. ! # Tkinter is smart enough to start the system if it's not already going. class Test(Frame): def printit(self): ! print "hi" def createWidgets(self): ! self.QUIT = Button(self, text='QUIT', foreground='red', ! command=self.quit) ! self.QUIT.pack(side=BOTTOM, fill=BOTH) ! self.draw = Canvas(self, width="5i", height="5i") ! self.speed = Scale(self, orient=HORIZONTAL, from_=-100, to=100) ! self.speed.pack(side=BOTTOM, fill=X) ! # all of these work.. ! self.draw.create_rectangle(0, 0, 10, 10, tags="thing", fill="blue") ! self.draw.pack(side=LEFT) def moveThing(self, *args): ! velocity = self.speed.get() ! str = float(velocity) / 1000.0 ! str = "%ri" % (str,) ! self.draw.move("thing", str, str) ! self.after(10, self.moveThing) def __init__(self, master=None): ! Frame.__init__(self, master) ! Pack.config(self) ! self.createWidgets() ! self.after(10, self.moveThing) --- 1,41 ---- from Tkinter import * ! # this is the same as simple-demo-1.py, but uses ! # subclassing. ! # note that there is no explicit call to start Tk. ! # Tkinter is smart enough to start the system if it's not already going. class Test(Frame): def printit(self): ! print "hi" def createWidgets(self): ! self.QUIT = Button(self, text='QUIT', foreground='red', ! command=self.quit) ! self.QUIT.pack(side=BOTTOM, fill=BOTH) ! self.draw = Canvas(self, width="5i", height="5i") ! self.speed = Scale(self, orient=HORIZONTAL, from_=-100, to=100) ! self.speed.pack(side=BOTTOM, fill=X) ! # all of these work.. ! self.draw.create_rectangle(0, 0, 10, 10, tags="thing", fill="blue") ! self.draw.pack(side=LEFT) def moveThing(self, *args): ! velocity = self.speed.get() ! str = float(velocity) / 1000.0 ! str = "%ri" % (str,) ! self.draw.move("thing", str, str) ! self.after(10, self.moveThing) def __init__(self, master=None): ! Frame.__init__(self, master) ! Pack.config(self) ! self.createWidgets() ! self.after(10, self.moveThing) Index: bind-w-mult-calls-p-type.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/matt/bind-w-mult-calls-p-type.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** bind-w-mult-calls-p-type.py 30 Jul 1996 18:56:33 -0000 1.2 --- bind-w-mult-calls-p-type.py 18 Jul 2004 06:09:09 -0000 1.3 *************** *** 1,4 **** from Tkinter import * ! import string # This program shows how to use a simple type-in box --- 1,4 ---- from Tkinter import * ! import string # This program shows how to use a simple type-in box *************** *** 6,33 **** class App(Frame): def __init__(self, master=None): ! Frame.__init__(self, master) ! self.pack() ! self.entrythingy = Entry() ! self.entrythingy.pack() ! # and here we get a callback when the user hits return. we could ! # make the key that triggers the callback anything we wanted to. ! # other typical options might be or (for anything) ! self.entrythingy.bind('', self.print_contents) ! # Note that here is where we bind a completely different callback to ! # the same event. We pass "+" here to indicate that we wish to ADD ! # this callback to the list associated with this event type. ! # Not specifying "+" would simply override whatever callback was ! # defined on this event. ! self.entrythingy.bind('', self.print_something_else, "+") def print_contents(self, event): ! print "hi. contents of entry is now ---->", self.entrythingy.get() def print_something_else(self, event): ! print "hi. Now doing something completely different" --- 6,33 ---- class App(Frame): def __init__(self, master=None): ! Frame.__init__(self, master) ! self.pack() ! self.entrythingy = Entry() ! self.entrythingy.pack() ! # and here we get a callback when the user hits return. we could ! # make the key that triggers the callback anything we wanted to. ! # other typical options might be or (for anything) ! self.entrythingy.bind('', self.print_contents) ! # Note that here is where we bind a completely different callback to ! # the same event. We pass "+" here to indicate that we wish to ADD ! # this callback to the list associated with this event type. ! # Not specifying "+" would simply override whatever callback was ! # defined on this event. ! self.entrythingy.bind('', self.print_something_else, "+") def print_contents(self, event): ! print "hi. contents of entry is now ---->", self.entrythingy.get() def print_something_else(self, event): ! print "hi. Now doing something completely different" *************** *** 38,44 **** ! # secret tip for experts: if you pass *any* non-false value as ! # the third parameter to bind(), Tkinter.py will accumulate # callbacks instead of overwriting. I use "+" here because that's ! # the Tk notation for getting this sort of behavior. The perfect GUI # interface would use a less obscure notation. --- 38,44 ---- ! # secret tip for experts: if you pass *any* non-false value as ! # the third parameter to bind(), Tkinter.py will accumulate # callbacks instead of overwriting. I use "+" here because that's ! # the Tk notation for getting this sort of behavior. The perfect GUI # interface would use a less obscure notation. Index: canvas-demo-simple.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/matt/canvas-demo-simple.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** canvas-demo-simple.py 30 Jul 1996 18:56:35 -0000 1.2 --- canvas-demo-simple.py 18 Jul 2004 06:09:09 -0000 1.3 *************** *** 5,26 **** class Test(Frame): def printit(self): ! print "hi" def createWidgets(self): ! self.QUIT = Button(self, text='QUIT', foreground='red', ! command=self.quit) ! self.QUIT.pack(side=BOTTOM, fill=BOTH) ! self.draw = Canvas(self, width="5i", height="5i") ! # see the other demos for other ways of specifying coords for a polygon ! self.draw.create_rectangle(0, 0, "3i", "3i", fill="black") ! self.draw.pack(side=LEFT) def __init__(self, master=None): ! Frame.__init__(self, master) ! Pack.config(self) ! self.createWidgets() test = Test() --- 5,26 ---- class Test(Frame): def printit(self): ! print "hi" def createWidgets(self): ! self.QUIT = Button(self, text='QUIT', foreground='red', ! command=self.quit) ! self.QUIT.pack(side=BOTTOM, fill=BOTH) ! self.draw = Canvas(self, width="5i", height="5i") ! # see the other demos for other ways of specifying coords for a polygon ! self.draw.create_rectangle(0, 0, "3i", "3i", fill="black") ! self.draw.pack(side=LEFT) def __init__(self, master=None): ! Frame.__init__(self, master) ! Pack.config(self) ! self.createWidgets() test = Test() Index: canvas-gridding.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/matt/canvas-gridding.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** canvas-gridding.py 30 Jul 1996 18:56:37 -0000 1.2 --- canvas-gridding.py 18 Jul 2004 06:09:09 -0000 1.3 *************** *** 1,59 **** from Tkinter import * ! # this is the same as simple-demo-1.py, but uses ! # subclassing. ! # note that there is no explicit call to start Tk. ! # Tkinter is smart enough to start the system if it's not already going. class Test(Frame): def printit(self): ! print "hi" def createWidgets(self): ! self.QUIT = Button(self, text='QUIT', ! background='red', ! foreground='white', ! height=3, ! command=self.quit) ! self.QUIT.pack(side=BOTTOM, fill=BOTH) ! self.canvasObject = Canvas(self, width="5i", height="5i") ! self.canvasObject.pack(side=LEFT) def mouseDown(self, event): ! # canvas x and y take the screen coords from the event and translate ! # them into the coordinate system of the canvas object ! self.startx = self.canvasObject.canvasx(event.x, self.griddingSize) ! self.starty = self.canvasObject.canvasy(event.y, self.griddingSize) def mouseMotion(self, event): ! # canvas x and y take the screen coords from the event and translate ! # them into the coordinate system of the canvas object ! x = self.canvasObject.canvasx(event.x, self.griddingSize) ! y = self.canvasObject.canvasy(event.y, self.griddingSize) ! if (self.startx != event.x) and (self.starty != event.y) : ! self.canvasObject.delete(self.rubberbandBox) ! self.rubberbandBox = self.canvasObject.create_rectangle( ! self.startx, self.starty, x, y) ! # this flushes the output, making sure that ! # the rectangle makes it to the screen ! # before the next event is handled ! self.update_idletasks() def __init__(self, master=None): ! Frame.__init__(self, master) ! Pack.config(self) ! self.createWidgets() ! # this is a "tagOrId" for the rectangle we draw on the canvas ! self.rubberbandBox = None ! # this is the size of the gridding squares ! self.griddingSize = 50 - Widget.bind(self.canvasObject, "", self.mouseDown) - Widget.bind(self.canvasObject, "", self.mouseMotion) - test = Test() --- 1,59 ---- from Tkinter import * ! # this is the same as simple-demo-1.py, but uses ! # subclassing. ! # note that there is no explicit call to start Tk. ! # Tkinter is smart enough to start the system if it's not already going. class Test(Frame): def printit(self): ! print "hi" def createWidgets(self): ! self.QUIT = Button(self, text='QUIT', ! background='red', ! foreground='white', ! height=3, ! command=self.quit) ! self.QUIT.pack(side=BOTTOM, fill=BOTH) ! self.canvasObject = Canvas(self, width="5i", height="5i") ! self.canvasObject.pack(side=LEFT) def mouseDown(self, event): ! # canvas x and y take the screen coords from the event and translate ! # them into the coordinate system of the canvas object ! self.startx = self.canvasObject.canvasx(event.x, self.griddingSize) ! self.starty = self.canvasObject.canvasy(event.y, self.griddingSize) def mouseMotion(self, event): ! # canvas x and y take the screen coords from the event and translate ! # them into the coordinate system of the canvas object ! x = self.canvasObject.canvasx(event.x, self.griddingSize) ! y = self.canvasObject.canvasy(event.y, self.griddingSize) ! if (self.startx != event.x) and (self.starty != event.y) : ! self.canvasObject.delete(self.rubberbandBox) ! self.rubberbandBox = self.canvasObject.create_rectangle( ! self.startx, self.starty, x, y) ! # this flushes the output, making sure that ! # the rectangle makes it to the screen ! # before the next event is handled ! self.update_idletasks() def __init__(self, master=None): ! Frame.__init__(self, master) ! Pack.config(self) ! self.createWidgets() ! # this is a "tagOrId" for the rectangle we draw on the canvas ! self.rubberbandBox = None ! # this is the size of the gridding squares ! self.griddingSize = 50 ! ! Widget.bind(self.canvasObject, "", self.mouseDown) ! Widget.bind(self.canvasObject, "", self.mouseMotion) test = Test() Index: canvas-moving-or-creating.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/matt/canvas-moving-or-creating.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** canvas-moving-or-creating.py 24 Sep 1997 13:39:51 -0000 1.3 --- canvas-moving-or-creating.py 18 Jul 2004 06:09:09 -0000 1.4 *************** *** 1,5 **** from Tkinter import * ! # this file demonstrates a more sophisticated movement -- # move dots or create new ones if you click outside the dots --- 1,5 ---- from Tkinter import * ! # this file demonstrates a more sophisticated movement -- # move dots or create new ones if you click outside the dots *************** *** 9,33 **** ################################################################### def mouseDown(self, event): ! # see if we're inside a dot. If we are, it ! # gets tagged as CURRENT for free by tk. ! if not event.widget.find_withtag(CURRENT): ! # there is no dot here, so we can make one, ! # and bind some interesting behavior to it. ! # ------ ! # create a dot, and mark it as CURRENT ! fred = self.draw.create_oval( ! event.x - 10, event.y -10, event.x +10, event.y + 10, ! fill="green", tags=CURRENT) ! self.draw.tag_bind(fred, "", self.mouseEnter) ! self.draw.tag_bind(fred, "", self.mouseLeave) ! self.lastx = event.x ! self.lasty = event.y def mouseMove(self, event): ! self.draw.move(CURRENT, event.x - self.lastx, event.y - self.lasty) ! self.lastx = event.x ! self.lasty = event.y ################################################################### --- 9,33 ---- ################################################################### def mouseDown(self, event): ! # see if we're inside a dot. If we are, it ! # gets tagged as CURRENT for free by tk. ! if not event.widget.find_withtag(CURRENT): ! # there is no dot here, so we can make one, ! # and bind some interesting behavior to it. ! # ------ ! # create a dot, and mark it as CURRENT ! fred = self.draw.create_oval( ! event.x - 10, event.y -10, event.x +10, event.y + 10, ! fill="green", tags=CURRENT) ! self.draw.tag_bind(fred, "", self.mouseEnter) ! self.draw.tag_bind(fred, "", self.mouseLeave) ! self.lastx = event.x ! self.lasty = event.y def mouseMove(self, event): ! self.draw.move(CURRENT, event.x - self.lastx, event.y - self.lasty) ! self.lastx = event.x ! self.lasty = event.y ################################################################### *************** *** 36,65 **** def mouseEnter(self, event): # the CURRENT tag is applied to the object the cursor is over. ! # this happens automatically. ! self.draw.itemconfig(CURRENT, fill="red") def mouseLeave(self, event): ! # the CURRENT tag is applied to the object the cursor is over. ! # this happens automatically. ! self.draw.itemconfig(CURRENT, fill="blue") def createWidgets(self): ! self.QUIT = Button(self, text='QUIT', foreground='red', ! command=self.quit) ! self.QUIT.pack(side=LEFT, fill=BOTH) ! self.draw = Canvas(self, width="5i", height="5i") ! self.draw.pack(side=LEFT) ! Widget.bind(self.draw, "<1>", self.mouseDown) ! Widget.bind(self.draw, "", self.mouseMove) def __init__(self, master=None): ! Frame.__init__(self, master) ! Pack.config(self) ! self.createWidgets() test = Test() test.mainloop() - - - --- 36,62 ---- def mouseEnter(self, event): # the CURRENT tag is applied to the object the cursor is over. ! # this happens automatically. ! self.draw.itemconfig(CURRENT, fill="red") def mouseLeave(self, event): ! # the CURRENT tag is applied to the object the cursor is over. ! # this happens automatically. ! self.draw.itemconfig(CURRENT, fill="blue") def createWidgets(self): ! self.QUIT = Button(self, text='QUIT', foreground='red', ! command=self.quit) ! self.QUIT.pack(side=LEFT, fill=BOTH) ! self.draw = Canvas(self, width="5i", height="5i") ! self.draw.pack(side=LEFT) ! Widget.bind(self.draw, "<1>", self.mouseDown) ! Widget.bind(self.draw, "", self.mouseMove) def __init__(self, master=None): ! Frame.__init__(self, master) ! Pack.config(self) ! self.createWidgets() test = Test() test.mainloop() Index: canvas-moving-w-mouse.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/matt/canvas-moving-w-mouse.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** canvas-moving-w-mouse.py 30 Jul 1996 18:56:38 -0000 1.3 --- canvas-moving-w-mouse.py 18 Jul 2004 06:09:09 -0000 1.4 *************** *** 8,20 **** ################################################################### def mouseDown(self, event): ! # remember where the mouse went down ! self.lastx = event.x ! self.lasty = event.y def mouseMove(self, event): ! # whatever the mouse is over gets tagged as CURRENT for free by tk. ! self.draw.move(CURRENT, event.x - self.lastx, event.y - self.lasty) ! self.lastx = event.x ! self.lasty = event.y ################################################################### --- 8,20 ---- ################################################################### def mouseDown(self, event): ! # remember where the mouse went down ! self.lastx = event.x ! self.lasty = event.y def mouseMove(self, event): ! # whatever the mouse is over gets tagged as CURRENT for free by tk. ! self.draw.move(CURRENT, event.x - self.lastx, event.y - self.lasty) ! self.lastx = event.x ! self.lasty = event.y ################################################################### *************** *** 23,54 **** def mouseEnter(self, event): # the CURRENT tag is applied to the object the cursor is over. ! # this happens automatically. ! self.draw.itemconfig(CURRENT, fill="red") ! def mouseLeave(self, event): ! # the CURRENT tag is applied to the object the cursor is over. ! # this happens automatically. ! self.draw.itemconfig(CURRENT, fill="blue") def createWidgets(self): ! self.QUIT = Button(self, text='QUIT', foreground='red', ! command=self.quit) ! self.QUIT.pack(side=LEFT, fill=BOTH) ! self.draw = Canvas(self, width="5i", height="5i") ! self.draw.pack(side=LEFT) ! fred = self.draw.create_oval(0, 0, 20, 20, ! fill="green", tags="selected") ! self.draw.tag_bind(fred, "", self.mouseEnter) ! self.draw.tag_bind(fred, "", self.mouseLeave) ! Widget.bind(self.draw, "<1>", self.mouseDown) ! Widget.bind(self.draw, "", self.mouseMove) def __init__(self, master=None): ! Frame.__init__(self, master) ! Pack.config(self) ! self.createWidgets() test = Test() --- 23,54 ---- def mouseEnter(self, event): # the CURRENT tag is applied to the object the cursor is over. ! # this happens automatically. ! self.draw.itemconfig(CURRENT, fill="red") ! def mouseLeave(self, event): ! # the CURRENT tag is applied to the object the cursor is over. ! # this happens automatically. ! self.draw.itemconfig(CURRENT, fill="blue") def createWidgets(self): ! self.QUIT = Button(self, text='QUIT', foreground='red', ! command=self.quit) ! self.QUIT.pack(side=LEFT, fill=BOTH) ! self.draw = Canvas(self, width="5i", height="5i") ! self.draw.pack(side=LEFT) ! fred = self.draw.create_oval(0, 0, 20, 20, ! fill="green", tags="selected") ! self.draw.tag_bind(fred, "", self.mouseEnter) ! self.draw.tag_bind(fred, "", self.mouseLeave) ! Widget.bind(self.draw, "<1>", self.mouseDown) ! Widget.bind(self.draw, "", self.mouseMove) def __init__(self, master=None): ! Frame.__init__(self, master) ! Pack.config(self) ! self.createWidgets() test = Test() Index: canvas-mult-item-sel.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/matt/canvas-mult-item-sel.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** canvas-mult-item-sel.py 30 Jul 1996 18:56:41 -0000 1.2 --- canvas-mult-item-sel.py 18 Jul 2004 06:09:09 -0000 1.3 *************** *** 1,5 **** from Tkinter import * ! # allows moving dots with multiple selection. SELECTED_COLOR = "red" --- 1,5 ---- from Tkinter import * ! # allows moving dots with multiple selection. SELECTED_COLOR = "red" *************** *** 11,81 **** ################################################################### def mouseDown(self, event): ! # see if we're inside a dot. If we are, it ! # gets tagged as CURRENT for free by tk. - if not event.widget.find_withtag(CURRENT): - # we clicked outside of all dots on the canvas. unselect all. - - # re-color everything back to an unselected color - self.draw.itemconfig("selected", fill=UNSELECTED_COLOR) - # unselect everything - self.draw.dtag("selected") - else: - # mark as "selected" the thing the cursor is under - self.draw.addtag("selected", "withtag", CURRENT) - # color it as selected - self.draw.itemconfig("selected", fill=SELECTED_COLOR) - self.lastx = event.x - self.lasty = event.y - - def mouseMove(self, event): ! self.draw.move("selected", event.x - self.lastx, event.y - self.lasty) ! self.lastx = event.x ! self.lasty = event.y def makeNewDot(self): ! # create a dot, and mark it as current ! fred = self.draw.create_oval(0, 0, 20, 20, ! fill=SELECTED_COLOR, tags=CURRENT) ! # and make it selected ! self.draw.addtag("selected", "withtag", CURRENT) ! def createWidgets(self): ! self.QUIT = Button(self, text='QUIT', foreground='red', ! command=self.quit) ! ################ ! # make the canvas and bind some behavior to it ! ################ ! self.draw = Canvas(self, width="5i", height="5i") ! Widget.bind(self.draw, "<1>", self.mouseDown) ! Widget.bind(self.draw, "", self.mouseMove) ! # and other things..... ! self.button = Button(self, text="make a new dot", foreground="blue", ! command=self.makeNewDot) ! message = ("%s dots are selected and can be dragged.\n" ! "%s are not selected.\n" ! "Click in a dot to select it.\n" ! "Click on empty space to deselect all dots." ! ) % (SELECTED_COLOR, UNSELECTED_COLOR) ! self.label = Message(self, width="5i", text=message) ! self.QUIT.pack(side=BOTTOM, fill=BOTH) ! self.label.pack(side=BOTTOM, fill=X, expand=1) ! self.button.pack(side=BOTTOM, fill=X) ! self.draw.pack(side=LEFT) def __init__(self, master=None): ! Frame.__init__(self, master) ! Pack.config(self) ! self.createWidgets() test = Test() test.mainloop() - - - --- 11,78 ---- ################################################################### def mouseDown(self, event): ! # see if we're inside a dot. If we are, it ! # gets tagged as CURRENT for free by tk. ! ! if not event.widget.find_withtag(CURRENT): ! # we clicked outside of all dots on the canvas. unselect all. ! ! # re-color everything back to an unselected color ! self.draw.itemconfig("selected", fill=UNSELECTED_COLOR) ! # unselect everything ! self.draw.dtag("selected") ! else: ! # mark as "selected" the thing the cursor is under ! self.draw.addtag("selected", "withtag", CURRENT) ! # color it as selected ! self.draw.itemconfig("selected", fill=SELECTED_COLOR) ! ! self.lastx = event.x ! self.lasty = event.y def mouseMove(self, event): ! self.draw.move("selected", event.x - self.lastx, event.y - self.lasty) ! self.lastx = event.x ! self.lasty = event.y def makeNewDot(self): ! # create a dot, and mark it as current ! fred = self.draw.create_oval(0, 0, 20, 20, ! fill=SELECTED_COLOR, tags=CURRENT) ! # and make it selected ! self.draw.addtag("selected", "withtag", CURRENT) ! def createWidgets(self): ! self.QUIT = Button(self, text='QUIT', foreground='red', ! command=self.quit) ! ################ ! # make the canvas and bind some behavior to it ! ################ ! self.draw = Canvas(self, width="5i", height="5i") ! Widget.bind(self.draw, "<1>", self.mouseDown) ! Widget.bind(self.draw, "", self.mouseMove) ! # and other things..... ! self.button = Button(self, text="make a new dot", foreground="blue", ! command=self.makeNewDot) ! message = ("%s dots are selected and can be dragged.\n" ! "%s are not selected.\n" ! "Click in a dot to select it.\n" ! "Click on empty space to deselect all dots." ! ) % (SELECTED_COLOR, UNSELECTED_COLOR) ! self.label = Message(self, width="5i", text=message) ! self.QUIT.pack(side=BOTTOM, fill=BOTH) ! self.label.pack(side=BOTTOM, fill=X, expand=1) ! self.button.pack(side=BOTTOM, fill=X) ! self.draw.pack(side=LEFT) def __init__(self, master=None): ! Frame.__init__(self, master) ! Pack.config(self) ! self.createWidgets() test = Test() test.mainloop() Index: canvas-reading-tag-info.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/matt/canvas-reading-tag-info.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** canvas-reading-tag-info.py 30 Jul 1996 18:56:43 -0000 1.2 --- canvas-reading-tag-info.py 18 Jul 2004 06:09:09 -0000 1.3 *************** *** 4,47 **** class Test(Frame): def printit(self): ! print "hi" def createWidgets(self): ! self.QUIT = Button(self, text='QUIT', foreground='red', ! command=self.quit) ! self.QUIT.pack(side=BOTTOM, fill=BOTH) ! self.drawing = Canvas(self, width="5i", height="5i") ! # make a shape ! pgon = self.drawing.create_polygon( ! 10, 10, 110, 10, 110, 110, 10 , 110, ! fill="red", tags=("weee", "foo", "groo")) ! # this is how you query an object for its attributes ! # config options FOR CANVAS ITEMS always come back in tuples of length 5. ! # 0 attribute name ! # 1 BLANK ! # 2 BLANK ! # 3 default value ! # 4 current value ! # the blank spots are for consistency with the config command that ! # is used for widgets. (remember, this is for ITEMS drawn ! # on a canvas widget, not widgets) ! option_value = self.drawing.itemconfig(pgon, "stipple") ! print "pgon's current stipple value is -->", option_value[4], "<--" ! option_value = self.drawing.itemconfig(pgon, "fill") ! print "pgon's current fill value is -->", option_value[4], "<--" ! print " when he is usually colored -->", option_value[3], "<--" ! ## here we print out all the tags associated with this object ! option_value = self.drawing.itemconfig(pgon, "tags") ! print "pgon's tags are", option_value[4] ! self.drawing.pack(side=LEFT) def __init__(self, master=None): ! Frame.__init__(self, master) ! Pack.config(self) ! self.createWidgets() test = Test() --- 4,47 ---- class Test(Frame): def printit(self): ! print "hi" def createWidgets(self): ! self.QUIT = Button(self, text='QUIT', foreground='red', ! command=self.quit) ! self.QUIT.pack(side=BOTTOM, fill=BOTH) ! self.drawing = Canvas(self, width="5i", height="5i") ! # make a shape ! pgon = self.drawing.create_polygon( ! 10, 10, 110, 10, 110, 110, 10 , 110, ! fill="red", tags=("weee", "foo", "groo")) ! # this is how you query an object for its attributes ! # config options FOR CANVAS ITEMS always come back in tuples of length 5. ! # 0 attribute name ! # 1 BLANK ! # 2 BLANK ! # 3 default value ! # 4 current value ! # the blank spots are for consistency with the config command that ! # is used for widgets. (remember, this is for ITEMS drawn ! # on a canvas widget, not widgets) ! option_value = self.drawing.itemconfig(pgon, "stipple") ! print "pgon's current stipple value is -->", option_value[4], "<--" ! option_value = self.drawing.itemconfig(pgon, "fill") ! print "pgon's current fill value is -->", option_value[4], "<--" ! print " when he is usually colored -->", option_value[3], "<--" ! ## here we print out all the tags associated with this object ! option_value = self.drawing.itemconfig(pgon, "tags") ! print "pgon's tags are", option_value[4] ! self.drawing.pack(side=LEFT) def __init__(self, master=None): ! Frame.__init__(self, master) ! Pack.config(self) ! self.createWidgets() test = Test() Index: canvas-w-widget-draw-el.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/matt/canvas-w-widget-draw-el.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** canvas-w-widget-draw-el.py 30 Jul 1996 18:56:46 -0000 1.2 --- canvas-w-widget-draw-el.py 18 Jul 2004 06:09:09 -0000 1.3 *************** *** 5,34 **** class Test(Frame): def printhi(self): ! print "hi" def createWidgets(self): ! self.QUIT = Button(self, text='QUIT', foreground='red', ! command=self.quit) ! self.QUIT.pack(side=BOTTOM, fill=BOTH) ! self.draw = Canvas(self, width="5i", height="5i") ! self.button = Button(self, text="this is a button", ! command=self.printhi) ! # note here the coords are given in pixels (form the ! # upper right and corner of the window, as usual for X) ! # but might just have well been given in inches or points or ! # whatever...use the "anchor" option to control what point of the ! # widget (in this case the button) gets mapped to the given x, y. ! # you can specify corners, edges, center, etc... ! self.draw.create_window(300, 300, window=self.button) ! self.draw.pack(side=LEFT) def __init__(self, master=None): ! Frame.__init__(self, master) ! Pack.config(self) ! self.createWidgets() test = Test() --- 5,34 ---- class Test(Frame): def printhi(self): ! print "hi" def createWidgets(self): ! self.QUIT = Button(self, text='QUIT', foreground='red', ! command=self.quit) ! self.QUIT.pack(side=BOTTOM, fill=BOTH) ! self.draw = Canvas(self, width="5i", height="5i") ! self.button = Button(self, text="this is a button", ! command=self.printhi) ! # note here the coords are given in pixels (form the ! # upper right and corner of the window, as usual for X) ! # but might just have well been given in inches or points or ! # whatever...use the "anchor" option to control what point of the ! # widget (in this case the button) gets mapped to the given x, y. ! # you can specify corners, edges, center, etc... ! self.draw.create_window(300, 300, window=self.button) ! self.draw.pack(side=LEFT) def __init__(self, master=None): ! Frame.__init__(self, master) ! Pack.config(self) ! self.createWidgets() test = Test() Index: canvas-with-scrollbars.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/matt/canvas-with-scrollbars.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** canvas-with-scrollbars.py 30 Jul 1996 18:56:44 -0000 1.3 --- canvas-with-scrollbars.py 18 Jul 2004 06:09:09 -0000 1.4 *************** *** 1,5 **** from Tkinter import * ! # This example program creates a scroling canvas, and demonstrates # how to tie scrollbars and canvses together. The mechanism # is analogus for listboxes and other widgets with --- 1,5 ---- from Tkinter import * ! # This example program creates a scroling canvas, and demonstrates # how to tie scrollbars and canvses together. The mechanism # is analogus for listboxes and other widgets with *************** *** 8,58 **** class Test(Frame): def printit(self): ! print "hi" def createWidgets(self): ! self.question = Label(self, text="Can Find The BLUE Square??????") ! self.question.pack() ! self.QUIT = Button(self, text='QUIT', background='red', ! height=3, command=self.quit) ! self.QUIT.pack(side=BOTTOM, fill=BOTH) ! spacer = Frame(self, height="0.25i") ! spacer.pack(side=BOTTOM) ! # notice that the scroll region (20" x 20") is larger than ! # displayed size of the widget (5" x 5") ! self.draw = Canvas(self, width="5i", height="5i", ! background="white", ! scrollregion=(0, 0, "20i", "20i")) ! self.draw.scrollX = Scrollbar(self, orient=HORIZONTAL) ! self.draw.scrollY = Scrollbar(self, orient=VERTICAL) ! # now tie the three together. This is standard boilerplate text ! self.draw['xscrollcommand'] = self.draw.scrollX.set ! self.draw['yscrollcommand'] = self.draw.scrollY.set ! self.draw.scrollX['command'] = self.draw.xview ! self.draw.scrollY['command'] = self.draw.yview ! # draw something. Note that the first square ! # is visible, but you need to scroll to see the second one. ! self.draw.create_rectangle(0, 0, "3.5i", "3.5i", fill="black") ! self.draw.create_rectangle("10i", "10i", "13.5i", "13.5i", fill="blue") ! # pack 'em up ! self.draw.scrollX.pack(side=BOTTOM, fill=X) ! self.draw.scrollY.pack(side=RIGHT, fill=Y) ! self.draw.pack(side=LEFT) ! def scrollCanvasX(self, *args): ! print "scrolling", args ! print self.draw.scrollX.get() def __init__(self, master=None): ! Frame.__init__(self, master) ! Pack.config(self) ! self.createWidgets() test = Test() --- 8,58 ---- class Test(Frame): def printit(self): ! print "hi" def createWidgets(self): ! self.question = Label(self, text="Can Find The BLUE Square??????") ! self.question.pack() ! self.QUIT = Button(self, text='QUIT', background='red', ! height=3, command=self.quit) ! self.QUIT.pack(side=BOTTOM, fill=BOTH) ! spacer = Frame(self, height="0.25i") ! spacer.pack(side=BOTTOM) ! # notice that the scroll region (20" x 20") is larger than ! # displayed size of the widget (5" x 5") ! self.draw = Canvas(self, width="5i", height="5i", ! background="white", ! scrollregion=(0, 0, "20i", "20i")) ! self.draw.scrollX = Scrollbar(self, orient=HORIZONTAL) ! self.draw.scrollY = Scrollbar(self, orient=VERTICAL) ! # now tie the three together. This is standard boilerplate text ! self.draw['xscrollcommand'] = self.draw.scrollX.set ! self.draw['yscrollcommand'] = self.draw.scrollY.set ! self.draw.scrollX['command'] = self.draw.xview ! self.draw.scrollY['command'] = self.draw.yview ! # draw something. Note that the first square ! # is visible, but you need to scroll to see the second one. ! self.draw.create_rectangle(0, 0, "3.5i", "3.5i", fill="black") ! self.draw.create_rectangle("10i", "10i", "13.5i", "13.5i", fill="blue") ! # pack 'em up ! self.draw.scrollX.pack(side=BOTTOM, fill=X) ! self.draw.scrollY.pack(side=RIGHT, fill=Y) ! self.draw.pack(side=LEFT) ! def scrollCanvasX(self, *args): ! print "scrolling", args ! print self.draw.scrollX.get() def __init__(self, master=None): ! Frame.__init__(self, master) ! Pack.config(self) ! self.createWidgets() test = Test() Index: dialog-box.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/matt/dialog-box.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** dialog-box.py 30 Jul 1996 18:56:47 -0000 1.2 --- dialog-box.py 18 Jul 2004 06:09:09 -0000 1.3 *************** *** 7,63 **** class Test(Frame): def printit(self): ! print "hi" def makeWindow(self): ! """Create a top-level dialog with some buttons. ! This uses the Dialog class, which is a wrapper around the Tcl/Tk ! tk_dialog script. The function returns 0 if the user clicks 'yes' ! or 1 if the user clicks 'no'. ! """ ! # the parameters to this call are as follows: ! d = Dialog( ! self, ## name of a toplevel window ! title="fred the dialog box",## title on the window ! text="click on a choice", ## message to appear in window ! bitmap="info", ## bitmap (if any) to appear; ! ## if none, use "" ! # legal values here are: ! # string what it looks like ! # ---------------------------------------------- ! # error a circle with a slash through it ! # grey25 grey square ! # grey50 darker grey square ! # hourglass use for "wait.." ! # info a large, lower case "i" ! # questhead a human head with a "?" in it ! # question a large "?" ! # warning a large "!" ! # @fname X bitmap where fname is the path to the file ! # ! default=0, # the index of the default button choice. ! # hitting return selects this ! strings=("yes", "no")) ! # values of the 'strings' key are the labels for the ! # buttons that appear left to right in the dialog box ! return d.num def createWidgets(self): ! self.QUIT = Button(self, text='QUIT', foreground='red', ! command=self.quit) ! self.QUIT.pack(side=LEFT, fill=BOTH) ! # a hello button ! self.hi_there = Button(self, text='Make a New Window', ! command=self.makeWindow) ! self.hi_there.pack(side=LEFT) def __init__(self, master=None): ! Frame.__init__(self, master) ! Pack.config(self) ! self.windownum = 0 ! self.createWidgets() test = Test() --- 7,63 ---- class Test(Frame): def printit(self): ! print "hi" def makeWindow(self): ! """Create a top-level dialog with some buttons. ! This uses the Dialog class, which is a wrapper around the Tcl/Tk ! tk_dialog script. The function returns 0 if the user clicks 'yes' ! or 1 if the user clicks 'no'. ! """ ! # the parameters to this call are as follows: ! d = Dialog( ! self, ## name of a toplevel window ! title="fred the dialog box",## title on the window ! text="click on a choice", ## message to appear in window ! bitmap="info", ## bitmap (if any) to appear; ! ## if none, use "" ! # legal values here are: ! # string what it looks like ! # ---------------------------------------------- ! # error a circle with a slash through it ! # grey25 grey square ! # grey50 darker grey square ! # hourglass use for "wait.." ! # info a large, lower case "i" ! # questhead a human head with a "?" in it ! # question a large "?" ! # warning a large "!" ! # @fname X bitmap where fname is the path to the file ! # ! default=0, # the index of the default button choice. ! # hitting return selects this ! strings=("yes", "no")) ! # values of the 'strings' key are the labels for the ! # buttons that appear left to right in the dialog box ! return d.num def createWidgets(self): ! self.QUIT = Button(self, text='QUIT', foreground='red', ! command=self.quit) ! self.QUIT.pack(side=LEFT, fill=BOTH) ! # a hello button ! self.hi_there = Button(self, text='Make a New Window', ! command=self.makeWindow) ! self.hi_there.pack(side=LEFT) def __init__(self, master=None): ! Frame.__init__(self, master) ! Pack.config(self) ! self.windownum = 0 ! self.createWidgets() test = Test() Index: entry-simple.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/matt/entry-simple.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** entry-simple.py 7 Oct 1994 09:53:59 -0000 1.1 --- entry-simple.py 18 Jul 2004 06:09:09 -0000 1.2 *************** *** 1,4 **** from Tkinter import * ! import string # This program shows how to use a simple type-in box --- 1,4 ---- from Tkinter import * ! import string # This program shows how to use a simple type-in box *************** *** 6,25 **** class App(Frame): def __init__(self, master=None): ! Frame.__init__(self, master) ! self.pack() ! self.entrythingy = Entry() ! self.entrythingy.pack() ! # and here we get a callback when the user hits return. we could ! # make the key that triggers the callback anything we wanted to. ! # other typical options might be or (for anything) ! self.entrythingy.bind('', self.print_contents) def print_contents(self, event): ! print "hi. contents of entry is now ---->", self.entrythingy.get() root = App() root.master.title("Foo") root.mainloop() - --- 6,24 ---- class App(Frame): def __init__(self, master=None): ! Frame.__init__(self, master) ! self.pack() ! self.entrythingy = Entry() ! self.entrythingy.pack() ! # and here we get a callback when the user hits return. we could ! # make the key that triggers the callback anything we wanted to. ! # other typical options might be or (for anything) ! self.entrythingy.bind('', self.print_contents) def print_contents(self, event): ! print "hi. contents of entry is now ---->", self.entrythingy.get() root = App() root.master.title("Foo") root.mainloop() Index: entry-with-shared-variable.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/matt/entry-with-shared-variable.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** entry-with-shared-variable.py 27 Nov 1996 19:47:42 -0000 1.3 --- entry-with-shared-variable.py 18 Jul 2004 06:09:09 -0000 1.4 *************** *** 1,4 **** from Tkinter import * ! import string # This program shows how to make a typein box shadow a program variable. --- 1,4 ---- from Tkinter import * ! import string # This program shows how to make a typein box shadow a program variable. *************** *** 6,47 **** class App(Frame): def __init__(self, master=None): ! Frame.__init__(self, master) ! self.pack() ! self.entrythingy = Entry(self) ! self.entrythingy.pack() ! self.button = Button(self, text="Uppercase The Entry", ! command=self.upper) ! self.button.pack() ! # here we have the text in the entry widget tied to a variable. ! # changes in the variable are echoed in the widget and vice versa. ! # Very handy. ! # there are other Variable types. See Tkinter.py for all ! # the other variable types that can be shadowed ! self.contents = StringVar() ! self.contents.set("this is a variable") ! self.entrythingy.config(textvariable=self.contents) ! # and here we get a callback when the user hits return. we could ! # make the key that triggers the callback anything we wanted to. ! # other typical options might be or (for anything) ! self.entrythingy.bind('', self.print_contents) def upper(self): ! # notice here, we don't actually refer to the entry box. ! # we just operate on the string variable and we # because it's being looked at by the entry widget, changing ! # the variable changes the entry widget display automatically. ! # the strange get/set operators are clunky, true... ! str = string.upper(self.contents.get()) ! self.contents.set(str) def print_contents(self, event): ! print "hi. contents of entry is now ---->", self.contents.get() root = App() root.master.title("Foo") root.mainloop() - --- 6,46 ---- class App(Frame): def __init__(self, master=None): ! Frame.__init__(self, master) ! self.pack() ! self.entrythingy = Entry(self) ! self.entrythingy.pack() ! self.button = Button(self, text="Uppercase The Entry", ! command=self.upper) ! self.button.pack() ! # here we have the text in the entry widget tied to a variable. ! # changes in the variable are echoed in the widget and vice versa. ! # Very handy. ! # there are other Variable types. See Tkinter.py for all ! # the other variable types that can be shadowed ! self.contents = StringVar() ! self.contents.set("this is a variable") ! self.entrythingy.config(textvariable=self.contents) ! # and here we get a callback when the user hits return. we could ! # make the key that triggers the callback anything we wanted to. ! # other typical options might be or (for anything) ! self.entrythingy.bind('', self.print_contents) def upper(self): ! # notice here, we don't actually refer to the entry box. ! # we just operate on the string variable and we # because it's being looked at by the entry widget, changing ! # the variable changes the entry widget display automatically. ! # the strange get/set operators are clunky, true... ! str = string.upper(self.contents.get()) ! self.contents.set(str) def print_contents(self, event): ! print "hi. contents of entry is now ---->", self.contents.get() root = App() root.master.title("Foo") root.mainloop() Index: killing-window-w-wm.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/matt/killing-window-w-wm.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** killing-window-w-wm.py 30 Jul 1996 18:56:50 -0000 1.2 --- killing-window-w-wm.py 18 Jul 2004 06:09:09 -0000 1.3 *************** *** 1,7 **** from Tkinter import * ! # This file shows how to trap the killing of a window # when the user uses window manager menus (typ. upper left hand corner ! # menu in the decoration border). --- 1,7 ---- from Tkinter import * ! # This file shows how to trap the killing of a window # when the user uses window manager menus (typ. upper left hand corner ! # menu in the decoration border). *************** *** 12,40 **** class Test(Frame): def deathHandler(self, event): ! print self, "is now getting nuked. performing some save here...." def createWidgets(self): ! # a hello button ! self.hi_there = Button(self, text='Hello') ! self.hi_there.pack(side=LEFT) def __init__(self, master=None): ! Frame.__init__(self, master) ! Pack.config(self) ! self.createWidgets() ! ### ! ### PREVENT WM kills from happening ! ### ! # the docs would have you do this: ! # self.master.protocol("WM_DELETE_WINDOW", my_delete_callback) ! # unfortunately, some window managers will not send this request to a window. ! # the "protocol" function seems incapable of trapping these "aggressive" window kills. ! # this line of code catches everything, tho. The window is deleted, but you have a chance ! # of cleaning up first. ! self.bind_all("", self.deathHandler) --- 12,40 ---- class Test(Frame): def deathHandler(self, event): ! print self, "is now getting nuked. performing some save here...." def createWidgets(self): ! # a hello button ! self.hi_there = Button(self, text='Hello') ! self.hi_there.pack(side=LEFT) def __init__(self, master=None): ! Frame.__init__(self, master) ! Pack.config(self) ! self.createWidgets() ! ### ! ### PREVENT WM kills from happening ! ### ! # the docs would have you do this: ! # self.master.protocol("WM_DELETE_WINDOW", my_delete_callback) ! # unfortunately, some window managers will not send this request to a window. ! # the "protocol" function seems incapable of trapping these "aggressive" window kills. ! # this line of code catches everything, tho. The window is deleted, but you have a chance ! # of cleaning up first. ! self.bind_all("", self.deathHandler) Index: menu-all-types-of-entries.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/matt/menu-all-types-of-entries.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** menu-all-types-of-entries.py 30 Jul 1996 18:56:52 -0000 1.2 --- menu-all-types-of-entries.py 18 Jul 2004 06:09:09 -0000 1.3 *************** *** 1,15 **** from Tkinter import * ! # some vocabulary to keep from getting confused. This terminology ! # is something I cooked up for this file, but follows the man pages # pretty closely ! # ! # ! # # This is a MENUBUTTON # V # +-------------+ # | | ! # # +------------++------------++------------+ # | || || | --- 1,15 ---- from Tkinter import * ! # some vocabulary to keep from getting confused. This terminology ! # is something I cooked up for this file, but follows the man pages # pretty closely ! # ! # ! # # This is a MENUBUTTON # V # +-------------+ # | | ! # # +------------++------------++------------+ # | || || | *************** *** 23,27 **** # | | MENU ENTRIES # | +---------------+ ! # | Open Files > | file1 | # | | file2 | # | | another file | <------ this cascading part is also a MENU --- 23,27 ---- # | | MENU ENTRIES # | +---------------+ ! # | Open Files > | file1 | # | | file2 | # | | another file | <------ this cascading part is also a MENU *************** *** 54,62 **** def makeCommandMenu(): ! # make menu button ! Command_button = Menubutton(mBar, text='Simple Button Commands', ! underline=0) Command_button.pack(side=LEFT, padx="2m") ! # make the pulldown part of the File menu. The parameter passed is the master. # we attach it to the button as a python attribute called "menu" by convention. --- 54,62 ---- def makeCommandMenu(): ! # make menu button ! Command_button = Menubutton(mBar, text='Simple Button Commands', ! underline=0) Command_button.pack(side=LEFT, padx="2m") ! # make the pulldown part of the File menu. The parameter passed is the master. # we attach it to the button as a python attribute called "menu" by convention. *************** *** 69,94 **** Command_button.menu.entryconfig(0, state=DISABLED) ! Command_button.menu.add_command(label='New...', underline=0, ! command=new_file) ! Command_button.menu.add_command(label='Open...', underline=0, ! command=open_file) Command_button.menu.add_command(label='Different Font', underline=0, ! font='-*-helvetica-*-r-*-*-*-180-*-*-*-*-*-*', ! command=print_something) ! # we can make bitmaps be menu entries too. File format is X11 bitmap. # if you use XV, save it under X11 bitmap format. duh-uh.,.. Command_button.menu.add_command( ! bitmap="info") ! #bitmap='@/home/mjc4y/dilbert/project.status.is.doomed.last.panel.bm') ! # this is just a line Command_button.menu.add('separator') # change the color ! Command_button.menu.add_command(label='Quit', underline=0, ! background='red', ! activebackground='green', ! command=Command_button.quit) # set up a pointer from the file menubutton back to the file menu --- 69,94 ---- Command_button.menu.entryconfig(0, state=DISABLED) ! Command_button.menu.add_command(label='New...', underline=0, ! command=new_file) ! Command_button.menu.add_command(label='Open...', underline=0, ! command=open_file) Command_button.menu.add_command(label='Different Font', underline=0, ! font='-*-helvetica-*-r-*-*-*-180-*-*-*-*-*-*', ! command=print_something) ! # we can make bitmaps be menu entries too. File format is X11 bitmap. # if you use XV, save it under X11 bitmap format. duh-uh.,.. Command_button.menu.add_command( ! bitmap="info") ! #bitmap='@/home/mjc4y/dilbert/project.status.is.doomed.last.panel.bm') ! # this is just a line Command_button.menu.add('separator') # change the color ! Command_button.menu.add_command(label='Quit', underline=0, ! background='red', ! activebackground='green', ! command=Command_button.quit) # set up a pointer from the file menubutton back to the file menu *************** *** 100,107 **** def makeCascadeMenu(): ! # make menu button Cascade_button = Menubutton(mBar, text='Cascading Menus', underline=0) Cascade_button.pack(side=LEFT, padx="2m") ! # the primary pulldown Cascade_button.menu = Menu(Cascade_button) --- 100,107 ---- def makeCascadeMenu(): ! # make menu button Cascade_button = Menubutton(mBar, text='Cascading Menus', underline=0) Cascade_button.pack(side=LEFT, padx="2m") ! # the primary pulldown Cascade_button.menu = Menu(Cascade_button) *************** *** 126,135 **** Cascade_button.menu.choices.add_command(label='BubbleGum') Cascade_button.menu.choices.add_cascade( ! label='Wierd Flavors', ! menu=Cascade_button.menu.choices.wierdones) # and finally, the definition for the top level ! Cascade_button.menu.add_cascade(label='more choices', ! menu=Cascade_button.menu.choices) Cascade_button['menu'] = Cascade_button.menu --- 126,135 ---- Cascade_button.menu.choices.add_command(label='BubbleGum') Cascade_button.menu.choices.add_cascade( ! label='Wierd Flavors', ! menu=Cascade_button.menu.choices.wierdones) # and finally, the definition for the top level ! Cascade_button.menu.add_cascade(label='more choices', ! menu=Cascade_button.menu.choices) Cascade_button['menu'] = Cascade_button.menu *************** *** 139,152 **** def makeCheckbuttonMenu(): global fred ! # make menu button ! Checkbutton_button = Menubutton(mBar, text='Checkbutton Menus', ! underline=0) Checkbutton_button.pack(side=LEFT, padx='2m') ! # the primary pulldown Checkbutton_button.menu = Menu(Checkbutton_button) # and all the check buttons. Note that the "variable" "onvalue" and "offvalue" options ! # are not supported correctly at present. You have to do all your application # work through the calback. Checkbutton_button.menu.add_checkbutton(label='Pepperoni') --- 139,152 ---- def makeCheckbuttonMenu(): global fred ! # make menu button ! Checkbutton_button = Menubutton(mBar, text='Checkbutton Menus', ! underline=0) Checkbutton_button.pack(side=LEFT, padx='2m') ! # the primary pulldown Checkbutton_button.menu = Menu(Checkbutton_button) # and all the check buttons. Note that the "variable" "onvalue" and "offvalue" options ! # are not supported correctly at present. You have to do all your application # work through the calback. Checkbutton_button.menu.add_checkbutton(label='Pepperoni') *************** *** 155,169 **** # so here's a callback ! Checkbutton_button.menu.add_checkbutton(label='Anchovy', ! command=print_anchovies) ! # and start with anchovies selected to be on. Do this by # calling invoke on this menu option. To refer to the "anchovy" menu # entry we need to know it's index. To do this, we use the index method ! # which takes arguments of several forms: # # argument what it does # ----------------------------------- ! # a number -- this is useless. # "last" -- last option in the menu # "none" -- used with the activate command. see the man page on menus --- 155,169 ---- # so here's a callback ! Checkbutton_button.menu.add_checkbutton(label='Anchovy', ! command=print_anchovies) ! # and start with anchovies selected to be on. Do this by # calling invoke on this menu option. To refer to the "anchovy" menu # entry we need to know it's index. To do this, we use the index method ! # which takes arguments of several forms: # # argument what it does # ----------------------------------- ! # a number -- this is useless. # "last" -- last option in the menu # "none" -- used with the activate command. see the man page on menus *************** *** 171,175 **** # with the 'activate' method # "@number" -- where 'number' is an integer and is treated like a y coordinate in pixels ! # string pattern -- this is the option used below, and attempts to match "labels" using the # rules of Tcl_StringMatch Checkbutton_button.menu.invoke(Checkbutton_button.menu.index('Anchovy')) --- 171,175 ---- # with the 'activate' method # "@number" -- where 'number' is an integer and is treated like a y coordinate in pixels ! # string pattern -- this is the option used below, and attempts to match "labels" using the # rules of Tcl_StringMatch Checkbutton_button.menu.invoke(Checkbutton_button.menu.index('Anchovy')) *************** *** 182,195 **** def makeRadiobuttonMenu(): ! # make menu button ! Radiobutton_button = Menubutton(mBar, text='Radiobutton Menus', ! underline=0) Radiobutton_button.pack(side=LEFT, padx='2m') ! # the primary pulldown Radiobutton_button.menu = Menu(Radiobutton_button) # and all the Radio buttons. Note that the "variable" "onvalue" and "offvalue" options ! # are not supported correctly at present. You have to do all your application # work through the calback. Radiobutton_button.menu.add_radiobutton(label='Republican') --- 182,195 ---- def makeRadiobuttonMenu(): ! # make menu button ! Radiobutton_button = Menubutton(mBar, text='Radiobutton Menus', ! underline=0) Radiobutton_button.pack(side=LEFT, padx='2m') ! # the primary pulldown Radiobutton_button.menu = Menu(Radiobutton_button) # and all the Radio buttons. Note that the "variable" "onvalue" and "offvalue" options ! # are not supported correctly at present. You have to do all your application # work through the calback. Radiobutton_button.menu.add_radiobutton(label='Republican') *************** *** 210,214 **** ! def makeDisabledMenu(): Dummy_button = Menubutton(mBar, text='Dead Menu', underline=0) Dummy_button.pack(side=LEFT, padx='2m') --- 210,214 ---- ! def makeDisabledMenu(): Dummy_button = Menubutton(mBar, text='Dead Menu', underline=0) Dummy_button.pack(side=LEFT, padx='2m') *************** *** 234,238 **** NoMenu = makeDisabledMenu() ! # finally, install the buttons in the menu bar. # This allows for scanning from one menubutton to the next. mBar.tk_menuBar(Command_button, Cascade_button, Checkbutton_button, Radiobutton_button, NoMenu) --- 234,238 ---- NoMenu = makeDisabledMenu() ! # finally, install the buttons in the menu bar. # This allows for scanning from one menubutton to the next. mBar.tk_menuBar(Command_button, Cascade_button, Checkbutton_button, Radiobutton_button, NoMenu) *************** *** 243,250 **** root.mainloop() - - - - - - --- 243,244 ---- Index: menu-simple.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/matt/menu-simple.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** menu-simple.py 21 Aug 1996 20:13:08 -0000 1.4 --- menu-simple.py 18 Jul 2004 06:09:09 -0000 1.5 *************** *** 1,15 **** from Tkinter import * ! # some vocabulary to keep from getting confused. This terminology ! # is something I cooked up for this file, but follows the man pages # pretty closely ! # ! # ! # # This is a MENUBUTTON # V # +-------------+ # | | ! # # +------------++------------++------------+ # | || || | --- 1,15 ---- from Tkinter import * ! # some vocabulary to keep from getting confused. This terminology ! # is something I cooked up for this file, but follows the man pages # pretty closely ! # ! # ! # # This is a MENUBUTTON # V # +-------------+ # | | ! # # +------------++------------++------------+ # | || || | *************** *** 23,27 **** # | | MENU ENTRIES # | +---------------+ ! # | Open Files > | file1 | # | | file2 | # | | another file | <------ this cascading part is also a MENU --- 23,27 ---- # | | MENU ENTRIES # | +---------------+ ! # | Open Files > | file1 | # | | file2 | # | | another file | <------ this cascading part is also a MENU *************** *** 47,63 **** File_button.pack(side=LEFT, padx="1m") File_button.menu = Menu(File_button) ! ! # add an item. The first param is a menu entry type, # must be one of: "cascade", "checkbutton", "command", "radiobutton", "seperator" # see menu-demo-2.py for examples of use ! File_button.menu.add_command(label='New...', underline=0, ! command=new_file) ! ! ! File_button.menu.add_command(label='Open...', underline=0, ! command=open_file) ! ! File_button.menu.add_command(label='Quit', underline=0, ! command='exit') # set up a pointer from the file menubutton back to the file menu --- 47,63 ---- File_button.pack(side=LEFT, padx="1m") File_button.menu = Menu(File_button) ! ! # add an item. The first param is a menu entry type, # must be one of: "cascade", "checkbutton", "command", "radiobutton", "seperator" # see menu-demo-2.py for examples of use ! File_button.menu.add_command(label='New...', underline=0, ! command=new_file) ! ! ! File_button.menu.add_command(label='Open...', underline=0, ! command=open_file) ! ! File_button.menu.add_command(label='Quit', underline=0, ! command='exit') # set up a pointer from the file menubutton back to the file menu *************** *** 103,107 **** Edit_button = makeEditMenu() ! # finally, install the buttons in the menu bar. # This allows for scanning from one menubutton to the next. mBar.tk_menuBar(File_button, Edit_button) --- 103,107 ---- Edit_button = makeEditMenu() ! # finally, install the buttons in the menu bar. # This allows for scanning from one menubutton to the next. mBar.tk_menuBar(File_button, Edit_button) *************** *** 111,118 **** root.mainloop() - - - - - - --- 111,112 ---- Index: not-what-you-might-think-1.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/matt/not-what-you-might-think-1.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** not-what-you-might-think-1.py 30 Jul 1996 18:56:55 -0000 1.2 --- not-what-you-might-think-1.py 18 Jul 2004 06:09:09 -0000 1.3 *************** *** 5,23 **** def createWidgets(self): ! self.Gpanel = Frame(self, width='1i', height='1i', ! background='green') ! self.Gpanel.pack(side=LEFT) ! # a QUIT button ! self.Gpanel.QUIT = Button(self.Gpanel, text='QUIT', ! foreground='red', ! command=self.quit) ! self.Gpanel.QUIT.pack(side=LEFT) def __init__(self, master=None): ! Frame.__init__(self, master) ! Pack.config(self) ! self.createWidgets() test = Test() --- 5,23 ---- def createWidgets(self): ! self.Gpanel = Frame(self, width='1i', height='1i', ! background='green') ! self.Gpanel.pack(side=LEFT) ! # a QUIT button ! self.Gpanel.QUIT = Button(self.Gpanel, text='QUIT', ! foreground='red', ! command=self.quit) ! self.Gpanel.QUIT.pack(side=LEFT) def __init__(self, master=None): ! Frame.__init__(self, master) ! Pack.config(self) ! self.createWidgets() test = Test() Index: not-what-you-might-think-2.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/matt/not-what-you-might-think-2.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** not-what-you-might-think-2.py 30 Jul 1996 18:56:57 -0000 1.2 --- not-what-you-might-think-2.py 18 Jul 2004 06:09:09 -0000 1.3 *************** *** 5,25 **** def createWidgets(self): ! self.Gpanel = Frame(self, width='1i', height='1i', ! background='green') ! # this line turns off the recalculation of geometry by masters. ! self.Gpanel.propagate(0) ! self.Gpanel.pack(side=LEFT) ! # a QUIT button ! self.Gpanel.QUIT = Button(self.Gpanel, text='QUIT', foreground='red', ! command=self.quit) ! self.Gpanel.QUIT.pack(side=LEFT) def __init__(self, master=None): ! Frame.__init__(self, master) ! Pack.config(self) ! self.createWidgets() test = Test() --- 5,25 ---- def createWidgets(self): ! self.Gpanel = Frame(self, width='1i', height='1i', ! background='green') ! # this line turns off the recalculation of geometry by masters. ! self.Gpanel.propagate(0) ! self.Gpanel.pack(side=LEFT) ! # a QUIT button ! self.Gpanel.QUIT = Button(self.Gpanel, text='QUIT', foreground='red', ! command=self.quit) ! self.Gpanel.QUIT.pack(side=LEFT) def __init__(self, master=None): ! Frame.__init__(self, master) ! Pack.config(self) ! self.createWidgets() test = Test() Index: packer-and-placer-together.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/matt/packer-and-placer-together.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** packer-and-placer-together.py 30 Jul 1996 18:56:58 -0000 1.2 --- packer-and-placer-together.py 18 Jul 2004 06:09:09 -0000 1.3 *************** *** 1,5 **** from Tkinter import * ! # This is a program that tests the placer geom manager in conjunction with # the packer. The background (green) is packed, while the widget inside is placed --- 1,5 ---- from Tkinter import * ! # This is a program that tests the placer geom manager in conjunction with # the packer. The background (green) is packed, while the widget inside is placed *************** *** 18,24 **** f = Frame(top, width=200, height=200, background='green') ! # note that we use a different manager here. ! # This way, the top level frame widget resizes when the ! # application window does. f.pack(fill=BOTH, expand=1) --- 18,24 ---- f = Frame(top, width=200, height=200, background='green') ! # note that we use a different manager here. ! # This way, the top level frame widget resizes when the ! # application window does. f.pack(fill=BOTH, expand=1) *************** *** 26,30 **** f.button = Button(f, foreground='red', text='amazing', command=dothis) ! # and place it so that the nw corner is # 1/2 way along the top X edge of its' parent f.button.place(relx=0.5, rely=0.0, anchor=NW) --- 26,30 ---- f.button = Button(f, foreground='red', text='amazing', command=dothis) ! # and place it so that the nw corner is # 1/2 way along the top X edge of its' parent f.button.place(relx=0.5, rely=0.0, anchor=NW) *************** *** 40,42 **** root.maxsize(1000, 1000) root.mainloop() - --- 40,41 ---- Index: packer-simple.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/matt/packer-simple.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** packer-simple.py 30 Jul 1996 18:56:59 -0000 1.2 --- packer-simple.py 18 Jul 2004 06:09:09 -0000 1.3 *************** *** 4,31 **** class Test(Frame): def printit(self): ! print self.hi_there["command"] def createWidgets(self): ! # a hello button ! self.QUIT = Button(self, text='QUIT', foreground='red', ! command=self.quit) ! self.QUIT.pack(side=LEFT, fill=BOTH) ! self.hi_there = Button(self, text='Hello', ! command=self.printit) ! self.hi_there.pack(side=LEFT) ! # note how Packer defaults to side=TOP ! self.guy2 = Button(self, text='button 2') ! self.guy2.pack() ! self.guy3 = Button(self, text='button 3') ! self.guy3.pack() def __init__(self, master=None): ! Frame.__init__(self, master) ! Pack.config(self) ! self.createWidgets() test = Test() --- 4,31 ---- class Test(Frame): def printit(self): ! print self.hi_there["command"] def createWidgets(self): ! # a hello button ! self.QUIT = Button(self, text='QUIT', foreground='red', ! command=self.quit) ! self.QUIT.pack(side=LEFT, fill=BOTH) ! self.hi_there = Button(self, text='Hello', ! command=self.printit) ! self.hi_there.pack(side=LEFT) ! # note how Packer defaults to side=TOP ! self.guy2 = Button(self, text='button 2') ! self.guy2.pack() ! self.guy3 = Button(self, text='button 3') ! self.guy3.pack() def __init__(self, master=None): ! Frame.__init__(self, master) ! Pack.config(self) ! self.createWidgets() test = Test() Index: placer-simple.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/matt/placer-simple.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** placer-simple.py 30 Jul 1996 18:57:01 -0000 1.2 --- placer-simple.py 18 Jul 2004 06:09:09 -0000 1.3 *************** *** 16,20 **** f = Frame(top, width=200, height=200, background='green') ! # place it so the upper left hand corner of # the frame is in the upper left corner of # the parent --- 16,20 ---- f = Frame(top, width=200, height=200, background='green') ! # place it so the upper left hand corner of # the frame is in the upper left corner of # the parent *************** *** 24,28 **** f.button = Button(f, foreground='red', text='amazing', command=dothis) ! # and place it so that the nw corner is # 1/2 way along the top X edge of its' parent f.button.place(relx=0.5, rely=0.0, anchor=NW) --- 24,28 ---- f.button = Button(f, foreground='red', text='amazing', command=dothis) ! # and place it so that the nw corner is # 1/2 way along the top X edge of its' parent f.button.place(relx=0.5, rely=0.0, anchor=NW) *************** *** 38,40 **** root.maxsize(1000, 1000) root.mainloop() - --- 38,39 ---- Index: pong-demo-1.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/matt/pong-demo-1.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** pong-demo-1.py 12 Feb 2004 17:35:04 -0000 1.3 --- pong-demo-1.py 18 Jul 2004 06:09:09 -0000 1.4 *************** *** 6,51 **** class Pong(Frame): def createWidgets(self): ! self.QUIT = Button(self, text='QUIT', foreground='red', ! command=self.quit) ! self.QUIT.pack(side=LEFT, fill=BOTH) ! ## The playing field ! self.draw = Canvas(self, width="5i", height="5i") ! ## The speed control for the ball ! self.speed = Scale(self, orient=HORIZONTAL, label="ball speed", ! from_=-100, to=100) ! self.speed.pack(side=BOTTOM, fill=X) ! # The ball ! self.ball = self.draw.create_oval("0i", "0i", "0.10i", "0.10i", ! fill="red") ! self.x = 0.05 ! self.y = 0.05 ! self.velocity_x = 0.3 ! self.velocity_y = 0.5 ! self.draw.pack(side=LEFT) def moveBall(self, *args): ! if (self.x > 5.0) or (self.x < 0.0): ! self.velocity_x = -1.0 * self.velocity_x ! if (self.y > 5.0) or (self.y < 0.0): ! self.velocity_y = -1.0 * self.velocity_y ! deltax = (self.velocity_x * self.speed.get() / 100.0) ! deltay = (self.velocity_y * self.speed.get() / 100.0) ! self.x = self.x + deltax ! self.y = self.y + deltay ! self.draw.move(self.ball, "%ri" % deltax, "%ri" % deltay) ! self.after(10, self.moveBall) def __init__(self, master=None): ! Frame.__init__(self, master) ! Pack.config(self) ! self.createWidgets() ! self.after(10, self.moveBall) --- 6,51 ---- class Pong(Frame): def createWidgets(self): ! self.QUIT = Button(self, text='QUIT', foreground='red', ! command=self.quit) ! self.QUIT.pack(side=LEFT, fill=BOTH) ! ## The playing field ! self.draw = Canvas(self, width="5i", height="5i") ! ## The speed control for the ball ! self.speed = Scale(self, orient=HORIZONTAL, label="ball speed", ! from_=-100, to=100) ! self.speed.pack(side=BOTTOM, fill=X) ! # The ball ! self.ball = self.draw.create_oval("0i", "0i", "0.10i", "0.10i", ! fill="red") ! self.x = 0.05 ! self.y = 0.05 ! self.velocity_x = 0.3 ! self.velocity_y = 0.5 ! self.draw.pack(side=LEFT) def moveBall(self, *args): ! if (self.x > 5.0) or (self.x < 0.0): ! self.velocity_x = -1.0 * self.velocity_x ! if (self.y > 5.0) or (self.y < 0.0): ! self.velocity_y = -1.0 * self.velocity_y ! deltax = (self.velocity_x * self.speed.get() / 100.0) ! deltay = (self.velocity_y * self.speed.get() / 100.0) ! self.x = self.x + deltax ! self.y = self.y + deltay ! self.draw.move(self.ball, "%ri" % deltax, "%ri" % deltay) ! self.after(10, self.moveBall) def __init__(self, master=None): ! Frame.__init__(self, master) ! Pack.config(self) ! self.createWidgets() ! self.after(10, self.moveBall) Index: printing-coords-of-items.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/matt/printing-coords-of-items.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** printing-coords-of-items.py 30 Jul 1996 18:57:04 -0000 1.2 --- printing-coords-of-items.py 18 Jul 2004 06:09:09 -0000 1.3 *************** *** 8,31 **** ################################################################### def mouseDown(self, event): ! # see if we're inside a dot. If we are, it ! # gets tagged as CURRENT for free by tk. ! if not event.widget.find_withtag(CURRENT): ! # there is no dot here, so we can make one, ! # and bind some interesting behavior to it. ! # ------ ! # create a dot, and mark it as current ! fred = self.draw.create_oval( ! event.x - 10, event.y -10, event.x +10, event.y + 10, ! fill="green") ! self.draw.tag_bind(fred, "", self.mouseEnter) ! self.draw.tag_bind(fred, "", self.mouseLeave) ! self.lastx = event.x ! self.lasty = event.y def mouseMove(self, event): ! self.draw.move(CURRENT, event.x - self.lastx, event.y - self.lasty) ! self.lastx = event.x ! self.lasty = event.y ################################################################### --- 8,31 ---- ################################################################### def mouseDown(self, event): ! # see if we're inside a dot. If we are, it ! # gets tagged as CURRENT for free by tk. ! if not event.widget.find_withtag(CURRENT): ! # there is no dot here, so we can make one, ! # and bind some interesting behavior to it. ! # ------ ! # create a dot, and mark it as current ! fred = self.draw.create_oval( ! event.x - 10, event.y -10, event.x +10, event.y + 10, ! fill="green") ! self.draw.tag_bind(fred, "", self.mouseEnter) ! self.draw.tag_bind(fred, "", self.mouseLeave) ! self.lastx = event.x ! self.lasty = event.y def mouseMove(self, event): ! self.draw.move(CURRENT, event.x - self.lastx, event.y - self.lasty) ! self.lastx = event.x ! self.lasty = event.y ################################################################### *************** *** 34,64 **** def mouseEnter(self, event): # the "current" tag is applied to the object the cursor is over. ! # this happens automatically. ! self.draw.itemconfig(CURRENT, fill="red") ! print self.draw.coords(CURRENT) ! def mouseLeave(self, event): ! # the "current" tag is applied to the object the cursor is over. ! # this happens automatically. ! self.draw.itemconfig(CURRENT, fill="blue") def createWidgets(self): ! self.QUIT = Button(self, text='QUIT', foreground='red', ! command=self.quit) ! self.QUIT.pack(side=LEFT, fill=BOTH) ! self.draw = Canvas(self, width="5i", height="5i") ! self.draw.pack(side=LEFT) ! Widget.bind(self.draw, "<1>", self.mouseDown) ! Widget.bind(self.draw, "", self.mouseMove) def __init__(self, master=None): ! Frame.__init__(self, master) ! Pack.config(self) ! self.createWidgets() test = Test() test.mainloop() - - - --- 34,61 ---- def mouseEnter(self, event): # the "current" tag is applied to the object the cursor is over. ! # this happens automatically. ! self.draw.itemconfig(CURRENT, fill="red") ! print self.draw.coords(CURRENT) ! def mouseLeave(self, event): ! # the "current" tag is applied to the object the cursor is over. ! # this happens automatically. ! self.draw.itemconfig(CURRENT, fill="blue") def createWidgets(self): ! self.QUIT = Button(self, text='QUIT', foreground='red', ! command=self.quit) ! self.QUIT.pack(side=LEFT, fill=BOTH) ! self.draw = Canvas(self, width="5i", height="5i") ! self.draw.pack(side=LEFT) ! Widget.bind(self.draw, "<1>", self.mouseDown) ! Widget.bind(self.draw, "", self.mouseMove) def __init__(self, master=None): ! Frame.__init__(self, master) ! Pack.config(self) ! self.createWidgets() test = Test() test.mainloop() Index: radiobutton-simple.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/matt/radiobutton-simple.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** radiobutton-simple.py 30 Jul 1996 18:57:06 -0000 1.2 --- radiobutton-simple.py 18 Jul 2004 06:09:09 -0000 1.3 *************** *** 1,9 **** from Tkinter import * ! # This is a demo program that shows how to ! # create radio buttons and how to get other widgets to ! # share the information in a radio button. ! # ! # There are other ways of doing this too, but # the "variable" option of radiobuttons seems to be the easiest. # --- 1,9 ---- from Tkinter import * ! # This is a demo program that shows how to ! # create radio buttons and how to get other widgets to ! # share the information in a radio button. ! # ! # There are other ways of doing this too, but # the "variable" option of radiobuttons seems to be the easiest. # *************** *** 13,60 **** class Test(Frame): def printit(self): ! print "hi" def createWidgets(self): ! self.flavor = StringVar() ! self.flavor.set("chocolate") ! self.radioframe = Frame(self) ! self.radioframe.pack() ! # 'text' is the label ! # 'variable' is the name of the variable that all these radio buttons share ! # 'value' is the value this variable takes on when the radio button is selected ! # 'anchor' makes the text appear left justified (default is centered. ick) ! self.radioframe.choc = Radiobutton( ! self.radioframe, text="Chocolate Flavor", ! variable=self.flavor, value="chocolate", ! anchor=W) ! self.radioframe.choc.pack(fill=X) ! self.radioframe.straw = Radiobutton( ! self.radioframe, text="Strawberry Flavor", ! variable=self.flavor, value="strawberry", ! anchor=W) ! self.radioframe.straw.pack(fill=X) ! self.radioframe.lemon = Radiobutton( ! self.radioframe, text="Lemon Flavor", ! variable=self.flavor, value="lemon", ! anchor=W) ! self.radioframe.lemon.pack(fill=X) ! ! # this is a text entry that lets you type in the name of a flavor too. ! self.entry = Entry(self, textvariable=self.flavor) ! self.entry.pack(fill=X) ! self.QUIT = Button(self, text='QUIT', foreground='red', ! command=self.quit) ! self.QUIT.pack(side=BOTTOM, fill=BOTH) def __init__(self, master=None): ! Frame.__init__(self, master) ! Pack.config(self) ! self.createWidgets() test = Test() --- 13,60 ---- class Test(Frame): def printit(self): ! print "hi" def createWidgets(self): ! self.flavor = StringVar() ! self.flavor.set("chocolate") ! self.radioframe = Frame(self) ! self.radioframe.pack() ! # 'text' is the label ! # 'variable' is the name of the variable that all these radio buttons share ! # 'value' is the value this variable takes on when the radio button is selected ! # 'anchor' makes the text appear left justified (default is centered. ick) ! self.radioframe.choc = Radiobutton( ! self.radioframe, text="Chocolate Flavor", ! variable=self.flavor, value="chocolate", ! anchor=W) ! self.radioframe.choc.pack(fill=X) ! self.radioframe.straw = Radiobutton( ! self.radioframe, text="Strawberry Flavor", ! variable=self.flavor, value="strawberry", ! anchor=W) ! self.radioframe.straw.pack(fill=X) ! self.radioframe.lemon = Radiobutton( ! self.radioframe, text="Lemon Flavor", ! variable=self.flavor, value="lemon", ! anchor=W) ! self.radioframe.lemon.pack(fill=X) ! ! # this is a text entry that lets you type in the name of a flavor too. ! self.entry = Entry(self, textvariable=self.flavor) ! self.entry.pack(fill=X) ! self.QUIT = Button(self, text='QUIT', foreground='red', ! command=self.quit) ! self.QUIT.pack(side=BOTTOM, fill=BOTH) def __init__(self, master=None): ! Frame.__init__(self, master) ! Pack.config(self) ! self.createWidgets() test = Test() Index: rubber-band-box-demo-1.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/matt/rubber-band-box-demo-1.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** rubber-band-box-demo-1.py 30 Jul 1996 18:57:07 -0000 1.2 --- rubber-band-box-demo-1.py 18 Jul 2004 06:09:09 -0000 1.3 *************** *** 3,55 **** class Test(Frame): def printit(self): ! print "hi" def createWidgets(self): ! self.QUIT = Button(self, text='QUIT', ! background='red', ! foreground='white', ! height=3, ! command=self.quit) ! self.QUIT.pack(side=BOTTOM, fill=BOTH) ! self.canvasObject = Canvas(self, width="5i", height="5i") ! self.canvasObject.pack(side=LEFT) def mouseDown(self, event): ! # canvas x and y take the screen coords from the event and translate ! # them into the coordinate system of the canvas object ! self.startx = self.canvasObject.canvasx(event.x) ! self.starty = self.canvasObject.canvasy(event.y) def mouseMotion(self, event): ! # canvas x and y take the screen coords from the event and translate ! # them into the coordinate system of the canvas object ! x = self.canvasObject.canvasx(event.x) ! y = self.canvasObject.canvasy(event.y) ! if (self.startx != event.x) and (self.starty != event.y) : ! self.canvasObject.delete(self.rubberbandBox) ! self.rubberbandBox = self.canvasObject.create_rectangle( ! self.startx, self.starty, x, y) ! # this flushes the output, making sure that ! # the rectangle makes it to the screen ! # before the next event is handled ! self.update_idletasks() def mouseUp(self, event): ! self.canvasObject.delete(self.rubberbandBox) ! def __init__(self, master=None): ! Frame.__init__(self, master) ! Pack.config(self) ! self.createWidgets() ! # this is a "tagOrId" for the rectangle we draw on the canvas ! self.rubberbandBox = None ! ! # and the bindings that make it work.. ! Widget.bind(self.canvasObject, "", self.mouseDown) ! Widget.bind(self.canvasObject, "", self.mouseMotion) ! Widget.bind(self.canvasObject, "", self.mouseUp) --- 3,55 ---- class Test(Frame): def printit(self): ! print "hi" def createWidgets(self): ! self.QUIT = Button(self, text='QUIT', ! background='red', ! foreground='white', ! height=3, ! command=self.quit) ! self.QUIT.pack(side=BOTTOM, fill=BOTH) ! self.canvasObject = Canvas(self, width="5i", height="5i") ! self.canvasObject.pack(side=LEFT) def mouseDown(self, event): ! # canvas x and y take the screen coords from the event and translate ! # them into the coordinate system of the canvas object ! self.startx = self.canvasObject.canvasx(event.x) ! self.starty = self.canvasObject.canvasy(event.y) def mouseMotion(self, event): ! # canvas x and y take the screen coords from the event and translate ! # them into the coordinate system of the canvas object ! x = self.canvasObject.canvasx(event.x) ! y = self.canvasObject.canvasy(event.y) ! if (self.startx != event.x) and (self.starty != event.y) : ! self.canvasObject.delete(self.rubberbandBox) ! self.rubberbandBox = self.canvasObject.create_rectangle( ! self.startx, self.starty, x, y) ! # this flushes the output, making sure that ! # the rectangle makes it to the screen ! # before the next event is handled ! self.update_idletasks() def mouseUp(self, event): ! self.canvasObject.delete(self.rubberbandBox) ! def __init__(self, master=None): ! Frame.__init__(self, master) ! Pack.config(self) ! self.createWidgets() ! # this is a "tagOrId" for the rectangle we draw on the canvas ! self.rubberbandBox = None ! ! # and the bindings that make it work.. ! Widget.bind(self.canvasObject, "", self.mouseDown) ! Widget.bind(self.canvasObject, "", self.mouseMotion) ! Widget.bind(self.canvasObject, "", self.mouseUp) Index: rubber-line-demo-1.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/matt/rubber-line-demo-1.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** rubber-line-demo-1.py 30 Jul 1996 18:57:09 -0000 1.2 --- rubber-line-demo-1.py 18 Jul 2004 06:09:09 -0000 1.3 *************** *** 3,49 **** class Test(Frame): def printit(self): ! print "hi" def createWidgets(self): ! self.QUIT = Button(self, text='QUIT', ! background='red', ! foreground='white', ! height=3, ! command=self.quit) ! self.QUIT.pack(side=BOTTOM, fill=BOTH) ! self.canvasObject = Canvas(self, width="5i", height="5i") ! self.canvasObject.pack(side=LEFT) def mouseDown(self, event): ! # canvas x and y take the screen coords from the event and translate ! # them into the coordinate system of the canvas object ! self.startx = self.canvasObject.canvasx(event.x) ! self.starty = self.canvasObject.canvasy(event.y) def mouseMotion(self, event): ! # canvas x and y take the screen coords from the event and translate ! # them into the coordinate system of the canvas object ! x = self.canvasObject.canvasx(event.x) ! y = self.canvasObject.canvasy(event.y) ! if (self.startx != event.x) and (self.starty != event.y) : ! self.canvasObject.delete(self.rubberbandLine) ! self.rubberbandLine = self.canvasObject.create_line( ! self.startx, self.starty, x, y) ! # this flushes the output, making sure that ! # the rectangle makes it to the screen ! # before the next event is handled ! self.update_idletasks() def __init__(self, master=None): ! Frame.__init__(self, master) ! Pack.config(self) ! self.createWidgets() ! # this is a "tagOrId" for the rectangle we draw on the canvas ! self.rubberbandLine = None ! Widget.bind(self.canvasObject, "", self.mouseDown) ! Widget.bind(self.canvasObject, "", self.mouseMotion) ! test = Test() --- 3,49 ---- class Test(Frame): def printit(self): ! print "hi" def createWidgets(self): ! self.QUIT = Button(self, text='QUIT', ! background='red', ! foreground='white', ! height=3, ! command=self.quit) ! self.QUIT.pack(side=BOTTOM, fill=BOTH) ! self.canvasObject = Canvas(self, width="5i", height="5i") ! self.canvasObject.pack(side=LEFT) def mouseDown(self, event): ! # canvas x and y take the screen coords from the event and translate ! # them into the coordinate system of the canvas object ! self.startx = self.canvasObject.canvasx(event.x) ! self.starty = self.canvasObject.canvasy(event.y) def mouseMotion(self, event): ! # canvas x and y take the screen coords from the event and translate ! # them into the coordinate system of the canvas object ! x = self.canvasObject.canvasx(event.x) ! y = self.canvasObject.canvasy(event.y) ! if (self.startx != event.x) and (self.starty != event.y) : ! self.canvasObject.delete(self.rubberbandLine) ! self.rubberbandLine = self.canvasObject.create_line( ! self.startx, self.starty, x, y) ! # this flushes the output, making sure that ! # the rectangle makes it to the screen ! # before the next event is handled ! self.update_idletasks() def __init__(self, master=None): ! Frame.__init__(self, master) ! Pack.config(self) ! self.createWidgets() ! # this is a "tagOrId" for the rectangle we draw on the canvas ! self.rubberbandLine = None ! Widget.bind(self.canvasObject, "", self.mouseDown) ! Widget.bind(self.canvasObject, "", self.mouseMotion) ! test = Test() Index: slider-demo-1.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/matt/slider-demo-1.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** slider-demo-1.py 30 Jul 1996 18:57:10 -0000 1.2 --- slider-demo-1.py 18 Jul 2004 06:09:09 -0000 1.3 *************** *** 6,35 **** class Test(Frame): def print_value(self, val): ! print "slider now at", val ! def reset(self): ! self.slider.set(0) def createWidgets(self): ! self.slider = Scale(self, from_=0, to=100, ! orient=HORIZONTAL, ! length="3i", ! label="happy slider", ! command=self.print_value) ! self.reset = Button(self, text='reset slider', ! command=self.reset) ! self.QUIT = Button(self, text='QUIT', foreground='red', ! command=self.quit) ! self.slider.pack(side=LEFT) ! self.reset.pack(side=LEFT) ! self.QUIT.pack(side=LEFT, fill=BOTH) def __init__(self, master=None): ! Frame.__init__(self, master) ! Pack.config(self) ! self.createWidgets() test = Test() --- 6,35 ---- class Test(Frame): def print_value(self, val): ! print "slider now at", val ! def reset(self): ! self.slider.set(0) def createWidgets(self): ! self.slider = Scale(self, from_=0, to=100, ! orient=HORIZONTAL, ! length="3i", ! label="happy slider", ! command=self.print_value) ! self.reset = Button(self, text='reset slider', ! command=self.reset) ! self.QUIT = Button(self, text='QUIT', foreground='red', ! command=self.quit) ! self.slider.pack(side=LEFT) ! self.reset.pack(side=LEFT) ! self.QUIT.pack(side=LEFT, fill=BOTH) def __init__(self, master=None): ! Frame.__init__(self, master) ! Pack.config(self) ! self.createWidgets() test = Test() Index: subclass-existing-widgets.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/matt/subclass-existing-widgets.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** subclass-existing-widgets.py 30 Jul 1996 18:57:12 -0000 1.2 --- subclass-existing-widgets.py 18 Jul 2004 06:09:09 -0000 1.3 *************** *** 6,12 **** class New_Button(Button): def callback(self): ! print self.counter ! self.counter = self.counter + 1 ! def createWidgets(top): f = Frame(top) --- 6,12 ---- class New_Button(Button): def callback(self): ! print self.counter ! self.counter = self.counter + 1 ! def createWidgets(top): f = Frame(top) *************** *** 27,29 **** createWidgets(root) root.mainloop() - --- 27,28 ---- Index: two-radio-groups.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/matt/two-radio-groups.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** two-radio-groups.py 30 Jul 1996 18:57:13 -0000 1.2 --- two-radio-groups.py 18 Jul 2004 06:09:09 -0000 1.3 *************** *** 1,43 **** from Tkinter import * ! # The way to think about this is that each radio button menu ! # controls a different variable -- clicking on one of the ! # mutually exclusive choices in a radiobutton assigns some value ! # to an application variable you provide. When you define a ! # radiobutton menu choice, you have the option of specifying the ! # name of a varaible and value to assign to that variable when ! # that choice is selected. This clever mechanism relieves you, ! # the programmer, from having to write a dumb callback that ! # probably wouldn't have done anything more than an assignment ! # anyway. The Tkinter options for this follow their Tk ! # counterparts: ! # {"variable" : my_flavor_variable, "value" : "strawberry"} # where my_flavor_variable is an instance of one of the # subclasses of Variable, provided in Tkinter.py (there is ! # StringVar(), IntVar(), DoubleVar() and BooleanVar() to choose ! # from) def makePoliticalParties(var): ! # make menu button ! Radiobutton_button = Menubutton(mBar, text='Political Party', ! underline=0) Radiobutton_button.pack(side=LEFT, padx='2m') ! # the primary pulldown Radiobutton_button.menu = Menu(Radiobutton_button) ! Radiobutton_button.menu.add_radiobutton(label='Republican', ! variable=var, value=1) ! Radiobutton_button.menu.add('radiobutton', {'label': 'Democrat', ! 'variable' : var, ! 'value' : 2}) - Radiobutton_button.menu.add('radiobutton', {'label': 'Libertarian', - 'variable' : var, - 'value' : 3}) - var.set(2) --- 1,43 ---- from Tkinter import * ! # The way to think about this is that each radio button menu ! # controls a different variable -- clicking on one of the ! # mutually exclusive choices in a radiobutton assigns some value ! # to an application variable you provide. When you define a ! # radiobutton menu choice, you have the option of specifying the ! # name of a varaible and value to assign to that variable when ! # that choice is selected. This clever mechanism relieves you, ! # the programmer, from having to write a dumb callback that ! # probably wouldn't have done anything more than an assignment ! # anyway. The Tkinter options for this follow their Tk ! # counterparts: ! # {"variable" : my_flavor_variable, "value" : "strawberry"} # where my_flavor_variable is an instance of one of the # subclasses of Variable, provided in Tkinter.py (there is ! # StringVar(), IntVar(), DoubleVar() and BooleanVar() to choose ! # from) def makePoliticalParties(var): ! # make menu button ! Radiobutton_button = Menubutton(mBar, text='Political Party', ! underline=0) Radiobutton_button.pack(side=LEFT, padx='2m') ! # the primary pulldown Radiobutton_button.menu = Menu(Radiobutton_button) ! Radiobutton_button.menu.add_radiobutton(label='Republican', ! variable=var, value=1) ! Radiobutton_button.menu.add('radiobutton', {'label': 'Democrat', ! 'variable' : var, ! 'value' : 2}) ! ! Radiobutton_button.menu.add('radiobutton', {'label': 'Libertarian', ! 'variable' : var, ! 'value' : 3}) var.set(2) *************** *** 49,55 **** def makeFlavors(var): ! # make menu button ! Radiobutton_button = Menubutton(mBar, text='Flavors', ! underline=0) Radiobutton_button.pack(side=LEFT, padx='2m') --- 49,55 ---- def makeFlavors(var): ! # make menu button ! Radiobutton_button = Menubutton(mBar, text='Flavors', ! underline=0) Radiobutton_button.pack(side=LEFT, padx='2m') *************** *** 58,68 **** Radiobutton_button.menu.add_radiobutton(label='Strawberry', ! variable=var, value='Strawberry') Radiobutton_button.menu.add_radiobutton(label='Chocolate', ! variable=var, value='Chocolate') Radiobutton_button.menu.add_radiobutton(label='Rocky Road', ! variable=var, value='Rocky Road') # choose a default --- 58,68 ---- Radiobutton_button.menu.add_radiobutton(label='Strawberry', ! variable=var, value='Strawberry') Radiobutton_button.menu.add_radiobutton(label='Chocolate', ! variable=var, value='Chocolate') Radiobutton_button.menu.add_radiobutton(label='Rocky Road', ! variable=var, value='Rocky Road') # choose a default *************** *** 89,93 **** mBar.pack(fill=X) ! # make two application variables, # one to control each radio button set party = IntVar() --- 89,93 ---- mBar.pack(fill=X) ! # make two application variables, # one to control each radio button set party = IntVar() *************** *** 97,106 **** Radiobutton_button2 = makeFlavors(flavor) ! # finally, install the buttons in the menu bar. # This allows for scanning from one menubutton to the next. mBar.tk_menuBar(Radiobutton_button, Radiobutton_button2) b = Button(root, text="print party and flavor", foreground="red", ! command=printStuff) b.pack(side=TOP) --- 97,106 ---- Radiobutton_button2 = makeFlavors(flavor) ! # finally, install the buttons in the menu bar. # This allows for scanning from one menubutton to the next. mBar.tk_menuBar(Radiobutton_button, Radiobutton_button2) b = Button(root, text="print party and flavor", foreground="red", ! command=printStuff) b.pack(side=TOP) Index: window-creation-more.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/matt/window-creation-more.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** window-creation-more.py 30 Jul 1996 18:57:15 -0000 1.2 --- window-creation-more.py 18 Jul 2004 06:09:09 -0000 1.3 *************** *** 6,34 **** class Test(Frame): def printit(self): ! print "hi" def makeWindow(self): ! fred = Toplevel() ! fred.label = Button(fred, ! text="This is window number %d." % self.windownum, ! command=self.makeWindow) ! fred.label.pack() ! self.windownum = self.windownum + 1 def createWidgets(self): ! self.QUIT = Button(self, text='QUIT', foreground='red', ! command=self.quit) ! self.QUIT.pack(side=LEFT, fill=BOTH) ! # a hello button ! self.hi_there = Button(self, text='Make a New Window', ! command=self.makeWindow) ! self.hi_there.pack(side=LEFT) def __init__(self, master=None): ! Frame.__init__(self, master) ! Pack.config(self) ! self.windownum = 0 ! self.createWidgets() test = Test() --- 6,34 ---- class Test(Frame): def printit(self): ! print "hi" def makeWindow(self): ! fred = Toplevel() ! fred.label = Button(fred, ! text="This is window number %d." % self.windownum, ! command=self.makeWindow) ! fred.label.pack() ! self.windownum = self.windownum + 1 def createWidgets(self): ! self.QUIT = Button(self, text='QUIT', foreground='red', ! command=self.quit) ! self.QUIT.pack(side=LEFT, fill=BOTH) ! # a hello button ! self.hi_there = Button(self, text='Make a New Window', ! command=self.makeWindow) ! self.hi_there.pack(side=LEFT) def __init__(self, master=None): ! Frame.__init__(self, master) ! Pack.config(self) ! self.windownum = 0 ! self.createWidgets() test = Test() Index: window-creation-simple.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/matt/window-creation-simple.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** window-creation-simple.py 30 Jul 1996 18:57:17 -0000 1.2 --- window-creation-simple.py 18 Jul 2004 06:09:09 -0000 1.3 *************** *** 5,30 **** class Test(Frame): def printit(self): ! print "hi" def makeWindow(self): ! fred = Toplevel() ! fred.label = Label(fred, text="Here's a new window") ! fred.label.pack() def createWidgets(self): ! self.QUIT = Button(self, text='QUIT', foreground='red', ! command=self.quit) ! ! self.QUIT.pack(side=LEFT, fill=BOTH) ! # a hello button ! self.hi_there = Button(self, text='Make a New Window', ! command=self.makeWindow) ! self.hi_there.pack(side=LEFT) def __init__(self, master=None): ! Frame.__init__(self, master) ! Pack.config(self) ! self.createWidgets() test = Test() --- 5,30 ---- class Test(Frame): def printit(self): ! print "hi" def makeWindow(self): ! fred = Toplevel() ! fred.label = Label(fred, text="Here's a new window") ! fred.label.pack() def createWidgets(self): ! self.QUIT = Button(self, text='QUIT', foreground='red', ! command=self.quit) ! self.QUIT.pack(side=LEFT, fill=BOTH) ! ! # a hello button ! self.hi_there = Button(self, text='Make a New Window', ! command=self.makeWindow) ! self.hi_there.pack(side=LEFT) def __init__(self, master=None): ! Frame.__init__(self, master) ! Pack.config(self) ! self.createWidgets() test = Test() Index: window-creation-w-location.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/matt/window-creation-w-location.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** window-creation-w-location.py 8 Apr 1999 15:18:12 -0000 1.3 --- window-creation-w-location.py 18 Jul 2004 06:09:09 -0000 1.4 *************** *** 18,44 **** class Test(Frame): def makeWindow(self, *args): ! fred = Toplevel() ! fred.label = Canvas (fred, width="2i", height="2i") ! fred.label.create_line("0", "0", "2i", "2i") ! fred.label.create_line("0", "2i", "2i", "0") ! fred.label.pack() ! ##centerWindow(fred, self.master) def createWidgets(self): ! self.QUIT = QuitButton(self) ! self.QUIT.pack(side=LEFT, fill=BOTH) ! self.makeWindow = Button(self, text='Make a New Window', ! width=50, height=20, ! command=self.makeWindow) ! self.makeWindow.pack(side=LEFT) def __init__(self, master=None): ! Frame.__init__(self, master) ! Pack.config(self) ! self.createWidgets() test = Test() --- 18,44 ---- class Test(Frame): def makeWindow(self, *args): ! fred = Toplevel() ! fred.label = Canvas (fred, width="2i", height="2i") ! fred.label.create_line("0", "0", "2i", "2i") ! fred.label.create_line("0", "2i", "2i", "0") ! fred.label.pack() ! ##centerWindow(fred, self.master) def createWidgets(self): ! self.QUIT = QuitButton(self) ! self.QUIT.pack(side=LEFT, fill=BOTH) ! self.makeWindow = Button(self, text='Make a New Window', ! width=50, height=20, ! command=self.makeWindow) ! self.makeWindow.pack(side=LEFT) def __init__(self, master=None): ! Frame.__init__(self, master) ! Pack.config(self) ! self.createWidgets() test = Test() From tim_one at users.sourceforge.net Sun Jul 18 08:10:39 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 08:10:42 2004 Subject: [Python-checkins] python/dist/src/Demo/tix tixwidgets.py,1.10,1.11 Message-ID: Update of /cvsroot/python/python/dist/src/Demo/tix In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30843 Modified Files: tixwidgets.py Log Message: Whitespace normalization, via reindent.py. Index: tixwidgets.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tix/tixwidgets.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** tixwidgets.py 30 Dec 2002 23:52:00 -0000 1.10 --- tixwidgets.py 18 Jul 2004 06:10:36 -0000 1.11 *************** *** 5,14 **** # tixwidgets.py -- # ! # For Tix, see http://tix.sourceforge.net # ! # This is a demo program of some of the Tix widgets available in Python. ! # If you have installed Python & Tix properly, you can execute this as # ! # % python tixwidgets.py # --- 5,14 ---- # tixwidgets.py -- # ! # For Tix, see http://tix.sourceforge.net # ! # This is a demo program of some of the Tix widgets available in Python. ! # If you have installed Python & Tix properly, you can execute this as # ! # % python tixwidgets.py # *************** *** 17,26 **** import traceback, tkMessageBox ! TCL_DONT_WAIT = 1<<1 ! TCL_WINDOW_EVENTS = 1<<2 ! TCL_FILE_EVENTS = 1<<3 ! TCL_TIMER_EVENTS = 1<<4 ! TCL_IDLE_EVENTS = 1<<5 ! TCL_ALL_EVENTS = 0 class Demo: --- 17,26 ---- import traceback, tkMessageBox ! TCL_DONT_WAIT = 1<<1 ! TCL_WINDOW_EVENTS = 1<<2 ! TCL_FILE_EVENTS = 1<<3 ! TCL_TIMER_EVENTS = 1<<4 ! TCL_IDLE_EVENTS = 1<<5 ! TCL_ALL_EVENTS = 0 class Demo: *************** *** 29,40 **** self.exit = -1 ! self.dir = None # script directory ! self.balloon = None # balloon widget self.useBalloons = Tix.StringVar() self.useBalloons.set('0') ! self.statusbar = None # status bar widget ! self.welmsg = None # Msg widget ! self.welfont = '' # font name ! self.welsize = '' # font size progname = sys.argv[0] --- 29,40 ---- self.exit = -1 ! self.dir = None # script directory ! self.balloon = None # balloon widget self.useBalloons = Tix.StringVar() self.useBalloons.set('0') ! self.statusbar = None # status bar widget ! self.welmsg = None # Msg widget ! self.welfont = '' # font name ! self.welsize = '' # font size progname = sys.argv[0] *************** *** 73,77 **** # The trace variable option doesn't seem to work, instead I use 'command' #apply(w.tk.call, ('trace', 'variable', self.useBalloons, 'w', ! # ToggleHelp)) return w --- 73,77 ---- # The trace variable option doesn't seem to work, instead I use 'command' #apply(w.tk.call, ('trace', 'variable', self.useBalloons, 'w', ! # ToggleHelp)) return w *************** *** 131,135 **** # Tkinter defines a Tcl tkerror procedure that in effect # silences all background Tcl error reporting. ! # root.tk.eval('if {[info commands tkerror] != ""} {rename tkerror pytkerror}') def quitcmd (self): """Quit our mainloop. It is up to you to call root.destroy() after.""" --- 131,135 ---- # Tkinter defines a Tcl tkerror procedure that in effect # silences all background Tcl error reporting. ! # root.tk.eval('if {[info commands tkerror] != ""} {rename tkerror pytkerror}') def quitcmd (self): """Quit our mainloop. It is up to you to call root.destroy() after.""" *************** *** 137,143 **** def loop(self): ! """This is an explict replacement for _tkinter mainloop() ! It lets you catch keyboard interrupts easier, and avoids ! the 20 msec. dead sleep() which burns a constant CPU.""" while self.exit < 0: # There are 2 whiles here. The outer one lets you continue --- 137,143 ---- def loop(self): ! """This is an explict replacement for _tkinter mainloop() ! It lets you catch keyboard interrupts easier, and avoids ! the 20 msec. dead sleep() which burns a constant CPU.""" while self.exit < 0: # There are 2 whiles here. The outer one lets you continue *************** *** 222,228 **** demo.balloon.bind_widget(b1, msg='Choose\na font', ! statusmsg='Choose a font for this page') demo.balloon.bind_widget(b2, msg='Point size', ! statusmsg='Choose the font size for this page') return w --- 222,228 ---- demo.balloon.bind_widget(b1, msg='Choose\na font', ! statusmsg='Choose a font for this page') demo.balloon.bind_widget(b2, msg='Point size', ! statusmsg='Choose the font size for this page') return w *************** *** 234,241 **** text = 'Welcome to TIX in Python' title = Tix.Label(win, ! bd=0, width=30, anchor=Tix.N, text=text) msg = Tix.Message(win, ! bd=0, width=400, anchor=Tix.N, ! text='Tix is a set of mega-widgets based on TK. This program \ demonstrates the widgets in the Tix widget set. You can choose the pages \ in this window to look at the corresponding widgets. \n\n\ --- 234,241 ---- text = 'Welcome to TIX in Python' title = Tix.Label(win, ! bd=0, width=30, anchor=Tix.N, text=text) msg = Tix.Message(win, ! bd=0, width=400, anchor=Tix.N, ! text='Tix is a set of mega-widgets based on TK. This program \ demonstrates the widgets in the Tix widget set. You can choose the pages \ in this window to look at the corresponding widgets. \n\n\ *************** *** 251,259 **** if not demo.welmsg: ! return font = demo.welfont['value'] point = demo.welsize['value'] if font == 'Times Roman': ! font = 'times' fontstr = '%s %s' % (font, point) demo.welmsg['font'] = fontstr --- 251,259 ---- if not demo.welmsg: ! return font = demo.welfont['value'] point = demo.welsize['value'] if font == 'Times Roman': ! font = 'times' fontstr = '%s %s' % (font, point) demo.welmsg['font'] = fontstr *************** *** 261,267 **** def ToggleHelp(): if demo.useBalloons.get() == '1': ! demo.balloon['state'] = 'both' else: ! demo.balloon['state'] = 'none' def MkChoosers(nb, name): --- 261,267 ---- def ToggleHelp(): if demo.useBalloons.get() == '1': ! demo.balloon['state'] = 'both' else: ! demo.balloon['state'] = 'none' def MkChoosers(nb, name): *************** *** 308,312 **** editable = Tix.ComboBox(w, label='Editable', editable=1, options=options) history = Tix.ComboBox(w, label='History', editable=1, history=1, ! anchor=Tix.E, options=options) static.insert(Tix.END, 'January') static.insert(Tix.END, 'February') --- 308,312 ---- editable = Tix.ComboBox(w, label='Editable', editable=1, options=options) history = Tix.ComboBox(w, label='History', editable=1, history=1, ! anchor=Tix.E, options=options) static.insert(Tix.END, 'January') static.insert(Tix.END, 'February') *************** *** 341,350 **** idx = states.index(demo_spintxt.get()) + inc if idx < 0: ! idx = len(states) - 1 elif idx >= len(states): ! idx = 0 # following doesn't work. # return states[idx] ! demo_spintxt.set(states[idx]) # this works def spin_validate(w): --- 341,350 ---- idx = states.index(demo_spintxt.get()) + inc if idx < 0: ! idx = len(states) - 1 elif idx >= len(states): ! idx = 0 # following doesn't work. # return states[idx] ! demo_spintxt.set(states[idx]) # this works def spin_validate(w): *************** *** 352,358 **** try: ! i = states.index(demo_spintxt.get()) except ValueError: ! return states[0] return states[i] # why this procedure works as opposed to the previous one beats me. --- 352,358 ---- try: ! i = states.index(demo_spintxt.get()) except ValueError: ! return states[0] return states[i] # why this procedure works as opposed to the previous one beats me. *************** *** 418,423 **** def MkFileEnt(w): msg = Tix.Message(w, ! relief=Tix.FLAT, width=240, anchor=Tix.N, ! text='Press the "open file" icon button and a TixFileSelectDialog will popup.') ent = Tix.FileEntry(w, label='Select a file : ') msg.pack(side=Tix.TOP, expand=1, fill=Tix.BOTH, padx=3, pady=3) --- 418,423 ---- def MkFileEnt(w): msg = Tix.Message(w, ! relief=Tix.FLAT, width=240, anchor=Tix.N, ! text='Press the "open file" icon button and a TixFileSelectDialog will popup.') ent = Tix.FileEntry(w, label='Select a file : ') msg.pack(side=Tix.TOP, expand=1, fill=Tix.BOTH, padx=3, pady=3) *************** *** 430,435 **** """ msg = Tix.Message(w, ! relief=Tix.FLAT, width=240, anchor=Tix.N, ! text='The Tix FileSelectBox is a Motif-style box with various enhancements. For example, you can adjust the size of the two listboxes and your past selections are recorded.') box = Tix.FileSelectBox(w) msg.pack(side=Tix.TOP, expand=1, fill=Tix.BOTH, padx=3, pady=3) --- 430,435 ---- """ msg = Tix.Message(w, ! relief=Tix.FLAT, width=240, anchor=Tix.N, ! text='The Tix FileSelectBox is a Motif-style box with various enhancements. For example, you can adjust the size of the two listboxes and your past selections are recorded.') box = Tix.FileSelectBox(w) msg.pack(side=Tix.TOP, expand=1, fill=Tix.BOTH, padx=3, pady=3) *************** *** 444,449 **** msg = Tix.Message(w, ! relief=Tix.FLAT, width=240, anchor=Tix.N, ! text='The Select widget is also good for arranging buttons in a tool bar.') bar = Tix.Frame(w, bd=2, relief=Tix.RAISED) font = Tix.Select(w, allowzero=1, radio=0, label='', options=options) --- 444,449 ---- msg = Tix.Message(w, ! relief=Tix.FLAT, width=240, anchor=Tix.N, ! text='The Select widget is also good for arranging buttons in a tool bar.') bar = Tix.Frame(w, bd=2, relief=Tix.RAISED) font = Tix.Select(w, allowzero=1, radio=0, label='', options=options) *************** *** 467,472 **** def MkTitle(w): msg = Tix.Message(w, ! relief=Tix.FLAT, width=240, anchor=Tix.N, ! text='There are many types of "chooser" widgets that allow the user to input different types of information') msg.pack(side=Tix.TOP, expand=1, fill=Tix.BOTH, padx=3, pady=3) --- 467,472 ---- def MkTitle(w): msg = Tix.Message(w, ! relief=Tix.FLAT, width=240, anchor=Tix.N, ! text='There are many types of "chooser" widgets that allow the user to input different types of information') msg.pack(side=Tix.TOP, expand=1, fill=Tix.BOTH, padx=3, pady=3) *************** *** 495,500 **** bot = Tix.Frame(w) msg = Tix.Message(top, ! relief=Tix.FLAT, width=200, anchor=Tix.N, ! text='This TixScrolledListBox is configured so that it uses scrollbars only when it is necessary. Use the handles to resize the listbox and watch the scrollbars automatically appear and disappear.') list = Tix.ScrolledListBox(top, scrollbar='auto') --- 495,500 ---- bot = Tix.Frame(w) msg = Tix.Message(top, ! relief=Tix.FLAT, width=200, anchor=Tix.N, ! text='This TixScrolledListBox is configured so that it uses scrollbars only when it is necessary. Use the handles to resize the listbox and watch the scrollbars automatically appear and disappear.') list = Tix.ScrolledListBox(top, scrollbar='auto') *************** *** 509,514 **** rh = Tix.ResizeHandle(top, bg='black', ! relief=Tix.RAISED, ! handlesize=8, gridded=1, minwidth=50, minheight=30) btn = Tix.Button(bot, text='Reset', command=lambda w=rh, x=list: SList_reset(w,x)) top.propagate(0) --- 509,514 ---- rh = Tix.ResizeHandle(top, bg='black', ! relief=Tix.RAISED, ! handlesize=8, gridded=1, minwidth=50, minheight=30) btn = Tix.Button(bot, text='Reset', command=lambda w=rh, x=list: SList_reset(w,x)) top.propagate(0) *************** *** 518,522 **** bot.pack(fill=Tix.BOTH) list.bind('', func=lambda arg=0, rh=rh, list=list: ! list.tk.call('tixDoWhenIdle', str(rh), 'attachwidget', str(list))) def SList_reset(rh, list): --- 518,522 ---- bot.pack(fill=Tix.BOTH) list.bind('', func=lambda arg=0, rh=rh, list=list: ! list.tk.call('tixDoWhenIdle', str(rh), 'attachwidget', str(list))) def SList_reset(rh, list): *************** *** 540,545 **** bot = Tix.Frame(w) msg = Tix.Message(top, ! relief=Tix.FLAT, width=200, anchor=Tix.N, ! text=text) win = Tix.ScrolledWindow(top, scrollbar='auto') --- 540,545 ---- bot = Tix.Frame(w) msg = Tix.Message(top, ! relief=Tix.FLAT, width=200, anchor=Tix.N, ! text=text) win = Tix.ScrolledWindow(top, scrollbar='auto') *************** *** 552,557 **** rh = Tix.ResizeHandle(top, bg='black', ! relief=Tix.RAISED, ! handlesize=8, gridded=1, minwidth=50, minheight=30) btn = Tix.Button(bot, text='Reset', command=lambda w=rh, x=win: SWindow_reset(w,x)) top.propagate(0) --- 552,557 ---- rh = Tix.ResizeHandle(top, bg='black', ! relief=Tix.RAISED, ! handlesize=8, gridded=1, minwidth=50, minheight=30) btn = Tix.Button(bot, text='Reset', command=lambda w=rh, x=win: SWindow_reset(w,x)) top.propagate(0) *************** *** 562,566 **** win.bind('', func=lambda arg=0, rh=rh, win=win: ! win.tk.call('tixDoWhenIdle', str(rh), 'attachwidget', str(win))) def SWindow_reset(rh, win): --- 562,566 ---- win.bind('', func=lambda arg=0, rh=rh, win=win: ! win.tk.call('tixDoWhenIdle', str(rh), 'attachwidget', str(win))) def SWindow_reset(rh, win): *************** *** 575,592 **** bot = Tix.Frame(w) msg = Tix.Message(top, ! relief=Tix.FLAT, width=200, anchor=Tix.N, ! text='The Tix ScrolledWindow widget allows you to scroll any kind of Tk widget. It is more versatile than a scrolled canvas widget.') win = Tix.ScrolledText(top, scrollbar='auto') win.text['wrap'] = 'none' win.text.insert(Tix.END, '''When -scrollbar is set to "auto", the ! scrollbars are shown only when needed. Additional modifiers can be used to force a ! scrollbar to be shown or hidden. For example, ! "auto -y" means the horizontal scrollbar ! should be shown when needed but the vertical scrollbar should always be hidden; "auto +x" means the vertical scrollbar ! should be shown when needed but the horizontal scrollbar should always be shown, and so on.''' ) --- 575,592 ---- bot = Tix.Frame(w) msg = Tix.Message(top, ! relief=Tix.FLAT, width=200, anchor=Tix.N, ! text='The Tix ScrolledWindow widget allows you to scroll any kind of Tk widget. It is more versatile than a scrolled canvas widget.') win = Tix.ScrolledText(top, scrollbar='auto') win.text['wrap'] = 'none' win.text.insert(Tix.END, '''When -scrollbar is set to "auto", the ! scrollbars are shown only when needed. Additional modifiers can be used to force a ! scrollbar to be shown or hidden. For example, ! "auto -y" means the horizontal scrollbar ! should be shown when needed but the vertical scrollbar should always be hidden; "auto +x" means the vertical scrollbar ! should be shown when needed but the horizontal scrollbar should always be shown, and so on.''' ) *************** *** 594,599 **** rh = Tix.ResizeHandle(top, bg='black', ! relief=Tix.RAISED, ! handlesize=8, gridded=1, minwidth=50, minheight=30) btn = Tix.Button(bot, text='Reset', command=lambda w=rh, x=win: SText_reset(w,x)) top.propagate(0) --- 594,599 ---- rh = Tix.ResizeHandle(top, bg='black', ! relief=Tix.RAISED, ! handlesize=8, gridded=1, minwidth=50, minheight=30) btn = Tix.Button(bot, text='Reset', command=lambda w=rh, x=win: SText_reset(w,x)) top.propagate(0) *************** *** 603,607 **** bot.pack(fill=Tix.BOTH) win.bind('', func=lambda arg=0, rh=rh, win=win: ! win.tk.call('tixDoWhenIdle', str(rh), 'attachwidget', str(win))) def SText_reset(rh, win): --- 603,607 ---- bot.pack(fill=Tix.BOTH) win.bind('', func=lambda arg=0, rh=rh, win=win: ! win.tk.call('tixDoWhenIdle', str(rh), 'attachwidget', str(win))) def SText_reset(rh, win): *************** *** 629,634 **** """ msg = Tix.Message(w, ! relief=Tix.FLAT, width=240, anchor=Tix.N, ! text='The PanedWindow widget allows the user to interactively manipulate the sizes of several panes. The panes can be arranged either vertically or horizontally.') group = Tix.LabelEntry(w, label='Newsgroup:', options='entry.width 25') group.entry.insert(0,'comp.lang.python') --- 629,634 ---- """ msg = Tix.Message(w, ! relief=Tix.FLAT, width=240, anchor=Tix.N, ! text='The PanedWindow widget allows the user to interactively manipulate the sizes of several panes. The panes can be arranged either vertically or horizontally.') group = Tix.LabelEntry(w, label='Newsgroup:', options='entry.width 25') group.entry.insert(0,'comp.lang.python') *************** *** 672,677 **** def MkNoteBook(w): msg = Tix.Message(w, ! relief=Tix.FLAT, width=240, anchor=Tix.N, ! text='The NoteBook widget allows you to layout a complex interface into individual pages.') # prefix = Tix.OptionName(w) # if not prefix: prefix = '' --- 672,677 ---- def MkNoteBook(w): msg = Tix.Message(w, ! relief=Tix.FLAT, width=240, anchor=Tix.N, ! text='The NoteBook widget allows you to layout a complex interface into individual pages.') # prefix = Tix.OptionName(w) # if not prefix: prefix = '' *************** *** 739,744 **** """ msg = Tix.Message(w, ! relief=Tix.FLAT, width=240, anchor=Tix.N, ! text='The Tix DirList widget gives a graphical representation of the file system directory and makes it easy for the user to choose and access directories.') dirlist = Tix.DirList(w, options='hlist.padY 1 hlist.width 25 hlist.height 16') msg.pack(side=Tix.TOP, expand=1, fill=Tix.BOTH, padx=3, pady=3) --- 739,744 ---- """ msg = Tix.Message(w, ! relief=Tix.FLAT, width=240, anchor=Tix.N, ! text='The Tix DirList widget gives a graphical representation of the file system directory and makes it easy for the user to choose and access directories.') dirlist = Tix.DirList(w, options='hlist.padY 1 hlist.width 25 hlist.height 16') msg.pack(side=Tix.TOP, expand=1, fill=Tix.BOTH, padx=3, pady=3) *************** *** 749,754 **** style FileSelectBox. """ msg = Tix.Message(w, ! relief=Tix.FLAT, width=240, anchor=Tix.N, ! text='The Tix ExFileSelectBox widget is more user friendly than the Motif style FileSelectBox.') # There's a bug in the ComboBoxes - the scrolledlistbox is destroyed box = Tix.ExFileSelectBox(w, bd=2, relief=Tix.RAISED) --- 749,754 ---- style FileSelectBox. """ msg = Tix.Message(w, ! relief=Tix.FLAT, width=240, anchor=Tix.N, ! text='The Tix ExFileSelectBox widget is more user friendly than the Motif style FileSelectBox.') # There's a bug in the ComboBoxes - the scrolledlistbox is destroyed box = Tix.ExFileSelectBox(w, bd=2, relief=Tix.RAISED) *************** *** 759,867 **** ### List of all the demos we want to show off comments = {'widget' : 'Widget Demos', 'image' : 'Image Demos'} ! samples = {'Balloon' : 'Balloon', ! 'Button Box' : 'BtnBox', ! 'Combo Box' : 'ComboBox', ! 'Compound Image' : 'CmpImg', ! 'Directory List' : 'DirList', ! 'Directory Tree' : 'DirTree', ! 'Control' : 'Control', ! 'Notebook' : 'NoteBook', ! 'Option Menu' : 'OptMenu', ! 'Paned Window' : 'PanedWin', ! 'Popup Menu' : 'PopMenu', ! 'ScrolledHList (1)' : 'SHList1', ! 'ScrolledHList (2)' : 'SHList2', ! 'Tree (dynamic)' : 'Tree' } # There are still a lot of demos to be translated: ! ## set root { ! ## {d "File Selectors" file } ! ## {d "Hierachical ListBox" hlist } ! ## {d "Tabular ListBox" tlist {c tixTList}} ! ## {d "Grid Widget" grid {c tixGrid}} ! ## {d "Manager Widgets" manager } ! ## {d "Scrolled Widgets" scroll } ! ## {d "Miscellaneous Widgets" misc } ! ## {d "Image Types" image } ! ## } ## ! ## set image { ! ## {d "Compound Image" cmpimg } ! ## {d "XPM Image" xpm {i pixmap}} ! ## } ## ! ## set cmpimg { ! ##done {f "In Buttons" CmpImg.tcl } ! ## {f "In NoteBook" CmpImg2.tcl } ! ## {f "Notebook Color Tabs" CmpImg4.tcl } ! ## {f "Icons" CmpImg3.tcl } ! ## } ## ! ## set xpm { ! ## {f "In Button" Xpm.tcl {i pixmap}} ! ## {f "In Menu" Xpm1.tcl {i pixmap}} ! ## } ## ! ## set file { ! ##added {f DirList DirList.tcl } ! ##added {f DirTree DirTree.tcl } ! ## {f DirSelectDialog DirDlg.tcl } ! ## {f ExFileSelectDialog EFileDlg.tcl } ! ## {f FileSelectDialog FileDlg.tcl } ! ## {f FileEntry FileEnt.tcl } ! ## } ## ! ## set hlist { ! ## {f HList HList1.tcl } ! ## {f CheckList ChkList.tcl {c tixCheckList}} ! ##done {f "ScrolledHList (1)" SHList.tcl } ! ##done {f "ScrolledHList (2)" SHList2.tcl } ! ##done {f Tree Tree.tcl } ! ##done {f "Tree (Dynamic)" DynTree.tcl {v win}} ! ## } ## ! ## set tlist { ! ## {f "ScrolledTList (1)" STList1.tcl {c tixTList}} ! ## {f "ScrolledTList (2)" STList2.tcl {c tixTList}} ! ## } ! ## global tcl_platform ! ## # This demo hangs windows ! ## if {$tcl_platform(platform) != "windows"} { ! ##na lappend tlist {f "TList File Viewer" STList3.tcl {c tixTList}} ! ## } ## ! ## set grid { ! ##na {f "Simple Grid" SGrid0.tcl {c tixGrid}} ! ##na {f "ScrolledGrid" SGrid1.tcl {c tixGrid}} ! ##na {f "Editable Grid" EditGrid.tcl {c tixGrid}} ! ## } ## ! ## set scroll { ! ## {f ScrolledListBox SListBox.tcl } ! ## {f ScrolledText SText.tcl } ! ## {f ScrolledWindow SWindow.tcl } ! ##na {f "Canvas Object View" CObjView.tcl {c tixCObjView}} ! ## } ## ! ## set manager { ! ## {f ListNoteBook ListNBK.tcl } ! ##done {f NoteBook NoteBook.tcl } ! ##done {f PanedWindow PanedWin.tcl } ! ## } ## ! ## set misc { ! ##done {f Balloon Balloon.tcl } ! ##done {f ButtonBox BtnBox.tcl } ! ##done {f ComboBox ComboBox.tcl } ! ##done {f Control Control.tcl } ! ## {f LabelEntry LabEntry.tcl } ! ## {f LabelFrame LabFrame.tcl } ! ## {f Meter Meter.tcl {c tixMeter}} ! ##done {f OptionMenu OptMenu.tcl } ! ##done {f PopupMenu PopMenu.tcl } ! ## {f Select Select.tcl } ! ## {f StdButtonBox StdBBox.tcl } ! ## } ## --- 759,867 ---- ### List of all the demos we want to show off comments = {'widget' : 'Widget Demos', 'image' : 'Image Demos'} ! samples = {'Balloon' : 'Balloon', ! 'Button Box' : 'BtnBox', ! 'Combo Box' : 'ComboBox', ! 'Compound Image' : 'CmpImg', ! 'Directory List' : 'DirList', ! 'Directory Tree' : 'DirTree', ! 'Control' : 'Control', ! 'Notebook' : 'NoteBook', ! 'Option Menu' : 'OptMenu', ! 'Paned Window' : 'PanedWin', ! 'Popup Menu' : 'PopMenu', ! 'ScrolledHList (1)' : 'SHList1', ! 'ScrolledHList (2)' : 'SHList2', ! 'Tree (dynamic)' : 'Tree' } # There are still a lot of demos to be translated: ! ## set root { ! ## {d "File Selectors" file } ! ## {d "Hierachical ListBox" hlist } ! ## {d "Tabular ListBox" tlist {c tixTList}} ! ## {d "Grid Widget" grid {c tixGrid}} ! ## {d "Manager Widgets" manager } ! ## {d "Scrolled Widgets" scroll } ! ## {d "Miscellaneous Widgets" misc } ! ## {d "Image Types" image } ! ## } ## ! ## set image { ! ## {d "Compound Image" cmpimg } ! ## {d "XPM Image" xpm {i pixmap}} ! ## } ## ! ## set cmpimg { ! ##done {f "In Buttons" CmpImg.tcl } ! ## {f "In NoteBook" CmpImg2.tcl } ! ## {f "Notebook Color Tabs" CmpImg4.tcl } ! ## {f "Icons" CmpImg3.tcl } ! ## } ## ! ## set xpm { ! ## {f "In Button" Xpm.tcl {i pixmap}} ! ## {f "In Menu" Xpm1.tcl {i pixmap}} ! ## } ## ! ## set file { ! ##added {f DirList DirList.tcl } ! ##added {f DirTree DirTree.tcl } ! ## {f DirSelectDialog DirDlg.tcl } ! ## {f ExFileSelectDialog EFileDlg.tcl } ! ## {f FileSelectDialog FileDlg.tcl } ! ## {f FileEntry FileEnt.tcl } ! ## } ## ! ## set hlist { ! ## {f HList HList1.tcl } ! ## {f CheckList ChkList.tcl {c tixCheckList}} ! ##done {f "ScrolledHList (1)" SHList.tcl } ! ##done {f "ScrolledHList (2)" SHList2.tcl } ! ##done {f Tree Tree.tcl } ! ##done {f "Tree (Dynamic)" DynTree.tcl {v win}} ! ## } ## ! ## set tlist { ! ## {f "ScrolledTList (1)" STList1.tcl {c tixTList}} ! ## {f "ScrolledTList (2)" STList2.tcl {c tixTList}} ! ## } ! ## global tcl_platform ! ## # This demo hangs windows ! ## if {$tcl_platform(platform) != "windows"} { ! ##na lappend tlist {f "TList File Viewer" STList3.tcl {c tixTList}} ! ## } ## ! ## set grid { ! ##na {f "Simple Grid" SGrid0.tcl {c tixGrid}} ! ##na {f "ScrolledGrid" SGrid1.tcl {c tixGrid}} ! ##na {f "Editable Grid" EditGrid.tcl {c tixGrid}} ! ## } ## ! ## set scroll { ! ## {f ScrolledListBox SListBox.tcl } ! ## {f ScrolledText SText.tcl } ! ## {f ScrolledWindow SWindow.tcl } ! ##na {f "Canvas Object View" CObjView.tcl {c tixCObjView}} ! ## } ## ! ## set manager { ! ## {f ListNoteBook ListNBK.tcl } ! ##done {f NoteBook NoteBook.tcl } ! ##done {f PanedWindow PanedWin.tcl } ! ## } ## ! ## set misc { ! ##done {f Balloon Balloon.tcl } ! ##done {f ButtonBox BtnBox.tcl } ! ##done {f ComboBox ComboBox.tcl } ! ##done {f Control Control.tcl } ! ## {f LabelEntry LabEntry.tcl } ! ## {f LabelFrame LabFrame.tcl } ! ## {f Meter Meter.tcl {c tixMeter}} ! ##done {f OptionMenu OptMenu.tcl } ! ##done {f PopupMenu PopMenu.tcl } ! ## {f Select Select.tcl } ! ## {f StdButtonBox StdBBox.tcl } ! ## } ## *************** *** 869,874 **** stypes['widget'] = ['Balloon', 'Button Box', 'Combo Box', 'Control', 'Directory List', 'Directory Tree', ! 'Notebook', 'Option Menu', 'Popup Menu', 'Paned Window', ! 'ScrolledHList (1)', 'ScrolledHList (2)', 'Tree (dynamic)'] stypes['image'] = ['Compound Image'] --- 869,874 ---- stypes['widget'] = ['Balloon', 'Button Box', 'Combo Box', 'Control', 'Directory List', 'Directory Tree', ! 'Notebook', 'Option Menu', 'Popup Menu', 'Paned Window', ! 'ScrolledHList (1)', 'ScrolledHList (2)', 'Tree (dynamic)'] stypes['image'] = ['Compound Image'] *************** *** 923,935 **** for type in ['widget', 'image']: ! if type != 'widget': ! x = Tix.Frame(slb.hlist, bd=2, height=2, width=150, ! relief=Tix.SUNKEN, bg=slb.hlist['bg']) ! slb.hlist.add_child(itemtype=Tix.WINDOW, window=x, state='disabled') ! x = slb.hlist.add_child(itemtype=Tix.TEXT, state='disabled', ! text=comments[type]) ! for key in stypes[type]: ! slb.hlist.add_child(x, itemtype=Tix.TEXT, data=key, ! text=key) slb.hlist.selection_clear() --- 923,935 ---- for type in ['widget', 'image']: ! if type != 'widget': ! x = Tix.Frame(slb.hlist, bd=2, height=2, width=150, ! relief=Tix.SUNKEN, bg=slb.hlist['bg']) ! slb.hlist.add_child(itemtype=Tix.WINDOW, window=x, state='disabled') ! x = slb.hlist.add_child(itemtype=Tix.TEXT, state='disabled', ! text=comments[type]) ! for key in stypes[type]: ! slb.hlist.add_child(x, itemtype=Tix.TEXT, data=key, ! text=key) slb.hlist.selection_clear() *************** *** 943,951 **** anchor = hlist.info_anchor() if not anchor: ! run['state'] = 'disabled' ! view['state'] = 'disabled' elif not hlist.info_parent(anchor): ! # a comment ! return run['state'] = 'normal' --- 943,951 ---- anchor = hlist.info_anchor() if not anchor: ! run['state'] = 'disabled' ! view['state'] = 'disabled' elif not hlist.info_parent(anchor): ! # a comment ! return run['state'] = 'normal' *************** *** 956,970 **** if action == 'run': ! exec('import ' + prog) ! w = Tix.Toplevel() ! w.title(title) ! rtn = eval(prog + '.RunSample') ! rtn(w) elif action == 'view': ! w = Tix.Toplevel() ! w.title('Source view: ' + title) ! LoadFile(w, demo.dir + '/samples/' + prog + '.py') elif action == 'browse': ! ReadFile(stext.text, demo.dir + '/samples/' + prog + '.py') def LoadFile(w, fname): --- 956,970 ---- if action == 'run': ! exec('import ' + prog) ! w = Tix.Toplevel() ! w.title(title) ! rtn = eval(prog + '.RunSample') ! rtn(w) elif action == 'view': ! w = Tix.Toplevel() ! w.title('Source view: ' + title) ! LoadFile(w, demo.dir + '/samples/' + prog + '.py') elif action == 'browse': ! ReadFile(stext.text, demo.dir + '/samples/' + prog + '.py') def LoadFile(w, fname): *************** *** 990,1004 **** try: ! f = open(fname) ! lines = f.readlines() ! for s in lines: ! w.insert(Tix.END, s) ! f.close() finally: ! # w.see('1.0') ! w['state'] = old_state if __name__ == '__main__': root = Tix.Tk() RunMain(root) - --- 990,1003 ---- try: ! f = open(fname) ! lines = f.readlines() ! for s in lines: ! w.insert(Tix.END, s) ! f.close() finally: ! # w.see('1.0') ! w['state'] = old_state if __name__ == '__main__': root = Tix.Tk() RunMain(root) From tim_one at users.sourceforge.net Sun Jul 18 08:10:39 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 08:10:43 2004 Subject: [Python-checkins] python/dist/src/Demo/tix/samples Balloon.py, 1.2, 1.3 BtnBox.py, 1.2, 1.3 CmpImg.py, 1.2, 1.3 ComboBox.py, 1.2, 1.3 Control.py, 1.3, 1.4 DirList.py, 1.3, 1.4 DirTree.py, 1.2, 1.3 NoteBook.py, 1.2, 1.3 OptMenu.py, 1.2, 1.3 PanedWin.py, 1.1, 1.2 PopMenu.py, 1.2, 1.3 SHList1.py, 1.3, 1.4 SHList2.py, 1.3, 1.4 Tree.py, 1.2, 1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Demo/tix/samples In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30843/samples Modified Files: Balloon.py BtnBox.py CmpImg.py ComboBox.py Control.py DirList.py DirTree.py NoteBook.py OptMenu.py PanedWin.py PopMenu.py SHList1.py SHList2.py Tree.py Log Message: Whitespace normalization, via reindent.py. Index: Balloon.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tix/samples/Balloon.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Balloon.py 17 Mar 2002 18:19:13 -0000 1.2 --- Balloon.py 18 Jul 2004 06:10:36 -0000 1.3 *************** *** 18,22 **** import Tix ! TCL_ALL_EVENTS = 0 def RunSample (root): --- 18,22 ---- import Tix ! TCL_ALL_EVENTS = 0 def RunSample (root): Index: BtnBox.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tix/samples/BtnBox.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** BtnBox.py 17 Mar 2002 18:19:13 -0000 1.2 --- BtnBox.py 18 Jul 2004 06:10:36 -0000 1.3 *************** *** 1,4 **** # -*-mode: python; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*- ! # # $Id$ # --- 1,4 ---- # -*-mode: python; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*- ! # # $Id$ # *************** *** 22,26 **** # top = Tix.Label(w, padx=20, pady=10, bd=1, relief=Tix.RAISED, ! anchor=Tix.CENTER, text='This dialog box is\n a demonstration of the\n tixButtonBox widget') # Create the button box and add a few buttons in it. Set the --- 22,26 ---- # top = Tix.Label(w, padx=20, pady=10, bd=1, relief=Tix.RAISED, ! anchor=Tix.CENTER, text='This dialog box is\n a demonstration of the\n tixButtonBox widget') # Create the button box and add a few buttons in it. Set the *************** *** 33,39 **** box = Tix.ButtonBox(w, orientation=Tix.HORIZONTAL) box.add('ok', text='OK', underline=0, width=5, ! command=lambda w=w: w.destroy()) box.add('close', text='Cancel', underline=0, width=5, ! command=lambda w=w: w.destroy()) box.pack(side=Tix.BOTTOM, fill=Tix.X) top.pack(side=Tix.TOP, fill=Tix.BOTH, expand=1) --- 33,39 ---- box = Tix.ButtonBox(w, orientation=Tix.HORIZONTAL) box.add('ok', text='OK', underline=0, width=5, ! command=lambda w=w: w.destroy()) box.add('close', text='Cancel', underline=0, width=5, ! command=lambda w=w: w.destroy()) box.pack(side=Tix.BOTTOM, fill=Tix.X) top.pack(side=Tix.TOP, fill=Tix.BOTH, expand=1) Index: CmpImg.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tix/samples/CmpImg.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CmpImg.py 17 Mar 2002 18:19:13 -0000 1.2 --- CmpImg.py 18 Jul 2004 06:10:36 -0000 1.3 *************** *** 1,4 **** # -*-mode: python; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*- ! # # $Id$ # --- 1,4 ---- # -*-mode: python; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*- ! # # $Id$ # *************** *** 23,33 **** "32 32 7 1", /* colors */ ! " s None c None", ! ". c #000000000000", ! "X c white", ! "o c #c000c000c000", ! "O c #404040", ! "+ c blue", ! "@ c red", /* pixels */ " ", --- 23,33 ---- "32 32 7 1", /* colors */ ! " s None c None", ! ". c #000000000000", ! "X c white", ! "o c #c000c000c000", ! "O c #404040", ! "+ c blue", ! "@ c red", /* pixels */ " ", *************** *** 70,78 **** "32 32 5 1", /* colors */ ! " s None c None", ! ". c #000000000000", ! "X c white", ! "o c #c000c000c000", ! "O c #800080008000", /* pixels */ " ", --- 70,78 ---- "32 32 5 1", /* colors */ ! " s None c None", ! ". c #000000000000", ! "X c white", ! "o c #c000c000c000", ! "O c #800080008000", /* pixels */ " ", *************** *** 147,154 **** w.img0 = Tix.Image('pixmap', data=network_pixmap) if not w.img0: ! w.img0 = Tix.Image('bitmap', data=network_bitmap) w.img1 = Tix.Image('pixmap', data=hard_disk_pixmap) if not w.img0: ! w.img1 = Tix.Image('bitmap', data=hard_disk_bitmap) hdd = Tix.Button(w, padx=4, pady=1, width=120) --- 147,154 ---- w.img0 = Tix.Image('pixmap', data=network_pixmap) if not w.img0: ! w.img0 = Tix.Image('bitmap', data=network_bitmap) w.img1 = Tix.Image('pixmap', data=hard_disk_pixmap) if not w.img0: ! w.img1 = Tix.Image('bitmap', data=hard_disk_bitmap) hdd = Tix.Button(w, padx=4, pady=1, width=120) *************** *** 164,168 **** w.hdd_img.tk.call(str(w.hdd_img), 'add', 'line') w.hdd_img.tk.call(str(w.hdd_img), 'add', 'text', '-text', 'Hard Disk', ! '-underline', '0') w.hdd_img.tk.call(str(w.hdd_img), 'add', 'space', '-width', '7') w.hdd_img.tk.call(str(w.hdd_img), 'add', 'image', '-image', w.img1) --- 164,168 ---- w.hdd_img.tk.call(str(w.hdd_img), 'add', 'line') w.hdd_img.tk.call(str(w.hdd_img), 'add', 'text', '-text', 'Hard Disk', ! '-underline', '0') w.hdd_img.tk.call(str(w.hdd_img), 'add', 'space', '-width', '7') w.hdd_img.tk.call(str(w.hdd_img), 'add', 'image', '-image', w.img1) *************** *** 176,180 **** w.net_img.tk.call(str(w.net_img), 'add', 'line') w.net_img.tk.call(str(w.net_img), 'add', 'text', '-text', 'Network', ! '-underline', '0') w.net_img.tk.call(str(w.net_img), 'add', 'space', '-width', '7') w.net_img.tk.call(str(w.net_img), 'add', 'image', '-image', w.img0) --- 176,180 ---- w.net_img.tk.call(str(w.net_img), 'add', 'line') w.net_img.tk.call(str(w.net_img), 'add', 'text', '-text', 'Network', ! '-underline', '0') w.net_img.tk.call(str(w.net_img), 'add', 'space', '-width', '7') w.net_img.tk.call(str(w.net_img), 'add', 'image', '-image', w.img0) *************** *** 185,189 **** close = Tix.Button(w, pady=1, text='Close', ! command=lambda w=w: w.destroy()) hdd.pack(side=Tix.LEFT, padx=10, pady=10, fill=Tix.Y, expand=1) --- 185,189 ---- close = Tix.Button(w, pady=1, text='Close', ! command=lambda w=w: w.destroy()) hdd.pack(side=Tix.LEFT, padx=10, pady=10, fill=Tix.Y, expand=1) *************** *** 195,197 **** RunSample(root) root.mainloop() - --- 195,196 ---- Index: ComboBox.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tix/samples/ComboBox.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ComboBox.py 17 Mar 2002 18:19:13 -0000 1.2 --- ComboBox.py 18 Jul 2004 06:10:36 -0000 1.3 *************** *** 1,4 **** # -*-mode: python; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*- ! # # $Id$ # --- 1,4 ---- # -*-mode: python; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*- ! # # $Id$ # *************** *** 28,37 **** # # [Hint] The -options switch sets the options of the subwidgets. ! # [Hint] We set the label.width subwidget option of both comboboxes to # be 10 so that their labels appear to be aligned. # a = Tix.ComboBox(top, label="Month: ", dropdown=1, ! command=select_month, editable=0, variable=demo_month, ! options='listbox.height 6 label.width 10 label.anchor e') # $w.top.b is a non-drop-down combo box. It is not editable: we provide --- 28,37 ---- # # [Hint] The -options switch sets the options of the subwidgets. ! # [Hint] We set the label.width subwidget option of both comboboxes to # be 10 so that their labels appear to be aligned. # a = Tix.ComboBox(top, label="Month: ", dropdown=1, ! command=select_month, editable=0, variable=demo_month, ! options='listbox.height 6 label.width 10 label.anchor e') # $w.top.b is a non-drop-down combo box. It is not editable: we provide *************** *** 40,50 **** # # [Hint] Use the padY and anchor options of the label subwidget to ! # align the label with the entry subwidget. # [Hint] Notice that you should use padY (the NAME of the option) and not # pady (the SWITCH of the option). # b = Tix.ComboBox(top, label="Year: ", dropdown=0, ! command=select_year, editable=1, variable=demo_year, ! options='listbox.height 4 label.padY 5 label.width 10 label.anchor ne') a.pack(side=Tix.TOP, anchor=Tix.W) --- 40,50 ---- # # [Hint] Use the padY and anchor options of the label subwidget to ! # align the label with the entry subwidget. # [Hint] Notice that you should use padY (the NAME of the option) and not # pady (the SWITCH of the option). # b = Tix.ComboBox(top, label="Year: ", dropdown=0, ! command=select_year, editable=1, variable=demo_year, ! options='listbox.height 4 label.padY 5 label.width 10 label.anchor ne') a.pack(side=Tix.TOP, anchor=Tix.W) *************** *** 71,75 **** # Use "tixSetSilent" to set the values of the combo box if you ! # don't want your -command procedures (cbx:select_month and # cbx:select_year) to be called. # --- 71,75 ---- # Use "tixSetSilent" to set the values of the combo box if you ! # don't want your -command procedures (cbx:select_month and # cbx:select_year) to be called. # *************** *** 79,85 **** box = Tix.ButtonBox(w, orientation=Tix.HORIZONTAL) box.add('ok', text='Ok', underline=0, width=6, ! command=lambda w=w: ok_command(w)) box.add('cancel', text='Cancel', underline=0, width=6, ! command=lambda w=w: w.destroy()) box.pack(side=Tix.BOTTOM, fill=Tix.X) top.pack(side=Tix.TOP, fill=Tix.BOTH, expand=1) --- 79,85 ---- box = Tix.ButtonBox(w, orientation=Tix.HORIZONTAL) box.add('ok', text='Ok', underline=0, width=6, ! command=lambda w=w: ok_command(w)) box.add('cancel', text='Cancel', underline=0, width=6, ! command=lambda w=w: w.destroy()) box.pack(side=Tix.BOTTOM, fill=Tix.X) top.pack(side=Tix.TOP, fill=Tix.BOTH, expand=1) Index: Control.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tix/samples/Control.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Control.py 17 Mar 2002 18:19:13 -0000 1.3 --- Control.py 18 Jul 2004 06:10:36 -0000 1.4 *************** *** 21,25 **** import Tix ! TCL_ALL_EVENTS = 0 def RunSample (root): --- 21,25 ---- import Tix ! TCL_ALL_EVENTS = 0 def RunSample (root): *************** *** 47,51 **** # # [Hint] The -options switch sets the options of the subwidgets. ! # [Hint] We set the label.width subwidget option of the Controls to # be 16 so that their labels appear to be aligned. # --- 47,51 ---- # # [Hint] The -options switch sets the options of the subwidgets. ! # [Hint] We set the label.width subwidget option of the Controls to # be 16 so that their labels appear to be aligned. # *************** *** 84,88 **** # tixDemo:Status "Selected %d of %s engines each of thrust %d", (demo_num_engines.get(), demo_maker.get(), demo_thrust.get()) self.quitcmd() ! def quitcmd (self): self.exit = 0 --- 84,88 ---- # tixDemo:Status "Selected %d of %s engines each of thrust %d", (demo_num_engines.get(), demo_maker.get(), demo_thrust.get()) self.quitcmd() ! def quitcmd (self): self.exit = 0 *************** *** 101,107 **** i = i + inc if i >= len(maker_list): ! i = 0 elif i < 0: ! i = len(maker_list) - 1 # In Tcl/Tix we should return the string maker_list[i]. We can't --- 101,107 ---- i = i + inc if i >= len(maker_list): ! i = 0 elif i < 0: ! i = len(maker_list) - 1 # In Tcl/Tix we should return the string maker_list[i]. We can't *************** *** 111,118 **** def validate_maker(w): try: ! i = maker_list.index(demo_maker.get()) except ValueError: ! # Works here though. Why ? Beats me. ! return maker_list[0] # Works here though. Why ? Beats me. return maker_list[i] --- 111,118 ---- def validate_maker(w): try: ! i = maker_list.index(demo_maker.get()) except ValueError: ! # Works here though. Why ? Beats me. ! return maker_list[0] # Works here though. Why ? Beats me. return maker_list[i] Index: DirList.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tix/samples/DirList.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** DirList.py 12 Feb 2004 17:35:03 -0000 1.3 --- DirList.py 18 Jul 2004 06:10:36 -0000 1.4 *************** *** 1,5 **** # -*-mode: python; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*- # ! # $Id$ # # Tix Demostration Program --- 1,5 ---- # -*-mode: python; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*- # ! # $Id$ # # Tix Demostration Program *************** *** 20,24 **** from Tkconstants import * ! TCL_ALL_EVENTS = 0 def RunSample (root): --- 20,24 ---- from Tkconstants import * ! TCL_ALL_EVENTS = 0 def RunSample (root): *************** *** 26,38 **** dirlist.mainloop() dirlist.destroy() ! class DemoDirList: def __init__(self, w): self.root = w self.exit = -1 ! z = w.winfo_toplevel() z.wm_protocol("WM_DELETE_WINDOW", lambda self=self: self.quitcmd()) ! # Create the tixDirList and the tixLabelEntry widgets on the on the top # of the dialog box --- 26,38 ---- dirlist.mainloop() dirlist.destroy() ! class DemoDirList: def __init__(self, w): self.root = w self.exit = -1 ! z = w.winfo_toplevel() z.wm_protocol("WM_DELETE_WINDOW", lambda self=self: self.quitcmd()) ! # Create the tixDirList and the tixLabelEntry widgets on the on the top # of the dialog box *************** *** 49,53 **** top.dir = Tix.DirList(top) top.dir.hlist['width'] = 40 ! # When the user presses the ".." button, the selected directory # is "transferred" into the entry widget --- 49,53 ---- top.dir = Tix.DirList(top) top.dir.hlist['width'] = 40 ! # When the user presses the ".." button, the selected directory # is "transferred" into the entry widget *************** *** 56,60 **** # We use a LabelEntry to hold the installation directory. The user ! # can choose from the DirList widget, or he can type in the directory # manually # --- 56,60 ---- # We use a LabelEntry to hold the installation directory. The user ! # can choose from the DirList widget, or he can type in the directory # manually # *************** *** 65,69 **** label.anchor w ''') ! font = self.root.tk.eval('tix option get fixed_font') # font = self.root.master.tix_option_get('fixed_font') --- 65,69 ---- label.anchor w ''') ! font = self.root.tk.eval('tix option get fixed_font') # font = self.root.master.tix_option_get('fixed_font') *************** *** 130,132 **** text = text + line + '\n' d = tkMessageBox.showerror ( 'Tix Demo Error', text) - --- 130,131 ---- Index: DirTree.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tix/samples/DirTree.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** DirTree.py 17 Mar 2002 18:19:13 -0000 1.2 --- DirTree.py 18 Jul 2004 06:10:36 -0000 1.3 *************** *** 1,5 **** # -*-mode: python; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*- # ! # $Id$ # # Tix Demostration Program --- 1,5 ---- # -*-mode: python; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*- # ! # $Id$ # # Tix Demostration Program *************** *** 20,24 **** from Tkconstants import * ! TCL_ALL_EVENTS = 0 def RunSample (root): --- 20,24 ---- from Tkconstants import * ! TCL_ALL_EVENTS = 0 def RunSample (root): *************** *** 31,35 **** self.root = w self.exit = -1 ! z = w.winfo_toplevel() z.wm_protocol("WM_DELETE_WINDOW", lambda self=self: self.quitcmd()) --- 31,35 ---- self.root = w self.exit = -1 ! z = w.winfo_toplevel() z.wm_protocol("WM_DELETE_WINDOW", lambda self=self: self.quitcmd()) *************** *** 49,53 **** top.dir = Tix.DirTree(top) top.dir.hlist['width'] = 40 ! # When the user presses the ".." button, the selected directory # is "transferred" into the entry widget --- 49,53 ---- top.dir = Tix.DirTree(top) top.dir.hlist['width'] = 40 ! # When the user presses the ".." button, the selected directory # is "transferred" into the entry widget *************** *** 56,60 **** # We use a LabelEntry to hold the installation directory. The user ! # can choose from the DirTree widget, or he can type in the directory # manually # --- 56,60 ---- # We use a LabelEntry to hold the installation directory. The user ! # can choose from the DirTree widget, or he can type in the directory # manually # *************** *** 116,118 **** root=Tix.Tk() RunSample(root) - --- 116,117 ---- Index: NoteBook.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tix/samples/NoteBook.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** NoteBook.py 17 Mar 2002 18:19:13 -0000 1.2 --- NoteBook.py 18 Jul 2004 06:10:36 -0000 1.3 *************** *** 1,4 **** # -*-mode: python; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*- ! # # $Id$ # --- 1,4 ---- # -*-mode: python; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*- ! # # $Id$ # *************** *** 24,30 **** prefix = Tix.OptionName(w) if prefix: ! prefix = '*'+prefix else: ! prefix = '' w.option_add(prefix+'*TixControl*entry.width', 10) w.option_add(prefix+'*TixControl*label.width', 18) --- 24,30 ---- prefix = Tix.OptionName(w) if prefix: ! prefix = '*'+prefix else: ! prefix = '' w.option_add(prefix+'*TixControl*entry.width', 10) w.option_add(prefix+'*TixControl*label.width', 18) *************** *** 38,49 **** nb['bg'] = 'gray' nb.nbframe['backpagecolor'] = 'gray' ! # Create the two tabs on the notebook. The -underline option # puts a underline on the first character of the labels of the tabs. # Keyboard accelerators will be defined automatically according ! # to the underlined character. nb.add('hard_disk', label="Hard Disk", underline=0) nb.add('network', label="Network", underline=0) ! nb.pack(expand=1, fill=Tix.BOTH, padx=5, pady=5 ,side=Tix.TOP) --- 38,49 ---- nb['bg'] = 'gray' nb.nbframe['backpagecolor'] = 'gray' ! # Create the two tabs on the notebook. The -underline option # puts a underline on the first character of the labels of the tabs. # Keyboard accelerators will be defined automatically according ! # to the underlined character. nb.add('hard_disk', label="Hard Disk", underline=0) nb.add('network', label="Network", underline=0) ! nb.pack(expand=1, fill=Tix.BOTH, padx=5, pady=5 ,side=Tix.TOP) *************** *** 57,89 **** f = Tix.Frame(tab) common = Tix.Frame(tab) ! f.pack(side=Tix.LEFT, padx=2, pady=2, fill=Tix.BOTH, expand=1) common.pack(side=Tix.RIGHT, padx=2, fill=Tix.Y) ! a = Tix.Control(f, value=12, label='Access time: ') w = Tix.Control(f, value=400, label='Write Throughput: ') r = Tix.Control(f, value=400, label='Read Throughput: ') c = Tix.Control(f, value=1021, label='Capacity: ') ! a.pack(side=Tix.TOP, padx=20, pady=2) w.pack(side=Tix.TOP, padx=20, pady=2) r.pack(side=Tix.TOP, padx=20, pady=2) c.pack(side=Tix.TOP, padx=20, pady=2) ! # Create the common buttons createCommonButtons(common) ! #---------------------------------------- ! # Create the second page #---------------------------------------- ! tab = nb.network f = Tix.Frame(tab) common = Tix.Frame(tab) ! f.pack(side=Tix.LEFT, padx=2, pady=2, fill=Tix.BOTH, expand=1) common.pack(side=Tix.RIGHT, padx=2, fill=Tix.Y) ! a = Tix.Control(f, value=12, label='Access time: ') w = Tix.Control(f, value=400, label='Write Throughput: ') --- 57,89 ---- f = Tix.Frame(tab) common = Tix.Frame(tab) ! f.pack(side=Tix.LEFT, padx=2, pady=2, fill=Tix.BOTH, expand=1) common.pack(side=Tix.RIGHT, padx=2, fill=Tix.Y) ! a = Tix.Control(f, value=12, label='Access time: ') w = Tix.Control(f, value=400, label='Write Throughput: ') r = Tix.Control(f, value=400, label='Read Throughput: ') c = Tix.Control(f, value=1021, label='Capacity: ') ! a.pack(side=Tix.TOP, padx=20, pady=2) w.pack(side=Tix.TOP, padx=20, pady=2) r.pack(side=Tix.TOP, padx=20, pady=2) c.pack(side=Tix.TOP, padx=20, pady=2) ! # Create the common buttons createCommonButtons(common) ! #---------------------------------------- ! # Create the second page #---------------------------------------- ! tab = nb.network f = Tix.Frame(tab) common = Tix.Frame(tab) ! f.pack(side=Tix.LEFT, padx=2, pady=2, fill=Tix.BOTH, expand=1) common.pack(side=Tix.RIGHT, padx=2, fill=Tix.Y) ! a = Tix.Control(f, value=12, label='Access time: ') w = Tix.Control(f, value=400, label='Write Throughput: ') *************** *** 91,95 **** c = Tix.Control(f, value=1021, label='Capacity: ') u = Tix.Control(f, value=10, label='Users: ') ! a.pack(side=Tix.TOP, padx=20, pady=2) w.pack(side=Tix.TOP, padx=20, pady=2) --- 91,95 ---- c = Tix.Control(f, value=1021, label='Capacity: ') u = Tix.Control(f, value=10, label='Users: ') ! a.pack(side=Tix.TOP, padx=20, pady=2) w.pack(side=Tix.TOP, padx=20, pady=2) *************** *** 97,103 **** c.pack(side=Tix.TOP, padx=20, pady=2) u.pack(side=Tix.TOP, padx=20, pady=2) ! createCommonButtons(common) ! def doDestroy(): global root --- 97,103 ---- c.pack(side=Tix.TOP, padx=20, pady=2) u.pack(side=Tix.TOP, padx=20, pady=2) ! createCommonButtons(common) ! def doDestroy(): global root *************** *** 105,116 **** def createCommonButtons(master): ! ok = Tix.Button(master, name='ok', text='OK', width=6, ! command=doDestroy) ! cancel = Tix.Button(master, name='cancel', ! text='Cancel', width=6, ! command=doDestroy) ! ok.pack(side=Tix.TOP, padx=2, pady=2) ! cancel.pack(side=Tix.TOP, padx=2, pady=2) if __name__ == '__main__': --- 105,116 ---- def createCommonButtons(master): ! ok = Tix.Button(master, name='ok', text='OK', width=6, ! command=doDestroy) ! cancel = Tix.Button(master, name='cancel', ! text='Cancel', width=6, ! command=doDestroy) ! ok.pack(side=Tix.TOP, padx=2, pady=2) ! cancel.pack(side=Tix.TOP, padx=2, pady=2) if __name__ == '__main__': Index: OptMenu.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tix/samples/OptMenu.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** OptMenu.py 17 Mar 2002 18:19:13 -0000 1.2 --- OptMenu.py 18 Jul 2004 06:10:36 -0000 1.3 *************** *** 1,4 **** # -*-mode: python; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*- ! # # $Id$ # --- 1,4 ---- # -*-mode: python; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*- ! # # $Id$ # *************** *** 17,21 **** options = {'text':'Plain Text', 'post':'PostScript', 'html':'HTML', ! 'tex':'LaTeX', 'rtf':'Rich Text Format'} def RunSample(w): --- 17,21 ---- options = {'text':'Plain Text', 'post':'PostScript', 'html':'HTML', ! 'tex':'LaTeX', 'rtf':'Rich Text Format'} def RunSample(w): *************** *** 28,47 **** from_file = Tix.OptionMenu(top, label="From File Format : ", ! variable=demo_opt_from, ! options = 'label.width 19 label.anchor e menubutton.width 15') to_file = Tix.OptionMenu(top, label="To File Format : ", ! variable=demo_opt_to, ! options='label.width 19 label.anchor e menubutton.width 15') # Add the available options to the two OptionMenu widgets # # [Hint] You have to add the options first before you set the ! # global variables "demo_opt_from" and "demo_opt_to". Otherwise ! # the OptionMenu widget will complain about "unknown options"! # for opt in options.keys(): ! from_file.add_command(opt, label=options[opt]) ! to_file.add_command(opt, label=options[opt]) demo_opt_from.set('html') --- 28,47 ---- from_file = Tix.OptionMenu(top, label="From File Format : ", ! variable=demo_opt_from, ! options = 'label.width 19 label.anchor e menubutton.width 15') to_file = Tix.OptionMenu(top, label="To File Format : ", ! variable=demo_opt_to, ! options='label.width 19 label.anchor e menubutton.width 15') # Add the available options to the two OptionMenu widgets # # [Hint] You have to add the options first before you set the ! # global variables "demo_opt_from" and "demo_opt_to". Otherwise ! # the OptionMenu widget will complain about "unknown options"! # for opt in options.keys(): ! from_file.add_command(opt, label=options[opt]) ! to_file.add_command(opt, label=options[opt]) demo_opt_from.set('html') *************** *** 53,59 **** box = Tix.ButtonBox(w, orientation=Tix.HORIZONTAL) box.add('ok', text='Ok', underline=0, width=6, ! command=lambda w=w: ok_command(w)) box.add('cancel', text='Cancel', underline=0, width=6, ! command=lambda w=w: w.destroy()) box.pack(side=Tix.BOTTOM, fill=Tix.X) top.pack(side=Tix.TOP, fill=Tix.BOTH, expand=1) --- 53,59 ---- box = Tix.ButtonBox(w, orientation=Tix.HORIZONTAL) box.add('ok', text='Ok', underline=0, width=6, ! command=lambda w=w: ok_command(w)) box.add('cancel', text='Cancel', underline=0, width=6, ! command=lambda w=w: w.destroy()) box.pack(side=Tix.BOTTOM, fill=Tix.X) top.pack(side=Tix.TOP, fill=Tix.BOTH, expand=1) Index: PanedWin.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tix/samples/PanedWin.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PanedWin.py 25 Nov 2001 14:50:55 -0000 1.1 --- PanedWin.py 18 Jul 2004 06:10:36 -0000 1.2 *************** *** 18,22 **** import Tix ! TCL_ALL_EVENTS = 0 def RunSample (root): --- 18,22 ---- import Tix ! TCL_ALL_EVENTS = 0 def RunSample (root): Index: PopMenu.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tix/samples/PopMenu.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PopMenu.py 17 Mar 2002 18:19:13 -0000 1.2 --- PopMenu.py 18 Jul 2004 06:10:36 -0000 1.3 *************** *** 1,5 **** # -*-mode: python; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*- # ! # $Id$ # # Tix Demostration Program --- 1,5 ---- # -*-mode: python; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*- # ! # $Id$ # # Tix Demostration Program *************** *** 28,34 **** p.bind_widget(but) ! # Set the entries inside the PopupMenu widget. # [Hint] You have to manipulate the "menu" subwidget. ! # $w.top.p itself is NOT a menu widget. # [Hint] Watch carefully how the sub-menu is created # --- 28,34 ---- p.bind_widget(but) ! # Set the entries inside the PopupMenu widget. # [Hint] You have to manipulate the "menu" subwidget. ! # $w.top.p itself is NOT a menu widget. # [Hint] Watch carefully how the sub-menu is created # *************** *** 46,52 **** box = Tix.ButtonBox(w, orientation=Tix.HORIZONTAL) box.add('ok', text='Ok', underline=0, width=6, ! command=lambda w=w: w.destroy()) box.add('cancel', text='Cancel', underline=0, width=6, ! command=lambda w=w: w.destroy()) box.pack(side=Tix.BOTTOM, fill=Tix.X) top.pack(side=Tix.TOP, fill=Tix.BOTH, expand=1) --- 46,52 ---- box = Tix.ButtonBox(w, orientation=Tix.HORIZONTAL) box.add('ok', text='Ok', underline=0, width=6, ! command=lambda w=w: w.destroy()) box.add('cancel', text='Cancel', underline=0, width=6, ! command=lambda w=w: w.destroy()) box.pack(side=Tix.BOTTOM, fill=Tix.X) top.pack(side=Tix.TOP, fill=Tix.BOTH, expand=1) Index: SHList1.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tix/samples/SHList1.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** SHList1.py 17 Mar 2002 18:19:13 -0000 1.3 --- SHList1.py 18 Jul 2004 06:10:36 -0000 1.4 *************** *** 1,4 **** # -*-mode: python; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*- ! # # $Id$ # --- 1,4 ---- # -*-mode: python; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*- ! # # $Id$ # *************** *** 16,20 **** import Tix ! TCL_ALL_EVENTS = 0 def RunSample (root): --- 16,20 ---- import Tix ! TCL_ALL_EVENTS = 0 def RunSample (root): *************** *** 22,26 **** shlist.mainloop() shlist.destroy() ! class DemoSHList: def __init__(self, w): --- 22,26 ---- shlist.mainloop() shlist.destroy() ! class DemoSHList: def __init__(self, w): *************** *** 30,34 **** z = w.winfo_toplevel() z.wm_protocol("WM_DELETE_WINDOW", lambda self=self: self.quitcmd()) ! # We create the frame and the ScrolledHList widget # at the top of the dialog box --- 30,34 ---- z = w.winfo_toplevel() z.wm_protocol("WM_DELETE_WINDOW", lambda self=self: self.quitcmd()) ! # We create the frame and the ScrolledHList widget # at the top of the dialog box *************** *** 62,66 **** hlist=top.a.hlist ! # Let configure the appearance of the HList subwidget # hlist.config( separator='.', width=25, drawbranch=0, indent=10) --- 62,66 ---- hlist=top.a.hlist ! # Let configure the appearance of the HList subwidget # hlist.config( separator='.', width=25, drawbranch=0, indent=10) *************** *** 72,76 **** bd=2, relief=Tix.SUNKEN ) ! hlist.add_child( itemtype=Tix.WINDOW, window=f, state=Tix.DISABLED ) --- 72,76 ---- bd=2, relief=Tix.SUNKEN ) ! hlist.add_child( itemtype=Tix.WINDOW, window=f, state=Tix.DISABLED ) *************** *** 89,99 **** # [Hint] Make sure the keys (e.g. 'boss.person') you choose ! # are unique names. If you cannot be sure of this (because of ! # the structure of your database, e.g.) you can use the ! # "add_child" command instead: # # hlist.addchild( boss, text=name) # ^^^^ ! # parent entryPath --- 89,99 ---- # [Hint] Make sure the keys (e.g. 'boss.person') you choose ! # are unique names. If you cannot be sure of this (because of ! # the structure of your database, e.g.) you can use the ! # "add_child" command instead: # # hlist.addchild( boss, text=name) # ^^^^ ! # parent entryPath *************** *** 130,132 **** root=Tix.Tk() RunSample(root) - --- 130,131 ---- Index: SHList2.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tix/samples/SHList2.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** SHList2.py 17 Mar 2002 18:19:13 -0000 1.3 --- SHList2.py 18 Jul 2004 06:10:36 -0000 1.4 *************** *** 1,4 **** # -*-mode: python; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*- ! # # $Id$ # --- 1,4 ---- # -*-mode: python; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*- ! # # $Id$ # *************** *** 14,23 **** # in the tixHList widget # ! # In a tixHList widget, you can have one ore more columns. # import Tix ! TCL_ALL_EVENTS = 0 def RunSample (root): --- 14,23 ---- # in the tixHList widget # ! # In a tixHList widget, you can have one ore more columns. # import Tix ! TCL_ALL_EVENTS = 0 def RunSample (root): *************** *** 25,29 **** shlist.mainloop() shlist.destroy() ! class DemoSHList: def __init__(self, w): --- 25,29 ---- shlist.mainloop() shlist.destroy() ! class DemoSHList: def __init__(self, w): *************** *** 33,37 **** z = w.winfo_toplevel() z.wm_protocol("WM_DELETE_WINDOW", lambda self=self: self.quitcmd()) ! # We create the frame and the ScrolledHList widget # at the top of the dialog box --- 33,37 ---- z = w.winfo_toplevel() z.wm_protocol("WM_DELETE_WINDOW", lambda self=self: self.quitcmd()) ! # We create the frame and the ScrolledHList widget # at the top of the dialog box *************** *** 48,52 **** # Create the title for the HList widget ! # >> Notice that we have set the hlist.header subwidget option to true # so that the header is displayed # --- 48,52 ---- # Create the title for the HList widget ! # >> Notice that we have set the hlist.header subwidget option to true # so that the header is displayed # *************** *** 73,92 **** # This is our little relational database # ! boss = ('doe', 'John Doe', 'Director') managers = [ ! ('jeff', 'Jeff Waxman', 'Manager'), ! ('john', 'John Lee', 'Manager'), ! ('peter', 'Peter Kenson', 'Manager') ] employees = [ ! ('alex', 'john', 'Alex Kellman', 'Clerk'), ! ('alan', 'john', 'Alan Adams', 'Clerk'), ! ('andy', 'peter', 'Andreas Crawford', 'Salesman'), ! ('doug', 'jeff', 'Douglas Bloom', 'Clerk'), ! ('jon', 'peter', 'Jon Baraki', 'Salesman'), ! ('chris', 'jeff', 'Chris Geoffrey', 'Clerk'), ! ('chuck', 'jeff', 'Chuck McLean', 'Cleaner') ] --- 73,92 ---- # This is our little relational database # ! boss = ('doe', 'John Doe', 'Director') managers = [ ! ('jeff', 'Jeff Waxman', 'Manager'), ! ('john', 'John Lee', 'Manager'), ! ('peter', 'Peter Kenson', 'Manager') ] employees = [ ! ('alex', 'john', 'Alex Kellman', 'Clerk'), ! ('alan', 'john', 'Alan Adams', 'Clerk'), ! ('andy', 'peter', 'Andreas Crawford', 'Salesman'), ! ('doug', 'jeff', 'Douglas Bloom', 'Clerk'), ! ('jon', 'peter', 'Jon Baraki', 'Salesman'), ! ('chris', 'jeff', 'Chris Geoffrey', 'Clerk'), ! ('chuck', 'jeff', 'Chuck McLean', 'Cleaner') ] *************** *** 99,103 **** style['empl_posn'] = Tix.DisplayStyle(Tix.TEXT, padx=8, refwindow=hlist) ! # Let configure the appearance of the HList subwidget # hlist.config(separator='.', width=25, drawbranch=0, indent=10) --- 99,103 ---- style['empl_posn'] = Tix.DisplayStyle(Tix.TEXT, padx=8, refwindow=hlist) ! # Let configure the appearance of the HList subwidget # hlist.config(separator='.', width=25, drawbranch=0, indent=10) *************** *** 125,132 **** # "." is the separator character we chose above ! entrypath = '.' + mgr + '.' + key # ^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^ ! # parent entryPath / child's name hlist.add(entrypath, text=name, style=style['empl_name']) --- 125,132 ---- # "." is the separator character we chose above ! entrypath = '.' + mgr + '.' + key # ^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^ ! # parent entryPath / child's name hlist.add(entrypath, text=name, style=style['empl_name']) *************** *** 167,169 **** root=Tix.Tk() RunSample(root) - --- 167,168 ---- Index: Tree.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tix/samples/Tree.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Tree.py 17 Mar 2002 18:19:13 -0000 1.2 --- Tree.py 18 Jul 2004 06:10:36 -0000 1.3 *************** *** 1,4 **** # -*-mode: python; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*- ! # # $Id$ # --- 1,4 ---- # -*-mode: python; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*- ! # # $Id$ # *************** *** 35,49 **** def adddir(tree, dir): if dir == '/': ! text = '/' else: ! text = os.path.basename(dir) tree.hlist.add(dir, itemtype=Tix.IMAGETEXT, text=text, ! image=tree.tk.call('tix', 'getimage', 'folder')) try: ! os.listdir(dir) ! tree.setmode(dir, 'open') except os.error: ! # No read permission ? ! pass # This function is called whenever the user presses the (+) indicator or --- 35,49 ---- def adddir(tree, dir): if dir == '/': ! text = '/' else: ! text = os.path.basename(dir) tree.hlist.add(dir, itemtype=Tix.IMAGETEXT, text=text, ! image=tree.tk.call('tix', 'getimage', 'folder')) try: ! os.listdir(dir) ! tree.setmode(dir, 'open') except os.error: ! # No read permission ? ! pass # This function is called whenever the user presses the (+) indicator or *************** *** 58,77 **** entries = tree.hlist.info_children(dir) if entries: ! # We have already loaded this directory. Let's just ! # show all the child entries ! # ! # Note: since we load the directory only once, it will not be ! # refreshed if the you add or remove files from this ! # directory. ! # ! for entry in entries: ! tree.hlist.show_entry(entry) files = os.listdir(dir) for file in files: ! if os.path.isdir(dir + '/' + file): ! adddir(tree, dir + '/' + file) ! else: ! tree.hlist.add(dir + '/' + file, itemtype=Tix.IMAGETEXT, text=file, ! image=tree.tk.call('tix', 'getimage', 'file')) if __name__ == '__main__': --- 58,77 ---- entries = tree.hlist.info_children(dir) if entries: ! # We have already loaded this directory. Let's just ! # show all the child entries ! # ! # Note: since we load the directory only once, it will not be ! # refreshed if the you add or remove files from this ! # directory. ! # ! for entry in entries: ! tree.hlist.show_entry(entry) files = os.listdir(dir) for file in files: ! if os.path.isdir(dir + '/' + file): ! adddir(tree, dir + '/' + file) ! else: ! tree.hlist.add(dir + '/' + file, itemtype=Tix.IMAGETEXT, text=file, ! image=tree.tk.call('tix', 'getimage', 'file')) if __name__ == '__main__': From tim_one at users.sourceforge.net Sun Jul 18 08:11:34 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 08:11:37 2004 Subject: [Python-checkins] python/dist/src/Demo/xml elem_count.py, 1.1, 1.2 roundtrip.py, 1.1, 1.2 rss2html.py, 1.1, 1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Demo/xml In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31002 Modified Files: elem_count.py roundtrip.py rss2html.py Log Message: Whitespace normalization, via reindent.py. Index: elem_count.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/xml/elem_count.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** elem_count.py 16 Oct 2000 15:27:05 -0000 1.1 --- elem_count.py 18 Jul 2004 06:11:32 -0000 1.2 *************** *** 31,35 **** print "%20s %d" % pair ! parser = make_parser() parser.setContentHandler(FancyCounter()) --- 31,35 ---- print "%20s %d" % pair ! parser = make_parser() parser.setContentHandler(FancyCounter()) Index: roundtrip.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/xml/roundtrip.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** roundtrip.py 16 Oct 2000 15:27:05 -0000 1.1 --- roundtrip.py 18 Jul 2004 06:11:32 -0000 1.2 *************** *** 17,21 **** # ContentHandler methods ! def startDocument(self): self._out.write('\n') --- 17,21 ---- # ContentHandler methods ! def startDocument(self): self._out.write('\n') *************** *** 35,39 **** def ignorableWhitespace(self, content): self._out.write(content) ! def processingInstruction(self, target, data): self._out.write('' % (target, data)) --- 35,39 ---- def ignorableWhitespace(self, content): self._out.write(content) ! def processingInstruction(self, target, data): self._out.write('' % (target, data)) Index: rss2html.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/xml/rss2html.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** rss2html.py 16 Oct 2000 15:27:05 -0000 1.1 --- rss2html.py 18 Jul 2004 06:11:32 -0000 1.2 *************** *** 81,85 **** if name == "rss": self._out.write(bottom) ! def characters(self, content): self._text = self._text + content --- 81,85 ---- if name == "rss": self._out.write(bottom) ! def characters(self, content): self._text = self._text + content From tim_one at users.sourceforge.net Sun Jul 18 08:11:58 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 08:12:01 2004 Subject: [Python-checkins] python/dist/src/Demo/zlib minigzip.py, 1.3, 1.4 zlibdemo.py, 1.2, 1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Demo/zlib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31031 Modified Files: minigzip.py zlibdemo.py Log Message: Whitespace normalization, via reindent.py. Index: minigzip.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/zlib/minigzip.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** minigzip.py 12 Mar 1999 19:07:58 -0000 1.3 --- minigzip.py 18 Jul 2004 06:11:56 -0000 1.4 *************** *** 10,14 **** output.write(chr(value & 255)) ; value=value / 256 output.write(chr(value & 255)) ! def read32(input): v=ord(input.read(1)) --- 10,14 ---- output.write(chr(value & 255)) ; value=value / 256 output.write(chr(value & 255)) ! def read32(input): v=ord(input.read(1)) *************** *** 20,26 **** import zlib, sys if len(sys.argv)!=2: ! print 'Usage: minigzip.py ' ! print ' The file will be compressed or decompressed.' ! sys.exit(0) filename=sys.argv[1] --- 20,26 ---- import zlib, sys if len(sys.argv)!=2: ! print 'Usage: minigzip.py ' ! print ' The file will be compressed or decompressed.' ! sys.exit(0) filename=sys.argv[1] *************** *** 65,69 **** if flag & FEXTRA: # Read & discard the extra field, if present ! xlen=ord(input.read(1)) xlen=xlen+256*ord(input.read(1)) input.read(xlen) --- 65,69 ---- if flag & FEXTRA: # Read & discard the extra field, if present ! xlen=ord(input.read(1)) xlen=xlen+256*ord(input.read(1)) input.read(xlen) *************** *** 93,101 **** output.write(decompdata) ; length=length+len(decompdata) crcval=zlib.crc32(decompdata, crcval) ! # We've read to the end of the file, so we have to rewind in order # to reread the 8 bytes containing the CRC and the file size. The # decompressor is smart and knows when to stop, so feeding it ! # extra data is harmless. input.seek(-8, 2) crc32=read32(input) --- 93,101 ---- output.write(decompdata) ; length=length+len(decompdata) crcval=zlib.crc32(decompdata, crcval) ! # We've read to the end of the file, so we have to rewind in order # to reread the 8 bytes containing the CRC and the file size. The # decompressor is smart and knows when to stop, so feeding it ! # extra data is harmless. input.seek(-8, 2) crc32=read32(input) *************** *** 105,107 **** input.close() ; output.close() - --- 105,106 ---- Index: zlibdemo.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/zlib/zlibdemo.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** zlibdemo.py 12 Mar 1999 19:07:59 -0000 1.2 --- zlibdemo.py 18 Jul 2004 06:11:56 -0000 1.3 *************** *** 5,9 **** else: filename='zlibdemo.py' print 'Reading', filename ! f=open(filename, 'r') # Get the data to compress s=f.read() f.close() --- 5,9 ---- else: filename='zlibdemo.py' print 'Reading', filename ! f=open(filename, 'r') # Get the data to compress s=f.read() f.close() *************** *** 25,29 **** for i in range(0, len(s), chunk): comptext=comptext+compressor.compress(s[i:i+chunk]) ! comptext=comptext+compressor.flush() # Don't forget to call flush()!! for i in range(0, len(comptext), chunk): --- 25,29 ---- for i in range(0, len(s), chunk): comptext=comptext+compressor.compress(s[i:i+chunk]) ! comptext=comptext+compressor.flush() # Don't forget to call flush()!! for i in range(0, len(comptext), chunk): *************** *** 34,36 **** print ' Original:', len(s), 'Compressed:', len(comptext), print 'Uncompressed:', len(decomp) - --- 34,35 ---- From tim_one at users.sourceforge.net Sun Jul 18 08:14:50 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 08:14:55 2004 Subject: [Python-checkins] python/dist/src/Lib/plat-mac/lib-scriptpackages/SystemEvents Disk_Folder_File_Suite.py, 1.2, 1.3 Folder_Actions_Suite.py, 1.4, 1.5 Standard_Suite.py, 1.4, 1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/plat-mac/lib-scriptpackages/SystemEvents In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31286/plat-mac/lib-scriptpackages/SystemEvents Modified Files: Disk_Folder_File_Suite.py Folder_Actions_Suite.py Standard_Suite.py Log Message: Whitespace normalization, via reindent.py. Index: Disk_Folder_File_Suite.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/lib-scriptpackages/SystemEvents/Disk_Folder_File_Suite.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Disk_Folder_File_Suite.py 13 Jun 2003 14:31:17 -0000 1.2 --- Disk_Folder_File_Suite.py 18 Jul 2004 06:14:48 -0000 1.3 *************** *** 314,332 **** } _Enum_edfm = { ! 'MS_2d_DOS_format' : 'dfms', # MS-DOS format ! 'Apple_Photo_format' : 'dfph', # Apple Photo format ! 'ISO_9660_format' : 'df96', # ISO 9660 format ! 'QuickTake_format' : 'dfqt', # QuickTake format ! 'AppleShare_format' : 'dfas', # AppleShare format ! 'High_Sierra_format' : 'dfhs', # High Sierra format ! 'Mac_OS_Extended_format' : 'dfh+', # Mac OS Extended format ! 'UDF_format' : 'dfud', # UDF format ! 'unknown_format' : 'df??', # unknown format ! 'audio_format' : 'dfau', # audio format ! 'Mac_OS_format' : 'dfhf', # Mac OS format ! 'UFS_format' : 'dfuf', # UFS format ! 'NFS_format' : 'dfnf', # NFS format ! 'ProDOS_format' : 'dfpr', # ProDOS format ! 'WebDAV_format' : 'dfwd', # WebDAV format } --- 314,332 ---- } _Enum_edfm = { ! 'MS_2d_DOS_format' : 'dfms', # MS-DOS format ! 'Apple_Photo_format' : 'dfph', # Apple Photo format ! 'ISO_9660_format' : 'df96', # ISO 9660 format ! 'QuickTake_format' : 'dfqt', # QuickTake format ! 'AppleShare_format' : 'dfas', # AppleShare format ! 'High_Sierra_format' : 'dfhs', # High Sierra format ! 'Mac_OS_Extended_format' : 'dfh+', # Mac OS Extended format ! 'UDF_format' : 'dfud', # UDF format ! 'unknown_format' : 'df??', # unknown format ! 'audio_format' : 'dfau', # audio format ! 'Mac_OS_format' : 'dfhf', # Mac OS format ! 'UFS_format' : 'dfuf', # UFS format ! 'NFS_format' : 'dfnf', # NFS format ! 'ProDOS_format' : 'dfpr', # ProDOS format ! 'WebDAV_format' : 'dfwd', # WebDAV format } Index: Folder_Actions_Suite.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/lib-scriptpackages/SystemEvents/Folder_Actions_Suite.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Folder_Actions_Suite.py 13 Jun 2003 14:31:18 -0000 1.4 --- Folder_Actions_Suite.py 18 Jul 2004 06:14:48 -0000 1.5 *************** *** 253,261 **** } _Enum_actn = { ! 'items_added' : 'fget', # items added ! 'items_removed' : 'flos', # items removed ! 'window_closed' : 'fclo', # window closed ! 'window_moved' : 'fsiz', # window moved ! 'window_opened' : 'fopn', # window opened } --- 253,261 ---- } _Enum_actn = { ! 'items_added' : 'fget', # items added ! 'items_removed' : 'flos', # items removed ! 'window_closed' : 'fclo', # window closed ! 'window_moved' : 'fsiz', # window moved ! 'window_opened' : 'fopn', # window opened } Index: Standard_Suite.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/lib-scriptpackages/SystemEvents/Standard_Suite.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Standard_Suite.py 13 Jun 2003 14:31:18 -0000 1.4 --- Standard_Suite.py 18 Jul 2004 06:14:48 -0000 1.5 *************** *** 525,531 **** """\xb3 - Greater than or equal to """ _Enum_savo = { ! 'ask' : 'ask ', # Ask the user whether or not to save the file. ! 'yes' : 'yes ', # Save the file. ! 'no' : 'no ', # Do not save the file. } --- 525,531 ---- """\xb3 - Greater than or equal to """ _Enum_savo = { ! 'ask' : 'ask ', # Ask the user whether or not to save the file. ! 'yes' : 'yes ', # Save the file. ! 'no' : 'no ', # Do not save the file. } From tim_one at users.sourceforge.net Sun Jul 18 08:14:51 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 08:14:56 2004 Subject: [Python-checkins] python/dist/src/Lib/plat-riscos rourl2path.py, 1.4, 1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/plat-riscos In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31286/plat-riscos Modified Files: rourl2path.py Log Message: Whitespace normalization, via reindent.py. Index: rourl2path.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-riscos/rourl2path.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** rourl2path.py 12 Feb 2004 17:35:10 -0000 1.4 --- rourl2path.py 18 Jul 2004 06:14:49 -0000 1.5 *************** *** 26,30 **** del components[0] else: ! components[0] = '$' # Remove . and embedded .. i = 0 --- 26,30 ---- del components[0] else: ! components[0] = '$' # Remove . and embedded .. i = 0 From tim_one at users.sourceforge.net Sun Jul 18 08:14:51 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 08:14:58 2004 Subject: [Python-checkins] python/dist/src/Lib/plat-mac/lib-scriptpackages/StdSuites AppleScript_Suite.py, 1.8, 1.9 Macintosh_Connectivity_Clas.py, 1.8, 1.9 QuickDraw_Graphics_Suite.py, 1.8, 1.9 Standard_Suite.py, 1.8, 1.9 Table_Suite.py, 1.7, 1.8 Text_Suite.py, 1.7, 1.8 __init__.py, 1.9, 1.10 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/plat-mac/lib-scriptpackages/StdSuites In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31286/plat-mac/lib-scriptpackages/StdSuites Modified Files: AppleScript_Suite.py Macintosh_Connectivity_Clas.py QuickDraw_Graphics_Suite.py Standard_Suite.py Table_Suite.py Text_Suite.py __init__.py Log Message: Whitespace normalization, via reindent.py. Index: AppleScript_Suite.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/lib-scriptpackages/StdSuites/AppleScript_Suite.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** AppleScript_Suite.py 13 Jun 2003 14:31:15 -0000 1.8 --- AppleScript_Suite.py 18 Jul 2004 06:14:47 -0000 1.9 *************** *** 1996,2057 **** } _Enum_boov = { ! 'true' : 'true', # the true boolean value ! 'false' : 'fals', # the false boolean value } _Enum_cons = { ! 'case' : 'case', # case ! 'diacriticals' : 'diac', # diacriticals ! 'white_space' : 'whit', # white space ! 'hyphens' : 'hyph', # hyphens ! 'expansion' : 'expa', # expansion ! 'punctuation' : 'punc', # punctuation ! 'application_responses' : 'rmte', # remote event replies } _Enum_eMds = { ! 'option_down' : 'Kopt', # ! 'command_down' : 'Kcmd', # ! 'control_down' : 'Kctl', # ! 'shift_down' : 'Ksft', # ! 'caps_lock_down' : 'Kclk', # } _Enum_ekst = { ! 'escape_key' : 'ks5\x00', # ! 'delete_key' : 'ks3\x00', # ! 'tab_key' : 'ks0\x00', # ! 'return_key' : 'ks$\x00', # ! 'clear_key' : 'ksG\x00', # ! 'enter_key' : 'ksL\x00', # ! 'up_arrow_key' : 'ks~\x00', # ! 'down_arrow_key' : 'ks}\x00', # ! 'left_arrow_key' : 'ks{\x00', # ! 'right_arrow_key' : 'ks|\x00', # ! 'help_key' : 'ksr\x00', # ! 'home_key' : 'kss\x00', # ! 'page_up_key' : 'kst\x00', # ! 'page_down_key' : 'ksy\x00', # ! 'forward_del_key' : 'ksu\x00', # ! 'end_key' : 'ksw\x00', # ! 'F1_key' : 'ksz\x00', # ! 'F2_key' : 'ksx\x00', # ! 'F3_key' : 'ksc\x00', # ! 'F4_key' : 'ksv\x00', # ! 'F5_key' : 'ks`\x00', # ! 'F6_key' : 'ksa\x00', # ! 'F7_key' : 'ksb\x00', # ! 'F8_key' : 'ksd\x00', # ! 'F9_key' : 'kse\x00', # ! 'F10_key' : 'ksm\x00', # ! 'F11_key' : 'ksg\x00', # ! 'F12_key' : 'kso\x00', # ! 'F13_key' : 'ksi\x00', # ! 'F14_key' : 'ksk\x00', # ! 'F15_key' : 'ksq\x00', # } _Enum_misc = { ! 'current_application' : 'cura', # the current application } --- 1996,2057 ---- } _Enum_boov = { ! 'true' : 'true', # the true boolean value ! 'false' : 'fals', # the false boolean value } _Enum_cons = { ! 'case' : 'case', # case ! 'diacriticals' : 'diac', # diacriticals ! 'white_space' : 'whit', # white space ! 'hyphens' : 'hyph', # hyphens ! 'expansion' : 'expa', # expansion ! 'punctuation' : 'punc', # punctuation ! 'application_responses' : 'rmte', # remote event replies } _Enum_eMds = { ! 'option_down' : 'Kopt', # ! 'command_down' : 'Kcmd', # ! 'control_down' : 'Kctl', # ! 'shift_down' : 'Ksft', # ! 'caps_lock_down' : 'Kclk', # } _Enum_ekst = { ! 'escape_key' : 'ks5\x00', # ! 'delete_key' : 'ks3\x00', # ! 'tab_key' : 'ks0\x00', # ! 'return_key' : 'ks$\x00', # ! 'clear_key' : 'ksG\x00', # ! 'enter_key' : 'ksL\x00', # ! 'up_arrow_key' : 'ks~\x00', # ! 'down_arrow_key' : 'ks}\x00', # ! 'left_arrow_key' : 'ks{\x00', # ! 'right_arrow_key' : 'ks|\x00', # ! 'help_key' : 'ksr\x00', # ! 'home_key' : 'kss\x00', # ! 'page_up_key' : 'kst\x00', # ! 'page_down_key' : 'ksy\x00', # ! 'forward_del_key' : 'ksu\x00', # ! 'end_key' : 'ksw\x00', # ! 'F1_key' : 'ksz\x00', # ! 'F2_key' : 'ksx\x00', # ! 'F3_key' : 'ksc\x00', # ! 'F4_key' : 'ksv\x00', # ! 'F5_key' : 'ks`\x00', # ! 'F6_key' : 'ksa\x00', # ! 'F7_key' : 'ksb\x00', # ! 'F8_key' : 'ksd\x00', # ! 'F9_key' : 'kse\x00', # ! 'F10_key' : 'ksm\x00', # ! 'F11_key' : 'ksg\x00', # ! 'F12_key' : 'kso\x00', # ! 'F13_key' : 'ksi\x00', # ! 'F14_key' : 'ksk\x00', # ! 'F15_key' : 'ksq\x00', # } _Enum_misc = { ! 'current_application' : 'cura', # the current application } Index: Macintosh_Connectivity_Clas.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/lib-scriptpackages/StdSuites/Macintosh_Connectivity_Clas.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Macintosh_Connectivity_Clas.py 13 Jun 2003 14:31:15 -0000 1.8 --- Macintosh_Connectivity_Clas.py 18 Jul 2004 06:14:48 -0000 1.9 *************** *** 254,325 **** } _Enum_econ = { ! 'ADB' : 'eadb', # ! 'printer_port' : 'ecpp', # ! 'modem_port' : 'ecmp', # ! 'modem_printer_port' : 'empp', # ! 'LocalTalk' : 'eclt', # ! 'Ethernet' : 'ecen', # ! 'Token_Ring' : 'etok', # ! 'SCSI' : 'ecsc', # ! 'USB' : 'ecus', # ! 'FireWire' : 'ecfw', # ! 'infrared' : 'ecir', # ! 'PC_card' : 'ecpc', # ! 'PCI_bus' : 'ecpi', # ! 'NuBus' : 'enub', # ! 'PDS_slot' : 'ecpd', # ! 'Comm_slot' : 'eccm', # ! 'monitor_out' : 'ecmn', # ! 'video_out' : 'ecvo', # ! 'video_in' : 'ecvi', # ! 'audio_out' : 'ecao', # ! 'audio_line_in' : 'ecai', # ! 'audio_line_out' : 'ecal', # ! 'microphone' : 'ecmi', # } _Enum_edvt = { ! 'hard_disk_drive' : 'ehd ', # ! 'floppy_disk_drive' : 'efd ', # ! 'CD_ROM_drive' : 'ecd ', # ! 'DVD_drive' : 'edvd', # ! 'storage_device' : 'edst', # ! 'keyboard' : 'ekbd', # ! 'mouse' : 'emou', # ! 'trackball' : 'etrk', # ! 'trackpad' : 'edtp', # ! 'pointing_device' : 'edpd', # ! 'video_monitor' : 'edvm', # ! 'LCD_display' : 'edlc', # ! 'display' : 'edds', # ! 'modem' : 'edmm', # ! 'PC_card' : 'ecpc', # ! 'PCI_card' : 'edpi', # ! 'NuBus_card' : 'ednb', # ! 'printer' : 'edpr', # ! 'speakers' : 'edsp', # ! 'microphone' : 'ecmi', # } _Enum_epro = { ! 'serial' : 'epsr', # ! 'AppleTalk' : 'epat', # ! 'IP' : 'epip', # ! 'SCSI' : 'ecsc', # ! 'ADB' : 'eadb', # ! 'FireWire' : 'ecfw', # ! 'IrDA' : 'epir', # ! 'IRTalk' : 'epit', # ! 'USB' : 'ecus', # ! 'PC_card' : 'ecpc', # ! 'PCI_bus' : 'ecpi', # ! 'NuBus' : 'enub', # ! 'bus' : 'ebus', # ! 'Macintosh_video' : 'epmv', # ! 'SVGA' : 'epsg', # ! 'S_video' : 'epsv', # ! 'analog_audio' : 'epau', # ! 'digital_audio' : 'epda', # ! 'PostScript' : 'epps', # } --- 254,325 ---- } _Enum_econ = { ! 'ADB' : 'eadb', # ! 'printer_port' : 'ecpp', # ! 'modem_port' : 'ecmp', # ! 'modem_printer_port' : 'empp', # ! 'LocalTalk' : 'eclt', # ! 'Ethernet' : 'ecen', # ! 'Token_Ring' : 'etok', # ! 'SCSI' : 'ecsc', # ! 'USB' : 'ecus', # ! 'FireWire' : 'ecfw', # ! 'infrared' : 'ecir', # ! 'PC_card' : 'ecpc', # ! 'PCI_bus' : 'ecpi', # ! 'NuBus' : 'enub', # ! 'PDS_slot' : 'ecpd', # ! 'Comm_slot' : 'eccm', # ! 'monitor_out' : 'ecmn', # ! 'video_out' : 'ecvo', # ! 'video_in' : 'ecvi', # ! 'audio_out' : 'ecao', # ! 'audio_line_in' : 'ecai', # ! 'audio_line_out' : 'ecal', # ! 'microphone' : 'ecmi', # } _Enum_edvt = { ! 'hard_disk_drive' : 'ehd ', # ! 'floppy_disk_drive' : 'efd ', # ! 'CD_ROM_drive' : 'ecd ', # ! 'DVD_drive' : 'edvd', # ! 'storage_device' : 'edst', # ! 'keyboard' : 'ekbd', # ! 'mouse' : 'emou', # ! 'trackball' : 'etrk', # ! 'trackpad' : 'edtp', # ! 'pointing_device' : 'edpd', # ! 'video_monitor' : 'edvm', # ! 'LCD_display' : 'edlc', # ! 'display' : 'edds', # ! 'modem' : 'edmm', # ! 'PC_card' : 'ecpc', # ! 'PCI_card' : 'edpi', # ! 'NuBus_card' : 'ednb', # ! 'printer' : 'edpr', # ! 'speakers' : 'edsp', # ! 'microphone' : 'ecmi', # } _Enum_epro = { ! 'serial' : 'epsr', # ! 'AppleTalk' : 'epat', # ! 'IP' : 'epip', # ! 'SCSI' : 'ecsc', # ! 'ADB' : 'eadb', # ! 'FireWire' : 'ecfw', # ! 'IrDA' : 'epir', # ! 'IRTalk' : 'epit', # ! 'USB' : 'ecus', # ! 'PC_card' : 'ecpc', # ! 'PCI_bus' : 'ecpi', # ! 'NuBus' : 'enub', # ! 'bus' : 'ebus', # ! 'Macintosh_video' : 'epmv', # ! 'SVGA' : 'epsg', # ! 'S_video' : 'epsv', # ! 'analog_audio' : 'epau', # ! 'digital_audio' : 'epda', # ! 'PostScript' : 'epps', # } Index: QuickDraw_Graphics_Suite.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/lib-scriptpackages/StdSuites/QuickDraw_Graphics_Suite.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** QuickDraw_Graphics_Suite.py 13 Jun 2003 14:31:16 -0000 1.8 --- QuickDraw_Graphics_Suite.py 18 Jul 2004 06:14:48 -0000 1.9 *************** *** 328,353 **** } _Enum_arro = { ! 'no_arrow' : 'arno', # No arrow on line ! 'arrow_at_start' : 'arst', # Arrow at start of line ! 'arrow_at_end' : 'aren', # Arrow at end of line ! 'arrow_at_both_ends' : 'arbo', # Arrow at both the start and the end of the line } _Enum_tran = { ! 'copy_pixels' : 'cpy ', # ! 'not_copy_pixels' : 'ncpy', # ! 'or_pixels' : 'or ', # ! 'not_or_pixels' : 'ntor', # ! 'bic_pixels' : 'bic ', # ! 'not_bic_pixels' : 'nbic', # ! 'xor_pixels' : 'xor ', # ! 'not_xor_pixels' : 'nxor', # ! 'add_over_pixels' : 'addo', # ! 'add_pin_pixels' : 'addp', # ! 'sub_over_pixels' : 'subo', # ! 'sub_pin_pixels' : 'subp', # ! 'ad_max_pixels' : 'admx', # ! 'ad_min_pixels' : 'admn', # ! 'blend_pixels' : 'blnd', # } --- 328,353 ---- } _Enum_arro = { ! 'no_arrow' : 'arno', # No arrow on line ! 'arrow_at_start' : 'arst', # Arrow at start of line ! 'arrow_at_end' : 'aren', # Arrow at end of line ! 'arrow_at_both_ends' : 'arbo', # Arrow at both the start and the end of the line } _Enum_tran = { ! 'copy_pixels' : 'cpy ', # ! 'not_copy_pixels' : 'ncpy', # ! 'or_pixels' : 'or ', # ! 'not_or_pixels' : 'ntor', # ! 'bic_pixels' : 'bic ', # ! 'not_bic_pixels' : 'nbic', # ! 'xor_pixels' : 'xor ', # ! 'not_xor_pixels' : 'nxor', # ! 'add_over_pixels' : 'addo', # ! 'add_pin_pixels' : 'addp', # ! 'sub_over_pixels' : 'subo', # ! 'sub_pin_pixels' : 'subp', # ! 'ad_max_pixels' : 'admx', # ! 'ad_min_pixels' : 'admn', # ! 'blend_pixels' : 'blnd', # } Index: Standard_Suite.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/lib-scriptpackages/StdSuites/Standard_Suite.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Standard_Suite.py 13 Jun 2003 14:31:16 -0000 1.8 --- Standard_Suite.py 18 Jul 2004 06:14:48 -0000 1.9 *************** *** 657,687 **** """\xb3 - Greater than or equal to """ _Enum_kfrm = { ! 'index' : 'indx', # keyform designating indexed access ! 'named' : 'name', # keyform designating named access ! 'id' : 'ID ', # keyform designating access by unique identifier } _Enum_savo = { ! 'yes' : 'yes ', # Save objects now ! 'no' : 'no ', # Do not save objects ! 'ask' : 'ask ', # Ask the user whether to save } _Enum_styl = { ! 'plain' : 'plan', # Plain ! 'bold' : 'bold', # Bold ! 'italic' : 'ital', # Italic ! 'outline' : 'outl', # Outline ! 'shadow' : 'shad', # Shadow ! 'underline' : 'undl', # Underline ! 'superscript' : 'spsc', # Superscript ! 'subscript' : 'sbsc', # Subscript ! 'strikethrough' : 'strk', # Strikethrough ! 'small_caps' : 'smcp', # Small caps ! 'all_caps' : 'alcp', # All capital letters ! 'all_lowercase' : 'lowc', # Lowercase ! 'condensed' : 'cond', # Condensed ! 'expanded' : 'pexp', # Expanded ! 'hidden' : 'hidn', # Hidden } --- 657,687 ---- """\xb3 - Greater than or equal to """ _Enum_kfrm = { ! 'index' : 'indx', # keyform designating indexed access ! 'named' : 'name', # keyform designating named access ! 'id' : 'ID ', # keyform designating access by unique identifier } _Enum_savo = { ! 'yes' : 'yes ', # Save objects now ! 'no' : 'no ', # Do not save objects ! 'ask' : 'ask ', # Ask the user whether to save } _Enum_styl = { ! 'plain' : 'plan', # Plain ! 'bold' : 'bold', # Bold ! 'italic' : 'ital', # Italic ! 'outline' : 'outl', # Outline ! 'shadow' : 'shad', # Shadow ! 'underline' : 'undl', # Underline ! 'superscript' : 'spsc', # Superscript ! 'subscript' : 'sbsc', # Subscript ! 'strikethrough' : 'strk', # Strikethrough ! 'small_caps' : 'smcp', # Small caps ! 'all_caps' : 'alcp', # All capital letters ! 'all_lowercase' : 'lowc', # Lowercase ! 'condensed' : 'cond', # Condensed ! 'expanded' : 'pexp', # Expanded ! 'hidden' : 'hidn', # Hidden } Index: Table_Suite.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/lib-scriptpackages/StdSuites/Table_Suite.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Table_Suite.py 13 Jun 2003 14:31:16 -0000 1.7 --- Table_Suite.py 18 Jul 2004 06:14:48 -0000 1.8 *************** *** 75,81 **** } _Enum_prtn = { ! 'read_only' : 'nmod', # Can\xd5t change values or formulas ! 'formulas_protected' : 'fpro', # Can changes values but not formulas ! 'read_2f_write' : 'modf', # Can change values and formulas } --- 75,81 ---- } _Enum_prtn = { ! 'read_only' : 'nmod', # Can\xd5t change values or formulas ! 'formulas_protected' : 'fpro', # Can changes values but not formulas ! 'read_2f_write' : 'modf', # Can change values and formulas } Index: Text_Suite.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/lib-scriptpackages/StdSuites/Text_Suite.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Text_Suite.py 13 Jun 2003 14:31:17 -0000 1.7 --- Text_Suite.py 18 Jul 2004 06:14:48 -0000 1.8 *************** *** 163,188 **** } _Enum_just = { ! 'left' : 'left', # Align with left margin ! 'right' : 'rght', # Align with right margin ! 'center' : 'cent', # Align with center ! 'full' : 'full', # Align with both left and right margins } _Enum_styl = { ! 'plain' : 'plan', # Plain ! 'bold' : 'bold', # Bold ! 'italic' : 'ital', # Italic ! 'outline' : 'outl', # Outline ! 'shadow' : 'shad', # Shadow ! 'underline' : 'undl', # Underline ! 'superscript' : 'spsc', # Superscript ! 'subscript' : 'sbsc', # Subscript ! 'strikethrough' : 'strk', # Strikethrough ! 'small_caps' : 'smcp', # Small caps ! 'all_caps' : 'alcp', # All capital letters ! 'all_lowercase' : 'lowc', # Lowercase ! 'condensed' : 'cond', # Condensed ! 'expanded' : 'pexp', # Expanded ! 'hidden' : 'hidn', # Hidden } --- 163,188 ---- } _Enum_just = { ! 'left' : 'left', # Align with left margin ! 'right' : 'rght', # Align with right margin ! 'center' : 'cent', # Align with center ! 'full' : 'full', # Align with both left and right margins } _Enum_styl = { ! 'plain' : 'plan', # Plain ! 'bold' : 'bold', # Bold ! 'italic' : 'ital', # Italic ! 'outline' : 'outl', # Outline ! 'shadow' : 'shad', # Shadow ! 'underline' : 'undl', # Underline ! 'superscript' : 'spsc', # Superscript ! 'subscript' : 'sbsc', # Subscript ! 'strikethrough' : 'strk', # Strikethrough ! 'small_caps' : 'smcp', # Small caps ! 'all_caps' : 'alcp', # All capital letters ! 'all_lowercase' : 'lowc', # Lowercase ! 'condensed' : 'cond', # Condensed ! 'expanded' : 'pexp', # Expanded ! 'hidden' : 'hidn', # Hidden } Index: __init__.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/lib-scriptpackages/StdSuites/__init__.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** __init__.py 13 Jun 2003 14:31:17 -0000 1.9 --- __init__.py 18 Jul 2004 06:14:48 -0000 1.10 *************** *** 470,472 **** _moduleName = 'StdSuites' - --- 470,471 ---- From tim_one at users.sourceforge.net Sun Jul 18 08:14:52 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 08:15:00 2004 Subject: [Python-checkins] python/dist/src/Lib/plat-unixware7 IN.py,1.1,1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/plat-unixware7 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31286/plat-unixware7 Modified Files: IN.py Log Message: Whitespace normalization, via reindent.py. Index: IN.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-unixware7/IN.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** IN.py 11 Apr 2001 20:54:43 -0000 1.1 --- IN.py 18 Jul 2004 06:14:49 -0000 1.2 *************** *** 173,181 **** # Included from sys/cdefs.h ! def __P(protos): return protos def __STRING(x): return #x ! def __P(protos): return () def __STRING(x): return "x" --- 173,181 ---- # Included from sys/cdefs.h ! def __P(protos): return protos def __STRING(x): return #x ! def __P(protos): return () def __STRING(x): return "x" *************** *** 486,490 **** def ATOMIC_INT_DECR(atomic_intp): return _ATOMIC_INT_DECR(atomic_intp) ! def FSPIN_INIT(lp): return def FSPIN_LOCK(l): return DISABLE() --- 486,490 ---- def ATOMIC_INT_DECR(atomic_intp): return _ATOMIC_INT_DECR(atomic_intp) ! def FSPIN_INIT(lp): return def FSPIN_LOCK(l): return DISABLE() *************** *** 494,506 **** def FSPIN_UNLOCK(l): return ENABLE() ! def LOCK_DEINIT(lp): return ! def LOCK_DEALLOC(lp): return def LOCK_OWNED(lp): return (B_TRUE) ! def RW_DEINIT(lp): return ! def RW_DEALLOC(lp): return def RW_OWNED(lp): return (B_TRUE) --- 494,506 ---- def FSPIN_UNLOCK(l): return ENABLE() ! def LOCK_DEINIT(lp): return ! def LOCK_DEALLOC(lp): return def LOCK_OWNED(lp): return (B_TRUE) ! def RW_DEINIT(lp): return ! def RW_DEALLOC(lp): return def RW_OWNED(lp): return (B_TRUE) *************** *** 518,522 **** def RW_WRLOCK_PLMIN(lockp): return LOCK_PLMIN(lockp) ! def LOCK_DEINIT(l): return def LOCK_PLMIN(lockp): return LOCK((lockp), PLMIN) --- 518,522 ---- def RW_WRLOCK_PLMIN(lockp): return LOCK_PLMIN(lockp) ! def LOCK_DEINIT(l): return def LOCK_PLMIN(lockp): return LOCK((lockp), PLMIN) *************** *** 538,544 **** CR_MLDREAL = 0x00000001 CR_RDUMP = 0x00000002 ! def crhold(credp): return crholdn((credp), 1) ! def crfree(credp): return crfreen((credp), 1) --- 538,544 ---- CR_MLDREAL = 0x00000001 CR_RDUMP = 0x00000002 ! def crhold(credp): return crholdn((credp), 1) ! def crfree(credp): return crfreen((credp), 1) *************** *** 824,832 **** # Included from sys/inline.h IP_HIER_BASE = (20) ! def ASSERT_LOCK(x): return ! def ASSERT_WRLOCK(x): return ! def ASSERT_UNLOCK(x): return def CANPUT(q): return canput((q)) --- 824,832 ---- # Included from sys/inline.h IP_HIER_BASE = (20) ! def ASSERT_LOCK(x): return ! def ASSERT_WRLOCK(x): return ! def ASSERT_UNLOCK(x): return def CANPUT(q): return canput((q)) From tim_one at users.sourceforge.net Sun Jul 18 08:14:52 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 08:15:01 2004 Subject: [Python-checkins] python/dist/src/Lib/xml/sax _exceptions.py, 1.10, 1.11 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/xml/sax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31286/xml/sax Modified Files: _exceptions.py Log Message: Whitespace normalization, via reindent.py. Index: _exceptions.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/xml/sax/_exceptions.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** _exceptions.py 20 Mar 2004 08:15:30 -0000 1.10 --- _exceptions.py 18 Jul 2004 06:14:50 -0000 1.11 *************** *** 94,101 **** linenum = self.getLineNumber() if linenum is None: ! linenum = "?" colnum = self.getColumnNumber() if colnum is None: ! colnum = "?" return "%s:%s:%s: %s" % (sysid, linenum, colnum, self._msg) --- 94,101 ---- linenum = self.getLineNumber() if linenum is None: ! linenum = "?" colnum = self.getColumnNumber() if colnum is None: ! colnum = "?" return "%s:%s:%s: %s" % (sysid, linenum, colnum, self._msg) From tim_one at users.sourceforge.net Sun Jul 18 08:14:52 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 08:15:03 2004 Subject: [Python-checkins] python/dist/src/Lib/plat-sunos5 IN.py, 1.3, 1.4 STROPTS.py, 1.2, 1.3 SUNAUDIODEV.py, 1.2, 1.3 TYPES.py, 1.1, 1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/plat-sunos5 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31286/plat-sunos5 Modified Files: IN.py STROPTS.py SUNAUDIODEV.py TYPES.py Log Message: Whitespace normalization, via reindent.py. Index: IN.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-sunos5/IN.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** IN.py 9 Aug 2001 12:33:32 -0000 1.3 --- IN.py 18 Jul 2004 06:14:49 -0000 1.4 *************** *** 837,841 **** TS_CREATE = 0x2000 TS_ALLSTART = \ ! (TS_CSTART|TS_UNPAUSE|TS_XSTART|TS_PSTART|TS_RESUME|TS_CREATE) def CPR_VSTOPPED(t): return \ --- 837,841 ---- TS_CREATE = 0x2000 TS_ALLSTART = \ ! (TS_CSTART|TS_UNPAUSE|TS_XSTART|TS_PSTART|TS_RESUME|TS_CREATE) def CPR_VSTOPPED(t): return \ *************** *** 1015,1025 **** AT_VCODE = 0x4000 AT_ALL = (AT_TYPE|AT_MODE|AT_UID|AT_GID|AT_FSID|AT_NODEID|\ ! AT_NLINK|AT_SIZE|AT_ATIME|AT_MTIME|AT_CTIME|\ ! AT_RDEV|AT_BLKSIZE|AT_NBLOCKS|AT_VCODE) AT_STAT = (AT_MODE|AT_UID|AT_GID|AT_FSID|AT_NODEID|AT_NLINK|\ ! AT_SIZE|AT_ATIME|AT_MTIME|AT_CTIME|AT_RDEV) AT_TIMES = (AT_ATIME|AT_MTIME|AT_CTIME) AT_NOSET = (AT_NLINK|AT_RDEV|AT_FSID|AT_NODEID|AT_TYPE|\ ! AT_BLKSIZE|AT_NBLOCKS|AT_VCODE) VSUID = 04000 VSGID = 02000 --- 1015,1025 ---- AT_VCODE = 0x4000 AT_ALL = (AT_TYPE|AT_MODE|AT_UID|AT_GID|AT_FSID|AT_NODEID|\ ! AT_NLINK|AT_SIZE|AT_ATIME|AT_MTIME|AT_CTIME|\ ! AT_RDEV|AT_BLKSIZE|AT_NBLOCKS|AT_VCODE) AT_STAT = (AT_MODE|AT_UID|AT_GID|AT_FSID|AT_NODEID|AT_NLINK|\ ! AT_SIZE|AT_ATIME|AT_MTIME|AT_CTIME|AT_RDEV) AT_TIMES = (AT_ATIME|AT_MTIME|AT_CTIME) AT_NOSET = (AT_NLINK|AT_RDEV|AT_FSID|AT_NODEID|AT_TYPE|\ ! AT_BLKSIZE|AT_NBLOCKS|AT_VCODE) VSUID = 04000 VSGID = 02000 Index: STROPTS.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-sunos5/STROPTS.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** STROPTS.py 9 Aug 2001 12:33:32 -0000 1.2 --- STROPTS.py 18 Jul 2004 06:14:49 -0000 1.3 *************** *** 834,838 **** TS_CREATE = 0x2000 TS_ALLSTART = \ ! (TS_CSTART|TS_UNPAUSE|TS_XSTART|TS_PSTART|TS_RESUME|TS_CREATE) def CPR_VSTOPPED(t): return \ --- 834,838 ---- TS_CREATE = 0x2000 TS_ALLSTART = \ ! (TS_CSTART|TS_UNPAUSE|TS_XSTART|TS_PSTART|TS_RESUME|TS_CREATE) def CPR_VSTOPPED(t): return \ *************** *** 1394,1404 **** AT_VCODE = 0x4000 AT_ALL = (AT_TYPE|AT_MODE|AT_UID|AT_GID|AT_FSID|AT_NODEID|\ ! AT_NLINK|AT_SIZE|AT_ATIME|AT_MTIME|AT_CTIME|\ ! AT_RDEV|AT_BLKSIZE|AT_NBLOCKS|AT_VCODE) AT_STAT = (AT_MODE|AT_UID|AT_GID|AT_FSID|AT_NODEID|AT_NLINK|\ ! AT_SIZE|AT_ATIME|AT_MTIME|AT_CTIME|AT_RDEV) AT_TIMES = (AT_ATIME|AT_MTIME|AT_CTIME) AT_NOSET = (AT_NLINK|AT_RDEV|AT_FSID|AT_NODEID|AT_TYPE|\ ! AT_BLKSIZE|AT_NBLOCKS|AT_VCODE) VSUID = 04000 VSGID = 02000 --- 1394,1404 ---- AT_VCODE = 0x4000 AT_ALL = (AT_TYPE|AT_MODE|AT_UID|AT_GID|AT_FSID|AT_NODEID|\ ! AT_NLINK|AT_SIZE|AT_ATIME|AT_MTIME|AT_CTIME|\ ! AT_RDEV|AT_BLKSIZE|AT_NBLOCKS|AT_VCODE) AT_STAT = (AT_MODE|AT_UID|AT_GID|AT_FSID|AT_NODEID|AT_NLINK|\ ! AT_SIZE|AT_ATIME|AT_MTIME|AT_CTIME|AT_RDEV) AT_TIMES = (AT_ATIME|AT_MTIME|AT_CTIME) AT_NOSET = (AT_NLINK|AT_RDEV|AT_FSID|AT_NODEID|AT_TYPE|\ ! AT_BLKSIZE|AT_NBLOCKS|AT_VCODE) VSUID = 04000 VSGID = 02000 *************** *** 1683,1694 **** DDI_PROP_TYPE_BYTE = 0x0400 DDI_PROP_TYPE_COMPOSITE = 0x0800 ! DDI_PROP_TYPE_ANY = (DDI_PROP_TYPE_INT | \ ! DDI_PROP_TYPE_STRING | \ ! DDI_PROP_TYPE_BYTE | \ ! DDI_PROP_TYPE_COMPOSITE) ! DDI_PROP_TYPE_MASK = (DDI_PROP_TYPE_INT | \ ! DDI_PROP_TYPE_STRING | \ ! DDI_PROP_TYPE_BYTE | \ ! DDI_PROP_TYPE_COMPOSITE) DDI_RELATIVE_ADDRESSING = "relative-addressing" DDI_GENERIC_ADDRESSING = "generic-addressing" --- 1683,1694 ---- DDI_PROP_TYPE_BYTE = 0x0400 DDI_PROP_TYPE_COMPOSITE = 0x0800 ! DDI_PROP_TYPE_ANY = (DDI_PROP_TYPE_INT | \ ! DDI_PROP_TYPE_STRING | \ ! DDI_PROP_TYPE_BYTE | \ ! DDI_PROP_TYPE_COMPOSITE) ! DDI_PROP_TYPE_MASK = (DDI_PROP_TYPE_INT | \ ! DDI_PROP_TYPE_STRING | \ ! DDI_PROP_TYPE_BYTE | \ ! DDI_PROP_TYPE_COMPOSITE) DDI_RELATIVE_ADDRESSING = "relative-addressing" DDI_GENERIC_ADDRESSING = "generic-addressing" *************** *** 1705,1709 **** DEVMAP_USE_PAGESIZE = 0x04 DEVMAP_SETUP_FLAGS = \ ! (DEVMAP_MAPPING_INVALID | DEVMAP_ALLOW_REMAP | DEVMAP_USE_PAGESIZE) DEVMAP_SETUP_DONE = 0x100 DEVMAP_LOCK_INITED = 0x200 --- 1705,1709 ---- DEVMAP_USE_PAGESIZE = 0x04 DEVMAP_SETUP_FLAGS = \ ! (DEVMAP_MAPPING_INVALID | DEVMAP_ALLOW_REMAP | DEVMAP_USE_PAGESIZE) DEVMAP_SETUP_DONE = 0x100 DEVMAP_LOCK_INITED = 0x200 Index: SUNAUDIODEV.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-sunos5/SUNAUDIODEV.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** SUNAUDIODEV.py 24 Sep 1998 18:09:47 -0000 1.2 --- SUNAUDIODEV.py 18 Jul 2004 06:14:49 -0000 1.3 *************** *** 7,25 **** # Encoding types, for fields i_encoding and o_encoding ! ENCODING_NONE = 0 # no encoding assigned ! ENCODING_ULAW = 1 # u-law encoding ! ENCODING_ALAW = 2 # A-law encoding ! ENCODING_LINEAR = 3 # Linear PCM encoding # Gain ranges for i_gain, o_gain and monitor_gain ! MIN_GAIN = 0 # minimum gain value ! MAX_GAIN = 255 # maximum gain value # Balance values for i_balance and o_balance ! LEFT_BALANCE = 0 # left channel only ! MID_BALANCE = 32 # equal left/right channel ! RIGHT_BALANCE = 64 # right channel only BALANCE_SHIFT = 3 --- 7,25 ---- # Encoding types, for fields i_encoding and o_encoding ! ENCODING_NONE = 0 # no encoding assigned ! ENCODING_ULAW = 1 # u-law encoding ! ENCODING_ALAW = 2 # A-law encoding ! ENCODING_LINEAR = 3 # Linear PCM encoding # Gain ranges for i_gain, o_gain and monitor_gain ! MIN_GAIN = 0 # minimum gain value ! MAX_GAIN = 255 # maximum gain value # Balance values for i_balance and o_balance ! LEFT_BALANCE = 0 # left channel only ! MID_BALANCE = 32 # equal left/right channel ! RIGHT_BALANCE = 64 # right channel only BALANCE_SHIFT = 3 *************** *** 31,40 **** PORT_D = 4 ! SPEAKER = 0x01 # output to built-in speaker ! HEADPHONE = 0x02 # output to headphone jack ! LINE_OUT = 0x04 # output to line out ! MICROPHONE = 0x01 # input from microphone ! LINE_IN = 0x02 # input from line in CD = 0x04 # input from on-board CD inputs INTERNAL_CD_IN = CD # input from internal CDROM --- 31,40 ---- PORT_D = 4 ! SPEAKER = 0x01 # output to built-in speaker ! HEADPHONE = 0x02 # output to headphone jack ! LINE_OUT = 0x04 # output to line out ! MICROPHONE = 0x01 # input from microphone ! LINE_IN = 0x02 # input from line in CD = 0x04 # input from on-board CD inputs INTERNAL_CD_IN = CD # input from internal CDROM Index: TYPES.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-sunos5/TYPES.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TYPES.py 9 Aug 2001 12:33:32 -0000 1.1 --- TYPES.py 18 Jul 2004 06:14:49 -0000 1.2 *************** *** 312,314 **** NBBY = _NBBY def FD_ZERO(p): return bzero((p), sizeof (*(p))) - --- 312,313 ---- From tim_one at users.sourceforge.net Sun Jul 18 08:15:14 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 08:15:16 2004 Subject: [Python-checkins] python/dist/src/Lib/bsddb/test test_basics.py, 1.12, 1.13 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/bsddb/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31286/bsddb/test Modified Files: test_basics.py Log Message: Whitespace normalization, via reindent.py. Index: test_basics.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/bsddb/test/test_basics.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** test_basics.py 26 Feb 2004 10:07:14 -0000 1.12 --- test_basics.py 18 Jul 2004 06:14:41 -0000 1.13 *************** *** 302,306 **** txn = None c = self.d.cursor(txn=txn) ! rec = c.first() count = 0 --- 302,306 ---- txn = None c = self.d.cursor(txn=txn) ! rec = c.first() count = 0 *************** *** 319,323 **** self.fail("unexpected DBNotFoundError") assert c.get_current_size() == len(c.current()[1]), "%s != len(%r)" % (c.get_current_size(), c.current()[1]) ! assert count == self._numKeys --- 319,323 ---- self.fail("unexpected DBNotFoundError") assert c.get_current_size() == len(c.current()[1]), "%s != len(%r)" % (c.get_current_size(), c.current()[1]) ! assert count == self._numKeys *************** *** 352,356 **** assert rec[1] == '' assert c.get_current_size() == 0 ! try: n = c.set('bad key') --- 352,356 ---- assert rec[1] == '' assert c.get_current_size() == 0 ! try: n = c.set('bad key') From tim_one at users.sourceforge.net Sun Jul 18 08:15:14 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 08:15:19 2004 Subject: [Python-checkins] python/dist/src/Lib _threading_local.py, 1.2, 1.3 asyncore.py, 1.58, 1.59 cgitb.py, 1.14, 1.15 dummy_threading.py, 1.2, 1.3 posixpath.py, 1.68, 1.69 urllib.py, 1.163, 1.164 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31286 Modified Files: _threading_local.py asyncore.py cgitb.py dummy_threading.py posixpath.py urllib.py Log Message: Whitespace normalization, via reindent.py. Index: _threading_local.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/_threading_local.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** _threading_local.py 15 Jul 2004 12:17:26 -0000 1.2 --- _threading_local.py 18 Jul 2004 06:14:41 -0000 1.3 *************** *** 82,86 **** an initial color: ! >>> mydata.color 'red' --- 82,86 ---- an initial color: ! >>> mydata.color 'red' *************** *** 217,221 **** # shutdown, we'll skip cleanup under the assumption # that there is nothing to clean up ! return for thread in threads: --- 217,221 ---- # shutdown, we'll skip cleanup under the assumption # that there is nothing to clean up ! return for thread in threads: *************** *** 229,233 **** try: del __dict__[key] ! except KeyError: pass # didn't have anything in this thread --- 229,233 ---- try: del __dict__[key] ! except KeyError: pass # didn't have anything in this thread Index: asyncore.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/asyncore.py,v retrieving revision 1.58 retrieving revision 1.59 diff -C2 -d -r1.58 -r1.59 *** asyncore.py 15 Jul 2004 16:17:07 -0000 1.58 --- asyncore.py 18 Jul 2004 06:14:41 -0000 1.59 *************** *** 269,273 **** else: reuse_constant = socket.SO_REUSEADDR ! self.socket.setsockopt( socket.SOL_SOCKET, reuse_constant, --- 269,273 ---- else: reuse_constant = socket.SO_REUSEADDR ! self.socket.setsockopt( socket.SOL_SOCKET, reuse_constant, *************** *** 277,281 **** except socket.error: pass ! # ================================================== # predicates for select() --- 277,281 ---- except socket.error: pass ! # ================================================== # predicates for select() Index: cgitb.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/cgitb.py,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** cgitb.py 10 Jul 2004 14:14:51 -0000 1.14 --- cgitb.py 18 Jul 2004 06:14:41 -0000 1.15 *************** *** 43,47 **** else: return '' ! def strong(text): if text: --- 43,47 ---- else: return '' ! def strong(text): if text: *************** *** 49,53 **** else: return '' ! def grey(text): if text: --- 49,53 ---- else: return '' ! def grey(text): if text: Index: dummy_threading.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/dummy_threading.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** dummy_threading.py 14 Jul 2004 19:11:50 -0000 1.2 --- dummy_threading.py 18 Jul 2004 06:14:41 -0000 1.3 *************** *** 47,51 **** holding__threading_local = True del sys_modules['_threading_local'] ! import threading # Need a copy of the code kept somewhere... --- 47,51 ---- holding__threading_local = True del sys_modules['_threading_local'] ! import threading # Need a copy of the code kept somewhere... Index: posixpath.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/posixpath.py,v retrieving revision 1.68 retrieving revision 1.69 diff -C2 -d -r1.68 -r1.69 *** posixpath.py 11 Jul 2004 19:16:21 -0000 1.68 --- posixpath.py 18 Jul 2004 06:14:41 -0000 1.69 *************** *** 421,425 **** def _resolve_link(path): """Internal helper function. Takes a path and follows symlinks ! until we either arrive at something that isn't a symlink, or encounter a path we've seen before (meaning that there's a loop). """ --- 421,425 ---- def _resolve_link(path): """Internal helper function. Takes a path and follows symlinks ! until we either arrive at something that isn't a symlink, or encounter a path we've seen before (meaning that there's a loop). """ Index: urllib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/urllib.py,v retrieving revision 1.163 retrieving revision 1.164 diff -C2 -d -r1.163 -r1.164 *** urllib.py 16 Jul 2004 11:45:00 -0000 1.163 --- urllib.py 18 Jul 2004 06:14:41 -0000 1.164 *************** *** 1224,1228 **** def getproxies(): return getproxies_environment() or getproxies_internetconfig() ! elif os.name == 'nt': def getproxies_registry(): --- 1224,1228 ---- def getproxies(): return getproxies_environment() or getproxies_internetconfig() ! elif os.name == 'nt': def getproxies_registry(): From tim_one at users.sourceforge.net Sun Jul 18 08:15:14 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 08:15:21 2004 Subject: [Python-checkins] python/dist/src/Lib/curses __init__.py, 1.4, 1.5 has_key.py, 1.4, 1.5 panel.py, 1.1, 1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/curses In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31286/curses Modified Files: __init__.py has_key.py panel.py Log Message: Whitespace normalization, via reindent.py. Index: __init__.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/curses/__init__.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** __init__.py 5 Apr 2001 16:08:41 -0000 1.4 --- __init__.py 18 Jul 2004 06:14:41 -0000 1.5 *************** *** 8,12 **** curses.initwin() ... ! """ --- 8,12 ---- curses.initwin() ... ! """ *************** *** 30,34 **** if key[0:4] == 'ACS_' or key in ('LINES', 'COLS'): setattr(curses, key, value) ! return stdscr --- 30,34 ---- if key[0:4] == 'ACS_' or key in ('LINES', 'COLS'): setattr(curses, key, value) ! return stdscr *************** *** 36,40 **** # COLOR_PAIRS variables which are only available after start_color() is # called. ! def start_color(): import _curses, curses --- 36,40 ---- # COLOR_PAIRS variables which are only available after start_color() is # called. ! def start_color(): import _curses, curses *************** *** 44,48 **** if hasattr(_curses, 'COLOR_PAIRS'): curses.COLOR_PAIRS = _curses.COLOR_PAIRS ! return retval # Import Python has_key() implementation if _curses doesn't contain has_key() --- 44,48 ---- if hasattr(_curses, 'COLOR_PAIRS'): curses.COLOR_PAIRS = _curses.COLOR_PAIRS ! return retval # Import Python has_key() implementation if _curses doesn't contain has_key() *************** *** 52,54 **** except NameError: from has_key import has_key - --- 52,53 ---- Index: has_key.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/curses/has_key.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** has_key.py 2 Sep 2003 11:52:06 -0000 1.4 --- has_key.py 18 Jul 2004 06:14:41 -0000 1.5 *************** *** 9,160 **** _capability_names = { ! _curses.KEY_A1: 'ka1', ! _curses.KEY_A3: 'ka3', ! _curses.KEY_B2: 'kb2', ! _curses.KEY_BACKSPACE: 'kbs', ! _curses.KEY_BEG: 'kbeg', ! _curses.KEY_BTAB: 'kcbt', ! _curses.KEY_C1: 'kc1', ! _curses.KEY_C3: 'kc3', ! _curses.KEY_CANCEL: 'kcan', ! _curses.KEY_CATAB: 'ktbc', ! _curses.KEY_CLEAR: 'kclr', ! _curses.KEY_CLOSE: 'kclo', ! _curses.KEY_COMMAND: 'kcmd', ! _curses.KEY_COPY: 'kcpy', ! _curses.KEY_CREATE: 'kcrt', ! _curses.KEY_CTAB: 'kctab', ! _curses.KEY_DC: 'kdch1', ! _curses.KEY_DL: 'kdl1', ! _curses.KEY_DOWN: 'kcud1', ! _curses.KEY_EIC: 'krmir', ! _curses.KEY_END: 'kend', ! _curses.KEY_ENTER: 'kent', ! _curses.KEY_EOL: 'kel', ! _curses.KEY_EOS: 'ked', ! _curses.KEY_EXIT: 'kext', ! _curses.KEY_F0: 'kf0', ! _curses.KEY_F1: 'kf1', ! _curses.KEY_F10: 'kf10', ! _curses.KEY_F11: 'kf11', ! _curses.KEY_F12: 'kf12', ! _curses.KEY_F13: 'kf13', ! _curses.KEY_F14: 'kf14', ! _curses.KEY_F15: 'kf15', ! _curses.KEY_F16: 'kf16', ! _curses.KEY_F17: 'kf17', ! _curses.KEY_F18: 'kf18', ! _curses.KEY_F19: 'kf19', ! _curses.KEY_F2: 'kf2', ! _curses.KEY_F20: 'kf20', ! _curses.KEY_F21: 'kf21', ! _curses.KEY_F22: 'kf22', ! _curses.KEY_F23: 'kf23', ! _curses.KEY_F24: 'kf24', ! _curses.KEY_F25: 'kf25', ! _curses.KEY_F26: 'kf26', ! _curses.KEY_F27: 'kf27', ! _curses.KEY_F28: 'kf28', ! _curses.KEY_F29: 'kf29', ! _curses.KEY_F3: 'kf3', ! _curses.KEY_F30: 'kf30', ! _curses.KEY_F31: 'kf31', ! _curses.KEY_F32: 'kf32', ! _curses.KEY_F33: 'kf33', ! _curses.KEY_F34: 'kf34', ! _curses.KEY_F35: 'kf35', ! _curses.KEY_F36: 'kf36', ! _curses.KEY_F37: 'kf37', ! _curses.KEY_F38: 'kf38', ! _curses.KEY_F39: 'kf39', ! _curses.KEY_F4: 'kf4', ! _curses.KEY_F40: 'kf40', ! _curses.KEY_F41: 'kf41', ! _curses.KEY_F42: 'kf42', ! _curses.KEY_F43: 'kf43', ! _curses.KEY_F44: 'kf44', ! _curses.KEY_F45: 'kf45', ! _curses.KEY_F46: 'kf46', ! _curses.KEY_F47: 'kf47', ! _curses.KEY_F48: 'kf48', ! _curses.KEY_F49: 'kf49', ! _curses.KEY_F5: 'kf5', ! _curses.KEY_F50: 'kf50', ! _curses.KEY_F51: 'kf51', ! _curses.KEY_F52: 'kf52', ! _curses.KEY_F53: 'kf53', ! _curses.KEY_F54: 'kf54', ! _curses.KEY_F55: 'kf55', ! _curses.KEY_F56: 'kf56', ! _curses.KEY_F57: 'kf57', ! _curses.KEY_F58: 'kf58', ! _curses.KEY_F59: 'kf59', ! _curses.KEY_F6: 'kf6', ! _curses.KEY_F60: 'kf60', ! _curses.KEY_F61: 'kf61', ! _curses.KEY_F62: 'kf62', ! _curses.KEY_F63: 'kf63', ! _curses.KEY_F7: 'kf7', ! _curses.KEY_F8: 'kf8', ! _curses.KEY_F9: 'kf9', ! _curses.KEY_FIND: 'kfnd', ! _curses.KEY_HELP: 'khlp', ! _curses.KEY_HOME: 'khome', ! _curses.KEY_IC: 'kich1', ! _curses.KEY_IL: 'kil1', ! _curses.KEY_LEFT: 'kcub1', ! _curses.KEY_LL: 'kll', ! _curses.KEY_MARK: 'kmrk', ! _curses.KEY_MESSAGE: 'kmsg', ! _curses.KEY_MOVE: 'kmov', ! _curses.KEY_NEXT: 'knxt', ! _curses.KEY_NPAGE: 'knp', ! _curses.KEY_OPEN: 'kopn', ! _curses.KEY_OPTIONS: 'kopt', ! _curses.KEY_PPAGE: 'kpp', ! _curses.KEY_PREVIOUS: 'kprv', ! _curses.KEY_PRINT: 'kprt', ! _curses.KEY_REDO: 'krdo', ! _curses.KEY_REFERENCE: 'kref', ! _curses.KEY_REFRESH: 'krfr', ! _curses.KEY_REPLACE: 'krpl', ! _curses.KEY_RESTART: 'krst', ! _curses.KEY_RESUME: 'kres', ! _curses.KEY_RIGHT: 'kcuf1', ! _curses.KEY_SAVE: 'ksav', ! _curses.KEY_SBEG: 'kBEG', ! _curses.KEY_SCANCEL: 'kCAN', ! _curses.KEY_SCOMMAND: 'kCMD', ! _curses.KEY_SCOPY: 'kCPY', ! _curses.KEY_SCREATE: 'kCRT', ! _curses.KEY_SDC: 'kDC', ! _curses.KEY_SDL: 'kDL', ! _curses.KEY_SELECT: 'kslt', ! _curses.KEY_SEND: 'kEND', ! _curses.KEY_SEOL: 'kEOL', ! _curses.KEY_SEXIT: 'kEXT', ! _curses.KEY_SF: 'kind', ! _curses.KEY_SFIND: 'kFND', ! _curses.KEY_SHELP: 'kHLP', ! _curses.KEY_SHOME: 'kHOM', ! _curses.KEY_SIC: 'kIC', ! _curses.KEY_SLEFT: 'kLFT', ! _curses.KEY_SMESSAGE: 'kMSG', ! _curses.KEY_SMOVE: 'kMOV', ! _curses.KEY_SNEXT: 'kNXT', ! _curses.KEY_SOPTIONS: 'kOPT', ! _curses.KEY_SPREVIOUS: 'kPRV', ! _curses.KEY_SPRINT: 'kPRT', ! _curses.KEY_SR: 'kri', ! _curses.KEY_SREDO: 'kRDO', ! _curses.KEY_SREPLACE: 'kRPL', ! _curses.KEY_SRIGHT: 'kRIT', ! _curses.KEY_SRSUME: 'kRES', ! _curses.KEY_SSAVE: 'kSAV', ! _curses.KEY_SSUSPEND: 'kSPD', ! _curses.KEY_STAB: 'khts', ! _curses.KEY_SUNDO: 'kUND', ! _curses.KEY_SUSPEND: 'kspd', ! _curses.KEY_UNDO: 'kund', _curses.KEY_UP: 'kcuu1' } --- 9,160 ---- _capability_names = { ! _curses.KEY_A1: 'ka1', ! _curses.KEY_A3: 'ka3', ! _curses.KEY_B2: 'kb2', ! _curses.KEY_BACKSPACE: 'kbs', ! _curses.KEY_BEG: 'kbeg', ! _curses.KEY_BTAB: 'kcbt', ! _curses.KEY_C1: 'kc1', ! _curses.KEY_C3: 'kc3', ! _curses.KEY_CANCEL: 'kcan', ! _curses.KEY_CATAB: 'ktbc', ! _curses.KEY_CLEAR: 'kclr', ! _curses.KEY_CLOSE: 'kclo', ! _curses.KEY_COMMAND: 'kcmd', ! _curses.KEY_COPY: 'kcpy', ! _curses.KEY_CREATE: 'kcrt', ! _curses.KEY_CTAB: 'kctab', ! _curses.KEY_DC: 'kdch1', ! _curses.KEY_DL: 'kdl1', ! _curses.KEY_DOWN: 'kcud1', ! _curses.KEY_EIC: 'krmir', ! _curses.KEY_END: 'kend', ! _curses.KEY_ENTER: 'kent', ! _curses.KEY_EOL: 'kel', ! _curses.KEY_EOS: 'ked', ! _curses.KEY_EXIT: 'kext', ! _curses.KEY_F0: 'kf0', ! _curses.KEY_F1: 'kf1', ! _curses.KEY_F10: 'kf10', ! _curses.KEY_F11: 'kf11', ! _curses.KEY_F12: 'kf12', ! _curses.KEY_F13: 'kf13', ! _curses.KEY_F14: 'kf14', ! _curses.KEY_F15: 'kf15', ! _curses.KEY_F16: 'kf16', ! _curses.KEY_F17: 'kf17', ! _curses.KEY_F18: 'kf18', ! _curses.KEY_F19: 'kf19', ! _curses.KEY_F2: 'kf2', ! _curses.KEY_F20: 'kf20', ! _curses.KEY_F21: 'kf21', ! _curses.KEY_F22: 'kf22', ! _curses.KEY_F23: 'kf23', ! _curses.KEY_F24: 'kf24', ! _curses.KEY_F25: 'kf25', ! _curses.KEY_F26: 'kf26', ! _curses.KEY_F27: 'kf27', ! _curses.KEY_F28: 'kf28', ! _curses.KEY_F29: 'kf29', ! _curses.KEY_F3: 'kf3', ! _curses.KEY_F30: 'kf30', ! _curses.KEY_F31: 'kf31', ! _curses.KEY_F32: 'kf32', ! _curses.KEY_F33: 'kf33', ! _curses.KEY_F34: 'kf34', ! _curses.KEY_F35: 'kf35', ! _curses.KEY_F36: 'kf36', ! _curses.KEY_F37: 'kf37', ! _curses.KEY_F38: 'kf38', ! _curses.KEY_F39: 'kf39', ! _curses.KEY_F4: 'kf4', ! _curses.KEY_F40: 'kf40', ! _curses.KEY_F41: 'kf41', ! _curses.KEY_F42: 'kf42', ! _curses.KEY_F43: 'kf43', ! _curses.KEY_F44: 'kf44', ! _curses.KEY_F45: 'kf45', ! _curses.KEY_F46: 'kf46', ! _curses.KEY_F47: 'kf47', ! _curses.KEY_F48: 'kf48', ! _curses.KEY_F49: 'kf49', ! _curses.KEY_F5: 'kf5', ! _curses.KEY_F50: 'kf50', ! _curses.KEY_F51: 'kf51', ! _curses.KEY_F52: 'kf52', ! _curses.KEY_F53: 'kf53', ! _curses.KEY_F54: 'kf54', ! _curses.KEY_F55: 'kf55', ! _curses.KEY_F56: 'kf56', ! _curses.KEY_F57: 'kf57', ! _curses.KEY_F58: 'kf58', ! _curses.KEY_F59: 'kf59', ! _curses.KEY_F6: 'kf6', ! _curses.KEY_F60: 'kf60', ! _curses.KEY_F61: 'kf61', ! _curses.KEY_F62: 'kf62', ! _curses.KEY_F63: 'kf63', ! _curses.KEY_F7: 'kf7', ! _curses.KEY_F8: 'kf8', ! _curses.KEY_F9: 'kf9', ! _curses.KEY_FIND: 'kfnd', ! _curses.KEY_HELP: 'khlp', ! _curses.KEY_HOME: 'khome', ! _curses.KEY_IC: 'kich1', ! _curses.KEY_IL: 'kil1', ! _curses.KEY_LEFT: 'kcub1', ! _curses.KEY_LL: 'kll', ! _curses.KEY_MARK: 'kmrk', ! _curses.KEY_MESSAGE: 'kmsg', ! _curses.KEY_MOVE: 'kmov', ! _curses.KEY_NEXT: 'knxt', ! _curses.KEY_NPAGE: 'knp', ! _curses.KEY_OPEN: 'kopn', ! _curses.KEY_OPTIONS: 'kopt', ! _curses.KEY_PPAGE: 'kpp', ! _curses.KEY_PREVIOUS: 'kprv', ! _curses.KEY_PRINT: 'kprt', ! _curses.KEY_REDO: 'krdo', ! _curses.KEY_REFERENCE: 'kref', ! _curses.KEY_REFRESH: 'krfr', ! _curses.KEY_REPLACE: 'krpl', ! _curses.KEY_RESTART: 'krst', ! _curses.KEY_RESUME: 'kres', ! _curses.KEY_RIGHT: 'kcuf1', ! _curses.KEY_SAVE: 'ksav', ! _curses.KEY_SBEG: 'kBEG', ! _curses.KEY_SCANCEL: 'kCAN', ! _curses.KEY_SCOMMAND: 'kCMD', ! _curses.KEY_SCOPY: 'kCPY', ! _curses.KEY_SCREATE: 'kCRT', ! _curses.KEY_SDC: 'kDC', ! _curses.KEY_SDL: 'kDL', ! _curses.KEY_SELECT: 'kslt', ! _curses.KEY_SEND: 'kEND', ! _curses.KEY_SEOL: 'kEOL', ! _curses.KEY_SEXIT: 'kEXT', ! _curses.KEY_SF: 'kind', ! _curses.KEY_SFIND: 'kFND', ! _curses.KEY_SHELP: 'kHLP', ! _curses.KEY_SHOME: 'kHOM', ! _curses.KEY_SIC: 'kIC', ! _curses.KEY_SLEFT: 'kLFT', ! _curses.KEY_SMESSAGE: 'kMSG', ! _curses.KEY_SMOVE: 'kMOV', ! _curses.KEY_SNEXT: 'kNXT', ! _curses.KEY_SOPTIONS: 'kOPT', ! _curses.KEY_SPREVIOUS: 'kPRV', ! _curses.KEY_SPRINT: 'kPRT', ! _curses.KEY_SR: 'kri', ! _curses.KEY_SREDO: 'kRDO', ! _curses.KEY_SREPLACE: 'kRPL', ! _curses.KEY_SRIGHT: 'kRIT', ! _curses.KEY_SRSUME: 'kRES', ! _curses.KEY_SSAVE: 'kSAV', ! _curses.KEY_SSUSPEND: 'kSPD', ! _curses.KEY_STAB: 'khts', ! _curses.KEY_SUNDO: 'kUND', ! _curses.KEY_SUSPEND: 'kspd', ! _curses.KEY_UNDO: 'kund', _curses.KEY_UP: 'kcuu1' } *************** *** 191,194 **** _curses.endwin() for i in L: print i - - --- 191,192 ---- Index: panel.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/curses/panel.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** panel.py 22 Dec 2000 21:58:29 -0000 1.1 --- panel.py 18 Jul 2004 06:14:41 -0000 1.2 *************** *** 7,9 **** from _curses_panel import * - --- 7,8 ---- From tim_one at users.sourceforge.net Sun Jul 18 08:15:16 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 08:15:22 2004 Subject: [Python-checkins] python/dist/src/Lib/distutils/command bdist.py, 1.28, 1.29 bdist_dumb.py, 1.23, 1.24 bdist_wininst.py, 1.49, 1.50 build_ext.py, 1.95, 1.96 build_scripts.py, 1.22, 1.23 install.py, 1.69, 1.70 register.py, 1.6, 1.7 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils/command In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31286/distutils/command Modified Files: bdist.py bdist_dumb.py bdist_wininst.py build_ext.py build_scripts.py install.py register.py Log Message: Whitespace normalization, via reindent.py. Index: bdist.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/bdist.py,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** bdist.py 19 Nov 2002 13:12:28 -0000 1.28 --- bdist.py 18 Jul 2004 06:14:42 -0000 1.29 *************** *** 79,83 **** "Windows executable installer"), 'zip': ('bdist_dumb', "ZIP file"), ! #'pkgtool': ('bdist_pkgtool', # "Solaris pkgtool distribution"), #'sdux': ('bdist_sdux', "HP-UX swinstall depot"), --- 79,83 ---- "Windows executable installer"), 'zip': ('bdist_dumb', "ZIP file"), ! #'pkgtool': ('bdist_pkgtool', # "Solaris pkgtool distribution"), #'sdux': ('bdist_sdux', "HP-UX swinstall depot"), Index: bdist_dumb.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/bdist_dumb.py,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** bdist_dumb.py 26 Nov 2002 17:45:19 -0000 1.23 --- bdist_dumb.py 18 Jul 2004 06:14:42 -0000 1.24 *************** *** 54,58 **** self.skip_build = 0 self.relative = 0 ! # initialize_options() --- 54,58 ---- self.skip_build = 0 self.relative = 0 ! # initialize_options() Index: bdist_wininst.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/bdist_wininst.py,v retrieving revision 1.49 retrieving revision 1.50 diff -C2 -d -r1.49 -r1.50 *** bdist_wininst.py 6 Jul 2004 19:23:27 -0000 1.49 --- bdist_wininst.py 18 Jul 2004 06:14:42 -0000 1.50 *************** *** 116,120 **** install_lib.compile = 0 install_lib.optimize = 0 ! # If we are building an installer for a Python version other # than the one we are currently running, then we need to ensure --- 116,120 ---- install_lib.compile = 0 install_lib.optimize = 0 ! # If we are building an installer for a Python version other # than the one we are currently running, then we need to ensure Index: build_ext.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/build_ext.py,v retrieving revision 1.95 retrieving revision 1.96 diff -C2 -d -r1.95 -r1.96 *** build_ext.py 11 May 2004 18:18:35 -0000 1.95 --- build_ext.py 18 Jul 2004 06:14:43 -0000 1.96 *************** *** 174,178 **** self.library_dirs.append(os.path.join(sys.exec_prefix, 'PCBuild')) ! # OS/2 (EMX) doesn't support Debug vs Release builds, but has the # import libraries in its "Config" subdirectory if os.name == 'os2': --- 174,178 ---- self.library_dirs.append(os.path.join(sys.exec_prefix, 'PCBuild')) ! # OS/2 (EMX) doesn't support Debug vs Release builds, but has the # import libraries in its "Config" subdirectory if os.name == 'os2': *************** *** 637,641 **** # believe VACPP does as well (though not confirmed) - AIM Apr01 template = "python%d%d" ! # debug versions of the main DLL aren't supported, at least # not at this time - AIM Apr01 #if self.debug: --- 637,641 ---- # believe VACPP does as well (though not confirmed) - AIM Apr01 template = "python%d%d" ! # debug versions of the main DLL aren't supported, at least # not at this time - AIM Apr01 #if self.debug: Index: build_scripts.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/build_scripts.py,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** build_scripts.py 25 Mar 2004 22:04:51 -0000 1.22 --- build_scripts.py 18 Jul 2004 06:14:43 -0000 1.23 *************** *** 95,99 **** outf = open(outfile, "w") if not sysconfig.python_build: ! outf.write("#!%s%s\n" % (os.path.normpath(sys.executable), post_interp)) --- 95,99 ---- outf = open(outfile, "w") if not sysconfig.python_build: ! outf.write("#!%s%s\n" % (os.path.normpath(sys.executable), post_interp)) Index: install.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/install.py,v retrieving revision 1.69 retrieving revision 1.70 diff -C2 -d -r1.69 -r1.70 *** install.py 25 Jun 2004 23:02:43 -0000 1.69 --- install.py 18 Jul 2004 06:14:43 -0000 1.70 *************** *** 538,542 **** install_lib not in sys_path): log.debug(("modules installed to '%s', which is not in " ! "Python's module search path (sys.path) -- " "you'll have to change the search path yourself"), self.install_lib) --- 538,542 ---- install_lib not in sys_path): log.debug(("modules installed to '%s', which is not in " ! "Python's module search path (sys.path) -- " "you'll have to change the search path yourself"), self.install_lib) Index: register.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/register.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** register.py 9 Apr 2003 12:35:51 -0000 1.6 --- register.py 18 Jul 2004 06:14:43 -0000 1.7 *************** *** 287,289 **** print '-'*75, data, '-'*75 return result - --- 287,288 ---- From tim_one at users.sourceforge.net Sun Jul 18 08:15:16 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 08:15:24 2004 Subject: [Python-checkins] python/dist/src/Lib/plat-atheos IN.py, 1.1, 1.2 TYPES.py, 1.1, 1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/plat-atheos In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31286/plat-atheos Modified Files: IN.py TYPES.py Log Message: Whitespace normalization, via reindent.py. Index: IN.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-atheos/IN.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** IN.py 11 Jun 2002 06:22:30 -0000 1.1 --- IN.py 18 Jul 2004 06:14:44 -0000 1.2 *************** *** 51,55 **** def __PMT(args): return args ! def __P(args): return () def __PMT(args): return () --- 51,55 ---- def __PMT(args): return args ! def __P(args): return () def __PMT(args): return () *************** *** 61,65 **** def __ASMNAME(cname): return __ASMNAME2 (__USER_LABEL_PREFIX__, cname) ! def __attribute__(xyz): return __USE_EXTERN_INLINES = 1 --- 61,65 ---- def __ASMNAME(cname): return __ASMNAME2 (__USER_LABEL_PREFIX__, cname) ! def __attribute__(xyz): return __USE_EXTERN_INLINES = 1 *************** *** 943,945 **** def IN6_IS_ADDR_MC_GLOBAL(a): return \ - --- 943,944 ---- Index: TYPES.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-atheos/TYPES.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TYPES.py 11 Jun 2002 06:22:30 -0000 1.1 --- TYPES.py 18 Jul 2004 06:14:44 -0000 1.2 *************** *** 51,55 **** def __PMT(args): return args ! def __P(args): return () def __PMT(args): return () --- 51,55 ---- def __PMT(args): return args ! def __P(args): return () def __PMT(args): return () *************** *** 61,65 **** def __ASMNAME(cname): return __ASMNAME2 (__USER_LABEL_PREFIX__, cname) ! def __attribute__(xyz): return __USE_EXTERN_INLINES = 1 --- 61,65 ---- def __ASMNAME(cname): return __ASMNAME2 (__USER_LABEL_PREFIX__, cname) ! def __attribute__(xyz): return __USE_EXTERN_INLINES = 1 *************** *** 141,143 **** def minor(dev): return ( ((dev) & 0xff)) - --- 141,142 ---- From tim_one at users.sourceforge.net Sun Jul 18 08:15:17 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 08:15:26 2004 Subject: [Python-checkins] python/dist/src/Lib/plat-beos5 IN.py,1.1,1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/plat-beos5 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31286/plat-beos5 Modified Files: IN.py Log Message: Whitespace normalization, via reindent.py. Index: IN.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-beos5/IN.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** IN.py 7 Oct 2000 12:25:17 -0000 1.1 --- IN.py 18 Jul 2004 06:14:44 -0000 1.2 *************** *** 325,327 **** def _FDMSKNO(fd): return ((fd) / NFDBITS) ! def _FDBITNO(fd): return ((fd) % NFDBITS) \ No newline at end of file --- 325,327 ---- def _FDMSKNO(fd): return ((fd) / NFDBITS) ! def _FDBITNO(fd): return ((fd) % NFDBITS) From tim_one at users.sourceforge.net Sun Jul 18 08:15:16 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 08:15:27 2004 Subject: [Python-checkins] python/dist/src/Lib/lib-tk Tix.py, 1.18, 1.19 Tkinter.py, 1.179, 1.180 tkFileDialog.py, 1.12, 1.13 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/lib-tk In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31286/lib-tk Modified Files: Tix.py Tkinter.py tkFileDialog.py Log Message: Whitespace normalization, via reindent.py. Index: Tix.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/lib-tk/Tix.py,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** Tix.py 21 Mar 2004 15:26:44 -0000 1.18 --- Tix.py 18 Jul 2004 06:14:44 -0000 1.19 *************** *** 1105,1117 **** def page(self, name): ! return self.subwidget(name) def pages(self): ! # Can't call subwidgets_all directly because we don't want .nbframe ! names = self.tk.split(self.tk.call(self._w, 'pages')) ! ret = [] ! for x in names: ! ret.append(self.subwidget(x)) ! return ret def raise_page(self, name): # raise is a python keyword --- 1105,1117 ---- def page(self, name): ! return self.subwidget(name) def pages(self): ! # Can't call subwidgets_all directly because we don't want .nbframe ! names = self.tk.split(self.tk.call(self._w, 'pages')) ! ret = [] ! for x in names: ! ret.append(self.subwidget(x)) ! return ret def raise_page(self, name): # raise is a python keyword *************** *** 1738,1742 **** class _dummyPanedWindow(PanedWindow, TixSubWidget): def __init__(self, master, name, destroy_physically=1): ! TixSubWidget.__init__(self, master, name, destroy_physically) ######################## --- 1738,1742 ---- class _dummyPanedWindow(PanedWindow, TixSubWidget): def __init__(self, master, name, destroy_physically=1): ! TixSubWidget.__init__(self, master, name, destroy_physically) ######################## Index: Tkinter.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/lib-tk/Tkinter.py,v retrieving revision 1.179 retrieving revision 1.180 diff -C2 -d -r1.179 -r1.180 *** Tkinter.py 18 Feb 2004 05:59:53 -0000 1.179 --- Tkinter.py 18 Jul 2004 06:14:44 -0000 1.180 *************** *** 1558,1562 **** # to avoid recursions in the getattr code in case of failure, we # ensure that self.tk is always _something_. ! self.tk = None if baseName is None: import sys, os --- 1558,1562 ---- # to avoid recursions in the getattr code in case of failure, we # ensure that self.tk is always _something_. ! self.tk = None if baseName is None: import sys, os Index: tkFileDialog.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/lib-tk/tkFileDialog.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** tkFileDialog.py 1 Dec 2003 21:04:22 -0000 1.12 --- tkFileDialog.py 18 Jul 2004 06:14:44 -0000 1.13 *************** *** 132,137 **** def askopenfilenames(**options): """Ask for multiple filenames to open ! ! Returns a list of filenames or empty list if cancel button selected """ --- 132,137 ---- def askopenfilenames(**options): """Ask for multiple filenames to open ! ! Returns a list of filenames or empty list if cancel button selected """ *************** *** 152,157 **** """Ask for multiple filenames and return the open file objects ! ! returns a list of open file objects or an empty list if cancel selected """ --- 152,157 ---- """Ask for multiple filenames and return the open file objects ! ! returns a list of open file objects or an empty list if cancel selected """ *************** *** 205,209 **** fp.close() except: ! print "Could not open File: " print sys.exc_info()[1] --- 205,209 ---- fp.close() except: ! print "Could not open File: " print sys.exc_info()[1] *************** *** 214,216 **** saveasfilename=asksaveasfilename() print "saveas", saveasfilename.encode(enc) - --- 214,215 ---- From tim_one at users.sourceforge.net Sun Jul 18 08:15:16 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 08:15:31 2004 Subject: [Python-checkins] python/dist/src/Lib/distutils archive_util.py, 1.15, 1.16 bcppcompiler.py, 1.16, 1.17 ccompiler.py, 1.58, 1.59 cmd.py, 1.37, 1.38 core.py, 1.60, 1.61 cygwinccompiler.py, 1.25, 1.26 debug.py, 1.2, 1.3 dir_util.py, 1.13, 1.14 dist.py, 1.67, 1.68 file_util.py, 1.15, 1.16 filelist.py, 1.16, 1.17 log.py, 1.4, 1.5 msvccompiler.py, 1.59, 1.60 spawn.py, 1.17, 1.18 sysconfig.py, 1.59, 1.60 unixccompiler.py, 1.54, 1.55 util.py, 1.75, 1.76 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31286/distutils Modified Files: archive_util.py bcppcompiler.py ccompiler.py cmd.py core.py cygwinccompiler.py debug.py dir_util.py dist.py file_util.py filelist.py log.py msvccompiler.py spawn.py sysconfig.py unixccompiler.py util.py Log Message: Whitespace normalization, via reindent.py. Index: archive_util.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/archive_util.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** archive_util.py 21 Nov 2002 18:33:28 -0000 1.15 --- archive_util.py 18 Jul 2004 06:14:41 -0000 1.16 *************** *** 69,73 **** except ImportError: zipfile = None ! zip_filename = base_name + ".zip" mkpath(os.path.dirname(zip_filename), dry_run=dry_run) --- 69,73 ---- except ImportError: zipfile = None ! zip_filename = base_name + ".zip" mkpath(os.path.dirname(zip_filename), dry_run=dry_run) *************** *** 80,84 **** else: zipoptions = "-rq" ! try: spawn(["zip", zipoptions, zip_filename, base_dir], --- 80,84 ---- else: zipoptions = "-rq" ! try: spawn(["zip", zipoptions, zip_filename, base_dir], Index: bcppcompiler.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/bcppcompiler.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** bcppcompiler.py 5 Dec 2003 20:12:23 -0000 1.16 --- bcppcompiler.py 18 Jul 2004 06:14:42 -0000 1.17 *************** *** 86,90 **** output_dir=None, macros=None, include_dirs=None, debug=0, extra_preargs=None, extra_postargs=None, depends=None): ! macros, objects, extra_postargs, pp_opts, build = \ self._setup_compile(output_dir, macros, include_dirs, sources, --- 86,90 ---- output_dir=None, macros=None, include_dirs=None, debug=0, extra_preargs=None, extra_postargs=None, depends=None): ! macros, objects, extra_postargs, pp_opts, build = \ self._setup_compile(output_dir, macros, include_dirs, sources, Index: ccompiler.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/ccompiler.py,v retrieving revision 1.58 retrieving revision 1.59 diff -C2 -d -r1.58 -r1.59 *** ccompiler.py 5 Dec 2003 20:12:23 -0000 1.58 --- ccompiler.py 18 Jul 2004 06:14:42 -0000 1.59 *************** *** 686,690 **** # A concrete compiler class can either override this method # entirely or implement _compile(). ! macros, objects, extra_postargs, pp_opts, build = \ self._setup_compile(output_dir, macros, include_dirs, sources, --- 686,690 ---- # A concrete compiler class can either override this method # entirely or implement _compile(). ! macros, objects, extra_postargs, pp_opts, build = \ self._setup_compile(output_dir, macros, include_dirs, sources, *************** *** 704,708 **** def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts): """Compile 'src' to product 'obj'.""" ! # A concrete compiler class that does not override compile() # should implement _compile(). --- 704,708 ---- def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts): """Compile 'src' to product 'obj'.""" ! # A concrete compiler class that does not override compile() # should implement _compile(). Index: cmd.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/cmd.py,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** cmd.py 18 Jun 2004 21:28:28 -0000 1.37 --- cmd.py 18 Jul 2004 06:14:42 -0000 1.38 *************** *** 80,84 **** # backwards compatibility (I think)? self.verbose = dist.verbose ! # Some commands define a 'self.force' option to ignore file # timestamps, but methods defined *here* assume that --- 80,84 ---- # backwards compatibility (I think)? self.verbose = dist.verbose ! # Some commands define a 'self.force' option to ignore file # timestamps, but methods defined *here* assume that *************** *** 101,105 **** # XXX A more explicit way to customize dry_run would be better. ! def __getattr__ (self, attr): if attr == 'dry_run': --- 101,105 ---- # XXX A more explicit way to customize dry_run would be better. ! def __getattr__ (self, attr): if attr == 'dry_run': Index: core.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/core.py,v retrieving revision 1.60 retrieving revision 1.61 diff -C2 -d -r1.60 -r1.61 *** core.py 22 Mar 2004 22:22:04 -0000 1.60 --- core.py 18 Jul 2004 06:14:42 -0000 1.61 *************** *** 240,242 **** # run_setup () - --- 240,241 ---- Index: cygwinccompiler.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/cygwinccompiler.py,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** cygwinccompiler.py 5 Jun 2004 18:37:53 -0000 1.25 --- cygwinccompiler.py 18 Jul 2004 06:14:42 -0000 1.26 *************** *** 76,80 **** if status is not CONFIG_H_OK: self.warn( ! "Python's pyconfig.h doesn't seem to support your compiler. " "Reason: %s. " "Compiling may fail because of undefined preprocessor macros." --- 76,80 ---- if status is not CONFIG_H_OK: self.warn( ! "Python's pyconfig.h doesn't seem to support your compiler. " "Reason: %s. " "Compiling may fail because of undefined preprocessor macros." Index: debug.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/debug.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** debug.py 19 Nov 2002 13:12:27 -0000 1.2 --- debug.py 18 Jul 2004 06:14:42 -0000 1.3 *************** *** 8,10 **** # debug mode. DEBUG = os.environ.get('DISTUTILS_DEBUG') - --- 8,9 ---- Index: dir_util.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/dir_util.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** dir_util.py 12 Feb 2004 17:35:08 -0000 1.13 --- dir_util.py 18 Jul 2004 06:14:42 -0000 1.14 *************** *** 226,228 **** path = drive + path[1:] return path - --- 226,227 ---- Index: dist.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/dist.py,v retrieving revision 1.67 retrieving revision 1.68 diff -C2 -d -r1.67 -r1.68 *** dist.py 11 Jun 2004 21:50:32 -0000 1.67 --- dist.py 18 Jul 2004 06:14:42 -0000 1.68 *************** *** 232,236 **** attrs['requires'] = newreq ! # Build up the provides object. If the setup() has no # provides line, we use packages or modules and the version # to synthesise the provides. If no version is provided (no --- 232,236 ---- attrs['requires'] = newreq ! # Build up the provides object. If the setup() has no # provides line, we use packages or modules and the version # to synthesise the provides. If no version is provided (no *************** *** 1138,1142 **** def get_requires(self): ! return [ '%s%s%s'%(x, (y and '-') or '', y or '') for x,y in self.requires ] --- 1138,1142 ---- def get_requires(self): ! return [ '%s%s%s'%(x, (y and '-') or '', y or '') for x,y in self.requires ] Index: file_util.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/file_util.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** file_util.py 19 Nov 2002 13:12:27 -0000 1.15 --- file_util.py 18 Jul 2004 06:14:42 -0000 1.16 *************** *** 43,47 **** raise DistutilsFileError, \ "could not delete '%s': %s" % (dst, errstr) ! try: fdst = open(dst, 'wb') --- 43,47 ---- raise DistutilsFileError, \ "could not delete '%s': %s" % (dst, errstr) ! try: fdst = open(dst, 'wb') Index: filelist.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/filelist.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** filelist.py 31 May 2004 15:12:27 -0000 1.16 --- filelist.py 18 Jul 2004 06:14:42 -0000 1.17 *************** *** 168,172 **** if not self.include_pattern(pattern, prefix=dir): log.warn(("warning: no files found matching '%s' " + ! "under directory '%s'"), pattern, dir) --- 168,172 ---- if not self.include_pattern(pattern, prefix=dir): log.warn(("warning: no files found matching '%s' " + ! "under directory '%s'"), pattern, dir) Index: log.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/log.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** log.py 20 Feb 2003 02:09:30 -0000 1.4 --- log.py 18 Jul 2004 06:14:42 -0000 1.5 *************** *** 29,42 **** def debug(self, msg, *args): self._log(DEBUG, msg, args) ! def info(self, msg, *args): self._log(INFO, msg, args) ! def warn(self, msg, *args): self._log(WARN, msg, args) ! def error(self, msg, *args): self._log(ERROR, msg, args) ! def fatal(self, msg, *args): self._log(FATAL, msg, args) --- 29,42 ---- def debug(self, msg, *args): self._log(DEBUG, msg, args) ! def info(self, msg, *args): self._log(INFO, msg, args) ! def warn(self, msg, *args): self._log(WARN, msg, args) ! def error(self, msg, *args): self._log(ERROR, msg, args) ! def fatal(self, msg, *args): self._log(FATAL, msg, args) Index: msvccompiler.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/msvccompiler.py,v retrieving revision 1.59 retrieving revision 1.60 diff -C2 -d -r1.59 -r1.60 *** msvccompiler.py 5 Dec 2003 20:12:23 -0000 1.59 --- msvccompiler.py 18 Jul 2004 06:14:42 -0000 1.60 *************** *** 118,122 **** self.macros["$(%s)" % macro] = d[key] break ! def load_macros(self, version): vsbase = r"Software\Microsoft\VisualStudio\%0.1f" % version --- 118,122 ---- self.macros["$(%s)" % macro] = d[key] break ! def load_macros(self, version): vsbase = r"Software\Microsoft\VisualStudio\%0.1f" % version *************** *** 167,171 **** # else we don't know what version of the compiler this is return None ! class MSVCCompiler (CCompiler) : --- 167,171 ---- # else we don't know what version of the compiler this is return None ! class MSVCCompiler (CCompiler) : *************** *** 526,530 **** return exe ! def get_msvc_paths(self, path, platform='x86'): """Get a list of devstudio directories (include, lib or path). --- 526,530 ---- return exe ! def get_msvc_paths(self, path, platform='x86'): """Get a list of devstudio directories (include, lib or path). *************** *** 577,579 **** if p: os.environ[name] = string.join(p, ';') - --- 577,578 ---- Index: spawn.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/spawn.py,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** spawn.py 24 Feb 2004 23:54:17 -0000 1.17 --- spawn.py 18 Jul 2004 06:14:42 -0000 1.18 *************** *** 98,102 **** if search_path: # either we find one or it stays the same ! executable = find_executable(executable) or executable log.info(string.join([executable] + cmd[1:], ' ')) if not dry_run: --- 98,102 ---- if search_path: # either we find one or it stays the same ! executable = find_executable(executable) or executable log.info(string.join([executable] + cmd[1:], ' ')) if not dry_run: Index: sysconfig.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/sysconfig.py,v retrieving revision 1.59 retrieving revision 1.60 diff -C2 -d -r1.59 -r1.60 *** sysconfig.py 3 Jun 2004 12:41:45 -0000 1.59 --- sysconfig.py 18 Jul 2004 06:14:42 -0000 1.60 *************** *** 368,372 **** % (cur_target, cfg_target)) raise DistutilsPlatformError(my_msg) ! # On AIX, there are wrong paths to the linker scripts in the Makefile # -- these paths are relative to the Python source, but when installed --- 368,372 ---- % (cur_target, cfg_target)) raise DistutilsPlatformError(my_msg) ! # On AIX, there are wrong paths to the linker scripts in the Makefile # -- these paths are relative to the Python source, but when installed Index: unixccompiler.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/unixccompiler.py,v retrieving revision 1.54 retrieving revision 1.55 diff -C2 -d -r1.54 -r1.55 *** unixccompiler.py 1 Jun 2003 19:27:40 -0000 1.54 --- unixccompiler.py 18 Jul 2004 06:14:42 -0000 1.55 *************** *** 207,211 **** return "+s -L" + dir elif compiler[:3] == "gcc" or compiler[:3] == "g++": ! return "-Wl,-R" + dir else: return "-R" + dir --- 207,211 ---- return "+s -L" + dir elif compiler[:3] == "gcc" or compiler[:3] == "g++": ! return "-Wl,-R" + dir else: return "-R" + dir *************** *** 218,222 **** dylib_f = self.library_filename(lib, lib_type='dylib') static_f = self.library_filename(lib, lib_type='static') ! for dir in dirs: shared = os.path.join(dir, shared_f) --- 218,222 ---- dylib_f = self.library_filename(lib, lib_type='dylib') static_f = self.library_filename(lib, lib_type='static') ! for dir in dirs: shared = os.path.join(dir, shared_f) *************** *** 233,237 **** elif os.path.exists(static): return static ! # Oops, didn't find it in *any* of 'dirs' return None --- 233,237 ---- elif os.path.exists(static): return static ! # Oops, didn't find it in *any* of 'dirs' return None Index: util.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/util.py,v retrieving revision 1.75 retrieving revision 1.76 diff -C2 -d -r1.75 -r1.76 *** util.py 25 Mar 2004 14:58:19 -0000 1.75 --- util.py 18 Jul 2004 06:14:42 -0000 1.76 *************** *** 301,305 **** def strtobool (val): """Convert a string representation of truth to true (1) or false (0). ! True values are 'y', 'yes', 't', 'true', 'on', and '1'; false values are 'n', 'no', 'f', 'false', 'off', and '0'. Raises ValueError if --- 301,305 ---- def strtobool (val): """Convert a string representation of truth to true (1) or false (0). ! True values are 'y', 'yes', 't', 'true', 'on', and '1'; false values are 'n', 'no', 'f', 'false', 'off', and '0'. Raises ValueError if From tim_one at users.sourceforge.net Sun Jul 18 08:15:18 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 08:15:33 2004 Subject: [Python-checkins] python/dist/src/Lib/plat-linux2 DLFCN.py, 1.1, 1.2 IN.py, 1.5, 1.6 TYPES.py, 1.1, 1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/plat-linux2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31286/plat-linux2 Modified Files: DLFCN.py IN.py TYPES.py Log Message: Whitespace normalization, via reindent.py. Index: DLFCN.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-linux2/DLFCN.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** DLFCN.py 9 Aug 2001 12:48:17 -0000 1.1 --- DLFCN.py 18 Jul 2004 06:14:45 -0000 1.2 *************** *** 62,70 **** def __ASMNAME(cname): return __ASMNAME2 (__USER_LABEL_PREFIX__, cname) ! def __attribute__(xyz): return def __attribute_format_arg__(x): return __attribute__ ((__format_arg__ (x))) ! def __attribute_format_arg__(x): return __USE_LARGEFILE = 1 --- 62,70 ---- def __ASMNAME(cname): return __ASMNAME2 (__USER_LABEL_PREFIX__, cname) ! def __attribute__(xyz): return def __attribute_format_arg__(x): return __attribute__ ((__format_arg__ (x))) ! def __attribute_format_arg__(x): return __USE_LARGEFILE = 1 Index: IN.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-linux2/IN.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** IN.py 23 Nov 2002 12:09:28 -0000 1.5 --- IN.py 18 Jul 2004 06:14:45 -0000 1.6 *************** *** 62,70 **** def __ASMNAME(cname): return __ASMNAME2 (__USER_LABEL_PREFIX__, cname) ! def __attribute__(xyz): return def __attribute_format_arg__(x): return __attribute__ ((__format_arg__ (x))) ! def __attribute_format_arg__(x): return __USE_LARGEFILE = 1 --- 62,70 ---- def __ASMNAME(cname): return __ASMNAME2 (__USER_LABEL_PREFIX__, cname) ! def __attribute__(xyz): return def __attribute_format_arg__(x): return __attribute__ ((__format_arg__ (x))) ! def __attribute_format_arg__(x): return __USE_LARGEFILE = 1 *************** *** 614,616 **** def IN6_IS_ADDR_MC_GLOBAL(a): return \ - --- 614,615 ---- Index: TYPES.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-linux2/TYPES.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TYPES.py 9 Aug 2001 12:48:17 -0000 1.1 --- TYPES.py 18 Jul 2004 06:14:45 -0000 1.2 *************** *** 62,70 **** def __ASMNAME(cname): return __ASMNAME2 (__USER_LABEL_PREFIX__, cname) ! def __attribute__(xyz): return def __attribute_format_arg__(x): return __attribute__ ((__format_arg__ (x))) ! def __attribute_format_arg__(x): return __USE_LARGEFILE = 1 --- 62,70 ---- def __ASMNAME(cname): return __ASMNAME2 (__USER_LABEL_PREFIX__, cname) ! def __attribute__(xyz): return def __attribute_format_arg__(x): return __attribute__ ((__format_arg__ (x))) ! def __attribute_format_arg__(x): return __USE_LARGEFILE = 1 *************** *** 169,171 **** def minor(dev): return ((dev).__val[0] & 0xff) - --- 169,170 ---- From tim_one at users.sourceforge.net Sun Jul 18 08:15:18 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 08:15:35 2004 Subject: [Python-checkins] python/dist/src/Lib/lib-old Para.py, 1.7, 1.8 addpack.py, 1.1, 1.2 codehack.py, 1.6, 1.7 dump.py, 1.2, 1.3 find.py, 1.1, 1.2 fmt.py, 1.6, 1.7 grep.py, 1.10, 1.11 lockfile.py, 1.2, 1.3 newdir.py, 1.5, 1.6 packmail.py, 1.10, 1.11 poly.py, 1.2, 1.3 rand.py, 1.2, 1.3 tb.py, 1.9, 1.10 util.py, 1.4, 1.5 zmod.py, 1.2, 1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/lib-old In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31286/lib-old Modified Files: Para.py addpack.py codehack.py dump.py find.py fmt.py grep.py lockfile.py newdir.py packmail.py poly.py rand.py tb.py util.py zmod.py Log Message: Whitespace normalization, via reindent.py. Index: Para.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/lib-old/Para.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Para.py 12 Dec 2000 23:11:41 -0000 1.7 --- Para.py 18 Jul 2004 06:14:43 -0000 1.8 *************** *** 1,3 **** ! # Text formatting abstractions # Note -- this module is obsolete, it's too slow anyway --- 1,3 ---- ! # Text formatting abstractions # Note -- this module is obsolete, it's too slow anyway *************** *** 15,343 **** # for mouse hits, and parts of the text can be highlighted class Para: ! # ! def __init__(self): ! self.words = [] # The words ! self.just = 'l' # Justification: 'l', 'r', 'lr' or 'c' ! self.indent_left = self.indent_right = self.indent_hang = 0 ! # Final lay-out parameters, may change ! self.left = self.top = self.right = self.bottom = \ ! self.width = self.height = self.lines = None ! # ! # Add a word, computing size information for it. ! # Words may also be added manually by appending to self.words ! # Each word should be a 7-tuple: ! # (font, text, width, space, stretch, ascent, descent) ! def addword(self, d, font, text, space, stretch): ! if font is not None: ! d.setfont(font) ! width = d.textwidth(text) ! ascent = d.baseline() ! descent = d.lineheight() - ascent ! spw = d.textwidth(' ') ! space = space * spw ! stretch = stretch * spw ! tuple = (font, text, width, space, stretch, ascent, descent) ! self.words.append(tuple) ! # ! # Hooks to begin and end anchors -- insert numbers in the word list! ! def bgn_anchor(self, id): ! self.words.append(id) ! # ! def end_anchor(self, id): ! self.words.append(0) ! # ! # Return the total length (width) of the text added so far, in pixels ! def getlength(self): ! total = 0 ! for word in self.words: ! if type(word) is not Int: ! total = total + word[2] + word[3] ! return total ! # ! # Tab to a given position (relative to the current left indent): ! # remove all stretch, add fixed space up to the new indent. ! # If the current position is already at the tab stop, ! # don't add any new space (but still remove the stretch) ! def tabto(self, tab): ! total = 0 ! as, de = 1, 0 ! for i in range(len(self.words)): ! word = self.words[i] ! if type(word) is Int: continue ! (fo, te, wi, sp, st, as, de) = word ! self.words[i] = (fo, te, wi, sp, 0, as, de) ! total = total + wi + sp ! if total < tab: ! self.words.append((None, '', 0, tab-total, 0, as, de)) ! # ! # Make a hanging tag: tab to hang, increment indent_left by hang, ! # and reset indent_hang to -hang ! def makehangingtag(self, hang): ! self.tabto(hang) ! self.indent_left = self.indent_left + hang ! self.indent_hang = -hang ! # ! # Decide where the line breaks will be given some screen width ! def layout(self, linewidth): ! self.width = linewidth ! height = 0 ! self.lines = lines = [] ! avail1 = self.width - self.indent_left - self.indent_right ! avail = avail1 - self.indent_hang ! words = self.words ! i = 0 ! n = len(words) ! lastfont = None ! while i < n: ! firstfont = lastfont ! charcount = 0 ! width = 0 ! stretch = 0 ! ascent = 0 ! descent = 0 ! lsp = 0 ! j = i ! while i < n: ! word = words[i] ! if type(word) is Int: ! if word > 0 and width >= avail: ! break ! i = i+1 ! continue ! fo, te, wi, sp, st, as, de = word ! if width + wi > avail and width > 0 and wi > 0: ! break ! if fo is not None: ! lastfont = fo ! if width == 0: ! firstfont = fo ! charcount = charcount + len(te) + (sp > 0) ! width = width + wi + sp ! lsp = sp ! stretch = stretch + st ! lst = st ! ascent = max(ascent, as) ! descent = max(descent, de) ! i = i+1 ! while i > j and type(words[i-1]) is Int and \ ! words[i-1] > 0: i = i-1 ! width = width - lsp ! if i < n: ! stretch = stretch - lst ! else: ! stretch = 0 ! tuple = i-j, firstfont, charcount, width, stretch, \ ! ascent, descent ! lines.append(tuple) ! height = height + ascent + descent ! avail = avail1 ! self.height = height ! # ! # Call a function for all words in a line ! def visit(self, wordfunc, anchorfunc): ! avail1 = self.width - self.indent_left - self.indent_right ! avail = avail1 - self.indent_hang ! v = self.top ! i = 0 ! for tuple in self.lines: ! wordcount, firstfont, charcount, width, stretch, \ ! ascent, descent = tuple ! h = self.left + self.indent_left ! if i == 0: h = h + self.indent_hang ! extra = 0 ! if self.just == 'r': h = h + avail - width ! elif self.just == 'c': h = h + (avail - width) / 2 ! elif self.just == 'lr' and stretch > 0: ! extra = avail - width ! v2 = v + ascent + descent ! for j in range(i, i+wordcount): ! word = self.words[j] ! if type(word) is Int: ! ok = anchorfunc(self, tuple, word, \ ! h, v) ! if ok is not None: return ok ! continue ! fo, te, wi, sp, st, as, de = word ! if extra > 0 and stretch > 0: ! ex = extra * st / stretch ! extra = extra - ex ! stretch = stretch - st ! else: ! ex = 0 ! h2 = h + wi + sp + ex ! ok = wordfunc(self, tuple, word, h, v, \ ! h2, v2, (j==i), (j==i+wordcount-1)) ! if ok is not None: return ok ! h = h2 ! v = v2 ! i = i + wordcount ! avail = avail1 ! # ! # Render a paragraph in "drawing object" d, using the rectangle ! # given by (left, top, right) with an unspecified bottom. ! # Return the computed bottom of the text. ! def render(self, d, left, top, right): ! if self.width != right-left: ! self.layout(right-left) ! self.left = left ! self.top = top ! self.right = right ! self.bottom = self.top + self.height ! self.anchorid = 0 ! try: ! self.d = d ! self.visit(self.__class__._renderword, \ ! self.__class__._renderanchor) ! finally: ! self.d = None ! return self.bottom ! # ! def _renderword(self, tuple, word, h, v, h2, v2, isfirst, islast): ! if word[0] is not None: self.d.setfont(word[0]) ! baseline = v + tuple[5] ! self.d.text((h, baseline - word[5]), word[1]) ! if self.anchorid > 0: ! self.d.line((h, baseline+2), (h2, baseline+2)) ! # ! def _renderanchor(self, tuple, word, h, v): ! self.anchorid = word ! # ! # Return which anchor(s) was hit by the mouse ! def hitcheck(self, mouseh, mousev): ! self.mouseh = mouseh ! self.mousev = mousev ! self.anchorid = 0 ! self.hits = [] ! self.visit(self.__class__._hitcheckword, \ ! self.__class__._hitcheckanchor) ! return self.hits ! # ! def _hitcheckword(self, tuple, word, h, v, h2, v2, isfirst, islast): ! if self.anchorid > 0 and h <= self.mouseh <= h2 and \ ! v <= self.mousev <= v2: ! self.hits.append(self.anchorid) ! # ! def _hitcheckanchor(self, tuple, word, h, v): ! self.anchorid = word ! # ! # Return whether the given anchor id is present ! def hasanchor(self, id): ! return id in self.words or -id in self.words ! # ! # Extract the raw text from the word list, substituting one space ! # for non-empty inter-word space, and terminating with '\n' ! def extract(self): ! text = '' ! for w in self.words: ! if type(w) is not Int: ! word = w[1] ! if w[3]: word = word + ' ' ! text = text + word ! return text + '\n' ! # ! # Return which character position was hit by the mouse, as ! # an offset in the entire text as returned by extract(). ! # Return None if the mouse was not in this paragraph ! def whereis(self, d, mouseh, mousev): ! if mousev < self.top or mousev > self.bottom: ! return None ! self.mouseh = mouseh ! self.mousev = mousev ! self.lastfont = None ! self.charcount = 0 ! try: ! self.d = d ! return self.visit(self.__class__._whereisword, \ ! self.__class__._whereisanchor) ! finally: ! self.d = None ! # ! def _whereisword(self, tuple, word, h1, v1, h2, v2, isfirst, islast): ! fo, te, wi, sp, st, as, de = word ! if fo is not None: self.lastfont = fo ! h = h1 ! if isfirst: h1 = 0 ! if islast: h2 = 999999 ! if not (v1 <= self.mousev <= v2 and h1 <= self.mouseh <= h2): ! self.charcount = self.charcount + len(te) + (sp > 0) ! return ! if self.lastfont is not None: ! self.d.setfont(self.lastfont) ! cc = 0 ! for c in te: ! cw = self.d.textwidth(c) ! if self.mouseh <= h + cw/2: ! return self.charcount + cc ! cc = cc+1 ! h = h+cw ! self.charcount = self.charcount + cc ! if self.mouseh <= (h+h2) / 2: ! return self.charcount ! else: ! return self.charcount + 1 ! # ! def _whereisanchor(self, tuple, word, h, v): ! pass ! # ! # Return screen position corresponding to position in paragraph. ! # Return tuple (h, vtop, vbaseline, vbottom). ! # This is more or less the inverse of whereis() ! def screenpos(self, d, pos): ! if pos < 0: ! ascent, descent = self.lines[0][5:7] ! return self.left, self.top, self.top + ascent, \ ! self.top + ascent + descent ! self.pos = pos ! self.lastfont = None ! try: ! self.d = d ! ok = self.visit(self.__class__._screenposword, \ ! self.__class__._screenposanchor) ! finally: ! self.d = None ! if ok is None: ! ascent, descent = self.lines[-1][5:7] ! ok = self.right, self.bottom - ascent - descent, \ ! self.bottom - descent, self.bottom ! return ok ! # ! def _screenposword(self, tuple, word, h1, v1, h2, v2, isfirst, islast): ! fo, te, wi, sp, st, as, de = word ! if fo is not None: self.lastfont = fo ! cc = len(te) + (sp > 0) ! if self.pos > cc: ! self.pos = self.pos - cc ! return ! if self.pos < cc: ! self.d.setfont(self.lastfont) ! h = h1 + self.d.textwidth(te[:self.pos]) ! else: ! h = h2 ! ascent, descent = tuple[5:7] ! return h, v1, v1+ascent, v2 ! # ! def _screenposanchor(self, tuple, word, h, v): ! pass ! # ! # Invert the stretch of text between pos1 and pos2. ! # If pos1 is None, the beginning is implied; ! # if pos2 is None, the end is implied. ! # Undoes its own effect when called again with the same arguments ! def invert(self, d, pos1, pos2): ! if pos1 is None: ! pos1 = self.left, self.top, self.top, self.top ! else: ! pos1 = self.screenpos(d, pos1) ! if pos2 is None: ! pos2 = self.right, self.bottom,self.bottom,self.bottom ! else: ! pos2 = self.screenpos(d, pos2) ! h1, top1, baseline1, bottom1 = pos1 ! h2, top2, baseline2, bottom2 = pos2 ! if bottom1 <= top2: ! d.invert((h1, top1), (self.right, bottom1)) ! h1 = self.left ! if bottom1 < top2: ! d.invert((h1, bottom1), (self.right, top2)) ! top1, bottom1 = top2, bottom2 ! d.invert((h1, top1), (h2, bottom2)) --- 15,343 ---- # for mouse hits, and parts of the text can be highlighted class Para: ! # ! def __init__(self): ! self.words = [] # The words ! self.just = 'l' # Justification: 'l', 'r', 'lr' or 'c' ! self.indent_left = self.indent_right = self.indent_hang = 0 ! # Final lay-out parameters, may change ! self.left = self.top = self.right = self.bottom = \ ! self.width = self.height = self.lines = None ! # ! # Add a word, computing size information for it. ! # Words may also be added manually by appending to self.words ! # Each word should be a 7-tuple: ! # (font, text, width, space, stretch, ascent, descent) ! def addword(self, d, font, text, space, stretch): ! if font is not None: ! d.setfont(font) ! width = d.textwidth(text) ! ascent = d.baseline() ! descent = d.lineheight() - ascent ! spw = d.textwidth(' ') ! space = space * spw ! stretch = stretch * spw ! tuple = (font, text, width, space, stretch, ascent, descent) ! self.words.append(tuple) ! # ! # Hooks to begin and end anchors -- insert numbers in the word list! ! def bgn_anchor(self, id): ! self.words.append(id) ! # ! def end_anchor(self, id): ! self.words.append(0) ! # ! # Return the total length (width) of the text added so far, in pixels ! def getlength(self): ! total = 0 ! for word in self.words: ! if type(word) is not Int: ! total = total + word[2] + word[3] ! return total ! # ! # Tab to a given position (relative to the current left indent): ! # remove all stretch, add fixed space up to the new indent. ! # If the current position is already at the tab stop, ! # don't add any new space (but still remove the stretch) ! def tabto(self, tab): ! total = 0 ! as, de = 1, 0 ! for i in range(len(self.words)): ! word = self.words[i] ! if type(word) is Int: continue ! (fo, te, wi, sp, st, as, de) = word ! self.words[i] = (fo, te, wi, sp, 0, as, de) ! total = total + wi + sp ! if total < tab: ! self.words.append((None, '', 0, tab-total, 0, as, de)) ! # ! # Make a hanging tag: tab to hang, increment indent_left by hang, ! # and reset indent_hang to -hang ! def makehangingtag(self, hang): ! self.tabto(hang) ! self.indent_left = self.indent_left + hang ! self.indent_hang = -hang ! # ! # Decide where the line breaks will be given some screen width ! def layout(self, linewidth): ! self.width = linewidth ! height = 0 ! self.lines = lines = [] ! avail1 = self.width - self.indent_left - self.indent_right ! avail = avail1 - self.indent_hang ! words = self.words ! i = 0 ! n = len(words) ! lastfont = None ! while i < n: ! firstfont = lastfont ! charcount = 0 ! width = 0 ! stretch = 0 ! ascent = 0 ! descent = 0 ! lsp = 0 ! j = i ! while i < n: ! word = words[i] ! if type(word) is Int: ! if word > 0 and width >= avail: ! break ! i = i+1 ! continue ! fo, te, wi, sp, st, as, de = word ! if width + wi > avail and width > 0 and wi > 0: ! break ! if fo is not None: ! lastfont = fo ! if width == 0: ! firstfont = fo ! charcount = charcount + len(te) + (sp > 0) ! width = width + wi + sp ! lsp = sp ! stretch = stretch + st ! lst = st ! ascent = max(ascent, as) ! descent = max(descent, de) ! i = i+1 ! while i > j and type(words[i-1]) is Int and \ ! words[i-1] > 0: i = i-1 ! width = width - lsp ! if i < n: ! stretch = stretch - lst ! else: ! stretch = 0 ! tuple = i-j, firstfont, charcount, width, stretch, \ ! ascent, descent ! lines.append(tuple) ! height = height + ascent + descent ! avail = avail1 ! self.height = height ! # ! # Call a function for all words in a line ! def visit(self, wordfunc, anchorfunc): ! avail1 = self.width - self.indent_left - self.indent_right ! avail = avail1 - self.indent_hang ! v = self.top ! i = 0 ! for tuple in self.lines: ! wordcount, firstfont, charcount, width, stretch, \ ! ascent, descent = tuple ! h = self.left + self.indent_left ! if i == 0: h = h + self.indent_hang ! extra = 0 ! if self.just == 'r': h = h + avail - width ! elif self.just == 'c': h = h + (avail - width) / 2 ! elif self.just == 'lr' and stretch > 0: ! extra = avail - width ! v2 = v + ascent + descent ! for j in range(i, i+wordcount): ! word = self.words[j] ! if type(word) is Int: ! ok = anchorfunc(self, tuple, word, \ ! h, v) ! if ok is not None: return ok ! continue ! fo, te, wi, sp, st, as, de = word ! if extra > 0 and stretch > 0: ! ex = extra * st / stretch ! extra = extra - ex ! stretch = stretch - st ! else: ! ex = 0 ! h2 = h + wi + sp + ex ! ok = wordfunc(self, tuple, word, h, v, \ ! h2, v2, (j==i), (j==i+wordcount-1)) ! if ok is not None: return ok ! h = h2 ! v = v2 ! i = i + wordcount ! avail = avail1 ! # ! # Render a paragraph in "drawing object" d, using the rectangle ! # given by (left, top, right) with an unspecified bottom. ! # Return the computed bottom of the text. ! def render(self, d, left, top, right): ! if self.width != right-left: ! self.layout(right-left) ! self.left = left ! self.top = top ! self.right = right ! self.bottom = self.top + self.height ! self.anchorid = 0 ! try: ! self.d = d ! self.visit(self.__class__._renderword, \ ! self.__class__._renderanchor) ! finally: ! self.d = None ! return self.bottom ! # ! def _renderword(self, tuple, word, h, v, h2, v2, isfirst, islast): ! if word[0] is not None: self.d.setfont(word[0]) ! baseline = v + tuple[5] ! self.d.text((h, baseline - word[5]), word[1]) ! if self.anchorid > 0: ! self.d.line((h, baseline+2), (h2, baseline+2)) ! # ! def _renderanchor(self, tuple, word, h, v): ! self.anchorid = word ! # ! # Return which anchor(s) was hit by the mouse ! def hitcheck(self, mouseh, mousev): ! self.mouseh = mouseh ! self.mousev = mousev ! self.anchorid = 0 ! self.hits = [] ! self.visit(self.__class__._hitcheckword, \ ! self.__class__._hitcheckanchor) ! return self.hits ! # ! def _hitcheckword(self, tuple, word, h, v, h2, v2, isfirst, islast): ! if self.anchorid > 0 and h <= self.mouseh <= h2 and \ ! v <= self.mousev <= v2: ! self.hits.append(self.anchorid) ! # ! def _hitcheckanchor(self, tuple, word, h, v): ! self.anchorid = word ! # ! # Return whether the given anchor id is present ! def hasanchor(self, id): ! return id in self.words or -id in self.words ! # ! # Extract the raw text from the word list, substituting one space ! # for non-empty inter-word space, and terminating with '\n' ! def extract(self): ! text = '' ! for w in self.words: ! if type(w) is not Int: ! word = w[1] ! if w[3]: word = word + ' ' ! text = text + word ! return text + '\n' ! # ! # Return which character position was hit by the mouse, as ! # an offset in the entire text as returned by extract(). ! # Return None if the mouse was not in this paragraph ! def whereis(self, d, mouseh, mousev): ! if mousev < self.top or mousev > self.bottom: ! return None ! self.mouseh = mouseh ! self.mousev = mousev ! self.lastfont = None ! self.charcount = 0 ! try: ! self.d = d ! return self.visit(self.__class__._whereisword, \ ! self.__class__._whereisanchor) ! finally: ! self.d = None ! # ! def _whereisword(self, tuple, word, h1, v1, h2, v2, isfirst, islast): ! fo, te, wi, sp, st, as, de = word ! if fo is not None: self.lastfont = fo ! h = h1 ! if isfirst: h1 = 0 ! if islast: h2 = 999999 ! if not (v1 <= self.mousev <= v2 and h1 <= self.mouseh <= h2): ! self.charcount = self.charcount + len(te) + (sp > 0) ! return ! if self.lastfont is not None: ! self.d.setfont(self.lastfont) ! cc = 0 ! for c in te: ! cw = self.d.textwidth(c) ! if self.mouseh <= h + cw/2: ! return self.charcount + cc ! cc = cc+1 ! h = h+cw ! self.charcount = self.charcount + cc ! if self.mouseh <= (h+h2) / 2: ! return self.charcount ! else: ! return self.charcount + 1 ! # ! def _whereisanchor(self, tuple, word, h, v): ! pass ! # ! # Return screen position corresponding to position in paragraph. ! # Return tuple (h, vtop, vbaseline, vbottom). ! # This is more or less the inverse of whereis() ! def screenpos(self, d, pos): ! if pos < 0: ! ascent, descent = self.lines[0][5:7] ! return self.left, self.top, self.top + ascent, \ ! self.top + ascent + descent ! self.pos = pos ! self.lastfont = None ! try: ! self.d = d ! ok = self.visit(self.__class__._screenposword, \ ! self.__class__._screenposanchor) ! finally: ! self.d = None ! if ok is None: ! ascent, descent = self.lines[-1][5:7] ! ok = self.right, self.bottom - ascent - descent, \ ! self.bottom - descent, self.bottom ! return ok ! # ! def _screenposword(self, tuple, word, h1, v1, h2, v2, isfirst, islast): ! fo, te, wi, sp, st, as, de = word ! if fo is not None: self.lastfont = fo ! cc = len(te) + (sp > 0) ! if self.pos > cc: ! self.pos = self.pos - cc ! return ! if self.pos < cc: ! self.d.setfont(self.lastfont) ! h = h1 + self.d.textwidth(te[:self.pos]) ! else: ! h = h2 ! ascent, descent = tuple[5:7] ! return h, v1, v1+ascent, v2 ! # ! def _screenposanchor(self, tuple, word, h, v): ! pass ! # ! # Invert the stretch of text between pos1 and pos2. ! # If pos1 is None, the beginning is implied; ! # if pos2 is None, the end is implied. ! # Undoes its own effect when called again with the same arguments ! def invert(self, d, pos1, pos2): ! if pos1 is None: ! pos1 = self.left, self.top, self.top, self.top ! else: ! pos1 = self.screenpos(d, pos1) ! if pos2 is None: ! pos2 = self.right, self.bottom,self.bottom,self.bottom ! else: ! pos2 = self.screenpos(d, pos2) ! h1, top1, baseline1, bottom1 = pos1 ! h2, top2, baseline2, bottom2 = pos2 ! if bottom1 <= top2: ! d.invert((h1, top1), (self.right, bottom1)) ! h1 = self.left ! if bottom1 < top2: ! d.invert((h1, bottom1), (self.right, top2)) ! top1, bottom1 = top2, bottom2 ! d.invert((h1, top1), (h2, bottom2)) Index: addpack.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/lib-old/addpack.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** addpack.py 7 Mar 1994 11:45:34 -0000 1.1 --- addpack.py 18 Jul 2004 06:14:43 -0000 1.2 *************** *** 34,67 **** # If no directory is found, ImportError is raised. ! _packs = {} # {pack: [pathname, ...], ...} def addpack(pack, *locations): ! import os ! if os.path.isabs(pack): ! base = os.path.basename(pack) ! else: ! base = pack ! if _packs.has_key(base): ! return ! import sys ! path = [] ! for loc in _flatten(locations) + sys.path: ! fn = os.path.join(loc, base) ! if fn not in path and os.path.isdir(fn): ! path.append(fn) ! if pack != base and pack not in path and os.path.isdir(pack): ! path.append(pack) ! if not path: raise ImportError, 'package ' + pack + ' not found' ! _packs[base] = path ! for fn in path: ! if fn not in sys.path: ! sys.path.append(fn) def _flatten(locations): ! locs = [] ! for loc in locations: ! if type(loc) == type(''): ! locs.append(loc) ! else: ! locs = locs + _flatten(loc) ! return locs --- 34,67 ---- # If no directory is found, ImportError is raised. ! _packs = {} # {pack: [pathname, ...], ...} def addpack(pack, *locations): ! import os ! if os.path.isabs(pack): ! base = os.path.basename(pack) ! else: ! base = pack ! if _packs.has_key(base): ! return ! import sys ! path = [] ! for loc in _flatten(locations) + sys.path: ! fn = os.path.join(loc, base) ! if fn not in path and os.path.isdir(fn): ! path.append(fn) ! if pack != base and pack not in path and os.path.isdir(pack): ! path.append(pack) ! if not path: raise ImportError, 'package ' + pack + ' not found' ! _packs[base] = path ! for fn in path: ! if fn not in sys.path: ! sys.path.append(fn) def _flatten(locations): ! locs = [] ! for loc in locations: ! if type(loc) == type(''): ! locs.append(loc) ! else: ! locs = locs + _flatten(loc) ! return locs Index: codehack.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/lib-old/codehack.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** codehack.py 20 Jul 2001 18:54:44 -0000 1.6 --- codehack.py 18 Jul 2004 06:14:43 -0000 1.7 *************** *** 37,81 **** def getcodename(co): ! try: ! return co.co_name ! except AttributeError: ! pass ! key = `co` # arbitrary but uniquely identifying string ! if _namecache.has_key(key): return _namecache[key] ! filename = co.co_filename ! code = co.co_code ! name = '' ! if ord(code[0]) == SET_LINENO: ! lineno = ord(code[1]) | ord(code[2]) << 8 ! line = linecache.getline(filename, lineno) ! words = line.split() ! if len(words) >= 2 and words[0] in ('def', 'class'): ! name = words[1] ! for i in range(len(name)): ! if name[i] not in identchars: ! name = name[:i] ! break ! _namecache[key] = name ! return name # Use the above routine to find a function's name. def getfuncname(func): ! try: ! return func.func_name ! except AttributeError: ! pass ! return getcodename(func.func_code) # A part of the above code to extract just the line number from a code object. def getlineno(co): ! try: ! return co.co_firstlineno ! except AttributeError: ! pass ! code = co.co_code ! if ord(code[0]) == SET_LINENO: ! return ord(code[1]) | ord(code[2]) << 8 ! else: ! return -1 --- 37,81 ---- def getcodename(co): ! try: ! return co.co_name ! except AttributeError: ! pass ! key = `co` # arbitrary but uniquely identifying string ! if _namecache.has_key(key): return _namecache[key] ! filename = co.co_filename ! code = co.co_code ! name = '' ! if ord(code[0]) == SET_LINENO: ! lineno = ord(code[1]) | ord(code[2]) << 8 ! line = linecache.getline(filename, lineno) ! words = line.split() ! if len(words) >= 2 and words[0] in ('def', 'class'): ! name = words[1] ! for i in range(len(name)): ! if name[i] not in identchars: ! name = name[:i] ! break ! _namecache[key] = name ! return name # Use the above routine to find a function's name. def getfuncname(func): ! try: ! return func.func_name ! except AttributeError: ! pass ! return getcodename(func.func_code) # A part of the above code to extract just the line number from a code object. def getlineno(co): ! try: ! return co.co_firstlineno ! except AttributeError: ! pass ! code = co.co_code ! if ord(code[0]) == SET_LINENO: ! return ord(code[1]) | ord(code[2]) << 8 ! else: ! return -1 Index: dump.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/lib-old/dump.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** dump.py 1 Jan 1992 19:28:43 -0000 1.2 --- dump.py 18 Jul 2004 06:14:43 -0000 1.3 *************** *** 24,63 **** # def dumpsymtab(dict): ! for key in dict.keys(): ! dumpvar(key, dict[key]) # Dump a single variable # def dumpvar(name, x): ! import sys ! t = type(x) ! if t == type({}): ! print name, '= {}' ! for key in x.keys(): ! item = x[key] ! if not printable(item): ! print '#', ! print name, '[', `key`, '] =', `item` ! elif t in (type(''), type(0), type(0.0), type([]), type(())): ! if not printable(x): ! print '#', ! print name, '=', `x` ! elif t == type(sys): ! print 'import', name, '#', x ! else: ! print '#', name, '=', x # check if a value is printable in a way that can be read back with input() # def printable(x): ! t = type(x) ! if t in (type(''), type(0), type(0.0)): ! return 1 ! if t in (type([]), type(())): ! for item in x: ! if not printable(item): ! return 0 ! return 1 ! if x == {}: ! return 1 ! return 0 --- 24,63 ---- # def dumpsymtab(dict): ! for key in dict.keys(): ! dumpvar(key, dict[key]) # Dump a single variable # def dumpvar(name, x): ! import sys ! t = type(x) ! if t == type({}): ! print name, '= {}' ! for key in x.keys(): ! item = x[key] ! if not printable(item): ! print '#', ! print name, '[', `key`, '] =', `item` ! elif t in (type(''), type(0), type(0.0), type([]), type(())): ! if not printable(x): ! print '#', ! print name, '=', `x` ! elif t == type(sys): ! print 'import', name, '#', x ! else: ! print '#', name, '=', x # check if a value is printable in a way that can be read back with input() # def printable(x): ! t = type(x) ! if t in (type(''), type(0), type(0.0)): ! return 1 ! if t in (type([]), type(())): ! for item in x: ! if not printable(item): ! return 0 ! return 1 ! if x == {}: ! return 1 ! return 0 Index: find.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/lib-old/find.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** find.py 27 Jan 1995 02:41:42 -0000 1.1 --- find.py 18 Jul 2004 06:14:43 -0000 1.2 *************** *** 7,26 **** def find(pattern, dir = os.curdir): ! list = [] ! names = os.listdir(dir) ! names.sort() ! for name in names: ! if name in (os.curdir, os.pardir): ! continue ! fullname = os.path.join(dir, name) ! if fnmatch.fnmatch(name, pattern): ! list.append(fullname) ! if os.path.isdir(fullname) and not os.path.islink(fullname): ! for p in _prune: ! if fnmatch.fnmatch(name, p): ! if _debug: print "skip", `fullname` ! break ! else: ! if _debug: print "descend into", `fullname` ! list = list + find(pattern, fullname) ! return list --- 7,26 ---- def find(pattern, dir = os.curdir): ! list = [] ! names = os.listdir(dir) ! names.sort() ! for name in names: ! if name in (os.curdir, os.pardir): ! continue ! fullname = os.path.join(dir, name) ! if fnmatch.fnmatch(name, pattern): ! list.append(fullname) ! if os.path.isdir(fullname) and not os.path.islink(fullname): ! for p in _prune: ! if fnmatch.fnmatch(name, p): ! if _debug: print "skip", `fullname` ! break ! else: ! if _debug: print "descend into", `fullname` ! list = list + find(pattern, fullname) ! return list Index: fmt.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/lib-old/fmt.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** fmt.py 12 Dec 2000 23:11:41 -0000 1.6 --- fmt.py 18 Jul 2004 06:14:43 -0000 1.7 *************** *** 13,106 **** # Formatter back-end to do nothing at all with the paragraphs class NullBackEnd: ! # ! def __init__(self): ! pass ! # ! def addpara(self, p): ! pass ! # ! def bgn_anchor(self, id): [...1140 lines suppressed...] ! def finish(self): ! pass ! # ! def addpara(self, p): ! self.paralist.append(p) ! self.height = p.render(self.d, 0, self.height, self.width) ! # ! def redraw(self): ! import gl ! gl.winset(self.wid) ! width = gl.getsize()[1] ! if width != self.width: ! setdocsize = 1 ! self.width = width ! for p in self.paralist: ! p.top = p.bottom = None ! d = self.d ! v = 0 ! for p in self.paralist: ! v = p.render(d, 0, v, width) Index: grep.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/lib-old/grep.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** grep.py 9 Feb 2001 16:34:24 -0000 1.10 --- grep.py 18 Jul 2004 06:14:43 -0000 1.11 *************** *** 9,79 **** def grep(pat, *files): ! return ggrep(RE_SYNTAX_GREP, pat, files) def egrep(pat, *files): ! return ggrep(RE_SYNTAX_EGREP, pat, files) def emgrep(pat, *files): ! return ggrep(RE_SYNTAX_EMACS, pat, files) def ggrep(syntax, pat, files): ! if len(files) == 1 and type(files[0]) == type([]): ! files = files[0] ! global opt_show_filename ! opt_show_filename = (len(files) != 1) ! syntax = regex.set_syntax(syntax) ! try: ! prog = regex.compile(pat) ! finally: ! syntax = regex.set_syntax(syntax) ! for filename in files: ! fp = open(filename, 'r') ! lineno = 0 ! while 1: ! line = fp.readline() ! if not line: break ! lineno = lineno + 1 ! if prog.search(line) >= 0: ! showline(filename, lineno, line, prog) ! fp.close() def pgrep(pat, *files): ! if len(files) == 1 and type(files[0]) == type([]): ! files = files[0] ! global opt_show_filename ! opt_show_filename = (len(files) != 1) ! import re ! prog = re.compile(pat) ! for filename in files: ! fp = open(filename, 'r') ! lineno = 0 ! while 1: ! line = fp.readline() ! if not line: break ! lineno = lineno + 1 ! if prog.search(line): ! showline(filename, lineno, line, prog) ! fp.close() def showline(filename, lineno, line, prog): ! if line[-1:] == '\n': line = line[:-1] ! if opt_show_lineno: ! prefix = `lineno`.rjust(3) + ': ' ! else: ! prefix = '' ! if opt_show_filename: ! prefix = filename + ': ' + prefix ! print prefix + line ! if opt_show_where: ! start, end = prog.regs()[0] ! line = line[:start] ! if '\t' not in line: ! prefix = ' ' * (len(prefix) + start) ! else: ! prefix = ' ' * len(prefix) ! for c in line: ! if c != '\t': c = ' ' ! prefix = prefix + c ! if start == end: prefix = prefix + '\\' ! else: prefix = prefix + '^'*(end-start) ! print prefix --- 9,79 ---- def grep(pat, *files): ! return ggrep(RE_SYNTAX_GREP, pat, files) def egrep(pat, *files): ! return ggrep(RE_SYNTAX_EGREP, pat, files) def emgrep(pat, *files): ! return ggrep(RE_SYNTAX_EMACS, pat, files) def ggrep(syntax, pat, files): ! if len(files) == 1 and type(files[0]) == type([]): ! files = files[0] ! global opt_show_filename ! opt_show_filename = (len(files) != 1) ! syntax = regex.set_syntax(syntax) ! try: ! prog = regex.compile(pat) ! finally: ! syntax = regex.set_syntax(syntax) ! for filename in files: ! fp = open(filename, 'r') ! lineno = 0 ! while 1: ! line = fp.readline() ! if not line: break ! lineno = lineno + 1 ! if prog.search(line) >= 0: ! showline(filename, lineno, line, prog) ! fp.close() def pgrep(pat, *files): ! if len(files) == 1 and type(files[0]) == type([]): ! files = files[0] ! global opt_show_filename ! opt_show_filename = (len(files) != 1) ! import re ! prog = re.compile(pat) ! for filename in files: ! fp = open(filename, 'r') ! lineno = 0 ! while 1: ! line = fp.readline() ! if not line: break ! lineno = lineno + 1 ! if prog.search(line): ! showline(filename, lineno, line, prog) ! fp.close() def showline(filename, lineno, line, prog): ! if line[-1:] == '\n': line = line[:-1] ! if opt_show_lineno: ! prefix = `lineno`.rjust(3) + ': ' ! else: ! prefix = '' ! if opt_show_filename: ! prefix = filename + ': ' + prefix ! print prefix + line ! if opt_show_where: ! start, end = prog.regs()[0] ! line = line[:start] ! if '\t' not in line: ! prefix = ' ' * (len(prefix) + start) ! else: ! prefix = ' ' * len(prefix) ! for c in line: ! if c != '\t': c = ' ' ! prefix = prefix + c ! if start == end: prefix = prefix + '\\' ! else: prefix = prefix + '^'*(end-start) ! print prefix Index: lockfile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/lib-old/lockfile.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** lockfile.py 10 May 2001 15:33:31 -0000 1.2 --- lockfile.py 18 Jul 2004 06:14:43 -0000 1.3 *************** *** 2,15 **** def writelock(f): ! _lock(f, fcntl.F_WRLCK) def readlock(f): ! _lock(f, fcntl.F_RDLCK) def unlock(f): ! _lock(f, fcntl.F_UNLCK) def _lock(f, op): ! dummy = fcntl.fcntl(f.fileno(), fcntl.F_SETLKW, ! struct.pack('2h8l', op, ! 0, 0, 0, 0, 0, 0, 0, 0, 0)) --- 2,15 ---- def writelock(f): ! _lock(f, fcntl.F_WRLCK) def readlock(f): ! _lock(f, fcntl.F_RDLCK) def unlock(f): ! _lock(f, fcntl.F_UNLCK) def _lock(f, op): ! dummy = fcntl.fcntl(f.fileno(), fcntl.F_SETLKW, ! struct.pack('2h8l', op, ! 0, 0, 0, 0, 0, 0, 0, 0, 0)) Index: newdir.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/lib-old/newdir.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** newdir.py 1 Aug 1994 11:28:43 -0000 1.5 --- newdir.py 18 Jul 2004 06:14:43 -0000 1.6 *************** *** 6,58 **** def listattrs(x): ! try: ! dictkeys = x.__dict__.keys() ! except (AttributeError, TypeError): ! dictkeys = [] ! # ! try: ! methods = x.__methods__ ! except (AttributeError, TypeError): ! methods = [] ! # ! try: ! members = x.__members__ ! except (AttributeError, TypeError): ! members = [] ! # ! try: ! the_class = x.__class__ ! except (AttributeError, TypeError): ! the_class = None ! # ! try: ! bases = x.__bases__ ! except (AttributeError, TypeError): ! bases = () ! # ! total = dictkeys + methods + members ! if the_class: ! # It's a class instace; add the class's attributes ! # that are functions (methods)... ! class_attrs = listattrs(the_class) ! class_methods = [] ! for name in class_attrs: ! if is_function(getattr(the_class, name)): ! class_methods.append(name) ! total = total + class_methods ! elif bases: ! # It's a derived class; add the base class attributes ! for base in bases: ! base_attrs = listattrs(base) ! total = total + base_attrs ! total.sort() ! return total ! i = 0 ! while i+1 < len(total): ! if total[i] == total[i+1]: ! del total[i+1] ! else: ! i = i+1 ! return total --- 6,58 ---- def listattrs(x): ! try: ! dictkeys = x.__dict__.keys() ! except (AttributeError, TypeError): ! dictkeys = [] ! # ! try: ! methods = x.__methods__ ! except (AttributeError, TypeError): ! methods = [] ! # ! try: ! members = x.__members__ ! except (AttributeError, TypeError): ! members = [] ! # ! try: ! the_class = x.__class__ ! except (AttributeError, TypeError): ! the_class = None ! # ! try: ! bases = x.__bases__ ! except (AttributeError, TypeError): ! bases = () ! # ! total = dictkeys + methods + members ! if the_class: ! # It's a class instace; add the class's attributes ! # that are functions (methods)... ! class_attrs = listattrs(the_class) ! class_methods = [] ! for name in class_attrs: ! if is_function(getattr(the_class, name)): ! class_methods.append(name) ! total = total + class_methods ! elif bases: ! # It's a derived class; add the base class attributes ! for base in bases: ! base_attrs = listattrs(base) ! total = total + base_attrs ! total.sort() ! return total ! i = 0 ! while i+1 < len(total): ! if total[i] == total[i+1]: ! del total[i+1] ! else: ! i = i+1 ! return total *************** *** 60,64 **** def is_function(x): ! return type(x) == type(is_function) --- 60,64 ---- def is_function(x): ! return type(x) == type(is_function) *************** *** 67,73 **** def dir(x = None): ! if x is not None: ! return listattrs(x) ! else: ! import __main__ ! return listattrs(__main__) --- 67,73 ---- def dir(x = None): ! if x is not None: ! return listattrs(x) ! else: ! import __main__ ! return listattrs(__main__) Index: packmail.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/lib-old/packmail.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** packmail.py 9 Feb 2001 16:25:20 -0000 1.10 --- packmail.py 18 Jul 2004 06:14:43 -0000 1.11 *************** *** 9,111 **** # Print help def help(): ! print 'All fns have a file open for writing as first parameter' ! print 'pack(f, fullname, name): pack fullname as name' ! print 'packsome(f, directory, namelist): selected files from directory' ! print 'packall(f, directory): pack all files from directory' ! print 'packnotolder(f, directory, name): pack all files from directory' ! print ' that are not older than a file there' ! print 'packtree(f, directory): pack entire directory tree' # Pack one file def pack(outfp, file, name): ! fp = open(file, 'r') ! outfp.write('echo ' + name + '\n') ! outfp.write('sed "s/^X//" >"' + name + '" <<"!"\n') ! while 1: ! line = fp.readline() ! if not line: break ! if line[-1:] != '\n': ! line = line + '\n' ! outfp.write('X' + line) ! outfp.write('!\n') ! fp.close() # Pack some files from a directory def packsome(outfp, dirname, names): ! for name in names: ! print name ! file = os.path.join(dirname, name) ! pack(outfp, file, name) # Pack all files from a directory def packall(outfp, dirname): ! names = os.listdir(dirname) ! try: ! names.remove('.') ! except: ! pass ! try: ! names.remove('..') ! except: ! pass ! names.sort() ! packsome(outfp, dirname, names) # Pack all files from a directory that are not older than a give one def packnotolder(outfp, dirname, oldest): ! names = os.listdir(dirname) ! try: ! names.remove('.') ! except: ! pass ! try: ! names.remove('..') ! except: ! pass ! oldest = os.path.join(dirname, oldest) ! st = os.stat(oldest) ! mtime = st[ST_MTIME] ! todo = [] ! for name in names: ! print name, '...', ! st = os.stat(os.path.join(dirname, name)) ! if st[ST_MTIME] >= mtime: ! print 'Yes.' ! todo.append(name) ! else: ! print 'No.' ! todo.sort() ! packsome(outfp, dirname, todo) # Pack a whole tree (no exceptions) def packtree(outfp, dirname): ! print 'packtree', dirname ! outfp.write('mkdir ' + unixfix(dirname) + '\n') ! names = os.listdir(dirname) ! try: ! names.remove('.') ! except: ! pass ! try: ! names.remove('..') ! except: ! pass ! subdirs = [] ! for name in names: ! fullname = os.path.join(dirname, name) ! if os.path.isdir(fullname): ! subdirs.append(fullname) ! else: ! print 'pack', fullname ! pack(outfp, fullname, unixfix(fullname)) ! for subdirname in subdirs: ! packtree(outfp, subdirname) def unixfix(name): ! comps = name.split(os.sep) ! res = '' ! for comp in comps: ! if comp: ! if res: res = res + '/' ! res = res + comp ! return res --- 9,111 ---- # Print help def help(): ! print 'All fns have a file open for writing as first parameter' ! print 'pack(f, fullname, name): pack fullname as name' ! print 'packsome(f, directory, namelist): selected files from directory' ! print 'packall(f, directory): pack all files from directory' ! print 'packnotolder(f, directory, name): pack all files from directory' ! print ' that are not older than a file there' ! print 'packtree(f, directory): pack entire directory tree' # Pack one file def pack(outfp, file, name): ! fp = open(file, 'r') ! outfp.write('echo ' + name + '\n') ! outfp.write('sed "s/^X//" >"' + name + '" <<"!"\n') ! while 1: ! line = fp.readline() ! if not line: break ! if line[-1:] != '\n': ! line = line + '\n' ! outfp.write('X' + line) ! outfp.write('!\n') ! fp.close() # Pack some files from a directory def packsome(outfp, dirname, names): ! for name in names: ! print name ! file = os.path.join(dirname, name) ! pack(outfp, file, name) # Pack all files from a directory def packall(outfp, dirname): ! names = os.listdir(dirname) ! try: ! names.remove('.') ! except: ! pass ! try: ! names.remove('..') ! except: ! pass ! names.sort() ! packsome(outfp, dirname, names) # Pack all files from a directory that are not older than a give one def packnotolder(outfp, dirname, oldest): ! names = os.listdir(dirname) ! try: ! names.remove('.') ! except: ! pass ! try: ! names.remove('..') ! except: ! pass ! oldest = os.path.join(dirname, oldest) ! st = os.stat(oldest) ! mtime = st[ST_MTIME] ! todo = [] ! for name in names: ! print name, '...', ! st = os.stat(os.path.join(dirname, name)) ! if st[ST_MTIME] >= mtime: ! print 'Yes.' ! todo.append(name) ! else: ! print 'No.' ! todo.sort() ! packsome(outfp, dirname, todo) # Pack a whole tree (no exceptions) def packtree(outfp, dirname): ! print 'packtree', dirname ! outfp.write('mkdir ' + unixfix(dirname) + '\n') ! names = os.listdir(dirname) ! try: ! names.remove('.') ! except: ! pass ! try: ! names.remove('..') ! except: ! pass ! subdirs = [] ! for name in names: ! fullname = os.path.join(dirname, name) ! if os.path.isdir(fullname): ! subdirs.append(fullname) ! else: ! print 'pack', fullname ! pack(outfp, fullname, unixfix(fullname)) ! for subdirname in subdirs: ! packtree(outfp, subdirname) def unixfix(name): ! comps = name.split(os.sep) ! res = '' ! for comp in comps: ! if comp: ! if res: res = res + '/' ! res = res + comp ! return res Index: poly.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/lib-old/poly.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** poly.py 22 Feb 1999 15:19:47 -0000 1.2 --- poly.py 18 Jul 2004 06:14:43 -0000 1.3 *************** *** 7,52 **** def normalize(p): # Strip unnecessary zero coefficients ! n = len(p) ! while n: ! if p[n-1]: return p[:n] ! n = n-1 ! return [] def plus(a, b): ! if len(a) < len(b): a, b = b, a # make sure a is the longest ! res = a[:] # make a copy ! for i in range(len(b)): ! res[i] = res[i] + b[i] ! return normalize(res) def minus(a, b): ! neg_b = map(lambda x: -x, b[:]) ! return plus(a, neg_b) def one(power, coeff): # Representation of coeff * x**power ! res = [] ! for i in range(power): res.append(0) ! return res + [coeff] def times(a, b): ! res = [] ! for i in range(len(a)): ! for j in range(len(b)): ! res = plus(res, one(i+j, a[i]*b[j])) ! return res def power(a, n): # Raise polynomial a to the positive integral power n ! if n == 0: return [1] ! if n == 1: return a ! if n/2*2 == n: ! b = power(a, n/2) ! return times(b, b) ! return times(power(a, n-1), a) def der(a): # First derivative ! res = a[1:] ! for i in range(len(res)): ! res[i] = res[i] * (i+1) ! return res # Computing a primitive function would require rational arithmetic... --- 7,52 ---- def normalize(p): # Strip unnecessary zero coefficients ! n = len(p) ! while n: ! if p[n-1]: return p[:n] ! n = n-1 ! return [] def plus(a, b): ! if len(a) < len(b): a, b = b, a # make sure a is the longest ! res = a[:] # make a copy ! for i in range(len(b)): ! res[i] = res[i] + b[i] ! return normalize(res) def minus(a, b): ! neg_b = map(lambda x: -x, b[:]) ! return plus(a, neg_b) def one(power, coeff): # Representation of coeff * x**power ! res = [] ! for i in range(power): res.append(0) ! return res + [coeff] def times(a, b): ! res = [] ! for i in range(len(a)): ! for j in range(len(b)): ! res = plus(res, one(i+j, a[i]*b[j])) ! return res def power(a, n): # Raise polynomial a to the positive integral power n ! if n == 0: return [1] ! if n == 1: return a ! if n/2*2 == n: ! b = power(a, n/2) ! return times(b, b) ! return times(power(a, n-1), a) def der(a): # First derivative ! res = a[1:] ! for i in range(len(res)): ! res[i] = res[i] * (i+1) ! return res # Computing a primitive function would require rational arithmetic... Index: rand.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/lib-old/rand.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** rand.py 16 Aug 1991 13:28:11 -0000 1.2 --- rand.py 18 Jul 2004 06:14:43 -0000 1.3 *************** *** 5,13 **** def srand(seed): ! whrandom.seed(seed%256, seed/256%256, seed/65536%256) def rand(): ! return int(whrandom.random() * 32768.0) % 32768 def choice(seq): ! return seq[rand() % len(seq)] --- 5,13 ---- def srand(seed): ! whrandom.seed(seed%256, seed/256%256, seed/65536%256) def rand(): ! return int(whrandom.random() * 32768.0) % 32768 def choice(seq): ! return seq[rand() % len(seq)] Index: tb.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/lib-old/tb.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** tb.py 9 Feb 2001 11:29:54 -0000 1.9 --- tb.py 18 Jul 2004 06:14:43 -0000 1.10 *************** *** 13,177 **** def browser(tb): ! if not tb: ! print 'No traceback.' ! return ! tblist = [] ! while tb: ! tblist.append(tb) ! tb = tb.tb_next ! ptr = len(tblist)-1 ! tb = tblist[ptr] ! while 1: ! if tb != tblist[ptr]: ! tb = tblist[ptr] ! print `ptr` + ':', ! printtbheader(tb) ! try: ! line = raw_input('TB: ') ! except KeyboardInterrupt: ! print '\n[Interrupted]' ! break ! except EOFError: ! print '\n[EOF]' ! break ! cmd = line.strip() ! if cmd: ! if cmd == 'quit': ! break ! elif cmd == 'list': ! browserlist(tb) ! elif cmd == 'up': ! if ptr-1 >= 0: ptr = ptr-1 ! else: print 'Bottom of stack.' ! elif cmd == 'down': ! if ptr+1 < len(tblist): ptr = ptr+1 ! else: print 'Top of stack.' ! elif cmd == 'locals': ! printsymbols(tb.tb_frame.f_locals) ! elif cmd == 'globals': ! printsymbols(tb.tb_frame.f_globals) ! elif cmd in ('?', 'help'): ! browserhelp() ! else: ! browserexec(tb, cmd) def browserlist(tb): ! filename = tb.tb_frame.f_code.co_filename ! lineno = tb.tb_lineno ! last = lineno ! first = max(1, last-10) ! for i in range(first, last+1): ! if i == lineno: prefix = '***' + `i`.rjust(4) + ':' ! else: prefix = `i`.rjust(7) + ':' ! line = linecache.getline(filename, i) ! if line[-1:] == '\n': line = line[:-1] ! print prefix + line def browserexec(tb, cmd): ! locals = tb.tb_frame.f_locals ! globals = tb.tb_frame.f_globals ! try: ! exec cmd+'\n' in globals, locals ! except: ! t, v = sys.exc_info()[:2] ! print '*** Exception:', ! if type(t) is type(''): ! print t, ! else: ! print t.__name__, ! if v is not None: ! print ':', v, ! print ! print 'Type help to get help.' def browserhelp(): ! print ! print ' This is the traceback browser. Commands are:' ! print ' up : move one level up in the call stack' ! print ' down : move one level down in the call stack' ! print ' locals : print all local variables at this level' ! print ' globals : print all global variables at this level' ! print ' list : list source code around the failure' ! print ' help : print help (what you are reading now)' ! print ' quit : back to command interpreter' ! print ' Typing any other 1-line statement will execute it' ! print ' using the current level\'s symbol tables' ! print def printtb(tb): ! while tb: ! print1tb(tb) ! tb = tb.tb_next def print1tb(tb): ! printtbheader(tb) ! if tb.tb_frame.f_locals is not tb.tb_frame.f_globals: ! printsymbols(tb.tb_frame.f_locals) def printtbheader(tb): ! filename = tb.tb_frame.f_code.co_filename ! lineno = tb.tb_lineno ! info = '"' + filename + '"(' + `lineno` + ')' ! line = linecache.getline(filename, lineno) ! if line: ! info = info + ': ' + line.strip() ! print info def printsymbols(d): ! keys = d.keys() ! keys.sort() ! for name in keys: ! print ' ' + name.ljust(12) + ':', ! printobject(d[name], 4) ! print def printobject(v, maxlevel): ! if v is None: ! print 'None', ! elif type(v) in (type(0), type(0.0)): ! print v, ! elif type(v) is type(''): ! if len(v) > 20: ! print `v[:17] + '...'`, ! else: ! print `v`, ! elif type(v) is type(()): ! print '(', ! printlist(v, maxlevel) ! print ')', ! elif type(v) is type([]): ! print '[', ! printlist(v, maxlevel) ! print ']', ! elif type(v) is type({}): ! print '{', ! printdict(v, maxlevel) ! print '}', ! else: ! print v, def printlist(v, maxlevel): ! n = len(v) ! if n == 0: return ! if maxlevel <= 0: ! print '...', ! return ! for i in range(min(6, n)): ! printobject(v[i], maxlevel-1) ! if i+1 < n: print ',', ! if n > 6: print '...', def printdict(v, maxlevel): ! keys = v.keys() ! n = len(keys) ! if n == 0: return ! if maxlevel <= 0: ! print '...', ! return ! keys.sort() ! for i in range(min(6, n)): ! key = keys[i] ! print `key` + ':', ! printobject(v[key], maxlevel-1) ! if i+1 < n: print ',', ! if n > 6: print '...', --- 13,177 ---- def browser(tb): ! if not tb: ! print 'No traceback.' ! return ! tblist = [] ! while tb: ! tblist.append(tb) ! tb = tb.tb_next ! ptr = len(tblist)-1 ! tb = tblist[ptr] ! while 1: ! if tb != tblist[ptr]: ! tb = tblist[ptr] ! print `ptr` + ':', ! printtbheader(tb) ! try: ! line = raw_input('TB: ') ! except KeyboardInterrupt: ! print '\n[Interrupted]' ! break ! except EOFError: ! print '\n[EOF]' ! break ! cmd = line.strip() ! if cmd: ! if cmd == 'quit': ! break ! elif cmd == 'list': ! browserlist(tb) ! elif cmd == 'up': ! if ptr-1 >= 0: ptr = ptr-1 ! else: print 'Bottom of stack.' ! elif cmd == 'down': ! if ptr+1 < len(tblist): ptr = ptr+1 ! else: print 'Top of stack.' ! elif cmd == 'locals': ! printsymbols(tb.tb_frame.f_locals) ! elif cmd == 'globals': ! printsymbols(tb.tb_frame.f_globals) ! elif cmd in ('?', 'help'): ! browserhelp() ! else: ! browserexec(tb, cmd) def browserlist(tb): ! filename = tb.tb_frame.f_code.co_filename ! lineno = tb.tb_lineno ! last = lineno ! first = max(1, last-10) ! for i in range(first, last+1): ! if i == lineno: prefix = '***' + `i`.rjust(4) + ':' ! else: prefix = `i`.rjust(7) + ':' ! line = linecache.getline(filename, i) ! if line[-1:] == '\n': line = line[:-1] ! print prefix + line def browserexec(tb, cmd): ! locals = tb.tb_frame.f_locals ! globals = tb.tb_frame.f_globals ! try: ! exec cmd+'\n' in globals, locals ! except: ! t, v = sys.exc_info()[:2] ! print '*** Exception:', ! if type(t) is type(''): ! print t, ! else: ! print t.__name__, ! if v is not None: ! print ':', v, ! print ! print 'Type help to get help.' def browserhelp(): ! print ! print ' This is the traceback browser. Commands are:' ! print ' up : move one level up in the call stack' ! print ' down : move one level down in the call stack' ! print ' locals : print all local variables at this level' ! print ' globals : print all global variables at this level' ! print ' list : list source code around the failure' ! print ' help : print help (what you are reading now)' ! print ' quit : back to command interpreter' ! print ' Typing any other 1-line statement will execute it' ! print ' using the current level\'s symbol tables' ! print def printtb(tb): ! while tb: ! print1tb(tb) ! tb = tb.tb_next def print1tb(tb): ! printtbheader(tb) ! if tb.tb_frame.f_locals is not tb.tb_frame.f_globals: ! printsymbols(tb.tb_frame.f_locals) def printtbheader(tb): ! filename = tb.tb_frame.f_code.co_filename ! lineno = tb.tb_lineno ! info = '"' + filename + '"(' + `lineno` + ')' ! line = linecache.getline(filename, lineno) ! if line: ! info = info + ': ' + line.strip() ! print info def printsymbols(d): ! keys = d.keys() ! keys.sort() ! for name in keys: ! print ' ' + name.ljust(12) + ':', ! printobject(d[name], 4) ! print def printobject(v, maxlevel): ! if v is None: ! print 'None', ! elif type(v) in (type(0), type(0.0)): ! print v, ! elif type(v) is type(''): ! if len(v) > 20: ! print `v[:17] + '...'`, ! else: ! print `v`, ! elif type(v) is type(()): ! print '(', ! printlist(v, maxlevel) ! print ')', ! elif type(v) is type([]): ! print '[', ! printlist(v, maxlevel) ! print ']', ! elif type(v) is type({}): ! print '{', ! printdict(v, maxlevel) ! print '}', ! else: ! print v, def printlist(v, maxlevel): ! n = len(v) ! if n == 0: return ! if maxlevel <= 0: ! print '...', ! return ! for i in range(min(6, n)): ! printobject(v[i], maxlevel-1) ! if i+1 < n: print ',', ! if n > 6: print '...', def printdict(v, maxlevel): ! keys = v.keys() ! n = len(keys) ! if n == 0: return ! if maxlevel <= 0: ! print '...', ! return ! keys.sort() ! for i in range(min(6, n)): ! key = keys[i] ! print `key` + ':', ! printobject(v[key], maxlevel-1) ! if i+1 < n: print ',', ! if n > 6: print '...', Index: util.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/lib-old/util.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** util.py 21 Apr 1991 19:34:48 -0000 1.4 --- util.py 18 Jul 2004 06:14:43 -0000 1.5 *************** *** 11,15 **** # def remove(item, list): ! if item in list: list.remove(item) --- 11,15 ---- # def remove(item, list): ! if item in list: list.remove(item) *************** *** 17,21 **** # def readfile(fn): ! return readopenfile(open(fn, 'r')) --- 17,21 ---- # def readfile(fn): ! return readopenfile(open(fn, 'r')) *************** *** 23,25 **** # def readopenfile(fp): ! return fp.read() --- 23,25 ---- # def readopenfile(fp): ! return fp.read() Index: zmod.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/lib-old/zmod.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** zmod.py 12 Dec 2000 23:11:41 -0000 1.2 --- zmod.py 18 Jul 2004 06:14:43 -0000 1.3 *************** *** 2,6 **** # Compute properties of mathematical "fields" formed by taking ! # Z/n (the whole numbers modulo some whole number n) and an # irreducible polynomial (i.e., a polynomial with only complex zeros), # e.g., Z/5 and X**2 + 2. --- 2,6 ---- # Compute properties of mathematical "fields" formed by taking ! # Z/n (the whole numbers modulo some whole number n) and an # irreducible polynomial (i.e., a polynomial with only complex zeros), # e.g., Z/5 and X**2 + 2. *************** *** 31,35 **** def mod(x, y): ! return divmod(x, y)[1] --- 31,35 ---- def mod(x, y): ! return divmod(x, y)[1] *************** *** 37,45 **** def norm(a, n, p): ! a = poly.modulo(a, p) ! a = a[:] ! for i in range(len(a)): a[i] = mod(a[i], n) ! a = poly.normalize(a) ! return a --- 37,45 ---- def norm(a, n, p): ! a = poly.modulo(a, p) ! a = a[:] ! for i in range(len(a)): a[i] = mod(a[i], n) ! a = poly.normalize(a) ! return a *************** *** 47,94 **** def make_all(mat): ! all = [] ! for row in mat: ! for a in row: ! all.append(a) ! return all def make_elements(n, d): ! if d == 0: return [poly.one(0, 0)] ! sub = make_elements(n, d-1) ! all = [] ! for a in sub: ! for i in range(n): ! all.append(poly.plus(a, poly.one(d-1, i))) ! return all def make_inv(all, n, p): ! x = poly.one(1, 1) ! inv = [] ! for a in all: ! inv.append(norm(poly.times(a, x), n, p)) ! return inv def checkfield(n, p): ! all = make_elements(n, len(p)-1) ! inv = make_inv(all, n, p) ! all1 = all[:] ! inv1 = inv[:] ! all1.sort() ! inv1.sort() ! if all1 == inv1: print 'BINGO!' ! else: ! print 'Sorry:', n, p ! print all ! print inv def rj(s, width): ! if type(s) is not type(''): s = `s` ! n = len(s) ! if n >= width: return s ! return ' '*(width - n) + s def lj(s, width): ! if type(s) is not type(''): s = `s` ! n = len(s) ! if n >= width: return s ! return s + ' '*(width - n) --- 47,94 ---- def make_all(mat): ! all = [] ! for row in mat: ! for a in row: ! all.append(a) ! return all def make_elements(n, d): ! if d == 0: return [poly.one(0, 0)] ! sub = make_elements(n, d-1) ! all = [] ! for a in sub: ! for i in range(n): ! all.append(poly.plus(a, poly.one(d-1, i))) ! return all def make_inv(all, n, p): ! x = poly.one(1, 1) ! inv = [] ! for a in all: ! inv.append(norm(poly.times(a, x), n, p)) ! return inv def checkfield(n, p): ! all = make_elements(n, len(p)-1) ! inv = make_inv(all, n, p) ! all1 = all[:] ! inv1 = inv[:] ! all1.sort() ! inv1.sort() ! if all1 == inv1: print 'BINGO!' ! else: ! print 'Sorry:', n, p ! print all ! print inv def rj(s, width): ! if type(s) is not type(''): s = `s` ! n = len(s) ! if n >= width: return s ! return ' '*(width - n) + s def lj(s, width): ! if type(s) is not type(''): s = `s` ! n = len(s) ! if n >= width: return s ! return s + ' '*(width - n) From tim_one at users.sourceforge.net Sun Jul 18 08:15:19 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 08:15:36 2004 Subject: [Python-checkins] python/dist/src/Lib/plat-irix5 AL.py, 1.3, 1.4 CD.py, 1.2, 1.3 CL.py, 1.4, 1.5 CL_old.py, 1.2, 1.3 FL.py, 1.8, 1.9 SV.py, 1.2, 1.3 cddb.py, 1.12, 1.13 cdplayer.py, 1.9, 1.10 flp.py, 1.21, 1.22 jpeg.py, 1.4, 1.5 panel.py, 1.7, 1.8 panelparser.py, 1.3, 1.4 readcd.py, 1.13, 1.14 torgb.py, 1.10, 1.11 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/plat-irix5 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31286/plat-irix5 Modified Files: AL.py CD.py CL.py CL_old.py FL.py SV.py cddb.py cdplayer.py flp.py jpeg.py panel.py panelparser.py readcd.py torgb.py Log Message: Whitespace normalization, via reindent.py. Index: AL.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-irix5/AL.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** AL.py 13 Dec 1996 00:19:15 -0000 1.3 --- AL.py 18 Jul 2004 06:14:44 -0000 1.4 *************** *** 1,61 **** ! RATE_48000 = 48000 ! RATE_44100 = 44100 ! RATE_32000 = 32000 ! RATE_22050 = 22050 ! RATE_16000 = 16000 ! RATE_11025 = 11025 ! RATE_8000 = 8000 SAMPFMT_TWOSCOMP= 1 ! SAMPFMT_FLOAT = 32 ! SAMPFMT_DOUBLE = 64 ! SAMPLE_8 = 1 ! SAMPLE_16 = 2 ! # SAMPLE_24 is the low 24 bits of a long, sign extended to 32 bits ! SAMPLE_24 = 4 ! MONO = 1 ! STEREO = 2 ! QUADRO = 4 # 4CHANNEL is not a legal Python name ! INPUT_LINE = 0 ! INPUT_MIC = 1 ! INPUT_DIGITAL = 2 ! MONITOR_OFF = 0 ! MONITOR_ON = 1 ! ERROR_NUMBER = 0 ! ERROR_TYPE = 1 ! ERROR_LOCATION_LSP = 2 ! ERROR_LOCATION_MSP = 3 ! ERROR_LENGTH = 4 ! ERROR_INPUT_UNDERFLOW = 0 ! ERROR_OUTPUT_OVERFLOW = 1 # These seem to be not supported anymore: ! ##HOLD, RELEASE = 0, 1 ! ##ATTAIL, ATHEAD, ATMARK, ATTIME = 0, 1, 2, 3 ! DEFAULT_DEVICE = 1 ! INPUT_SOURCE = 0 ! LEFT_INPUT_ATTEN = 1 ! RIGHT_INPUT_ATTEN = 2 ! INPUT_RATE = 3 ! OUTPUT_RATE = 4 ! LEFT_SPEAKER_GAIN = 5 ! RIGHT_SPEAKER_GAIN = 6 ! INPUT_COUNT = 7 ! OUTPUT_COUNT = 8 ! UNUSED_COUNT = 9 ! SYNC_INPUT_TO_AES = 10 ! SYNC_OUTPUT_TO_AES = 11 ! MONITOR_CTL = 12 ! LEFT_MONITOR_ATTEN = 13 ! RIGHT_MONITOR_ATTEN = 14 ! ENUM_VALUE = 0 # only certain values are valid ! RANGE_VALUE = 1 # any value in range is valid --- 1,61 ---- ! RATE_48000 = 48000 ! RATE_44100 = 44100 ! RATE_32000 = 32000 ! RATE_22050 = 22050 ! RATE_16000 = 16000 ! RATE_11025 = 11025 ! RATE_8000 = 8000 SAMPFMT_TWOSCOMP= 1 ! SAMPFMT_FLOAT = 32 ! SAMPFMT_DOUBLE = 64 ! SAMPLE_8 = 1 ! SAMPLE_16 = 2 ! # SAMPLE_24 is the low 24 bits of a long, sign extended to 32 bits ! SAMPLE_24 = 4 ! MONO = 1 ! STEREO = 2 ! QUADRO = 4 # 4CHANNEL is not a legal Python name ! INPUT_LINE = 0 ! INPUT_MIC = 1 ! INPUT_DIGITAL = 2 ! MONITOR_OFF = 0 ! MONITOR_ON = 1 ! ERROR_NUMBER = 0 ! ERROR_TYPE = 1 ! ERROR_LOCATION_LSP = 2 ! ERROR_LOCATION_MSP = 3 ! ERROR_LENGTH = 4 ! ERROR_INPUT_UNDERFLOW = 0 ! ERROR_OUTPUT_OVERFLOW = 1 # These seem to be not supported anymore: ! ##HOLD, RELEASE = 0, 1 ! ##ATTAIL, ATHEAD, ATMARK, ATTIME = 0, 1, 2, 3 ! DEFAULT_DEVICE = 1 ! INPUT_SOURCE = 0 ! LEFT_INPUT_ATTEN = 1 ! RIGHT_INPUT_ATTEN = 2 ! INPUT_RATE = 3 ! OUTPUT_RATE = 4 ! LEFT_SPEAKER_GAIN = 5 ! RIGHT_SPEAKER_GAIN = 6 ! INPUT_COUNT = 7 ! OUTPUT_COUNT = 8 ! UNUSED_COUNT = 9 ! SYNC_INPUT_TO_AES = 10 ! SYNC_OUTPUT_TO_AES = 11 ! MONITOR_CTL = 12 ! LEFT_MONITOR_ATTEN = 13 ! RIGHT_MONITOR_ATTEN = 14 ! ENUM_VALUE = 0 # only certain values are valid ! RANGE_VALUE = 1 # any value in range is valid Index: CD.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-irix5/CD.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CD.py 6 May 1992 11:38:11 -0000 1.2 --- CD.py 18 Jul 2004 06:14:44 -0000 1.3 *************** *** 1,34 **** ! ERROR = 0 ! NODISC = 1 ! READY = 2 ! PLAYING = 3 ! PAUSED = 4 ! STILL = 5 ! AUDIO = 0 ! PNUM = 1 ! INDEX = 2 ! PTIME = 3 ! ATIME = 4 ! CATALOG = 5 ! IDENT = 6 ! CONTROL = 7 ! CDDA_DATASIZE = 2352 ! ##CDDA_SUBCODESIZE = (sizeof(struct subcodeQ)) ! ##CDDA_BLOCKSIZE = (sizeof(struct cdframe)) ! ##CDDA_NUMSAMPLES = (CDDA_DATASIZE/2) ## ! ##CDQ_PREEMP_MASK = 0xd ! ##CDQ_COPY_MASK = 0xb ! ##CDQ_DDATA_MASK = 0xd ! ##CDQ_BROADCAST_MASK = 0x8 ! ##CDQ_PREEMPHASIS = 0x1 ! ##CDQ_COPY_PERMITTED = 0x2 ! ##CDQ_DIGITAL_DATA = 0x4 ! ##CDQ_BROADCAST_USE = 0x8 ## ! ##CDQ_MODE1 = 0x1 ! ##CDQ_MODE2 = 0x2 ! ##CDQ_MODE3 = 0x3 --- 1,34 ---- ! ERROR = 0 ! NODISC = 1 ! READY = 2 ! PLAYING = 3 ! PAUSED = 4 ! STILL = 5 ! AUDIO = 0 ! PNUM = 1 ! INDEX = 2 ! PTIME = 3 ! ATIME = 4 ! CATALOG = 5 ! IDENT = 6 ! CONTROL = 7 ! CDDA_DATASIZE = 2352 ! ##CDDA_SUBCODESIZE = (sizeof(struct subcodeQ)) ! ##CDDA_BLOCKSIZE = (sizeof(struct cdframe)) ! ##CDDA_NUMSAMPLES = (CDDA_DATASIZE/2) ## ! ##CDQ_PREEMP_MASK = 0xd ! ##CDQ_COPY_MASK = 0xb ! ##CDQ_DDATA_MASK = 0xd ! ##CDQ_BROADCAST_MASK = 0x8 ! ##CDQ_PREEMPHASIS = 0x1 ! ##CDQ_COPY_PERMITTED = 0x2 ! ##CDQ_DIGITAL_DATA = 0x4 ! ##CDQ_BROADCAST_USE = 0x8 ## ! ##CDQ_MODE1 = 0x1 ! ##CDQ_MODE2 = 0x2 ! ##CDQ_MODE3 = 0x3 Index: CL.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-irix5/CL.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** CL.py 17 May 1995 11:18:20 -0000 1.4 --- CL.py 18 Jul 2004 06:14:44 -0000 1.5 *************** *** 2,24 **** # All relevant symbols are now defined in the module cl. try: ! from cl import * except ImportError: ! from CL_old import * else: ! del CompressImage ! del DecompressImage ! del GetAlgorithmName ! del OpenCompressor ! del OpenDecompressor ! del QueryAlgorithms ! del QueryMaxHeaderSize ! del QueryScheme ! del QuerySchemeFromName ! del SetDefault ! del SetMax ! del SetMin ! try: ! del cvt_type ! except NameError: ! pass ! del error --- 2,24 ---- # All relevant symbols are now defined in the module cl. try: ! from cl import * except ImportError: ! from CL_old import * else: ! del CompressImage ! del DecompressImage ! del GetAlgorithmName ! del OpenCompressor ! del OpenDecompressor ! del QueryAlgorithms ! del QueryMaxHeaderSize ! del QueryScheme ! del QuerySchemeFromName ! del SetDefault ! del SetMax ! del SetMin ! try: ! del cvt_type ! except NameError: ! pass ! del error Index: CL_old.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-irix5/CL_old.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CL_old.py 28 Jun 2000 14:48:01 -0000 1.2 --- CL_old.py 18 Jul 2004 06:14:44 -0000 1.3 *************** *** 2,7 **** # cl.h - Compression Library typedefs and prototypes # ! # 01/07/92 Cleanup by Brian Knittel ! # 02/18/92 Original Version by Brian Knittel # --- 2,7 ---- # cl.h - Compression Library typedefs and prototypes # ! # 01/07/92 Cleanup by Brian Knittel ! # 02/18/92 Original Version by Brian Knittel # *************** *** 15,25 **** STEREO_INTERLEAVED = 1 ! # Video # YUV is defined to be the same thing as YCrCb (luma and two chroma components). ! # 422 is appended to YUV (or YCrCb) if the chroma is sub-sampled by 2 ! # horizontally, packed as U Y1 V Y2 (byte order). ! # 422HC is appended to YUV (or YCrCb) if the chroma is sub-sampled by 2 ! # vertically in addition to horizontally, and is packed the same as ! # 422 except that U & V are not valid on the second line. # RGB = 0 --- 15,25 ---- STEREO_INTERLEAVED = 1 ! # Video # YUV is defined to be the same thing as YCrCb (luma and two chroma components). ! # 422 is appended to YUV (or YCrCb) if the chroma is sub-sampled by 2 ! # horizontally, packed as U Y1 V Y2 (byte order). ! # 422HC is appended to YUV (or YCrCb) if the chroma is sub-sampled by 2 ! # vertically in addition to horizontally, and is packed the same as ! # 422 except that U & V are not valid on the second line. # RGB = 0 *************** *** 30,89 **** GRAYSCALE = 4 Y = 4 ! YUV = 5 ! YCbCr = 5 ! YUV422 = 6 # 4:2:2 sampling ! YCbCr422 = 6 # 4:2:2 sampling ! YUV422HC = 7 # 4:1:1 sampling ! YCbCr422HC = 7 # 4:1:1 sampling ! YUV422DC = 7 # 4:1:1 sampling ! YCbCr422DC = 7 # 4:1:1 sampling ! BEST_FIT = -1 def BytesPerSample(s): ! if s in (MONO, YUV): ! return 2 ! elif s == STEREO_INTERLEAVED: ! return 4 ! else: ! return 0 def BytesPerPixel(f): ! if f in (RGB, YUV): ! return 3 ! elif f in (RGBX, RGBA): ! return 4 ! elif f in (RGB332, GRAYSCALE): ! return 1 ! else: ! return 2 def AudioFormatName(f): ! if f == MONO: ! return 'MONO' ! elif f == STEREO_INTERLEAVED: ! return 'STEREO_INTERLEAVED' ! else: ! return 'Not a valid format' def VideoFormatName(f): ! if f == RGB: ! return 'RGB' ! elif f == RGBX: ! return 'RGBX' ! elif f == RGBA: ! return 'RGBA' ! elif f == RGB332: ! return 'RGB332' ! elif f == GRAYSCALE: ! return 'GRAYSCALE' ! elif f == YUV: ! return 'YUV' ! elif f == YUV422: ! return 'YUV422' ! elif f == YUV422DC: ! return 'YUV422DC' ! else: ! return 'Not a valid format' MAX_NUMBER_OF_AUDIO_ALGORITHMS = 32 --- 30,89 ---- GRAYSCALE = 4 Y = 4 ! YUV = 5 ! YCbCr = 5 ! YUV422 = 6 # 4:2:2 sampling ! YCbCr422 = 6 # 4:2:2 sampling ! YUV422HC = 7 # 4:1:1 sampling ! YCbCr422HC = 7 # 4:1:1 sampling ! YUV422DC = 7 # 4:1:1 sampling ! YCbCr422DC = 7 # 4:1:1 sampling ! BEST_FIT = -1 def BytesPerSample(s): ! if s in (MONO, YUV): ! return 2 ! elif s == STEREO_INTERLEAVED: ! return 4 ! else: ! return 0 def BytesPerPixel(f): ! if f in (RGB, YUV): ! return 3 ! elif f in (RGBX, RGBA): ! return 4 ! elif f in (RGB332, GRAYSCALE): ! return 1 ! else: ! return 2 def AudioFormatName(f): ! if f == MONO: ! return 'MONO' ! elif f == STEREO_INTERLEAVED: ! return 'STEREO_INTERLEAVED' ! else: ! return 'Not a valid format' def VideoFormatName(f): ! if f == RGB: ! return 'RGB' ! elif f == RGBX: ! return 'RGBX' ! elif f == RGBA: ! return 'RGBA' ! elif f == RGB332: ! return 'RGB332' ! elif f == GRAYSCALE: ! return 'GRAYSCALE' ! elif f == YUV: ! return 'YUV' ! elif f == YUV422: ! return 'YUV422' ! elif f == YUV422DC: ! return 'YUV422DC' ! else: ! return 'Not a valid format' MAX_NUMBER_OF_AUDIO_ALGORITHMS = 32 *************** *** 97,105 **** def AlgorithmNumber(scheme): ! return scheme & 0x7fff def AlgorithmType(scheme): ! return (scheme >> 15) & 1 def Algorithm(type, n): ! return n | ((type & 1) << 15) # --- 97,105 ---- def AlgorithmNumber(scheme): ! return scheme & 0x7fff def AlgorithmType(scheme): ! return (scheme >> 15) & 1 def Algorithm(type, n): ! return n | ((type & 1) << 15) # *************** *** 115,119 **** AWARE_MPEG_AUDIO = Algorithm(AUDIO, 3) AWARE_MULTIRATE = Algorithm(AUDIO, 4) ! UNCOMPRESSED = Algorithm(VIDEO, 0) UNCOMPRESSED_VIDEO = Algorithm(VIDEO, 0) --- 115,119 ---- AWARE_MPEG_AUDIO = Algorithm(AUDIO, 3) AWARE_MULTIRATE = Algorithm(AUDIO, 4) ! UNCOMPRESSED = Algorithm(VIDEO, 0) UNCOMPRESSED_VIDEO = Algorithm(VIDEO, 0) *************** *** 131,135 **** # Default Parameters IMAGE_WIDTH = 0 ! IMAGE_HEIGHT = 1 ORIGINAL_FORMAT = 2 INTERNAL_FORMAT = 3 --- 131,135 ---- # Default Parameters IMAGE_WIDTH = 0 ! IMAGE_HEIGHT = 1 ORIGINAL_FORMAT = 2 INTERNAL_FORMAT = 3 *************** *** 139,143 **** COMPRESSION_RATIO = 7 EXACT_COMPRESSION_RATIO = 8 ! FRAME_BUFFER_SIZE = 9 COMPRESSED_BUFFER_SIZE = 10 BLOCK_SIZE = 11 --- 139,143 ---- COMPRESSION_RATIO = 7 EXACT_COMPRESSION_RATIO = 8 ! FRAME_BUFFER_SIZE = 9 COMPRESSED_BUFFER_SIZE = 10 BLOCK_SIZE = 11 *************** *** 166,173 **** # Parameter value types # ! ENUM_VALUE = 0 # only certain constant values are valid ! RANGE_VALUE = 1 # any value in a given range is valid ! FLOATING_ENUM_VALUE = 2 # only certain constant floating point values are valid ! FLOATING_RANGE_VALUE = 3 # any value in a given floating point range is valid # --- 166,173 ---- # Parameter value types # ! ENUM_VALUE = 0 # only certain constant values are valid ! RANGE_VALUE = 1 # any value in a given range is valid ! FLOATING_ENUM_VALUE = 2 # only certain constant floating point values are valid ! FLOATING_RANGE_VALUE = 3 # any value in a given floating point range is valid # *************** *** 209,236 **** # ! BAD_NO_BUFFERSPACE = -2 # no space for internal buffers ! BAD_PVBUFFER = -3 # param/val buffer doesn't make sense ! BAD_BUFFERLENGTH_NEG = -4 # negative buffer length ! BAD_BUFFERLENGTH_ODD = -5 # odd length parameter/value buffer ! BAD_PARAM = -6 # invalid parameter ! BAD_COMPRESSION_SCHEME = -7 # compression scheme parameter invalid ! BAD_COMPRESSOR_HANDLE = -8 # compression handle parameter invalid ! BAD_COMPRESSOR_HANDLE_POINTER = -9 # compression handle pointer invalid ! BAD_BUFFER_HANDLE = -10 # buffer handle invalid ! BAD_BUFFER_QUERY_SIZE = -11 # buffer query size too large ! JPEG_ERROR = -12 # error from libjpeg ! BAD_FRAME_SIZE = -13 # frame size invalid ! PARAM_OUT_OF_RANGE = -14 # parameter out of range ! ADDED_ALGORITHM_ERROR = -15 # added algorithm had a unique error ! BAD_ALGORITHM_TYPE = -16 # bad algorithm type ! BAD_ALGORITHM_NAME = -17 # bad algorithm name ! BAD_BUFFERING = -18 # bad buffering calls ! BUFFER_NOT_CREATED = -19 # buffer not created ! BAD_BUFFER_EXISTS = -20 # buffer already created ! BAD_INTERNAL_FORMAT = -21 # invalid internal format ! BAD_BUFFER_POINTER = -22 # invalid buffer pointer ! FRAME_BUFFER_SIZE_ZERO = -23 # frame buffer has zero size ! BAD_STREAM_HEADER = -24 # invalid stream header ! BAD_LICENSE = -25 # netls license not valid ! AWARE_ERROR = -26 # error from libawcmp --- 209,236 ---- # ! BAD_NO_BUFFERSPACE = -2 # no space for internal buffers ! BAD_PVBUFFER = -3 # param/val buffer doesn't make sense ! BAD_BUFFERLENGTH_NEG = -4 # negative buffer length ! BAD_BUFFERLENGTH_ODD = -5 # odd length parameter/value buffer ! BAD_PARAM = -6 # invalid parameter ! BAD_COMPRESSION_SCHEME = -7 # compression scheme parameter invalid ! BAD_COMPRESSOR_HANDLE = -8 # compression handle parameter invalid ! BAD_COMPRESSOR_HANDLE_POINTER = -9 # compression handle pointer invalid ! BAD_BUFFER_HANDLE = -10 # buffer handle invalid ! BAD_BUFFER_QUERY_SIZE = -11 # buffer query size too large ! JPEG_ERROR = -12 # error from libjpeg ! BAD_FRAME_SIZE = -13 # frame size invalid ! PARAM_OUT_OF_RANGE = -14 # parameter out of range ! ADDED_ALGORITHM_ERROR = -15 # added algorithm had a unique error ! BAD_ALGORITHM_TYPE = -16 # bad algorithm type ! BAD_ALGORITHM_NAME = -17 # bad algorithm name ! BAD_BUFFERING = -18 # bad buffering calls ! BUFFER_NOT_CREATED = -19 # buffer not created ! BAD_BUFFER_EXISTS = -20 # buffer already created ! BAD_INTERNAL_FORMAT = -21 # invalid internal format ! BAD_BUFFER_POINTER = -22 # invalid buffer pointer ! FRAME_BUFFER_SIZE_ZERO = -23 # frame buffer has zero size ! BAD_STREAM_HEADER = -24 # invalid stream header ! BAD_LICENSE = -25 # netls license not valid ! AWARE_ERROR = -26 # error from libawcmp Index: FL.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-irix5/FL.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** FL.py 12 Dec 2000 23:11:41 -0000 1.8 --- FL.py 18 Jul 2004 06:14:44 -0000 1.9 *************** *** 8,14 **** ##import fl ##try: ! ## _v20 = (fl.get_rgbmode is not None) ##except: ! ## _v20 = 0 ##del fl --- 8,14 ---- ##import fl ##try: ! ## _v20 = (fl.get_rgbmode is not None) ##except: ! ## _v20 = 0 ##del fl *************** *** 21,25 **** LABEL_SIZE = 64 if _v20: ! SHORTCUT_SIZE = 32 PLACE_FREE = 0 PLACE_SIZE = 1 --- 21,25 ---- LABEL_SIZE = 64 if _v20: ! SHORTCUT_SIZE = 32 PLACE_FREE = 0 PLACE_SIZE = 1 *************** *** 120,124 **** RETURN_BUTTON = 6 if _v20: ! HIDDEN_RET_BUTTON = 7 BUTTON_BOXTYPE = UP_BOX BUTTON_COL1 = COL1 --- 120,124 ---- RETURN_BUTTON = 6 if _v20: ! HIDDEN_RET_BUTTON = 7 BUTTON_BOXTYPE = UP_BOX BUTTON_COL1 = COL1 *************** *** 130,147 **** BUTTON_BW = BOUND_WIDTH if _v20: ! CHART = 4 ! BAR_CHART = 0 ! HORBAR_CHART = 1 ! LINE_CHART = 2 ! FILLED_CHART = 3 ! SPIKE_CHART = 4 ! PIE_CHART = 5 ! SPECIALPIE_CHART = 6 ! CHART_BOXTYPE = BORDER_BOX ! CHART_COL1 = COL1 ! CHART_LCOL = LCOL ! CHART_ALIGN = ALIGN_BOTTOM ! CHART_BW = BOUND_WIDTH ! CHART_MAX = 128 CHOICE = 42 NORMAL_CHOICE = 0 --- 130,147 ---- BUTTON_BW = BOUND_WIDTH if _v20: ! CHART = 4 ! BAR_CHART = 0 ! HORBAR_CHART = 1 ! LINE_CHART = 2 ! FILLED_CHART = 3 ! SPIKE_CHART = 4 ! PIE_CHART = 5 ! SPECIALPIE_CHART = 6 ! CHART_BOXTYPE = BORDER_BOX ! CHART_COL1 = COL1 ! CHART_LCOL = LCOL ! CHART_ALIGN = ALIGN_BOTTOM ! CHART_BW = BOUND_WIDTH ! CHART_MAX = 128 CHOICE = 42 NORMAL_CHOICE = 0 *************** *** 174,182 **** COUNTER_ALIGN = ALIGN_BOTTOM if _v20: ! COUNTER_BW = BOUND_WIDTH else: ! DEFAULT = 51 ! RETURN_DEFAULT = 0 ! ALWAYS_DEFAULT = 1 DIAL = 22 NORMAL_DIAL = 0 --- 174,182 ---- COUNTER_ALIGN = ALIGN_BOTTOM if _v20: ! COUNTER_BW = BOUND_WIDTH else: ! DEFAULT = 51 ! RETURN_DEFAULT = 0 ! ALWAYS_DEFAULT = 1 DIAL = 22 NORMAL_DIAL = 0 *************** *** 198,209 **** NORMAL_INPUT = 0 if _v20: ! FLOAT_INPUT = 1 ! INT_INPUT = 2 ! HIDDEN_INPUT = 3 ! if _v21: ! MULTILINE_INPUT = 4 ! SECRET_INPUT = 5 else: ! ALWAYS_INPUT = 1 INPUT_BOXTYPE = DOWN_BOX INPUT_COL1 = 13 --- 198,209 ---- NORMAL_INPUT = 0 if _v20: ! FLOAT_INPUT = 1 ! INT_INPUT = 2 ! HIDDEN_INPUT = 3 ! if _v21: ! MULTILINE_INPUT = 4 ! SECRET_INPUT = 5 else: ! ALWAYS_INPUT = 1 INPUT_BOXTYPE = DOWN_BOX INPUT_COL1 = 13 Index: SV.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-irix5/SV.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** SV.py 3 Sep 1992 13:08:04 -0000 1.2 --- SV.py 18 Jul 2004 06:14:44 -0000 1.3 *************** *** 8,21 **** # mode parameter for Bind calls ! IN_OFF = 0 # No Video ! IN_OVER = 1 # Video over graphics ! IN_UNDER = 2 # Video under graphics ! IN_REPLACE = 3 # Video replaces entire win # mode parameters for LoadMap calls. Specifies buffer, always 256 entries ! INPUT_COLORMAP = 0 # tuples of 8-bit RGB ! CHROMA_KEY_MAP = 1 # tuples of 8-bit RGB ! COLOR_SPACE_MAP = 2 # tuples of 8-bit RGB ! GAMMA_MAP = 3 # tuples of 24-bit red values # mode parameters for UseExclusive calls --- 8,21 ---- # mode parameter for Bind calls ! IN_OFF = 0 # No Video ! IN_OVER = 1 # Video over graphics ! IN_UNDER = 2 # Video under graphics ! IN_REPLACE = 3 # Video replaces entire win # mode parameters for LoadMap calls. Specifies buffer, always 256 entries ! INPUT_COLORMAP = 0 # tuples of 8-bit RGB ! CHROMA_KEY_MAP = 1 # tuples of 8-bit RGB ! COLOR_SPACE_MAP = 2 # tuples of 8-bit RGB ! GAMMA_MAP = 3 # tuples of 24-bit red values # mode parameters for UseExclusive calls *************** *** 25,31 **** # Format constants for the capture routines ! RGB8_FRAMES = 0 # noninterleaved 8 bit 3:2:3 RBG fields ! RGB32_FRAMES = 1 # 32-bit 8:8:8 RGB frames ! YUV411_FRAMES = 2 # interleaved, 8:2:2 YUV format YUV411_FRAMES_AND_BLANKING_BUFFER = 3 --- 25,31 ---- # Format constants for the capture routines ! RGB8_FRAMES = 0 # noninterleaved 8 bit 3:2:3 RBG fields ! RGB32_FRAMES = 1 # 32-bit 8:8:8 RGB frames ! YUV411_FRAMES = 2 # interleaved, 8:2:2 YUV format YUV411_FRAMES_AND_BLANKING_BUFFER = 3 Index: cddb.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-irix5/cddb.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** cddb.py 12 Feb 2004 17:35:10 -0000 1.12 --- cddb.py 18 Jul 2004 06:14:44 -0000 1.13 *************** *** 21,204 **** _dbid_map = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ@_=+abcdefghijklmnopqrstuvwxyz' def _dbid(v): ! if v >= len(_dbid_map): ! return string.zfill(v, 2) ! else: ! return _dbid_map[v] def tochash(toc): ! if type(toc) == type(''): ! tracklist = [] ! for i in range(2, len(toc), 4): ! tracklist.append((None, ! (int(toc[i:i+2]), ! int(toc[i+2:i+4])))) ! else: ! tracklist = toc ! ntracks = len(tracklist) ! hash = _dbid((ntracks >> 4) & 0xF) + _dbid(ntracks & 0xF) ! if ntracks <= _DB_ID_NTRACKS: ! nidtracks = ntracks ! else: ! nidtracks = _DB_ID_NTRACKS - 1 ! min = 0 ! sec = 0 ! for track in tracklist: ! start, length = track ! min = min + length[0] ! sec = sec + length[1] ! min = min + sec / 60 ! sec = sec % 60 ! hash = hash + _dbid(min) + _dbid(sec) ! for i in range(nidtracks): ! start, length = tracklist[i] ! hash = hash + _dbid(length[0]) + _dbid(length[1]) ! return hash ! class Cddb: ! def __init__(self, tracklist): ! if os.environ.has_key('CDDB_PATH'): ! path = os.environ['CDDB_PATH'] ! cddb_path = path.split(',') ! else: ! home = os.environ['HOME'] ! cddb_path = [home + '/' + _cddbrc] ! self._get_id(tracklist) ! for dir in cddb_path: ! file = dir + '/' + self.id + '.rdb' ! try: ! f = open(file, 'r') ! self.file = file ! break ! except IOError: ! pass ! ntracks = int(self.id[:2], 16) ! self.artist = '' ! self.title = '' ! self.track = [None] + [''] * ntracks ! self.trackartist = [None] + [''] * ntracks ! self.notes = [] ! if not hasattr(self, 'file'): ! return ! import re ! reg = re.compile(r'^([^.]*)\.([^:]*):[\t ]+(.*)') ! while 1: ! line = f.readline() ! if not line: ! break ! match = reg.match(line) ! if not match: ! print 'syntax error in ' + file ! continue ! name1, name2, value = match.group(1, 2, 3) ! if name1 == 'album': ! if name2 == 'artist': ! self.artist = value ! elif name2 == 'title': ! self.title = value ! elif name2 == 'toc': ! if not self.toc: ! self.toc = value ! if self.toc != value: ! print 'toc\'s don\'t match' ! elif name2 == 'notes': ! self.notes.append(value) ! elif name1[:5] == 'track': ! try: ! trackno = int(name1[5:]) ! except strings.atoi_error: ! print 'syntax error in ' + file ! continue ! if trackno > ntracks: ! print 'track number %r in file %r out of range' % (trackno, file) ! continue ! if name2 == 'title': ! self.track[trackno] = value ! elif name2 == 'artist': ! self.trackartist[trackno] = value ! f.close() ! for i in range(2, len(self.track)): ! track = self.track[i] ! # if track title starts with `,', use initial part ! # of previous track's title ! if track and track[0] == ',': ! try: ! off = self.track[i - 1].index(',') ! except ValueError: ! pass ! else: ! self.track[i] = self.track[i-1][:off] \ ! + track ! def _get_id(self, tracklist): ! # fill in self.id and self.toc. ! # if the argument is a string ending in .rdb, the part ! # upto the suffix is taken as the id. ! if type(tracklist) == type(''): ! if tracklist[-4:] == '.rdb': ! self.id = tracklist[:-4] ! self.toc = '' ! return ! t = [] ! for i in range(2, len(tracklist), 4): ! t.append((None, \ ! (int(tracklist[i:i+2]), \ ! int(tracklist[i+2:i+4])))) ! tracklist = t ! ntracks = len(tracklist) ! self.id = _dbid((ntracks >> 4) & 0xF) + _dbid(ntracks & 0xF) ! if ntracks <= _DB_ID_NTRACKS: ! nidtracks = ntracks ! else: ! nidtracks = _DB_ID_NTRACKS - 1 ! min = 0 ! sec = 0 ! for track in tracklist: ! start, length = track ! min = min + length[0] ! sec = sec + length[1] ! min = min + sec / 60 ! sec = sec % 60 ! self.id = self.id + _dbid(min) + _dbid(sec) ! for i in range(nidtracks): ! start, length = tracklist[i] ! self.id = self.id + _dbid(length[0]) + _dbid(length[1]) ! self.toc = string.zfill(ntracks, 2) ! for track in tracklist: ! start, length = track ! self.toc = self.toc + string.zfill(length[0], 2) + \ ! string.zfill(length[1], 2) ! def write(self): ! import posixpath ! if os.environ.has_key('CDDB_WRITE_DIR'): ! dir = os.environ['CDDB_WRITE_DIR'] ! else: ! dir = os.environ['HOME'] + '/' + _cddbrc ! file = dir + '/' + self.id + '.rdb' ! if posixpath.exists(file): ! # make backup copy ! posix.rename(file, file + '~') ! f = open(file, 'w') ! f.write('album.title:\t' + self.title + '\n') ! f.write('album.artist:\t' + self.artist + '\n') ! f.write('album.toc:\t' + self.toc + '\n') ! for note in self.notes: ! f.write('album.notes:\t' + note + '\n') ! prevpref = None ! for i in range(1, len(self.track)): ! if self.trackartist[i]: ! f.write('track%r.artist:\t%s\n' % (i, self.trackartist[i])) ! track = self.track[i] ! try: ! off = track.index(',') ! except ValuError: ! prevpref = None ! else: ! if prevpref and track[:off] == prevpref: ! track = track[off:] ! else: ! prevpref = track[:off] ! f.write('track%r.title:\t%s\n' % (i, track)) ! f.close() --- 21,204 ---- _dbid_map = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ@_=+abcdefghijklmnopqrstuvwxyz' def _dbid(v): ! if v >= len(_dbid_map): ! return string.zfill(v, 2) ! else: ! return _dbid_map[v] def tochash(toc): ! if type(toc) == type(''): ! tracklist = [] ! for i in range(2, len(toc), 4): ! tracklist.append((None, ! (int(toc[i:i+2]), ! int(toc[i+2:i+4])))) ! else: ! tracklist = toc ! ntracks = len(tracklist) ! hash = _dbid((ntracks >> 4) & 0xF) + _dbid(ntracks & 0xF) ! if ntracks <= _DB_ID_NTRACKS: ! nidtracks = ntracks ! else: ! nidtracks = _DB_ID_NTRACKS - 1 ! min = 0 ! sec = 0 ! for track in tracklist: ! start, length = track ! min = min + length[0] ! sec = sec + length[1] ! min = min + sec / 60 ! sec = sec % 60 ! hash = hash + _dbid(min) + _dbid(sec) ! for i in range(nidtracks): ! start, length = tracklist[i] ! hash = hash + _dbid(length[0]) + _dbid(length[1]) ! return hash ! class Cddb: ! def __init__(self, tracklist): ! if os.environ.has_key('CDDB_PATH'): ! path = os.environ['CDDB_PATH'] ! cddb_path = path.split(',') ! else: ! home = os.environ['HOME'] ! cddb_path = [home + '/' + _cddbrc] ! self._get_id(tracklist) ! for dir in cddb_path: ! file = dir + '/' + self.id + '.rdb' ! try: ! f = open(file, 'r') ! self.file = file ! break ! except IOError: ! pass ! ntracks = int(self.id[:2], 16) ! self.artist = '' ! self.title = '' ! self.track = [None] + [''] * ntracks ! self.trackartist = [None] + [''] * ntracks ! self.notes = [] ! if not hasattr(self, 'file'): ! return ! import re ! reg = re.compile(r'^([^.]*)\.([^:]*):[\t ]+(.*)') ! while 1: ! line = f.readline() ! if not line: ! break ! match = reg.match(line) ! if not match: ! print 'syntax error in ' + file ! continue ! name1, name2, value = match.group(1, 2, 3) ! if name1 == 'album': ! if name2 == 'artist': ! self.artist = value ! elif name2 == 'title': ! self.title = value ! elif name2 == 'toc': ! if not self.toc: ! self.toc = value ! if self.toc != value: ! print 'toc\'s don\'t match' ! elif name2 == 'notes': ! self.notes.append(value) ! elif name1[:5] == 'track': ! try: ! trackno = int(name1[5:]) ! except strings.atoi_error: ! print 'syntax error in ' + file ! continue ! if trackno > ntracks: ! print 'track number %r in file %r out of range' % (trackno, file) ! continue ! if name2 == 'title': ! self.track[trackno] = value ! elif name2 == 'artist': ! self.trackartist[trackno] = value ! f.close() ! for i in range(2, len(self.track)): ! track = self.track[i] ! # if track title starts with `,', use initial part ! # of previous track's title ! if track and track[0] == ',': ! try: ! off = self.track[i - 1].index(',') ! except ValueError: ! pass ! else: ! self.track[i] = self.track[i-1][:off] \ ! + track ! def _get_id(self, tracklist): ! # fill in self.id and self.toc. ! # if the argument is a string ending in .rdb, the part ! # upto the suffix is taken as the id. ! if type(tracklist) == type(''): ! if tracklist[-4:] == '.rdb': ! self.id = tracklist[:-4] ! self.toc = '' ! return ! t = [] ! for i in range(2, len(tracklist), 4): ! t.append((None, \ ! (int(tracklist[i:i+2]), \ ! int(tracklist[i+2:i+4])))) ! tracklist = t ! ntracks = len(tracklist) ! self.id = _dbid((ntracks >> 4) & 0xF) + _dbid(ntracks & 0xF) ! if ntracks <= _DB_ID_NTRACKS: ! nidtracks = ntracks ! else: ! nidtracks = _DB_ID_NTRACKS - 1 ! min = 0 ! sec = 0 ! for track in tracklist: ! start, length = track ! min = min + length[0] ! sec = sec + length[1] ! min = min + sec / 60 ! sec = sec % 60 ! self.id = self.id + _dbid(min) + _dbid(sec) ! for i in range(nidtracks): ! start, length = tracklist[i] ! self.id = self.id + _dbid(length[0]) + _dbid(length[1]) ! self.toc = string.zfill(ntracks, 2) ! for track in tracklist: ! start, length = track ! self.toc = self.toc + string.zfill(length[0], 2) + \ ! string.zfill(length[1], 2) ! def write(self): ! import posixpath ! if os.environ.has_key('CDDB_WRITE_DIR'): ! dir = os.environ['CDDB_WRITE_DIR'] ! else: ! dir = os.environ['HOME'] + '/' + _cddbrc ! file = dir + '/' + self.id + '.rdb' ! if posixpath.exists(file): ! # make backup copy ! posix.rename(file, file + '~') ! f = open(file, 'w') ! f.write('album.title:\t' + self.title + '\n') ! f.write('album.artist:\t' + self.artist + '\n') ! f.write('album.toc:\t' + self.toc + '\n') ! for note in self.notes: ! f.write('album.notes:\t' + note + '\n') ! prevpref = None ! for i in range(1, len(self.track)): ! if self.trackartist[i]: ! f.write('track%r.artist:\t%s\n' % (i, self.trackartist[i])) ! track = self.track[i] ! try: ! off = track.index(',') ! except ValuError: ! prevpref = None ! else: ! if prevpref and track[:off] == prevpref: ! track = track[off:] ! else: ! prevpref = track[:off] ! f.write('track%r.title:\t%s\n' % (i, track)) ! f.close() Index: cdplayer.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-irix5/cdplayer.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** cdplayer.py 3 Mar 2004 16:34:31 -0000 1.9 --- cdplayer.py 18 Jul 2004 06:14:44 -0000 1.10 *************** *** 18,88 **** class Cdplayer: ! def __init__(self, tracklist): ! import string ! self.artist = '' ! self.title = '' ! if type(tracklist) == type(''): ! t = [] ! for i in range(2, len(tracklist), 4): ! t.append((None, \ ! (string.atoi(tracklist[i:i+2]), \ ! string.atoi(tracklist[i+2:i+4])))) ! tracklist = t ! self.track = [None] + [''] * len(tracklist) ! self.id = 'd' + string.zfill(len(tracklist), 2) ! for track in tracklist: ! start, length = track ! self.id = self.id + string.zfill(length[0], 2) + \ ! string.zfill(length[1], 2) ! try: ! import posix ! f = open(posix.environ['HOME'] + '/' + cdplayerrc, 'r') ! except IOError: ! return ! import re ! reg = re.compile(r'^([^:]*):\t(.*)') ! s = self.id + '.' ! l = len(s) ! while 1: ! line = f.readline() ! if line == '': ! break ! if line[:l] == s: ! line = line[l:] ! match = reg.match(line) ! if not match: ! print 'syntax error in ~/' + cdplayerrc ! continue ! name, value = match.group(1, 2) ! if name == 'title': ! self.title = value ! elif name == 'artist': ! self.artist = value ! elif name[:5] == 'track': ! trackno = string.atoi(name[6:]) ! self.track[trackno] = value ! f.close() ! def write(self): ! import posix ! filename = posix.environ['HOME'] + '/' + cdplayerrc ! try: ! old = open(filename, 'r') ! except IOError: ! old = open('/dev/null', 'r') ! new = open(filename + '.new', 'w') ! s = self.id + '.' ! l = len(s) ! while 1: ! line = old.readline() ! if line == '': ! break ! if line[:l] != s: ! new.write(line) ! new.write(self.id + '.title:\t' + self.title + '\n') ! new.write(self.id + '.artist:\t' + self.artist + '\n') ! for i in range(1, len(self.track)): ! new.write('%s.track.%r:\t%s\n' % (self.id, i, self.track[i])) ! old.close() ! new.close() ! posix.rename(filename + '.new', filename) --- 18,88 ---- class Cdplayer: ! def __init__(self, tracklist): ! import string ! self.artist = '' ! self.title = '' ! if type(tracklist) == type(''): ! t = [] ! for i in range(2, len(tracklist), 4): ! t.append((None, \ ! (string.atoi(tracklist[i:i+2]), \ ! string.atoi(tracklist[i+2:i+4])))) ! tracklist = t ! self.track = [None] + [''] * len(tracklist) ! self.id = 'd' + string.zfill(len(tracklist), 2) ! for track in tracklist: ! start, length = track ! self.id = self.id + string.zfill(length[0], 2) + \ ! string.zfill(length[1], 2) ! try: ! import posix ! f = open(posix.environ['HOME'] + '/' + cdplayerrc, 'r') ! except IOError: ! return ! import re ! reg = re.compile(r'^([^:]*):\t(.*)') ! s = self.id + '.' ! l = len(s) ! while 1: ! line = f.readline() ! if line == '': ! break ! if line[:l] == s: ! line = line[l:] ! match = reg.match(line) ! if not match: ! print 'syntax error in ~/' + cdplayerrc ! continue ! name, value = match.group(1, 2) ! if name == 'title': ! self.title = value ! elif name == 'artist': ! self.artist = value ! elif name[:5] == 'track': ! trackno = string.atoi(name[6:]) ! self.track[trackno] = value ! f.close() ! def write(self): ! import posix ! filename = posix.environ['HOME'] + '/' + cdplayerrc ! try: ! old = open(filename, 'r') ! except IOError: ! old = open('/dev/null', 'r') ! new = open(filename + '.new', 'w') ! s = self.id + '.' ! l = len(s) ! while 1: ! line = old.readline() ! if line == '': ! break ! if line[:l] != s: ! new.write(line) ! new.write(self.id + '.title:\t' + self.title + '\n') ! new.write(self.id + '.artist:\t' + self.artist + '\n') ! for i in range(1, len(self.track)): ! new.write('%s.track.%r:\t%s\n' % (self.id, i, self.track[i])) ! old.close() ! new.close() ! posix.rename(filename + '.new', filename) Index: flp.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-irix5/flp.py,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** flp.py 12 Feb 2004 17:35:10 -0000 1.21 --- flp.py 18 Jul 2004 06:14:44 -0000 1.22 *************** *** 81,96 **** def _unpack_cache(altforms): ! forms = {} ! for name in altforms.keys(): ! altobj, altlist = altforms[name] ! obj = _newobj() ! obj.make(altobj) ! list = [] ! for altobj in altlist: ! nobj = _newobj() ! nobj.make(altobj) ! list.append(nobj) ! forms[name] = obj, list ! return forms def rdlong(fp): --- 81,96 ---- def _unpack_cache(altforms): ! forms = {} ! for name in altforms.keys(): ! altobj, altlist = altforms[name] ! obj = _newobj() ! obj.make(altobj) ! list = [] ! for altobj in altlist: ! nobj = _newobj() ! nobj.make(altobj) ! list.append(nobj) ! forms[name] = obj, list ! return forms def rdlong(fp): *************** *** 278,283 **** name, value = match.group(1, 2) if name[0] == 'N': ! name = string.join(string.split(name),'') ! name = string.lower(name) name = string.capitalize(name) try: --- 278,283 ---- name, value = match.group(1, 2) if name[0] == 'N': ! name = string.join(string.split(name),'') ! name = string.lower(name) name = string.capitalize(name) try: *************** *** 293,297 **** raise EOFError return line[:-1] ! def _parse_1_line(file): line = _readline(file) --- 293,297 ---- raise EOFError return line[:-1] ! def _parse_1_line(file): line = _readline(file) Index: jpeg.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-irix5/jpeg.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** jpeg.py 12 Dec 2000 23:11:42 -0000 1.4 --- jpeg.py 18 Jul 2004 06:14:44 -0000 1.5 *************** *** 7,11 **** class error(Exception): ! pass options = {'quality': 75, 'optimize': 0, 'smooth': 0, 'forcegray': 0} --- 7,11 ---- class error(Exception): ! pass options = {'quality': 75, 'optimize': 0, 'smooth': 0, 'forcegray': 0} *************** *** 15,111 **** def compress(imgdata, width, height, bytesperpixel): ! global comp ! import cl ! if comp is None: comp = cl.OpenCompressor(cl.JPEG) ! if bytesperpixel == 1: ! format = cl.GRAYSCALE ! elif bytesperpixel == 4: ! format = cl.RGBX ! if options['forcegray']: ! iformat = cl.GRAYSCALE ! else: ! iformat = cl.YUV ! # XXX How to support 'optimize'? ! params = [cl.IMAGE_WIDTH, width, cl.IMAGE_HEIGHT, height, \ ! cl.ORIGINAL_FORMAT, format, \ ! cl.ORIENTATION, cl.BOTTOM_UP, \ ! cl.QUALITY_FACTOR, options['quality'], \ ! cl.INTERNAL_FORMAT, iformat, \ ! ] ! comp.SetParams(params) ! jpegdata = comp.Compress(1, imgdata) ! return jpegdata def decompress(jpegdata): ! global decomp ! import cl ! if decomp is None: decomp = cl.OpenDecompressor(cl.JPEG) ! headersize = decomp.ReadHeader(jpegdata) ! params = [cl.IMAGE_WIDTH, 0, cl.IMAGE_HEIGHT, 0, cl.INTERNAL_FORMAT, 0] ! decomp.GetParams(params) ! width, height, format = params[1], params[3], params[5] ! if format == cl.GRAYSCALE or options['forcegray']: ! format = cl.GRAYSCALE ! bytesperpixel = 1 ! else: ! format = cl.RGBX ! bytesperpixel = 4 ! # XXX How to support 'smooth'? ! params = [cl.ORIGINAL_FORMAT, format, \ ! cl.ORIENTATION, cl.BOTTOM_UP, \ ! cl.FRAME_BUFFER_SIZE, width*height*bytesperpixel] ! decomp.SetParams(params) ! imgdata = decomp.Decompress(1, jpegdata) ! return imgdata, width, height, bytesperpixel def setoption(name, value): ! if type(value) is not type(0): ! raise TypeError, 'jpeg.setoption: numeric options only' ! if name == 'forcegrey': ! name = 'forcegray' ! if not options.has_key(name): ! raise KeyError, 'jpeg.setoption: unknown option name' ! options[name] = int(value) def test(): ! import sys ! if sys.argv[1:2] == ['-g']: ! del sys.argv[1] ! setoption('forcegray', 1) ! if not sys.argv[1:]: ! sys.argv.append('/usr/local/images/data/jpg/asterix.jpg') ! for file in sys.argv[1:]: ! show(file) def show(file): ! import gl, GL, DEVICE ! jpegdata = open(file, 'r').read() ! imgdata, width, height, bytesperpixel = decompress(jpegdata) ! gl.foreground() ! gl.prefsize(width, height) ! win = gl.winopen(file) ! if bytesperpixel == 1: ! gl.cmode() ! gl.pixmode(GL.PM_SIZE, 8) ! gl.gconfig() ! for i in range(256): ! gl.mapcolor(i, i, i, i) ! else: ! gl.RGBmode() ! gl.pixmode(GL.PM_SIZE, 32) ! gl.gconfig() ! gl.qdevice(DEVICE.REDRAW) ! gl.qdevice(DEVICE.ESCKEY) ! gl.qdevice(DEVICE.WINQUIT) ! gl.qdevice(DEVICE.WINSHUT) ! gl.lrectwrite(0, 0, width-1, height-1, imgdata) ! while 1: ! dev, val = gl.qread() ! if dev in (DEVICE.ESCKEY, DEVICE.WINSHUT, DEVICE.WINQUIT): ! break ! if dev == DEVICE.REDRAW: ! gl.lrectwrite(0, 0, width-1, height-1, imgdata) ! gl.winclose(win) ! # Now test the compression and write the result to a fixed filename ! newjpegdata = compress(imgdata, width, height, bytesperpixel) ! open('/tmp/j.jpg', 'w').write(newjpegdata) --- 15,111 ---- def compress(imgdata, width, height, bytesperpixel): ! global comp ! import cl ! if comp is None: comp = cl.OpenCompressor(cl.JPEG) ! if bytesperpixel == 1: ! format = cl.GRAYSCALE ! elif bytesperpixel == 4: ! format = cl.RGBX ! if options['forcegray']: ! iformat = cl.GRAYSCALE ! else: ! iformat = cl.YUV ! # XXX How to support 'optimize'? ! params = [cl.IMAGE_WIDTH, width, cl.IMAGE_HEIGHT, height, \ ! cl.ORIGINAL_FORMAT, format, \ ! cl.ORIENTATION, cl.BOTTOM_UP, \ ! cl.QUALITY_FACTOR, options['quality'], \ ! cl.INTERNAL_FORMAT, iformat, \ ! ] ! comp.SetParams(params) ! jpegdata = comp.Compress(1, imgdata) ! return jpegdata def decompress(jpegdata): ! global decomp ! import cl ! if decomp is None: decomp = cl.OpenDecompressor(cl.JPEG) ! headersize = decomp.ReadHeader(jpegdata) ! params = [cl.IMAGE_WIDTH, 0, cl.IMAGE_HEIGHT, 0, cl.INTERNAL_FORMAT, 0] ! decomp.GetParams(params) ! width, height, format = params[1], params[3], params[5] ! if format == cl.GRAYSCALE or options['forcegray']: ! format = cl.GRAYSCALE ! bytesperpixel = 1 ! else: ! format = cl.RGBX ! bytesperpixel = 4 ! # XXX How to support 'smooth'? ! params = [cl.ORIGINAL_FORMAT, format, \ ! cl.ORIENTATION, cl.BOTTOM_UP, \ ! cl.FRAME_BUFFER_SIZE, width*height*bytesperpixel] ! decomp.SetParams(params) ! imgdata = decomp.Decompress(1, jpegdata) ! return imgdata, width, height, bytesperpixel def setoption(name, value): ! if type(value) is not type(0): ! raise TypeError, 'jpeg.setoption: numeric options only' ! if name == 'forcegrey': ! name = 'forcegray' ! if not options.has_key(name): ! raise KeyError, 'jpeg.setoption: unknown option name' ! options[name] = int(value) def test(): ! import sys ! if sys.argv[1:2] == ['-g']: ! del sys.argv[1] ! setoption('forcegray', 1) ! if not sys.argv[1:]: ! sys.argv.append('/usr/local/images/data/jpg/asterix.jpg') ! for file in sys.argv[1:]: ! show(file) def show(file): ! import gl, GL, DEVICE ! jpegdata = open(file, 'r').read() ! imgdata, width, height, bytesperpixel = decompress(jpegdata) ! gl.foreground() ! gl.prefsize(width, height) ! win = gl.winopen(file) ! if bytesperpixel == 1: ! gl.cmode() ! gl.pixmode(GL.PM_SIZE, 8) ! gl.gconfig() ! for i in range(256): ! gl.mapcolor(i, i, i, i) ! else: ! gl.RGBmode() ! gl.pixmode(GL.PM_SIZE, 32) ! gl.gconfig() ! gl.qdevice(DEVICE.REDRAW) ! gl.qdevice(DEVICE.ESCKEY) ! gl.qdevice(DEVICE.WINQUIT) ! gl.qdevice(DEVICE.WINSHUT) ! gl.lrectwrite(0, 0, width-1, height-1, imgdata) ! while 1: ! dev, val = gl.qread() ! if dev in (DEVICE.ESCKEY, DEVICE.WINSHUT, DEVICE.WINQUIT): ! break ! if dev == DEVICE.REDRAW: ! gl.lrectwrite(0, 0, width-1, height-1, imgdata) ! gl.winclose(win) ! # Now test the compression and write the result to a fixed filename ! newjpegdata = compress(imgdata, width, height, bytesperpixel) ! open('/tmp/j.jpg', 'w').write(newjpegdata) Index: panel.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-irix5/panel.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** panel.py 12 Feb 2004 17:35:10 -0000 1.7 --- panel.py 18 Jul 2004 06:14:44 -0000 1.8 *************** *** 18,22 **** # def is_list(x): ! return type(x) == type([]) --- 18,22 ---- # def is_list(x): ! return type(x) == type([]) *************** *** 24,31 **** # def reverse(list): ! res = [] ! for item in list: ! res.insert(0, item) ! return res --- 24,31 ---- # def reverse(list): ! res = [] ! for item in list: ! res.insert(0, item) ! return res *************** *** 34,41 **** # def getattrlist(list, name): ! for item in list: ! if item and is_list(item) and item[0] == name: ! return item[1:] ! return [] --- 34,41 ---- # def getattrlist(list, name): ! for item in list: ! if item and is_list(item) and item[0] == name: ! return item[1:] ! return [] *************** *** 43,51 **** # def getproplist(list, name): ! for item in list: ! if item and is_list(item) and item[0] == 'prop': ! if len(item) > 1 and item[1] == name: ! return item[2:] ! return [] --- 43,51 ---- # def getproplist(list, name): ! for item in list: ! if item and is_list(item) and item[0] == 'prop': ! if len(item) > 1 and item[1] == name: ! return item[2:] ! return [] *************** *** 53,58 **** # def is_endgroup(list): ! x = getproplist(list, 'end-of-group') ! return (x and x[0] == '#t') --- 53,58 ---- # def is_endgroup(list): ! x = getproplist(list, 'end-of-group') ! return (x and x[0] == '#t') *************** *** 61,78 **** # def show_actuator(prefix, a): ! for item in a: ! if not is_list(item): ! print prefix, item ! elif item and item[0] == 'al': ! print prefix, 'Subactuator list:' ! for a in item[1:]: ! show_actuator(prefix + ' ', a) ! elif len(item) == 2: ! print prefix, item[0], '=>', item[1] ! elif len(item) == 3 and item[0] == 'prop': ! print prefix, 'Prop', item[1], '=>', ! print item[2] ! else: ! print prefix, '?', item --- 61,78 ---- # def show_actuator(prefix, a): ! for item in a: ! if not is_list(item): ! print prefix, item ! elif item and item[0] == 'al': ! print prefix, 'Subactuator list:' ! for a in item[1:]: ! show_actuator(prefix + ' ', a) ! elif len(item) == 2: ! print prefix, item[0], '=>', item[1] ! elif len(item) == 3 and item[0] == 'prop': ! print prefix, 'Prop', item[1], '=>', ! print item[2] ! else: ! print prefix, '?', item *************** *** 80,97 **** # def show_panel(prefix, p): ! for item in p: ! if not is_list(item): ! print prefix, item ! elif item and item[0] == 'al': ! print prefix, 'Actuator list:' ! for a in item[1:]: ! show_actuator(prefix + ' ', a) ! elif len(item) == 2: ! print prefix, item[0], '=>', item[1] ! elif len(item) == 3 and item[0] == 'prop': ! print prefix, 'Prop', item[1], '=>', ! print item[2] ! else: ! print prefix, '?', item --- 80,97 ---- # def show_panel(prefix, p): ! for item in p: ! if not is_list(item): ! print prefix, item ! elif item and item[0] == 'al': ! print prefix, 'Actuator list:' ! for a in item[1:]: ! show_actuator(prefix + ' ', a) ! elif len(item) == 2: ! print prefix, item[0], '=>', item[1] ! elif len(item) == 3 and item[0] == 'prop': ! print prefix, 'Prop', item[1], '=>', ! print item[2] ! else: ! print prefix, '?', item *************** *** 104,108 **** # def dummy_callback(arg): ! pass --- 104,108 ---- # def dummy_callback(arg): ! pass *************** *** 112,139 **** # def assign_members(target, attrlist, exclist, prefix): ! for item in attrlist: ! if is_list(item) and len(item) == 2 and item[0] not in exclist: ! name, value = item[0], item[1] ! ok = 1 ! if value[0] in '-0123456789': ! value = eval(value) ! elif value[0] == '"': ! value = value[1:-1] ! elif value == 'move-then-resize': ! # Strange default set by Panel Editor... ! ok = 0 ! else: ! print 'unknown value', value, 'for', name ! ok = 0 ! if ok: ! lhs = 'target.' + prefix + name ! stmt = lhs + '=' + repr(value) ! if debug: print 'exec', stmt ! try: ! exec stmt + '\n' ! except KeyboardInterrupt: # Don't catch this! ! raise KeyboardInterrupt ! except: ! print 'assign failed:', stmt --- 112,139 ---- # def assign_members(target, attrlist, exclist, prefix): ! for item in attrlist: ! if is_list(item) and len(item) == 2 and item[0] not in exclist: ! name, value = item[0], item[1] ! ok = 1 ! if value[0] in '-0123456789': ! value = eval(value) ! elif value[0] == '"': ! value = value[1:-1] ! elif value == 'move-then-resize': ! # Strange default set by Panel Editor... ! ok = 0 ! else: ! print 'unknown value', value, 'for', name ! ok = 0 ! if ok: ! lhs = 'target.' + prefix + name ! stmt = lhs + '=' + repr(value) ! if debug: print 'exec', stmt ! try: ! exec stmt + '\n' ! except KeyboardInterrupt: # Don't catch this! ! raise KeyboardInterrupt ! except: ! print 'assign failed:', stmt *************** *** 142,169 **** # def build_actuator(descr): ! namelist = getattrlist(descr, 'name') ! if namelist: ! # Assume it is a string ! actuatorname = namelist[0][1:-1] ! else: ! actuatorname = '' ! type = descr[0] ! if type[:4] == 'pnl_': type = type[4:] ! act = pnl.mkact(type) ! act.downfunc = act.activefunc = act.upfunc = dummy_callback ! # ! assign_members(act, descr[1:], ['al', 'data', 'name'], '') ! # ! # Treat actuator-specific data ! # ! datalist = getattrlist(descr, 'data') ! prefix = '' ! if type[-4:] == 'puck': ! prefix = 'puck_' ! elif type == 'mouse': ! prefix = 'mouse_' ! assign_members(act, datalist, [], prefix) ! # ! return act, actuatorname --- 142,169 ---- # def build_actuator(descr): ! namelist = getattrlist(descr, 'name') ! if namelist: ! # Assume it is a string ! actuatorname = namelist[0][1:-1] ! else: ! actuatorname = '' ! type = descr[0] ! if type[:4] == 'pnl_': type = type[4:] ! act = pnl.mkact(type) ! act.downfunc = act.activefunc = act.upfunc = dummy_callback ! # ! assign_members(act, descr[1:], ['al', 'data', 'name'], '') ! # ! # Treat actuator-specific data ! # ! datalist = getattrlist(descr, 'data') ! prefix = '' ! if type[-4:] == 'puck': ! prefix = 'puck_' ! elif type == 'mouse': ! prefix = 'mouse_' ! assign_members(act, datalist, [], prefix) ! # ! return act, actuatorname *************** *** 177,201 **** # def build_subactuators(panel, super_act, al): ! # ! # This is nearly the same loop as below in build_panel(), ! # except a call is made to addsubact() instead of addact(). ! # ! for a in al: ! act, name = build_actuator(a) ! act.addsubact(super_act) ! if name: ! stmt = 'panel.' + name + ' = act' ! if debug: print 'exec', stmt ! exec stmt + '\n' ! if is_endgroup(a): ! panel.endgroup() ! sub_al = getattrlist(a, 'al') ! if sub_al: ! build_subactuators(panel, act, sub_al) ! # ! # Fix the actuator to which whe just added subactuators. ! # This can't hurt (I hope) and is needed for the scroll actuator. ! # ! super_act.fixact() --- 177,201 ---- # def build_subactuators(panel, super_act, al): ! # ! # This is nearly the same loop as below in build_panel(), ! # except a call is made to addsubact() instead of addact(). ! # ! for a in al: ! act, name = build_actuator(a) ! act.addsubact(super_act) ! if name: ! stmt = 'panel.' + name + ' = act' ! if debug: print 'exec', stmt ! exec stmt + '\n' ! if is_endgroup(a): ! panel.endgroup() ! sub_al = getattrlist(a, 'al') ! if sub_al: ! build_subactuators(panel, act, sub_al) ! # ! # Fix the actuator to which whe just added subactuators. ! # This can't hurt (I hope) and is needed for the scroll actuator. ! # ! super_act.fixact() *************** *** 205,248 **** # def build_panel(descr): ! # ! # Sanity check ! # ! if (not descr) or descr[0] != 'panel': ! raise panel_error, 'panel description must start with "panel"' ! # ! if debug: show_panel('', descr) ! # ! # Create an empty panel ! # ! panel = pnl.mkpanel() ! # ! # Assign panel attributes ! # ! assign_members(panel, descr[1:], ['al'], '') ! # ! # Look for actuator list ! # ! al = getattrlist(descr, 'al') ! # ! # The order in which actuators are created is important ! # because of the endgroup() operator. ! # Unfortunately the Panel Editor outputs the actuator list ! # in reverse order, so we reverse it here. ! # ! al = reverse(al) ! # ! for a in al: ! act, name = build_actuator(a) ! act.addact(panel) ! if name: ! stmt = 'panel.' + name + ' = act' ! exec stmt + '\n' ! if is_endgroup(a): ! panel.endgroup() ! sub_al = getattrlist(a, 'al') ! if sub_al: ! build_subactuators(panel, act, sub_al) ! # ! return panel --- 205,248 ---- # def build_panel(descr): ! # ! # Sanity check ! # ! if (not descr) or descr[0] != 'panel': ! raise panel_error, 'panel description must start with "panel"' ! # ! if debug: show_panel('', descr) ! # ! # Create an empty panel ! # ! panel = pnl.mkpanel() ! # ! # Assign panel attributes ! # ! assign_members(panel, descr[1:], ['al'], '') ! # ! # Look for actuator list ! # ! al = getattrlist(descr, 'al') ! # ! # The order in which actuators are created is important ! # because of the endgroup() operator. ! # Unfortunately the Panel Editor outputs the actuator list ! # in reverse order, so we reverse it here. ! # ! al = reverse(al) ! # ! for a in al: ! act, name = build_actuator(a) ! act.addact(panel) ! if name: ! stmt = 'panel.' + name + ' = act' ! exec stmt + '\n' ! if is_endgroup(a): ! panel.endgroup() ! sub_al = getattrlist(a, 'al') ! if sub_al: ! build_subactuators(panel, act, sub_al) ! # ! return panel *************** *** 250,274 **** # def my_dopanel(): ! # Extract only the first 4 elements to allow for future expansion ! a, down, active, up = pnl.dopanel()[:4] ! if down: ! down.downfunc(down) ! if active: ! active.activefunc(active) ! if up: ! up.upfunc(up) ! return a # Create one or more panels from a description file (S-expressions) # generated by the Panel Editor. ! # def defpanellist(file): ! import panelparser ! descrlist = panelparser.parse_file(open(file, 'r')) ! panellist = [] ! for descr in descrlist: ! panellist.append(build_panel(descr)) ! return panellist --- 250,274 ---- # def my_dopanel(): ! # Extract only the first 4 elements to allow for future expansion ! a, down, active, up = pnl.dopanel()[:4] ! if down: ! down.downfunc(down) ! if active: ! active.activefunc(active) ! if up: ! up.upfunc(up) ! return a # Create one or more panels from a description file (S-expressions) # generated by the Panel Editor. ! # def defpanellist(file): ! import panelparser ! descrlist = panelparser.parse_file(open(file, 'r')) ! panellist = [] ! for descr in descrlist: ! panellist.append(build_panel(descr)) ! return panellist *************** *** 277,281 **** # This gives *no* performance penalty once this module is imported. # ! from pnl import * # for export ! dopanel = my_dopanel # override pnl.dopanel --- 277,281 ---- # This gives *no* performance penalty once this module is imported. # ! from pnl import * # for export ! dopanel = my_dopanel # override pnl.dopanel Index: panelparser.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-irix5/panelparser.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** panelparser.py 12 Dec 2000 23:11:42 -0000 1.3 --- panelparser.py 18 Jul 2004 06:14:44 -0000 1.4 *************** *** 16,48 **** # def tokenize_string(s): ! tokens = [] ! while s: ! c = s[:1] ! if c in whitespace: ! s = s[1:] ! elif c == ';': ! s = '' ! elif c == '"': ! n = len(s) ! i = 1 ! while i < n: ! c = s[i] ! i = i+1 ! if c == '"': break ! if c == '\\': i = i+1 ! tokens.append(s[:i]) ! s = s[i:] ! elif c in operators: ! tokens.append(c) ! s = s[1:] ! else: ! n = len(s) ! i = 1 ! while i < n: ! if s[i] in separators: break ! i = i+1 ! tokens.append(s[:i]) ! s = s[i:] ! return tokens --- 16,48 ---- # def tokenize_string(s): ! tokens = [] ! while s: ! c = s[:1] ! if c in whitespace: ! s = s[1:] ! elif c == ';': ! s = '' ! elif c == '"': ! n = len(s) ! i = 1 ! while i < n: ! c = s[i] ! i = i+1 ! if c == '"': break ! if c == '\\': i = i+1 ! tokens.append(s[:i]) ! s = s[i:] ! elif c in operators: ! tokens.append(c) ! s = s[1:] ! else: ! n = len(s) ! i = 1 ! while i < n: ! if s[i] in separators: break ! i = i+1 ! tokens.append(s[:i]) ! s = s[i:] ! return tokens *************** *** 51,60 **** # def tokenize_file(fp): ! tokens = [] ! while 1: ! line = fp.readline() ! if not line: break ! tokens = tokens + tokenize_string(line) ! return tokens --- 51,60 ---- # def tokenize_file(fp): ! tokens = [] ! while 1: ! line = fp.readline() ! if not line: break ! tokens = tokens + tokenize_string(line) ! return tokens *************** *** 72,90 **** # def parse_expr(tokens): ! if (not tokens) or tokens[0] != '(': ! raise syntax_error, 'expected "("' ! tokens = tokens[1:] ! expr = [] ! while 1: ! if not tokens: ! raise syntax_error, 'missing ")"' ! if tokens[0] == ')': ! return expr, tokens[1:] ! elif tokens[0] == '(': ! subexpr, tokens = parse_expr(tokens) ! expr.append(subexpr) ! else: ! expr.append(tokens[0]) ! tokens = tokens[1:] --- 72,90 ---- # def parse_expr(tokens): ! if (not tokens) or tokens[0] != '(': ! raise syntax_error, 'expected "("' ! tokens = tokens[1:] ! expr = [] ! while 1: ! if not tokens: ! raise syntax_error, 'missing ")"' ! if tokens[0] == ')': ! return expr, tokens[1:] ! elif tokens[0] == '(': ! subexpr, tokens = parse_expr(tokens) ! expr.append(subexpr) ! else: ! expr.append(tokens[0]) ! tokens = tokens[1:] *************** *** 93,102 **** # def parse_file(fp): ! tokens = tokenize_file(fp) ! exprlist = [] ! while tokens: ! expr, tokens = parse_expr(tokens) ! exprlist.append(expr) ! return exprlist --- 93,102 ---- # def parse_file(fp): ! tokens = tokenize_file(fp) ! exprlist = [] ! while tokens: ! expr, tokens = parse_expr(tokens) ! exprlist.append(expr) ! return exprlist *************** *** 104,119 **** # # The input ! # '(hip (hop hur-ray))' # # passed to tokenize_string() returns the token list ! # ['(', 'hip', '(', 'hop', 'hur-ray', ')', ')'] # # When this is passed to parse_expr() it returns the expression ! # ['hip', ['hop', 'hur-ray']] # plus an empty token list (because there are no tokens left. # # When a file containing the example is passed to parse_file() it returns # a list whose only element is the output of parse_expr() above: ! # [['hip', ['hop', 'hur-ray']]] --- 104,119 ---- # # The input ! # '(hip (hop hur-ray))' # # passed to tokenize_string() returns the token list ! # ['(', 'hip', '(', 'hop', 'hur-ray', ')', ')'] # # When this is passed to parse_expr() it returns the expression ! # ['hip', ['hop', 'hur-ray']] # plus an empty token list (because there are no tokens left. # # When a file containing the example is passed to parse_file() it returns # a list whose only element is the output of parse_expr() above: ! # [['hip', ['hop', 'hur-ray']]] *************** *** 124,128 **** # Tokens are separated by whitespace, except the following characters # always form a separate token (outside strings): ! # ( ) ' # Strings are enclosed in double quotes (") and backslash (\) is used # as escape character in strings. --- 124,128 ---- # Tokens are separated by whitespace, except the following characters # always form a separate token (outside strings): ! # ( ) ' # Strings are enclosed in double quotes (") and backslash (\) is used # as escape character in strings. Index: readcd.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-irix5/readcd.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** readcd.py 12 Feb 2004 17:35:10 -0000 1.13 --- readcd.py 18 Jul 2004 06:14:44 -0000 1.14 *************** *** 4,244 **** class Error(Exception): ! pass class _Stop(Exception): ! pass def _doatime(self, cb_type, data): ! if ((data[0] * 60) + data[1]) * 75 + data[2] > self.end: ! ## print 'done with list entry', repr(self.listindex) ! raise _Stop ! func, arg = self.callbacks[cb_type] ! if func: ! func(arg, cb_type, data) def _dopnum(self, cb_type, data): ! if data > self.end: ! ## print 'done with list entry', repr(self.listindex) ! raise _Stop ! func, arg = self.callbacks[cb_type] ! if func: ! func(arg, cb_type, data) class Readcd: ! def __init__(self, *arg): ! if len(arg) == 0: ! self.player = cd.open() ! elif len(arg) == 1: ! self.player = cd.open(arg[0]) ! elif len(arg) == 2: ! self.player = cd.open(arg[0], arg[1]) ! else: ! raise Error, 'bad __init__ call' ! self.list = [] ! self.callbacks = [(None, None)] * 8 ! self.parser = cd.createparser() ! self.playing = 0 ! self.end = 0 ! self.status = None ! self.trackinfo = None ! def eject(self): ! self.player.eject() ! self.list = [] ! self.end = 0 ! self.listindex = 0 ! self.status = None ! self.trackinfo = None ! if self.playing: ! ## print 'stop playing from eject' ! raise _Stop ! def pmsf2msf(self, track, min, sec, frame): ! if not self.status: ! self.cachestatus() ! if track < self.status[5] or track > self.status[6]: ! raise Error, 'track number out of range' ! if not self.trackinfo: ! self.cacheinfo() ! start, total = self.trackinfo[track] ! start = ((start[0] * 60) + start[1]) * 75 + start[2] ! total = ((total[0] * 60) + total[1]) * 75 + total[2] ! block = ((min * 60) + sec) * 75 + frame ! if block > total: ! raise Error, 'out of range' ! block = start + block ! min, block = divmod(block, 75*60) ! sec, frame = divmod(block, 75) ! return min, sec, frame ! def reset(self): ! self.list = [] ! def appendtrack(self, track): ! self.appendstretch(track, track) ! ! def appendstretch(self, start, end): ! if not self.status: ! self.cachestatus() ! if not start: ! start = 1 ! if not end: ! end = self.status[6] ! if type(end) == type(0): ! if end < self.status[5] or end > self.status[6]: ! raise Error, 'range error' ! else: ! l = len(end) ! if l == 4: ! prog, min, sec, frame = end ! if prog < self.status[5] or prog > self.status[6]: ! raise Error, 'range error' ! end = self.pmsf2msf(prog, min, sec, frame) ! elif l != 3: ! raise Error, 'syntax error' ! if type(start) == type(0): ! if start < self.status[5] or start > self.status[6]: ! raise Error, 'range error' ! if len(self.list) > 0: ! s, e = self.list[-1] ! if type(e) == type(0): ! if start == e+1: ! start = s ! del self.list[-1] ! else: ! l = len(start) ! if l == 4: ! prog, min, sec, frame = start ! if prog < self.status[5] or prog > self.status[6]: ! raise Error, 'range error' ! start = self.pmsf2msf(prog, min, sec, frame) ! elif l != 3: ! raise Error, 'syntax error' ! self.list.append((start, end)) ! def settracks(self, list): ! self.list = [] ! for track in list: ! self.appendtrack(track) ! def setcallback(self, cb_type, func, arg): ! if cb_type < 0 or cb_type >= 8: ! raise Error, 'type out of range' ! self.callbacks[cb_type] = (func, arg) ! if self.playing: ! start, end = self.list[self.listindex] ! if type(end) == type(0): ! if cb_type != CD.PNUM: ! self.parser.setcallback(cb_type, func, arg) ! else: ! if cb_type != CD.ATIME: ! self.parser.setcallback(cb_type, func, arg) ! def removecallback(self, cb_type): ! if cb_type < 0 or cb_type >= 8: ! raise Error, 'type out of range' ! self.callbacks[cb_type] = (None, None) ! if self.playing: ! start, end = self.list[self.listindex] ! if type(end) == type(0): ! if cb_type != CD.PNUM: ! self.parser.removecallback(cb_type) ! else: ! if cb_type != CD.ATIME: ! self.parser.removecallback(cb_type) ! def gettrackinfo(self, *arg): ! if not self.status: ! self.cachestatus() ! if not self.trackinfo: ! self.cacheinfo() ! if len(arg) == 0: ! return self.trackinfo[self.status[5]:self.status[6]+1] ! result = [] ! for i in arg: ! if i < self.status[5] or i > self.status[6]: ! raise Error, 'range error' ! result.append(self.trackinfo[i]) ! return result ! def cacheinfo(self): ! if not self.status: ! self.cachestatus() ! self.trackinfo = [] ! for i in range(self.status[5]): ! self.trackinfo.append(None) ! for i in range(self.status[5], self.status[6]+1): ! self.trackinfo.append(self.player.gettrackinfo(i)) ! def cachestatus(self): ! self.status = self.player.getstatus() ! if self.status[0] == CD.NODISC: ! self.status = None ! raise Error, 'no disc in player' ! def getstatus(self): ! return self.player.getstatus() ! def play(self): ! if not self.status: ! self.cachestatus() ! size = self.player.bestreadsize() ! self.listindex = 0 ! self.playing = 0 ! for i in range(8): ! func, arg = self.callbacks[i] ! if func: ! self.parser.setcallback(i, func, arg) ! else: ! self.parser.removecallback(i) ! if len(self.list) == 0: ! for i in range(self.status[5], self.status[6]+1): ! self.appendtrack(i) ! try: ! while 1: ! if not self.playing: ! if self.listindex >= len(self.list): ! return ! start, end = self.list[self.listindex] ! if type(start) == type(0): ! dummy = self.player.seektrack( ! start) ! else: ! min, sec, frame = start ! dummy = self.player.seek( ! min, sec, frame) ! if type(end) == type(0): ! self.parser.setcallback( ! CD.PNUM, _dopnum, self) ! self.end = end ! func, arg = \ ! self.callbacks[CD.ATIME] ! if func: ! self.parser.setcallback(CD.ATIME, func, arg) ! else: ! self.parser.removecallback(CD.ATIME) ! else: ! min, sec, frame = end ! self.parser.setcallback( ! CD.ATIME, _doatime, ! self) ! self.end = (min * 60 + sec) * \ ! 75 + frame ! func, arg = \ ! self.callbacks[CD.PNUM] ! if func: ! self.parser.setcallback(CD.PNUM, func, arg) ! else: ! self.parser.removecallback(CD.PNUM) ! self.playing = 1 ! data = self.player.readda(size) ! if data == '': ! self.playing = 0 ! self.listindex = self.listindex + 1 ! continue ! try: ! self.parser.parseframe(data) ! except _Stop: ! self.playing = 0 ! self.listindex = self.listindex + 1 ! finally: ! self.playing = 0 --- 4,244 ---- class Error(Exception): ! pass class _Stop(Exception): ! pass def _doatime(self, cb_type, data): ! if ((data[0] * 60) + data[1]) * 75 + data[2] > self.end: ! ## print 'done with list entry', repr(self.listindex) ! raise _Stop ! func, arg = self.callbacks[cb_type] ! if func: ! func(arg, cb_type, data) def _dopnum(self, cb_type, data): ! if data > self.end: ! ## print 'done with list entry', repr(self.listindex) ! raise _Stop ! func, arg = self.callbacks[cb_type] ! if func: ! func(arg, cb_type, data) class Readcd: ! def __init__(self, *arg): ! if len(arg) == 0: ! self.player = cd.open() ! elif len(arg) == 1: ! self.player = cd.open(arg[0]) ! elif len(arg) == 2: ! self.player = cd.open(arg[0], arg[1]) ! else: ! raise Error, 'bad __init__ call' ! self.list = [] ! self.callbacks = [(None, None)] * 8 ! self.parser = cd.createparser() ! self.playing = 0 ! self.end = 0 ! self.status = None ! self.trackinfo = None ! def eject(self): ! self.player.eject() ! self.list = [] ! self.end = 0 ! self.listindex = 0 ! self.status = None ! self.trackinfo = None ! if self.playing: ! ## print 'stop playing from eject' ! raise _Stop ! def pmsf2msf(self, track, min, sec, frame): ! if not self.status: ! self.cachestatus() ! if track < self.status[5] or track > self.status[6]: ! raise Error, 'track number out of range' ! if not self.trackinfo: ! self.cacheinfo() ! start, total = self.trackinfo[track] ! start = ((start[0] * 60) + start[1]) * 75 + start[2] ! total = ((total[0] * 60) + total[1]) * 75 + total[2] ! block = ((min * 60) + sec) * 75 + frame ! if block > total: ! raise Error, 'out of range' ! block = start + block ! min, block = divmod(block, 75*60) ! sec, frame = divmod(block, 75) ! return min, sec, frame ! def reset(self): ! self.list = [] ! def appendtrack(self, track): ! self.appendstretch(track, track) ! def appendstretch(self, start, end): ! if not self.status: ! self.cachestatus() ! if not start: ! start = 1 ! if not end: ! end = self.status[6] ! if type(end) == type(0): ! if end < self.status[5] or end > self.status[6]: ! raise Error, 'range error' ! else: ! l = len(end) ! if l == 4: ! prog, min, sec, frame = end ! if prog < self.status[5] or prog > self.status[6]: ! raise Error, 'range error' ! end = self.pmsf2msf(prog, min, sec, frame) ! elif l != 3: ! raise Error, 'syntax error' ! if type(start) == type(0): ! if start < self.status[5] or start > self.status[6]: ! raise Error, 'range error' ! if len(self.list) > 0: ! s, e = self.list[-1] ! if type(e) == type(0): ! if start == e+1: ! start = s ! del self.list[-1] ! else: ! l = len(start) ! if l == 4: ! prog, min, sec, frame = start ! if prog < self.status[5] or prog > self.status[6]: ! raise Error, 'range error' ! start = self.pmsf2msf(prog, min, sec, frame) ! elif l != 3: ! raise Error, 'syntax error' ! self.list.append((start, end)) ! def settracks(self, list): ! self.list = [] ! for track in list: ! self.appendtrack(track) ! def setcallback(self, cb_type, func, arg): ! if cb_type < 0 or cb_type >= 8: ! raise Error, 'type out of range' ! self.callbacks[cb_type] = (func, arg) ! if self.playing: ! start, end = self.list[self.listindex] ! if type(end) == type(0): ! if cb_type != CD.PNUM: ! self.parser.setcallback(cb_type, func, arg) ! else: ! if cb_type != CD.ATIME: ! self.parser.setcallback(cb_type, func, arg) ! def removecallback(self, cb_type): ! if cb_type < 0 or cb_type >= 8: ! raise Error, 'type out of range' ! self.callbacks[cb_type] = (None, None) ! if self.playing: ! start, end = self.list[self.listindex] ! if type(end) == type(0): ! if cb_type != CD.PNUM: ! self.parser.removecallback(cb_type) ! else: ! if cb_type != CD.ATIME: ! self.parser.removecallback(cb_type) ! def gettrackinfo(self, *arg): ! if not self.status: ! self.cachestatus() ! if not self.trackinfo: ! self.cacheinfo() ! if len(arg) == 0: ! return self.trackinfo[self.status[5]:self.status[6]+1] ! result = [] ! for i in arg: ! if i < self.status[5] or i > self.status[6]: ! raise Error, 'range error' ! result.append(self.trackinfo[i]) ! return result ! def cacheinfo(self): ! if not self.status: ! self.cachestatus() ! self.trackinfo = [] ! for i in range(self.status[5]): ! self.trackinfo.append(None) ! for i in range(self.status[5], self.status[6]+1): ! self.trackinfo.append(self.player.gettrackinfo(i)) ! def cachestatus(self): ! self.status = self.player.getstatus() ! if self.status[0] == CD.NODISC: ! self.status = None ! raise Error, 'no disc in player' ! def getstatus(self): ! return self.player.getstatus() ! ! def play(self): ! if not self.status: ! self.cachestatus() ! size = self.player.bestreadsize() ! self.listindex = 0 ! self.playing = 0 ! for i in range(8): ! func, arg = self.callbacks[i] ! if func: ! self.parser.setcallback(i, func, arg) ! else: ! self.parser.removecallback(i) ! if len(self.list) == 0: ! for i in range(self.status[5], self.status[6]+1): ! self.appendtrack(i) ! try: ! while 1: ! if not self.playing: ! if self.listindex >= len(self.list): ! return ! start, end = self.list[self.listindex] ! if type(start) == type(0): ! dummy = self.player.seektrack( ! start) ! else: ! min, sec, frame = start ! dummy = self.player.seek( ! min, sec, frame) ! if type(end) == type(0): ! self.parser.setcallback( ! CD.PNUM, _dopnum, self) ! self.end = end ! func, arg = \ ! self.callbacks[CD.ATIME] ! if func: ! self.parser.setcallback(CD.ATIME, func, arg) ! else: ! self.parser.removecallback(CD.ATIME) ! else: ! min, sec, frame = end ! self.parser.setcallback( ! CD.ATIME, _doatime, ! self) ! self.end = (min * 60 + sec) * \ ! 75 + frame ! func, arg = \ ! self.callbacks[CD.PNUM] ! if func: ! self.parser.setcallback(CD.PNUM, func, arg) ! else: ! self.parser.removecallback(CD.PNUM) ! self.playing = 1 ! data = self.player.readda(size) ! if data == '': ! self.playing = 0 ! self.listindex = self.listindex + 1 ! continue ! try: ! self.parser.parseframe(data) ! except _Stop: ! self.playing = 0 ! self.listindex = self.listindex + 1 ! finally: ! self.playing = 0 Index: torgb.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-irix5/torgb.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** torgb.py 3 Mar 2004 16:34:31 -0000 1.10 --- torgb.py 18 Jul 2004 06:14:44 -0000 1.11 *************** *** 52,99 **** class error(Exception): ! pass def torgb(filename): ! temps = [] ! ret = None ! try: ! ret = _torgb(filename, temps) ! finally: ! for temp in temps[:]: ! if temp != ret: ! try: ! os.unlink(temp) ! except os.error: ! pass ! temps.remove(temp) ! return ret def _torgb(filename, temps): ! if filename[-2:] == '.Z': ! (fd, fname) = tempfile.mkstemp() ! os.close(fd) ! temps.append(fname) ! sts = uncompress.copy(filename, fname) ! if sts: ! raise error, filename + ': uncompress failed' ! else: ! fname = filename ! try: ! ftype = imghdr.what(fname) ! except IOError, msg: ! if type(msg) == type(()) and len(msg) == 2 and \ ! type(msg[0]) == type(0) and type(msg[1]) == type(''): ! msg = msg[1] ! if type(msg) is not type(''): ! msg = repr(msg) ! raise error, filename + ': ' + msg ! if ftype == 'rgb': ! return fname ! if ftype is None or not table.has_key(ftype): ! raise error, '%s: unsupported image file type %r' % (filename, ftype) ! (fd, temp) = tempfile.mkstemp() ! os.close(fd) ! sts = table[ftype].copy(fname, temp) ! if sts: ! raise error, filename + ': conversion to rgb failed' ! return temp --- 52,99 ---- class error(Exception): ! pass def torgb(filename): ! temps = [] ! ret = None ! try: ! ret = _torgb(filename, temps) ! finally: ! for temp in temps[:]: ! if temp != ret: ! try: ! os.unlink(temp) ! except os.error: ! pass ! temps.remove(temp) ! return ret def _torgb(filename, temps): ! if filename[-2:] == '.Z': ! (fd, fname) = tempfile.mkstemp() ! os.close(fd) ! temps.append(fname) ! sts = uncompress.copy(filename, fname) ! if sts: ! raise error, filename + ': uncompress failed' ! else: ! fname = filename ! try: ! ftype = imghdr.what(fname) ! except IOError, msg: ! if type(msg) == type(()) and len(msg) == 2 and \ ! type(msg[0]) == type(0) and type(msg[1]) == type(''): ! msg = msg[1] ! if type(msg) is not type(''): ! msg = repr(msg) ! raise error, filename + ': ' + msg ! if ftype == 'rgb': ! return fname ! if ftype is None or not table.has_key(ftype): ! raise error, '%s: unsupported image file type %r' % (filename, ftype) ! (fd, temp) = tempfile.mkstemp() ! os.close(fd) ! sts = table[ftype].copy(fname, temp) ! if sts: ! raise error, filename + ': conversion to rgb failed' ! return temp From tim_one at users.sourceforge.net Sun Jul 18 08:15:20 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 08:15:38 2004 Subject: [Python-checkins] python/dist/src/Lib/plat-mac/lib-scriptpackages/Explorer Required_Suite.py, 1.6, 1.7 Standard_Suite.py, 1.6, 1.7 Web_Browser_Suite.py, 1.6, 1.7 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/plat-mac/lib-scriptpackages/Explorer In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31286/plat-mac/lib-scriptpackages/Explorer Modified Files: Required_Suite.py Standard_Suite.py Web_Browser_Suite.py Log Message: Whitespace normalization, via reindent.py. Index: Required_Suite.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/lib-scriptpackages/Explorer/Required_Suite.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Required_Suite.py 12 Apr 2003 22:27:06 -0000 1.6 --- Required_Suite.py 18 Jul 2004 06:14:47 -0000 1.7 *************** *** 74,78 **** def run(self, _no_object=None, _attributes={}, **_arguments): ! """run: Keyword argument _attributes: AppleEvent attribute dictionary """ --- 74,78 ---- def run(self, _no_object=None, _attributes={}, **_arguments): ! """run: Keyword argument _attributes: AppleEvent attribute dictionary """ Index: Standard_Suite.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/lib-scriptpackages/Explorer/Standard_Suite.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Standard_Suite.py 13 Jun 2003 14:31:11 -0000 1.6 --- Standard_Suite.py 18 Jul 2004 06:14:47 -0000 1.7 *************** *** 18,22 **** def get(self, _object, _attributes={}, **_arguments): ! """get: Required argument: an AE object reference Keyword argument as: undocumented, typecode 'type' --- 18,22 ---- def get(self, _object, _attributes={}, **_arguments): ! """get: Required argument: an AE object reference Keyword argument as: undocumented, typecode 'type' Index: Web_Browser_Suite.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/lib-scriptpackages/Explorer/Web_Browser_Suite.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Web_Browser_Suite.py 12 Apr 2003 22:27:06 -0000 1.6 --- Web_Browser_Suite.py 18 Jul 2004 06:14:47 -0000 1.7 *************** *** 85,89 **** Required argument: Window Identifier of the window Keyword argument _attributes: AppleEvent attribute dictionary ! Returns: """ _code = 'WWW!' --- 85,89 ---- Required argument: Window Identifier of the window Keyword argument _attributes: AppleEvent attribute dictionary ! Returns: """ _code = 'WWW!' From tim_one at users.sourceforge.net Sun Jul 18 08:15:20 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 08:15:40 2004 Subject: [Python-checkins] python/dist/src/Lib/plat-mac/lib-scriptpackages/Finder Enumerations.py, 1.7, 1.8 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/plat-mac/lib-scriptpackages/Finder In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31286/plat-mac/lib-scriptpackages/Finder Modified Files: Enumerations.py Log Message: Whitespace normalization, via reindent.py. Index: Enumerations.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/lib-scriptpackages/Finder/Enumerations.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Enumerations.py 12 Apr 2003 22:27:08 -0000 1.7 --- Enumerations.py 18 Jul 2004 06:14:47 -0000 1.8 *************** *** 17,120 **** _Enum_earr = { ! 'not_arranged' : 'narr', # ! 'snap_to_grid' : 'grda', # ! 'arranged_by_name' : 'nama', # ! 'arranged_by_modification_date' : 'mdta', # ! 'arranged_by_creation_date' : 'cdta', # ! 'arranged_by_size' : 'siza', # ! 'arranged_by_kind' : 'kina', # ! 'arranged_by_label' : 'laba', # } _Enum_ecvw = { ! 'icon_view' : 'icnv', # ! 'list_view' : 'lsvw', # ! 'column_view' : 'clvw', # } _Enum_edfm = { ! 'Mac_OS_format' : 'dfhf', # ! 'Mac_OS_Extended_format' : 'dfh+', # ! 'UFS_format' : 'dfuf', # ! 'NFS_format' : 'dfnf', # ! 'audio_format' : 'dfau', # ! 'ProDOS_format' : 'dfpr', # ! 'MS_2d_DOS_format' : 'dfms', # ! 'ISO_9660_format' : 'df96', # ! 'High_Sierra_format' : 'dfhs', # ! 'QuickTake_format' : 'dfqt', # ! 'Apple_Photo_format' : 'dfph', # ! 'AppleShare_format' : 'dfas', # ! 'UDF_format' : 'dfud', # ! 'WebDAV_format' : 'dfwd', # ! 'FTP_format' : 'dfft', # ! 'Packet_2d_written_UDF_format' : 'dfpu', # ! 'unknown_format' : 'df??', # } _Enum_elsv = { ! 'name_column' : 'elsn', # ! 'modification_date_column' : 'elsm', # ! 'creation_date_column' : 'elsc', # ! 'size_column' : 'elss', # ! 'kind_column' : 'elsk', # ! 'label_column' : 'elsl', # ! 'version_column' : 'elsv', # ! 'comment_column' : 'elsC', # } _Enum_ipnl = { ! 'General_Information_panel' : 'gpnl', # ! 'Sharing_panel' : 'spnl', # ! 'Memory_panel' : 'mpnl', # ! 'Preview_panel' : 'vpnl', # ! 'Application_panel' : 'apnl', # ! 'Languages_panel' : 'pklg', # ! 'Plugins_panel' : 'pkpg', # ! 'Name__26__Extension_panel' : 'npnl', # ! 'Comments_panel' : 'cpnl', # ! 'Content_Index_panel' : 'cinl', # } _Enum_isiz = { ! 'mini' : 'miic', # ! 'small' : 'smic', # ! 'large' : 'lgic', # } _Enum_lvic = { ! 'small_icon' : 'smic', # ! 'large_icon' : 'lgic', # } _Enum_priv = { ! 'read_only' : 'read', # ! 'read_write' : 'rdwr', # ! 'write_only' : 'writ', # ! 'none' : 'none', # } _Enum_sodr = { ! 'normal' : 'snrm', # ! 'reversed' : 'srvs', # } _Enum_vwby = { ! 'conflicts' : 'cflc', # ! 'existing_items' : 'exsi', # ! 'small_icon' : 'smic', # ! 'icon' : 'iimg', # ! 'name' : 'pnam', # ! 'modification_date' : 'asmo', # ! 'size' : 'ptsz', # ! 'kind' : 'kind', # ! 'comment' : 'comt', # ! 'label' : 'labi', # ! 'version' : 'vers', # ! 'creation_date' : 'ascd', # ! 'small_button' : 'smbu', # ! 'large_button' : 'lgbu', # ! 'grid' : 'grid', # ! 'all' : 'kyal', # } --- 17,120 ---- _Enum_earr = { ! 'not_arranged' : 'narr', # ! 'snap_to_grid' : 'grda', # ! 'arranged_by_name' : 'nama', # ! 'arranged_by_modification_date' : 'mdta', # ! 'arranged_by_creation_date' : 'cdta', # ! 'arranged_by_size' : 'siza', # ! 'arranged_by_kind' : 'kina', # ! 'arranged_by_label' : 'laba', # } _Enum_ecvw = { ! 'icon_view' : 'icnv', # ! 'list_view' : 'lsvw', # ! 'column_view' : 'clvw', # } _Enum_edfm = { ! 'Mac_OS_format' : 'dfhf', # ! 'Mac_OS_Extended_format' : 'dfh+', # ! 'UFS_format' : 'dfuf', # ! 'NFS_format' : 'dfnf', # ! 'audio_format' : 'dfau', # ! 'ProDOS_format' : 'dfpr', # ! 'MS_2d_DOS_format' : 'dfms', # ! 'ISO_9660_format' : 'df96', # ! 'High_Sierra_format' : 'dfhs', # ! 'QuickTake_format' : 'dfqt', # ! 'Apple_Photo_format' : 'dfph', # ! 'AppleShare_format' : 'dfas', # ! 'UDF_format' : 'dfud', # ! 'WebDAV_format' : 'dfwd', # ! 'FTP_format' : 'dfft', # ! 'Packet_2d_written_UDF_format' : 'dfpu', # ! 'unknown_format' : 'df??', # } _Enum_elsv = { ! 'name_column' : 'elsn', # ! 'modification_date_column' : 'elsm', # ! 'creation_date_column' : 'elsc', # ! 'size_column' : 'elss', # ! 'kind_column' : 'elsk', # ! 'label_column' : 'elsl', # ! 'version_column' : 'elsv', # ! 'comment_column' : 'elsC', # } _Enum_ipnl = { ! 'General_Information_panel' : 'gpnl', # ! 'Sharing_panel' : 'spnl', # ! 'Memory_panel' : 'mpnl', # ! 'Preview_panel' : 'vpnl', # ! 'Application_panel' : 'apnl', # ! 'Languages_panel' : 'pklg', # ! 'Plugins_panel' : 'pkpg', # ! 'Name__26__Extension_panel' : 'npnl', # ! 'Comments_panel' : 'cpnl', # ! 'Content_Index_panel' : 'cinl', # } _Enum_isiz = { ! 'mini' : 'miic', # ! 'small' : 'smic', # ! 'large' : 'lgic', # } _Enum_lvic = { ! 'small_icon' : 'smic', # ! 'large_icon' : 'lgic', # } _Enum_priv = { ! 'read_only' : 'read', # ! 'read_write' : 'rdwr', # ! 'write_only' : 'writ', # ! 'none' : 'none', # } _Enum_sodr = { ! 'normal' : 'snrm', # ! 'reversed' : 'srvs', # } _Enum_vwby = { ! 'conflicts' : 'cflc', # ! 'existing_items' : 'exsi', # ! 'small_icon' : 'smic', # ! 'icon' : 'iimg', # ! 'name' : 'pnam', # ! 'modification_date' : 'asmo', # ! 'size' : 'ptsz', # ! 'kind' : 'kind', # ! 'comment' : 'comt', # ! 'label' : 'labi', # ! 'version' : 'vers', # ! 'creation_date' : 'ascd', # ! 'small_button' : 'smbu', # ! 'large_button' : 'lgbu', # ! 'grid' : 'grid', # ! 'all' : 'kyal', # } From tim_one at users.sourceforge.net Sun Jul 18 08:15:19 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 08:15:41 2004 Subject: [Python-checkins] python/dist/src/Lib/plat-mac/lib-scriptpackages/CodeWarrior CodeWarrior_suite.py, 1.8, 1.9 Metrowerks_Shell_Suite.py, 1.8, 1.9 Required.py, 1.5, 1.6 __init__.py, 1.10, 1.11 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/plat-mac/lib-scriptpackages/CodeWarrior In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31286/plat-mac/lib-scriptpackages/CodeWarrior Modified Files: CodeWarrior_suite.py Metrowerks_Shell_Suite.py Required.py __init__.py Log Message: Whitespace normalization, via reindent.py. Index: CodeWarrior_suite.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/lib-scriptpackages/CodeWarrior/CodeWarrior_suite.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** CodeWarrior_suite.py 13 Jun 2003 14:31:07 -0000 1.8 --- CodeWarrior_suite.py 18 Jul 2004 06:14:46 -0000 1.9 *************** *** 581,622 **** } _Enum_DKND = { ! 'project' : 'PRJD', # a project document ! 'editor_document' : 'EDIT', # an editor document ! 'message' : 'MSSG', # a message document ! 'file_compare' : 'COMP', # a file compare document ! 'catalog_document' : 'CTLG', # a browser catalog ! 'class_browser' : 'BROW', # a class browser document ! 'single_class_browser' : '1BRW', # a single class browser document ! 'symbol_browser' : 'SYMB', # a symbol browser document ! 'class_hierarchy' : 'HIER', # a class hierarchy document ! 'single_class_hierarchy' : '1HIR', # a single class hierarchy document ! 'project_inspector' : 'INSP', # a project inspector ! 'ToolServer_worksheet' : 'TOOL', # the ToolServer worksheet ! 'build_progress_document' : 'PRGS', # the build progress window } _Enum_FTYP = { ! 'library_file' : 'LIBF', # a library file ! 'project_file' : 'PRJF', # a project file ! 'resource_file' : 'RESF', # a resource file ! 'text_file' : 'TXTF', # a text file ! 'unknown_file' : 'UNKN', # unknown file type } _Enum_Inte = { ! 'never_interact' : 'eNvr', # never allow user interactions ! 'interact_with_self' : 'eInS', # allow user interaction only when an AppleEvent is sent from within CodeWarrior ! 'interact_with_local' : 'eInL', # allow user interaction when AppleEvents are sent from applications on the same machine (default) ! 'interact_with_all' : 'eInA', # allow user interaction from both local and remote AppleEvents } _Enum_PERM = { ! 'read_write' : 'RdWr', # the file is open with read/write permission ! 'read_only' : 'Read', # the file is open with read/only permission ! 'checked_out_read_write' : 'CkRW', # the file is checked out with read/write permission ! 'checked_out_read_only' : 'CkRO', # the file is checked out with read/only permission ! 'checked_out_read_modify' : 'CkRM', # the file is checked out with read/modify permission ! 'locked' : 'Lock', # the file is locked on disk ! 'none' : 'LNNO', # the file is new } --- 581,622 ---- } _Enum_DKND = { ! 'project' : 'PRJD', # a project document ! 'editor_document' : 'EDIT', # an editor document ! 'message' : 'MSSG', # a message document ! 'file_compare' : 'COMP', # a file compare document ! 'catalog_document' : 'CTLG', # a browser catalog ! 'class_browser' : 'BROW', # a class browser document ! 'single_class_browser' : '1BRW', # a single class browser document ! 'symbol_browser' : 'SYMB', # a symbol browser document ! 'class_hierarchy' : 'HIER', # a class hierarchy document ! 'single_class_hierarchy' : '1HIR', # a single class hierarchy document ! 'project_inspector' : 'INSP', # a project inspector ! 'ToolServer_worksheet' : 'TOOL', # the ToolServer worksheet ! 'build_progress_document' : 'PRGS', # the build progress window } _Enum_FTYP = { ! 'library_file' : 'LIBF', # a library file ! 'project_file' : 'PRJF', # a project file ! 'resource_file' : 'RESF', # a resource file ! 'text_file' : 'TXTF', # a text file ! 'unknown_file' : 'UNKN', # unknown file type } _Enum_Inte = { ! 'never_interact' : 'eNvr', # never allow user interactions ! 'interact_with_self' : 'eInS', # allow user interaction only when an AppleEvent is sent from within CodeWarrior ! 'interact_with_local' : 'eInL', # allow user interaction when AppleEvents are sent from applications on the same machine (default) ! 'interact_with_all' : 'eInA', # allow user interaction from both local and remote AppleEvents } _Enum_PERM = { ! 'read_write' : 'RdWr', # the file is open with read/write permission ! 'read_only' : 'Read', # the file is open with read/only permission ! 'checked_out_read_write' : 'CkRW', # the file is checked out with read/write permission ! 'checked_out_read_only' : 'CkRO', # the file is checked out with read/only permission ! 'checked_out_read_modify' : 'CkRM', # the file is checked out with read/modify permission ! 'locked' : 'Lock', # the file is locked on disk ! 'none' : 'LNNO', # the file is new } Index: Metrowerks_Shell_Suite.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/lib-scriptpackages/CodeWarrior/Metrowerks_Shell_Suite.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Metrowerks_Shell_Suite.py 13 Jun 2003 14:31:09 -0000 1.8 --- Metrowerks_Shell_Suite.py 18 Jul 2004 06:14:46 -0000 1.9 *************** *** 2026,2133 **** } _Enum_Acce = { ! 'public' : 'Publ', # ! 'protected' : 'Prot', # ! 'private' : 'Priv', # } _Enum_BXbr = { ! 'Always_Build' : 'BXb1', # Always build the target before running. ! 'Ask_Build' : 'BXb2', # Ask before building the target when running. ! 'Never_Build' : 'BXb3', # Never before building the target before running. } _Enum_DbSA = { ! 'No_Action' : 'DSA1', # Don\xd5t do anything to non-debug windows ! 'Hide_Windows' : 'DSA2', # Hide non-debugging windows ! 'Collapse_Windows' : 'DSA3', # Collapse non-debugging windows ! 'Close_Windows' : 'DSA4', # Close non-debugging windows } _Enum_DgBL = { ! 'Always' : 'DgB0', # Always build before debugging. ! 'Never' : 'DgB1', # Never build before debugging. ! 'Ask' : 'DgB2', # Ask about building before debugging. } _Enum_ErrT = { ! 'information' : 'ErIn', # ! 'compiler_warning' : 'ErCW', # ! 'compiler_error' : 'ErCE', # ! 'definition' : 'ErDf', # ! 'linker_warning' : 'ErLW', # ! 'linker_error' : 'ErLE', # ! 'find_result' : 'ErFn', # ! 'generic_error' : 'ErGn', # } _Enum_Inte = { ! 'never_interact' : 'eNvr', # Never allow user interactions ! 'interact_with_self' : 'eInS', # Allow user interaction only when an AppleEvent is sent from within CodeWarrior ! 'interact_with_local' : 'eInL', # Allow user interaction when AppleEvents are sent from applications on the same machine (default) ! 'interact_with_all' : 'eInA', # Allow user interaction from both local and remote AppleEvents } _Enum_Lang = { ! 'C' : 'LC ', # ! 'C_2b__2b_' : 'LC++', # ! 'Pascal' : 'LP ', # ! 'Object_Pascal' : 'LP++', # ! 'Java' : 'LJav', # ! 'Assembler' : 'LAsm', # ! 'Unknown' : 'L? ', # } _Enum_PPrm = { ! 'absolute' : 'Abso', # An absolute path name, including volume name. ! 'project_relative' : 'PRel', # A path relative to the current project\xd5s folder. ! 'shell_relative' : 'SRel', # A path relative to the CodeWarrior\xaa folder. ! 'system_relative' : 'YRel', # A path relative to the system folder ! 'root_relative' : 'RRel', # } _Enum_PXdg = { ! 'Diagnose_None' : 'PXd1', # No Plugin Diagnostics. ! 'Diagnose_Errors' : 'PXd2', # Plugin Diagnostics for errors only. ! 'Diagnose_All' : 'PXd3', # Plugin Diagnostics for everything. } _Enum_PthF = { ! 'Generic_Path' : 'PFGn', # ! 'MacOS_Path' : 'PFMc', # MacOS path using colon as separator ! 'Windows_Path' : 'PFWn', # Windows path using backslash as separator ! 'Unix_Path' : 'PFUx', # Unix path using slash as separator } _Enum_RefP = { ! 'Think_Reference' : 'DanR', # ! 'QuickView' : 'ALTV', # } _Enum_STKd = { ! 'Absolute_Path' : 'STK0', # The \xd2path\xd3 property is an absolute path to the location of the source tree. ! 'Registry_Key' : 'STK1', # The \xd2path\xd3 property is the name of a registry key that contains the path to the root. ! 'Environment_Variable' : 'STK2', # The \xd2path\xd3 property is the name of an environment variable that contains the path to the root. } _Enum_SrcT = { ! 'source' : 'FTxt', # A source file (.c, .cp, .p, etc). ! 'unknown' : 'FUnk', # An unknown file type. } _Enum_TmpB = { ! 'User_Specified' : 'Usrs', # Use user specified symbols when setting temporary breakpoints on program launch. ! 'Default' : 'Dflt', # Use system default symbols when setting temporary breakpoints on program launch. } _Enum_TxtF = { ! 'MacOS' : 'TxF0', # MacOS text format ! 'DOS' : 'TxF1', # DOS text format ! 'Unix' : 'TxF2', # Unix text format } _Enum_savo = { ! 'yes' : 'yes ', # Save changes ! 'no' : 'no ', # Do not save changes ! 'ask' : 'ask ', # Ask the user whether to save } --- 2026,2133 ---- } _Enum_Acce = { ! 'public' : 'Publ', # ! 'protected' : 'Prot', # ! 'private' : 'Priv', # } _Enum_BXbr = { ! 'Always_Build' : 'BXb1', # Always build the target before running. ! 'Ask_Build' : 'BXb2', # Ask before building the target when running. ! 'Never_Build' : 'BXb3', # Never before building the target before running. } _Enum_DbSA = { ! 'No_Action' : 'DSA1', # Don\xd5t do anything to non-debug windows ! 'Hide_Windows' : 'DSA2', # Hide non-debugging windows ! 'Collapse_Windows' : 'DSA3', # Collapse non-debugging windows ! 'Close_Windows' : 'DSA4', # Close non-debugging windows } _Enum_DgBL = { ! 'Always' : 'DgB0', # Always build before debugging. ! 'Never' : 'DgB1', # Never build before debugging. ! 'Ask' : 'DgB2', # Ask about building before debugging. } _Enum_ErrT = { ! 'information' : 'ErIn', # ! 'compiler_warning' : 'ErCW', # ! 'compiler_error' : 'ErCE', # ! 'definition' : 'ErDf', # ! 'linker_warning' : 'ErLW', # ! 'linker_error' : 'ErLE', # ! 'find_result' : 'ErFn', # ! 'generic_error' : 'ErGn', # } _Enum_Inte = { ! 'never_interact' : 'eNvr', # Never allow user interactions ! 'interact_with_self' : 'eInS', # Allow user interaction only when an AppleEvent is sent from within CodeWarrior ! 'interact_with_local' : 'eInL', # Allow user interaction when AppleEvents are sent from applications on the same machine (default) ! 'interact_with_all' : 'eInA', # Allow user interaction from both local and remote AppleEvents } _Enum_Lang = { ! 'C' : 'LC ', # ! 'C_2b__2b_' : 'LC++', # ! 'Pascal' : 'LP ', # ! 'Object_Pascal' : 'LP++', # ! 'Java' : 'LJav', # ! 'Assembler' : 'LAsm', # ! 'Unknown' : 'L? ', # } _Enum_PPrm = { ! 'absolute' : 'Abso', # An absolute path name, including volume name. ! 'project_relative' : 'PRel', # A path relative to the current project\xd5s folder. ! 'shell_relative' : 'SRel', # A path relative to the CodeWarrior\xaa folder. ! 'system_relative' : 'YRel', # A path relative to the system folder ! 'root_relative' : 'RRel', # } _Enum_PXdg = { ! 'Diagnose_None' : 'PXd1', # No Plugin Diagnostics. ! 'Diagnose_Errors' : 'PXd2', # Plugin Diagnostics for errors only. ! 'Diagnose_All' : 'PXd3', # Plugin Diagnostics for everything. } _Enum_PthF = { ! 'Generic_Path' : 'PFGn', # ! 'MacOS_Path' : 'PFMc', # MacOS path using colon as separator ! 'Windows_Path' : 'PFWn', # Windows path using backslash as separator ! 'Unix_Path' : 'PFUx', # Unix path using slash as separator } _Enum_RefP = { ! 'Think_Reference' : 'DanR', # ! 'QuickView' : 'ALTV', # } _Enum_STKd = { ! 'Absolute_Path' : 'STK0', # The \xd2path\xd3 property is an absolute path to the location of the source tree. ! 'Registry_Key' : 'STK1', # The \xd2path\xd3 property is the name of a registry key that contains the path to the root. ! 'Environment_Variable' : 'STK2', # The \xd2path\xd3 property is the name of an environment variable that contains the path to the root. } _Enum_SrcT = { ! 'source' : 'FTxt', # A source file (.c, .cp, .p, etc). ! 'unknown' : 'FUnk', # An unknown file type. } _Enum_TmpB = { ! 'User_Specified' : 'Usrs', # Use user specified symbols when setting temporary breakpoints on program launch. ! 'Default' : 'Dflt', # Use system default symbols when setting temporary breakpoints on program launch. } _Enum_TxtF = { ! 'MacOS' : 'TxF0', # MacOS text format ! 'DOS' : 'TxF1', # DOS text format ! 'Unix' : 'TxF2', # Unix text format } _Enum_savo = { ! 'yes' : 'yes ', # Save changes ! 'no' : 'no ', # Do not save changes ! 'ask' : 'ask ', # Ask the user whether to save } Index: Required.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/lib-scriptpackages/CodeWarrior/Required.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Required.py 13 Jun 2003 14:31:10 -0000 1.5 --- Required.py 18 Jul 2004 06:14:47 -0000 1.6 *************** *** 41,46 **** _Enum_Conv = { ! 'yes' : 'yes ', # Convert the project if necessary on open ! 'no' : 'no ', # Do not convert the project if needed on open } --- 41,46 ---- _Enum_Conv = { ! 'yes' : 'yes ', # Convert the project if necessary on open ! 'no' : 'no ', # Do not convert the project if needed on open } Index: __init__.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/lib-scriptpackages/CodeWarrior/__init__.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** __init__.py 13 Jun 2003 14:31:10 -0000 1.10 --- __init__.py 18 Jul 2004 06:14:47 -0000 1.11 *************** *** 188,190 **** _moduleName = 'CodeWarrior' - --- 188,189 ---- From tim_one at users.sourceforge.net Sun Jul 18 08:15:19 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 08:15:43 2004 Subject: [Python-checkins] python/dist/src/Lib/plat-irix6 AL.py, 1.1, 1.2 CD.py, 1.1, 1.2 CL.py, 1.1, 1.2 FILE.py, 1.2, 1.3 FL.py, 1.2, 1.3 SV.py, 1.1, 1.2 cddb.py, 1.5, 1.6 cdplayer.py, 1.6, 1.7 flp.py, 1.9, 1.10 jpeg.py, 1.4, 1.5 panel.py, 1.4, 1.5 panelparser.py, 1.2, 1.3 readcd.py, 1.4, 1.5 torgb.py, 1.6, 1.7 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/plat-irix6 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31286/plat-irix6 Modified Files: AL.py CD.py CL.py FILE.py FL.py SV.py cddb.py cdplayer.py flp.py jpeg.py panel.py panelparser.py readcd.py torgb.py Log Message: Whitespace normalization, via reindent.py. Index: AL.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-irix6/AL.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** AL.py 15 Jan 1997 19:18:26 -0000 1.1 --- AL.py 18 Jul 2004 06:14:44 -0000 1.2 *************** *** 1,61 **** ! RATE_48000 = 48000 ! RATE_44100 = 44100 ! RATE_32000 = 32000 ! RATE_22050 = 22050 ! RATE_16000 = 16000 ! RATE_11025 = 11025 ! RATE_8000 = 8000 SAMPFMT_TWOSCOMP= 1 ! SAMPFMT_FLOAT = 32 ! SAMPFMT_DOUBLE = 64 ! SAMPLE_8 = 1 ! SAMPLE_16 = 2 ! # SAMPLE_24 is the low 24 bits of a long, sign extended to 32 bits ! SAMPLE_24 = 4 ! MONO = 1 ! STEREO = 2 ! QUADRO = 4 # 4CHANNEL is not a legal Python name ! INPUT_LINE = 0 ! INPUT_MIC = 1 ! INPUT_DIGITAL = 2 ! MONITOR_OFF = 0 ! MONITOR_ON = 1 ! ERROR_NUMBER = 0 ! ERROR_TYPE = 1 ! ERROR_LOCATION_LSP = 2 ! ERROR_LOCATION_MSP = 3 ! ERROR_LENGTH = 4 ! ERROR_INPUT_UNDERFLOW = 0 ! ERROR_OUTPUT_OVERFLOW = 1 # These seem to be not supported anymore: ! ##HOLD, RELEASE = 0, 1 ! ##ATTAIL, ATHEAD, ATMARK, ATTIME = 0, 1, 2, 3 ! DEFAULT_DEVICE = 1 ! INPUT_SOURCE = 0 ! LEFT_INPUT_ATTEN = 1 ! RIGHT_INPUT_ATTEN = 2 ! INPUT_RATE = 3 ! OUTPUT_RATE = 4 ! LEFT_SPEAKER_GAIN = 5 ! RIGHT_SPEAKER_GAIN = 6 ! INPUT_COUNT = 7 ! OUTPUT_COUNT = 8 ! UNUSED_COUNT = 9 ! SYNC_INPUT_TO_AES = 10 ! SYNC_OUTPUT_TO_AES = 11 ! MONITOR_CTL = 12 ! LEFT_MONITOR_ATTEN = 13 ! RIGHT_MONITOR_ATTEN = 14 ! ENUM_VALUE = 0 # only certain values are valid ! RANGE_VALUE = 1 # any value in range is valid --- 1,61 ---- ! RATE_48000 = 48000 ! RATE_44100 = 44100 ! RATE_32000 = 32000 ! RATE_22050 = 22050 ! RATE_16000 = 16000 ! RATE_11025 = 11025 ! RATE_8000 = 8000 SAMPFMT_TWOSCOMP= 1 ! SAMPFMT_FLOAT = 32 ! SAMPFMT_DOUBLE = 64 ! SAMPLE_8 = 1 ! SAMPLE_16 = 2 ! # SAMPLE_24 is the low 24 bits of a long, sign extended to 32 bits ! SAMPLE_24 = 4 ! MONO = 1 ! STEREO = 2 ! QUADRO = 4 # 4CHANNEL is not a legal Python name ! INPUT_LINE = 0 ! INPUT_MIC = 1 ! INPUT_DIGITAL = 2 ! MONITOR_OFF = 0 ! MONITOR_ON = 1 ! ERROR_NUMBER = 0 ! ERROR_TYPE = 1 ! ERROR_LOCATION_LSP = 2 ! ERROR_LOCATION_MSP = 3 ! ERROR_LENGTH = 4 ! ERROR_INPUT_UNDERFLOW = 0 ! ERROR_OUTPUT_OVERFLOW = 1 # These seem to be not supported anymore: ! ##HOLD, RELEASE = 0, 1 ! ##ATTAIL, ATHEAD, ATMARK, ATTIME = 0, 1, 2, 3 ! DEFAULT_DEVICE = 1 ! INPUT_SOURCE = 0 ! LEFT_INPUT_ATTEN = 1 ! RIGHT_INPUT_ATTEN = 2 ! INPUT_RATE = 3 ! OUTPUT_RATE = 4 ! LEFT_SPEAKER_GAIN = 5 ! RIGHT_SPEAKER_GAIN = 6 ! INPUT_COUNT = 7 ! OUTPUT_COUNT = 8 ! UNUSED_COUNT = 9 ! SYNC_INPUT_TO_AES = 10 ! SYNC_OUTPUT_TO_AES = 11 ! MONITOR_CTL = 12 ! LEFT_MONITOR_ATTEN = 13 ! RIGHT_MONITOR_ATTEN = 14 ! ENUM_VALUE = 0 # only certain values are valid ! RANGE_VALUE = 1 # any value in range is valid Index: CD.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-irix6/CD.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CD.py 15 Jan 1997 19:18:33 -0000 1.1 --- CD.py 18 Jul 2004 06:14:45 -0000 1.2 *************** *** 1,34 **** ! ERROR = 0 ! NODISC = 1 ! READY = 2 ! PLAYING = 3 ! PAUSED = 4 ! STILL = 5 ! AUDIO = 0 ! PNUM = 1 ! INDEX = 2 ! PTIME = 3 ! ATIME = 4 ! CATALOG = 5 ! IDENT = 6 ! CONTROL = 7 ! CDDA_DATASIZE = 2352 ! ##CDDA_SUBCODESIZE = (sizeof(struct subcodeQ)) ! ##CDDA_BLOCKSIZE = (sizeof(struct cdframe)) ! ##CDDA_NUMSAMPLES = (CDDA_DATASIZE/2) ## ! ##CDQ_PREEMP_MASK = 0xd ! ##CDQ_COPY_MASK = 0xb ! ##CDQ_DDATA_MASK = 0xd ! ##CDQ_BROADCAST_MASK = 0x8 ! ##CDQ_PREEMPHASIS = 0x1 ! ##CDQ_COPY_PERMITTED = 0x2 ! ##CDQ_DIGITAL_DATA = 0x4 ! ##CDQ_BROADCAST_USE = 0x8 ## ! ##CDQ_MODE1 = 0x1 ! ##CDQ_MODE2 = 0x2 ! ##CDQ_MODE3 = 0x3 --- 1,34 ---- ! ERROR = 0 ! NODISC = 1 ! READY = 2 ! PLAYING = 3 ! PAUSED = 4 ! STILL = 5 ! AUDIO = 0 ! PNUM = 1 ! INDEX = 2 ! PTIME = 3 ! ATIME = 4 ! CATALOG = 5 ! IDENT = 6 ! CONTROL = 7 ! CDDA_DATASIZE = 2352 ! ##CDDA_SUBCODESIZE = (sizeof(struct subcodeQ)) ! ##CDDA_BLOCKSIZE = (sizeof(struct cdframe)) ! ##CDDA_NUMSAMPLES = (CDDA_DATASIZE/2) ## ! ##CDQ_PREEMP_MASK = 0xd ! ##CDQ_COPY_MASK = 0xb ! ##CDQ_DDATA_MASK = 0xd ! ##CDQ_BROADCAST_MASK = 0x8 ! ##CDQ_PREEMPHASIS = 0x1 ! ##CDQ_COPY_PERMITTED = 0x2 ! ##CDQ_DIGITAL_DATA = 0x4 ! ##CDQ_BROADCAST_USE = 0x8 ## ! ##CDQ_MODE1 = 0x1 ! ##CDQ_MODE2 = 0x2 ! ##CDQ_MODE3 = 0x3 Index: CL.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-irix6/CL.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CL.py 15 Jan 1997 19:18:35 -0000 1.1 --- CL.py 18 Jul 2004 06:14:45 -0000 1.2 *************** *** 2,24 **** # All relevant symbols are now defined in the module cl. try: ! from cl import * except ImportError: ! from CL_old import * else: ! del CompressImage ! del DecompressImage ! del GetAlgorithmName ! del OpenCompressor ! del OpenDecompressor ! del QueryAlgorithms ! del QueryMaxHeaderSize ! del QueryScheme ! del QuerySchemeFromName ! del SetDefault ! del SetMax ! del SetMin ! try: ! del cvt_type ! except NameError: ! pass ! del error --- 2,24 ---- # All relevant symbols are now defined in the module cl. try: ! from cl import * except ImportError: ! from CL_old import * else: ! del CompressImage ! del DecompressImage ! del GetAlgorithmName ! del OpenCompressor ! del OpenDecompressor ! del QueryAlgorithms ! del QueryMaxHeaderSize ! del QueryScheme ! del QuerySchemeFromName ! del SetDefault ! del SetMax ! del SetMin ! try: ! del cvt_type ! except NameError: ! pass ! del error Index: FILE.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-irix6/FILE.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** FILE.py 17 Mar 2002 21:49:20 -0000 1.2 --- FILE.py 18 Jul 2004 06:14:45 -0000 1.3 *************** *** 442,446 **** def OFFTOBBT(bytes): return ((off_t)(bytes) >> BBSHIFT) ! def BBTOOFF(bbs): return ((off_t)(bbs) << BBSHIFT) SEEKLIMIT32 = 0x7fffffff --- 442,446 ---- def OFFTOBBT(bytes): return ((off_t)(bytes) >> BBSHIFT) ! def BBTOOFF(bbs): return ((off_t)(bbs) << BBSHIFT) SEEKLIMIT32 = 0x7fffffff *************** *** 490,496 **** MRLOCK_ALLOW_EQUAL_PRI = 0x8 MRLOCK_DEFAULT = MRLOCK_BARRIER ! def mraccess(mrp): return mraccessf(mrp, 0) ! def mrupdate(mrp): return mrupdatef(mrp, 0) def mp_mutex_unlock(m): return mutex_unlock(m) --- 490,496 ---- MRLOCK_ALLOW_EQUAL_PRI = 0x8 MRLOCK_DEFAULT = MRLOCK_BARRIER ! def mraccess(mrp): return mraccessf(mrp, 0) ! def mrupdate(mrp): return mrupdatef(mrp, 0) def mp_mutex_unlock(m): return mutex_unlock(m) Index: FL.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-irix6/FL.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** FL.py 12 Dec 2000 23:11:42 -0000 1.2 --- FL.py 18 Jul 2004 06:14:45 -0000 1.3 *************** *** 8,14 **** ##import fl ##try: ! ## _v20 = (fl.get_rgbmode is not None) ##except: ! ## _v20 = 0 ##del fl --- 8,14 ---- ##import fl ##try: ! ## _v20 = (fl.get_rgbmode is not None) ##except: ! ## _v20 = 0 ##del fl *************** *** 21,25 **** LABEL_SIZE = 64 if _v20: ! SHORTCUT_SIZE = 32 PLACE_FREE = 0 PLACE_SIZE = 1 --- 21,25 ---- LABEL_SIZE = 64 if _v20: ! SHORTCUT_SIZE = 32 PLACE_FREE = 0 PLACE_SIZE = 1 *************** *** 120,124 **** RETURN_BUTTON = 6 if _v20: ! HIDDEN_RET_BUTTON = 7 BUTTON_BOXTYPE = UP_BOX BUTTON_COL1 = COL1 --- 120,124 ---- RETURN_BUTTON = 6 if _v20: ! HIDDEN_RET_BUTTON = 7 BUTTON_BOXTYPE = UP_BOX BUTTON_COL1 = COL1 *************** *** 130,147 **** BUTTON_BW = BOUND_WIDTH if _v20: ! CHART = 4 ! BAR_CHART = 0 ! HORBAR_CHART = 1 ! LINE_CHART = 2 ! FILLED_CHART = 3 ! SPIKE_CHART = 4 ! PIE_CHART = 5 ! SPECIALPIE_CHART = 6 ! CHART_BOXTYPE = BORDER_BOX ! CHART_COL1 = COL1 ! CHART_LCOL = LCOL ! CHART_ALIGN = ALIGN_BOTTOM ! CHART_BW = BOUND_WIDTH ! CHART_MAX = 128 CHOICE = 42 NORMAL_CHOICE = 0 --- 130,147 ---- BUTTON_BW = BOUND_WIDTH if _v20: ! CHART = 4 ! BAR_CHART = 0 ! HORBAR_CHART = 1 ! LINE_CHART = 2 ! FILLED_CHART = 3 ! SPIKE_CHART = 4 ! PIE_CHART = 5 ! SPECIALPIE_CHART = 6 ! CHART_BOXTYPE = BORDER_BOX ! CHART_COL1 = COL1 ! CHART_LCOL = LCOL ! CHART_ALIGN = ALIGN_BOTTOM ! CHART_BW = BOUND_WIDTH ! CHART_MAX = 128 CHOICE = 42 NORMAL_CHOICE = 0 *************** *** 174,182 **** COUNTER_ALIGN = ALIGN_BOTTOM if _v20: ! COUNTER_BW = BOUND_WIDTH else: ! DEFAULT = 51 ! RETURN_DEFAULT = 0 ! ALWAYS_DEFAULT = 1 DIAL = 22 NORMAL_DIAL = 0 --- 174,182 ---- COUNTER_ALIGN = ALIGN_BOTTOM if _v20: ! COUNTER_BW = BOUND_WIDTH else: ! DEFAULT = 51 ! RETURN_DEFAULT = 0 ! ALWAYS_DEFAULT = 1 DIAL = 22 NORMAL_DIAL = 0 *************** *** 198,209 **** NORMAL_INPUT = 0 if _v20: ! FLOAT_INPUT = 1 ! INT_INPUT = 2 ! HIDDEN_INPUT = 3 ! if _v21: ! MULTILINE_INPUT = 4 ! SECRET_INPUT = 5 else: ! ALWAYS_INPUT = 1 INPUT_BOXTYPE = DOWN_BOX INPUT_COL1 = 13 --- 198,209 ---- NORMAL_INPUT = 0 if _v20: ! FLOAT_INPUT = 1 ! INT_INPUT = 2 ! HIDDEN_INPUT = 3 ! if _v21: ! MULTILINE_INPUT = 4 ! SECRET_INPUT = 5 else: ! ALWAYS_INPUT = 1 INPUT_BOXTYPE = DOWN_BOX INPUT_COL1 = 13 Index: SV.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-irix6/SV.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SV.py 15 Jan 1997 19:18:56 -0000 1.1 --- SV.py 18 Jul 2004 06:14:45 -0000 1.2 *************** *** 8,21 **** # mode parameter for Bind calls ! IN_OFF = 0 # No Video ! IN_OVER = 1 # Video over graphics ! IN_UNDER = 2 # Video under graphics ! IN_REPLACE = 3 # Video replaces entire win # mode parameters for LoadMap calls. Specifies buffer, always 256 entries ! INPUT_COLORMAP = 0 # tuples of 8-bit RGB ! CHROMA_KEY_MAP = 1 # tuples of 8-bit RGB ! COLOR_SPACE_MAP = 2 # tuples of 8-bit RGB ! GAMMA_MAP = 3 # tuples of 24-bit red values # mode parameters for UseExclusive calls --- 8,21 ---- # mode parameter for Bind calls ! IN_OFF = 0 # No Video ! IN_OVER = 1 # Video over graphics ! IN_UNDER = 2 # Video under graphics ! IN_REPLACE = 3 # Video replaces entire win # mode parameters for LoadMap calls. Specifies buffer, always 256 entries ! INPUT_COLORMAP = 0 # tuples of 8-bit RGB ! CHROMA_KEY_MAP = 1 # tuples of 8-bit RGB ! COLOR_SPACE_MAP = 2 # tuples of 8-bit RGB ! GAMMA_MAP = 3 # tuples of 24-bit red values # mode parameters for UseExclusive calls *************** *** 25,31 **** # Format constants for the capture routines ! RGB8_FRAMES = 0 # noninterleaved 8 bit 3:2:3 RBG fields ! RGB32_FRAMES = 1 # 32-bit 8:8:8 RGB frames ! YUV411_FRAMES = 2 # interleaved, 8:2:2 YUV format YUV411_FRAMES_AND_BLANKING_BUFFER = 3 --- 25,31 ---- # Format constants for the capture routines ! RGB8_FRAMES = 0 # noninterleaved 8 bit 3:2:3 RBG fields ! RGB32_FRAMES = 1 # 32-bit 8:8:8 RGB frames ! YUV411_FRAMES = 2 # interleaved, 8:2:2 YUV format YUV411_FRAMES_AND_BLANKING_BUFFER = 3 Index: cddb.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-irix6/cddb.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** cddb.py 3 Mar 2004 16:34:31 -0000 1.5 --- cddb.py 18 Jul 2004 06:14:45 -0000 1.6 *************** *** 21,204 **** _dbid_map = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ@_=+abcdefghijklmnopqrstuvwxyz' def _dbid(v): ! if v >= len(_dbid_map): ! return string.zfill(v, 2) ! else: ! return _dbid_map[v] def tochash(toc): ! if type(toc) == type(''): ! tracklist = [] ! for i in range(2, len(toc), 4): ! tracklist.append((None, ! (int(toc[i:i+2]), ! int(toc[i+2:i+4])))) ! else: ! tracklist = toc ! ntracks = len(tracklist) ! hash = _dbid((ntracks >> 4) & 0xF) + _dbid(ntracks & 0xF) ! if ntracks <= _DB_ID_NTRACKS: ! nidtracks = ntracks ! else: ! nidtracks = _DB_ID_NTRACKS - 1 ! min = 0 ! sec = 0 ! for track in tracklist: ! start, length = track ! min = min + length[0] ! sec = sec + length[1] ! min = min + sec / 60 ! sec = sec % 60 ! hash = hash + _dbid(min) + _dbid(sec) ! for i in range(nidtracks): ! start, length = tracklist[i] ! hash = hash + _dbid(length[0]) + _dbid(length[1]) ! return hash ! class Cddb: ! def __init__(self, tracklist): ! if os.environ.has_key('CDDB_PATH'): ! path = os.environ['CDDB_PATH'] ! cddb_path = path.split(',') ! else: ! home = os.environ['HOME'] ! cddb_path = [home + '/' + _cddbrc] ! self._get_id(tracklist) ! for dir in cddb_path: ! file = dir + '/' + self.id + '.rdb' ! try: ! f = open(file, 'r') ! self.file = file ! break ! except IOError: ! pass ! ntracks = int(self.id[:2], 16) ! self.artist = '' ! self.title = '' ! self.track = [None] + [''] * ntracks ! self.trackartist = [None] + [''] * ntracks ! self.notes = [] ! if not hasattr(self, 'file'): ! return ! import re ! reg = re.compile(r'^([^.]*)\.([^:]*):[\t ]+(.*)') ! while 1: ! line = f.readline() ! if not line: ! break ! match = reg.match(line) ! if not match: ! print 'syntax error in ' + file ! continue ! name1, name2, value = match.group(1, 2, 3) ! if name1 == 'album': ! if name2 == 'artist': ! self.artist = value ! elif name2 == 'title': ! self.title = value ! elif name2 == 'toc': ! if not self.toc: ! self.toc = value ! if self.toc != value: ! print 'toc\'s don\'t match' ! elif name2 == 'notes': ! self.notes.append(value) ! elif name1[:5] == 'track': ! try: ! trackno = int(name1[5:]) ! except ValueError: ! print 'syntax error in ' + file ! continue ! if trackno > ntracks: ! print 'track number %r in file %s out of range' % (trackno, file) ! continue ! if name2 == 'title': ! self.track[trackno] = value ! elif name2 == 'artist': ! self.trackartist[trackno] = value ! f.close() ! for i in range(2, len(self.track)): ! track = self.track[i] ! # if track title starts with `,', use initial part ! # of previous track's title ! if track and track[0] == ',': ! try: ! off = self.track[i - 1].index(',') ! except ValueError: ! pass ! else: ! self.track[i] = self.track[i-1][:off] \ ! + track ! def _get_id(self, tracklist): ! # fill in self.id and self.toc. ! # if the argument is a string ending in .rdb, the part ! # upto the suffix is taken as the id. ! if type(tracklist) == type(''): ! if tracklist[-4:] == '.rdb': ! self.id = tracklist[:-4] ! self.toc = '' ! return ! t = [] ! for i in range(2, len(tracklist), 4): ! t.append((None, \ ! (int(tracklist[i:i+2]), \ ! int(tracklist[i+2:i+4])))) ! tracklist = t ! ntracks = len(tracklist) ! self.id = _dbid((ntracks >> 4) & 0xF) + _dbid(ntracks & 0xF) ! if ntracks <= _DB_ID_NTRACKS: ! nidtracks = ntracks ! else: ! nidtracks = _DB_ID_NTRACKS - 1 ! min = 0 ! sec = 0 ! for track in tracklist: ! start, length = track ! min = min + length[0] ! sec = sec + length[1] ! min = min + sec / 60 ! sec = sec % 60 ! self.id = self.id + _dbid(min) + _dbid(sec) ! for i in range(nidtracks): ! start, length = tracklist[i] ! self.id = self.id + _dbid(length[0]) + _dbid(length[1]) ! self.toc = string.zfill(ntracks, 2) ! for track in tracklist: ! start, length = track ! self.toc = self.toc + string.zfill(length[0], 2) + \ ! string.zfill(length[1], 2) ! def write(self): ! import posixpath ! if os.environ.has_key('CDDB_WRITE_DIR'): ! dir = os.environ['CDDB_WRITE_DIR'] ! else: ! dir = os.environ['HOME'] + '/' + _cddbrc ! file = dir + '/' + self.id + '.rdb' ! if posixpath.exists(file): ! # make backup copy ! posix.rename(file, file + '~') ! f = open(file, 'w') ! f.write('album.title:\t' + self.title + '\n') ! f.write('album.artist:\t' + self.artist + '\n') ! f.write('album.toc:\t' + self.toc + '\n') ! for note in self.notes: ! f.write('album.notes:\t' + note + '\n') ! prevpref = None ! for i in range(1, len(self.track)): ! if self.trackartist[i]: ! f.write('track%r.artist:\t%s\n' % (i, self.trackartist[i])) ! track = self.track[i] ! try: ! off = track.index(',') ! except ValueError: ! prevpref = None ! else: ! if prevpref and track[:off] == prevpref: ! track = track[off:] ! else: ! prevpref = track[:off] ! f.write('track%r.title:\t%s\n' % (i, track)) ! f.close() --- 21,204 ---- _dbid_map = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ@_=+abcdefghijklmnopqrstuvwxyz' def _dbid(v): ! if v >= len(_dbid_map): ! return string.zfill(v, 2) ! else: ! return _dbid_map[v] def tochash(toc): ! if type(toc) == type(''): ! tracklist = [] ! for i in range(2, len(toc), 4): ! tracklist.append((None, ! (int(toc[i:i+2]), ! int(toc[i+2:i+4])))) ! else: ! tracklist = toc ! ntracks = len(tracklist) ! hash = _dbid((ntracks >> 4) & 0xF) + _dbid(ntracks & 0xF) ! if ntracks <= _DB_ID_NTRACKS: ! nidtracks = ntracks ! else: ! nidtracks = _DB_ID_NTRACKS - 1 ! min = 0 ! sec = 0 ! for track in tracklist: ! start, length = track ! min = min + length[0] ! sec = sec + length[1] ! min = min + sec / 60 ! sec = sec % 60 ! hash = hash + _dbid(min) + _dbid(sec) ! for i in range(nidtracks): ! start, length = tracklist[i] ! hash = hash + _dbid(length[0]) + _dbid(length[1]) ! return hash ! class Cddb: ! def __init__(self, tracklist): ! if os.environ.has_key('CDDB_PATH'): ! path = os.environ['CDDB_PATH'] ! cddb_path = path.split(',') ! else: ! home = os.environ['HOME'] ! cddb_path = [home + '/' + _cddbrc] ! self._get_id(tracklist) ! for dir in cddb_path: ! file = dir + '/' + self.id + '.rdb' ! try: ! f = open(file, 'r') ! self.file = file ! break ! except IOError: ! pass ! ntracks = int(self.id[:2], 16) ! self.artist = '' ! self.title = '' ! self.track = [None] + [''] * ntracks ! self.trackartist = [None] + [''] * ntracks ! self.notes = [] ! if not hasattr(self, 'file'): ! return ! import re ! reg = re.compile(r'^([^.]*)\.([^:]*):[\t ]+(.*)') ! while 1: ! line = f.readline() ! if not line: ! break ! match = reg.match(line) ! if not match: ! print 'syntax error in ' + file ! continue ! name1, name2, value = match.group(1, 2, 3) ! if name1 == 'album': ! if name2 == 'artist': ! self.artist = value ! elif name2 == 'title': ! self.title = value ! elif name2 == 'toc': ! if not self.toc: ! self.toc = value ! if self.toc != value: ! print 'toc\'s don\'t match' ! elif name2 == 'notes': ! self.notes.append(value) ! elif name1[:5] == 'track': ! try: ! trackno = int(name1[5:]) ! except ValueError: ! print 'syntax error in ' + file ! continue ! if trackno > ntracks: ! print 'track number %r in file %s out of range' % (trackno, file) ! continue ! if name2 == 'title': ! self.track[trackno] = value ! elif name2 == 'artist': ! self.trackartist[trackno] = value ! f.close() ! for i in range(2, len(self.track)): ! track = self.track[i] ! # if track title starts with `,', use initial part ! # of previous track's title ! if track and track[0] == ',': ! try: ! off = self.track[i - 1].index(',') ! except ValueError: ! pass ! else: ! self.track[i] = self.track[i-1][:off] \ ! + track ! def _get_id(self, tracklist): ! # fill in self.id and self.toc. ! # if the argument is a string ending in .rdb, the part ! # upto the suffix is taken as the id. ! if type(tracklist) == type(''): ! if tracklist[-4:] == '.rdb': ! self.id = tracklist[:-4] ! self.toc = '' ! return ! t = [] ! for i in range(2, len(tracklist), 4): ! t.append((None, \ ! (int(tracklist[i:i+2]), \ ! int(tracklist[i+2:i+4])))) ! tracklist = t ! ntracks = len(tracklist) ! self.id = _dbid((ntracks >> 4) & 0xF) + _dbid(ntracks & 0xF) ! if ntracks <= _DB_ID_NTRACKS: ! nidtracks = ntracks ! else: ! nidtracks = _DB_ID_NTRACKS - 1 ! min = 0 ! sec = 0 ! for track in tracklist: ! start, length = track ! min = min + length[0] ! sec = sec + length[1] ! min = min + sec / 60 ! sec = sec % 60 ! self.id = self.id + _dbid(min) + _dbid(sec) ! for i in range(nidtracks): ! start, length = tracklist[i] ! self.id = self.id + _dbid(length[0]) + _dbid(length[1]) ! self.toc = string.zfill(ntracks, 2) ! for track in tracklist: ! start, length = track ! self.toc = self.toc + string.zfill(length[0], 2) + \ ! string.zfill(length[1], 2) ! def write(self): ! import posixpath ! if os.environ.has_key('CDDB_WRITE_DIR'): ! dir = os.environ['CDDB_WRITE_DIR'] ! else: ! dir = os.environ['HOME'] + '/' + _cddbrc ! file = dir + '/' + self.id + '.rdb' ! if posixpath.exists(file): ! # make backup copy ! posix.rename(file, file + '~') ! f = open(file, 'w') ! f.write('album.title:\t' + self.title + '\n') ! f.write('album.artist:\t' + self.artist + '\n') ! f.write('album.toc:\t' + self.toc + '\n') ! for note in self.notes: ! f.write('album.notes:\t' + note + '\n') ! prevpref = None ! for i in range(1, len(self.track)): ! if self.trackartist[i]: ! f.write('track%r.artist:\t%s\n' % (i, self.trackartist[i])) ! track = self.track[i] ! try: ! off = track.index(',') ! except ValueError: ! prevpref = None ! else: ! if prevpref and track[:off] == prevpref: ! track = track[off:] ! else: ! prevpref = track[:off] ! f.write('track%r.title:\t%s\n' % (i, track)) ! f.close() Index: cdplayer.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-irix6/cdplayer.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** cdplayer.py 12 Feb 2004 17:35:10 -0000 1.6 --- cdplayer.py 18 Jul 2004 06:14:45 -0000 1.7 *************** *** 18,88 **** class Cdplayer: ! def __init__(self, tracklist): ! import string ! self.artist = '' ! self.title = '' ! if type(tracklist) == type(''): ! t = [] ! for i in range(2, len(tracklist), 4): ! t.append((None, \ ! (int(tracklist[i:i+2]), \ ! int(tracklist[i+2:i+4])))) ! tracklist = t ! self.track = [None] + [''] * len(tracklist) ! self.id = 'd' + string.zfill(len(tracklist), 2) ! for track in tracklist: ! start, length = track ! self.id = self.id + string.zfill(length[0], 2) + \ ! string.zfill(length[1], 2) ! try: ! import posix ! f = open(posix.environ['HOME'] + '/' + cdplayerrc, 'r') ! except IOError: ! return ! import re ! reg = re.compile(r'^([^:]*):\t(.*)') ! s = self.id + '.' ! l = len(s) ! while 1: ! line = f.readline() ! if line == '': ! break ! if line[:l] == s: ! line = line[l:] ! match = reg.match(line) ! if not match: ! print 'syntax error in ~/' + cdplayerrc ! continue ! name, value = match.group(1, 2) ! if name == 'title': ! self.title = value ! elif name == 'artist': ! self.artist = value ! elif name[:5] == 'track': ! trackno = int(name[6:]) ! self.track[trackno] = value ! f.close() ! def write(self): ! import posix ! filename = posix.environ['HOME'] + '/' + cdplayerrc ! try: ! old = open(filename, 'r') ! except IOError: ! old = open('/dev/null', 'r') ! new = open(filename + '.new', 'w') ! s = self.id + '.' ! l = len(s) ! while 1: ! line = old.readline() ! if line == '': ! break ! if line[:l] != s: ! new.write(line) ! new.write(self.id + '.title:\t' + self.title + '\n') ! new.write(self.id + '.artist:\t' + self.artist + '\n') ! for i in range(1, len(self.track)): ! new.write('%s.track.%r:\t%s\n' % (i, track)) ! old.close() ! new.close() ! posix.rename(filename + '.new', filename) --- 18,88 ---- class Cdplayer: ! def __init__(self, tracklist): ! import string ! self.artist = '' ! self.title = '' ! if type(tracklist) == type(''): ! t = [] ! for i in range(2, len(tracklist), 4): ! t.append((None, \ ! (int(tracklist[i:i+2]), \ ! int(tracklist[i+2:i+4])))) ! tracklist = t ! self.track = [None] + [''] * len(tracklist) ! self.id = 'd' + string.zfill(len(tracklist), 2) ! for track in tracklist: ! start, length = track ! self.id = self.id + string.zfill(length[0], 2) + \ ! string.zfill(length[1], 2) ! try: ! import posix ! f = open(posix.environ['HOME'] + '/' + cdplayerrc, 'r') ! except IOError: ! return ! import re ! reg = re.compile(r'^([^:]*):\t(.*)') ! s = self.id + '.' ! l = len(s) ! while 1: ! line = f.readline() ! if line == '': ! break ! if line[:l] == s: ! line = line[l:] ! match = reg.match(line) ! if not match: ! print 'syntax error in ~/' + cdplayerrc ! continue ! name, value = match.group(1, 2) ! if name == 'title': ! self.title = value ! elif name == 'artist': ! self.artist = value ! elif name[:5] == 'track': ! trackno = int(name[6:]) ! self.track[trackno] = value ! f.close() ! def write(self): ! import posix ! filename = posix.environ['HOME'] + '/' + cdplayerrc ! try: ! old = open(filename, 'r') ! except IOError: ! old = open('/dev/null', 'r') ! new = open(filename + '.new', 'w') ! s = self.id + '.' ! l = len(s) ! while 1: ! line = old.readline() ! if line == '': ! break ! if line[:l] != s: ! new.write(line) ! new.write(self.id + '.title:\t' + self.title + '\n') ! new.write(self.id + '.artist:\t' + self.artist + '\n') ! for i in range(1, len(self.track)): ! new.write('%s.track.%r:\t%s\n' % (i, track)) ! old.close() ! new.close() ! posix.rename(filename + '.new', filename) Index: flp.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-irix6/flp.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** flp.py 12 Feb 2004 17:35:10 -0000 1.9 --- flp.py 18 Jul 2004 06:14:45 -0000 1.10 *************** *** 80,95 **** def _unpack_cache(altforms): ! forms = {} ! for name in altforms.keys(): ! altobj, altlist = altforms[name] ! obj = _newobj() ! obj.make(altobj) ! list = [] ! for altobj in altlist: ! nobj = _newobj() ! nobj.make(altobj) ! list.append(nobj) ! forms[name] = obj, list ! return forms def rdlong(fp): --- 80,95 ---- def _unpack_cache(altforms): ! forms = {} ! for name in altforms.keys(): ! altobj, altlist = altforms[name] ! obj = _newobj() ! obj.make(altobj) ! list = [] ! for altobj in altlist: ! nobj = _newobj() ! nobj.make(altobj) ! list.append(nobj) ! forms[name] = obj, list ! return forms def rdlong(fp): *************** *** 277,282 **** name, value = match.group(1, 2) if name[0] == 'N': ! name = ''.join(name.split()) ! name = name.lower() name = name.capitalize() try: --- 277,282 ---- name, value = match.group(1, 2) if name[0] == 'N': ! name = ''.join(name.split()) ! name = name.lower() name = name.capitalize() try: *************** *** 292,296 **** raise EOFError return line[:-1] ! def _parse_1_line(file): line = _readline(file) --- 292,296 ---- raise EOFError return line[:-1] ! def _parse_1_line(file): line = _readline(file) Index: jpeg.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-irix6/jpeg.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** jpeg.py 12 Dec 2000 23:11:42 -0000 1.4 --- jpeg.py 18 Jul 2004 06:14:45 -0000 1.5 *************** *** 7,11 **** class error(Exception): ! pass options = {'quality': 75, 'optimize': 0, 'smooth': 0, 'forcegray': 0} --- 7,11 ---- class error(Exception): ! pass options = {'quality': 75, 'optimize': 0, 'smooth': 0, 'forcegray': 0} *************** *** 15,111 **** def compress(imgdata, width, height, bytesperpixel): ! global comp ! import cl ! if comp is None: comp = cl.OpenCompressor(cl.JPEG) ! if bytesperpixel == 1: ! format = cl.GRAYSCALE ! elif bytesperpixel == 4: ! format = cl.RGBX ! if options['forcegray']: ! iformat = cl.GRAYSCALE ! else: ! iformat = cl.YUV ! # XXX How to support 'optimize'? ! params = [cl.IMAGE_WIDTH, width, cl.IMAGE_HEIGHT, height, ! cl.ORIGINAL_FORMAT, format, ! cl.ORIENTATION, cl.BOTTOM_UP, ! cl.QUALITY_FACTOR, options['quality'], ! cl.INTERNAL_FORMAT, iformat, ! ] ! comp.SetParams(params) ! jpegdata = comp.Compress(1, imgdata) ! return jpegdata def decompress(jpegdata): ! global decomp ! import cl ! if decomp is None: decomp = cl.OpenDecompressor(cl.JPEG) ! headersize = decomp.ReadHeader(jpegdata) ! params = [cl.IMAGE_WIDTH, 0, cl.IMAGE_HEIGHT, 0, cl.INTERNAL_FORMAT, 0] ! decomp.GetParams(params) ! width, height, format = params[1], params[3], params[5] ! if format == cl.GRAYSCALE or options['forcegray']: ! format = cl.GRAYSCALE ! bytesperpixel = 1 ! else: ! format = cl.RGBX ! bytesperpixel = 4 ! # XXX How to support 'smooth'? ! params = [cl.ORIGINAL_FORMAT, format, ! cl.ORIENTATION, cl.BOTTOM_UP, ! cl.FRAME_BUFFER_SIZE, width*height*bytesperpixel] ! decomp.SetParams(params) ! imgdata = decomp.Decompress(1, jpegdata) ! return imgdata, width, height, bytesperpixel def setoption(name, value): ! if type(value) is not type(0): ! raise TypeError, 'jpeg.setoption: numeric options only' ! if name == 'forcegrey': ! name = 'forcegray' ! if not options.has_key(name): ! raise KeyError, 'jpeg.setoption: unknown option name' ! options[name] = int(value) def test(): ! import sys ! if sys.argv[1:2] == ['-g']: ! del sys.argv[1] ! setoption('forcegray', 1) ! if not sys.argv[1:]: ! sys.argv.append('/usr/local/images/data/jpg/asterix.jpg') ! for file in sys.argv[1:]: ! show(file) def show(file): ! import gl, GL, DEVICE ! jpegdata = open(file, 'r').read() ! imgdata, width, height, bytesperpixel = decompress(jpegdata) ! gl.foreground() ! gl.prefsize(width, height) ! win = gl.winopen(file) ! if bytesperpixel == 1: ! gl.cmode() ! gl.pixmode(GL.PM_SIZE, 8) ! gl.gconfig() ! for i in range(256): ! gl.mapcolor(i, i, i, i) ! else: ! gl.RGBmode() ! gl.pixmode(GL.PM_SIZE, 32) ! gl.gconfig() ! gl.qdevice(DEVICE.REDRAW) ! gl.qdevice(DEVICE.ESCKEY) ! gl.qdevice(DEVICE.WINQUIT) ! gl.qdevice(DEVICE.WINSHUT) ! gl.lrectwrite(0, 0, width-1, height-1, imgdata) ! while 1: ! dev, val = gl.qread() ! if dev in (DEVICE.ESCKEY, DEVICE.WINSHUT, DEVICE.WINQUIT): ! break ! if dev == DEVICE.REDRAW: ! gl.lrectwrite(0, 0, width-1, height-1, imgdata) ! gl.winclose(win) ! # Now test the compression and write the result to a fixed filename ! newjpegdata = compress(imgdata, width, height, bytesperpixel) ! open('/tmp/j.jpg', 'w').write(newjpegdata) --- 15,111 ---- def compress(imgdata, width, height, bytesperpixel): ! global comp ! import cl ! if comp is None: comp = cl.OpenCompressor(cl.JPEG) ! if bytesperpixel == 1: ! format = cl.GRAYSCALE ! elif bytesperpixel == 4: ! format = cl.RGBX ! if options['forcegray']: ! iformat = cl.GRAYSCALE ! else: ! iformat = cl.YUV ! # XXX How to support 'optimize'? ! params = [cl.IMAGE_WIDTH, width, cl.IMAGE_HEIGHT, height, ! cl.ORIGINAL_FORMAT, format, ! cl.ORIENTATION, cl.BOTTOM_UP, ! cl.QUALITY_FACTOR, options['quality'], ! cl.INTERNAL_FORMAT, iformat, ! ] ! comp.SetParams(params) ! jpegdata = comp.Compress(1, imgdata) ! return jpegdata def decompress(jpegdata): ! global decomp ! import cl ! if decomp is None: decomp = cl.OpenDecompressor(cl.JPEG) ! headersize = decomp.ReadHeader(jpegdata) ! params = [cl.IMAGE_WIDTH, 0, cl.IMAGE_HEIGHT, 0, cl.INTERNAL_FORMAT, 0] ! decomp.GetParams(params) ! width, height, format = params[1], params[3], params[5] ! if format == cl.GRAYSCALE or options['forcegray']: ! format = cl.GRAYSCALE ! bytesperpixel = 1 ! else: ! format = cl.RGBX ! bytesperpixel = 4 ! # XXX How to support 'smooth'? ! params = [cl.ORIGINAL_FORMAT, format, ! cl.ORIENTATION, cl.BOTTOM_UP, ! cl.FRAME_BUFFER_SIZE, width*height*bytesperpixel] ! decomp.SetParams(params) ! imgdata = decomp.Decompress(1, jpegdata) ! return imgdata, width, height, bytesperpixel def setoption(name, value): ! if type(value) is not type(0): ! raise TypeError, 'jpeg.setoption: numeric options only' ! if name == 'forcegrey': ! name = 'forcegray' ! if not options.has_key(name): ! raise KeyError, 'jpeg.setoption: unknown option name' ! options[name] = int(value) def test(): ! import sys ! if sys.argv[1:2] == ['-g']: ! del sys.argv[1] ! setoption('forcegray', 1) ! if not sys.argv[1:]: ! sys.argv.append('/usr/local/images/data/jpg/asterix.jpg') ! for file in sys.argv[1:]: ! show(file) def show(file): ! import gl, GL, DEVICE ! jpegdata = open(file, 'r').read() ! imgdata, width, height, bytesperpixel = decompress(jpegdata) ! gl.foreground() ! gl.prefsize(width, height) ! win = gl.winopen(file) ! if bytesperpixel == 1: ! gl.cmode() ! gl.pixmode(GL.PM_SIZE, 8) ! gl.gconfig() ! for i in range(256): ! gl.mapcolor(i, i, i, i) ! else: ! gl.RGBmode() ! gl.pixmode(GL.PM_SIZE, 32) ! gl.gconfig() ! gl.qdevice(DEVICE.REDRAW) ! gl.qdevice(DEVICE.ESCKEY) ! gl.qdevice(DEVICE.WINQUIT) ! gl.qdevice(DEVICE.WINSHUT) ! gl.lrectwrite(0, 0, width-1, height-1, imgdata) ! while 1: ! dev, val = gl.qread() ! if dev in (DEVICE.ESCKEY, DEVICE.WINSHUT, DEVICE.WINQUIT): ! break ! if dev == DEVICE.REDRAW: ! gl.lrectwrite(0, 0, width-1, height-1, imgdata) ! gl.winclose(win) ! # Now test the compression and write the result to a fixed filename ! newjpegdata = compress(imgdata, width, height, bytesperpixel) ! open('/tmp/j.jpg', 'w').write(newjpegdata) Index: panel.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-irix6/panel.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** panel.py 12 Feb 2004 17:35:10 -0000 1.4 --- panel.py 18 Jul 2004 06:14:45 -0000 1.5 *************** *** 18,22 **** # def is_list(x): ! return type(x) == type([]) --- 18,22 ---- # def is_list(x): ! return type(x) == type([]) *************** *** 24,31 **** # def reverse(list): ! res = [] ! for item in list: ! res.insert(0, item) ! return res --- 24,31 ---- # def reverse(list): ! res = [] ! for item in list: ! res.insert(0, item) ! return res *************** *** 34,41 **** # def getattrlist(list, name): ! for item in list: ! if item and is_list(item) and item[0] == name: ! return item[1:] ! return [] --- 34,41 ---- # def getattrlist(list, name): ! for item in list: ! if item and is_list(item) and item[0] == name: ! return item[1:] ! return [] *************** *** 43,51 **** # def getproplist(list, name): ! for item in list: ! if item and is_list(item) and item[0] == 'prop': ! if len(item) > 1 and item[1] == name: ! return item[2:] ! return [] --- 43,51 ---- # def getproplist(list, name): ! for item in list: ! if item and is_list(item) and item[0] == 'prop': ! if len(item) > 1 and item[1] == name: ! return item[2:] ! return [] *************** *** 53,58 **** # def is_endgroup(list): ! x = getproplist(list, 'end-of-group') ! return (x and x[0] == '#t') --- 53,58 ---- # def is_endgroup(list): ! x = getproplist(list, 'end-of-group') ! return (x and x[0] == '#t') *************** *** 61,78 **** # def show_actuator(prefix, a): ! for item in a: ! if not is_list(item): ! print prefix, item ! elif item and item[0] == 'al': ! print prefix, 'Subactuator list:' ! for a in item[1:]: ! show_actuator(prefix + ' ', a) ! elif len(item) == 2: ! print prefix, item[0], '=>', item[1] ! elif len(item) == 3 and item[0] == 'prop': ! print prefix, 'Prop', item[1], '=>', ! print item[2] ! else: ! print prefix, '?', item --- 61,78 ---- # def show_actuator(prefix, a): ! for item in a: ! if not is_list(item): ! print prefix, item ! elif item and item[0] == 'al': ! print prefix, 'Subactuator list:' ! for a in item[1:]: ! show_actuator(prefix + ' ', a) ! elif len(item) == 2: ! print prefix, item[0], '=>', item[1] ! elif len(item) == 3 and item[0] == 'prop': ! print prefix, 'Prop', item[1], '=>', ! print item[2] ! else: ! print prefix, '?', item *************** *** 80,97 **** # def show_panel(prefix, p): ! for item in p: ! if not is_list(item): ! print prefix, item ! elif item and item[0] == 'al': ! print prefix, 'Actuator list:' ! for a in item[1:]: ! show_actuator(prefix + ' ', a) ! elif len(item) == 2: ! print prefix, item[0], '=>', item[1] ! elif len(item) == 3 and item[0] == 'prop': ! print prefix, 'Prop', item[1], '=>', ! print item[2] ! else: ! print prefix, '?', item --- 80,97 ---- # def show_panel(prefix, p): ! for item in p: ! if not is_list(item): ! print prefix, item ! elif item and item[0] == 'al': ! print prefix, 'Actuator list:' ! for a in item[1:]: ! show_actuator(prefix + ' ', a) ! elif len(item) == 2: ! print prefix, item[0], '=>', item[1] ! elif len(item) == 3 and item[0] == 'prop': ! print prefix, 'Prop', item[1], '=>', ! print item[2] ! else: ! print prefix, '?', item *************** *** 104,108 **** # def dummy_callback(arg): ! pass --- 104,108 ---- # def dummy_callback(arg): ! pass *************** *** 112,139 **** # def assign_members(target, attrlist, exclist, prefix): ! for item in attrlist: ! if is_list(item) and len(item) == 2 and item[0] not in exclist: ! name, value = item[0], item[1] ! ok = 1 ! if value[0] in '-0123456789': ! value = eval(value) ! elif value[0] == '"': ! value = value[1:-1] ! elif value == 'move-then-resize': ! # Strange default set by Panel Editor... ! ok = 0 ! else: ! print 'unknown value', value, 'for', name ! ok = 0 ! if ok: ! lhs = 'target.' + prefix + name ! stmt = lhs + '=' + repr(value) ! if debug: print 'exec', stmt ! try: ! exec stmt + '\n' ! except KeyboardInterrupt: # Don't catch this! ! raise KeyboardInterrupt ! except: ! print 'assign failed:', stmt --- 112,139 ---- # def assign_members(target, attrlist, exclist, prefix): ! for item in attrlist: ! if is_list(item) and len(item) == 2 and item[0] not in exclist: ! name, value = item[0], item[1] ! ok = 1 ! if value[0] in '-0123456789': ! value = eval(value) ! elif value[0] == '"': ! value = value[1:-1] ! elif value == 'move-then-resize': ! # Strange default set by Panel Editor... ! ok = 0 ! else: ! print 'unknown value', value, 'for', name ! ok = 0 ! if ok: ! lhs = 'target.' + prefix + name ! stmt = lhs + '=' + repr(value) ! if debug: print 'exec', stmt ! try: ! exec stmt + '\n' ! except KeyboardInterrupt: # Don't catch this! ! raise KeyboardInterrupt ! except: ! print 'assign failed:', stmt *************** *** 142,169 **** # def build_actuator(descr): ! namelist = getattrlist(descr, 'name') ! if namelist: ! # Assume it is a string ! actuatorname = namelist[0][1:-1] ! else: ! actuatorname = '' ! type = descr[0] ! if type[:4] == 'pnl_': type = type[4:] ! act = pnl.mkact(type) ! act.downfunc = act.activefunc = act.upfunc = dummy_callback ! # ! assign_members(act, descr[1:], ['al', 'data', 'name'], '') ! # ! # Treat actuator-specific data ! # ! datalist = getattrlist(descr, 'data') ! prefix = '' ! if type[-4:] == 'puck': ! prefix = 'puck_' ! elif type == 'mouse': ! prefix = 'mouse_' ! assign_members(act, datalist, [], prefix) ! # ! return act, actuatorname --- 142,169 ---- # def build_actuator(descr): ! namelist = getattrlist(descr, 'name') ! if namelist: ! # Assume it is a string ! actuatorname = namelist[0][1:-1] ! else: ! actuatorname = '' ! type = descr[0] ! if type[:4] == 'pnl_': type = type[4:] ! act = pnl.mkact(type) ! act.downfunc = act.activefunc = act.upfunc = dummy_callback ! # ! assign_members(act, descr[1:], ['al', 'data', 'name'], '') ! # ! # Treat actuator-specific data ! # ! datalist = getattrlist(descr, 'data') ! prefix = '' ! if type[-4:] == 'puck': ! prefix = 'puck_' ! elif type == 'mouse': ! prefix = 'mouse_' ! assign_members(act, datalist, [], prefix) ! # ! return act, actuatorname *************** *** 177,201 **** # def build_subactuators(panel, super_act, al): ! # ! # This is nearly the same loop as below in build_panel(), ! # except a call is made to addsubact() instead of addact(). ! # ! for a in al: ! act, name = build_actuator(a) ! act.addsubact(super_act) ! if name: ! stmt = 'panel.' + name + ' = act' ! if debug: print 'exec', stmt ! exec stmt + '\n' ! if is_endgroup(a): ! panel.endgroup() ! sub_al = getattrlist(a, 'al') ! if sub_al: ! build_subactuators(panel, act, sub_al) ! # ! # Fix the actuator to which whe just added subactuators. ! # This can't hurt (I hope) and is needed for the scroll actuator. ! # ! super_act.fixact() --- 177,201 ---- # def build_subactuators(panel, super_act, al): ! # ! # This is nearly the same loop as below in build_panel(), ! # except a call is made to addsubact() instead of addact(). ! # ! for a in al: ! act, name = build_actuator(a) ! act.addsubact(super_act) ! if name: ! stmt = 'panel.' + name + ' = act' ! if debug: print 'exec', stmt ! exec stmt + '\n' ! if is_endgroup(a): ! panel.endgroup() ! sub_al = getattrlist(a, 'al') ! if sub_al: ! build_subactuators(panel, act, sub_al) ! # ! # Fix the actuator to which whe just added subactuators. ! # This can't hurt (I hope) and is needed for the scroll actuator. ! # ! super_act.fixact() *************** *** 205,248 **** # def build_panel(descr): ! # ! # Sanity check ! # ! if (not descr) or descr[0] != 'panel': ! raise panel_error, 'panel description must start with "panel"' ! # ! if debug: show_panel('', descr) ! # ! # Create an empty panel ! # ! panel = pnl.mkpanel() ! # ! # Assign panel attributes ! # ! assign_members(panel, descr[1:], ['al'], '') ! # ! # Look for actuator list ! # ! al = getattrlist(descr, 'al') ! # ! # The order in which actuators are created is important ! # because of the endgroup() operator. ! # Unfortunately the Panel Editor outputs the actuator list ! # in reverse order, so we reverse it here. ! # ! al = reverse(al) ! # ! for a in al: ! act, name = build_actuator(a) ! act.addact(panel) ! if name: ! stmt = 'panel.' + name + ' = act' ! exec stmt + '\n' ! if is_endgroup(a): ! panel.endgroup() ! sub_al = getattrlist(a, 'al') ! if sub_al: ! build_subactuators(panel, act, sub_al) ! # ! return panel --- 205,248 ---- # def build_panel(descr): ! # ! # Sanity check ! # ! if (not descr) or descr[0] != 'panel': ! raise panel_error, 'panel description must start with "panel"' ! # ! if debug: show_panel('', descr) ! # ! # Create an empty panel ! # ! panel = pnl.mkpanel() ! # ! # Assign panel attributes ! # ! assign_members(panel, descr[1:], ['al'], '') ! # ! # Look for actuator list ! # ! al = getattrlist(descr, 'al') ! # ! # The order in which actuators are created is important ! # because of the endgroup() operator. ! # Unfortunately the Panel Editor outputs the actuator list ! # in reverse order, so we reverse it here. ! # ! al = reverse(al) ! # ! for a in al: ! act, name = build_actuator(a) ! act.addact(panel) ! if name: ! stmt = 'panel.' + name + ' = act' ! exec stmt + '\n' ! if is_endgroup(a): ! panel.endgroup() ! sub_al = getattrlist(a, 'al') ! if sub_al: ! build_subactuators(panel, act, sub_al) ! # ! return panel *************** *** 250,274 **** # def my_dopanel(): ! # Extract only the first 4 elements to allow for future expansion ! a, down, active, up = pnl.dopanel()[:4] ! if down: ! down.downfunc(down) ! if active: ! active.activefunc(active) ! if up: ! up.upfunc(up) ! return a # Create one or more panels from a description file (S-expressions) # generated by the Panel Editor. ! # def defpanellist(file): ! import panelparser ! descrlist = panelparser.parse_file(open(file, 'r')) ! panellist = [] ! for descr in descrlist: ! panellist.append(build_panel(descr)) ! return panellist --- 250,274 ---- # def my_dopanel(): ! # Extract only the first 4 elements to allow for future expansion ! a, down, active, up = pnl.dopanel()[:4] ! if down: ! down.downfunc(down) ! if active: ! active.activefunc(active) ! if up: ! up.upfunc(up) ! return a # Create one or more panels from a description file (S-expressions) # generated by the Panel Editor. ! # def defpanellist(file): ! import panelparser ! descrlist = panelparser.parse_file(open(file, 'r')) ! panellist = [] ! for descr in descrlist: ! panellist.append(build_panel(descr)) ! return panellist *************** *** 277,281 **** # This gives *no* performance penalty once this module is imported. # ! from pnl import * # for export ! dopanel = my_dopanel # override pnl.dopanel --- 277,281 ---- # This gives *no* performance penalty once this module is imported. # ! from pnl import * # for export ! dopanel = my_dopanel # override pnl.dopanel Index: panelparser.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-irix6/panelparser.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** panelparser.py 12 Dec 2000 23:11:42 -0000 1.2 --- panelparser.py 18 Jul 2004 06:14:45 -0000 1.3 *************** *** 16,48 **** # def tokenize_string(s): ! tokens = [] ! while s: ! c = s[:1] ! if c in whitespace: ! s = s[1:] ! elif c == ';': ! s = '' ! elif c == '"': ! n = len(s) ! i = 1 ! while i < n: ! c = s[i] ! i = i+1 ! if c == '"': break ! if c == '\\': i = i+1 ! tokens.append(s[:i]) ! s = s[i:] ! elif c in operators: ! tokens.append(c) ! s = s[1:] ! else: ! n = len(s) ! i = 1 ! while i < n: ! if s[i] in separators: break ! i = i+1 ! tokens.append(s[:i]) ! s = s[i:] ! return tokens --- 16,48 ---- # def tokenize_string(s): ! tokens = [] ! while s: ! c = s[:1] ! if c in whitespace: ! s = s[1:] ! elif c == ';': ! s = '' ! elif c == '"': ! n = len(s) ! i = 1 ! while i < n: ! c = s[i] ! i = i+1 ! if c == '"': break ! if c == '\\': i = i+1 ! tokens.append(s[:i]) ! s = s[i:] ! elif c in operators: ! tokens.append(c) ! s = s[1:] ! else: ! n = len(s) ! i = 1 ! while i < n: ! if s[i] in separators: break ! i = i+1 ! tokens.append(s[:i]) ! s = s[i:] ! return tokens *************** *** 51,60 **** # def tokenize_file(fp): ! tokens = [] ! while 1: ! line = fp.readline() ! if not line: break ! tokens = tokens + tokenize_string(line) ! return tokens --- 51,60 ---- # def tokenize_file(fp): ! tokens = [] ! while 1: ! line = fp.readline() ! if not line: break ! tokens = tokens + tokenize_string(line) ! return tokens *************** *** 72,90 **** # def parse_expr(tokens): ! if (not tokens) or tokens[0] != '(': ! raise syntax_error, 'expected "("' ! tokens = tokens[1:] ! expr = [] ! while 1: ! if not tokens: ! raise syntax_error, 'missing ")"' ! if tokens[0] == ')': ! return expr, tokens[1:] ! elif tokens[0] == '(': ! subexpr, tokens = parse_expr(tokens) ! expr.append(subexpr) ! else: ! expr.append(tokens[0]) ! tokens = tokens[1:] --- 72,90 ---- # def parse_expr(tokens): ! if (not tokens) or tokens[0] != '(': ! raise syntax_error, 'expected "("' ! tokens = tokens[1:] ! expr = [] ! while 1: ! if not tokens: ! raise syntax_error, 'missing ")"' ! if tokens[0] == ')': ! return expr, tokens[1:] ! elif tokens[0] == '(': ! subexpr, tokens = parse_expr(tokens) ! expr.append(subexpr) ! else: ! expr.append(tokens[0]) ! tokens = tokens[1:] *************** *** 93,102 **** # def parse_file(fp): ! tokens = tokenize_file(fp) ! exprlist = [] ! while tokens: ! expr, tokens = parse_expr(tokens) ! exprlist.append(expr) ! return exprlist --- 93,102 ---- # def parse_file(fp): ! tokens = tokenize_file(fp) ! exprlist = [] ! while tokens: ! expr, tokens = parse_expr(tokens) ! exprlist.append(expr) ! return exprlist *************** *** 104,119 **** # # The input ! # '(hip (hop hur-ray))' # # passed to tokenize_string() returns the token list ! # ['(', 'hip', '(', 'hop', 'hur-ray', ')', ')'] # # When this is passed to parse_expr() it returns the expression ! # ['hip', ['hop', 'hur-ray']] # plus an empty token list (because there are no tokens left. # # When a file containing the example is passed to parse_file() it returns # a list whose only element is the output of parse_expr() above: ! # [['hip', ['hop', 'hur-ray']]] --- 104,119 ---- # # The input ! # '(hip (hop hur-ray))' # # passed to tokenize_string() returns the token list ! # ['(', 'hip', '(', 'hop', 'hur-ray', ')', ')'] # # When this is passed to parse_expr() it returns the expression ! # ['hip', ['hop', 'hur-ray']] # plus an empty token list (because there are no tokens left. # # When a file containing the example is passed to parse_file() it returns # a list whose only element is the output of parse_expr() above: ! # [['hip', ['hop', 'hur-ray']]] *************** *** 124,128 **** # Tokens are separated by whitespace, except the following characters # always form a separate token (outside strings): ! # ( ) ' # Strings are enclosed in double quotes (") and backslash (\) is used # as escape character in strings. --- 124,128 ---- # Tokens are separated by whitespace, except the following characters # always form a separate token (outside strings): ! # ( ) ' # Strings are enclosed in double quotes (") and backslash (\) is used # as escape character in strings. Index: readcd.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-irix6/readcd.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** readcd.py 12 Feb 2004 17:35:10 -0000 1.4 --- readcd.py 18 Jul 2004 06:14:45 -0000 1.5 *************** *** 4,244 **** class Error(Exception): ! pass class _Stop(Exception): ! pass def _doatime(self, cb_type, data): ! if ((data[0] * 60) + data[1]) * 75 + data[2] > self.end: ! ## print 'done with list entry', repr(self.listindex) ! raise _Stop ! func, arg = self.callbacks[cb_type] ! if func: ! func(arg, cb_type, data) def _dopnum(self, cb_type, data): ! if data > self.end: ! ## print 'done with list entry', repr(self.listindex) ! raise _Stop ! func, arg = self.callbacks[cb_type] ! if func: ! func(arg, cb_type, data) class Readcd: ! def __init__(self, *arg): ! if len(arg) == 0: ! self.player = cd.open() ! elif len(arg) == 1: ! self.player = cd.open(arg[0]) ! elif len(arg) == 2: ! self.player = cd.open(arg[0], arg[1]) ! else: ! raise Error, 'bad __init__ call' ! self.list = [] ! self.callbacks = [(None, None)] * 8 ! self.parser = cd.createparser() ! self.playing = 0 ! self.end = 0 ! self.status = None ! self.trackinfo = None ! def eject(self): ! self.player.eject() ! self.list = [] ! self.end = 0 ! self.listindex = 0 ! self.status = None ! self.trackinfo = None ! if self.playing: ! ## print 'stop playing from eject' ! raise _Stop ! def pmsf2msf(self, track, min, sec, frame): ! if not self.status: ! self.cachestatus() ! if track < self.status[5] or track > self.status[6]: ! raise Error, 'track number out of range' ! if not self.trackinfo: ! self.cacheinfo() ! start, total = self.trackinfo[track] ! start = ((start[0] * 60) + start[1]) * 75 + start[2] ! total = ((total[0] * 60) + total[1]) * 75 + total[2] ! block = ((min * 60) + sec) * 75 + frame ! if block > total: ! raise Error, 'out of range' ! block = start + block ! min, block = divmod(block, 75*60) ! sec, frame = divmod(block, 75) ! return min, sec, frame ! def reset(self): ! self.list = [] ! def appendtrack(self, track): ! self.appendstretch(track, track) ! ! def appendstretch(self, start, end): ! if not self.status: ! self.cachestatus() ! if not start: ! start = 1 ! if not end: ! end = self.status[6] ! if type(end) == type(0): ! if end < self.status[5] or end > self.status[6]: ! raise Error, 'range error' ! else: ! l = len(end) ! if l == 4: ! prog, min, sec, frame = end ! if prog < self.status[5] or prog > self.status[6]: ! raise Error, 'range error' ! end = self.pmsf2msf(prog, min, sec, frame) ! elif l != 3: ! raise Error, 'syntax error' ! if type(start) == type(0): ! if start < self.status[5] or start > self.status[6]: ! raise Error, 'range error' ! if len(self.list) > 0: ! s, e = self.list[-1] ! if type(e) == type(0): ! if start == e+1: ! start = s ! del self.list[-1] ! else: ! l = len(start) ! if l == 4: ! prog, min, sec, frame = start ! if prog < self.status[5] or prog > self.status[6]: ! raise Error, 'range error' ! start = self.pmsf2msf(prog, min, sec, frame) ! elif l != 3: ! raise Error, 'syntax error' ! self.list.append((start, end)) ! def settracks(self, list): ! self.list = [] ! for track in list: ! self.appendtrack(track) ! def setcallback(self, cb_type, func, arg): ! if cb_type < 0 or cb_type >= 8: ! raise Error, 'type out of range' ! self.callbacks[cb_type] = (func, arg) ! if self.playing: ! start, end = self.list[self.listindex] ! if type(end) == type(0): ! if cb_type != CD.PNUM: ! self.parser.setcallback(cb_type, func, arg) ! else: ! if cb_type != CD.ATIME: ! self.parser.setcallback(cb_type, func, arg) ! def removecallback(self, cb_type): ! if cb_type < 0 or cb_type >= 8: ! raise Error, 'type out of range' ! self.callbacks[cb_type] = (None, None) ! if self.playing: ! start, end = self.list[self.listindex] ! if type(end) == type(0): ! if cb_type != CD.PNUM: ! self.parser.removecallback(cb_type) ! else: ! if cb_type != CD.ATIME: ! self.parser.removecallback(cb_type) ! def gettrackinfo(self, *arg): ! if not self.status: ! self.cachestatus() ! if not self.trackinfo: ! self.cacheinfo() ! if len(arg) == 0: ! return self.trackinfo[self.status[5]:self.status[6]+1] ! result = [] ! for i in arg: ! if i < self.status[5] or i > self.status[6]: ! raise Error, 'range error' ! result.append(self.trackinfo[i]) ! return result ! def cacheinfo(self): ! if not self.status: ! self.cachestatus() ! self.trackinfo = [] ! for i in range(self.status[5]): ! self.trackinfo.append(None) ! for i in range(self.status[5], self.status[6]+1): ! self.trackinfo.append(self.player.gettrackinfo(i)) ! def cachestatus(self): ! self.status = self.player.getstatus() ! if self.status[0] == CD.NODISC: ! self.status = None ! raise Error, 'no disc in player' ! def getstatus(self): ! return self.player.getstatus() ! def play(self): ! if not self.status: ! self.cachestatus() ! size = self.player.bestreadsize() ! self.listindex = 0 ! self.playing = 0 ! for i in range(8): ! func, arg = self.callbacks[i] ! if func: ! self.parser.setcallback(i, func, arg) ! else: ! self.parser.removecallback(i) ! if len(self.list) == 0: ! for i in range(self.status[5], self.status[6]+1): ! self.appendtrack(i) ! try: ! while 1: ! if not self.playing: ! if self.listindex >= len(self.list): ! return ! start, end = self.list[self.listindex] ! if type(start) == type(0): ! dummy = self.player.seektrack( ! start) ! else: ! min, sec, frame = start ! dummy = self.player.seek( ! min, sec, frame) ! if type(end) == type(0): ! self.parser.setcallback( ! CD.PNUM, _dopnum, self) ! self.end = end ! func, arg = \ ! self.callbacks[CD.ATIME] ! if func: ! self.parser.setcallback(CD.ATIME, func, arg) ! else: ! self.parser.removecallback(CD.ATIME) ! else: ! min, sec, frame = end ! self.parser.setcallback( ! CD.ATIME, _doatime, ! self) ! self.end = (min * 60 + sec) * \ ! 75 + frame ! func, arg = \ ! self.callbacks[CD.PNUM] ! if func: ! self.parser.setcallback(CD.PNUM, func, arg) ! else: ! self.parser.removecallback(CD.PNUM) ! self.playing = 1 ! data = self.player.readda(size) ! if data == '': ! self.playing = 0 ! self.listindex = self.listindex + 1 ! continue ! try: ! self.parser.parseframe(data) ! except _Stop: ! self.playing = 0 ! self.listindex = self.listindex + 1 ! finally: ! self.playing = 0 --- 4,244 ---- class Error(Exception): ! pass class _Stop(Exception): ! pass def _doatime(self, cb_type, data): ! if ((data[0] * 60) + data[1]) * 75 + data[2] > self.end: ! ## print 'done with list entry', repr(self.listindex) ! raise _Stop ! func, arg = self.callbacks[cb_type] ! if func: ! func(arg, cb_type, data) def _dopnum(self, cb_type, data): ! if data > self.end: ! ## print 'done with list entry', repr(self.listindex) ! raise _Stop ! func, arg = self.callbacks[cb_type] ! if func: ! func(arg, cb_type, data) class Readcd: ! def __init__(self, *arg): ! if len(arg) == 0: ! self.player = cd.open() ! elif len(arg) == 1: ! self.player = cd.open(arg[0]) ! elif len(arg) == 2: ! self.player = cd.open(arg[0], arg[1]) ! else: ! raise Error, 'bad __init__ call' ! self.list = [] ! self.callbacks = [(None, None)] * 8 ! self.parser = cd.createparser() ! self.playing = 0 ! self.end = 0 ! self.status = None ! self.trackinfo = None ! def eject(self): ! self.player.eject() ! self.list = [] ! self.end = 0 ! self.listindex = 0 ! self.status = None ! self.trackinfo = None ! if self.playing: ! ## print 'stop playing from eject' ! raise _Stop ! def pmsf2msf(self, track, min, sec, frame): ! if not self.status: ! self.cachestatus() ! if track < self.status[5] or track > self.status[6]: ! raise Error, 'track number out of range' ! if not self.trackinfo: ! self.cacheinfo() ! start, total = self.trackinfo[track] ! start = ((start[0] * 60) + start[1]) * 75 + start[2] ! total = ((total[0] * 60) + total[1]) * 75 + total[2] ! block = ((min * 60) + sec) * 75 + frame ! if block > total: ! raise Error, 'out of range' ! block = start + block ! min, block = divmod(block, 75*60) ! sec, frame = divmod(block, 75) ! return min, sec, frame ! def reset(self): ! self.list = [] ! def appendtrack(self, track): ! self.appendstretch(track, track) ! def appendstretch(self, start, end): ! if not self.status: ! self.cachestatus() ! if not start: ! start = 1 ! if not end: ! end = self.status[6] ! if type(end) == type(0): ! if end < self.status[5] or end > self.status[6]: ! raise Error, 'range error' ! else: ! l = len(end) ! if l == 4: ! prog, min, sec, frame = end ! if prog < self.status[5] or prog > self.status[6]: ! raise Error, 'range error' ! end = self.pmsf2msf(prog, min, sec, frame) ! elif l != 3: ! raise Error, 'syntax error' ! if type(start) == type(0): ! if start < self.status[5] or start > self.status[6]: ! raise Error, 'range error' ! if len(self.list) > 0: ! s, e = self.list[-1] ! if type(e) == type(0): ! if start == e+1: ! start = s ! del self.list[-1] ! else: ! l = len(start) ! if l == 4: ! prog, min, sec, frame = start ! if prog < self.status[5] or prog > self.status[6]: ! raise Error, 'range error' ! start = self.pmsf2msf(prog, min, sec, frame) ! elif l != 3: ! raise Error, 'syntax error' ! self.list.append((start, end)) ! def settracks(self, list): ! self.list = [] ! for track in list: ! self.appendtrack(track) ! def setcallback(self, cb_type, func, arg): ! if cb_type < 0 or cb_type >= 8: ! raise Error, 'type out of range' ! self.callbacks[cb_type] = (func, arg) ! if self.playing: ! start, end = self.list[self.listindex] ! if type(end) == type(0): ! if cb_type != CD.PNUM: ! self.parser.setcallback(cb_type, func, arg) ! else: ! if cb_type != CD.ATIME: ! self.parser.setcallback(cb_type, func, arg) ! def removecallback(self, cb_type): ! if cb_type < 0 or cb_type >= 8: ! raise Error, 'type out of range' ! self.callbacks[cb_type] = (None, None) ! if self.playing: ! start, end = self.list[self.listindex] ! if type(end) == type(0): ! if cb_type != CD.PNUM: ! self.parser.removecallback(cb_type) ! else: ! if cb_type != CD.ATIME: ! self.parser.removecallback(cb_type) ! def gettrackinfo(self, *arg): ! if not self.status: ! self.cachestatus() ! if not self.trackinfo: ! self.cacheinfo() ! if len(arg) == 0: ! return self.trackinfo[self.status[5]:self.status[6]+1] ! result = [] ! for i in arg: ! if i < self.status[5] or i > self.status[6]: ! raise Error, 'range error' ! result.append(self.trackinfo[i]) ! return result ! def cacheinfo(self): ! if not self.status: ! self.cachestatus() ! self.trackinfo = [] ! for i in range(self.status[5]): ! self.trackinfo.append(None) ! for i in range(self.status[5], self.status[6]+1): ! self.trackinfo.append(self.player.gettrackinfo(i)) ! def cachestatus(self): ! self.status = self.player.getstatus() ! if self.status[0] == CD.NODISC: ! self.status = None ! raise Error, 'no disc in player' ! def getstatus(self): ! return self.player.getstatus() ! ! def play(self): ! if not self.status: ! self.cachestatus() ! size = self.player.bestreadsize() ! self.listindex = 0 ! self.playing = 0 ! for i in range(8): ! func, arg = self.callbacks[i] ! if func: ! self.parser.setcallback(i, func, arg) ! else: ! self.parser.removecallback(i) ! if len(self.list) == 0: ! for i in range(self.status[5], self.status[6]+1): ! self.appendtrack(i) ! try: ! while 1: ! if not self.playing: ! if self.listindex >= len(self.list): ! return ! start, end = self.list[self.listindex] ! if type(start) == type(0): ! dummy = self.player.seektrack( ! start) ! else: ! min, sec, frame = start ! dummy = self.player.seek( ! min, sec, frame) ! if type(end) == type(0): ! self.parser.setcallback( ! CD.PNUM, _dopnum, self) ! self.end = end ! func, arg = \ ! self.callbacks[CD.ATIME] ! if func: ! self.parser.setcallback(CD.ATIME, func, arg) ! else: ! self.parser.removecallback(CD.ATIME) ! else: ! min, sec, frame = end ! self.parser.setcallback( ! CD.ATIME, _doatime, ! self) ! self.end = (min * 60 + sec) * \ ! 75 + frame ! func, arg = \ ! self.callbacks[CD.PNUM] ! if func: ! self.parser.setcallback(CD.PNUM, func, arg) ! else: ! self.parser.removecallback(CD.PNUM) ! self.playing = 1 ! data = self.player.readda(size) ! if data == '': ! self.playing = 0 ! self.listindex = self.listindex + 1 ! continue ! try: ! self.parser.parseframe(data) ! except _Stop: ! self.playing = 0 ! self.listindex = self.listindex + 1 ! finally: ! self.playing = 0 Index: torgb.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-irix6/torgb.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** torgb.py 12 Feb 2004 17:35:10 -0000 1.6 --- torgb.py 18 Jul 2004 06:14:45 -0000 1.7 *************** *** 52,99 **** class error(Exception): ! pass def torgb(filename): ! temps = [] ! ret = None ! try: ! ret = _torgb(filename, temps) ! finally: ! for temp in temps[:]: ! if temp != ret: ! try: ! os.unlink(temp) ! except os.error: ! pass ! temps.remove(temp) ! return ret def _torgb(filename, temps): ! if filename[-2:] == '.Z': ! (fd, fname) = tempfile.mkstemp() ! os.close(fd) ! temps.append(fname) ! sts = uncompress.copy(filename, fname) ! if sts: ! raise error, filename + ': uncompress failed' ! else: ! fname = filename ! try: ! ftype = imghdr.what(fname) ! except IOError, msg: ! if type(msg) == type(()) and len(msg) == 2 and \ ! type(msg[0]) == type(0) and type(msg[1]) == type(''): ! msg = msg[1] ! if type(msg) is not type(''): ! msg = repr(msg) ! raise error, filename + ': ' + msg ! if ftype == 'rgb': ! return fname ! if ftype is None or not table.has_key(ftype): ! raise error, '%s: unsupported image file type %r' % (filename, ftype) ! (fd, temp) = tempfile.mkstemp() ! os.close(fd) ! sts = table[ftype].copy(fname, temp) ! if sts: ! raise error, filename + ': conversion to rgb failed' ! return temp --- 52,99 ---- class error(Exception): ! pass def torgb(filename): ! temps = [] ! ret = None ! try: ! ret = _torgb(filename, temps) ! finally: ! for temp in temps[:]: ! if temp != ret: ! try: ! os.unlink(temp) ! except os.error: ! pass ! temps.remove(temp) ! return ret def _torgb(filename, temps): ! if filename[-2:] == '.Z': ! (fd, fname) = tempfile.mkstemp() ! os.close(fd) ! temps.append(fname) ! sts = uncompress.copy(filename, fname) ! if sts: ! raise error, filename + ': uncompress failed' ! else: ! fname = filename ! try: ! ftype = imghdr.what(fname) ! except IOError, msg: ! if type(msg) == type(()) and len(msg) == 2 and \ ! type(msg[0]) == type(0) and type(msg[1]) == type(''): ! msg = msg[1] ! if type(msg) is not type(''): ! msg = repr(msg) ! raise error, filename + ': ' + msg ! if ftype == 'rgb': ! return fname ! if ftype is None or not table.has_key(ftype): ! raise error, '%s: unsupported image file type %r' % (filename, ftype) ! (fd, temp) = tempfile.mkstemp() ! os.close(fd) ! sts = table[ftype].copy(fname, temp) ! if sts: ! raise error, filename + ': conversion to rgb failed' ! return temp From tim_one at users.sourceforge.net Sun Jul 18 08:15:20 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 08:15:45 2004 Subject: [Python-checkins] python/dist/src/Lib/plat-mac/lib-scriptpackages/Netscape Mozilla_suite.py, 1.7, 1.8 PowerPlant.py, 1.6, 1.7 Required_suite.py, 1.5, 1.6 Standard_URL_suite.py, 1.5, 1.6 Text.py, 1.8, 1.9 WorldWideWeb_suite.py, 1.6, 1.7 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/plat-mac/lib-scriptpackages/Netscape In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31286/plat-mac/lib-scriptpackages/Netscape Modified Files: Mozilla_suite.py PowerPlant.py Required_suite.py Standard_URL_suite.py Text.py WorldWideWeb_suite.py Log Message: Whitespace normalization, via reindent.py. Index: Mozilla_suite.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/lib-scriptpackages/Netscape/Mozilla_suite.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Mozilla_suite.py 13 Jun 2003 14:31:13 -0000 1.7 --- Mozilla_suite.py 18 Jul 2004 06:14:47 -0000 1.8 *************** *** 225,251 **** _Enum_comp = { ! 'Navigator' : 'navg', # The Navigator component ! 'InBox' : 'inbx', # The InBox component ! 'Newsgroups' : 'colb', # The Newsgroups component ! 'Composer' : 'cpsr', # The Page Composer component ! 'Conference' : 'conf', # The Conference Component ! 'Calendar' : 'cald', # The Calendar Component } _Enum_dire = { ! 'again' : 'agai', # Again (reload) ! 'home' : 'home', # Home ! 'backward' : 'prev', # Previous page ! 'forward' : 'next', # Next page } _Enum_ncmd = { ! 'Get_new_mail' : '\x00\x00\x04W', # ! 'Send_queued_messages' : '\x00\x00\x04X', # ! 'Read_newsgroups' : '\x00\x00\x04\x04', # ! 'Show_Inbox' : '\x00\x00\x04\x05', # ! 'Show_Bookmarks_window' : '\x00\x00\x04\x06', # ! 'Show_History_window' : '\x00\x00\x04\x07', # ! 'Show_Address_Book_window' : '\x00\x00\x04\t', # } --- 225,251 ---- _Enum_comp = { ! 'Navigator' : 'navg', # The Navigator component ! 'InBox' : 'inbx', # The InBox component ! 'Newsgroups' : 'colb', # The Newsgroups component ! 'Composer' : 'cpsr', # The Page Composer component ! 'Conference' : 'conf', # The Conference Component ! 'Calendar' : 'cald', # The Calendar Component } _Enum_dire = { ! 'again' : 'agai', # Again (reload) ! 'home' : 'home', # Home ! 'backward' : 'prev', # Previous page ! 'forward' : 'next', # Next page } _Enum_ncmd = { ! 'Get_new_mail' : '\x00\x00\x04W', # ! 'Send_queued_messages' : '\x00\x00\x04X', # ! 'Read_newsgroups' : '\x00\x00\x04\x04', # ! 'Show_Inbox' : '\x00\x00\x04\x05', # ! 'Show_Bookmarks_window' : '\x00\x00\x04\x06', # ! 'Show_History_window' : '\x00\x00\x04\x07', # ! 'Show_Address_Book_window' : '\x00\x00\x04\t', # } Index: PowerPlant.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/lib-scriptpackages/Netscape/PowerPlant.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** PowerPlant.py 13 Jun 2003 14:31:13 -0000 1.6 --- PowerPlant.py 18 Jul 2004 06:14:47 -0000 1.7 *************** *** 1,3 **** ! """Suite PowerPlant: Level 0, version 0 --- 1,3 ---- ! """Suite PowerPlant: Level 0, version 0 *************** *** 63,70 **** _Enum_dbac = { ! 'DoNothing' : '\x00\x00\x00\x00', # No debugging action is taken. ! 'PostAlert' : '\x00\x00\x00\x01', # Post an alert. ! 'LowLevelDebugger' : '\x00\x00\x00\x02', # Break into the low level debugger (MacsBug). ! 'SourceDebugger' : '\x00\x00\x00\x03', # Break into the source level debugger (if source debugger is executing). } --- 63,70 ---- _Enum_dbac = { ! 'DoNothing' : '\x00\x00\x00\x00', # No debugging action is taken. ! 'PostAlert' : '\x00\x00\x00\x01', # Post an alert. ! 'LowLevelDebugger' : '\x00\x00\x00\x02', # Break into the low level debugger (MacsBug). ! 'SourceDebugger' : '\x00\x00\x00\x03', # Break into the source level debugger (if source debugger is executing). } Index: Required_suite.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/lib-scriptpackages/Netscape/Required_suite.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Required_suite.py 13 Jun 2003 14:31:13 -0000 1.5 --- Required_suite.py 18 Jul 2004 06:14:47 -0000 1.6 *************** *** 1,3 **** ! """Suite Required suite: Level 0, version 0 --- 1,3 ---- ! """Suite Required suite: Level 0, version 0 Index: Standard_URL_suite.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/lib-scriptpackages/Netscape/Standard_URL_suite.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Standard_URL_suite.py 13 Jun 2003 14:31:13 -0000 1.5 --- Standard_URL_suite.py 18 Jul 2004 06:14:47 -0000 1.6 *************** *** 21,26 **** def GetURL(self, _object, _attributes={}, **_arguments): """GetURL: Loads the URL (optionally to disk) ! Required argument: The url ! Keyword argument to: file the URL should be loaded into Keyword argument inside: Window the URL should be loaded to Keyword argument from_: Referrer, to be sent with the HTTP request --- 21,26 ---- def GetURL(self, _object, _attributes={}, **_arguments): """GetURL: Loads the URL (optionally to disk) ! Required argument: The url ! Keyword argument to: file the URL should be loaded into Keyword argument inside: Window the URL should be loaded to Keyword argument from_: Referrer, to be sent with the HTTP request Index: Text.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/lib-scriptpackages/Netscape/Text.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Text.py 13 Jun 2003 14:31:14 -0000 1.8 --- Text.py 18 Jul 2004 06:14:47 -0000 1.9 *************** *** 1,3 **** ! """Suite Text: Level 0, version 0 --- 1,3 ---- ! """Suite Text: Level 0, version 0 Index: WorldWideWeb_suite.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/lib-scriptpackages/Netscape/WorldWideWeb_suite.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** WorldWideWeb_suite.py 13 Jun 2003 14:31:14 -0000 1.6 --- WorldWideWeb_suite.py 18 Jul 2004 06:14:47 -0000 1.7 *************** *** 1,3 **** ! """Suite WorldWideWeb suite, as defined in Spyglass spec.: Level 1, version 1 --- 1,3 ---- ! """Suite WorldWideWeb suite, as defined in Spyglass spec.: Level 1, version 1 *************** *** 318,322 **** def unregister_protocol(self, _object=None, _attributes={}, **_arguments): """unregister protocol: reverses the effects of \xd2register protocol\xd3 ! Required argument: Application sig. Keyword argument for_protocol: protocol prefix. If none, unregister for all protocols Keyword argument _attributes: AppleEvent attribute dictionary --- 318,322 ---- def unregister_protocol(self, _object=None, _attributes={}, **_arguments): """unregister protocol: reverses the effects of \xd2register protocol\xd3 ! Required argument: Application sig. Keyword argument for_protocol: protocol prefix. If none, unregister for all protocols Keyword argument _attributes: AppleEvent attribute dictionary From tim_one at users.sourceforge.net Sun Jul 18 08:15:21 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 08:15:46 2004 Subject: [Python-checkins] python/dist/src/Lib/plat-mac Audio_mac.py, 1.3, 1.4 EasyDialogs.py, 1.15, 1.16 FrameWork.py, 1.6, 1.7 MiniAEFrame.py, 1.4, 1.5 PixMapWrapper.py, 1.3, 1.4 aepack.py, 1.6, 1.7 aetools.py, 1.9, 1.10 aetypes.py, 1.6, 1.7 applesingle.py, 1.3, 1.4 appletrawmain.py, 1.2, 1.3 bgenlocations.py, 1.7, 1.8 buildtools.py, 1.11, 1.12 cfmfile.py, 1.3, 1.4 findertools.py, 1.4, 1.5 gensuitemodule.py, 1.11, 1.12 ic.py, 1.6, 1.7 icopen.py, 1.2, 1.3 macfs.py, 1.10, 1.11 macostools.py, 1.3, 1.4 macresource.py, 1.5, 1.6 pimp.py, 1.34, 1.35 videoreader.py, 1.3, 1.4 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/plat-mac In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31286/plat-mac Modified Files: Audio_mac.py EasyDialogs.py FrameWork.py MiniAEFrame.py PixMapWrapper.py aepack.py aetools.py aetypes.py applesingle.py appletrawmain.py bgenlocations.py buildtools.py cfmfile.py findertools.py gensuitemodule.py ic.py icopen.py macfs.py macostools.py macresource.py pimp.py videoreader.py Log Message: Whitespace normalization, via reindent.py. Index: Audio_mac.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/Audio_mac.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Audio_mac.py 9 Apr 2003 13:25:42 -0000 1.3 --- Audio_mac.py 18 Jul 2004 06:14:45 -0000 1.4 *************** *** 82,86 **** if self._usercallback: self._usercallback() ! def setcallback(self, callback): self._usercallback = callback --- 82,86 ---- if self._usercallback: self._usercallback() ! def setcallback(self, callback): self._usercallback = callback Index: EasyDialogs.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/EasyDialogs.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** EasyDialogs.py 12 Feb 2004 17:35:10 -0000 1.15 --- EasyDialogs.py 18 Jul 2004 06:14:45 -0000 1.16 *************** *** 374,393 **** ## def _setmenu(control, items): ! mhandle = control.GetControlData_Handle(Controls.kControlMenuPart, ! Controls.kControlPopupButtonMenuHandleTag) ! menu = Menu.as_Menu(mhandle) ! for item in items: ! if type(item) == type(()): ! label = item[0] ! else: ! label = item ! if label[-1] == '=' or label[-1] == ':': ! label = label[:-1] ! menu.AppendMenu(label) ## mhandle, mid = menu.getpopupinfo() ## control.SetControlData_Handle(Controls.kControlMenuPart, ## Controls.kControlPopupButtonMenuHandleTag, mhandle) ! control.SetControlMinimum(1) ! control.SetControlMaximum(len(items)+1) def _selectoption(d, optionlist, idx): --- 374,393 ---- ## def _setmenu(control, items): ! mhandle = control.GetControlData_Handle(Controls.kControlMenuPart, ! Controls.kControlPopupButtonMenuHandleTag) ! menu = Menu.as_Menu(mhandle) ! for item in items: ! if type(item) == type(()): ! label = item[0] ! else: ! label = item ! if label[-1] == '=' or label[-1] == ':': ! label = label[:-1] ! menu.AppendMenu(label) ## mhandle, mid = menu.getpopupinfo() ## control.SetControlData_Handle(Controls.kControlMenuPart, ## Controls.kControlPopupButtonMenuHandleTag, mhandle) ! control.SetControlMinimum(1) ! control.SetControlMaximum(len(items)+1) def _selectoption(d, optionlist, idx): *************** *** 837,839 **** except KeyboardInterrupt: Message("Operation Canceled.") - --- 837,838 ---- Index: FrameWork.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/FrameWork.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** FrameWork.py 12 Feb 2004 17:35:10 -0000 1.6 --- FrameWork.py 18 Jul 2004 06:14:45 -0000 1.7 *************** *** 636,640 **** self._parent.menu.DisableMenuItem(self._parent_item) if self.bar and self.bar.parent: ! self.bar.parent.needmenubarredraw = 1 class PopupMenu(Menu): --- 636,640 ---- self._parent.menu.DisableMenuItem(self._parent_item) if self.bar and self.bar.parent: ! self.bar.parent.needmenubarredraw = 1 class PopupMenu(Menu): Index: MiniAEFrame.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/MiniAEFrame.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** MiniAEFrame.py 12 Feb 2004 17:35:10 -0000 1.4 --- MiniAEFrame.py 18 Jul 2004 06:14:45 -0000 1.5 *************** *** 60,66 **** def dooneevent(self, mask = everyEvent, timeout = 60*60): ! got, event = Evt.WaitNextEvent(mask, timeout) ! if got: ! self.lowlevelhandler(event) def lowlevelhandler(self, event): --- 60,66 ---- def dooneevent(self, mask = everyEvent, timeout = 60*60): ! got, event = Evt.WaitNextEvent(mask, timeout) ! if got: ! self.lowlevelhandler(event) def lowlevelhandler(self, event): Index: PixMapWrapper.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/PixMapWrapper.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PixMapWrapper.py 9 Apr 2003 13:25:42 -0000 1.3 --- PixMapWrapper.py 18 Jul 2004 06:14:45 -0000 1.4 *************** *** 1,4 **** """PixMapWrapper - defines the PixMapWrapper class, which wraps an opaque ! QuickDraw PixMap data structure in a handy Python class. Also provides methods to convert to/from pixel data (from, e.g., the img module) or a Python Imaging Library Image object. --- 1,4 ---- """PixMapWrapper - defines the PixMapWrapper class, which wraps an opaque ! QuickDraw PixMap data structure in a handy Python class. Also provides methods to convert to/from pixel data (from, e.g., the img module) or a Python Imaging Library Image object. *************** *** 78,82 **** 0, 0, 0) # planeBytes, pmTable, pmReserved self.__dict__['_pm'] = Qd.RawBitMap(self._header) ! def _stuff(self, element, bytes): offset = _pmElemOffset[element] --- 78,82 ---- 0, 0, 0) # planeBytes, pmTable, pmReserved self.__dict__['_pm'] = Qd.RawBitMap(self._header) ! def _stuff(self, element, bytes): offset = _pmElemOffset[element] *************** *** 86,90 **** + self._header[offset + struct.calcsize(fmt):] self.__dict__['_pm'] = None ! def _unstuff(self, element): offset = _pmElemOffset[element] --- 86,90 ---- + self._header[offset + struct.calcsize(fmt):] self.__dict__['_pm'] = None ! def _unstuff(self, element): offset = _pmElemOffset[element] *************** *** 114,118 **** self._stuff(attr, val) else: ! self.__dict__[attr] = val def __getattr__(self, attr): --- 114,118 ---- self._stuff(attr, val) else: ! self.__dict__[attr] = val def __getattr__(self, attr): *************** *** 134,140 **** return self._unstuff(attr) else: ! return self.__dict__[attr] - def PixMap(self): "Return a QuickDraw PixMap corresponding to this data." --- 134,140 ---- return self._unstuff(attr) else: ! return self.__dict__[attr] ! def PixMap(self): "Return a QuickDraw PixMap corresponding to this data." *************** *** 144,148 **** def blit(self, x1=0,y1=0,x2=None,y2=None, port=None): ! """Draw this pixmap into the given (default current) grafport.""" src = self.bounds dest = [x1,y1,x2,y2] --- 144,148 ---- def blit(self, x1=0,y1=0,x2=None,y2=None, port=None): ! """Draw this pixmap into the given (default current) grafport.""" src = self.bounds dest = [x1,y1,x2,y2] *************** *** 154,158 **** Qd.CopyBits(self.PixMap(), port.GetPortBitMapForCopyBits(), src, tuple(dest), QuickDraw.srcCopy, None) ! def fromstring(self,s,width,height,format=imgformat.macrgb): """Stuff this pixmap with raw pixel data from a string. --- 154,158 ---- Qd.CopyBits(self.PixMap(), port.GetPortBitMapForCopyBits(), src, tuple(dest), QuickDraw.srcCopy, None) ! def fromstring(self,s,width,height,format=imgformat.macrgb): """Stuff this pixmap with raw pixel data from a string. *************** *** 189,193 **** # We need data in ARGB format; PIL can't currently do that, # but it can do RGBA, which we can use by inserting one null ! # up frontpm = if im.mode != 'RGBA': im = im.convert('RGBA') data = chr(0) + im.tostring() --- 189,193 ---- # We need data in ARGB format; PIL can't currently do that, # but it can do RGBA, which we can use by inserting one null ! # up frontpm = if im.mode != 'RGBA': im = im.convert('RGBA') data = chr(0) + im.tostring() *************** *** 213,215 **** pm.blit(20,20) return pm - --- 213,214 ---- Index: aepack.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/aepack.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** aepack.py 9 Apr 2003 13:25:42 -0000 1.6 --- aepack.py 18 Jul 2004 06:14:45 -0000 1.7 *************** *** 75,79 **** def pack(x, forcetype = None): """Pack a python object into an AE descriptor""" ! if forcetype: if type(x) is StringType: --- 75,79 ---- def pack(x, forcetype = None): """Pack a python object into an AE descriptor""" ! if forcetype: if type(x) is StringType: *************** *** 81,88 **** else: return pack(x).AECoerceDesc(forcetype) ! if x == None: return AE.AECreateDesc('null', '') ! if isinstance(x, AEDescType): return x --- 81,88 ---- else: return pack(x).AECoerceDesc(forcetype) ! if x == None: return AE.AECreateDesc('null', '') ! if isinstance(x, AEDescType): return x *************** *** 129,137 **** """Unpack an AE descriptor to a python object""" t = desc.type ! if unpacker_coercions.has_key(t): desc = desc.AECoerceDesc(unpacker_coercions[t]) t = desc.type # This is a guess by Jack.... ! if t == typeAEList: l = [] --- 129,137 ---- """Unpack an AE descriptor to a python object""" t = desc.type ! if unpacker_coercions.has_key(t): desc = desc.AECoerceDesc(unpacker_coercions[t]) t = desc.type # This is a guess by Jack.... ! if t == typeAEList: l = [] *************** *** 249,253 **** return mklogical(unpack(record, formodulename)) return mkunknown(desc.type, desc.data) ! def coerce(data, egdata): """Coerce a python object to another type using the AE coercers""" --- 249,253 ---- return mklogical(unpack(record, formodulename)) return mkunknown(desc.type, desc.data) ! def coerce(data, egdata): """Coerce a python object to another type using the AE coercers""" *************** *** 312,319 **** def mkstyledtext(dict): return aetypes.StyledText(dict['ksty'], dict['ktxt']) ! def mkaetext(dict): return aetypes.AEText(dict[keyAEScriptTag], dict[keyAEStyles], dict[keyAEText]) ! def mkinsertionloc(dict): return aetypes.InsertionLoc(dict[keyAEObject], dict[keyAEPosition]) --- 312,319 ---- def mkstyledtext(dict): return aetypes.StyledText(dict['ksty'], dict['ktxt']) ! def mkaetext(dict): return aetypes.AEText(dict[keyAEScriptTag], dict[keyAEStyles], dict[keyAEText]) ! def mkinsertionloc(dict): return aetypes.InsertionLoc(dict[keyAEObject], dict[keyAEPosition]) *************** *** 356,360 **** newobj.__class__ = classtype return newobj ! def mktype(typecode, modulename=None): if modulename: --- 356,360 ---- newobj.__class__ = classtype return newobj ! def mktype(typecode, modulename=None): if modulename: Index: aetools.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/aetools.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** aetools.py 18 Jun 2003 14:19:08 -0000 1.9 --- aetools.py 18 Jul 2004 06:14:45 -0000 1.10 *************** *** 114,118 **** elif k != '----' and k not in ok: raise TypeError, 'Unknown keyword argument: %s'%k ! def enumsubst(arguments, key, edict): """Substitute a single enum keyword argument, if it occurs""" --- 114,118 ---- elif k != '----' and k not in ok: raise TypeError, 'Unknown keyword argument: %s'%k ! def enumsubst(arguments, key, edict): """Substitute a single enum keyword argument, if it occurs""" *************** *** 125,129 **** elif not v in ok: raise TypeError, 'Unknown enumerator: %s'%v ! def decodeerror(arguments): """Create the 'best' argument for a raise MacOS.Error""" --- 125,129 ---- elif not v in ok: raise TypeError, 'Unknown enumerator: %s'%v ! def decodeerror(arguments): """Create the 'best' argument for a raise MacOS.Error""" *************** *** 138,142 **** else: err_a3 = None ! return (err_a1, err_a2, err_a3) --- 138,142 ---- else: err_a3 = None ! return (err_a1, err_a2, err_a3) *************** *** 147,151 **** _elemdict = {} # Can be overridden by subclasses _propdict = {} # Can be overridden by subclasses ! __eventloop_initialized = 0 def __ensure_WMAvailable(klass): --- 147,151 ---- _elemdict = {} # Can be overridden by subclasses _propdict = {} # Can be overridden by subclasses ! __eventloop_initialized = 0 def __ensure_WMAvailable(klass): *************** *** 157,164 **** return 1 __ensure_WMAvailable = classmethod(__ensure_WMAvailable) ! def __init__(self, signature=None, start=0, timeout=0): """Create a communication channel with a particular application. ! Addressing the application is done by specifying either a 4-byte signature, an AEDesc or an object that will __aepack__ --- 157,164 ---- return 1 __ensure_WMAvailable = classmethod(__ensure_WMAvailable) ! def __init__(self, signature=None, start=0, timeout=0): """Create a communication channel with a particular application. ! Addressing the application is done by specifying either a 4-byte signature, an AEDesc or an object that will __aepack__ *************** *** 185,189 **** if start: self._start() ! def _start(self): """Start the application, if it is not running yet""" --- 185,189 ---- if start: self._start() ! def _start(self): """Start the application, if it is not running yet""" *************** *** 200,216 **** break time.sleep(1) ! def start(self): """Deprecated, used _start()""" self._start() ! def newevent(self, code, subcode, parameters = {}, attributes = {}): """Create a complete structure for an apple event""" ! event = AE.AECreateAppleEvent(code, subcode, self.target, AppleEvents.kAutoGenerateReturnID, AppleEvents.kAnyTransactionID) packevent(event, parameters, attributes) return event ! def sendevent(self, event): """Send a pre-created appleevent, await the reply and unpack it""" --- 200,216 ---- break time.sleep(1) ! def start(self): """Deprecated, used _start()""" self._start() ! def newevent(self, code, subcode, parameters = {}, attributes = {}): """Create a complete structure for an apple event""" ! event = AE.AECreateAppleEvent(code, subcode, self.target, AppleEvents.kAutoGenerateReturnID, AppleEvents.kAnyTransactionID) packevent(event, parameters, attributes) return event ! def sendevent(self, event): """Send a pre-created appleevent, await the reply and unpack it""" *************** *** 221,229 **** parameters, attributes = unpackevent(reply, self._moduleName) return reply, parameters, attributes ! def send(self, code, subcode, parameters = {}, attributes = {}): """Send an appleevent given code/subcode/pars/attrs and unpack the reply""" return self.sendevent(self.newevent(code, subcode, parameters, attributes)) ! # # The following events are somehow "standard" and don't seem to appear in any --- 221,229 ---- parameters, attributes = unpackevent(reply, self._moduleName) return reply, parameters, attributes ! def send(self, code, subcode, parameters = {}, attributes = {}): """Send an appleevent given code/subcode/pars/attrs and unpack the reply""" return self.sendevent(self.newevent(code, subcode, parameters, attributes)) ! # # The following events are somehow "standard" and don't seem to appear in any *************** *** 257,263 **** item.__class__ = as return item ! get = _get ! _argmap_set = { 'to' : 'data', --- 257,263 ---- item.__class__ = as return item ! get = _get ! _argmap_set = { 'to' : 'data', *************** *** 284,293 **** if _arguments.has_key('----'): return _arguments['----'] ! set = _set # Magic glue to allow suite-generated classes to function somewhat # like the "application" class in OSA. ! def __getattr__(self, name): if self._elemdict.has_key(name): --- 284,293 ---- if _arguments.has_key('----'): return _arguments['----'] ! set = _set # Magic glue to allow suite-generated classes to function somewhat # like the "application" class in OSA. ! def __getattr__(self, name): if self._elemdict.has_key(name): *************** *** 298,302 **** return cls() raise AttributeError, name ! # Tiny Finder class, for local use only --- 298,302 ---- return cls() raise AttributeError, name ! # Tiny Finder class, for local use only *************** *** 322,326 **** return _arguments['----'] #pass ! _finder = _miniFinder('MACS') --- 322,326 ---- return _arguments['----'] #pass ! _finder = _miniFinder('MACS') *************** *** 333,342 **** """application file - An application's file on disk""" want = 'appf' ! _application_file._propdict = { } _application_file._elemdict = { } ! # Test program # XXXX Should test more, really... --- 333,342 ---- """application file - An application's file on disk""" want = 'appf' ! _application_file._propdict = { } _application_file._elemdict = { } ! # Test program # XXXX Should test more, really... Index: aetypes.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/aetypes.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** aetypes.py 12 Feb 2004 17:35:10 -0000 1.6 --- aetypes.py 18 Jul 2004 06:14:45 -0000 1.7 *************** *** 13,17 **** from aepack import pack return pack( *args, **kwargs) ! def nice(s): """'nice' representation of an object""" --- 13,17 ---- from aepack import pack return pack( *args, **kwargs) ! def nice(s): """'nice' representation of an object""" *************** *** 21,32 **** class Unknown: """An uninterpreted AE object""" ! def __init__(self, type, data): self.type = type self.data = data ! def __repr__(self): return "Unknown(%r, %r)" % (self.type, self.data) ! def __aepack__(self): return pack(self.data, self.type) --- 21,32 ---- class Unknown: """An uninterpreted AE object""" ! def __init__(self, type, data): self.type = type self.data = data ! def __repr__(self): return "Unknown(%r, %r)" % (self.type, self.data) ! def __aepack__(self): return pack(self.data, self.type) *************** *** 34,47 **** class Enum: """An AE enumeration value""" ! def __init__(self, enum): self.enum = "%-4.4s" % str(enum) ! def __repr__(self): return "Enum(%r)" % (self.enum,) ! def __str__(self): return string.strip(self.enum) ! def __aepack__(self): return pack(self.enum, typeEnumeration) --- 34,47 ---- class Enum: """An AE enumeration value""" ! def __init__(self, enum): self.enum = "%-4.4s" % str(enum) ! def __repr__(self): return "Enum(%r)" % (self.enum,) ! def __str__(self): return string.strip(self.enum) ! def __aepack__(self): return pack(self.enum, typeEnumeration) *************** *** 59,74 **** self.of = of self.pos = pos ! def __repr__(self): return "InsertionLoc(%r, %r)" % (self.of, self.pos) ! def __aepack__(self): rec = {'kobj': self.of, 'kpos': self.pos} return pack(rec, forcetype='insl') ! # Convenience functions for dsp: def beginning(of): return InsertionLoc(of, Enum('bgng')) ! def end(of): return InsertionLoc(of, Enum('end ')) --- 59,74 ---- self.of = of self.pos = pos ! def __repr__(self): return "InsertionLoc(%r, %r)" % (self.of, self.pos) ! def __aepack__(self): rec = {'kobj': self.of, 'kpos': self.pos} return pack(rec, forcetype='insl') ! # Convenience functions for dsp: def beginning(of): return InsertionLoc(of, Enum('bgng')) ! def end(of): return InsertionLoc(of, Enum('end ')) *************** *** 76,86 **** class Boolean: """An AE boolean value""" ! def __init__(self, bool): self.bool = (not not bool) ! def __repr__(self): return "Boolean(%r)" % (self.bool,) ! def __str__(self): if self.bool: --- 76,86 ---- class Boolean: """An AE boolean value""" ! def __init__(self, bool): self.bool = (not not bool) ! def __repr__(self): return "Boolean(%r)" % (self.bool,) ! def __str__(self): if self.bool: *************** *** 88,92 **** else: return "False" ! def __aepack__(self): return pack(struct.pack('b', self.bool), 'bool') --- 88,92 ---- else: return "False" ! def __aepack__(self): return pack(struct.pack('b', self.bool), 'bool') *************** *** 101,114 **** class Type: """An AE 4-char typename object""" ! def __init__(self, type): self.type = "%-4.4s" % str(type) ! def __repr__(self): return "Type(%r)" % (self.type,) ! def __str__(self): return string.strip(self.type) ! def __aepack__(self): return pack(self.type, typeType) --- 101,114 ---- class Type: """An AE 4-char typename object""" ! def __init__(self, type): self.type = "%-4.4s" % str(type) ! def __repr__(self): return "Type(%r)" % (self.type,) ! def __str__(self): return string.strip(self.type) ! def __aepack__(self): return pack(self.type, typeType) *************** *** 124,137 **** class Keyword: """An AE 4-char keyword object""" ! def __init__(self, keyword): self.keyword = "%-4.4s" % str(keyword) ! def __repr__(self): return "Keyword(%r)" % `self.keyword` ! def __str__(self): return string.strip(self.keyword) ! def __aepack__(self): return pack(self.keyword, typeKeyword) --- 124,137 ---- class Keyword: """An AE 4-char keyword object""" ! def __init__(self, keyword): self.keyword = "%-4.4s" % str(keyword) ! def __repr__(self): return "Keyword(%r)" % `self.keyword` ! def __str__(self): return string.strip(self.keyword) ! def __aepack__(self): return pack(self.keyword, typeKeyword) *************** *** 142,156 **** class Range: """An AE range object""" ! def __init__(self, start, stop): self.start = start self.stop = stop ! def __repr__(self): return "Range(%r, %r)" % (self.start, self.stop) ! def __str__(self): return "%s thru %s" % (nice(self.start), nice(self.stop)) ! def __aepack__(self): return pack({'star': self.start, 'stop': self.stop}, 'rang') --- 142,156 ---- class Range: """An AE range object""" ! def __init__(self, start, stop): self.start = start self.stop = stop ! def __repr__(self): return "Range(%r, %r)" % (self.start, self.stop) ! def __str__(self): return "%s thru %s" % (nice(self.start), nice(self.stop)) ! def __aepack__(self): return pack({'star': self.start, 'stop': self.stop}, 'rang') *************** *** 161,176 **** class Comparison: """An AE Comparison""" ! def __init__(self, obj1, relo, obj2): self.obj1 = obj1 self.relo = "%-4.4s" % str(relo) self.obj2 = obj2 ! def __repr__(self): return "Comparison(%r, %r, %r)" % (self.obj1, self.relo, self.obj2) ! def __str__(self): return "%s %s %s" % (nice(self.obj1), string.strip(self.relo), nice(self.obj2)) ! def __aepack__(self): return pack({'obj1': self.obj1, --- 161,176 ---- class Comparison: """An AE Comparison""" ! def __init__(self, obj1, relo, obj2): self.obj1 = obj1 self.relo = "%-4.4s" % str(relo) self.obj2 = obj2 ! def __repr__(self): return "Comparison(%r, %r, %r)" % (self.obj1, self.relo, self.obj2) ! def __str__(self): return "%s %s %s" % (nice(self.obj1), string.strip(self.relo), nice(self.obj2)) ! def __aepack__(self): return pack({'obj1': self.obj1, *************** *** 181,188 **** def IsComparison(x): return isinstance(x, Comparison) ! class NComparison(Comparison): # The class attribute 'relo' must be set in a subclass ! def __init__(self, obj1, obj2): Comparison.__init__(obj1, self.relo, obj2) --- 181,188 ---- def IsComparison(x): return isinstance(x, Comparison) ! class NComparison(Comparison): # The class attribute 'relo' must be set in a subclass ! def __init__(self, obj1, obj2): Comparison.__init__(obj1, self.relo, obj2) *************** *** 190,204 **** class Ordinal: """An AE Ordinal""" ! def __init__(self, abso): # self.obj1 = obj1 self.abso = "%-4.4s" % str(abso) ! def __repr__(self): return "Ordinal(%r)" % (self.abso,) ! def __str__(self): return "%s" % (string.strip(self.abso)) ! def __aepack__(self): return pack(self.abso, 'abso') --- 190,204 ---- class Ordinal: """An AE Ordinal""" ! def __init__(self, abso): # self.obj1 = obj1 self.abso = "%-4.4s" % str(abso) ! def __repr__(self): return "Ordinal(%r)" % (self.abso,) ! def __str__(self): return "%s" % (string.strip(self.abso)) ! def __aepack__(self): return pack(self.abso, 'abso') *************** *** 206,213 **** def IsOrdinal(x): return isinstance(x, Ordinal) ! class NOrdinal(Ordinal): # The class attribute 'abso' must be set in a subclass ! def __init__(self): Ordinal.__init__(self, self.abso) --- 206,213 ---- def IsOrdinal(x): return isinstance(x, Ordinal) ! class NOrdinal(Ordinal): # The class attribute 'abso' must be set in a subclass ! def __init__(self): Ordinal.__init__(self, self.abso) *************** *** 215,226 **** class Logical: """An AE logical expression object""" ! def __init__(self, logc, term): self.logc = "%-4.4s" % str(logc) self.term = term ! def __repr__(self): return "Logical(%r, %r)" % (self.logc, self.term) ! def __str__(self): if type(self.term) == ListType and len(self.term) == 2: --- 215,226 ---- class Logical: """An AE logical expression object""" ! def __init__(self, logc, term): self.logc = "%-4.4s" % str(logc) self.term = term ! def __repr__(self): return "Logical(%r, %r)" % (self.logc, self.term) ! def __str__(self): if type(self.term) == ListType and len(self.term) == 2: *************** *** 230,234 **** else: return "%s(%s)" % (string.strip(self.logc), nice(self.term)) ! def __aepack__(self): return pack({'logc': mkenum(self.logc), 'term': self.term}, 'logi') --- 230,234 ---- else: return "%s(%s)" % (string.strip(self.logc), nice(self.term)) ! def __aepack__(self): return pack({'logc': mkenum(self.logc), 'term': self.term}, 'logi') *************** *** 239,253 **** class StyledText: """An AE object respresenting text in a certain style""" ! def __init__(self, style, text): self.style = style self.text = text ! def __repr__(self): return "StyledText(%r, %r)" % (self.style, self.text) ! def __str__(self): return self.text ! def __aepack__(self): return pack({'ksty': self.style, 'ktxt': self.text}, 'STXT') --- 239,253 ---- class StyledText: """An AE object respresenting text in a certain style""" ! def __init__(self, style, text): self.style = style self.text = text ! def __repr__(self): return "StyledText(%r, %r)" % (self.style, self.text) ! def __str__(self): return self.text ! def __aepack__(self): return pack({'ksty': self.style, 'ktxt': self.text}, 'STXT') *************** *** 258,273 **** class AEText: """An AE text object with style, script and language specified""" ! def __init__(self, script, style, text): self.script = script self.style = style self.text = text ! def __repr__(self): return "AEText(%r, %r, %r)" % (self.script, self.style, self.text) ! def __str__(self): return self.text ! def __aepack__(self): return pack({keyAEScriptTag: self.script, keyAEStyles: self.style, --- 258,273 ---- class AEText: """An AE text object with style, script and language specified""" ! def __init__(self, script, style, text): self.script = script self.style = style self.text = text ! def __repr__(self): return "AEText(%r, %r, %r)" % (self.script, self.style, self.text) ! def __str__(self): return self.text ! def __aepack__(self): return pack({keyAEScriptTag: self.script, keyAEStyles: self.style, *************** *** 279,294 **** class IntlText: """A text object with script and language specified""" ! def __init__(self, script, language, text): self.script = script self.language = language self.text = text ! def __repr__(self): return "IntlText(%r, %r, %r)" % (self.script, self.language, self.text) ! def __str__(self): return self.text ! def __aepack__(self): return pack(struct.pack('hh', self.script, self.language)+self.text, --- 279,294 ---- class IntlText: """A text object with script and language specified""" ! def __init__(self, script, language, text): self.script = script self.language = language self.text = text ! def __repr__(self): return "IntlText(%r, %r, %r)" % (self.script, self.language, self.text) ! def __str__(self): return self.text ! def __aepack__(self): return pack(struct.pack('hh', self.script, self.language)+self.text, *************** *** 300,314 **** class IntlWritingCode: """An object representing script and language""" ! def __init__(self, script, language): self.script = script self.language = language ! def __repr__(self): return "IntlWritingCode(%r, %r)" % (self.script, self.language) ! def __str__(self): return "script system %d, language %d"%(self.script, self.language) ! def __aepack__(self): return pack(struct.pack('hh', self.script, self.language), --- 300,314 ---- class IntlWritingCode: """An object representing script and language""" ! def __init__(self, script, language): self.script = script self.language = language ! def __repr__(self): return "IntlWritingCode(%r, %r)" % (self.script, self.language) ! def __str__(self): return "script system %d, language %d"%(self.script, self.language) ! def __aepack__(self): return pack(struct.pack('hh', self.script, self.language), *************** *** 320,334 **** class QDPoint: """A point""" ! def __init__(self, v, h): self.v = v self.h = h ! def __repr__(self): return "QDPoint(%r, %r)" % (self.v, self.h) ! def __str__(self): return "(%d, %d)"%(self.v, self.h) ! def __aepack__(self): return pack(struct.pack('hh', self.v, self.h), --- 320,334 ---- class QDPoint: """A point""" ! def __init__(self, v, h): self.v = v self.h = h ! def __repr__(self): return "QDPoint(%r, %r)" % (self.v, self.h) ! def __str__(self): return "(%d, %d)"%(self.v, self.h) ! def __aepack__(self): return pack(struct.pack('hh', self.v, self.h), *************** *** 340,344 **** class QDRectangle: """A rectangle""" ! def __init__(self, v0, h0, v1, h1): self.v0 = v0 --- 340,344 ---- class QDRectangle: """A rectangle""" ! def __init__(self, v0, h0, v1, h1): self.v0 = v0 *************** *** 346,356 **** self.v1 = v1 self.h1 = h1 ! def __repr__(self): return "QDRectangle(%r, %r, %r, %r)" % (self.v0, self.h0, self.v1, self.h1) ! def __str__(self): return "(%d, %d)-(%d, %d)"%(self.v0, self.h0, self.v1, self.h1) ! def __aepack__(self): return pack(struct.pack('hhhh', self.v0, self.h0, self.v1, self.h1), --- 346,356 ---- self.v1 = v1 self.h1 = h1 ! def __repr__(self): return "QDRectangle(%r, %r, %r, %r)" % (self.v0, self.h0, self.v1, self.h1) ! def __str__(self): return "(%d, %d)-(%d, %d)"%(self.v0, self.h0, self.v1, self.h1) ! def __aepack__(self): return pack(struct.pack('hhhh', self.v0, self.h0, self.v1, self.h1), *************** *** 362,377 **** class RGBColor: """An RGB color""" ! def __init__(self, r, g, b): self.r = r self.g = g self.b = b ! def __repr__(self): return "RGBColor(%r, %r, %r)" % (self.r, self.g, self.b) ! def __str__(self): return "0x%x red, 0x%x green, 0x%x blue"% (self.r, self.g, self.b) ! def __aepack__(self): return pack(struct.pack('hhh', self.r, self.g, self.b), --- 362,377 ---- class RGBColor: """An RGB color""" ! def __init__(self, r, g, b): self.r = r self.g = g self.b = b ! def __repr__(self): return "RGBColor(%r, %r, %r)" % (self.r, self.g, self.b) ! def __str__(self): return "0x%x red, 0x%x green, 0x%x blue"% (self.r, self.g, self.b) ! def __aepack__(self): return pack(struct.pack('hhh', self.r, self.g, self.b), *************** *** 382,409 **** class ObjectSpecifier: ! """A class for constructing and manipulation AE object specifiers in python. ! An object specifier is actually a record with four fields: ! key type description --- ---- ----------- ! 'want' type 4-char class code of thing we want, e.g. word, paragraph or property ! 'form' enum how we specify which 'want' thing(s) we want, e.g. by index, by range, by name, or by property specifier ! 'seld' any which thing(s) we want, e.g. its index, its name, or its property specifier ! 'from' object the object in which it is contained, or null, meaning look for it in the application ! Note that we don't call this class plain "Object", since that name is likely to be used by the application. """ ! def __init__(self, want, form, seld, fr = None): self.want = want --- 382,409 ---- class ObjectSpecifier: ! """A class for constructing and manipulation AE object specifiers in python. ! An object specifier is actually a record with four fields: ! key type description --- ---- ----------- ! 'want' type 4-char class code of thing we want, e.g. word, paragraph or property ! 'form' enum how we specify which 'want' thing(s) we want, e.g. by index, by range, by name, or by property specifier ! 'seld' any which thing(s) we want, e.g. its index, its name, or its property specifier ! 'from' object the object in which it is contained, or null, meaning look for it in the application ! Note that we don't call this class plain "Object", since that name is likely to be used by the application. """ ! def __init__(self, want, form, seld, fr = None): self.want = want *************** *** 411,415 **** self.seld = seld self.fr = fr ! def __repr__(self): s = "ObjectSpecifier(%r, %r, %r" % (self.want, self.form, self.seld) --- 411,415 ---- self.seld = seld self.fr = fr ! def __repr__(self): s = "ObjectSpecifier(%r, %r, %r" % (self.want, self.form, self.seld) *************** *** 419,423 **** s = s + ")" return s ! def __aepack__(self): return pack({'want': mktype(self.want), --- 419,423 ---- s = s + ")" return s ! def __aepack__(self): return pack({'want': mktype(self.want), *************** *** 442,446 **** else: return "Property(%r)" % (self.seld.type,) ! def __str__(self): if self.fr: --- 442,446 ---- else: return "Property(%r)" % (self.seld.type,) ! def __str__(self): if self.fr: *************** *** 461,465 **** # self.want = 'prop' self.want = 'prop' ! ObjectSpecifier.__init__(self, self.want, 'prop', mktype(self.which), fr) --- 461,465 ---- # self.want = 'prop' self.want = 'prop' ! ObjectSpecifier.__init__(self, self.want, 'prop', mktype(self.which), fr) *************** *** 471,475 **** rv = rv + ", want=%r" % (self.want,) return rv + ")" ! def __str__(self): if self.fr: --- 471,475 ---- rv = rv + ", want=%r" % (self.want,) return rv + ")" ! def __str__(self): if self.fr: *************** *** 480,484 **** class SelectableItem(ObjectSpecifier): ! def __init__(self, want, seld, fr = None): t = type(seld) --- 480,484 ---- class SelectableItem(ObjectSpecifier): ! def __init__(self, want, seld, fr = None): t = type(seld) *************** *** 507,516 **** def __init__(self, which, fr = None): SelectableItem.__init__(self, self.want, which, fr) ! def __repr__(self): if not self.fr: return "%s(%r)" % (self.__class__.__name__, self.seld) return "%s(%r, %r)" % (self.__class__.__name__, self.seld, self.fr) ! def __str__(self): seld = self.seld --- 507,516 ---- def __init__(self, which, fr = None): SelectableItem.__init__(self, self.want, which, fr) ! def __repr__(self): if not self.fr: return "%s(%r)" % (self.__class__.__name__, self.seld) return "%s(%r, %r)" % (self.__class__.__name__, self.seld, self.fr) ! def __str__(self): seld = self.seld *************** *** 529,533 **** if self.fr: s = s + " of %s" % str(self.fr) return s ! def __getattr__(self, name): if self._elemdict.has_key(name): --- 529,533 ---- if self.fr: s = s + " of %s" % str(self.fr) return s ! def __getattr__(self, name): if self._elemdict.has_key(name): *************** *** 538,554 **** return cls(self) raise AttributeError, name ! ! class DelayedComponentItem: def __init__(self, compclass, fr): self.compclass = compclass self.fr = fr ! def __call__(self, which): return self.compclass(which, self.fr) ! def __repr__(self): return "%s(???, %r)" % (self.__class__.__name__, self.fr) ! def __str__(self): return "selector for element %s of %s"%(self.__class__.__name__, str(self.fr)) --- 538,554 ---- return cls(self) raise AttributeError, name ! ! class DelayedComponentItem: def __init__(self, compclass, fr): self.compclass = compclass self.fr = fr ! def __call__(self, which): return self.compclass(which, self.fr) ! def __repr__(self): return "%s(???, %r)" % (self.__class__.__name__, self.fr) ! def __str__(self): return "selector for element %s of %s"%(self.__class__.__name__, str(self.fr)) *************** *** 567,569 **** exec template % ("File", 'file') exec template % ("InsertionPoint", 'cins') - --- 567,568 ---- Index: applesingle.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/applesingle.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** applesingle.py 18 Nov 2003 23:09:19 -0000 1.3 --- applesingle.py 18 Jul 2004 06:14:45 -0000 1.4 *************** *** 79,83 **** elif restype == AS_RESOURCEFORK: self.resourcefork = data ! def tofile(self, path, resonly=False): outfile = open(path, 'wb') --- 79,83 ---- elif restype == AS_RESOURCEFORK: self.resourcefork = data ! def tofile(self, path, resonly=False): outfile = open(path, 'wb') *************** *** 100,112 **** fp.write(self.resourcefork) fp.close() ! def decode(infile, outpath, resonly=False, verbose=False): """decode(infile, outpath [, resonly=False, verbose=False]) Creates a decoded file from an AppleSingle encoded file. ! If resonly is True, then it will create a regular file at outpath containing only the resource fork from infile. Otherwise it will create an AppleDouble file at outpath ! with the data and resource forks from infile. On platforms without the MacOS module, it will create inpath and inpath+'.rsrc' with the data and resource forks respectively. --- 100,112 ---- fp.write(self.resourcefork) fp.close() ! def decode(infile, outpath, resonly=False, verbose=False): """decode(infile, outpath [, resonly=False, verbose=False]) Creates a decoded file from an AppleSingle encoded file. ! If resonly is True, then it will create a regular file at outpath containing only the resource fork from infile. Otherwise it will create an AppleDouble file at outpath ! with the data and resource forks from infile. On platforms without the MacOS module, it will create inpath and inpath+'.rsrc' with the data and resource forks respectively. *************** *** 122,126 **** as = AppleSingle(infile, verbose=verbose) as.tofile(outpath, resonly=resonly) ! def _test(): if len(sys.argv) < 3 or sys.argv[1] == '-r' and len(sys.argv) != 4: --- 122,126 ---- as = AppleSingle(infile, verbose=verbose) as.tofile(outpath, resonly=resonly) ! def _test(): if len(sys.argv) < 3 or sys.argv[1] == '-r' and len(sys.argv) != 4: *************** *** 133,137 **** resonly = False decode(sys.argv[1], sys.argv[2], resonly=resonly) ! if __name__ == '__main__': _test() --- 133,137 ---- resonly = False decode(sys.argv[1], sys.argv[2], resonly=resonly) ! if __name__ == '__main__': _test() Index: appletrawmain.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/appletrawmain.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** appletrawmain.py 9 Apr 2003 13:25:42 -0000 1.2 --- appletrawmain.py 18 Jul 2004 06:14:45 -0000 1.3 *************** *** 24,28 **** # # Add the Resources directory to the path. This is where files installed ! # by BuildApplet.py with the --extra option show up, and if those files are # modules this sys.path modification is necessary to be able to import them. # --- 24,28 ---- # # Add the Resources directory to the path. This is where files installed ! # by BuildApplet.py with the --extra option show up, and if those files are # modules this sys.path modification is necessary to be able to import them. # Index: bgenlocations.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/bgenlocations.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** bgenlocations.py 15 Jul 2004 15:06:07 -0000 1.7 --- bgenlocations.py 18 Jul 2004 06:14:45 -0000 1.8 *************** *** 32,42 **** CREATOR="CWIE" ! # The previous definitions can be overriden by creating a module ! # bgenlocationscustomize.py and putting it in site-packages (or anywere else # on sys.path, actually) try: ! from bgenlocationscustomize import * except ImportError: ! pass if not os.path.exists(BGENDIR): --- 32,42 ---- CREATOR="CWIE" ! # The previous definitions can be overriden by creating a module ! # bgenlocationscustomize.py and putting it in site-packages (or anywere else # on sys.path, actually) try: ! from bgenlocationscustomize import * except ImportError: ! pass if not os.path.exists(BGENDIR): *************** *** 46,50 **** if not os.path.exists(TOOLBOXDIR): raise Error, "Please fix bgenlocations.py, TOOLBOXDIR does not exist: %s" % TOOLBOXDIR ! # Sigh, due to the way these are used make sure they end with : or /. if BGENDIR[-1] != os.sep: --- 46,50 ---- if not os.path.exists(TOOLBOXDIR): raise Error, "Please fix bgenlocations.py, TOOLBOXDIR does not exist: %s" % TOOLBOXDIR ! # Sigh, due to the way these are used make sure they end with : or /. if BGENDIR[-1] != os.sep: *************** *** 54,56 **** if TOOLBOXDIR[-1] != os.sep: TOOLBOXDIR = TOOLBOXDIR + os.sep - --- 54,55 ---- Index: buildtools.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/buildtools.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** buildtools.py 12 Feb 2004 17:35:10 -0000 1.11 --- buildtools.py 18 Jul 2004 06:14:45 -0000 1.12 *************** *** 59,66 **** file = file.as_pathname() return file ! ! def process(template, filename, destname, copy_codefragment=0, rsrcname=None, others=[], raw=0, progress="default"): ! if progress == "default": progress = EasyDialogs.ProgressBar("Processing %s..."%os.path.split(filename)[1], 120) --- 59,66 ---- file = file.as_pathname() return file ! ! def process(template, filename, destname, copy_codefragment=0, rsrcname=None, others=[], raw=0, progress="default"): ! if progress == "default": progress = EasyDialogs.ProgressBar("Processing %s..."%os.path.split(filename)[1], 120) *************** *** 73,77 **** # Read the source and compile it # (there's no point overwriting the destination if it has a syntax error) ! fp = open(filename, 'rU') text = fp.read() --- 73,77 ---- # Read the source and compile it # (there's no point overwriting the destination if it has a syntax error) ! fp = open(filename, 'rU') text = fp.read() *************** *** 83,90 **** except EOFError: raise BuildError, "End-of-file in script %s" % (filename,) ! # Set the destination file name. Note that basename # does contain the whole filepath, only a .py is stripped. ! if string.lower(filename[-3:]) == ".py": basename = filename[:-3] --- 83,90 ---- except EOFError: raise BuildError, "End-of-file in script %s" % (filename,) ! # Set the destination file name. Note that basename # does contain the whole filepath, only a .py is stripped. ! if string.lower(filename[-3:]) == ".py": basename = filename[:-3] *************** *** 93,97 **** else: basename = filename ! if not destname: if MacOS.runtimemodel == 'macho': --- 93,97 ---- else: basename = filename ! if not destname: if MacOS.runtimemodel == 'macho': *************** *** 101,105 **** if not rsrcname: rsrcname = basename + '.rsrc' ! # Try removing the output file. This fails in MachO, but it should # do any harm. --- 101,105 ---- if not rsrcname: rsrcname = basename + '.rsrc' ! # Try removing the output file. This fails in MachO, but it should # do any harm. *************** *** 108,114 **** except os.error: pass ! process_common(template, progress, code, rsrcname, destname, 0, copy_codefragment, raw, others, filename) ! def update(template, filename, output): --- 108,114 ---- except os.error: pass ! process_common(template, progress, code, rsrcname, destname, 0, copy_codefragment, raw, others, filename) ! def update(template, filename, output): *************** *** 121,125 **** if not output: output = filename + ' (updated)' ! # Try removing the output file try: --- 121,125 ---- if not output: output = filename + ' (updated)' ! # Try removing the output file try: *************** *** 130,134 **** ! def process_common(template, progress, code, rsrcname, destname, is_update, copy_codefragment, raw=0, others=[], filename=None): if MacOS.runtimemodel == 'macho': --- 130,134 ---- ! def process_common(template, progress, code, rsrcname, destname, is_update, copy_codefragment, raw=0, others=[], filename=None): if MacOS.runtimemodel == 'macho': *************** *** 140,149 **** template_fsr, d1, d2 = Carbon.File.FSResolveAliasFile(template, 1) template = template_fsr.as_pathname() ! # Copy data (not resources, yet) from the template if progress: progress.label("Copy data fork...") progress.set(10) ! if copy_codefragment: tmpl = open(template, "rb") --- 140,149 ---- template_fsr, d1, d2 = Carbon.File.FSResolveAliasFile(template, 1) template = template_fsr.as_pathname() ! # Copy data (not resources, yet) from the template if progress: progress.label("Copy data fork...") progress.set(10) ! if copy_codefragment: tmpl = open(template, "rb") *************** *** 156,162 **** del dest del tmpl ! # Open the output resource fork ! if progress: progress.label("Copy resources...") --- 156,162 ---- del dest del tmpl ! # Open the output resource fork ! if progress: progress.label("Copy resources...") *************** *** 168,172 **** Res.FSCreateResourceFile(destdir, unicode(destfile), RESOURCE_FORK_NAME) output = Res.FSOpenResourceFile(destname, RESOURCE_FORK_NAME, WRITE) ! # Copy the resources from the target specific resource template, if any typesfound, ownertype = [], None --- 168,172 ---- Res.FSCreateResourceFile(destdir, unicode(destfile), RESOURCE_FORK_NAME) output = Res.FSOpenResourceFile(destname, RESOURCE_FORK_NAME, WRITE) ! # Copy the resources from the target specific resource template, if any typesfound, ownertype = [], None *************** *** 184,208 **** typesfound, ownertype = copyres(input, output, skip_oldfile, 0, progress) Res.CloseResFile(input) ! # Check which resource-types we should not copy from the template skiptypes = [] if 'vers' in typesfound: skiptypes.append('vers') if 'SIZE' in typesfound: skiptypes.append('SIZE') ! if 'BNDL' in typesfound: skiptypes = skiptypes + ['BNDL', 'FREF', 'icl4', 'icl8', 'ics4', 'ics8', 'ICN#', 'ics#'] if not copy_codefragment: skiptypes.append('cfrg') ## skipowner = (ownertype <> None) ! # Copy the resources from the template ! input = Res.FSOpenResourceFile(template, RESOURCE_FORK_NAME, READ) dummy, tmplowner = copyres(input, output, skiptypes, 1, progress) ! Res.CloseResFile(input) ## if ownertype == None: ## raise BuildError, "No owner resource found in either resource file or template" # Make sure we're manipulating the output resource file now ! Res.UseResFile(output) --- 184,208 ---- typesfound, ownertype = copyres(input, output, skip_oldfile, 0, progress) Res.CloseResFile(input) ! # Check which resource-types we should not copy from the template skiptypes = [] if 'vers' in typesfound: skiptypes.append('vers') if 'SIZE' in typesfound: skiptypes.append('SIZE') ! if 'BNDL' in typesfound: skiptypes = skiptypes + ['BNDL', 'FREF', 'icl4', 'icl8', 'ics4', 'ics8', 'ICN#', 'ics#'] if not copy_codefragment: skiptypes.append('cfrg') ## skipowner = (ownertype <> None) ! # Copy the resources from the template ! input = Res.FSOpenResourceFile(template, RESOURCE_FORK_NAME, READ) dummy, tmplowner = copyres(input, output, skiptypes, 1, progress) ! Res.CloseResFile(input) ## if ownertype == None: ## raise BuildError, "No owner resource found in either resource file or template" # Make sure we're manipulating the output resource file now ! Res.UseResFile(output) *************** *** 214,221 **** newres.AddResource(DEFAULT_APPLET_CREATOR, 0, "Owner resource") ownertype = DEFAULT_APPLET_CREATOR ! if code: # Delete any existing 'PYC ' resource named __main__ ! try: res = Res.Get1NamedResource(RESTYPE, RESNAME) --- 214,221 ---- newres.AddResource(DEFAULT_APPLET_CREATOR, 0, "Owner resource") ownertype = DEFAULT_APPLET_CREATOR ! if code: # Delete any existing 'PYC ' resource named __main__ ! try: res = Res.Get1NamedResource(RESTYPE, RESNAME) *************** *** 223,238 **** except Res.Error: pass ! # Create the raw data for the resource from the code object if progress: progress.label("Write PYC resource...") progress.set(120) ! data = marshal.dumps(code) del code data = (MAGIC + '\0\0\0\0') + data ! # Create the resource and write it ! id = 0 while id < 128: --- 223,238 ---- except Res.Error: pass ! # Create the raw data for the resource from the code object if progress: progress.label("Write PYC resource...") progress.set(120) ! data = marshal.dumps(code) del code data = (MAGIC + '\0\0\0\0') + data ! # Create the resource and write it ! id = 0 while id < 128: *************** *** 245,253 **** res.WriteResource() res.ReleaseResource() ! # Close the output file ! Res.CloseResFile(output) ! # Now set the creator, type and bundle bit of the destination. # Done with FSSpec's, FSRef FInfo isn't good enough yet (2.3a1+) --- 245,253 ---- res.WriteResource() res.ReleaseResource() ! # Close the output file ! Res.CloseResFile(output) ! # Now set the creator, type and bundle bit of the destination. # Done with FSSpec's, FSRef FInfo isn't good enough yet (2.3a1+) *************** *** 259,263 **** dest_finfo.Flags = dest_finfo.Flags & ~Carbon.Files.kHasBeenInited dest_fss.FSpSetFInfo(dest_finfo) ! macostools.touched(destname) if progress: --- 259,263 ---- dest_finfo.Flags = dest_finfo.Flags & ~Carbon.Files.kHasBeenInited dest_fss.FSpSetFInfo(dest_finfo) ! macostools.touched(destname) if progress: *************** *** 265,269 **** progress.inc(0) ! def process_common_macho(template, progress, code, rsrcname, destname, is_update, raw=0, others=[], filename=None): # Check that we have a filename --- 265,269 ---- progress.inc(0) ! def process_common_macho(template, progress, code, rsrcname, destname, is_update, raw=0, others=[], filename=None): # Check that we have a filename *************** *** 305,309 **** if rsrcname: realrsrcname = macresource.resource_pathname(rsrcname) ! builder.files.append((realrsrcname, os.path.join('Contents/Resources', os.path.basename(rsrcname)))) for o in others: --- 305,309 ---- if rsrcname: realrsrcname = macresource.resource_pathname(rsrcname) ! builder.files.append((realrsrcname, os.path.join('Contents/Resources', os.path.basename(rsrcname)))) for o in others: *************** *** 321,328 **** builder.setup() builder.build() ! if progress: progress.label('Done.') progress.inc(0) ! ## macostools.touched(dest_fss) --- 321,328 ---- builder.setup() builder.build() ! if progress: progress.label('Done.') progress.inc(0) ! ## macostools.touched(dest_fss) *************** *** 407,411 **** progress.inc(0) shutil.copy2(srcpath, dstpath) ! def writepycfile(codeobject, cfile): import marshal --- 407,411 ---- progress.inc(0) shutil.copy2(srcpath, dstpath) ! def writepycfile(codeobject, cfile): import marshal *************** *** 418,420 **** fc.write(MAGIC) fc.close() - --- 418,419 ---- Index: cfmfile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/cfmfile.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** cfmfile.py 9 Apr 2003 13:25:42 -0000 1.3 --- cfmfile.py 18 Jul 2004 06:14:45 -0000 1.4 *************** *** 19,24 **** def mergecfmfiles(srclist, dst, architecture = 'fat'): ! """Merge all files in srclist into a new file dst. ! If architecture is given, only code fragments of that type will be used: "pwpc" for PPC, "m68k" for cfm68k. This does not work for "classic" --- 19,24 ---- def mergecfmfiles(srclist, dst, architecture = 'fat'): ! """Merge all files in srclist into a new file dst. ! If architecture is given, only code fragments of that type will be used: "pwpc" for PPC, "m68k" for cfm68k. This does not work for "classic" *************** *** 26,35 **** If architecture is None, all fragments will be used, enabling FAT binaries. """ ! srclist = list(srclist) for i in range(len(srclist)): srclist[i] = Carbon.File.pathname(srclist[i]) dst = Carbon.File.pathname(dst) ! dstfile = open(dst, "wb") rf = Res.FSpOpenResFile(dst, 3) --- 26,35 ---- If architecture is None, all fragments will be used, enabling FAT binaries. """ ! srclist = list(srclist) for i in range(len(srclist)): srclist[i] = Carbon.File.pathname(srclist[i]) dst = Carbon.File.pathname(dst) ! dstfile = open(dst, "wb") rf = Res.FSpOpenResFile(dst, 3) *************** *** 44,50 **** continue dstcfrg.append(frag) ! frag.copydata(dstfile) ! cfrgres = Res.Resource(dstcfrg.build()) Res.UseResFile(rf) --- 44,50 ---- continue dstcfrg.append(frag) ! frag.copydata(dstfile) ! cfrgres = Res.Resource(dstcfrg.build()) Res.UseResFile(rf) *************** *** 56,60 **** class CfrgResource: ! def __init__(self, path = None): self.version = 1 --- 56,60 ---- class CfrgResource: ! def __init__(self, path = None): self.version = 1 *************** *** 75,83 **** self.parse(data) if self.version <> 1: ! raise error, "unknown 'cfrg' resource format" ! def parse(self, data): ! (res1, res2, self.version, ! res3, res4, res5, res6, self.memberCount) = struct.unpack("8l", data[:32]) data = data[32:] --- 75,83 ---- self.parse(data) if self.version <> 1: ! raise error, "unknown 'cfrg' resource format" ! def parse(self, data): ! (res1, res2, self.version, ! res3, res4, res5, res6, self.memberCount) = struct.unpack("8l", data[:32]) data = data[32:] *************** *** 86,90 **** data = data[frag.memberSize:] self.fragments.append(frag) ! def build(self): self.memberCount = len(self.fragments) --- 86,90 ---- data = data[frag.memberSize:] self.fragments.append(frag) ! def build(self): self.memberCount = len(self.fragments) *************** *** 93,97 **** data = data + frag.build() return data ! def append(self, frag): self.fragments.append(frag) --- 93,97 ---- data = data + frag.build() return data ! def append(self, frag): self.fragments.append(frag) *************** *** 99,115 **** class FragmentDescriptor: ! def __init__(self, path, data = None): self.path = path if data is not None: self.parse(data) ! def parse(self, data): self.architecture = data[:4] ! ( self.updatelevel, ! self.currentVersion, ! self.oldDefVersion, self.stacksize, ! self.applibdir, self.fragtype, self.where, --- 99,115 ---- class FragmentDescriptor: ! def __init__(self, path, data = None): self.path = path if data is not None: self.parse(data) ! def parse(self, data): self.architecture = data[:4] ! ( self.updatelevel, ! self.currentVersion, ! self.oldDefVersion, self.stacksize, ! self.applibdir, self.fragtype, self.where, *************** *** 120,132 **** pname = data[42:self.memberSize] self.name = pname[1:1+ord(pname[0])] ! def build(self): data = self.architecture data = data + struct.pack("4lhBB4l", ! self.updatelevel, ! self.currentVersion, ! self.oldDefVersion, self.stacksize, ! self.applibdir, self.fragtype, self.where, --- 120,132 ---- pname = data[42:self.memberSize] self.name = pname[1:1+ord(pname[0])] ! def build(self): data = self.architecture data = data + struct.pack("4lhBB4l", ! self.updatelevel, ! self.currentVersion, ! self.oldDefVersion, self.stacksize, ! self.applibdir, self.fragtype, self.where, *************** *** 142,146 **** data = data + '\000' * (self.memberSize - len(data)) return data ! def getfragment(self): if self.where <> 1: --- 142,146 ---- data = data + '\000' * (self.memberSize - len(data)) return data ! def getfragment(self): if self.where <> 1: *************** *** 154,158 **** f.close() return frag ! def copydata(self, outfile): if self.where <> 1: --- 154,158 ---- f.close() return frag ! def copydata(self, outfile): if self.where <> 1: *************** *** 162,169 **** infile.seek(0, 2) self.length = infile.tell() ! # Position input file and record new offset from output file infile.seek(self.offset) ! # pad to 16 byte boundaries offset = outfile.tell() --- 162,169 ---- infile.seek(0, 2) self.length = infile.tell() ! # Position input file and record new offset from output file infile.seek(self.offset) ! # pad to 16 byte boundaries offset = outfile.tell() *************** *** 172,176 **** outfile.seek(offset) self.offset = offset ! l = self.length while l: --- 172,176 ---- outfile.seek(offset) self.offset = offset ! l = self.length while l: *************** *** 182,184 **** l = 0 infile.close() - --- 182,183 ---- Index: findertools.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/findertools.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** findertools.py 9 Apr 2003 13:25:42 -0000 1.4 --- findertools.py 18 Jul 2004 06:14:45 -0000 1.5 *************** *** 35,42 **** if not _finder_talker: _finder_talker = Finder.Finder() ! _finder_talker.send_flags = ( _finder_talker.send_flags | AppleEvents.kAECanInteract | AppleEvents.kAECanSwitchLayer) return _finder_talker ! def launch(file): """Open a file thru the finder. Specify file by name or fsspec""" --- 35,42 ---- if not _finder_talker: _finder_talker = Finder.Finder() ! _finder_talker.send_flags = ( _finder_talker.send_flags | AppleEvents.kAECanInteract | AppleEvents.kAECanSwitchLayer) return _finder_talker ! def launch(file): """Open a file thru the finder. Specify file by name or fsspec""" *************** *** 44,48 **** fss = Carbon.File.FSSpec(file) return finder.open(fss) ! def Print(file): """Print a file thru the finder. Specify file by name or fsspec""" --- 44,48 ---- fss = Carbon.File.FSSpec(file) return finder.open(fss) ! def Print(file): """Print a file thru the finder. Specify file by name or fsspec""" *************** *** 50,54 **** fss = Carbon.File.FSSpec(file) return finder._print(fss) ! def copy(src, dstdir): """Copy a file to a folder""" --- 50,54 ---- fss = Carbon.File.FSSpec(file) return finder._print(fss) ! def copy(src, dstdir): """Copy a file to a folder""" *************** *** 74,88 **** dst_fss = Carbon.File.FSSpec(dstdir) return finder.move(src_fss, to=dst_fss) ! def sleep(): """Put the mac to sleep""" finder = _getfinder() finder.sleep() ! def shutdown(): """Shut the mac down""" finder = _getfinder() finder.shut_down() ! def restart(): """Restart the mac""" --- 74,88 ---- dst_fss = Carbon.File.FSSpec(dstdir) return finder.move(src_fss, to=dst_fss) ! def sleep(): """Put the mac to sleep""" finder = _getfinder() finder.sleep() ! def shutdown(): """Shut the mac down""" finder = _getfinder() finder.shut_down() ! def restart(): """Restart the mac""" *************** *** 101,105 **** file_alias = fsr.FSNewAliasMinimal() return finder.reveal(file_alias) ! def select(file): """select a file in the finder. Specify file by name, fsref or fsspec.""" --- 101,105 ---- file_alias = fsr.FSNewAliasMinimal() return finder.reveal(file_alias) ! def select(file): """select a file in the finder. Specify file by name, fsref or fsspec.""" *************** *** 108,114 **** file_alias = fsr.FSNewAliasMinimal() return finder.select(file_alias) ! def update(file): ! """Update the display of the specified object(s) to match their on-disk representation. Specify file by name, fsref or fsspec.""" finder = _getfinder() --- 108,114 ---- file_alias = fsr.FSNewAliasMinimal() return finder.select(file_alias) ! def update(file): ! """Update the display of the specified object(s) to match their on-disk representation. Specify file by name, fsref or fsspec.""" finder = _getfinder() *************** *** 130,134 **** else: return _setcomment(object_alias, comment) ! def _setcomment(object_alias, comment): finder = _getfinder() --- 130,134 ---- else: return _setcomment(object_alias, comment) ! def _setcomment(object_alias, comment): finder = _getfinder() *************** *** 220,228 **** return 1 return 0 ! def processinfo(processname): """Return an object with all process properties as attributes for processname. MacOS9""" p = _process() ! if processname == "Finder": p.partition = None --- 220,228 ---- return 1 return 0 ! def processinfo(processname): """Return an object with all process properties as attributes for processname. MacOS9""" p = _process() ! if processname == "Finder": p.partition = None *************** *** 239,243 **** p.hasscripting = _processproperty(processname, 'hscr') #Does the process have a scripting terminology, i.e., can it be scripted? return p ! def _processproperty(processname, property): """return the partition size and memory used for processname""" --- 239,243 ---- p.hasscripting = _processproperty(processname, 'hscr') #Does the process have a scripting terminology, i.e., can it be scripted? return p ! def _processproperty(processname, property): """return the partition size and memory used for processname""" *************** *** 257,261 **** #--------------------------------------------------- # Mess around with Finder windows. ! def openwindow(object): """Open a Finder window for object, Specify object by name or fsspec.""" --- 257,261 ---- #--------------------------------------------------- # Mess around with Finder windows. ! def openwindow(object): """Open a Finder window for object, Specify object by name or fsspec.""" *************** *** 272,276 **** if args.has_key('errn'): raise Error, aetools.decodeerror(args) ! def closewindow(object): """Close a Finder window for folder, Specify by path.""" --- 272,276 ---- if args.has_key('errn'): raise Error, aetools.decodeerror(args) ! def closewindow(object): """Close a Finder window for folder, Specify by path.""" *************** *** 296,300 **** return _getlocation(object_alias) return _setlocation(object_alias, pos) ! def _setlocation(object_alias, (x, y)): """_setlocation: Set the location of the icon for the object.""" --- 296,300 ---- return _getlocation(object_alias) return _setlocation(object_alias, pos) ! def _setlocation(object_alias, (x, y)): """_setlocation: Set the location of the icon for the object.""" *************** *** 310,314 **** raise Error, aetools.decodeerror(args) return (x,y) ! def _getlocation(object_alias): """_getlocation: get the location of the icon for the object.""" --- 310,314 ---- raise Error, aetools.decodeerror(args) return (x,y) ! def _getlocation(object_alias): """_getlocation: get the location of the icon for the object.""" *************** *** 335,339 **** index = 0 return _setlabel(object_alias, index) ! def _getlabel(object_alias): """label: Get the label for the object.""" --- 335,339 ---- index = 0 return _setlabel(object_alias, index) ! def _getlabel(object_alias): """label: Get the label for the object.""" *************** *** 379,383 **** return _getwindowview(folder_alias) return _setwindowview(folder_alias, view) ! def _setwindowview(folder_alias, view=0): """set the windowview""" --- 379,383 ---- return _getwindowview(folder_alias) return _setwindowview(folder_alias, view) ! def _setwindowview(folder_alias, view=0): """set the windowview""" *************** *** 391,401 **** _v = aetypes.Type('iimg') finder = _getfinder() ! aeobj_0 = aetypes.ObjectSpecifier(want = aetypes.Type('cfol'), form = 'alis', seld = folder_alias, fr=None) ! aeobj_1 = aetypes.ObjectSpecifier(want = aetypes.Type('prop'), form = 'prop', seld = aetypes.Type('cwnd'), fr=aeobj_0) ! aeobj_2 = aetypes.ObjectSpecifier(want = aetypes.Type('prop'), form = 'prop', seld = aetypes.Type('pvew'), fr=aeobj_1) ! aeobj_3 = aetypes.ObjectSpecifier(want = aetypes.Type('prop'), form = 'prop', seld = _v, fr=None) _code = 'core' --- 391,401 ---- _v = aetypes.Type('iimg') finder = _getfinder() ! aeobj_0 = aetypes.ObjectSpecifier(want = aetypes.Type('cfol'), form = 'alis', seld = folder_alias, fr=None) ! aeobj_1 = aetypes.ObjectSpecifier(want = aetypes.Type('prop'), form = 'prop', seld = aetypes.Type('cwnd'), fr=aeobj_0) ! aeobj_2 = aetypes.ObjectSpecifier(want = aetypes.Type('prop'), form = 'prop', seld = aetypes.Type('pvew'), fr=aeobj_1) ! aeobj_3 = aetypes.ObjectSpecifier(want = aetypes.Type('prop'), form = 'prop', seld = _v, fr=None) _code = 'core' *************** *** 438,442 **** return _getwindowsize(folder_alias) return _setwindowsize(folder_alias, size) ! def _setwindowsize(folder_alias, (w, h)): """Set the size of a Finder window for folder to (w, h)""" --- 438,442 ---- return _getwindowsize(folder_alias) return _setwindowsize(folder_alias, size) ! def _setwindowsize(folder_alias, (w, h)): """Set the size of a Finder window for folder to (w, h)""" *************** *** 449,455 **** aeobj_0 = aetypes.ObjectSpecifier(want=aetypes.Type('cfol'), form="alis", seld=folder_alias, fr=None) ! aeobj_1 = aetypes.ObjectSpecifier(want=aetypes.Type('prop'), form="prop", seld=aetypes.Type('cwnd'), fr=aeobj_0) ! aeobj_2 = aetypes.ObjectSpecifier(want=aetypes.Type('prop'), form="prop", seld=aetypes.Type('ptsz'), fr=aeobj_1) args['----'] = aeobj_2 --- 449,455 ---- aeobj_0 = aetypes.ObjectSpecifier(want=aetypes.Type('cfol'), form="alis", seld=folder_alias, fr=None) ! aeobj_1 = aetypes.ObjectSpecifier(want=aetypes.Type('prop'), form="prop", seld=aetypes.Type('cwnd'), fr=aeobj_0) ! aeobj_2 = aetypes.ObjectSpecifier(want=aetypes.Type('prop'), form="prop", seld=aetypes.Type('ptsz'), fr=aeobj_1) args['----'] = aeobj_2 *************** *** 459,463 **** raise Error, aetools.decodeerror(args) return (w, h) ! def _getwindowsize(folder_alias): """Set the size of a Finder window for folder to (w, h)""" --- 459,463 ---- raise Error, aetools.decodeerror(args) return (w, h) ! def _getwindowsize(folder_alias): """Set the size of a Finder window for folder to (w, h)""" *************** *** 465,473 **** args = {} attrs = {} ! aeobj_0 = aetypes.ObjectSpecifier(want=aetypes.Type('cfol'), form="alis", seld=folder_alias, fr=None) ! aeobj_1 = aetypes.ObjectSpecifier(want=aetypes.Type('prop'), form="prop", seld=aetypes.Type('cwnd'), fr=aeobj_0) ! aeobj_2 = aetypes.ObjectSpecifier(want=aetypes.Type('prop'), form="prop", seld=aetypes.Type('posn'), fr=aeobj_1) args['----'] = aeobj_2 --- 465,473 ---- args = {} attrs = {} ! aeobj_0 = aetypes.ObjectSpecifier(want=aetypes.Type('cfol'), form="alis", seld=folder_alias, fr=None) ! aeobj_1 = aetypes.ObjectSpecifier(want=aetypes.Type('prop'), form="prop", seld=aetypes.Type('cwnd'), fr=aeobj_0) ! aeobj_2 = aetypes.ObjectSpecifier(want=aetypes.Type('prop'), form="prop", seld=aetypes.Type('posn'), fr=aeobj_1) args['----'] = aeobj_2 *************** *** 489,493 **** pos = (pos.h, pos.v) return _setwindowposition(folder_alias, pos) ! def _setwindowposition(folder_alias, (x, y)): """Set the size of a Finder window for folder to (w, h).""" --- 489,493 ---- pos = (pos.h, pos.v) return _setwindowposition(folder_alias, pos) ! def _setwindowposition(folder_alias, (x, y)): """Set the size of a Finder window for folder to (w, h).""" *************** *** 495,503 **** args = {} attrs = {} ! aeobj_0 = aetypes.ObjectSpecifier(want=aetypes.Type('cfol'), form="alis", seld=folder_alias, fr=None) ! aeobj_1 = aetypes.ObjectSpecifier(want=aetypes.Type('prop'), form="prop", seld=aetypes.Type('cwnd'), fr=aeobj_0) ! aeobj_2 = aetypes.ObjectSpecifier(want=aetypes.Type('prop'), form="prop", seld=aetypes.Type('posn'), fr=aeobj_1) args['----'] = aeobj_2 --- 495,503 ---- args = {} attrs = {} ! aeobj_0 = aetypes.ObjectSpecifier(want=aetypes.Type('cfol'), form="alis", seld=folder_alias, fr=None) ! aeobj_1 = aetypes.ObjectSpecifier(want=aetypes.Type('prop'), form="prop", seld=aetypes.Type('cwnd'), fr=aeobj_0) ! aeobj_2 = aetypes.ObjectSpecifier(want=aetypes.Type('prop'), form="prop", seld=aetypes.Type('posn'), fr=aeobj_1) args['----'] = aeobj_2 *************** *** 514,522 **** args = {} attrs = {} ! aeobj_0 = aetypes.ObjectSpecifier(want=aetypes.Type('cfol'), form="alis", seld=folder_alias, fr=None) ! aeobj_1 = aetypes.ObjectSpecifier(want=aetypes.Type('prop'), form="prop", seld=aetypes.Type('cwnd'), fr=aeobj_0) ! aeobj_2 = aetypes.ObjectSpecifier(want=aetypes.Type('prop'), form="prop", seld=aetypes.Type('ptsz'), fr=aeobj_1) args['----'] = aeobj_2 --- 514,522 ---- args = {} attrs = {} ! aeobj_0 = aetypes.ObjectSpecifier(want=aetypes.Type('cfol'), form="alis", seld=folder_alias, fr=None) ! aeobj_1 = aetypes.ObjectSpecifier(want=aetypes.Type('prop'), form="prop", seld=aetypes.Type('cwnd'), fr=aeobj_0) ! aeobj_2 = aetypes.ObjectSpecifier(want=aetypes.Type('prop'), form="prop", seld=aetypes.Type('ptsz'), fr=aeobj_1) args['----'] = aeobj_2 *************** *** 537,541 **** return _geticon(object_alias) return _seticon(object_alias, icondata) ! def _geticon(object_alias): """get the icondata for object. Binary data of some sort.""" --- 537,541 ---- return _geticon(object_alias) return _seticon(object_alias, icondata) ! def _geticon(object_alias): """get the icondata for object. Binary data of some sort.""" *************** *** 543,549 **** args = {} attrs = {} ! aeobj_00 = aetypes.ObjectSpecifier(want=aetypes.Type('cobj'), form="alis", seld=object_alias, fr=None) ! aeobj_01 = aetypes.ObjectSpecifier(want=aetypes.Type('prop'), form="prop", seld=aetypes.Type('iimg'), fr=aeobj_00) args['----'] = aeobj_01 --- 543,549 ---- args = {} attrs = {} ! aeobj_00 = aetypes.ObjectSpecifier(want=aetypes.Type('cobj'), form="alis", seld=object_alias, fr=None) ! aeobj_01 = aetypes.ObjectSpecifier(want=aetypes.Type('prop'), form="prop", seld=aetypes.Type('iimg'), fr=aeobj_00) args['----'] = aeobj_01 *************** *** 559,565 **** args = {} attrs = {} ! aeobj_00 = aetypes.ObjectSpecifier(want=aetypes.Type('cobj'), form="alis", seld=object_alias, fr=None) ! aeobj_01 = aetypes.ObjectSpecifier(want=aetypes.Type('prop'), form="prop", seld=aetypes.Type('iimg'), fr=aeobj_00) args['----'] = aeobj_01 --- 559,565 ---- args = {} attrs = {} ! aeobj_00 = aetypes.ObjectSpecifier(want=aetypes.Type('cobj'), form="alis", seld=object_alias, fr=None) ! aeobj_01 = aetypes.ObjectSpecifier(want=aetypes.Type('prop'), form="prop", seld=aetypes.Type('iimg'), fr=aeobj_00) args['----'] = aeobj_01 *************** *** 574,578 **** #--------------------------------------------------- # Volumes and servers. ! def mountvolume(volume, server=None, username=None, password=None): """mount a volume, local or on a server on AppleTalk. --- 574,578 ---- #--------------------------------------------------- # Volumes and servers. ! def mountvolume(volume, server=None, username=None, password=None): """mount a volume, local or on a server on AppleTalk. *************** *** 599,603 **** """unmount a volume that's on the desktop""" putaway(volume) ! def putaway(object): """puth the object away, whereever it came from.""" --- 599,603 ---- """unmount a volume that's on the desktop""" putaway(volume) ! def putaway(object): """puth the object away, whereever it came from.""" *************** *** 676,680 **** status = 0 return status ! def movetotrash(path): """move the object to the trash""" --- 676,680 ---- status = 0 return status ! def movetotrash(path): """move the object to the trash""" *************** *** 767,771 **** print '\tSystem beep volume' for i in range(0, 7): ! volumelevel(i) MacOS.SysBeep() --- 767,771 ---- print '\tSystem beep volume' for i in range(0, 7): ! volumelevel(i) MacOS.SysBeep() *************** *** 806,810 **** s = 'This is a comment no one reads!' comment(f, s) # set the Finder comment ! def _test3(): print 'MacOS9 or better specific functions' --- 806,810 ---- s = 'This is a comment no one reads!' comment(f, s) # set the Finder comment ! def _test3(): print 'MacOS9 or better specific functions' *************** *** 814,818 **** for p in pr: print '\t', p ! # get attributes of the first process in the list print 'Attributes of the first process in the list:' --- 814,818 ---- for p in pr: print '\t', p ! # get attributes of the first process in the list print 'Attributes of the first process in the list:' *************** *** 830,832 **** _test2() _test3() - --- 830,831 ---- Index: gensuitemodule.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/gensuitemodule.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** gensuitemodule.py 12 Feb 2004 17:35:10 -0000 1.11 --- gensuitemodule.py 18 Jul 2004 06:14:45 -0000 1.12 *************** *** 32,36 **** sys.stderr.write("Usage: %s [opts] application-or-resource-file\n" % sys.argv[0]) sys.stderr.write("""Options: ! --output pkgdir Pathname of the output package (short: -o) --resource Parse resource file in stead of launching application (-r) --base package Use another base package in stead of default StdSuites (-b) --- 32,36 ---- sys.stderr.write("Usage: %s [opts] application-or-resource-file\n" % sys.argv[0]) sys.stderr.write("""Options: ! --output pkgdir Pathname of the output package (short: -o) --resource Parse resource file in stead of launching application (-r) --base package Use another base package in stead of default StdSuites (-b) *************** *** 50,54 **** except getopt.GetoptError: usage() ! process_func = processfile basepkgname = 'StdSuites' --- 50,54 ---- except getopt.GetoptError: usage() ! process_func = processfile basepkgname = 'StdSuites' *************** *** 58,62 **** dump = None verbose = None ! for o, a in opts: if o in ('-r', '--resource'): --- 58,62 ---- dump = None verbose = None ! for o, a in opts: if o in ('-r', '--resource'): *************** *** 80,96 **** if o in ('-v', '--verbose'): verbose = sys.stderr ! ! if output and len(args) > 1: sys.stderr.write("%s: cannot specify --output with multiple inputs\n" % sys.argv[0]) sys.exit(1) ! for filename in args: ! process_func(filename, output=output, basepkgname=basepkgname, edit_modnames=edit_modnames, creatorsignature=creatorsignature, dump=dump, verbose=verbose) else: main_interactive() ! def main_interactive(interact=0, basepkgname='StdSuites'): if interact: --- 80,96 ---- if o in ('-v', '--verbose'): verbose = sys.stderr ! ! if output and len(args) > 1: sys.stderr.write("%s: cannot specify --output with multiple inputs\n" % sys.argv[0]) sys.exit(1) ! for filename in args: ! process_func(filename, output=output, basepkgname=basepkgname, edit_modnames=edit_modnames, creatorsignature=creatorsignature, dump=dump, verbose=verbose) else: main_interactive() ! def main_interactive(interact=0, basepkgname='StdSuites'): if interact: *************** *** 120,124 **** processfile_fromresource(filename, edit_modnames=edit_modnames, basepkgname=basepkgname, verbose=sys.stderr) ! def is_scriptable(application): """Return true if the application is scriptable""" --- 120,124 ---- processfile_fromresource(filename, edit_modnames=edit_modnames, basepkgname=basepkgname, verbose=sys.stderr) ! def is_scriptable(application): """Return true if the application is scriptable""" *************** *** 142,146 **** return n_terminology > 0 ! def processfile_fromresource(fullname, output=None, basepkgname=None, edit_modnames=None, creatorsignature=None, dump=None, verbose=None): """Process all resources in a single file""" --- 142,146 ---- return n_terminology > 0 ! def processfile_fromresource(fullname, output=None, basepkgname=None, edit_modnames=None, creatorsignature=None, dump=None, verbose=None): """Process all resources in a single file""" *************** *** 160,164 **** res = Get1IndResource('aeut', 1+i) resources.append(res) ! if verbose: print >>verbose, "\nLISTING aete+aeut RESOURCES IN", repr(fullname) aetelist = [] --- 160,164 ---- res = Get1IndResource('aeut', 1+i) resources.append(res) ! if verbose: print >>verbose, "\nLISTING aete+aeut RESOURCES IN", repr(fullname) aetelist = [] *************** *** 177,185 **** if dump: dumpaetelist(aetelist, dump) ! compileaetelist(aetelist, fullname, output=output, basepkgname=basepkgname, edit_modnames=edit_modnames, creatorsignature=creatorsignature, verbose=verbose) ! def processfile(fullname, output=None, basepkgname=None, edit_modnames=None, creatorsignature=None, dump=None, verbose=None): --- 177,185 ---- if dump: dumpaetelist(aetelist, dump) ! compileaetelist(aetelist, fullname, output=output, basepkgname=basepkgname, edit_modnames=edit_modnames, creatorsignature=creatorsignature, verbose=verbose) ! def processfile(fullname, output=None, basepkgname=None, edit_modnames=None, creatorsignature=None, dump=None, verbose=None): *************** *** 205,209 **** print >>verbose, "Launched", fullname raw = aetools.unpack(aedescobj) ! if not raw: if verbose: print >>verbose, 'Unpack returned empty value:', raw --- 205,209 ---- print >>verbose, "Launched", fullname raw = aetools.unpack(aedescobj) ! if not raw: if verbose: print >>verbose, 'Unpack returned empty value:', raw *************** *** 219,225 **** return compileaete(aete, None, fullname, output=output, basepkgname=basepkgname, ! creatorsignature=creatorsignature, edit_modnames=edit_modnames, verbose=verbose) ! def getappterminology(fullname, verbose=None): """Get application terminology by sending an AppleEvent""" --- 219,225 ---- return compileaete(aete, None, fullname, output=output, basepkgname=basepkgname, ! creatorsignature=creatorsignature, edit_modnames=edit_modnames, verbose=verbose) ! def getappterminology(fullname, verbose=None): """Get application terminology by sending an AppleEvent""" *************** *** 252,261 **** # Now pick the bits out of the return that we need. return reply[1]['----'], cr - ! def compileaetelist(aetelist, fullname, output=None, basepkgname=None, edit_modnames=None, creatorsignature=None, verbose=None): for aete, resinfo in aetelist: ! compileaete(aete, resinfo, fullname, output=output, basepkgname=basepkgname, edit_modnames=edit_modnames, creatorsignature=creatorsignature, verbose=verbose) --- 252,261 ---- # Now pick the bits out of the return that we need. return reply[1]['----'], cr ! ! def compileaetelist(aetelist, fullname, output=None, basepkgname=None, edit_modnames=None, creatorsignature=None, verbose=None): for aete, resinfo in aetelist: ! compileaete(aete, resinfo, fullname, output=output, basepkgname=basepkgname, edit_modnames=edit_modnames, creatorsignature=creatorsignature, verbose=verbose) *************** *** 264,268 **** import pprint pprint.pprint(aetelist, output) ! def decode(data, verbose=None): """Decode a resource into a python data structure""" --- 264,268 ---- import pprint pprint.pprint(aetelist, output) ! def decode(data, verbose=None): """Decode a resource into a python data structure""" *************** *** 428,432 **** ] ! def compileaete(aete, resinfo, fname, output=None, basepkgname=None, edit_modnames=None, creatorsignature=None, verbose=None): """Generate code for a full aete resource. fname passed for doc purposes""" --- 428,432 ---- ] ! def compileaete(aete, resinfo, fname, output=None, basepkgname=None, edit_modnames=None, creatorsignature=None, verbose=None): """Generate code for a full aete resource. fname passed for doc purposes""" *************** *** 501,505 **** for code, modname in suitelist: fp.write("from %s import *\n"%modname) ! # Generate property dicts and element dicts for all types declared in this module fp.write("\ndef getbaseclasses(v):\n") --- 501,505 ---- for code, modname in suitelist: fp.write("from %s import *\n"%modname) ! # Generate property dicts and element dicts for all types declared in this module fp.write("\ndef getbaseclasses(v):\n") *************** *** 535,539 **** fp.write("}\n") ! if suitelist: fp.write("\n\nclass %s(%s_Events"%(packagename, suitelist[0][1])) --- 535,539 ---- fp.write("}\n") ! if suitelist: fp.write("\n\nclass %s(%s_Events"%(packagename, suitelist[0][1])) *************** *** 555,568 **** self.output = output self.verbose = verbose ! # Set by precompilesuite self.pathname = None self.modname = None ! # Set by compilesuite self.fp = None self.basemodule = None self.enumsneeded = {} ! def precompilesuite(self): """Parse a single suite without generating the output. This step is needed --- 555,568 ---- self.output = output self.verbose = verbose ! # Set by precompilesuite self.pathname = None self.modname = None ! # Set by compilesuite self.fp = None self.basemodule = None self.enumsneeded = {} ! def precompilesuite(self): """Parse a single suite without generating the output. This step is needed *************** *** 570,574 **** in other suites""" [name, desc, code, level, version, events, classes, comps, enums] = self.suite ! modname = identify(name) if len(modname) > 28: --- 570,574 ---- in other suites""" [name, desc, code, level, version, events, classes, comps, enums] = self.suite ! modname = identify(name) if len(modname) > 28: *************** *** 587,593 **** if not self.pathname: return None, None, None ! self.modname = os.path.splitext(os.path.split(self.pathname)[1])[0] ! if self.basepackage and self.basepackage._code_to_module.has_key(code): # We are an extension of a baseclass (usually an application extending --- 587,593 ---- if not self.pathname: return None, None, None ! self.modname = os.path.splitext(os.path.split(self.pathname)[1])[0] ! if self.basepackage and self.basepackage._code_to_module.has_key(code): # We are an extension of a baseclass (usually an application extending *************** *** 597,605 **** # We are not an extension. basemodule = None ! self.enumsneeded = {} for event in events: self.findenumsinevent(event) ! objc = ObjectCompiler(None, self.modname, basemodule, interact=(self.edit_modnames is None), verbose=self.verbose) --- 597,605 ---- # We are not an extension. basemodule = None ! self.enumsneeded = {} for event in events: self.findenumsinevent(event) ! objc = ObjectCompiler(None, self.modname, basemodule, interact=(self.edit_modnames is None), verbose=self.verbose) *************** *** 612,625 **** for enum in enums: objc.compileenumeration(enum) ! for enum in self.enumsneeded.keys(): objc.checkforenum(enum) ! objc.dumpindex() ! precompinfo = objc.getprecompinfo(self.modname) ! return code, self.modname, precompinfo ! def compilesuite(self, major, minor, language, script, fname, precompinfo): """Generate code for a single suite""" --- 612,625 ---- for enum in enums: objc.compileenumeration(enum) ! for enum in self.enumsneeded.keys(): objc.checkforenum(enum) ! objc.dumpindex() ! precompinfo = objc.getprecompinfo(self.modname) ! return code, self.modname, precompinfo ! def compilesuite(self, major, minor, language, script, fname, precompinfo): """Generate code for a single suite""" *************** *** 638,650 **** return 1 return 0 ! events.sort() classes.sort(class_sorter) comps.sort() enums.sort() ! self.fp = fp = open(self.pathname, 'w') MacOS.SetCreatorAndType(self.pathname, 'Pyth', 'TEXT') ! fp.write('"""Suite %s: %s\n' % (ascii(name), ascii(desc))) fp.write("Level %d, version %d\n\n" % (level, version)) --- 638,650 ---- return 1 return 0 ! events.sort() classes.sort(class_sorter) comps.sort() enums.sort() ! self.fp = fp = open(self.pathname, 'w') MacOS.SetCreatorAndType(self.pathname, 'Pyth', 'TEXT') ! fp.write('"""Suite %s: %s\n' % (ascii(name), ascii(desc))) fp.write("Level %d, version %d\n\n" % (level, version)) *************** *** 653,657 **** (major, minor, language, script)) fp.write('"""\n\n') ! fp.write('import aetools\n') fp.write('import MacOS\n\n') --- 653,657 ---- (major, minor, language, script)) fp.write('"""\n\n') ! fp.write('import aetools\n') fp.write('import MacOS\n\n') *************** *** 671,675 **** self.basemodule = basemodule self.compileclassheader() ! self.enumsneeded = {} if events: --- 671,675 ---- self.basemodule = basemodule self.compileclassheader() ! self.enumsneeded = {} if events: *************** *** 678,682 **** else: fp.write(" pass\n\n") ! objc = ObjectCompiler(fp, self.modname, basemodule, precompinfo, interact=(self.edit_modnames is None), verbose=self.verbose) --- 678,682 ---- else: fp.write(" pass\n\n") ! objc = ObjectCompiler(fp, self.modname, basemodule, precompinfo, interact=(self.edit_modnames is None), verbose=self.verbose) *************** *** 689,698 **** for enum in enums: objc.compileenumeration(enum) ! for enum in self.enumsneeded.keys(): objc.checkforenum(enum) ! objc.dumpindex() ! def compileclassheader(self): """Generate class boilerplate""" --- 689,698 ---- for enum in enums: objc.compileenumeration(enum) ! for enum in self.enumsneeded.keys(): objc.checkforenum(enum) ! objc.dumpindex() ! def compileclassheader(self): """Generate class boilerplate""" *************** *** 704,708 **** else: self.fp.write("class %s:\n\n"%classname) ! def compileevent(self, event): """Generate code for a single event""" --- 704,708 ---- else: self.fp.write("class %s:\n\n"%classname) ! def compileevent(self, event): """Generate code for a single event""" *************** *** 718,722 **** fp.write(" %r : %r,\n"%(identify(a[0]), a[1])) fp.write(" }\n\n") ! # # Generate function header --- 718,722 ---- fp.write(" %r : %r,\n"%(identify(a[0]), a[1])) fp.write(" }\n\n") ! # # Generate function header *************** *** 724,728 **** has_arg = (not is_null(accepts)) opt_arg = (has_arg and is_optional(accepts)) ! fp.write(" def %s(self, "%funcname) if has_arg: --- 724,728 ---- has_arg = (not is_null(accepts)) opt_arg = (has_arg and is_optional(accepts)) ! fp.write(" def %s(self, "%funcname) if has_arg: *************** *** 804,808 **** fp.write(" return _arguments['----']\n") fp.write("\n") ! def findenumsinevent(self, event): """Find all enums for a single event""" --- 804,808 ---- fp.write(" return _arguments['----']\n") fp.write("\n") ! def findenumsinevent(self, event): """Find all enums for a single event""" *************** *** 813,817 **** if ename <> '****': self.enumsneeded[ename] = 1 ! # # This class stores the code<->name translations for a single module. It is used --- 813,817 ---- if ename <> '****': self.enumsneeded[ename] = 1 ! # # This class stores the code<->name translations for a single module. It is used *************** *** 822,826 **** # class CodeNameMapper: ! def __init__(self, interact=1, verbose=None): self.code2name = { --- 822,826 ---- # class CodeNameMapper: ! def __init__(self, interact=1, verbose=None): self.code2name = { *************** *** 840,849 **** self.can_interact = interact self.verbose = verbose ! def addnamecode(self, type, name, code): self.name2code[type][name] = code if not self.code2name[type].has_key(code): self.code2name[type][code] = name ! def hasname(self, name): for dict in self.name2code.values(): --- 840,849 ---- self.can_interact = interact self.verbose = verbose ! def addnamecode(self, type, name, code): self.name2code[type][name] = code if not self.code2name[type].has_key(code): self.code2name[type][code] = name ! def hasname(self, name): for dict in self.name2code.values(): *************** *** 851,858 **** return True return False ! def hascode(self, type, code): return self.code2name[type].has_key(code) ! def findcodename(self, type, code): if not self.hascode(type, code): --- 851,858 ---- return True return False ! def hascode(self, type, code): return self.code2name[type].has_key(code) ! def findcodename(self, type, code): if not self.hascode(type, code): *************** *** 864,871 **** qualname = name return name, qualname, self.modulename ! def getall(self, type): return self.code2name[type].items() ! def addmodule(self, module, name, star_imported): self.modulename = name --- 864,871 ---- qualname = name return name, qualname, self.modulename ! def getall(self, type): return self.code2name[type].items() ! def addmodule(self, module, name, star_imported): self.modulename = name *************** *** 879,890 **** for code, name in module._compdeclarations.items(): self.addnamecode('comparison', name, code) ! def prepareforexport(self, name=None): if not self.modulename: self.modulename = name return self ! class ObjectCompiler: ! def __init__(self, fp, modname, basesuite, othernamemappers=None, interact=1, verbose=None): self.fp = fp --- 879,890 ---- for code, name in module._compdeclarations.items(): self.addnamecode('comparison', name, code) ! def prepareforexport(self, name=None): if not self.modulename: self.modulename = name return self ! class ObjectCompiler: ! def __init__(self, fp, modname, basesuite, othernamemappers=None, interact=1, verbose=None): self.fp = fp *************** *** 902,906 **** basemapper.addmodule(basesuite, '', 1) self.namemappers.append(basemapper) ! def getprecompinfo(self, modname): list = [] --- 902,906 ---- basemapper.addmodule(basesuite, '', 1) self.namemappers.append(basemapper) ! def getprecompinfo(self, modname): list = [] *************** *** 910,914 **** list.append(emapper) return list ! def findcodename(self, type, code): while 1: --- 910,914 ---- list.append(emapper) return list ! def findcodename(self, type, code): while 1: *************** *** 936,940 **** mapper.addmodule(m, m.__name__, 0) self.namemappers.append(mapper) ! def hasname(self, name): for mapper in self.othernamemappers: --- 936,940 ---- mapper.addmodule(m, m.__name__, 0) self.namemappers.append(mapper) ! def hasname(self, name): for mapper in self.othernamemappers: *************** *** 944,948 **** return True return False ! def askdefinitionmodule(self, type, code): if not self.can_interact: --- 944,948 ---- return True return False ! def askdefinitionmodule(self, type, code): if not self.can_interact: *************** *** 959,963 **** self.fp.write("import %s\n"%modname) return m ! def compileclass(self, cls): [name, code, desc, properties, elements] = cls --- 959,963 ---- self.fp.write("import %s\n"%modname) return m ! def compileclass(self, cls): [name, code, desc, properties, elements] = cls *************** *** 981,985 **** for elem in elements: self.compileelement(elem) ! def compileproperty(self, prop, is_application_class=False): [name, code, what] = prop --- 981,985 ---- for elem in elements: self.compileelement(elem) ! def compileproperty(self, prop, is_application_class=False): [name, code, what] = prop *************** *** 1004,1008 **** if is_application_class and self.fp: self.fp.write("%s = _Prop_%s()\n" % (pname, pname)) ! def compileelement(self, elem): [code, keyform] = elem --- 1004,1008 ---- if is_application_class and self.fp: self.fp.write("%s = _Prop_%s()\n" % (pname, pname)) ! def compileelement(self, elem): [code, keyform] = elem *************** *** 1057,1064 **** else: elist.append((name, ename)) ! plist.sort() elist.sort() ! if self.fp: self.fp.write("%s._privpropdict = {\n"%cname) --- 1057,1064 ---- else: elist.append((name, ename)) ! plist.sort() elist.sort() ! if self.fp: self.fp.write("%s._privpropdict = {\n"%cname) *************** *** 1070,1074 **** self.fp.write(" '%s' : %s,\n"%(n, fulln)) self.fp.write("}\n") ! def compilecomparison(self, comp): [name, code, comment] = comp --- 1070,1074 ---- self.fp.write(" '%s' : %s,\n"%(n, fulln)) self.fp.write("}\n") ! def compilecomparison(self, comp): [name, code, comment] = comp *************** *** 1078,1082 **** self.fp.write("class %s(aetools.NComparison):\n" % iname) self.fp.write(' """%s - %s """\n' % (ascii(name), ascii(comment))) ! def compileenumeration(self, enum): [code, items] = enum --- 1078,1082 ---- self.fp.write("class %s(aetools.NComparison):\n" % iname) self.fp.write(' """%s - %s """\n' % (ascii(name), ascii(comment))) ! def compileenumeration(self, enum): [code, items] = enum *************** *** 1089,1097 **** self.namemappers[0].addnamecode('enum', name, code) return code ! def compileenumerator(self, item): [name, code, desc] = item self.fp.write(" %r : %r,\t# %s\n" % (identify(name), code, ascii(desc))) ! def checkforenum(self, enum): """This enum code is used by an event. Make sure it's available""" --- 1089,1097 ---- self.namemappers[0].addnamecode('enum', name, code) return code ! def compileenumerator(self, item): [name, code, desc] = item self.fp.write(" %r : %r,\t# %s\n" % (identify(name), code, ascii(desc))) ! def checkforenum(self, enum): """This enum code is used by an event. Make sure it's available""" *************** *** 1104,1113 **** if self.fp: self.fp.write("from %s import %s\n"%(module, name)) ! def dumpindex(self): if not self.fp: return self.fp.write("\n#\n# Indices of types declared in this module\n#\n") ! self.fp.write("_classdeclarations = {\n") classlist = self.namemappers[0].getall('class') --- 1104,1113 ---- if self.fp: self.fp.write("from %s import %s\n"%(module, name)) ! def dumpindex(self): if not self.fp: return self.fp.write("\n#\n# Indices of types declared in this module\n#\n") ! self.fp.write("_classdeclarations = {\n") classlist = self.namemappers[0].getall('class') *************** *** 1116,1120 **** self.fp.write(" %r : %s,\n" % (k, v)) self.fp.write("}\n") ! self.fp.write("\n_propdeclarations = {\n") proplist = self.namemappers[0].getall('property') --- 1116,1120 ---- self.fp.write(" %r : %s,\n" % (k, v)) self.fp.write("}\n") ! self.fp.write("\n_propdeclarations = {\n") proplist = self.namemappers[0].getall('property') *************** *** 1123,1127 **** self.fp.write(" %r : _Prop_%s,\n" % (k, v)) self.fp.write("}\n") ! self.fp.write("\n_compdeclarations = {\n") complist = self.namemappers[0].getall('comparison') --- 1123,1127 ---- self.fp.write(" %r : _Prop_%s,\n" % (k, v)) self.fp.write("}\n") ! self.fp.write("\n_compdeclarations = {\n") complist = self.namemappers[0].getall('comparison') *************** *** 1130,1134 **** self.fp.write(" %r : %s,\n" % (k, v)) self.fp.write("}\n") ! self.fp.write("\n_enumdeclarations = {\n") enumlist = self.namemappers[0].getall('enum') --- 1130,1134 ---- self.fp.write(" %r : %s,\n" % (k, v)) self.fp.write("}\n") ! self.fp.write("\n_enumdeclarations = {\n") enumlist = self.namemappers[0].getall('enum') *************** *** 1141,1154 **** [type, description, flags] = data return "%r -- %r %s" % (type, description, compiledataflags(flags)) ! def is_null(data): return data[0] == 'null' ! def is_optional(data): return (data[2] & 0x8000) ! def is_enum(data): return (data[2] & 0x2000) ! def getdatadoc(data): [type, descr, flags] = data --- 1141,1154 ---- [type, description, flags] = data return "%r -- %r %s" % (type, description, compiledataflags(flags)) ! def is_null(data): return data[0] == 'null' ! def is_optional(data): return (data[2] & 0x8000) ! def is_enum(data): return (data[2] & 0x2000) ! def getdatadoc(data): [type, descr, flags] = data *************** *** 1171,1175 **** bits.append(repr(i)) return '[%s]' % string.join(bits) ! def ascii(str): """Return a string with all non-ascii characters hex-encoded""" --- 1171,1175 ---- bits.append(repr(i)) return '[%s]' % string.join(bits) ! def ascii(str): """Return a string with all non-ascii characters hex-encoded""" *************** *** 1183,1187 **** rv = rv + '\\' + 'x%02.2x' % ord(c) return rv ! def identify(str): """Turn any string into an identifier: --- 1183,1187 ---- rv = rv + '\\' + 'x%02.2x' % ord(c) return rv ! def identify(str): """Turn any string into an identifier: Index: ic.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/ic.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** ic.py 12 Feb 2004 17:35:10 -0000 1.6 --- ic.py 18 Jul 2004 06:14:45 -0000 1.7 *************** *** 39,43 **** _ICOpaqueDataType=type(ICOpaqueData('')) ! def _decode_default(data, key): if len(data) == 0: --- 39,43 ---- _ICOpaqueDataType=type(ICOpaqueData('')) ! def _decode_default(data, key): if len(data) == 0: *************** *** 47,52 **** return data[1:] return ICOpaqueData(data) ! ! def _decode_multistr(data, key): numstr = ord(data[0]) << 8 | ord(data[1]) --- 47,52 ---- return data[1:] return ICOpaqueData(data) ! ! def _decode_multistr(data, key): numstr = ord(data[0]) << 8 | ord(data[1]) *************** *** 59,63 **** ptr = ptr + strlen + 1 return rv ! def _decode_fontrecord(data, key): size = ord(data[0]) << 8 | ord(data[1]) --- 59,63 ---- ptr = ptr + strlen + 1 return rv ! def _decode_fontrecord(data, key): size = ord(data[0]) << 8 | ord(data[1]) *************** *** 65,78 **** namelen = ord(data[4]) return size, face, data[5:5+namelen] ! def _decode_boolean(data, key): return ord(data[0]) ! def _decode_text(data, key): return data ! def _decode_charset(data, key): return data[:256], data[256:] ! def _decode_appspec(data, key): namelen = ord(data[4]) --- 65,78 ---- namelen = ord(data[4]) return size, face, data[5:5+namelen] ! def _decode_boolean(data, key): return ord(data[0]) ! def _decode_text(data, key): return data ! def _decode_charset(data, key): return data[:256], data[256:] ! def _decode_appspec(data, key): namelen = ord(data[4]) *************** *** 81,85 **** def _code_default(data, key): return chr(len(data)) + data ! def _code_multistr(data, key): numstr = len(data) --- 81,85 ---- def _code_default(data, key): return chr(len(data)) + data ! def _code_multistr(data, key): numstr = len(data) *************** *** 88,110 **** rv = rv + _code_default(i) return rv ! def _code_fontrecord(data, key): size, face, name = data return chr((size>>8) & 0xff) + chr(size & 0xff) + chr(face & 0xff) + \ chr(0) + _code_default(name) ! def _code_boolean(data, key): print 'XXXX boolean:', repr(data) return chr(data) ! def _code_text(data, key): return data ! def _code_charset(data, key): return data[0] + data[1] ! def _code_appspec(data, key): return data[0] + _code_default(data[1]) ! _decoder_table = { "ArchieAll" : (_decode_multistr , _code_multistr), --- 88,110 ---- rv = rv + _code_default(i) return rv ! def _code_fontrecord(data, key): size, face, name = data return chr((size>>8) & 0xff) + chr(size & 0xff) + chr(face & 0xff) + \ chr(0) + _code_default(name) ! def _code_boolean(data, key): print 'XXXX boolean:', repr(data) return chr(data) ! def _code_text(data, key): return data ! def _code_charset(data, key): return data[0] + data[1] ! def _code_appspec(data, key): return data[0] + _code_default(data[1]) ! _decoder_table = { "ArchieAll" : (_decode_multistr , _code_multistr), *************** *** 119,123 **** "MailHeaders" : (_decode_text , _code_text), "NewsHeaders" : (_decode_text , _code_text), ! # "Mapping" "CharacterSet" : (_decode_charset , _code_charset), "Helper\245" : (_decode_appspec , _code_appspec), --- 119,123 ---- "MailHeaders" : (_decode_text , _code_text), "NewsHeaders" : (_decode_text , _code_text), ! # "Mapping" "CharacterSet" : (_decode_charset , _code_charset), "Helper\245" : (_decode_appspec , _code_appspec), *************** *** 157,161 **** coder = _code_default return coder(data, key) ! class IC: def __init__(self, signature='Pyth', ic=None): --- 157,161 ---- coder = _code_default return coder(data, key) ! class IC: def __init__(self, signature='Pyth', ic=None): *************** *** 167,171 **** self.ic.ICFindConfigFile() self.h = Res.Resource('') ! def keys(self): rv = [] --- 167,171 ---- self.ic.ICFindConfigFile() self.h = Res.Resource('') ! def keys(self): rv = [] *************** *** 176,183 **** self.ic.ICEnd() return rv ! def has_key(self, key): return self.__contains__(key) ! def __contains__(self, key): try: --- 176,183 ---- self.ic.ICEnd() return rv ! def has_key(self, key): return self.__contains__(key) ! def __contains__(self, key): try: *************** *** 186,198 **** return 0 return 1 ! def __getitem__(self, key): attr = self.ic.ICFindPrefHandle(key, self.h) return _decode(self.h.data, key) ! def __setitem__(self, key, value): value = _code(value, key) self.ic.ICSetPref(key, ICattr_no_change, value) ! def launchurl(self, url, hint=""): # Work around a bug in ICLaunchURL: file:/foo does --- 186,198 ---- return 0 return 1 ! def __getitem__(self, key): attr = self.ic.ICFindPrefHandle(key, self.h) return _decode(self.h.data, key) ! def __setitem__(self, key, value): value = _code(value, key) self.ic.ICSetPref(key, ICattr_no_change, value) ! def launchurl(self, url, hint=""): # Work around a bug in ICLaunchURL: file:/foo does *************** *** 201,205 **** url = 'file:///' + url[6:] self.ic.ICLaunchURL(hint, url, 0, len(url)) ! def parseurl(self, data, start=None, end=None, hint=""): if start == None: --- 201,205 ---- url = 'file:///' + url[6:] self.ic.ICLaunchURL(hint, url, 0, len(url)) ! def parseurl(self, data, start=None, end=None, hint=""): if start == None: *************** *** 212,224 **** selStart, selEnd = self.ic.ICParseURL(hint, data, selStart, selEnd, self.h) return self.h.data, selStart, selEnd ! def mapfile(self, file): if type(file) != type(''): file = file.as_tuple()[2] return self.ic.ICMapFilename(file) ! def maptypecreator(self, type, creator, filename=""): return self.ic.ICMapTypeCreator(type, creator, filename) ! def settypecreator(self, file): file = Carbon.File.pathname(file) --- 212,224 ---- selStart, selEnd = self.ic.ICParseURL(hint, data, selStart, selEnd, self.h) return self.h.data, selStart, selEnd ! def mapfile(self, file): if type(file) != type(''): file = file.as_tuple()[2] return self.ic.ICMapFilename(file) ! def maptypecreator(self, type, creator, filename=""): return self.ic.ICMapTypeCreator(type, creator, filename) ! def settypecreator(self, file): file = Carbon.File.pathname(file) *************** *** 226,230 **** MacOS.SetCreatorAndType(file, record[2], record[1]) macostools.touched(fss) ! # Convenience routines _dft_ic = None --- 226,230 ---- MacOS.SetCreatorAndType(file, record[2], record[1]) macostools.touched(fss) ! # Convenience routines _dft_ic = None *************** *** 234,258 **** if _dft_ic == None: _dft_ic = IC() return _dft_ic.launchurl(url, hint) ! def parseurl(data, start=None, end=None, hint=""): global _dft_ic if _dft_ic == None: _dft_ic = IC() return _dft_ic.parseurl(data, start, end, hint) ! def mapfile(filename): global _dft_ic if _dft_ic == None: _dft_ic = IC() return _dft_ic.mapfile(filename) ! def maptypecreator(type, creator, filename=""): global _dft_ic if _dft_ic == None: _dft_ic = IC() return _dft_ic.maptypecreator(type, creator, filename) ! def settypecreator(file): global _dft_ic if _dft_ic == None: _dft_ic = IC() return _dft_ic.settypecreator(file) ! def _test(): ic = IC() --- 234,258 ---- if _dft_ic == None: _dft_ic = IC() return _dft_ic.launchurl(url, hint) ! def parseurl(data, start=None, end=None, hint=""): global _dft_ic if _dft_ic == None: _dft_ic = IC() return _dft_ic.parseurl(data, start, end, hint) ! def mapfile(filename): global _dft_ic if _dft_ic == None: _dft_ic = IC() return _dft_ic.mapfile(filename) ! def maptypecreator(type, creator, filename=""): global _dft_ic if _dft_ic == None: _dft_ic = IC() return _dft_ic.maptypecreator(type, creator, filename) ! def settypecreator(file): global _dft_ic if _dft_ic == None: _dft_ic = IC() return _dft_ic.settypecreator(file) ! def _test(): ic = IC() *************** *** 264,269 **** print k, '\t', v sys.exit(1) ! if __name__ == '__main__': _test() - --- 264,268 ---- print k, '\t', v sys.exit(1) ! if __name__ == '__main__': _test() Index: icopen.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/icopen.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** icopen.py 6 Apr 2003 09:01:02 -0000 1.2 --- icopen.py 18 Jul 2004 06:14:45 -0000 1.3 *************** *** 43,58 **** def _open_with_typer(*args): ! file = _builtin_open(*args) ! filename = args[0] ! mode = 'r' ! if args[1:]: ! mode = args[1] ! if mode[0] == 'w': ! from ic import error, settypecreator ! try: ! settypecreator(filename) ! except error: ! pass ! return file __builtin__.open = _open_with_typer --- 43,58 ---- def _open_with_typer(*args): ! file = _builtin_open(*args) ! filename = args[0] ! mode = 'r' ! if args[1:]: ! mode = args[1] ! if mode[0] == 'w': ! from ic import error, settypecreator ! try: ! settypecreator(filename) ! except error: ! pass ! return file __builtin__.open = _open_with_typer Index: macfs.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/macfs.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** macfs.py 9 Apr 2003 13:25:43 -0000 1.10 --- macfs.py 18 Jul 2004 06:14:45 -0000 1.11 *************** *** 10,14 **** warnings.warn("macfs is deprecated, use Carbon.File, Carbon.Folder or EasyDialogs", DeprecationWarning, stacklevel=2) ! # First step: ensure we also emulate the MACFS module, which contained # all the constants --- 10,14 ---- warnings.warn("macfs is deprecated, use Carbon.File, Carbon.Folder or EasyDialogs", DeprecationWarning, stacklevel=2) ! # First step: ensure we also emulate the MACFS module, which contained # all the constants *************** *** 39,43 **** return (0, int(t), 0) else: ! def _utc2time(utc): t = utc[1] if t < 0: --- 39,43 ---- return (0, int(t), 0) else: ! def _utc2time(utc): t = utc[1] if t < 0: *************** *** 59,70 **** def as_fsref(self): return FSRef(self) ! def NewAlias(self, src=None): return Alias(Carbon.File.NewAlias(src, self)) ! def GetCreatorType(self): finfo = self.FSpGetFInfo() return finfo.Creator, finfo.Type ! def SetCreatorType(self, ctor, tp): finfo = self.FSpGetFInfo() --- 59,70 ---- def as_fsref(self): return FSRef(self) ! def NewAlias(self, src=None): return Alias(Carbon.File.NewAlias(src, self)) ! def GetCreatorType(self): finfo = self.FSpGetFInfo() return finfo.Creator, finfo.Type ! def SetCreatorType(self, ctor, tp): finfo = self.FSpGetFInfo() *************** *** 72,82 **** finfo.Type = tp self.FSpSetFInfo(finfo) ! def GetFInfo(self): return self.FSpGetFInfo() ! def SetFInfo(self, info): return self.FSpSetFInfo(info) ! def GetDates(self): catInfoFlags = kFSCatInfoCreateDate|kFSCatInfoContentMod|kFSCatInfoBackupDate --- 72,82 ---- finfo.Type = tp self.FSpSetFInfo(finfo) ! def GetFInfo(self): return self.FSpGetFInfo() ! def SetFInfo(self, info): return self.FSpSetFInfo(info) ! def GetDates(self): catInfoFlags = kFSCatInfoCreateDate|kFSCatInfoContentMod|kFSCatInfoBackupDate *************** *** 86,90 **** bdate = catinfo.backupDate return _utc2time(cdate), _utc2time(mdate), _utc2time(bdate) ! def SetDates(self, cdate, mdate, bdate): catInfoFlags = kFSCatInfoCreateDate|kFSCatInfoContentMod|kFSCatInfoBackupDate --- 86,90 ---- bdate = catinfo.backupDate return _utc2time(cdate), _utc2time(mdate), _utc2time(bdate) ! def SetDates(self, cdate, mdate, bdate): catInfoFlags = kFSCatInfoCreateDate|kFSCatInfoContentMod|kFSCatInfoBackupDate *************** *** 94,114 **** backupDate = _time2utc(bdate)) FSRef(self).FSSetCatalogInfo(catInfoFlags, catinfo) ! class FSRef(Carbon.File.FSRef): def as_fsspec(self): return FSSpec(self) ! class Alias(Carbon.File.Alias): def GetInfo(self, index): return self.GetAliasInfo(index) ! def Update(self, *args): pass # print "Alias.Update not yet implemented" ! def Resolve(self, src=None): fss, changed = self.ResolveAlias(src) return FSSpec(fss), changed ! from Carbon.File import FInfo --- 94,114 ---- backupDate = _time2utc(bdate)) FSRef(self).FSSetCatalogInfo(catInfoFlags, catinfo) ! class FSRef(Carbon.File.FSRef): def as_fsspec(self): return FSSpec(self) ! class Alias(Carbon.File.Alias): def GetInfo(self, index): return self.GetAliasInfo(index) ! def Update(self, *args): pass # print "Alias.Update not yet implemented" ! def Resolve(self, src=None): fss, changed = self.ResolveAlias(src) return FSSpec(fss), changed ! from Carbon.File import FInfo *************** *** 123,139 **** fss, isdir, isalias = Carbon.File.ResolveAliasFile(fss, chain) return FSSpec(fss), isdir, isalias ! def RawFSSpec(data): return FSSpec(rawdata=data) ! def RawAlias(data): return Alias(rawdata=data) ! def FindApplication(*args): raise NotImplementedError, "FindApplication no longer implemented" ! def NewAliasMinimalFromFullPath(path): return Alias(Carbon.File.NewAliasMinimalFromFullPath(path, '', '')) ! # Another global function: from Carbon.Folder import FindFolder --- 123,139 ---- fss, isdir, isalias = Carbon.File.ResolveAliasFile(fss, chain) return FSSpec(fss), isdir, isalias ! def RawFSSpec(data): return FSSpec(rawdata=data) ! def RawAlias(data): return Alias(rawdata=data) ! def FindApplication(*args): raise NotImplementedError, "FindApplication no longer implemented" ! def NewAliasMinimalFromFullPath(path): return Alias(Carbon.File.NewAliasMinimalFromFullPath(path, '', '')) ! # Another global function: from Carbon.Folder import FindFolder *************** *** 149,153 **** allowable""" return PromptGetFile('', *typelist) ! def PromptGetFile(prompt, *typelist): """Ask for an input file giving the user a prompt message. Optionally you can --- 149,153 ---- allowable""" return PromptGetFile('', *typelist) ! def PromptGetFile(prompt, *typelist): """Ask for an input file giving the user a prompt message. Optionally you can *************** *** 158,162 **** if not typelist: typelist = None ! fss = EasyDialogs.AskFileForOpen(message=prompt, wanted=FSSpec, typeList=typelist, defaultLocation=_handleSetFolder()) return fss, not fss is None --- 158,162 ---- if not typelist: typelist = None ! fss = EasyDialogs.AskFileForOpen(message=prompt, wanted=FSSpec, typeList=typelist, defaultLocation=_handleSetFolder()) return fss, not fss is None *************** *** 168,175 **** warnings.warn("macfs.StandardGetFile and friends are deprecated, use EasyDialogs.AskFileForOpen", DeprecationWarning, stacklevel=2) ! fss = EasyDialogs.AskFileForSave(wanted=FSSpec, message=prompt, savedFileName=default, defaultLocation=_handleSetFolder()) return fss, not fss is None ! def SetFolder(folder): global _curfolder --- 168,175 ---- warnings.warn("macfs.StandardGetFile and friends are deprecated, use EasyDialogs.AskFileForOpen", DeprecationWarning, stacklevel=2) ! fss = EasyDialogs.AskFileForSave(wanted=FSSpec, message=prompt, savedFileName=default, defaultLocation=_handleSetFolder()) return fss, not fss is None ! def SetFolder(folder): global _curfolder *************** *** 182,186 **** _curfolder = folder return rv ! def _handleSetFolder(): global _curfolder --- 182,186 ---- _curfolder = folder return rv ! def _handleSetFolder(): global _curfolder *************** *** 188,192 **** _curfolder = None return rv ! def GetDirectory(prompt=None): """Ask the user to select a folder. Optionally you can give a prompt.""" --- 188,192 ---- _curfolder = None return rv ! def GetDirectory(prompt=None): """Ask the user to select a folder. Optionally you can give a prompt.""" *************** *** 194,198 **** warnings.warn("macfs.StandardGetFile and friends are deprecated, use EasyDialogs.AskFileForOpen", DeprecationWarning, stacklevel=2) ! fss = EasyDialogs.AskFolder(message=prompt, wanted=FSSpec, defaultLocation=_handleSetFolder()) return fss, not fss is None --- 194,198 ---- warnings.warn("macfs.StandardGetFile and friends are deprecated, use EasyDialogs.AskFileForOpen", DeprecationWarning, stacklevel=2) ! fss = EasyDialogs.AskFolder(message=prompt, wanted=FSSpec, defaultLocation=_handleSetFolder()) return fss, not fss is None Index: macostools.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/macostools.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** macostools.py 7 Mar 2003 15:36:49 -0000 1.3 --- macostools.py 18 Jul 2004 06:14:45 -0000 1.4 *************** *** 42,47 **** else: alias = srcfsr.FSNewAliasMinimal() ! ! dstfsr, dstfss = Res.FSCreateResourceFile(dstdirfsr, unicode(dstname), File.FSGetResourceForkName()) h = Res.FSOpenResourceFile(dstfsr, File.FSGetResourceForkName(), 3) --- 42,47 ---- else: alias = srcfsr.FSNewAliasMinimal() ! ! dstfsr, dstfss = Res.FSCreateResourceFile(dstdirfsr, unicode(dstname), File.FSGetResourceForkName()) h = Res.FSOpenResourceFile(dstfsr, File.FSGetResourceForkName(), 3) *************** *** 49,57 **** resource.AddResource('alis', 0, '') Res.CloseResFile(h) ! dstfinfo = dstfss.FSpGetFInfo() dstfinfo.Flags = dstfinfo.Flags|0x8000 # Alias flag dstfss.FSpSetFInfo(dstfinfo) ! def mkdirs(dst): """Make directories leading to 'dst' if they don't exist yet""" --- 49,57 ---- resource.AddResource('alis', 0, '') Res.CloseResFile(h) ! dstfinfo = dstfss.FSpGetFInfo() dstfinfo.Flags = dstfinfo.Flags|0x8000 # Alias flag dstfss.FSpSetFInfo(dstfinfo) ! def mkdirs(dst): """Make directories leading to 'dst' if they don't exist yet""" *************** *** 63,67 **** mkdirs(head) os.mkdir(dst, 0777) ! def touched(dst): """Tell the finder a file has changed. No-op on MacOSX.""" --- 63,67 ---- mkdirs(head) os.mkdir(dst, 0777) ! def touched(dst): """Tell the finder a file has changed. No-op on MacOSX.""" *************** *** 81,85 **** except macfs.error: pass ! def touched_ae(dst): """Tell the finder a file has changed""" --- 81,85 ---- except macfs.error: pass ! def touched_ae(dst): """Tell the finder a file has changed""" *************** *** 90,94 **** f = Finder.Finder() f.update(File.FSRef(pardir)) ! def copy(src, dst, createpath=0, copydates=1, forcetype=None): """Copy a file, including finder info, resource fork, etc""" --- 90,94 ---- f = Finder.Finder() f.update(File.FSRef(pardir)) ! def copy(src, dst, createpath=0, copydates=1, forcetype=None): """Copy a file, including finder info, resource fork, etc""" *************** *** 97,101 **** if createpath: mkdirs(os.path.split(dst)[0]) ! ifp = open(src, 'rb') ofp = open(dst, 'wb') --- 97,101 ---- if createpath: mkdirs(os.path.split(dst)[0]) ! ifp = open(src, 'rb') ofp = open(dst, 'wb') *************** *** 106,110 **** ifp.close() ofp.close() ! ifp = openrf(src, '*rb') ofp = openrf(dst, '*wb') --- 106,110 ---- ifp.close() ofp.close() ! ifp = openrf(src, '*rb') ofp = openrf(dst, '*wb') *************** *** 115,119 **** ifp.close() ofp.close() ! srcfss = File.FSSpec(src) dstfss = File.FSSpec(dst) --- 115,119 ---- ifp.close() ofp.close() ! srcfss = File.FSSpec(src) dstfss = File.FSSpec(dst) *************** *** 131,135 **** dstfsr.FSSetCatalogInfo(Files.kFSCatInfoAllDates, catinfo) touched(dstfss) ! def copytree(src, dst, copydates=1): """Copy a complete file tree to a new destination""" --- 131,135 ---- dstfsr.FSSetCatalogInfo(Files.kFSCatInfoAllDates, catinfo) touched(dstfss) ! def copytree(src, dst, copydates=1): """Copy a complete file tree to a new destination""" Index: macresource.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/macresource.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** macresource.py 9 Apr 2003 13:25:43 -0000 1.5 --- macresource.py 18 Jul 2004 06:14:45 -0000 1.6 *************** *** 16,25 **** (default: modname with .rsrc appended) either in the same folder as where modname was loaded from, or otherwise across sys.path. ! Returns the refno of the resource file opened (or None)""" if modname is None and filename is None: raise ArgumentError, "Either filename or modname argument (or both) must be given" ! if type(resid) is type(1): try: --- 16,25 ---- (default: modname with .rsrc appended) either in the same folder as where modname was loaded from, or otherwise across sys.path. ! Returns the refno of the resource file opened (or None)""" if modname is None and filename is None: raise ArgumentError, "Either filename or modname argument (or both) must be given" ! if type(resid) is type(1): try: *************** *** 36,40 **** else: return None ! # Construct a filename if we don't have one if not filename: --- 36,40 ---- else: return None ! # Construct a filename if we don't have one if not filename: *************** *** 43,47 **** else: filename = modname + '.rsrc' ! # Now create a list of folders to search searchdirs = [] --- 43,47 ---- else: filename = modname + '.rsrc' ! # Now create a list of folders to search searchdirs = [] *************** *** 54,58 **** searchdirs = [os.path.dirname(mod.__file__)] searchdirs.extend(sys.path) ! # And look for the file for dir in searchdirs: --- 54,58 ---- searchdirs = [os.path.dirname(mod.__file__)] searchdirs.extend(sys.path) ! # And look for the file for dir in searchdirs: *************** *** 62,68 **** else: raise ResourceFileNotFoundError, filename ! refno = open_pathname(pathname) ! # And check that the resource exists now if type(resid) is type(1): --- 62,68 ---- else: raise ResourceFileNotFoundError, filename ! refno = open_pathname(pathname) ! # And check that the resource exists now if type(resid) is type(1): *************** *** 71,75 **** h = Res.GetNamedResource(restype, resid) return refno ! def open_pathname(pathname, verbose=0): """Open a resource file given by pathname, possibly decoding an --- 71,75 ---- h = Res.GetNamedResource(restype, resid) return refno ! def open_pathname(pathname, verbose=0): """Open a resource file given by pathname, possibly decoding an *************** *** 96,100 **** raise return refno ! def resource_pathname(pathname, verbose=0): """Return the pathname for a resource file (either DF or RF based). --- 96,100 ---- raise return refno ! def resource_pathname(pathname, verbose=0): """Return the pathname for a resource file (either DF or RF based). *************** *** 122,131 **** raise return pathname ! def open_error_resource(): """Open the resource file containing the error code to error message mapping.""" need('Estr', 1, filename="errors.rsrc", modname=__name__) ! def _decode(pathname, verbose=0): # Decode an AppleSingle resource file, return the new pathname. --- 122,131 ---- raise return pathname ! def open_error_resource(): """Open the resource file containing the error code to error message mapping.""" need('Estr', 1, filename="errors.rsrc", modname=__name__) ! def _decode(pathname, verbose=0): # Decode an AppleSingle resource file, return the new pathname. Index: pimp.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/pimp.py,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** pimp.py 13 Mar 2004 23:50:48 -0000 1.34 --- pimp.py 18 Jul 2004 06:14:45 -0000 1.35 *************** *** 1,5 **** """Package Install Manager for Python. ! This is currently a MacOSX-only strawman implementation. Despite other rumours the name stands for "Packman IMPlementation". --- 1,5 ---- """Package Install Manager for Python. ! This is currently a MacOSX-only strawman implementation. Despite other rumours the name stands for "Packman IMPlementation". [...1188 lines suppressed...] sys.stderr.write(msg + '\r') return 1 ! try: opts, args = getopt.getopt(sys.argv[1:], "slifvdD:Vu:") *************** *** 1134,1140 **** else: from pimp_update import * ! if __name__ == '__main__': main() - - --- 1134,1138 ---- else: from pimp_update import * ! if __name__ == '__main__': main() Index: videoreader.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/videoreader.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** videoreader.py 9 Apr 2003 13:25:43 -0000 1.3 --- videoreader.py 18 Jul 2004 06:14:45 -0000 1.4 *************** *** 35,51 **** self.__height = height self.__format = format ! def getname(self): return self.__name ! def getdescr(self): return self.__descr ! def getsize(self): return self.__width, self.__height ! def getformat(self): return self.__format ! class _Reader: def __init__(self, path): --- 35,51 ---- self.__height = height self.__format = format ! def getname(self): return self.__name ! def getdescr(self): return self.__descr ! def getsize(self): return self.__width, self.__height ! def getformat(self): return self.__format ! class _Reader: def __init__(self, path): *************** *** 67,72 **** self.audiotimescale = self.audiomedia.GetMediaTimeScale() del handle ! ! try: self.videotrack = self.movie.GetMovieIndTrackType(1, QuickTime.VisualMediaCharacteristic, QuickTime.movieTrackCharacteristic) --- 67,72 ---- self.audiotimescale = self.audiomedia.GetMediaTimeScale() del handle ! ! try: self.videotrack = self.movie.GetMovieIndTrackType(1, QuickTime.VisualMediaCharacteristic, QuickTime.movieTrackCharacteristic) *************** *** 82,86 **** self.audiocurtime = None ! def __del__(self): self.audiomedia = None --- 82,86 ---- self.audiocurtime = None ! def __del__(self): self.audiomedia = None *************** *** 89,93 **** self.videotrack = None self.movie = None ! def _initgworld(self): old_port, old_dev = Qdoffs.GetGWorld() --- 89,93 ---- self.videotrack = None self.movie = None ! def _initgworld(self): old_port, old_dev = Qdoffs.GetGWorld() *************** *** 109,140 **** finally: Qdoffs.SetGWorld(old_port, old_dev) ! def _gettrackduration_ms(self, track): tracktime = track.GetTrackDuration() return self._movietime_to_ms(tracktime) ! def _movietime_to_ms(self, time): value, d1, d2 = Qt.ConvertTimeScale((time, self.movietimescale, None), 1000) return value ! def _videotime_to_ms(self, time): value, d1, d2 = Qt.ConvertTimeScale((time, self.videotimescale, None), 1000) return value ! def _audiotime_to_ms(self, time): value, d1, d2 = Qt.ConvertTimeScale((time, self.audiotimescale, None), 1000) return value ! def _videotime_to_movietime(self, time): value, d1, d2 = Qt.ConvertTimeScale((time, self.videotimescale, None), self.movietimescale) return value ! def HasAudio(self): return not self.audiotrack is None ! def HasVideo(self): return not self.videotrack is None ! def GetAudioDuration(self): if not self.audiotrack: --- 109,140 ---- finally: Qdoffs.SetGWorld(old_port, old_dev) ! def _gettrackduration_ms(self, track): tracktime = track.GetTrackDuration() return self._movietime_to_ms(tracktime) ! def _movietime_to_ms(self, time): value, d1, d2 = Qt.ConvertTimeScale((time, self.movietimescale, None), 1000) return value ! def _videotime_to_ms(self, time): value, d1, d2 = Qt.ConvertTimeScale((time, self.videotimescale, None), 1000) return value ! def _audiotime_to_ms(self, time): value, d1, d2 = Qt.ConvertTimeScale((time, self.audiotimescale, None), 1000) return value ! def _videotime_to_movietime(self, time): value, d1, d2 = Qt.ConvertTimeScale((time, self.videotimescale, None), self.movietimescale) return value ! def HasAudio(self): return not self.audiotrack is None ! def HasVideo(self): return not self.videotrack is None ! def GetAudioDuration(self): if not self.audiotrack: *************** *** 146,150 **** return 0 return self._gettrackduration_ms(self.videotrack) ! def GetAudioFormat(self): if not self.audiodescr: --- 146,150 ---- return 0 return self._gettrackduration_ms(self.videotrack) ! def GetAudioFormat(self): if not self.audiodescr: *************** *** 173,190 **** else: encoding = 'quicktime-coding-%s'%self.audiodescr['dataFormat'] ! ## return audio.format.AudioFormatLinear('quicktime_audio', 'QuickTime Audio Format', ## channels, encoding, blocksize=blocksize, fpb=fpb, bps=bps) return channels, encoding, blocksize, fpb, bps ! def GetAudioFrameRate(self): if not self.audiodescr: return None return int(self.audiodescr['sampleRate']) ! def GetVideoFormat(self): width = self.videodescr['width'] height = self.videodescr['height'] return VideoFormat('dummy_format', 'Dummy Video Format', width, height, macrgb) ! def GetVideoFrameRate(self): tv = self.videocurtime --- 173,190 ---- else: encoding = 'quicktime-coding-%s'%self.audiodescr['dataFormat'] ! ## return audio.format.AudioFormatLinear('quicktime_audio', 'QuickTime Audio Format', ## channels, encoding, blocksize=blocksize, fpb=fpb, bps=bps) return channels, encoding, blocksize, fpb, bps ! def GetAudioFrameRate(self): if not self.audiodescr: return None return int(self.audiodescr['sampleRate']) ! def GetVideoFormat(self): width = self.videodescr['width'] height = self.videodescr['height'] return VideoFormat('dummy_format', 'Dummy Video Format', width, height, macrgb) ! def GetVideoFrameRate(self): tv = self.videocurtime *************** *** 195,199 **** dur = self._videotime_to_ms(dur) return int((1000.0/dur)+0.5) ! def ReadAudio(self, nframes, time=None): if not time is None: --- 195,199 ---- dur = self._videotime_to_ms(dur) return int((1000.0/dur)+0.5) ! def ReadAudio(self, nframes, time=None): if not time is None: *************** *** 211,215 **** self.audiocurtime = actualtime + actualcount*sampleduration return self._audiotime_to_ms(actualtime), h.data ! def ReadVideo(self, time=None): if not time is None: --- 211,215 ---- self.audiocurtime = actualtime + actualcount*sampleduration return self._audiotime_to_ms(actualtime), h.data ! def ReadVideo(self, time=None): if not time is None: *************** *** 227,231 **** self.movie.MoviesTask(0) return self._videotime_to_ms(self.videocurtime), self._getpixmapcontent() ! def _getpixmapcontent(self): """Shuffle the offscreen PixMap data, because it may have funny stride values""" --- 227,231 ---- self.movie.MoviesTask(0) return self._videotime_to_ms(self.videocurtime), self._getpixmapcontent() ! def _getpixmapcontent(self): """Shuffle the offscreen PixMap data, because it may have funny stride values""" *************** *** 282,292 **** timestamp, data = rdr.ReadVideo() MacOS.SetCreatorAndType(pname, 'ogle', 'JPEG') ! if num > 20: print 'stopping at 20 frames so your disk does not fill up:-)' break print 'Total frames:', num ! if __name__ == '__main__': _test() sys.exit(1) - --- 282,291 ---- timestamp, data = rdr.ReadVideo() MacOS.SetCreatorAndType(pname, 'ogle', 'JPEG') ! if num > 20: print 'stopping at 20 frames so your disk does not fill up:-)' break print 'Total frames:', num ! if __name__ == '__main__': _test() sys.exit(1) From tim_one at users.sourceforge.net Sun Jul 18 08:15:22 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 08:15:48 2004 Subject: [Python-checkins] python/dist/src/Lib/plat-mac/Carbon Aliases.py, 1.1, 1.2 Appearance.py, 1.2, 1.3 AppleEvents.py, 1.2, 1.3 CarbonEvents.py, 1.2, 1.3 Components.py, 1.1, 1.2 ControlAccessor.py, 1.2, 1.3 Controls.py, 1.2, 1.3 CoreFoundation.py, 1.1, 1.2 CoreGraphics.py, 1.2, 1.3 Dialogs.py, 1.2, 1.3 Dragconst.py, 1.2, 1.3 Events.py, 1.2, 1.3 Files.py, 1.2, 1.3 Folders.py, 1.2, 1.3 Icons.py, 1.2, 1.3 LaunchServices.py, 1.3, 1.4 Lists.py, 1.1, 1.2 MacHelp.py, 1.1, 1.2 MacTextEditor.py, 1.2, 1.3 MediaDescr.py, 1.2, 1.3 Menus.py, 1.2, 1.3 OSAconst.py, 1.2, 1.3 Qt.py, 1.2, 1.3 QuickDraw.py, 1.2, 1.3 QuickTime.py, 1.3, 1.4 Resources.py, 1.1, 1.2 Sound.py, 1.1, 1.2 TextEdit.py, 1.1, 1.2 Windows.py, 1.2, 1.3 __init__.py, 1.1, 1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/plat-mac/Carbon In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31286/plat-mac/Carbon Modified Files: Aliases.py Appearance.py AppleEvents.py CarbonEvents.py Components.py ControlAccessor.py Controls.py CoreFoundation.py CoreGraphics.py Dialogs.py Dragconst.py Events.py Files.py Folders.py Icons.py LaunchServices.py Lists.py MacHelp.py MacTextEditor.py MediaDescr.py Menus.py OSAconst.py Qt.py QuickDraw.py QuickTime.py Resources.py Sound.py TextEdit.py Windows.py __init__.py Log Message: Whitespace normalization, via reindent.py. Index: Aliases.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/Carbon/Aliases.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Aliases.py 30 Dec 2002 22:04:20 -0000 1.1 --- Aliases.py 18 Jul 2004 06:14:46 -0000 1.2 *************** *** 4,8 **** true = True false = False ! rAliasType = FOUR_CHAR_CODE('alis') kARMMountVol = 0x00000001 kARMNoUI = 0x00000002 --- 4,8 ---- true = True false = False ! rAliasType = FOUR_CHAR_CODE('alis') kARMMountVol = 0x00000001 kARMNoUI = 0x00000002 *************** *** 10,18 **** kARMSearch = 0x00000100 kARMSearchMore = 0x00000200 ! kARMSearchRelFirst = 0x00000400 asiZoneName = -3 asiServerName = -2 asiVolumeName = -1 asiAliasName = 0 ! asiParentName = 1 ! kResolveAliasFileNoUI = 0x00000001 --- 10,18 ---- kARMSearch = 0x00000100 kARMSearchMore = 0x00000200 ! kARMSearchRelFirst = 0x00000400 asiZoneName = -3 asiServerName = -2 asiVolumeName = -1 asiAliasName = 0 ! asiParentName = 1 ! kResolveAliasFileNoUI = 0x00000001 Index: Appearance.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/Carbon/Appearance.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Appearance.py 5 Dec 2003 23:59:37 -0000 1.2 --- Appearance.py 18 Jul 2004 06:14:46 -0000 1.3 *************** *** 6,10 **** kAESystemFontChanged = FOUR_CHAR_CODE('sysf') kAESmallSystemFontChanged = FOUR_CHAR_CODE('ssfn') ! kAEViewsFontChanged = FOUR_CHAR_CODE('vfnt') kThemeDataFileType = FOUR_CHAR_CODE('thme') kThemePlatinumFileType = FOUR_CHAR_CODE('pltn') --- 6,10 ---- kAESystemFontChanged = FOUR_CHAR_CODE('sysf') kAESmallSystemFontChanged = FOUR_CHAR_CODE('ssfn') ! kAEViewsFontChanged = FOUR_CHAR_CODE('vfnt') kThemeDataFileType = FOUR_CHAR_CODE('thme') kThemePlatinumFileType = FOUR_CHAR_CODE('pltn') *************** *** 65,74 **** kThemeBrushSheetBackgroundTransparent = 53 kThemeBrushMenuBackground = 54 ! kThemeBrushMenuBackgroundSelected = 55 kThemeBrushSheetBackground = kThemeBrushSheetBackgroundOpaque kThemeBrushBlack = -1 kThemeBrushWhite = -2 kThemeBrushPrimaryHighlightColor = -3 ! kThemeBrushSecondaryHighlightColor = -4 kThemeTextColorDialogActive = 1 kThemeTextColorDialogInactive = 2 --- 65,74 ---- kThemeBrushSheetBackgroundTransparent = 53 kThemeBrushMenuBackground = 54 ! kThemeBrushMenuBackgroundSelected = 55 kThemeBrushSheetBackground = kThemeBrushSheetBackgroundOpaque kThemeBrushBlack = -1 kThemeBrushWhite = -2 kThemeBrushPrimaryHighlightColor = -3 ! kThemeBrushSecondaryHighlightColor = -4 kThemeTextColorDialogActive = 1 kThemeTextColorDialogInactive = 2 *************** *** 128,132 **** kThemeStateDisabled = 0 kThemeStatePressedUp = 2 ! kThemeStatePressedDown = 3 kThemeArrowCursor = 0 kThemeCopyArrowCursor = 1 --- 128,132 ---- kThemeStateDisabled = 0 kThemeStatePressedUp = 2 ! kThemeStatePressedDown = 3 kThemeArrowCursor = 0 kThemeCopyArrowCursor = 1 *************** *** 166,170 **** kThemeMenuItemPopUpBackground = 0x0800 kThemeMenuItemHasIcon = 0x8000 ! kThemeMenuItemNoBackground = 0x4000 kThemeBackgroundTabPane = 1 kThemeBackgroundPlacard = 2 --- 166,170 ---- kThemeMenuItemPopUpBackground = 0x0800 kThemeMenuItemHasIcon = 0x8000 ! kThemeMenuItemNoBackground = 0x4000 kThemeBackgroundTabPane = 1 kThemeBackgroundPlacard = 2 *************** *** 179,183 **** kThemeScrollBarThumbStyleTag = FOUR_CHAR_CODE('sbth') kThemeSoundsEnabledTag = FOUR_CHAR_CODE('snds') ! kThemeDblClickCollapseTag = FOUR_CHAR_CODE('coll') kThemeAppearanceFileNameTag = FOUR_CHAR_CODE('thme') kThemeSystemFontTag = FOUR_CHAR_CODE('lgsf') --- 179,183 ---- kThemeScrollBarThumbStyleTag = FOUR_CHAR_CODE('sbth') kThemeSoundsEnabledTag = FOUR_CHAR_CODE('snds') ! kThemeDblClickCollapseTag = FOUR_CHAR_CODE('coll') kThemeAppearanceFileNameTag = FOUR_CHAR_CODE('thme') kThemeSystemFontTag = FOUR_CHAR_CODE('lgsf') *************** *** 196,211 **** kThemeUserDefinedTag = FOUR_CHAR_CODE('user') kThemeSmoothFontEnabledTag = FOUR_CHAR_CODE('smoo') ! kThemeSmoothFontMinSizeTag = FOUR_CHAR_CODE('smos') kTiledOnScreen = 1 kCenterOnScreen = 2 kFitToScreen = 3 kFillScreen = 4 ! kUseBestGuess = 5 kThemeCheckBoxClassicX = 0 ! kThemeCheckBoxCheckMark = 1 kThemeScrollBarArrowsSingle = 0 ! kThemeScrollBarArrowsLowerRight = 1 kThemeScrollBarThumbNormal = 0 ! kThemeScrollBarThumbProportional = 1 kThemeSystemFont = 0 kThemeSmallSystemFont = 1 --- 196,211 ---- kThemeUserDefinedTag = FOUR_CHAR_CODE('user') kThemeSmoothFontEnabledTag = FOUR_CHAR_CODE('smoo') ! kThemeSmoothFontMinSizeTag = FOUR_CHAR_CODE('smos') kTiledOnScreen = 1 kCenterOnScreen = 2 kFitToScreen = 3 kFillScreen = 4 ! kUseBestGuess = 5 kThemeCheckBoxClassicX = 0 ! kThemeCheckBoxCheckMark = 1 kThemeScrollBarArrowsSingle = 0 ! kThemeScrollBarArrowsLowerRight = 1 kThemeScrollBarThumbNormal = 0 ! kThemeScrollBarThumbProportional = 1 kThemeSystemFont = 0 kThemeSmallSystemFont = 1 *************** *** 239,243 **** kThemeTabPaneOverlap = 3 kThemeSmallTabHeightMax = 19 ! kThemeLargeTabHeightMax = 24 kThemeMediumScrollBar = 0 kThemeSmallScrollBar = 1 --- 239,243 ---- kThemeTabPaneOverlap = 3 kThemeSmallTabHeightMax = 19 ! kThemeLargeTabHeightMax = 24 kThemeMediumScrollBar = 0 kThemeSmallScrollBar = 1 *************** *** 310,314 **** kThemeGrowRight = (1 << 1) kThemeGrowUp = (1 << 2) ! kThemeGrowDown = (1 << 3) kThemePushButton = 0 kThemeCheckBox = 1 --- 310,314 ---- kThemeGrowRight = (1 << 1) kThemeGrowUp = (1 << 2) ! kThemeGrowDown = (1 << 3) kThemePushButton = 0 kThemeCheckBox = 1 *************** *** 352,356 **** kThemeAdornmentArrowDownArrow = (1 << 7) kThemeAdornmentArrowDoubleArrow = (1 << 8) ! kThemeAdornmentArrowUpArrow = (1 << 9) kThemeNoSounds = 0 kThemeWindowSoundsMask = (1 << 0) --- 352,356 ---- kThemeAdornmentArrowDownArrow = (1 << 7) kThemeAdornmentArrowDoubleArrow = (1 << 8) ! kThemeAdornmentArrowUpArrow = (1 << 9) kThemeNoSounds = 0 kThemeWindowSoundsMask = (1 << 0) *************** *** 630,634 **** kThemeActivePopupLabelTextColor = kThemeTextColorPopupLabelActive kThemeInactivePopupLabelTextColor = kThemeTextColorPopupLabelInactive ! kAEThemeSwitch = kAEAppearanceChanged kThemeNoAdornment = kThemeAdornmentNone kThemeDefaultAdornment = kThemeAdornmentDefault --- 630,634 ---- kThemeActivePopupLabelTextColor = kThemeTextColorPopupLabelActive kThemeInactivePopupLabelTextColor = kThemeTextColorPopupLabelInactive ! kAEThemeSwitch = kAEAppearanceChanged kThemeNoAdornment = kThemeAdornmentNone kThemeDefaultAdornment = kThemeAdornmentDefault *************** *** 642,646 **** kThemeMetricBestListHeaderHeight = kThemeMetricListHeaderHeight kThemeMetricSmallProgressBarThickness = kThemeMetricNormalProgressBarThickness ! kThemeMetricProgressBarThickness = kThemeMetricLargeProgressBarThickness kThemeScrollBar = kThemeMediumScrollBar kThemeSlider = kThemeMediumSlider --- 642,646 ---- kThemeMetricBestListHeaderHeight = kThemeMetricListHeaderHeight kThemeMetricSmallProgressBarThickness = kThemeMetricNormalProgressBarThickness ! kThemeMetricProgressBarThickness = kThemeMetricLargeProgressBarThickness kThemeScrollBar = kThemeMediumScrollBar kThemeSlider = kThemeMediumSlider Index: AppleEvents.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/Carbon/AppleEvents.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** AppleEvents.py 5 Dec 2003 23:59:37 -0000 1.2 --- AppleEvents.py 18 Jul 2004 06:14:46 -0000 1.3 *************** *** 45,49 **** typeProcessSerialNumber = FOUR_CHAR_CODE('psn ') typeApplicationURL = FOUR_CHAR_CODE('aprl') ! typeNull = FOUR_CHAR_CODE('null') typeSessionID = FOUR_CHAR_CODE('ssid') typeTargetID = FOUR_CHAR_CODE('targ') --- 45,49 ---- typeProcessSerialNumber = FOUR_CHAR_CODE('psn ') typeApplicationURL = FOUR_CHAR_CODE('aprl') ! typeNull = FOUR_CHAR_CODE('null') typeSessionID = FOUR_CHAR_CODE('ssid') typeTargetID = FOUR_CHAR_CODE('targ') *************** *** 60,69 **** keyMissedKeywordAttr = FOUR_CHAR_CODE('miss') keyOriginalAddressAttr = FOUR_CHAR_CODE('from') ! keyAcceptTimeoutAttr = FOUR_CHAR_CODE('actm') kAEDescListFactorNone = 0 kAEDescListFactorType = 4 kAEDescListFactorTypeAndSize = 8 kAutoGenerateReturnID = -1 ! kAnyTransactionID = 0 kAEDataArray = 0 kAEPackedArray = 1 --- 60,69 ---- keyMissedKeywordAttr = FOUR_CHAR_CODE('miss') keyOriginalAddressAttr = FOUR_CHAR_CODE('from') ! keyAcceptTimeoutAttr = FOUR_CHAR_CODE('actm') kAEDescListFactorNone = 0 kAEDescListFactorType = 4 kAEDescListFactorTypeAndSize = 8 kAutoGenerateReturnID = -1 ! kAnyTransactionID = 0 kAEDataArray = 0 kAEPackedArray = 1 *************** *** 72,76 **** kAEHandleArray = 2 kAENormalPriority = 0x00000000 ! kAEHighPriority = 0x00000001 kAENoReply = 0x00000001 kAEQueueReply = 0x00000002 --- 72,76 ---- kAEHandleArray = 2 kAENormalPriority = 0x00000000 ! kAEHighPriority = 0x00000001 kAENoReply = 0x00000001 kAEQueueReply = 0x00000002 *************** *** 84,90 **** kAEDontRecord = 0x00001000 kAEDontExecute = 0x00002000 ! kAEProcessNonReplyEvents = 0x00008000 kAEDefaultTimeout = -1 ! kNoTimeOut = -2 kAEInteractWithSelf = 0 kAEInteractWithLocal = 1 --- 84,90 ---- kAEDontRecord = 0x00001000 kAEDontExecute = 0x00002000 ! kAEProcessNonReplyEvents = 0x00008000 kAEDefaultTimeout = -1 ! kNoTimeOut = -2 kAEInteractWithSelf = 0 kAEInteractWithLocal = 1 *************** *** 96,102 **** kAEIgnoreSysEventHandler = 0x00000008 kAEIngoreBuiltInEventHandler = 0x00000010 ! # kAEDontDisposeOnResume = (long)0x80000000 kAENoDispatch = 0 ! # kAEUseStandardDispatch = (long)0xFFFFFFFF keyDirectObject = FOUR_CHAR_CODE('----') keyErrorNumber = FOUR_CHAR_CODE('errn') --- 96,102 ---- kAEIgnoreSysEventHandler = 0x00000008 kAEIngoreBuiltInEventHandler = 0x00000010 ! # kAEDontDisposeOnResume = (long)0x80000000 kAENoDispatch = 0 ! # kAEUseStandardDispatch = (long)0xFFFFFFFF keyDirectObject = FOUR_CHAR_CODE('----') keyErrorNumber = FOUR_CHAR_CODE('errn') *************** *** 106,110 **** keySelectProc = FOUR_CHAR_CODE('selh') keyAERecorderCount = FOUR_CHAR_CODE('recr') ! keyAEVersion = FOUR_CHAR_CODE('vers') kCoreEventClass = FOUR_CHAR_CODE('aevt') kAEOpenApplication = FOUR_CHAR_CODE('oapp') --- 106,110 ---- keySelectProc = FOUR_CHAR_CODE('selh') keyAERecorderCount = FOUR_CHAR_CODE('recr') ! keyAEVersion = FOUR_CHAR_CODE('vers') kCoreEventClass = FOUR_CHAR_CODE('aevt') kAEOpenApplication = FOUR_CHAR_CODE('oapp') *************** *** 114,123 **** kAEAnswer = FOUR_CHAR_CODE('ansr') kAEApplicationDied = FOUR_CHAR_CODE('obit') ! kAEShowPreferences = FOUR_CHAR_CODE('pref') kAEStartRecording = FOUR_CHAR_CODE('reca') kAEStopRecording = FOUR_CHAR_CODE('recc') kAENotifyStartRecording = FOUR_CHAR_CODE('rec1') kAENotifyStopRecording = FOUR_CHAR_CODE('rec0') ! kAENotifyRecording = FOUR_CHAR_CODE('recr') kAEUnknownSource = 0 kAEDirectCall = 1 --- 114,123 ---- kAEAnswer = FOUR_CHAR_CODE('ansr') kAEApplicationDied = FOUR_CHAR_CODE('obit') ! kAEShowPreferences = FOUR_CHAR_CODE('pref') kAEStartRecording = FOUR_CHAR_CODE('reca') kAEStopRecording = FOUR_CHAR_CODE('recc') kAENotifyStartRecording = FOUR_CHAR_CODE('rec1') kAENotifyStopRecording = FOUR_CHAR_CODE('rec0') ! kAENotifyRecording = FOUR_CHAR_CODE('recr') kAEUnknownSource = 0 kAEDirectCall = 1 *************** *** 144,148 **** cGraphicShape = FOUR_CHAR_CODE('cgsh') cGraphicText = FOUR_CHAR_CODE('cgtx') ! cGroupedGraphic = FOUR_CHAR_CODE('cpic') cInsertionLoc = FOUR_CHAR_CODE('insl') cInsertionPoint = FOUR_CHAR_CODE('cins') --- 144,148 ---- cGraphicShape = FOUR_CHAR_CODE('cgsh') cGraphicText = FOUR_CHAR_CODE('cgtx') ! cGroupedGraphic = FOUR_CHAR_CODE('cpic') cInsertionLoc = FOUR_CHAR_CODE('insl') cInsertionPoint = FOUR_CHAR_CODE('cins') *************** *** 164,168 **** cObjectSpecifier = FOUR_CHAR_CODE('obj ') cOpenableObject = FOUR_CHAR_CODE('coob') ! cOval = FOUR_CHAR_CODE('covl') cParagraph = FOUR_CHAR_CODE('cpar') cPICT = FOUR_CHAR_CODE('PICT') --- 164,168 ---- cObjectSpecifier = FOUR_CHAR_CODE('obj ') cOpenableObject = FOUR_CHAR_CODE('coob') ! cOval = FOUR_CHAR_CODE('covl') cParagraph = FOUR_CHAR_CODE('cpar') cPICT = FOUR_CHAR_CODE('PICT') *************** *** 184,188 **** cTextFlow = FOUR_CHAR_CODE('cflo') cTextStyles = FOUR_CHAR_CODE('tsty') ! cType = FOUR_CHAR_CODE('type') cVersion = FOUR_CHAR_CODE('vers') cWindow = FOUR_CHAR_CODE('cwin') --- 184,188 ---- cTextFlow = FOUR_CHAR_CODE('cflo') cTextStyles = FOUR_CHAR_CODE('tsty') ! cType = FOUR_CHAR_CODE('type') cVersion = FOUR_CHAR_CODE('vers') cWindow = FOUR_CHAR_CODE('cwin') *************** *** 204,208 **** kAEArrowAtEnd = FOUR_CHAR_CODE('aren') kAEArrowAtStart = FOUR_CHAR_CODE('arst') ! kAEArrowBothEnds = FOUR_CHAR_CODE('arbo') kAEAsk = FOUR_CHAR_CODE('ask ') kAEBefore = FOUR_CHAR_CODE('befo') --- 204,208 ---- kAEArrowAtEnd = FOUR_CHAR_CODE('aren') kAEArrowAtStart = FOUR_CHAR_CODE('arst') ! kAEArrowBothEnds = FOUR_CHAR_CODE('arbo') kAEAsk = FOUR_CHAR_CODE('ask ') kAEBefore = FOUR_CHAR_CODE('befo') *************** *** 224,228 **** kAECreatePublisher = FOUR_CHAR_CODE('cpub') kAECut = FOUR_CHAR_CODE('cut ') ! kAEDelete = FOUR_CHAR_CODE('delo') kAEDoObjectsExist = FOUR_CHAR_CODE('doex') kAEDoScript = FOUR_CHAR_CODE('dosc') --- 224,228 ---- kAECreatePublisher = FOUR_CHAR_CODE('cpub') kAECut = FOUR_CHAR_CODE('cut ') ! kAEDelete = FOUR_CHAR_CODE('delo') kAEDoObjectsExist = FOUR_CHAR_CODE('doex') kAEDoScript = FOUR_CHAR_CODE('dosc') *************** *** 244,248 **** kAEGetDataSize = FOUR_CHAR_CODE('dsiz') kAEGetEventInfo = FOUR_CHAR_CODE('gtei') ! kAEGetInfoSelection = FOUR_CHAR_CODE('sinf') kAEGetPrivilegeSelection = FOUR_CHAR_CODE('sprv') kAEGetSuiteInfo = FOUR_CHAR_CODE('gtsi') --- 244,248 ---- kAEGetDataSize = FOUR_CHAR_CODE('dsiz') kAEGetEventInfo = FOUR_CHAR_CODE('gtei') ! kAEGetInfoSelection = FOUR_CHAR_CODE('sinf') kAEGetPrivilegeSelection = FOUR_CHAR_CODE('sprv') kAEGetSuiteInfo = FOUR_CHAR_CODE('gtsi') *************** *** 264,268 **** kAEMove = FOUR_CHAR_CODE('move') kAENo = FOUR_CHAR_CODE('no ') ! kAENoArrow = FOUR_CHAR_CODE('arno') kAENonmodifiable = FOUR_CHAR_CODE('nmod') kAEOpen = FOUR_CHAR_CODE('odoc') --- 264,268 ---- kAEMove = FOUR_CHAR_CODE('move') kAENo = FOUR_CHAR_CODE('no ') ! kAENoArrow = FOUR_CHAR_CODE('arno') kAENonmodifiable = FOUR_CHAR_CODE('nmod') kAEOpen = FOUR_CHAR_CODE('odoc') *************** *** 284,288 **** kAEQDCopy = FOUR_CHAR_CODE('cpy ') kAEQDNotBic = FOUR_CHAR_CODE('nbic') ! kAEQDNotCopy = FOUR_CHAR_CODE('ncpy') kAEQDNotOr = FOUR_CHAR_CODE('ntor') kAEQDNotXor = FOUR_CHAR_CODE('nxor') --- 284,288 ---- kAEQDCopy = FOUR_CHAR_CODE('cpy ') kAEQDNotBic = FOUR_CHAR_CODE('nbic') ! kAEQDNotCopy = FOUR_CHAR_CODE('ncpy') kAEQDNotOr = FOUR_CHAR_CODE('ntor') kAEQDNotXor = FOUR_CHAR_CODE('nxor') *************** *** 305,309 **** kAESave = FOUR_CHAR_CODE('save') kAESelect = FOUR_CHAR_CODE('slct') ! kAESetData = FOUR_CHAR_CODE('setd') kAESetPosition = FOUR_CHAR_CODE('posn') kAEShadow = FOUR_CHAR_CODE('shad') --- 305,309 ---- kAESave = FOUR_CHAR_CODE('save') kAESelect = FOUR_CHAR_CODE('slct') ! kAESetData = FOUR_CHAR_CODE('setd') kAESetPosition = FOUR_CHAR_CODE('posn') kAEShadow = FOUR_CHAR_CODE('shad') *************** *** 323,327 **** kAEWholeWordEquals = FOUR_CHAR_CODE('wweq') kAEYes = FOUR_CHAR_CODE('yes ') ! kAEZoom = FOUR_CHAR_CODE('zoom') kAEMouseClass = FOUR_CHAR_CODE('mous') kAEDown = FOUR_CHAR_CODE('down') --- 323,327 ---- kAEWholeWordEquals = FOUR_CHAR_CODE('wweq') kAEYes = FOUR_CHAR_CODE('yes ') ! kAEZoom = FOUR_CHAR_CODE('zoom') kAEMouseClass = FOUR_CHAR_CODE('mous') kAEDown = FOUR_CHAR_CODE('down') *************** *** 348,352 **** kAEHighLevel = FOUR_CHAR_CODE('high') keyAEAngle = FOUR_CHAR_CODE('kang') ! keyAEArcAngle = FOUR_CHAR_CODE('parc') keyAEBaseAddr = FOUR_CHAR_CODE('badd') keyAEBestType = FOUR_CHAR_CODE('pbst') --- 348,352 ---- kAEHighLevel = FOUR_CHAR_CODE('high') keyAEAngle = FOUR_CHAR_CODE('kang') ! keyAEArcAngle = FOUR_CHAR_CODE('parc') keyAEBaseAddr = FOUR_CHAR_CODE('badd') keyAEBestType = FOUR_CHAR_CODE('pbst') *************** *** 368,372 **** keyAEDoAntiAlias = FOUR_CHAR_CODE('anta') keyAEDoDithered = FOUR_CHAR_CODE('gdit') ! keyAEDoRotate = FOUR_CHAR_CODE('kdrt') keyAEDoScale = FOUR_CHAR_CODE('ksca') keyAEDoTranslate = FOUR_CHAR_CODE('ktra') --- 368,372 ---- keyAEDoAntiAlias = FOUR_CHAR_CODE('anta') keyAEDoDithered = FOUR_CHAR_CODE('gdit') ! keyAEDoRotate = FOUR_CHAR_CODE('kdrt') keyAEDoScale = FOUR_CHAR_CODE('ksca') keyAEDoTranslate = FOUR_CHAR_CODE('ktra') *************** *** 388,392 **** keyAEImageQuality = FOUR_CHAR_CODE('gqua') keyAEInsertHere = FOUR_CHAR_CODE('insh') ! keyAEKeyForms = FOUR_CHAR_CODE('keyf') keyAEKeyword = FOUR_CHAR_CODE('kywd') keyAELevel = FOUR_CHAR_CODE('levl') --- 388,392 ---- keyAEImageQuality = FOUR_CHAR_CODE('gqua') keyAEInsertHere = FOUR_CHAR_CODE('insh') ! keyAEKeyForms = FOUR_CHAR_CODE('keyf') keyAEKeyword = FOUR_CHAR_CODE('kywd') keyAELevel = FOUR_CHAR_CODE('levl') *************** *** 408,412 **** keyAEPointList = FOUR_CHAR_CODE('ptlt') keyAEPointSize = FOUR_CHAR_CODE('ptsz') ! keyAEPosition = FOUR_CHAR_CODE('kpos') keyAEPropData = FOUR_CHAR_CODE('prdt') keyAEProperties = FOUR_CHAR_CODE('qpro') --- 408,412 ---- keyAEPointList = FOUR_CHAR_CODE('ptlt') keyAEPointSize = FOUR_CHAR_CODE('ptsz') ! keyAEPosition = FOUR_CHAR_CODE('kpos') keyAEPropData = FOUR_CHAR_CODE('prdt') keyAEProperties = FOUR_CHAR_CODE('qpro') *************** *** 428,432 **** keyAEStartAngle = FOUR_CHAR_CODE('pang') keyAEStartPoint = FOUR_CHAR_CODE('pstp') ! keyAEStyles = FOUR_CHAR_CODE('ksty') keyAESuiteID = FOUR_CHAR_CODE('suit') keyAEText = FOUR_CHAR_CODE('ktxt') --- 428,432 ---- keyAEStartAngle = FOUR_CHAR_CODE('pang') keyAEStartPoint = FOUR_CHAR_CODE('pstp') ! keyAEStyles = FOUR_CHAR_CODE('ksty') keyAESuiteID = FOUR_CHAR_CODE('suit') keyAEText = FOUR_CHAR_CODE('ktxt') *************** *** 445,449 **** keyAEUserTerm = FOUR_CHAR_CODE('utrm') keyAEWindow = FOUR_CHAR_CODE('wndw') ! keyAEWritingCode = FOUR_CHAR_CODE('wrcd') keyMiscellaneous = FOUR_CHAR_CODE('fmsc') keySelection = FOUR_CHAR_CODE('fsel') --- 445,449 ---- keyAEUserTerm = FOUR_CHAR_CODE('utrm') keyAEWindow = FOUR_CHAR_CODE('wndw') ! keyAEWritingCode = FOUR_CHAR_CODE('wrcd') keyMiscellaneous = FOUR_CHAR_CODE('fmsc') keySelection = FOUR_CHAR_CODE('fsel') *************** *** 478,482 **** pFillColor = FOUR_CHAR_CODE('flcl') pFillPattern = FOUR_CHAR_CODE('flpt') ! pFont = FOUR_CHAR_CODE('font') pFormula = FOUR_CHAR_CODE('pfor') pGraphicObjects = FOUR_CHAR_CODE('gobs') --- 478,482 ---- pFillColor = FOUR_CHAR_CODE('flcl') pFillPattern = FOUR_CHAR_CODE('flpt') ! pFont = FOUR_CHAR_CODE('font') pFormula = FOUR_CHAR_CODE('pfor') pGraphicObjects = FOUR_CHAR_CODE('gobs') *************** *** 498,502 **** pLineArrow = FOUR_CHAR_CODE('arro') pMenuID = FOUR_CHAR_CODE('mnid') ! pName = FOUR_CHAR_CODE('pnam') pNewElementLoc = FOUR_CHAR_CODE('pnel') pPenColor = FOUR_CHAR_CODE('ppcl') --- 498,502 ---- pLineArrow = FOUR_CHAR_CODE('arro') pMenuID = FOUR_CHAR_CODE('mnid') ! pName = FOUR_CHAR_CODE('pnam') pNewElementLoc = FOUR_CHAR_CODE('pnel') pPenColor = FOUR_CHAR_CODE('ppcl') *************** *** 518,522 **** pTextFont = FOUR_CHAR_CODE('ptxf') pTextItemDelimiters = FOUR_CHAR_CODE('txdl') ! pTextPointSize = FOUR_CHAR_CODE('ptps') pTextStyles = FOUR_CHAR_CODE('txst') pTransferMode = FOUR_CHAR_CODE('pptm') --- 518,522 ---- pTextFont = FOUR_CHAR_CODE('ptxf') pTextItemDelimiters = FOUR_CHAR_CODE('txdl') ! pTextPointSize = FOUR_CHAR_CODE('ptps') pTextStyles = FOUR_CHAR_CODE('txst') pTransferMode = FOUR_CHAR_CODE('pptm') *************** *** 526,530 **** pUserSelection = FOUR_CHAR_CODE('pusl') pVersion = FOUR_CHAR_CODE('vers') ! pVisible = FOUR_CHAR_CODE('pvis') typeAEText = FOUR_CHAR_CODE('tTXT') typeArc = FOUR_CHAR_CODE('carc') --- 526,530 ---- pUserSelection = FOUR_CHAR_CODE('pusl') pVersion = FOUR_CHAR_CODE('vers') ! pVisible = FOUR_CHAR_CODE('pvis') typeAEText = FOUR_CHAR_CODE('tTXT') typeArc = FOUR_CHAR_CODE('carc') *************** *** 540,544 **** typeEnumeration = FOUR_CHAR_CODE('enum') typeEPS = FOUR_CHAR_CODE('EPS ') ! typeEventInfo = FOUR_CHAR_CODE('evin') typeFinderWindow = FOUR_CHAR_CODE('fwin') typeFixedPoint = FOUR_CHAR_CODE('fpnt') --- 540,544 ---- typeEnumeration = FOUR_CHAR_CODE('enum') typeEPS = FOUR_CHAR_CODE('EPS ') ! typeEventInfo = FOUR_CHAR_CODE('evin') typeFinderWindow = FOUR_CHAR_CODE('fwin') typeFixedPoint = FOUR_CHAR_CODE('fpnt') *************** *** 559,563 **** typeOval = FOUR_CHAR_CODE('covl') typeParamInfo = FOUR_CHAR_CODE('pmin') ! typePict = FOUR_CHAR_CODE('PICT') typePixelMap = FOUR_CHAR_CODE('cpix') typePixMapMinus = FOUR_CHAR_CODE('tpmm') --- 559,563 ---- typeOval = FOUR_CHAR_CODE('covl') typeParamInfo = FOUR_CHAR_CODE('pmin') ! typePict = FOUR_CHAR_CODE('PICT') typePixelMap = FOUR_CHAR_CODE('cpix') typePixMapMinus = FOUR_CHAR_CODE('tpmm') *************** *** 579,585 **** typeSuiteInfo = FOUR_CHAR_CODE('suin') typeTable = FOUR_CHAR_CODE('ctbl') ! typeTextStyles = FOUR_CHAR_CODE('tsty') typeTIFF = FOUR_CHAR_CODE('TIFF') ! typeVersion = FOUR_CHAR_CODE('vers') kAEMenuClass = FOUR_CHAR_CODE('menu') kAEMenuSelect = FOUR_CHAR_CODE('mhit') --- 579,585 ---- typeSuiteInfo = FOUR_CHAR_CODE('suin') typeTable = FOUR_CHAR_CODE('ctbl') ! typeTextStyles = FOUR_CHAR_CODE('tsty') typeTIFF = FOUR_CHAR_CODE('TIFF') ! typeVersion = FOUR_CHAR_CODE('vers') kAEMenuClass = FOUR_CHAR_CODE('menu') kAEMenuSelect = FOUR_CHAR_CODE('mhit') *************** *** 641,645 **** typeLowLevelEventRecord = FOUR_CHAR_CODE('evtr') typeEventRef = FOUR_CHAR_CODE('evrf') ! typeText = typeChar kTSMOutsideOfBody = 1 kTSMInsideOfBody = 2 --- 641,645 ---- typeLowLevelEventRecord = FOUR_CHAR_CODE('evtr') typeEventRef = FOUR_CHAR_CODE('evrf') ! typeText = typeChar kTSMOutsideOfBody = 1 kTSMInsideOfBody = 2 *************** *** 654,658 **** kBlockFillText = 6 kOutlineText = 7 ! kSelectedText = 8 keyAEHiliteRange = FOUR_CHAR_CODE('hrng') keyAEPinRange = FOUR_CHAR_CODE('pnrg') --- 654,658 ---- kBlockFillText = 6 kOutlineText = 7 ! kSelectedText = 8 keyAEHiliteRange = FOUR_CHAR_CODE('hrng') keyAEPinRange = FOUR_CHAR_CODE('pnrg') *************** *** 662,666 **** keyAELeftSide = FOUR_CHAR_CODE('klef') keyAERegionClass = FOUR_CHAR_CODE('rgnc') ! keyAEDragging = FOUR_CHAR_CODE('bool') keyAELeadingEdge = keyAELeftSide typeUnicodeText = FOUR_CHAR_CODE('utxt') --- 662,666 ---- keyAELeftSide = FOUR_CHAR_CODE('klef') keyAERegionClass = FOUR_CHAR_CODE('rgnc') ! keyAEDragging = FOUR_CHAR_CODE('bool') keyAELeadingEdge = keyAELeftSide typeUnicodeText = FOUR_CHAR_CODE('utxt') *************** *** 711,715 **** kFAEditCommand = FOUR_CHAR_CODE('edfa') kFAFileParam = FOUR_CHAR_CODE('faal') ! kFAIndexParam = FOUR_CHAR_CODE('indx') kAEInternetSuite = FOUR_CHAR_CODE('gurl') kAEISWebStarSuite = FOUR_CHAR_CODE('WWW\xbd') --- 711,715 ---- kFAEditCommand = FOUR_CHAR_CODE('edfa') kFAFileParam = FOUR_CHAR_CODE('faal') ! kFAIndexParam = FOUR_CHAR_CODE('indx') kAEInternetSuite = FOUR_CHAR_CODE('gurl') kAEISWebStarSuite = FOUR_CHAR_CODE('WWW\xbd') *************** *** 918,922 **** keyAEContainer = FOUR_CHAR_CODE('from') keyAEKeyForm = FOUR_CHAR_CODE('form') ! keyAEKeyData = FOUR_CHAR_CODE('seld') keyAERangeStart = FOUR_CHAR_CODE('star') keyAERangeStop = FOUR_CHAR_CODE('stop') --- 918,922 ---- keyAEContainer = FOUR_CHAR_CODE('from') keyAEKeyForm = FOUR_CHAR_CODE('form') ! keyAEKeyData = FOUR_CHAR_CODE('seld') keyAERangeStart = FOUR_CHAR_CODE('star') keyAERangeStop = FOUR_CHAR_CODE('stop') *************** *** 927,931 **** keyAEMarkProc = FOUR_CHAR_CODE('mark') keyAEAdjustMarksProc = FOUR_CHAR_CODE('adjm') ! keyAEGetErrDescProc = FOUR_CHAR_CODE('indc') formAbsolutePosition = FOUR_CHAR_CODE('indx') formRelativePosition = FOUR_CHAR_CODE('rele') --- 927,931 ---- keyAEMarkProc = FOUR_CHAR_CODE('mark') keyAEAdjustMarksProc = FOUR_CHAR_CODE('adjm') ! keyAEGetErrDescProc = FOUR_CHAR_CODE('indc') formAbsolutePosition = FOUR_CHAR_CODE('indx') formRelativePosition = FOUR_CHAR_CODE('rele') *************** *** 944,948 **** typeLogicalDescriptor = FOUR_CHAR_CODE('logi') typeCompDescriptor = FOUR_CHAR_CODE('cmpd') ! typeOSLTokenList = FOUR_CHAR_CODE('ostl') kAEIDoMinimum = 0x0000 kAEIDoWhose = 0x0001 --- 944,948 ---- typeLogicalDescriptor = FOUR_CHAR_CODE('logi') typeCompDescriptor = FOUR_CHAR_CODE('cmpd') ! typeOSLTokenList = FOUR_CHAR_CODE('ostl') kAEIDoMinimum = 0x0000 kAEIDoWhose = 0x0001 *************** *** 958,960 **** keyAEWhoseRangeStop = FOUR_CHAR_CODE('wstp') keyAEIndex = FOUR_CHAR_CODE('kidx') ! keyAETest = FOUR_CHAR_CODE('ktst') --- 958,960 ---- keyAEWhoseRangeStop = FOUR_CHAR_CODE('wstp') keyAEIndex = FOUR_CHAR_CODE('kidx') ! keyAETest = FOUR_CHAR_CODE('ktst') Index: CarbonEvents.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/Carbon/CarbonEvents.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CarbonEvents.py 5 Dec 2003 23:59:37 -0000 1.2 --- CarbonEvents.py 18 Jul 2004 06:14:46 -0000 1.3 *************** *** 72,78 **** kEventRawKeyModifiersChanged = 4 kEventHotKeyPressed = 5 ! kEventHotKeyReleased = 6 kEventKeyModifierNumLockBit = 16 ! kEventKeyModifierFnBit = 17 kEventKeyModifierNumLockMask = 1L << kEventKeyModifierNumLockBit kEventKeyModifierFnMask = 1L << kEventKeyModifierFnBit --- 72,78 ---- kEventRawKeyModifiersChanged = 4 kEventHotKeyPressed = 5 ! kEventHotKeyReleased = 6 kEventKeyModifierNumLockBit = 16 ! kEventKeyModifierFnBit = 17 kEventKeyModifierNumLockMask = 1L << kEventKeyModifierNumLockBit kEventKeyModifierFnMask = 1L << kEventKeyModifierFnBit *************** *** 263,270 **** kEventTabletPoint = 1 kEventTabletProximity = 2 ! kEventTabletPointer = 1 kEventVolumeMounted = 1 ! kEventVolumeUnmounted = 2 ! typeFSVolumeRefNum = FOUR_CHAR_CODE('voln') kEventAppearanceScrollBarVariantChanged = 1 kEventServiceCopy = 1 --- 263,270 ---- kEventTabletPoint = 1 kEventTabletProximity = 2 ! kEventTabletPointer = 1 kEventVolumeMounted = 1 ! kEventVolumeUnmounted = 2 ! typeFSVolumeRefNum = FOUR_CHAR_CODE('voln') kEventAppearanceScrollBarVariantChanged = 1 kEventServiceCopy = 1 *************** *** 272,278 **** kEventServiceGetTypes = 3 kEventServicePerform = 4 ! kEventParamDirectObject = FOUR_CHAR_CODE('----') kEventParamPostTarget = FOUR_CHAR_CODE('ptrg') ! typeEventTargetRef = FOUR_CHAR_CODE('etrg') kEventParamWindowRef = FOUR_CHAR_CODE('wind') kEventParamGrafPort = FOUR_CHAR_CODE('graf') --- 272,278 ---- kEventServiceGetTypes = 3 kEventServicePerform = 4 ! kEventParamDirectObject = FOUR_CHAR_CODE('----') kEventParamPostTarget = FOUR_CHAR_CODE('ptrg') ! typeEventTargetRef = FOUR_CHAR_CODE('etrg') kEventParamWindowRef = FOUR_CHAR_CODE('wind') kEventParamGrafPort = FOUR_CHAR_CODE('graf') *************** *** 305,309 **** typeHIPoint = FOUR_CHAR_CODE('hipt') typeHISize = FOUR_CHAR_CODE('hisz') ! typeHIRect = FOUR_CHAR_CODE('hirc') kEventParamMouseLocation = FOUR_CHAR_CODE('mloc') kEventParamMouseButton = FOUR_CHAR_CODE('mbtn') --- 305,309 ---- typeHIPoint = FOUR_CHAR_CODE('hipt') typeHISize = FOUR_CHAR_CODE('hisz') ! typeHIRect = FOUR_CHAR_CODE('hirc') kEventParamMouseLocation = FOUR_CHAR_CODE('mloc') kEventParamMouseButton = FOUR_CHAR_CODE('mbtn') *************** *** 315,319 **** kEventParamTabletEventType = FOUR_CHAR_CODE('tblt') typeMouseButton = FOUR_CHAR_CODE('mbtn') ! typeMouseWheelAxis = FOUR_CHAR_CODE('mwax') kEventParamKeyCode = FOUR_CHAR_CODE('kcod') kEventParamKeyMacCharCodes = FOUR_CHAR_CODE('kchr') --- 315,319 ---- kEventParamTabletEventType = FOUR_CHAR_CODE('tblt') typeMouseButton = FOUR_CHAR_CODE('mbtn') ! typeMouseWheelAxis = FOUR_CHAR_CODE('mwax') kEventParamKeyCode = FOUR_CHAR_CODE('kcod') kEventParamKeyMacCharCodes = FOUR_CHAR_CODE('kchr') *************** *** 321,325 **** kEventParamKeyUnicodes = FOUR_CHAR_CODE('kuni') kEventParamKeyboardType = FOUR_CHAR_CODE('kbdt') ! typeEventHotKeyID = FOUR_CHAR_CODE('hkid') kEventParamTextInputSendRefCon = FOUR_CHAR_CODE('tsrc') kEventParamTextInputSendComponentInstance = FOUR_CHAR_CODE('tsci') --- 321,325 ---- kEventParamKeyUnicodes = FOUR_CHAR_CODE('kuni') kEventParamKeyboardType = FOUR_CHAR_CODE('kbdt') ! typeEventHotKeyID = FOUR_CHAR_CODE('hkid') kEventParamTextInputSendRefCon = FOUR_CHAR_CODE('tsrc') kEventParamTextInputSendComponentInstance = FOUR_CHAR_CODE('tsci') *************** *** 351,357 **** kEventParamTextInputSendKeyboardEvent = FOUR_CHAR_CODE('tske') kEventParamTextInputSendTextServiceEncoding = FOUR_CHAR_CODE('tsse') ! kEventParamTextInputSendTextServiceMacEncoding = FOUR_CHAR_CODE('tssm') kEventParamHICommand = FOUR_CHAR_CODE('hcmd') ! typeHICommand = FOUR_CHAR_CODE('hcmd') kEventParamWindowFeatures = FOUR_CHAR_CODE('wftr') kEventParamWindowDefPart = FOUR_CHAR_CODE('wdpc') --- 351,357 ---- kEventParamTextInputSendKeyboardEvent = FOUR_CHAR_CODE('tske') kEventParamTextInputSendTextServiceEncoding = FOUR_CHAR_CODE('tsse') ! kEventParamTextInputSendTextServiceMacEncoding = FOUR_CHAR_CODE('tssm') kEventParamHICommand = FOUR_CHAR_CODE('hcmd') ! typeHICommand = FOUR_CHAR_CODE('hcmd') kEventParamWindowFeatures = FOUR_CHAR_CODE('wftr') kEventParamWindowDefPart = FOUR_CHAR_CODE('wdpc') *************** *** 376,380 **** typeWindowRegionCode = FOUR_CHAR_CODE('wshp') typeWindowDefPartCode = FOUR_CHAR_CODE('wdpt') ! typeClickActivationResult = FOUR_CHAR_CODE('clac') kEventParamControlPart = FOUR_CHAR_CODE('cprt') kEventParamInitCollection = FOUR_CHAR_CODE('icol') --- 376,380 ---- typeWindowRegionCode = FOUR_CHAR_CODE('wshp') typeWindowDefPartCode = FOUR_CHAR_CODE('wdpt') ! typeClickActivationResult = FOUR_CHAR_CODE('clac') kEventParamControlPart = FOUR_CHAR_CODE('cprt') kEventParamInitCollection = FOUR_CHAR_CODE('icol') *************** *** 403,407 **** typeControlActionUPP = FOUR_CHAR_CODE('caup') typeIndicatorDragConstraint = FOUR_CHAR_CODE('cidc') ! typeControlPartCode = FOUR_CHAR_CODE('cprt') kEventParamCurrentMenuTrackingMode = FOUR_CHAR_CODE('cmtm') kEventParamNewMenuTrackingMode = FOUR_CHAR_CODE('nmtm') --- 403,407 ---- typeControlActionUPP = FOUR_CHAR_CODE('caup') typeIndicatorDragConstraint = FOUR_CHAR_CODE('cidc') ! typeControlPartCode = FOUR_CHAR_CODE('cprt') kEventParamCurrentMenuTrackingMode = FOUR_CHAR_CODE('cmtm') kEventParamNewMenuTrackingMode = FOUR_CHAR_CODE('nmtm') *************** *** 429,436 **** typeMenuEventOptions = FOUR_CHAR_CODE('meop') typeThemeMenuState = FOUR_CHAR_CODE('tmns') ! typeThemeMenuItemType = FOUR_CHAR_CODE('tmit') kEventParamProcessID = FOUR_CHAR_CODE('psn ') kEventParamLaunchRefCon = FOUR_CHAR_CODE('lref') ! kEventParamLaunchErr = FOUR_CHAR_CODE('err ') kEventParamTabletPointRec = FOUR_CHAR_CODE('tbrc') kEventParamTabletProximityRec = FOUR_CHAR_CODE('tbpx') --- 429,436 ---- typeMenuEventOptions = FOUR_CHAR_CODE('meop') typeThemeMenuState = FOUR_CHAR_CODE('tmns') ! typeThemeMenuItemType = FOUR_CHAR_CODE('tmit') kEventParamProcessID = FOUR_CHAR_CODE('psn ') kEventParamLaunchRefCon = FOUR_CHAR_CODE('lref') ! kEventParamLaunchErr = FOUR_CHAR_CODE('err ') kEventParamTabletPointRec = FOUR_CHAR_CODE('tbrc') kEventParamTabletProximityRec = FOUR_CHAR_CODE('tbpx') *************** *** 438,443 **** typeTabletProximityRec = FOUR_CHAR_CODE('tbpx') kEventParamTabletPointerRec = FOUR_CHAR_CODE('tbrc') ! typeTabletPointerRec = FOUR_CHAR_CODE('tbrc') ! kEventParamNewScrollBarVariant = FOUR_CHAR_CODE('nsbv') kEventParamScrapRef = FOUR_CHAR_CODE('scrp') kEventParamServiceCopyTypes = FOUR_CHAR_CODE('svsd') --- 438,443 ---- typeTabletProximityRec = FOUR_CHAR_CODE('tbpx') kEventParamTabletPointerRec = FOUR_CHAR_CODE('tbrc') ! typeTabletPointerRec = FOUR_CHAR_CODE('tbrc') ! kEventParamNewScrollBarVariant = FOUR_CHAR_CODE('nsbv') kEventParamScrapRef = FOUR_CHAR_CODE('scrp') kEventParamServiceCopyTypes = FOUR_CHAR_CODE('svsd') *************** *** 446,450 **** kEventParamServiceUserData = FOUR_CHAR_CODE('svud') typeScrapRef = FOUR_CHAR_CODE('scrp') ! typeCFMutableArrayRef = FOUR_CHAR_CODE('cfma') # sHandler = NewEventHandlerUPP( x ) kMouseTrackingMousePressed = kMouseTrackingMouseDown --- 446,450 ---- kEventParamServiceUserData = FOUR_CHAR_CODE('svud') typeScrapRef = FOUR_CHAR_CODE('scrp') ! typeCFMutableArrayRef = FOUR_CHAR_CODE('cfma') # sHandler = NewEventHandlerUPP( x ) kMouseTrackingMousePressed = kMouseTrackingMouseDown Index: Components.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/Carbon/Components.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Components.py 30 Dec 2002 22:04:21 -0000 1.1 --- Components.py 18 Jul 2004 06:14:46 -0000 1.2 *************** *** 4,8 **** kAppleManufacturer = FOUR_CHAR_CODE('appl') kComponentResourceType = FOUR_CHAR_CODE('thng') ! kComponentAliasResourceType = FOUR_CHAR_CODE('thga') kAnyComponentType = 0 kAnyComponentSubType = 0 --- 4,8 ---- kAppleManufacturer = FOUR_CHAR_CODE('appl') kComponentResourceType = FOUR_CHAR_CODE('thng') ! kComponentAliasResourceType = FOUR_CHAR_CODE('thga') kAnyComponentType = 0 kAnyComponentSubType = 0 *************** *** 20,24 **** kComponentGetMPWorkFunctionSelect = -8 kComponentExecuteWiredActionSelect = -9 ! kComponentGetPublicResourceSelect = -10 componentDoAutoVersion = (1 << 0) componentWantsUnregister = (1 << 1) --- 20,24 ---- kComponentGetMPWorkFunctionSelect = -8 kComponentExecuteWiredActionSelect = -9 ! kComponentGetPublicResourceSelect = -10 componentDoAutoVersion = (1 << 0) componentWantsUnregister = (1 << 1) Index: ControlAccessor.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/Carbon/ControlAccessor.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ControlAccessor.py 9 Apr 2003 13:25:19 -0000 1.2 --- ControlAccessor.py 18 Jul 2004 06:14:46 -0000 1.3 *************** *** 7,14 **** def SetControlData_Handle(control, part, selector, data): control.SetControlData_Handle(part, selector, data) ! def GetControlData_Handle(control, part, selector): return control.GetControlData_Handle(part, selector) ! _accessdict = { kControlPopupButtonMenuHandleTag: (SetControlData_Handle, GetControlData_Handle), --- 7,14 ---- def SetControlData_Handle(control, part, selector, data): control.SetControlData_Handle(part, selector, data) ! def GetControlData_Handle(control, part, selector): return control.GetControlData_Handle(part, selector) ! _accessdict = { kControlPopupButtonMenuHandleTag: (SetControlData_Handle, GetControlData_Handle), *************** *** 17,26 **** _codingdict = { kControlPushButtonDefaultTag : ("b", None, None), ! kControlEditTextTextTag: (None, None, None), kControlEditTextPasswordTag: (None, None, None), ! kControlPopupButtonMenuIDTag: ("h", None, None), ! kControlListBoxDoubleClickTag: ("b", None, None), } --- 17,26 ---- _codingdict = { kControlPushButtonDefaultTag : ("b", None, None), ! kControlEditTextTextTag: (None, None, None), kControlEditTextPasswordTag: (None, None, None), ! kControlPopupButtonMenuIDTag: ("h", None, None), ! kControlListBoxDoubleClickTag: ("b", None, None), } *************** *** 39,43 **** data = struct.pack(structfmt, data) control.SetControlData(part, selector, data) ! def GetControlData(control, part, selector): if _accessdict.has_key(selector): --- 39,43 ---- data = struct.pack(structfmt, data) control.SetControlData(part, selector, data) ! def GetControlData(control, part, selector): if _accessdict.has_key(selector): *************** *** 55,57 **** data = data[0] return data - --- 55,56 ---- Index: Controls.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/Carbon/Controls.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Controls.py 5 Dec 2003 23:59:37 -0000 1.2 --- Controls.py 18 Jul 2004 06:14:46 -0000 1.3 *************** *** 18,28 **** controlNotifyClick = FOUR_CHAR_CODE('clik') controlNotifyFocus = FOUR_CHAR_CODE('focu') ! controlNotifyKey = FOUR_CHAR_CODE('key ') ! kControlCanAutoInvalidate = 1L << 0 staticTextProc = 256 editTextProc = 272 iconProc = 288 userItemProc = 304 ! pictItemProc = 320 cFrameColor = 0 cBodyColor = 1 --- 18,28 ---- controlNotifyClick = FOUR_CHAR_CODE('clik') controlNotifyFocus = FOUR_CHAR_CODE('focu') ! controlNotifyKey = FOUR_CHAR_CODE('key ') ! kControlCanAutoInvalidate = 1L << 0 staticTextProc = 256 editTextProc = 272 iconProc = 288 userItemProc = 304 ! pictItemProc = 320 cFrameColor = 0 cBodyColor = 1 *************** *** 31,35 **** kNumberCtlCTabEntries = 4 kControlNoVariant = 0 ! kControlUsesOwningWindowsFontVariant = 1 << 3 kControlNoPart = 0 kControlIndicatorPart = 129 --- 31,35 ---- kNumberCtlCTabEntries = 4 kControlNoVariant = 0 ! kControlUsesOwningWindowsFontVariant = 1 << 3 kControlNoPart = 0 kControlIndicatorPart = 129 *************** *** 41,45 **** kControlFocusNoPart = 0 kControlFocusNextPart = -1 ! kControlFocusPrevPart = -2 kControlCollectionTagBounds = FOUR_CHAR_CODE('boun') kControlCollectionTagValue = FOUR_CHAR_CODE('valu') --- 41,45 ---- kControlFocusNoPart = 0 kControlFocusNextPart = -1 ! kControlFocusPrevPart = -2 kControlCollectionTagBounds = FOUR_CHAR_CODE('boun') kControlCollectionTagValue = FOUR_CHAR_CODE('valu') *************** *** 54,58 **** kControlCollectionTagIDID = FOUR_CHAR_CODE('idid') kControlCollectionTagCommand = FOUR_CHAR_CODE('cmd ') ! kControlCollectionTagVarCode = FOUR_CHAR_CODE('varc') kControlContentTextOnly = 0 kControlNoContent = 0 --- 54,58 ---- kControlCollectionTagIDID = FOUR_CHAR_CODE('idid') kControlCollectionTagCommand = FOUR_CHAR_CODE('cmd ') ! kControlCollectionTagVarCode = FOUR_CHAR_CODE('varc') kControlContentTextOnly = 0 kControlNoContent = 0 *************** *** 68,76 **** kControlKeyScriptBehaviorAllowAnyScript = FOUR_CHAR_CODE('any ') kControlKeyScriptBehaviorPrefersRoman = FOUR_CHAR_CODE('prmn') ! kControlKeyScriptBehaviorRequiresRoman = FOUR_CHAR_CODE('rrmn') kControlFontBigSystemFont = -1 kControlFontSmallSystemFont = -2 kControlFontSmallBoldSystemFont = -3 ! kControlFontViewSystemFont = -4 kControlUseFontMask = 0x0001 kControlUseFaceMask = 0x0002 --- 68,76 ---- kControlKeyScriptBehaviorAllowAnyScript = FOUR_CHAR_CODE('any ') kControlKeyScriptBehaviorPrefersRoman = FOUR_CHAR_CODE('prmn') ! kControlKeyScriptBehaviorRequiresRoman = FOUR_CHAR_CODE('rrmn') kControlFontBigSystemFont = -1 kControlFontSmallSystemFont = -2 kControlFontSmallBoldSystemFont = -3 ! kControlFontViewSystemFont = -4 kControlUseFontMask = 0x0001 kControlUseFaceMask = 0x0002 *************** *** 82,91 **** kControlUseAllMask = 0x00FF kControlAddFontSizeMask = 0x0100 ! kControlAddToMetaFontMask = 0x0200 ! kControlUseThemeFontIDMask = 0x0080 kDoNotActivateAndIgnoreClick = 0 kDoNotActivateAndHandleClick = 1 kActivateAndIgnoreClick = 2 ! kActivateAndHandleClick = 3 kControlFontStyleTag = FOUR_CHAR_CODE('font') kControlKeyFilterTag = FOUR_CHAR_CODE('fltr') --- 82,91 ---- kControlUseAllMask = 0x00FF kControlAddFontSizeMask = 0x0100 ! kControlAddToMetaFontMask = 0x0200 ! kControlUseThemeFontIDMask = 0x0080 kDoNotActivateAndIgnoreClick = 0 kDoNotActivateAndHandleClick = 1 kActivateAndIgnoreClick = 2 ! kActivateAndHandleClick = 3 kControlFontStyleTag = FOUR_CHAR_CODE('font') kControlKeyFilterTag = FOUR_CHAR_CODE('fltr') *************** *** 111,115 **** kControlSupportsContextualMenus = 1 << 21 kControlSupportsClickActivation = 1 << 22 ! kControlIdlesWithTimer = 1 << 23 drawCntl = 0 testCntl = 1 --- 111,115 ---- kControlSupportsContextualMenus = 1 << 21 kControlSupportsClickActivation = 1 << 22 ! kControlIdlesWithTimer = 1 << 23 drawCntl = 0 testCntl = 1 *************** *** 150,154 **** kControlMsgDisplayDebugInfo = 46 kControlMsgContextualMenuClick = 47 ! kControlMsgGetClickActivation = 48 kControlSizeNormal = 0 kControlSizeSmall = 1 --- 150,154 ---- kControlMsgDisplayDebugInfo = 46 kControlMsgContextualMenuClick = 47 ! kControlMsgGetClickActivation = 48 kControlSizeNormal = 0 kControlSizeSmall = 1 *************** *** 166,172 **** vAxisOnly = 2 kControlDefProcPtr = 0 ! kControlDefObjectClass = 1 kControlKindSignatureApple = FOUR_CHAR_CODE('appl') ! kControlPropertyPersistent = 0x00000001 kDragTrackingEnterControl = 2 kDragTrackingInControl = 3 --- 166,172 ---- vAxisOnly = 2 kControlDefProcPtr = 0 ! kControlDefObjectClass = 1 kControlKindSignatureApple = FOUR_CHAR_CODE('appl') ! kControlPropertyPersistent = 0x00000001 kDragTrackingEnterControl = 2 kDragTrackingInControl = 3 *************** *** 179,183 **** kControlInactiveControlPart = kControlInactivePart kControlTabListResType = FOUR_CHAR_CODE('tab#') ! kControlListDescResType = FOUR_CHAR_CODE('ldes') kControlCheckBoxUncheckedValue = 0 kControlCheckBoxCheckedValue = 1 --- 179,183 ---- kControlInactiveControlPart = kControlInactivePart kControlTabListResType = FOUR_CHAR_CODE('tab#') ! kControlListDescResType = FOUR_CHAR_CODE('ldes') kControlCheckBoxUncheckedValue = 0 kControlCheckBoxCheckedValue = 1 *************** *** 229,233 **** kControlClockAMPMPart = 12 kControlDataBrowserPart = 24 ! kControlDataBrowserDraggedPart = 25 kControlBevelButtonSmallBevelProc = 32 kControlBevelButtonNormalBevelProc = 33 --- 229,233 ---- kControlClockAMPMPart = 12 kControlDataBrowserPart = 24 ! kControlDataBrowserDraggedPart = 25 kControlBevelButtonSmallBevelProc = 32 kControlBevelButtonNormalBevelProc = 33 *************** *** 246,250 **** kControlBehaviorMultiValueMenu = 0x4000 kControlBehaviorOffsetContents = 0x8000 ! kControlBehaviorCommandMenu = 0x2000 kControlBevelButtonMenuOnBottom = 0 kControlBevelButtonMenuOnRight = (1 << 2) --- 246,250 ---- kControlBehaviorMultiValueMenu = 0x4000 kControlBehaviorOffsetContents = 0x8000 ! kControlBehaviorCommandMenu = 0x2000 kControlBevelButtonMenuOnBottom = 0 kControlBevelButtonMenuOnRight = (1 << 2) *************** *** 280,289 **** kControlBevelButtonMenuHandleTag = FOUR_CHAR_CODE('mhnd') kControlBevelButtonMenuRefTag = FOUR_CHAR_CODE('mhnd') ! # kControlBevelButtonCenterPopupGlyphTag = FOUR_CHAR_CODE('pglc') kControlBevelButtonLastMenuTag = FOUR_CHAR_CODE('lmnu') ! kControlBevelButtonMenuDelayTag = FOUR_CHAR_CODE('mdly') ! kControlBevelButtonScaleIconTag = FOUR_CHAR_CODE('scal') kControlBevelButtonOwnedMenuRefTag = FOUR_CHAR_CODE('omrf') ! kControlBevelButtonKindTag = FOUR_CHAR_CODE('bebk') kControlSliderProc = 48 kControlSliderLiveFeedback = (1 << 0) --- 280,289 ---- kControlBevelButtonMenuHandleTag = FOUR_CHAR_CODE('mhnd') kControlBevelButtonMenuRefTag = FOUR_CHAR_CODE('mhnd') ! # kControlBevelButtonCenterPopupGlyphTag = FOUR_CHAR_CODE('pglc') kControlBevelButtonLastMenuTag = FOUR_CHAR_CODE('lmnu') ! kControlBevelButtonMenuDelayTag = FOUR_CHAR_CODE('mdly') ! kControlBevelButtonScaleIconTag = FOUR_CHAR_CODE('scal') kControlBevelButtonOwnedMenuRefTag = FOUR_CHAR_CODE('omrf') ! kControlBevelButtonKindTag = FOUR_CHAR_CODE('bebk') kControlSliderProc = 48 kControlSliderLiveFeedback = (1 << 0) *************** *** 303,307 **** kControlDisclosureTrianglePointLeft = 2 kControlKindDisclosureTriangle = FOUR_CHAR_CODE('dist') ! kControlTriangleLastValueTag = FOUR_CHAR_CODE('last') kControlProgressBarProc = 80 kControlRelevanceBarProc = 81 --- 303,307 ---- kControlDisclosureTrianglePointLeft = 2 kControlKindDisclosureTriangle = FOUR_CHAR_CODE('dist') ! kControlTriangleLastValueTag = FOUR_CHAR_CODE('last') kControlProgressBarProc = 80 kControlRelevanceBarProc = 81 *************** *** 309,318 **** kControlKindRelevanceBar = FOUR_CHAR_CODE('relb') kControlProgressBarIndeterminateTag = FOUR_CHAR_CODE('inde') ! kControlProgressBarAnimatingTag = FOUR_CHAR_CODE('anim') kControlLittleArrowsProc = 96 kControlKindLittleArrows = FOUR_CHAR_CODE('larr') kControlChasingArrowsProc = 112 kControlKindChasingArrows = FOUR_CHAR_CODE('carr') ! kControlChasingArrowsAnimatingTag = FOUR_CHAR_CODE('anim') kControlTabLargeProc = 128 kControlTabSmallProc = 129 --- 309,318 ---- kControlKindRelevanceBar = FOUR_CHAR_CODE('relb') kControlProgressBarIndeterminateTag = FOUR_CHAR_CODE('inde') ! kControlProgressBarAnimatingTag = FOUR_CHAR_CODE('anim') kControlLittleArrowsProc = 96 kControlKindLittleArrows = FOUR_CHAR_CODE('larr') kControlChasingArrowsProc = 112 kControlKindChasingArrows = FOUR_CHAR_CODE('carr') ! kControlChasingArrowsAnimatingTag = FOUR_CHAR_CODE('anim') kControlTabLargeProc = 128 kControlTabSmallProc = 129 *************** *** 324,328 **** kControlTabSmallEastProc = 133 kControlTabLargeWestProc = 134 ! kControlTabSmallWestProc = 135 kControlTabDirectionNorth = 0 kControlTabDirectionSouth = 1 --- 324,328 ---- kControlTabSmallEastProc = 133 kControlTabLargeWestProc = 134 ! kControlTabSmallWestProc = 135 kControlTabDirectionNorth = 0 kControlTabDirectionSouth = 1 *************** *** 334,342 **** kControlTabContentRectTag = FOUR_CHAR_CODE('rect') kControlTabEnabledFlagTag = FOUR_CHAR_CODE('enab') ! kControlTabFontStyleTag = kControlFontStyleTag ! kControlTabInfoTag = FOUR_CHAR_CODE('tabi') ! kControlTabImageContentTag = FOUR_CHAR_CODE('cont') kControlTabInfoVersionZero = 0 ! kControlTabInfoVersionOne = 1 kControlSeparatorLineProc = 144 kControlKindSeparator = FOUR_CHAR_CODE('sepa') --- 334,342 ---- kControlTabContentRectTag = FOUR_CHAR_CODE('rect') kControlTabEnabledFlagTag = FOUR_CHAR_CODE('enab') ! kControlTabFontStyleTag = kControlFontStyleTag ! kControlTabInfoTag = FOUR_CHAR_CODE('tabi') ! kControlTabImageContentTag = FOUR_CHAR_CODE('cont') kControlTabInfoVersionZero = 0 ! kControlTabInfoVersionOne = 1 kControlSeparatorLineProc = 144 kControlKindSeparator = FOUR_CHAR_CODE('sepa') *************** *** 352,362 **** kControlGroupBoxMenuHandleTag = FOUR_CHAR_CODE('mhan') kControlGroupBoxMenuRefTag = FOUR_CHAR_CODE('mhan') ! kControlGroupBoxFontStyleTag = kControlFontStyleTag ! kControlGroupBoxTitleRectTag = FOUR_CHAR_CODE('trec') kControlImageWellProc = 176 kControlKindImageWell = FOUR_CHAR_CODE('well') kControlImageWellContentTag = FOUR_CHAR_CODE('cont') kControlImageWellTransformTag = FOUR_CHAR_CODE('tran') ! kControlImageWellIsDragDestinationTag = FOUR_CHAR_CODE('drag') kControlPopupArrowEastProc = 192 kControlPopupArrowWestProc = 193 --- 352,362 ---- kControlGroupBoxMenuHandleTag = FOUR_CHAR_CODE('mhan') kControlGroupBoxMenuRefTag = FOUR_CHAR_CODE('mhan') ! kControlGroupBoxFontStyleTag = kControlFontStyleTag ! kControlGroupBoxTitleRectTag = FOUR_CHAR_CODE('trec') kControlImageWellProc = 176 kControlKindImageWell = FOUR_CHAR_CODE('well') kControlImageWellContentTag = FOUR_CHAR_CODE('cont') kControlImageWellTransformTag = FOUR_CHAR_CODE('tran') ! kControlImageWellIsDragDestinationTag = FOUR_CHAR_CODE('drag') kControlPopupArrowEastProc = 192 kControlPopupArrowWestProc = 193 *************** *** 393,397 **** kControlClockLongDateTag = FOUR_CHAR_CODE('date') kControlClockFontStyleTag = kControlFontStyleTag ! kControlClockAnimatingTag = FOUR_CHAR_CODE('anim') kControlUserPaneProc = 256 kControlKindUserPane = FOUR_CHAR_CODE('upan') --- 393,397 ---- kControlClockLongDateTag = FOUR_CHAR_CODE('date') kControlClockFontStyleTag = kControlFontStyleTag ! kControlClockAnimatingTag = FOUR_CHAR_CODE('anim') kControlUserPaneProc = 256 kControlKindUserPane = FOUR_CHAR_CODE('upan') *************** *** 404,411 **** kControlUserPaneActivateProcTag = FOUR_CHAR_CODE('acti') kControlUserPaneFocusProcTag = FOUR_CHAR_CODE('foci') ! kControlUserPaneBackgroundProcTag = FOUR_CHAR_CODE('back') kControlEditTextProc = 272 kControlEditTextPasswordProc = 274 ! kControlEditTextInlineInputProc = 276 kControlKindEditText = FOUR_CHAR_CODE('etxt') kControlEditTextStyleTag = kControlFontStyleTag --- 404,411 ---- kControlUserPaneActivateProcTag = FOUR_CHAR_CODE('acti') kControlUserPaneFocusProcTag = FOUR_CHAR_CODE('foci') ! kControlUserPaneBackgroundProcTag = FOUR_CHAR_CODE('back') kControlEditTextProc = 272 kControlEditTextPasswordProc = 274 ! kControlEditTextInlineInputProc = 276 kControlKindEditText = FOUR_CHAR_CODE('etxt') kControlEditTextStyleTag = kControlFontStyleTag *************** *** 414,418 **** kControlEditTextKeyFilterTag = kControlKeyFilterTag kControlEditTextSelectionTag = FOUR_CHAR_CODE('sele') ! kControlEditTextPasswordTag = FOUR_CHAR_CODE('pass') kControlEditTextKeyScriptBehaviorTag = FOUR_CHAR_CODE('kscr') kControlEditTextLockedTag = FOUR_CHAR_CODE('lock') --- 414,418 ---- kControlEditTextKeyFilterTag = kControlKeyFilterTag kControlEditTextSelectionTag = FOUR_CHAR_CODE('sele') ! kControlEditTextPasswordTag = FOUR_CHAR_CODE('pass') kControlEditTextKeyScriptBehaviorTag = FOUR_CHAR_CODE('kscr') kControlEditTextLockedTag = FOUR_CHAR_CODE('lock') *************** *** 420,450 **** kControlEditTextValidationProcTag = FOUR_CHAR_CODE('vali') kControlEditTextInlinePreUpdateProcTag = FOUR_CHAR_CODE('prup') ! kControlEditTextInlinePostUpdateProcTag = FOUR_CHAR_CODE('poup') kControlEditTextCFStringTag = FOUR_CHAR_CODE('cfst') ! kControlEditTextPasswordCFStringTag = FOUR_CHAR_CODE('pwcf') kControlStaticTextProc = 288 kControlKindStaticText = FOUR_CHAR_CODE('stxt') kControlStaticTextStyleTag = kControlFontStyleTag kControlStaticTextTextTag = FOUR_CHAR_CODE('text') ! kControlStaticTextTextHeightTag = FOUR_CHAR_CODE('thei') ! kControlStaticTextTruncTag = FOUR_CHAR_CODE('trun') ! kControlStaticTextCFStringTag = FOUR_CHAR_CODE('cfst') kControlPictureProc = 304 ! kControlPictureNoTrackProc = 305 kControlKindPicture = FOUR_CHAR_CODE('pict') ! kControlPictureHandleTag = FOUR_CHAR_CODE('pich') kControlIconProc = 320 kControlIconNoTrackProc = 321 kControlIconSuiteProc = 322 ! kControlIconSuiteNoTrackProc = 323 kControlIconRefProc = 324 ! kControlIconRefNoTrackProc = 325 kControlKindIcon = FOUR_CHAR_CODE('icon') kControlIconTransformTag = FOUR_CHAR_CODE('trfm') ! kControlIconAlignmentTag = FOUR_CHAR_CODE('algn') kControlIconResourceIDTag = FOUR_CHAR_CODE('ires') ! kControlIconContentTag = FOUR_CHAR_CODE('cont') kControlWindowHeaderProc = 336 ! kControlWindowListViewHeaderProc = 337 kControlKindWindowHeader = FOUR_CHAR_CODE('whed') kControlListBoxProc = 352 --- 420,450 ---- kControlEditTextValidationProcTag = FOUR_CHAR_CODE('vali') kControlEditTextInlinePreUpdateProcTag = FOUR_CHAR_CODE('prup') ! kControlEditTextInlinePostUpdateProcTag = FOUR_CHAR_CODE('poup') kControlEditTextCFStringTag = FOUR_CHAR_CODE('cfst') ! kControlEditTextPasswordCFStringTag = FOUR_CHAR_CODE('pwcf') kControlStaticTextProc = 288 kControlKindStaticText = FOUR_CHAR_CODE('stxt') kControlStaticTextStyleTag = kControlFontStyleTag kControlStaticTextTextTag = FOUR_CHAR_CODE('text') ! kControlStaticTextTextHeightTag = FOUR_CHAR_CODE('thei') ! kControlStaticTextTruncTag = FOUR_CHAR_CODE('trun') ! kControlStaticTextCFStringTag = FOUR_CHAR_CODE('cfst') kControlPictureProc = 304 ! kControlPictureNoTrackProc = 305 kControlKindPicture = FOUR_CHAR_CODE('pict') ! kControlPictureHandleTag = FOUR_CHAR_CODE('pich') kControlIconProc = 320 kControlIconNoTrackProc = 321 kControlIconSuiteProc = 322 ! kControlIconSuiteNoTrackProc = 323 kControlIconRefProc = 324 ! kControlIconRefNoTrackProc = 325 kControlKindIcon = FOUR_CHAR_CODE('icon') kControlIconTransformTag = FOUR_CHAR_CODE('trfm') ! kControlIconAlignmentTag = FOUR_CHAR_CODE('algn') kControlIconResourceIDTag = FOUR_CHAR_CODE('ires') ! kControlIconContentTag = FOUR_CHAR_CODE('cont') kControlWindowHeaderProc = 336 ! kControlWindowListViewHeaderProc = 337 kControlKindWindowHeader = FOUR_CHAR_CODE('whed') kControlListBoxProc = 352 *************** *** 453,464 **** kControlListBoxListHandleTag = FOUR_CHAR_CODE('lhan') kControlListBoxKeyFilterTag = kControlKeyFilterTag ! kControlListBoxFontStyleTag = kControlFontStyleTag kControlListBoxDoubleClickTag = FOUR_CHAR_CODE('dblc') ! kControlListBoxLDEFTag = FOUR_CHAR_CODE('ldef') kControlPushButtonProc = 368 kControlCheckBoxProc = 369 kControlRadioButtonProc = 370 kControlPushButLeftIconProc = 374 ! kControlPushButRightIconProc = 375 kControlCheckBoxAutoToggleProc = 371 kControlRadioButtonAutoToggleProc = 372 --- 453,464 ---- kControlListBoxListHandleTag = FOUR_CHAR_CODE('lhan') kControlListBoxKeyFilterTag = kControlKeyFilterTag ! kControlListBoxFontStyleTag = kControlFontStyleTag kControlListBoxDoubleClickTag = FOUR_CHAR_CODE('dblc') ! kControlListBoxLDEFTag = FOUR_CHAR_CODE('ldef') kControlPushButtonProc = 368 kControlCheckBoxProc = 369 kControlRadioButtonProc = 370 kControlPushButLeftIconProc = 374 ! kControlPushButRightIconProc = 375 kControlCheckBoxAutoToggleProc = 371 kControlRadioButtonAutoToggleProc = 372 *************** *** 470,478 **** kControlKindCheckBox = FOUR_CHAR_CODE('cbox') kControlPushButtonDefaultTag = FOUR_CHAR_CODE('dflt') ! kControlPushButtonCancelTag = FOUR_CHAR_CODE('cncl') kControlScrollBarProc = 384 ! kControlScrollBarLiveProc = 386 kControlKindScrollBar = FOUR_CHAR_CODE('sbar') ! kControlScrollBarShowsArrowsTag = FOUR_CHAR_CODE('arro') kControlPopupButtonProc = 400 kControlPopupFixedWidthVariant = 1 << 0 --- 470,478 ---- kControlKindCheckBox = FOUR_CHAR_CODE('cbox') kControlPushButtonDefaultTag = FOUR_CHAR_CODE('dflt') ! kControlPushButtonCancelTag = FOUR_CHAR_CODE('cncl') kControlScrollBarProc = 384 ! kControlScrollBarLiveProc = 386 kControlKindScrollBar = FOUR_CHAR_CODE('sbar') ! kControlScrollBarShowsArrowsTag = FOUR_CHAR_CODE('arro') kControlPopupButtonProc = 400 kControlPopupFixedWidthVariant = 1 << 0 *************** *** 483,490 **** kControlPopupButtonMenuHandleTag = FOUR_CHAR_CODE('mhan') kControlPopupButtonMenuRefTag = FOUR_CHAR_CODE('mhan') ! kControlPopupButtonMenuIDTag = FOUR_CHAR_CODE('mnid') kControlPopupButtonExtraHeightTag = FOUR_CHAR_CODE('exht') ! kControlPopupButtonOwnedMenuRefTag = FOUR_CHAR_CODE('omrf') ! kControlPopupButtonCheckCurrentTag = FOUR_CHAR_CODE('chck') kControlRadioGroupProc = 416 kControlKindRadioGroup = FOUR_CHAR_CODE('rgrp') --- 483,490 ---- kControlPopupButtonMenuHandleTag = FOUR_CHAR_CODE('mhan') kControlPopupButtonMenuRefTag = FOUR_CHAR_CODE('mhan') ! kControlPopupButtonMenuIDTag = FOUR_CHAR_CODE('mnid') kControlPopupButtonExtraHeightTag = FOUR_CHAR_CODE('exht') ! kControlPopupButtonOwnedMenuRefTag = FOUR_CHAR_CODE('omrf') ! kControlPopupButtonCheckCurrentTag = FOUR_CHAR_CODE('chck') kControlRadioGroupProc = 416 kControlKindRadioGroup = FOUR_CHAR_CODE('rgrp') *************** *** 496,500 **** kControlScrollTextBoxAutoScrollAmountTag = FOUR_CHAR_CODE('samt') kControlScrollTextBoxContentsTag = FOUR_CHAR_CODE('tres') ! kControlScrollTextBoxAnimatingTag = FOUR_CHAR_CODE('anim') kControlKindDisclosureButton = FOUR_CHAR_CODE('disb') kControlDisclosureButtonClosed = 0 --- 496,500 ---- kControlScrollTextBoxAutoScrollAmountTag = FOUR_CHAR_CODE('samt') kControlScrollTextBoxContentsTag = FOUR_CHAR_CODE('tres') ! kControlScrollTextBoxAnimatingTag = FOUR_CHAR_CODE('anim') kControlKindDisclosureButton = FOUR_CHAR_CODE('disb') kControlDisclosureButtonClosed = 0 *************** *** 503,507 **** kControlRoundButtonLargeSize = kControlSizeLarge kControlRoundButtonContentTag = FOUR_CHAR_CODE('cont') ! kControlRoundButtonSizeTag = kControlSizeTag kControlKindRoundButton = FOUR_CHAR_CODE('rndb') kControlKindDataBrowser = FOUR_CHAR_CODE('datb') --- 503,507 ---- kControlRoundButtonLargeSize = kControlSizeLarge kControlRoundButtonContentTag = FOUR_CHAR_CODE('cont') ! kControlRoundButtonSizeTag = kControlSizeTag kControlKindRoundButton = FOUR_CHAR_CODE('rndb') kControlKindDataBrowser = FOUR_CHAR_CODE('datb') *************** *** 512,516 **** errDataBrowserInvalidPropertyPart = -4973 errDataBrowserInvalidPropertyData = -4974 ! errDataBrowserPropertyNotSupported = -4979 kControlDataBrowserIncludesFrameAndFocusTag = FOUR_CHAR_CODE('brdr') kControlDataBrowserKeyFilterTag = kControlEditTextKeyFilterTag --- 512,516 ---- errDataBrowserInvalidPropertyPart = -4973 errDataBrowserInvalidPropertyData = -4974 ! errDataBrowserPropertyNotSupported = -4979 kControlDataBrowserIncludesFrameAndFocusTag = FOUR_CHAR_CODE('brdr') kControlDataBrowserKeyFilterTag = kControlEditTextKeyFilterTag *************** *** 526,539 **** kDataBrowserNoDisjointSelection = 1 << 4 kDataBrowserAlwaysExtendSelection = 1 << 5 ! kDataBrowserNeverEmptySelectionSet = 1 << 6 kDataBrowserOrderUndefined = 0 kDataBrowserOrderIncreasing = 1 kDataBrowserOrderDecreasing = 2 ! kDataBrowserNoItem = 0L kDataBrowserItemNoState = 0 # kDataBrowserItemAnyState = (unsigned long)(-1) kDataBrowserItemIsSelected = 1 << 0 kDataBrowserContainerIsOpen = 1 << 1 ! kDataBrowserItemIsDragTarget = 1 << 2 kDataBrowserRevealOnly = 0 kDataBrowserRevealAndCenterInView = 1 << 0 --- 526,539 ---- kDataBrowserNoDisjointSelection = 1 << 4 kDataBrowserAlwaysExtendSelection = 1 << 5 ! kDataBrowserNeverEmptySelectionSet = 1 << 6 kDataBrowserOrderUndefined = 0 kDataBrowserOrderIncreasing = 1 kDataBrowserOrderDecreasing = 2 ! kDataBrowserNoItem = 0L kDataBrowserItemNoState = 0 # kDataBrowserItemAnyState = (unsigned long)(-1) kDataBrowserItemIsSelected = 1 << 0 kDataBrowserContainerIsOpen = 1 << 1 ! kDataBrowserItemIsDragTarget = 1 << 2 kDataBrowserRevealOnly = 0 kDataBrowserRevealAndCenterInView = 1 << 0 *************** *** 542,546 **** kDataBrowserItemsAssign = 1 kDataBrowserItemsToggle = 2 ! kDataBrowserItemsRemove = 3 kDataBrowserSelectionAnchorUp = 0 kDataBrowserSelectionAnchorDown = 1 --- 542,546 ---- kDataBrowserItemsAssign = 1 kDataBrowserItemsToggle = 2 ! kDataBrowserItemsRemove = 3 kDataBrowserSelectionAnchorUp = 0 kDataBrowserSelectionAnchorDown = 1 *************** *** 569,573 **** kDataBrowserTargetChanged = 15 kDataBrowserUserStateChanged = 13 ! kDataBrowserSelectionSetChanged = 14 kDataBrowserItemNoProperty = 0L kDataBrowserItemIsActiveProperty = 1L --- 569,573 ---- kDataBrowserTargetChanged = 15 kDataBrowserUserStateChanged = 13 ! kDataBrowserSelectionSetChanged = 14 kDataBrowserItemNoProperty = 0L kDataBrowserItemIsActiveProperty = 1L *************** *** 581,585 **** kDataBrowserContainerAliasIDProperty = 9L kDataBrowserColumnViewPreviewProperty = 10L ! kDataBrowserItemParentContainerProperty = 11L kDataBrowserCustomType = 0x3F3F3F3F kDataBrowserIconType = FOUR_CHAR_CODE('icnr') --- 581,585 ---- kDataBrowserContainerAliasIDProperty = 9L kDataBrowserColumnViewPreviewProperty = 10L ! kDataBrowserItemParentContainerProperty = 11L kDataBrowserCustomType = 0x3F3F3F3F kDataBrowserIconType = FOUR_CHAR_CODE('icnr') *************** *** 591,595 **** kDataBrowserRelevanceRankType = FOUR_CHAR_CODE('rank') kDataBrowserPopupMenuType = FOUR_CHAR_CODE('menu') ! kDataBrowserIconAndTextType = FOUR_CHAR_CODE('ticn') kDataBrowserPropertyEnclosingPart = 0L kDataBrowserPropertyContentPart = FOUR_CHAR_CODE('----') --- 591,595 ---- kDataBrowserRelevanceRankType = FOUR_CHAR_CODE('rank') kDataBrowserPopupMenuType = FOUR_CHAR_CODE('menu') ! kDataBrowserIconAndTextType = FOUR_CHAR_CODE('ticn') kDataBrowserPropertyEnclosingPart = 0L kDataBrowserPropertyContentPart = FOUR_CHAR_CODE('----') *************** *** 605,609 **** kDataBrowserDefaultPropertyFlags = 0 << 0 kDataBrowserUniversalPropertyFlags = kDataBrowserUniversalPropertyFlagsMask ! kDataBrowserPropertyIsEditable = kDataBrowserPropertyIsMutable kDataBrowserPropertyFlagsOffset = 8 kDataBrowserPropertyFlagsMask = 0xFF << kDataBrowserPropertyFlagsOffset --- 605,609 ---- kDataBrowserDefaultPropertyFlags = 0 << 0 kDataBrowserUniversalPropertyFlags = kDataBrowserUniversalPropertyFlagsMask ! kDataBrowserPropertyIsEditable = kDataBrowserPropertyIsMutable kDataBrowserPropertyFlagsOffset = 8 kDataBrowserPropertyFlagsMask = 0xFF << kDataBrowserPropertyFlagsOffset *************** *** 621,628 **** kDataBrowserTruncateTextAtStart = 1 << kDataBrowserPropertyFlagsOffset kDataBrowserPropertyModificationFlags = kDataBrowserPropertyFlagsMask ! kDataBrowserRelativeDateTime = kDataBrowserDateTimeRelative kDataBrowserViewSpecificFlagsOffset = 16 kDataBrowserViewSpecificFlagsMask = 0xFF << kDataBrowserViewSpecificFlagsOffset ! kDataBrowserViewSpecificPropertyFlags = kDataBrowserViewSpecificFlagsMask kDataBrowserClientPropertyFlagsOffset = 24 # kDataBrowserClientPropertyFlagsMask = (unsigned long)(0xFF << kDataBrowserClientPropertyFlagsOffset) --- 621,628 ---- kDataBrowserTruncateTextAtStart = 1 << kDataBrowserPropertyFlagsOffset kDataBrowserPropertyModificationFlags = kDataBrowserPropertyFlagsMask ! kDataBrowserRelativeDateTime = kDataBrowserDateTimeRelative kDataBrowserViewSpecificFlagsOffset = 16 kDataBrowserViewSpecificFlagsMask = 0xFF << kDataBrowserViewSpecificFlagsOffset ! kDataBrowserViewSpecificPropertyFlags = kDataBrowserViewSpecificFlagsMask kDataBrowserClientPropertyFlagsOffset = 24 # kDataBrowserClientPropertyFlagsMask = (unsigned long)(0xFF << kDataBrowserClientPropertyFlagsOffset) Index: CoreFoundation.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/Carbon/CoreFoundation.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CoreFoundation.py 30 Dec 2002 22:04:21 -0000 1.1 --- CoreFoundation.py 18 Jul 2004 06:14:46 -0000 1.2 *************** *** 17,21 **** kCFStringEncodingUnicode = 0x0100 kCFStringEncodingUTF8 = 0x08000100 ! kCFStringEncodingNonLossyASCII = 0x0BFF kCFCompareCaseInsensitive = 1 kCFCompareBackwards = 4 --- 17,21 ---- kCFStringEncodingUnicode = 0x0100 kCFStringEncodingUTF8 = 0x08000100 ! kCFStringEncodingNonLossyASCII = 0x0BFF kCFCompareCaseInsensitive = 1 kCFCompareBackwards = 4 *************** *** 23,27 **** kCFCompareNonliteral = 16 kCFCompareLocalized = 32 ! kCFCompareNumerically = 64 kCFURLPOSIXPathStyle = 0 kCFURLHFSPathStyle = 1 --- 23,27 ---- kCFCompareNonliteral = 16 kCFCompareLocalized = 32 ! kCFCompareNumerically = 64 kCFURLPOSIXPathStyle = 0 kCFURLHFSPathStyle = 1 Index: CoreGraphics.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/Carbon/CoreGraphics.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CoreGraphics.py 5 Dec 2003 23:59:37 -0000 1.2 --- CoreGraphics.py 18 Jul 2004 06:14:46 -0000 1.3 *************** *** 26,28 **** kCGInterpolationNone = 1 kCGInterpolationLow = 2 ! kCGInterpolationHigh = 3 --- 26,28 ---- kCGInterpolationNone = 1 kCGInterpolationLow = 2 ! kCGInterpolationHigh = 3 Index: Dialogs.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/Carbon/Dialogs.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Dialogs.py 5 Dec 2003 23:59:37 -0000 1.2 --- Dialogs.py 18 Jul 2004 06:14:46 -0000 1.3 *************** *** 46,50 **** kAlertDefaultOKText = -1 kAlertDefaultCancelText = -1 ! kAlertDefaultOtherText = -1 kAlertStdAlertOKButton = 1 kAlertStdAlertCancelButton = 2 --- 46,50 ---- kAlertDefaultOKText = -1 kAlertDefaultCancelText = -1 ! kAlertDefaultOtherText = -1 kAlertStdAlertOKButton = 1 kAlertStdAlertCancelButton = 2 *************** *** 72,77 **** kDialogFontAddToMetaFontMask = 0x0400 kDialogFontUseThemeFontIDMask = 0x0080 ! kHICommandOther = FOUR_CHAR_CODE('othr') ! kStdCFStringAlertVersionOne = 1 kStdAlertDoNotDisposeSheet = 1 << 0 kStdAlertDoNotAnimateOnDefault = 1 << 1 --- 72,77 ---- kDialogFontAddToMetaFontMask = 0x0400 kDialogFontUseThemeFontIDMask = 0x0080 ! kHICommandOther = FOUR_CHAR_CODE('othr') ! kStdCFStringAlertVersionOne = 1 kStdAlertDoNotDisposeSheet = 1 << 0 kStdAlertDoNotAnimateOnDefault = 1 << 1 Index: Dragconst.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/Carbon/Dragconst.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Dragconst.py 5 Dec 2003 23:59:37 -0000 1.2 --- Dragconst.py 18 Jul 2004 06:14:46 -0000 1.3 *************** *** 7,60 **** ! kDragHasLeftSenderWindow = (1 << 0) kDragInsideSenderApplication = (1 << 1) ! kDragInsideSenderWindow = (1 << 2) ! kDragRegionAndImage = (1 << 4) ! flavorSenderOnly = (1 << 0) ! flavorSenderTranslated = (1 << 1) ! flavorNotSaved = (1 << 2) ! flavorSystemTranslated = (1 << 8) kDragHasLeftSenderWindow = (1L << 0) kDragInsideSenderApplication = (1L << 1) ! kDragInsideSenderWindow = (1L << 2) kDragBehaviorNone = 0 ! kDragBehaviorZoomBackAnimation = (1L << 0) ! kDragRegionAndImage = (1L << 4) kDragStandardTranslucency = 0L kDragDarkTranslucency = 1L kDragDarkerTranslucency = 2L ! kDragOpaqueTranslucency = 3L kDragRegionBegin = 1 kDragRegionDraw = 2 kDragRegionHide = 3 kDragRegionIdle = 4 ! kDragRegionEnd = 5 kZoomNoAcceleration = 0 kZoomAccelerate = 1 ! kZoomDecelerate = 2 flavorSenderOnly = (1 << 0) flavorSenderTranslated = (1 << 1) flavorNotSaved = (1 << 2) flavorSystemTranslated = (1 << 8) ! flavorDataPromised = (1 << 9) kDragFlavorTypeHFS = FOUR_CHAR_CODE('hfs ') kDragFlavorTypePromiseHFS = FOUR_CHAR_CODE('phfs') flavorTypeHFS = kDragFlavorTypeHFS ! flavorTypePromiseHFS = kDragFlavorTypePromiseHFS kDragPromisedFlavorFindFile = FOUR_CHAR_CODE('rWm1') ! kDragPromisedFlavor = FOUR_CHAR_CODE('fssP') kDragPseudoCreatorVolumeOrDirectory = FOUR_CHAR_CODE('MACS') kDragPseudoFileTypeVolume = FOUR_CHAR_CODE('disk') ! kDragPseudoFileTypeDirectory = FOUR_CHAR_CODE('fold') ! flavorTypeDirectory = FOUR_CHAR_CODE('diry') kFlavorTypeClippingName = FOUR_CHAR_CODE('clnm') kFlavorTypeClippingFilename = FOUR_CHAR_CODE('clfn') kFlavorTypeDragToTrashOnly = FOUR_CHAR_CODE('fdtt') ! kFlavorTypeFinderNoTrackingBehavior = FOUR_CHAR_CODE('fntb') kDragTrackingEnterHandler = 1 kDragTrackingEnterWindow = 2 kDragTrackingInWindow = 3 kDragTrackingLeaveWindow = 4 ! kDragTrackingLeaveHandler = 5 kDragActionNothing = 0L kDragActionCopy = 1L --- 7,60 ---- ! kDragHasLeftSenderWindow = (1 << 0) kDragInsideSenderApplication = (1 << 1) ! kDragInsideSenderWindow = (1 << 2) ! kDragRegionAndImage = (1 << 4) ! flavorSenderOnly = (1 << 0) ! flavorSenderTranslated = (1 << 1) ! flavorNotSaved = (1 << 2) ! flavorSystemTranslated = (1 << 8) kDragHasLeftSenderWindow = (1L << 0) kDragInsideSenderApplication = (1L << 1) ! kDragInsideSenderWindow = (1L << 2) kDragBehaviorNone = 0 ! kDragBehaviorZoomBackAnimation = (1L << 0) ! kDragRegionAndImage = (1L << 4) kDragStandardTranslucency = 0L kDragDarkTranslucency = 1L kDragDarkerTranslucency = 2L ! kDragOpaqueTranslucency = 3L kDragRegionBegin = 1 kDragRegionDraw = 2 kDragRegionHide = 3 kDragRegionIdle = 4 ! kDragRegionEnd = 5 kZoomNoAcceleration = 0 kZoomAccelerate = 1 ! kZoomDecelerate = 2 flavorSenderOnly = (1 << 0) flavorSenderTranslated = (1 << 1) flavorNotSaved = (1 << 2) flavorSystemTranslated = (1 << 8) ! flavorDataPromised = (1 << 9) kDragFlavorTypeHFS = FOUR_CHAR_CODE('hfs ') kDragFlavorTypePromiseHFS = FOUR_CHAR_CODE('phfs') flavorTypeHFS = kDragFlavorTypeHFS ! flavorTypePromiseHFS = kDragFlavorTypePromiseHFS kDragPromisedFlavorFindFile = FOUR_CHAR_CODE('rWm1') ! kDragPromisedFlavor = FOUR_CHAR_CODE('fssP') kDragPseudoCreatorVolumeOrDirectory = FOUR_CHAR_CODE('MACS') kDragPseudoFileTypeVolume = FOUR_CHAR_CODE('disk') ! kDragPseudoFileTypeDirectory = FOUR_CHAR_CODE('fold') ! flavorTypeDirectory = FOUR_CHAR_CODE('diry') kFlavorTypeClippingName = FOUR_CHAR_CODE('clnm') kFlavorTypeClippingFilename = FOUR_CHAR_CODE('clfn') kFlavorTypeDragToTrashOnly = FOUR_CHAR_CODE('fdtt') ! kFlavorTypeFinderNoTrackingBehavior = FOUR_CHAR_CODE('fntb') kDragTrackingEnterHandler = 1 kDragTrackingEnterWindow = 2 kDragTrackingInWindow = 3 kDragTrackingLeaveWindow = 4 ! kDragTrackingLeaveHandler = 5 kDragActionNothing = 0L kDragActionCopy = 1L *************** *** 67,86 **** dragHasLeftSenderWindow = kDragHasLeftSenderWindow dragInsideSenderApplication = kDragInsideSenderApplication ! dragInsideSenderWindow = kDragInsideSenderWindow dragTrackingEnterHandler = kDragTrackingEnterHandler dragTrackingEnterWindow = kDragTrackingEnterWindow dragTrackingInWindow = kDragTrackingInWindow dragTrackingLeaveWindow = kDragTrackingLeaveWindow ! dragTrackingLeaveHandler = kDragTrackingLeaveHandler dragRegionBegin = kDragRegionBegin dragRegionDraw = kDragRegionDraw dragRegionHide = kDragRegionHide dragRegionIdle = kDragRegionIdle ! dragRegionEnd = kDragRegionEnd zoomNoAcceleration = kZoomNoAcceleration zoomAccelerate = kZoomAccelerate ! zoomDecelerate = kZoomDecelerate kDragStandardImage = kDragStandardTranslucency kDragDarkImage = kDragDarkTranslucency kDragDarkerImage = kDragDarkerTranslucency ! kDragOpaqueImage = kDragOpaqueTranslucency --- 67,86 ---- dragHasLeftSenderWindow = kDragHasLeftSenderWindow dragInsideSenderApplication = kDragInsideSenderApplication ! dragInsideSenderWindow = kDragInsideSenderWindow dragTrackingEnterHandler = kDragTrackingEnterHandler dragTrackingEnterWindow = kDragTrackingEnterWindow dragTrackingInWindow = kDragTrackingInWindow dragTrackingLeaveWindow = kDragTrackingLeaveWindow ! dragTrackingLeaveHandler = kDragTrackingLeaveHandler dragRegionBegin = kDragRegionBegin dragRegionDraw = kDragRegionDraw dragRegionHide = kDragRegionHide dragRegionIdle = kDragRegionIdle ! dragRegionEnd = kDragRegionEnd zoomNoAcceleration = kZoomNoAcceleration zoomAccelerate = kZoomAccelerate ! zoomDecelerate = kZoomDecelerate kDragStandardImage = kDragStandardTranslucency kDragDarkImage = kDragDarkTranslucency kDragDarkerImage = kDragDarkerTranslucency ! kDragOpaqueImage = kDragOpaqueTranslucency Index: Events.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/Carbon/Events.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Events.py 5 Dec 2003 23:59:37 -0000 1.2 --- Events.py 18 Jul 2004 06:14:46 -0000 1.3 *************** *** 22,26 **** highLevelEventMask = 0x0400 osMask = 1 << osEvt ! everyEvent = 0xFFFF charCodeMask = 0x000000FF keyCodeMask = 0x0000FF00 --- 22,26 ---- highLevelEventMask = 0x0400 osMask = 1 << osEvt ! everyEvent = 0xFFFF charCodeMask = 0x000000FF keyCodeMask = 0x0000FF00 *************** *** 29,34 **** mouseMovedMessage = 0x00FA suspendResumeMessage = 0x0001 ! resumeFlag = 1 ! convertClipboardFlag = 2 activeFlagBit = 0 btnStateBit = 7 --- 29,34 ---- mouseMovedMessage = 0x00FA suspendResumeMessage = 0x0001 ! resumeFlag = 1 ! convertClipboardFlag = 2 activeFlagBit = 0 btnStateBit = 7 *************** *** 40,44 **** rightShiftKeyBit = 13 rightOptionKeyBit = 14 ! rightControlKeyBit = 15 activeFlag = 1 << activeFlagBit btnState = 1 << btnStateBit --- 40,44 ---- rightShiftKeyBit = 13 rightOptionKeyBit = 14 ! rightControlKeyBit = 15 activeFlag = 1 << activeFlagBit btnState = 1 << btnStateBit *************** *** 88,92 **** kDiamondUnicode = 0x25C6 kBulletUnicode = 0x2022 ! kAppleLogoUnicode = 0xF8FF networkEvt = 10 driverEvt = 11 --- 88,92 ---- kDiamondUnicode = 0x25C6 kBulletUnicode = 0x2022 ! kAppleLogoUnicode = 0xF8FF networkEvt = 10 driverEvt = 11 Index: Files.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/Carbon/Files.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Files.py 5 Dec 2003 23:59:37 -0000 1.2 --- Files.py 18 Jul 2004 06:14:46 -0000 1.3 *************** *** 10,14 **** fsRdWrShPerm = 0x04 fsRdDenyPerm = 0x10 ! fsWrDenyPerm = 0x20 fsRtParID = 1 fsRtDirID = 2 --- 10,14 ---- fsRdWrShPerm = 0x04 fsRdDenyPerm = 0x10 ! fsWrDenyPerm = 0x20 fsRtParID = 1 fsRtDirID = 2 *************** *** 28,32 **** newLineBit = 7 newLineMask = 0x0080 ! newLineCharMask = 0xFF00 fsSBPartialName = 1 fsSBFullName = 2 --- 28,32 ---- newLineBit = 7 newLineMask = 0x0080 ! newLineCharMask = 0xFF00 fsSBPartialName = 1 fsSBFullName = 2 *************** *** 70,74 **** fsSBDrBkDatBit = 11 fsSBDrFndrInfoBit = 12 ! fsSBDrParIDBit = 13 bLimitFCBs = 31 bLocalWList = 30 --- 70,74 ---- fsSBDrBkDatBit = 11 fsSBDrFndrInfoBit = 12 ! fsSBDrParIDBit = 13 bLimitFCBs = 31 bLocalWList = 30 *************** *** 107,116 **** bSupportsNamedForks = 7 bSupportsSubtreeIterators = 8 ! bL2PCanMapFileBlocks = 9 bParentModDateChanges = 10 ! bAncestorModDateChanges = 11 bSupportsSymbolicLinks = 13 bIsAutoMounted = 14 ! bAllowCDiDataHandler = 17 kLargeIcon = 1 kLarge4BitIcon = 2 --- 107,116 ---- bSupportsNamedForks = 7 bSupportsSubtreeIterators = 8 ! bL2PCanMapFileBlocks = 9 bParentModDateChanges = 10 ! bAncestorModDateChanges = 11 bSupportsSymbolicLinks = 13 bIsAutoMounted = 14 ! bAllowCDiDataHandler = 17 kLargeIcon = 1 kLarge4BitIcon = 2 *************** *** 119,123 **** kSmall4BitIcon = 5 kSmall8BitIcon = 6 ! kicnsIconFamily = 239 kLargeIconSize = 256 kLarge4BitIconSize = 512 --- 119,123 ---- kSmall4BitIcon = 5 kSmall8BitIcon = 6 ! kicnsIconFamily = 239 kLargeIconSize = 256 kLarge4BitIconSize = 512 *************** *** 230,234 **** kioACAccessOwnerSearchMask = 0x00000001 kfullPrivileges = 0x00070007 ! kownerPrivileges = 0x00000007 knoUser = 0 kadministratorUser = 1 --- 230,234 ---- kioACAccessOwnerSearchMask = 0x00000001 kfullPrivileges = 0x00070007 ! kownerPrivileges = 0x00000007 knoUser = 0 kadministratorUser = 1 *************** *** 244,253 **** volMountChangedMask = 0x4000 volMountFSReservedMask = 0x00FF ! volMountSysReservedMask = 0xFF00 ! kAFPExtendedFlagsAlternateAddressMask = 1 kAFPTagTypeIP = 0x01 kAFPTagTypeIPPort = 0x02 kAFPTagTypeDDP = 0x03 ! kAFPTagTypeDNS = 0x04 kAFPTagLengthIP = 0x06 kAFPTagLengthIPPort = 0x08 --- 244,253 ---- volMountChangedMask = 0x4000 volMountFSReservedMask = 0x00FF ! volMountSysReservedMask = 0xFF00 ! kAFPExtendedFlagsAlternateAddressMask = 1 kAFPTagTypeIP = 0x01 kAFPTagTypeIPPort = 0x02 kAFPTagTypeDDP = 0x03 ! kAFPTagTypeDNS = 0x04 kAFPTagLengthIP = 0x06 kAFPTagLengthIPPort = 0x08 *************** *** 277,281 **** kFSCatInfoGettableInfo = 0x0003FFFF kFSCatInfoSettableInfo = 0x00001FE3 ! # kFSCatInfoReserved = (long)0xFFFC0000 kFSNodeLockedBit = 0 kFSNodeLockedMask = 0x0001 --- 277,281 ---- kFSCatInfoGettableInfo = 0x0003FFFF kFSCatInfoSettableInfo = 0x00001FE3 ! # kFSCatInfoReserved = (long)0xFFFC0000 kFSNodeLockedBit = 0 kFSNodeLockedMask = 0x0001 *************** *** 312,316 **** kFSAllocContiguousMask = 0x0002 kFSAllocNoRoundUpMask = 0x0004 ! kFSAllocReservedMask = 0xFFF8 kFSVolInfoNone = 0x0000 kFSVolInfoCreateDate = 0x0001 --- 312,316 ---- kFSAllocContiguousMask = 0x0002 kFSAllocNoRoundUpMask = 0x0004 ! kFSAllocReservedMask = 0xFFF8 kFSVolInfoNone = 0x0000 kFSVolInfoCreateDate = 0x0001 *************** *** 331,335 **** kFSVolInfoDriveInfo = 0x8000 kFSVolInfoGettableInfo = 0xFFFF ! kFSVolInfoSettableInfo = 0x3004 kFSVolFlagDefaultVolumeBit = 5 kFSVolFlagDefaultVolumeMask = 0x0020 --- 331,335 ---- kFSVolInfoDriveInfo = 0x8000 kFSVolInfoGettableInfo = 0xFFFF ! kFSVolInfoSettableInfo = 0x3004 kFSVolFlagDefaultVolumeBit = 5 kFSVolFlagDefaultVolumeMask = 0x0020 *************** *** 342,346 **** kFNDirectoryModifiedMessage = 1 kFNNoImplicitAllSubscription = (1 << 0) ! rAliasType = FOUR_CHAR_CODE('alis') kARMMountVol = 0x00000001 kARMNoUI = 0x00000002 --- 342,346 ---- kFNDirectoryModifiedMessage = 1 kFNNoImplicitAllSubscription = (1 << 0) ! rAliasType = FOUR_CHAR_CODE('alis') kARMMountVol = 0x00000001 kARMNoUI = 0x00000002 *************** *** 348,358 **** kARMSearch = 0x00000100 kARMSearchMore = 0x00000200 ! kARMSearchRelFirst = 0x00000400 asiZoneName = -3 asiServerName = -2 asiVolumeName = -1 asiAliasName = 0 ! asiParentName = 1 ! kResolveAliasFileNoUI = 0x00000001 kClippingCreator = FOUR_CHAR_CODE('drag') kClippingPictureType = FOUR_CHAR_CODE('clpp') --- 348,358 ---- kARMSearch = 0x00000100 kARMSearchMore = 0x00000200 ! kARMSearchRelFirst = 0x00000400 asiZoneName = -3 asiServerName = -2 asiVolumeName = -1 asiAliasName = 0 ! asiParentName = 1 ! kResolveAliasFileNoUI = 0x00000001 kClippingCreator = FOUR_CHAR_CODE('drag') kClippingPictureType = FOUR_CHAR_CODE('clpp') *************** *** 370,374 **** kInternetLocationNSL = FOUR_CHAR_CODE('ilns') kInternetLocationGeneric = FOUR_CHAR_CODE('ilge') ! kCustomIconResource = -16455 kCustomBadgeResourceType = FOUR_CHAR_CODE('badg') kCustomBadgeResourceID = kCustomIconResource --- 370,374 ---- kInternetLocationNSL = FOUR_CHAR_CODE('ilns') kInternetLocationGeneric = FOUR_CHAR_CODE('ilge') ! kCustomIconResource = -16455 kCustomBadgeResourceType = FOUR_CHAR_CODE('badg') kCustomBadgeResourceID = kCustomIconResource *************** *** 389,393 **** kApplicationDAAliasType = FOUR_CHAR_CODE('addp') kPackageAliasType = FOUR_CHAR_CODE('fpka') ! kAppPackageAliasType = FOUR_CHAR_CODE('fapa') kSystemFolderAliasType = FOUR_CHAR_CODE('fasy') kAppleMenuFolderAliasType = FOUR_CHAR_CODE('faam') --- 389,393 ---- kApplicationDAAliasType = FOUR_CHAR_CODE('addp') kPackageAliasType = FOUR_CHAR_CODE('fpka') ! kAppPackageAliasType = FOUR_CHAR_CODE('fapa') kSystemFolderAliasType = FOUR_CHAR_CODE('fasy') kAppleMenuFolderAliasType = FOUR_CHAR_CODE('faam') *************** *** 411,415 **** kHasBundle = 0x2000 kIsInvisible = 0x4000 ! kIsAlias = 0x8000 fOnDesk = kIsOnDesk fHasBundle = kHasBundle --- 411,415 ---- kHasBundle = 0x2000 kIsInvisible = 0x4000 ! kIsAlias = 0x8000 fOnDesk = kIsOnDesk fHasBundle = kHasBundle *************** *** 421,425 **** kExtendedFlagsAreInvalid = 0x8000 kExtendedFlagHasCustomBadge = 0x0100 ! kExtendedFlagHasRoutingInfo = 0x0004 kFirstMagicBusyFiletype = FOUR_CHAR_CODE('bzy ') kLastMagicBusyFiletype = FOUR_CHAR_CODE('bzy?') --- 421,425 ---- kExtendedFlagsAreInvalid = 0x8000 kExtendedFlagHasCustomBadge = 0x0100 ! kExtendedFlagHasRoutingInfo = 0x0004 kFirstMagicBusyFiletype = FOUR_CHAR_CODE('bzy ') kLastMagicBusyFiletype = FOUR_CHAR_CODE('bzy?') Index: Folders.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/Carbon/Folders.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Folders.py 5 Dec 2003 23:59:37 -0000 1.2 --- Folders.py 18 Jul 2004 06:14:46 -0000 1.3 *************** *** 10,14 **** kNetworkDomain = -32764 kUserDomain = -32763 ! kClassicDomain = -32762 kCreateFolder = true kDontCreateFolder = false --- 10,14 ---- kNetworkDomain = -32764 kUserDomain = -32763 ! kClassicDomain = -32762 kCreateFolder = true kDontCreateFolder = false *************** *** 29,33 **** kPreferencesFolderType = FOUR_CHAR_CODE('pref') kSystemPreferencesFolderType = FOUR_CHAR_CODE('sprf') ! kTemporaryFolderType = FOUR_CHAR_CODE('temp') kExtensionDisabledFolderType = FOUR_CHAR_CODE('extD') kControlPanelDisabledFolderType = FOUR_CHAR_CODE('ctrD') --- 29,33 ---- kPreferencesFolderType = FOUR_CHAR_CODE('pref') kSystemPreferencesFolderType = FOUR_CHAR_CODE('sprf') ! kTemporaryFolderType = FOUR_CHAR_CODE('temp') kExtensionDisabledFolderType = FOUR_CHAR_CODE('extD') kControlPanelDisabledFolderType = FOUR_CHAR_CODE('ctrD') *************** *** 87,91 **** kDisplayExtensionsFolderType = FOUR_CHAR_CODE('dspl') kMultiprocessingFolderType = FOUR_CHAR_CODE('mpxf') ! kPrintingPlugInsFolderType = FOUR_CHAR_CODE('pplg') kDomainTopLevelFolderType = FOUR_CHAR_CODE('dtop') kDomainLibraryFolderType = FOUR_CHAR_CODE('dlib') --- 87,91 ---- kDisplayExtensionsFolderType = FOUR_CHAR_CODE('dspl') kMultiprocessingFolderType = FOUR_CHAR_CODE('mpxf') ! kPrintingPlugInsFolderType = FOUR_CHAR_CODE('pplg') kDomainTopLevelFolderType = FOUR_CHAR_CODE('dtop') kDomainLibraryFolderType = FOUR_CHAR_CODE('dlib') *************** *** 128,134 **** kAppleShareSupportFolderType = FOUR_CHAR_CODE('shar') kAppleShareAuthenticationFolderType = FOUR_CHAR_CODE('auth') ! kMIDIDriversFolderType = FOUR_CHAR_CODE('midi') kLocalesFolderType = FOUR_CHAR_CODE('\xc4loc') ! kFindByContentPluginsFolderType = FOUR_CHAR_CODE('fbcp') kUsersFolderType = FOUR_CHAR_CODE('usrs') kCurrentUserFolderType = FOUR_CHAR_CODE('cusr') --- 128,134 ---- kAppleShareSupportFolderType = FOUR_CHAR_CODE('shar') kAppleShareAuthenticationFolderType = FOUR_CHAR_CODE('auth') ! kMIDIDriversFolderType = FOUR_CHAR_CODE('midi') kLocalesFolderType = FOUR_CHAR_CODE('\xc4loc') ! kFindByContentPluginsFolderType = FOUR_CHAR_CODE('fbcp') kUsersFolderType = FOUR_CHAR_CODE('usrs') kCurrentUserFolderType = FOUR_CHAR_CODE('cusr') *************** *** 136,140 **** kCurrentUserRemoteFolderType = FOUR_CHAR_CODE('rusr') kSharedUserDataFolderType = FOUR_CHAR_CODE('sdat') ! kVolumeSettingsFolderType = FOUR_CHAR_CODE('vsfd') kAppleshareAutomountServerAliasesFolderType = FOUR_CHAR_CODE('srv\xc4') kPreMacOS91ApplicationsFolderType = FOUR_CHAR_CODE('\x8cpps') --- 136,140 ---- kCurrentUserRemoteFolderType = FOUR_CHAR_CODE('rusr') kSharedUserDataFolderType = FOUR_CHAR_CODE('sdat') ! kVolumeSettingsFolderType = FOUR_CHAR_CODE('vsfd') kAppleshareAutomountServerAliasesFolderType = FOUR_CHAR_CODE('srv\xc4') kPreMacOS91ApplicationsFolderType = FOUR_CHAR_CODE('\x8cpps') *************** *** 146,150 **** kPreMacOS91InternetFolderType = FOUR_CHAR_CODE('\x94nt\xc4') kPreMacOS91AutomountedServersFolderType = FOUR_CHAR_CODE('\xa7rv\xc4') ! kPreMacOS91StationeryFolderType = FOUR_CHAR_CODE('\xbfdst') kCreateFolderAtBoot = 0x00000002 kCreateFolderAtBootBit = 1 --- 146,150 ---- kPreMacOS91InternetFolderType = FOUR_CHAR_CODE('\x94nt\xc4') kPreMacOS91AutomountedServersFolderType = FOUR_CHAR_CODE('\xa7rv\xc4') ! kPreMacOS91StationeryFolderType = FOUR_CHAR_CODE('\xbfdst') kCreateFolderAtBoot = 0x00000002 kCreateFolderAtBootBit = 1 *************** *** 172,176 **** kBlessedFolder = FOUR_CHAR_CODE('blsf') kRootFolder = FOUR_CHAR_CODE('rotf') ! kCurrentUserFolderLocation = FOUR_CHAR_CODE('cusf') kFindFolderRedirectionFlagUseDistinctUserFoldersBit = 0 kFindFolderRedirectionFlagUseGivenVRefAndDirIDAsUserFolderBit = 1 --- 172,176 ---- kBlessedFolder = FOUR_CHAR_CODE('blsf') kRootFolder = FOUR_CHAR_CODE('rotf') ! kCurrentUserFolderLocation = FOUR_CHAR_CODE('cusf') kFindFolderRedirectionFlagUseDistinctUserFoldersBit = 0 kFindFolderRedirectionFlagUseGivenVRefAndDirIDAsUserFolderBit = 1 *************** *** 185,190 **** kFolderManagerNotificationMessagePostUserLogOut = FOUR_CHAR_CODE('logp') kFolderManagerNotificationDiscardCachedData = FOUR_CHAR_CODE('dche') ! kFolderManagerNotificationMessageLoginStartup = FOUR_CHAR_CODE('stup') kDoNotRemoveWhenCurrentApplicationQuitsBit = 0 ! kDoNotRemoveWheCurrentApplicationQuitsBit = kDoNotRemoveWhenCurrentApplicationQuitsBit kStopIfAnyNotificationProcReturnsErrorBit = 31 --- 185,190 ---- kFolderManagerNotificationMessagePostUserLogOut = FOUR_CHAR_CODE('logp') kFolderManagerNotificationDiscardCachedData = FOUR_CHAR_CODE('dche') ! kFolderManagerNotificationMessageLoginStartup = FOUR_CHAR_CODE('stup') kDoNotRemoveWhenCurrentApplicationQuitsBit = 0 ! kDoNotRemoveWheCurrentApplicationQuitsBit = kDoNotRemoveWhenCurrentApplicationQuitsBit kStopIfAnyNotificationProcReturnsErrorBit = 31 Index: Icons.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/Carbon/Icons.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Icons.py 5 Dec 2003 23:59:37 -0000 1.2 --- Icons.py 18 Jul 2004 06:14:46 -0000 1.3 *************** *** 255,259 **** kTrueTypeMultiFlatFontIcon = FOUR_CHAR_CODE('ttcf') kUserIDiskIcon = FOUR_CHAR_CODE('udsk') ! kInternationResourcesIcon = kInternationalResourcesIcon kInternetLocationHTTPIcon = FOUR_CHAR_CODE('ilht') kInternetLocationFTPIcon = FOUR_CHAR_CODE('ilft') --- 255,259 ---- kTrueTypeMultiFlatFontIcon = FOUR_CHAR_CODE('ttcf') kUserIDiskIcon = FOUR_CHAR_CODE('udsk') ! kInternationResourcesIcon = kInternationalResourcesIcon kInternetLocationHTTPIcon = FOUR_CHAR_CODE('ilht') kInternetLocationFTPIcon = FOUR_CHAR_CODE('ilft') Index: LaunchServices.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/Carbon/LaunchServices.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** LaunchServices.py 13 Mar 2004 23:50:48 -0000 1.3 --- LaunchServices.py 18 Jul 2004 06:14:46 -0000 1.4 *************** *** 21,28 **** kLSAppDoesNotSupportSchemeWarning = -10821 kLSServerCommunicationErr = -10822 ! kLSCannotSetInfoErr = -10823 kLSInitializeDefaults = 0x00000001 ! kLSMinCatInfoBitmap = (kFSCatInfoNodeFlags | kFSCatInfoParentDirID | kFSCatInfoFinderInfo | kFSCatInfoFinderXInfo) ! # kLSInvalidExtensionIndex = (unsigned long)0xFFFFFFFF kLSRequestExtension = 0x00000001 kLSRequestTypeCreator = 0x00000002 --- 21,28 ---- kLSAppDoesNotSupportSchemeWarning = -10821 kLSServerCommunicationErr = -10822 ! kLSCannotSetInfoErr = -10823 kLSInitializeDefaults = 0x00000001 ! kLSMinCatInfoBitmap = (kFSCatInfoNodeFlags | kFSCatInfoParentDirID | kFSCatInfoFinderInfo | kFSCatInfoFinderXInfo) ! # kLSInvalidExtensionIndex = (unsigned long)0xFFFFFFFF kLSRequestExtension = 0x00000001 kLSRequestTypeCreator = 0x00000002 *************** *** 32,36 **** kLSRequestIconAndKind = 0x00000020 kLSRequestExtensionFlagsOnly = 0x00000040 ! # kLSRequestAllInfo = (unsigned long)0xFFFFFFFF kLSItemInfoIsPlainFile = 0x00000001 kLSItemInfoIsPackage = 0x00000002 --- 32,36 ---- kLSRequestIconAndKind = 0x00000020 kLSRequestExtensionFlagsOnly = 0x00000040 ! # kLSRequestAllInfo = (unsigned long)0xFFFFFFFF kLSItemInfoIsPlainFile = 0x00000001 kLSItemInfoIsPackage = 0x00000002 *************** *** 46,59 **** kLSItemInfoAppIsScriptable = 0x00000800 kLSItemInfoIsVolume = 0x00001000 ! kLSItemInfoExtensionIsHidden = 0x00100000 kLSRolesNone = 0x00000001 kLSRolesViewer = 0x00000002 kLSRolesEditor = 0x00000004 ! # kLSRolesAll = (unsigned long)0xFFFFFFFF kLSUnknownKindID = 0 # kLSUnknownType = 0 # kLSUnknownCreator = 0 kLSAcceptDefault = 0x00000001 ! kLSAcceptAllowLoginUI = 0x00000002 kLSLaunchDefaults = 0x00000001 kLSLaunchAndPrint = 0x00000002 --- 46,59 ---- kLSItemInfoAppIsScriptable = 0x00000800 kLSItemInfoIsVolume = 0x00001000 ! kLSItemInfoExtensionIsHidden = 0x00100000 kLSRolesNone = 0x00000001 kLSRolesViewer = 0x00000002 kLSRolesEditor = 0x00000004 ! # kLSRolesAll = (unsigned long)0xFFFFFFFF kLSUnknownKindID = 0 # kLSUnknownType = 0 # kLSUnknownCreator = 0 kLSAcceptDefault = 0x00000001 ! kLSAcceptAllowLoginUI = 0x00000002 kLSLaunchDefaults = 0x00000001 kLSLaunchAndPrint = 0x00000002 *************** *** 72,74 **** kLSLaunchNewInstance = 0x00080000 kLSLaunchAndHide = 0x00100000 ! kLSLaunchAndHideOthers = 0x00200000 --- 72,74 ---- kLSLaunchNewInstance = 0x00080000 kLSLaunchAndHide = 0x00100000 ! kLSLaunchAndHideOthers = 0x00200000 Index: Lists.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/Carbon/Lists.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Lists.py 30 Dec 2002 22:04:21 -0000 1.1 --- Lists.py 18 Jul 2004 06:14:46 -0000 1.2 *************** *** 5,9 **** listNotifyClick = FOUR_CHAR_CODE('clik') listNotifyDoubleClick = FOUR_CHAR_CODE('dblc') ! listNotifyPreClick = FOUR_CHAR_CODE('pclk') lDrawingModeOffBit = 3 lDoVAutoscrollBit = 1 --- 5,9 ---- listNotifyClick = FOUR_CHAR_CODE('clik') listNotifyDoubleClick = FOUR_CHAR_CODE('dblc') ! listNotifyPreClick = FOUR_CHAR_CODE('pclk') lDrawingModeOffBit = 3 lDoVAutoscrollBit = 1 Index: MacHelp.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/Carbon/MacHelp.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** MacHelp.py 30 Dec 2002 22:04:21 -0000 1.1 --- MacHelp.py 18 Jul 2004 06:14:46 -0000 1.2 *************** *** 52,58 **** kHMContentNotProvidedDontPropagate = 2 kHMMinimumContentIndex = 0 ! kHMMaximumContentIndex = 1 errHMIllegalContentForMinimumState = -10980 ! errHMIllegalContentForMaximumState = -10981 kHMIllegalContentForMinimumState = errHMIllegalContentForMinimumState kHelpTagEventHandlerTag = FOUR_CHAR_CODE('hevt') --- 52,58 ---- kHMContentNotProvidedDontPropagate = 2 kHMMinimumContentIndex = 0 ! kHMMaximumContentIndex = 1 errHMIllegalContentForMinimumState = -10980 ! errHMIllegalContentForMaximumState = -10981 kHMIllegalContentForMinimumState = errHMIllegalContentForMinimumState kHelpTagEventHandlerTag = FOUR_CHAR_CODE('hevt') Index: MacTextEditor.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/Carbon/MacTextEditor.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** MacTextEditor.py 5 Dec 2003 23:59:37 -0000 1.2 --- MacTextEditor.py 18 Jul 2004 06:14:46 -0000 1.3 *************** *** 146,150 **** kTXNFontFeatureAction = 13 kTXNFontVariationAction = 14 ! kTXNUndoLastAction = 1024 # kTXNClearThisControl = (long)0xFFFFFFFF # kTXNClearTheseFontFeatures = (long)0x80000000 --- 146,150 ---- kTXNFontFeatureAction = 13 kTXNFontVariationAction = 14 ! kTXNUndoLastAction = 1024 # kTXNClearThisControl = (long)0xFFFFFFFF # kTXNClearTheseFontFeatures = (long)0x80000000 *************** *** 177,181 **** kTXNCenter = 4 kTXNFullJust = 8 ! kTXNForceFullJust = 16 kScrollBarsAlwaysActive = true kScrollBarsSyncWithFocus = false --- 177,181 ---- kTXNCenter = 4 kTXNFullJust = 8 ! kTXNForceFullJust = 16 kScrollBarsAlwaysActive = true kScrollBarsSyncWithFocus = false *************** *** 193,197 **** kTXNShowStart = false kTXNShowEnd = true ! kTXNDefaultFontName = 0 kTXNDefaultFontSize = 0x000C0000 kTXNDefaultFontStyle = normal --- 193,197 ---- kTXNShowStart = false kTXNShowEnd = true ! kTXNDefaultFontName = 0 kTXNDefaultFontSize = 0x000C0000 kTXNDefaultFontStyle = normal Index: MediaDescr.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/Carbon/MediaDescr.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** MediaDescr.py 6 Apr 2003 09:01:02 -0000 1.2 --- MediaDescr.py 18 Jul 2004 06:14:46 -0000 1.3 *************** *** 5,60 **** class _MediaDescriptionCodec: ! def __init__(self, trunc, size, names, fmt): ! self.trunc = trunc ! self.size = size ! self.names = names ! self.fmt = fmt ! def decode(self, data): ! if self.trunc: ! data = data[:self.size] ! values = struct.unpack(self.fmt, data) ! if len(values) != len(self.names): ! raise Error, ('Format length does not match number of names', descr) ! rv = {} ! for i in range(len(values)): ! name = self.names[i] ! value = values[i] ! if type(name) == type(()): ! name, cod, dec = name ! value = dec(value) ! rv[name] = value ! return rv ! def encode(dict): ! list = [self.fmt] ! for name in self.names: ! if type(name) == type(()): ! name, cod, dec = name ! else: ! cod = dec = None ! value = dict[name] ! if cod: ! value = cod(value) ! list.append(value) ! rv = struct.pack(*list) ! return rv # Helper functions def _tofixed(float): ! hi = int(float) ! lo = int(float*0x10000) & 0xffff ! return (hi<<16)|lo def _fromfixed(fixed): ! hi = (fixed >> 16) & 0xffff ! lo = (fixed & 0xffff) ! return hi + (lo / float(0x10000)) def _tostr31(str): ! return chr(len(str)) + str + '\0'*(31-len(str)) def _fromstr31(str31): ! return str31[1:1+ord(str31[0])] SampleDescription = _MediaDescriptionCodec( --- 5,60 ---- class _MediaDescriptionCodec: ! def __init__(self, trunc, size, names, fmt): ! self.trunc = trunc ! self.size = size ! self.names = names ! self.fmt = fmt ! def decode(self, data): ! if self.trunc: ! data = data[:self.size] ! values = struct.unpack(self.fmt, data) ! if len(values) != len(self.names): ! raise Error, ('Format length does not match number of names', descr) ! rv = {} ! for i in range(len(values)): ! name = self.names[i] ! value = values[i] ! if type(name) == type(()): ! name, cod, dec = name ! value = dec(value) ! rv[name] = value ! return rv ! def encode(dict): ! list = [self.fmt] ! for name in self.names: ! if type(name) == type(()): ! name, cod, dec = name ! else: ! cod = dec = None ! value = dict[name] ! if cod: ! value = cod(value) ! list.append(value) ! rv = struct.pack(*list) ! return rv # Helper functions def _tofixed(float): ! hi = int(float) ! lo = int(float*0x10000) & 0xffff ! return (hi<<16)|lo def _fromfixed(fixed): ! hi = (fixed >> 16) & 0xffff ! lo = (fixed & 0xffff) ! return hi + (lo / float(0x10000)) def _tostr31(str): ! return chr(len(str)) + str + '\0'*(31-len(str)) def _fromstr31(str31): ! return str31[1:1+ord(str31[0])] SampleDescription = _MediaDescriptionCodec( Index: Menus.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/Carbon/Menus.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Menus.py 5 Dec 2003 23:59:37 -0000 1.2 --- Menus.py 18 Jul 2004 06:14:46 -0000 1.3 *************** *** 2,6 **** def FOUR_CHAR_CODE(x): return x ! noMark = 0 kMenuDrawMsg = 0 kMenuSizeMsg = 2 --- 2,6 ---- def FOUR_CHAR_CODE(x): return x ! noMark = 0 kMenuDrawMsg = 0 kMenuSizeMsg = 2 *************** *** 16,20 **** kMenuChooseMsg = 1 kMenuDrawItemMsg = 4 ! kThemeSavvyMenuResponse = 0x7473 kMenuInitMsg = 8 kMenuDisposeMsg = 9 --- 16,20 ---- kMenuChooseMsg = 1 kMenuDrawItemMsg = 4 ! kThemeSavvyMenuResponse = 0x7473 kMenuInitMsg = 8 kMenuDisposeMsg = 9 *************** *** 27,31 **** kInsertHierarchicalMenu = -1 mctAllItems = -98 ! mctLastIDIndic = -99 kMenuStdMenuProc = 63 kMenuStdMenuBarProc = 63 --- 27,31 ---- kInsertHierarchicalMenu = -1 mctAllItems = -98 ! mctLastIDIndic = -99 kMenuStdMenuProc = 63 kMenuStdMenuBarProc = 63 *************** *** 34,38 **** kMenuOptionModifier = (1 << 1) kMenuControlModifier = (1 << 2) ! kMenuNoCommandModifier = (1 << 3) kMenuNoIcon = 0 kMenuIconType = 1 --- 34,38 ---- kMenuOptionModifier = (1 << 1) kMenuControlModifier = (1 << 2) ! kMenuNoCommandModifier = (1 << 3) kMenuNoIcon = 0 kMenuIconType = 1 *************** *** 44,48 **** kMenuCGImageRefType = 7 kMenuSystemIconSelectorType = 8 ! kMenuIconResourceType = 9 kMenuNullGlyph = 0x00 kMenuTabRightGlyph = 0x02 --- 44,48 ---- kMenuCGImageRefType = 7 kMenuSystemIconSelectorType = 8 ! kMenuIconResourceType = 9 kMenuNullGlyph = 0x00 kMenuTabRightGlyph = 0x02 *************** *** 102,106 **** kMenuF14Glyph = 0x88 kMenuF15Glyph = 0x89 ! kMenuControlISOGlyph = 0x8A kMenuAttrExcludesMarkColumn = (1 << 0) kMenuAttrAutoDisable = (1 << 2) --- 102,106 ---- kMenuF14Glyph = 0x88 kMenuF15Glyph = 0x89 ! kMenuControlISOGlyph = 0x8A kMenuAttrExcludesMarkColumn = (1 << 0) kMenuAttrAutoDisable = (1 << 2) *************** *** 148,153 **** kMenuItemDataAllDataVersionOne = 0x000FFFFF kMenuItemDataAllDataVersionTwo = kMenuItemDataAllDataVersionOne | kMenuItemDataCmdVirtualKey ! kMenuDefProcPtr = 0 ! kMenuPropertyPersistent = 0x00000001 kHierarchicalFontMenuOption = 0x00000001 gestaltContextualMenuAttr = FOUR_CHAR_CODE('cmnu') --- 148,153 ---- kMenuItemDataAllDataVersionOne = 0x000FFFFF kMenuItemDataAllDataVersionTwo = kMenuItemDataAllDataVersionOne | kMenuItemDataCmdVirtualKey ! kMenuDefProcPtr = 0 ! kMenuPropertyPersistent = 0x00000001 kHierarchicalFontMenuOption = 0x00000001 gestaltContextualMenuAttr = FOUR_CHAR_CODE('cmnu') *************** *** 155,159 **** gestaltContextualMenuTrapAvailable = 1 gestaltContextualMenuHasAttributeAndModifierKeys = 2 ! gestaltContextualMenuHasUnicodeSupport = 3 kCMHelpItemNoHelp = 0 kCMHelpItemAppleGuide = 1 --- 155,159 ---- gestaltContextualMenuTrapAvailable = 1 gestaltContextualMenuHasAttributeAndModifierKeys = 2 ! gestaltContextualMenuHasUnicodeSupport = 3 kCMHelpItemNoHelp = 0 kCMHelpItemAppleGuide = 1 Index: OSAconst.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/Carbon/OSAconst.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** OSAconst.py 5 Dec 2003 23:59:37 -0000 1.2 --- OSAconst.py 18 Jul 2004 06:14:46 -0000 1.3 *************** *** 19,26 **** keyOSADialectCode = FOUR_CHAR_CODE('dcod') keyOSADialectLangCode = FOUR_CHAR_CODE('dlcd') ! keyOSADialectScriptCode = FOUR_CHAR_CODE('dscd') kOSANullScript = 0L kOSANullMode = 0 ! kOSAModeNull = 0 kOSASupportsCompiling = 0x0002 kOSASupportsGetSource = 0x0004 --- 19,26 ---- keyOSADialectCode = FOUR_CHAR_CODE('dcod') keyOSADialectLangCode = FOUR_CHAR_CODE('dlcd') ! keyOSADialectScriptCode = FOUR_CHAR_CODE('dscd') kOSANullScript = 0L kOSANullMode = 0 ! kOSAModeNull = 0 kOSASupportsCompiling = 0x0002 kOSASupportsGetSource = 0x0004 *************** *** 131,133 **** keyLocalsNames = FOUR_CHAR_CODE('dfln') keyGlobalsNames = FOUR_CHAR_CODE('dfgn') ! keyParamsNames = FOUR_CHAR_CODE('dfpn') --- 131,133 ---- keyLocalsNames = FOUR_CHAR_CODE('dfln') keyGlobalsNames = FOUR_CHAR_CODE('dfgn') ! keyParamsNames = FOUR_CHAR_CODE('dfpn') Index: Qt.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/Carbon/Qt.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Qt.py 13 Mar 2004 23:50:48 -0000 1.2 --- Qt.py 18 Jul 2004 06:14:46 -0000 1.3 *************** *** 4,6 **** except: raise ImportError, "Old (2.3) _Qt.so module loaded in stead of new (2.4) _Qt.so" - \ No newline at end of file --- 4,5 ---- Index: QuickDraw.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/Carbon/QuickDraw.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** QuickDraw.py 5 Dec 2003 23:59:37 -0000 1.2 --- QuickDraw.py 18 Jul 2004 06:14:46 -0000 1.3 *************** *** 3,15 **** def FOUR_CHAR_CODE(x): return x ! normal = 0 ! bold = 1 ! italic = 2 ! underline = 4 ! outline = 8 ! shadow = 0x10 ! condense = 0x20 ! extend = 0x40 ! invalColReq = -1 srcCopy = 0 srcOr = 1 --- 3,15 ---- def FOUR_CHAR_CODE(x): return x ! normal = 0 ! bold = 1 ! italic = 2 ! underline = 4 ! outline = 8 ! shadow = 0x10 ! condense = 0x20 ! extend = 0x40 ! invalColReq = -1 srcCopy = 0 srcOr = 1 *************** *** 69,73 **** fixedType = 1 directType = 2 ! gdDevType = 0 interlacedDevice = 2 hwMirroredDevice = 4 --- 69,73 ---- fixedType = 1 directType = 2 ! gdDevType = 0 interlacedDevice = 2 hwMirroredDevice = 4 *************** *** 86,90 **** defQDColors = 127 RGBDirect = 16 ! baseAddr32 = 4 sysPatListID = 0 iBeamCursor = 1 --- 86,90 ---- defQDColors = 127 RGBDirect = 16 ! baseAddr32 = 4 sysPatListID = 0 iBeamCursor = 1 *************** *** 126,130 **** k2IndexedGrayPixelFormat = 0x00000022 k4IndexedGrayPixelFormat = 0x00000024 ! k8IndexedGrayPixelFormat = 0x00000028 k16LE555PixelFormat = FOUR_CHAR_CODE('L555') k16LE5551PixelFormat = FOUR_CHAR_CODE('5551') --- 126,130 ---- k2IndexedGrayPixelFormat = 0x00000022 k4IndexedGrayPixelFormat = 0x00000024 ! k8IndexedGrayPixelFormat = 0x00000028 k16LE555PixelFormat = FOUR_CHAR_CODE('L555') k16LE5551PixelFormat = FOUR_CHAR_CODE('5551') *************** *** 142,146 **** kUYVY422PixelFormat = FOUR_CHAR_CODE('UYVY') kYUV211PixelFormat = FOUR_CHAR_CODE('Y211') ! k2vuyPixelFormat = FOUR_CHAR_CODE('2vuy') kCursorImageMajorVersion = 0x0001 kCursorImageMinorVersion = 0x0000 --- 142,146 ---- kUYVY422PixelFormat = FOUR_CHAR_CODE('UYVY') kYUV211PixelFormat = FOUR_CHAR_CODE('Y211') ! k2vuyPixelFormat = FOUR_CHAR_CODE('2vuy') kCursorImageMajorVersion = 0x0001 kCursorImageMinorVersion = 0x0000 *************** *** 158,162 **** customXFer = 54 kXFer1PixelAtATime = 0x00000001 ! kXFerConvertPixelToRGB32 = 0x00000002 kCursorComponentsVersion = 0x00010001 kCursorComponentType = FOUR_CHAR_CODE('curs') --- 158,162 ---- customXFer = 54 kXFer1PixelAtATime = 0x00000001 ! kXFerConvertPixelToRGB32 = 0x00000002 kCursorComponentsVersion = 0x00010001 kCursorComponentType = FOUR_CHAR_CODE('curs') *************** *** 180,197 **** def FOUR_CHAR_CODE(x): return x ! normal = 0 ! bold = 1 ! italic = 2 ! underline = 4 ! outline = 8 ! shadow = 0x10 ! condense = 0x20 ! extend = 0x40 leftCaret = 0 rightCaret = -1 ! kHilite = 1 smLeftCaret = 0 smRightCaret = -1 ! smHilite = 1 onlyStyleRun = 0 leftStyleRun = 1 --- 180,197 ---- def FOUR_CHAR_CODE(x): return x ! normal = 0 ! bold = 1 ! italic = 2 ! underline = 4 ! outline = 8 ! shadow = 0x10 ! condense = 0x20 ! extend = 0x40 leftCaret = 0 rightCaret = -1 ! kHilite = 1 smLeftCaret = 0 smRightCaret = -1 ! smHilite = 1 onlyStyleRun = 0 leftStyleRun = 1 *************** *** 201,209 **** smLeftStyleRun = 1 smRightStyleRun = 2 ! smMiddleStyleRun = 3 truncEnd = 0 truncMiddle = 0x4000 smTruncEnd = 0 ! smTruncMiddle = 0x4000 notTruncated = 0 truncated = 1 --- 201,209 ---- smLeftStyleRun = 1 smRightStyleRun = 2 ! smMiddleStyleRun = 3 truncEnd = 0 truncMiddle = 0x4000 smTruncEnd = 0 ! smTruncMiddle = 0x4000 notTruncated = 0 truncated = 1 *************** *** 211,215 **** smNotTruncated = 0 smTruncated = 1 ! smTruncErr = -1 smBreakWord = 0 smBreakChar = 1 --- 211,215 ---- smNotTruncated = 0 smTruncated = 1 ! smTruncErr = -1 smBreakWord = 0 smBreakChar = 1 Index: QuickTime.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/Carbon/QuickTime.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** QuickTime.py 13 Mar 2004 23:50:48 -0000 1.3 --- QuickTime.py 18 Jul 2004 06:14:46 -0000 1.4 *************** *** 119,123 **** dfKeyedText = 1 << 14 dfInverseHilite = 1 << 15 ! dfTextColorHilite = 1 << 16 searchTextDontGoToFoundTime = 1L << 16 searchTextDontHiliteFoundText = 1L << 17 --- 119,123 ---- dfKeyedText = 1 << 14 dfInverseHilite = 1 << 15 ! dfTextColorHilite = 1 << 16 searchTextDontGoToFoundTime = 1L << 16 [...1141 lines suppressed...] kNoteEventType = 0x00000001 *************** *** 3348,3355 **** kGeneralEventNoOp = 10 kGeneralEventUsedNotes = 11 ! kGeneralEventPartMix = 12 kMarkerEventEnd = 0 kMarkerEventBeat = 1 ! kMarkerEventTempo = 2 kCurrentlyNativeEndian = 1 kCurrentlyNotNativeEndian = 2 --- 3348,3355 ---- kGeneralEventNoOp = 10 kGeneralEventUsedNotes = 11 ! kGeneralEventPartMix = 12 kMarkerEventEnd = 0 kMarkerEventBeat = 1 ! kMarkerEventTempo = 2 kCurrentlyNativeEndian = 1 kCurrentlyNotNativeEndian = 2 Index: Resources.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/Carbon/Resources.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Resources.py 30 Dec 2002 22:04:21 -0000 1.1 --- Resources.py 18 Jul 2004 06:14:46 -0000 1.2 *************** *** 9,13 **** mapReadOnly = 128 mapCompact = 64 ! mapChanged = 32 resSysRefBit = 7 resSysHeapBit = 6 --- 9,13 ---- mapReadOnly = 128 mapCompact = 64 ! mapChanged = 32 resSysRefBit = 7 resSysHeapBit = 6 *************** *** 19,27 **** mapReadOnlyBit = 7 mapCompactBit = 6 ! mapChangedBit = 5 kResFileNotOpened = -1 ! kSystemResFile = 0 kRsrcChainBelowSystemMap = 0 kRsrcChainBelowApplicationMap = 1 kRsrcChainAboveApplicationMap = 2 ! kRsrcChainAboveAllMaps = 4 --- 19,27 ---- mapReadOnlyBit = 7 mapCompactBit = 6 ! mapChangedBit = 5 kResFileNotOpened = -1 ! kSystemResFile = 0 kRsrcChainBelowSystemMap = 0 kRsrcChainBelowApplicationMap = 1 kRsrcChainAboveApplicationMap = 2 ! kRsrcChainAboveAllMaps = 4 Index: Sound.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/Carbon/Sound.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Sound.py 30 Dec 2002 22:04:21 -0000 1.1 --- Sound.py 18 Jul 2004 06:14:46 -0000 1.2 *************** *** 2,7 **** def FOUR_CHAR_CODE(x): return x ! soundListRsrc = FOUR_CHAR_CODE('snd ') ! kSimpleBeepID = 1 # rate48khz = (long)0xBB800000 # rate44khz = (long)0xAC440000 --- 2,7 ---- def FOUR_CHAR_CODE(x): return x ! soundListRsrc = FOUR_CHAR_CODE('snd ') ! kSimpleBeepID = 1 # rate48khz = (long)0xBB800000 # rate44khz = (long)0xAC440000 *************** *** 12,30 **** rate11khz = 0x2B7745D1 rate11025hz = 0x2B110000 ! rate8khz = 0x1F400000 ! sampledSynth = 5 squareWaveSynth = 1 waveTableSynth = 3 MACE3snthID = 11 MACE6snthID = 13 ! kMiddleC = 60 kNoVolume = 0 ! kFullVolume = 0x0100 stdQLength = 128 dataOffsetFlag = 0x8000 ! kUseOptionalOutputDevice = -1 notCompressed = 0 fixedCompression = -1 ! variableCompression = -2 twoToOne = 1 eightToThree = 2 --- 12,30 ---- rate11khz = 0x2B7745D1 rate11025hz = 0x2B110000 ! rate8khz = 0x1F400000 ! sampledSynth = 5 squareWaveSynth = 1 waveTableSynth = 3 MACE3snthID = 11 MACE6snthID = 13 ! kMiddleC = 60 kNoVolume = 0 ! kFullVolume = 0x0100 stdQLength = 128 dataOffsetFlag = 0x8000 ! kUseOptionalOutputDevice = -1 notCompressed = 0 fixedCompression = -1 ! variableCompression = -2 twoToOne = 1 eightToThree = 2 *************** *** 36,50 **** leftOverBlockSize = 32 firstSoundFormat = 0x0001 ! secondSoundFormat = 0x0002 dbBufferReady = 0x00000001 ! dbLastBuffer = 0x00000004 sysBeepDisable = 0x0000 sysBeepEnable = (1 << 0) ! sysBeepSynchronous = (1 << 1) unitTypeNoSelection = 0xFFFF unitTypeSeconds = 0x0000 stdSH = 0x00 extSH = 0xFF ! cmpSH = 0xFE nullCmd = 0 quietCmd = 3 --- 36,50 ---- leftOverBlockSize = 32 firstSoundFormat = 0x0001 ! secondSoundFormat = 0x0002 dbBufferReady = 0x00000001 ! dbLastBuffer = 0x00000004 sysBeepDisable = 0x0000 sysBeepEnable = (1 << 0) ! sysBeepSynchronous = (1 << 1) unitTypeNoSelection = 0xFFFF unitTypeSeconds = 0x0000 stdSH = 0x00 extSH = 0xFF ! cmpSH = 0xFE nullCmd = 0 quietCmd = 3 *************** *** 85,89 **** getRateCmd = 85 sizeCmd = 90 ! convertCmd = 91 waveInitChannelMask = 0x07 waveInitChannel0 = 0x04 --- 85,89 ---- getRateCmd = 85 sizeCmd = 90 ! convertCmd = 91 waveInitChannelMask = 0x07 waveInitChannel0 = 0x04 *************** *** 94,98 **** initChan1 = waveInitChannel1 initChan2 = waveInitChannel2 ! initChan3 = waveInitChannel3 outsideCmpSH = 0 insideCmpSH = 1 --- 94,98 ---- initChan1 = waveInitChannel1 initChan2 = waveInitChannel2 ! initChan3 = waveInitChannel3 outsideCmpSH = 0 insideCmpSH = 1 *************** *** 103,107 **** aceBadEncode = 4 aceBadDest = 5 ! aceBadCmd = 6 initChanLeft = 0x0002 initChanRight = 0x0003 --- 103,107 ---- aceBadEncode = 4 aceBadDest = 5 ! aceBadCmd = 6 initChanLeft = 0x0002 initChanRight = 0x0003 *************** *** 115,119 **** initSRateMask = 0x0030 initStereoMask = 0x00C0 ! initCompMask = 0xFF00 siActiveChannels = FOUR_CHAR_CODE('chac') siActiveLevels = FOUR_CHAR_CODE('lmac') --- 115,119 ---- initSRateMask = 0x0030 initStereoMask = 0x00C0 ! initCompMask = 0xFF00 siActiveChannels = FOUR_CHAR_CODE('chac') siActiveLevels = FOUR_CHAR_CODE('lmac') *************** *** 201,209 **** siSupportedExtendedFlags = FOUR_CHAR_CODE('exfl') siRateConverterRollOffSlope = FOUR_CHAR_CODE('rcdb') ! siOutputLatency = FOUR_CHAR_CODE('olte') siCloseDriver = FOUR_CHAR_CODE('clos') siInitializeDriver = FOUR_CHAR_CODE('init') siPauseRecording = FOUR_CHAR_CODE('paus') ! siUserInterruptProc = FOUR_CHAR_CODE('user') # kInvalidSource = (long)0xFFFFFFFF kNoSource = FOUR_CHAR_CODE('none') --- 201,209 ---- siSupportedExtendedFlags = FOUR_CHAR_CODE('exfl') siRateConverterRollOffSlope = FOUR_CHAR_CODE('rcdb') ! siOutputLatency = FOUR_CHAR_CODE('olte') siCloseDriver = FOUR_CHAR_CODE('clos') siInitializeDriver = FOUR_CHAR_CODE('init') siPauseRecording = FOUR_CHAR_CODE('paus') ! siUserInterruptProc = FOUR_CHAR_CODE('user') # kInvalidSource = (long)0xFFFFFFFF kNoSource = FOUR_CHAR_CODE('none') *************** *** 220,224 **** kZoomVideoSource = FOUR_CHAR_CODE('zvpc') kDVDSource = FOUR_CHAR_CODE('dvda') ! kMicrophoneArray = FOUR_CHAR_CODE('mica') kNoSoundComponentType = FOUR_CHAR_CODE('****') kSoundComponentType = FOUR_CHAR_CODE('sift') --- 220,224 ---- kZoomVideoSource = FOUR_CHAR_CODE('zvpc') kDVDSource = FOUR_CHAR_CODE('dvda') ! kMicrophoneArray = FOUR_CHAR_CODE('mica') kNoSoundComponentType = FOUR_CHAR_CODE('****') kSoundComponentType = FOUR_CHAR_CODE('sift') *************** *** 288,292 **** kLittleEndianFormat = k16BitLittleEndianFormat kMPEGLayer3Format = 0x6D730055 ! kFullMPEGLay3Format = FOUR_CHAR_CODE('.mp3') k16BitNativeEndianFormat = k16BitLittleEndianFormat k16BitNonNativeEndianFormat = k16BitBigEndianFormat --- 288,292 ---- kLittleEndianFormat = k16BitLittleEndianFormat kMPEGLayer3Format = 0x6D730055 ! kFullMPEGLay3Format = FOUR_CHAR_CODE('.mp3') k16BitNativeEndianFormat = k16BitLittleEndianFormat k16BitNonNativeEndianFormat = k16BitBigEndianFormat *************** *** 324,329 **** kPagingMixer = (1 << 12) kVMAwareMixer = (1 << 13) ! kExtendedSoundData = (1 << 14) ! kBestQuality = (1 << 0) kInputMask = 0x000000FF kOutputMask = 0x0000FF00 --- 324,329 ---- kPagingMixer = (1 << 12) kVMAwareMixer = (1 << 13) ! kExtendedSoundData = (1 << 14) ! kBestQuality = (1 << 0) kInputMask = 0x000000FF kOutputMask = 0x0000FF00 *************** *** 338,342 **** kAVDisplayHeadphoneInsert = 1 kAVDisplayPlainTalkRemove = 2 ! kAVDisplayPlainTalkInsert = 3 audioAllChannels = 0 audioLeftChannel = 1 --- 338,342 ---- kAVDisplayHeadphoneInsert = 1 kAVDisplayPlainTalkRemove = 2 ! kAVDisplayPlainTalkInsert = 3 audioAllChannels = 0 audioLeftChannel = 1 *************** *** 346,364 **** audioDoesMono = (1L << 0) audioDoesStereo = (1L << 1) ! audioDoesIndependentChannels = (1L << 2) siCDQuality = FOUR_CHAR_CODE('cd ') siBestQuality = FOUR_CHAR_CODE('best') siBetterQuality = FOUR_CHAR_CODE('betr') siGoodQuality = FOUR_CHAR_CODE('good') ! siNoneQuality = FOUR_CHAR_CODE('none') siDeviceIsConnected = 1 siDeviceNotConnected = 0 siDontKnowIfConnected = -1 siReadPermission = 0 ! siWritePermission = 1 kSoundConverterDidntFillBuffer = (1 << 0) ! kSoundConverterHasLeftOverData = (1 << 1) kExtendedSoundSampleCountNotValid = 1L << 0 ! kExtendedSoundBufferSizeValid = 1L << 1 kScheduledSoundDoScheduled = 1 << 0 kScheduledSoundDoCallBack = 1 << 1 --- 346,364 ---- audioDoesMono = (1L << 0) audioDoesStereo = (1L << 1) ! audioDoesIndependentChannels = (1L << 2) siCDQuality = FOUR_CHAR_CODE('cd ') siBestQuality = FOUR_CHAR_CODE('best') siBetterQuality = FOUR_CHAR_CODE('betr') siGoodQuality = FOUR_CHAR_CODE('good') ! siNoneQuality = FOUR_CHAR_CODE('none') siDeviceIsConnected = 1 siDeviceNotConnected = 0 siDontKnowIfConnected = -1 siReadPermission = 0 ! siWritePermission = 1 kSoundConverterDidntFillBuffer = (1 << 0) ! kSoundConverterHasLeftOverData = (1 << 1) kExtendedSoundSampleCountNotValid = 1L << 0 ! kExtendedSoundBufferSizeValid = 1L << 1 kScheduledSoundDoScheduled = 1 << 0 kScheduledSoundDoCallBack = 1 << 1 Index: TextEdit.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/Carbon/TextEdit.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TextEdit.py 30 Dec 2002 22:04:21 -0000 1.1 --- TextEdit.py 18 Jul 2004 06:14:46 -0000 1.2 *************** *** 8,12 **** teCenter = 1 teFlushRight = -1 ! teFlushLeft = -2 fontBit = 0 faceBit = 1 --- 8,12 ---- teCenter = 1 teFlushRight = -1 ! teFlushLeft = -2 fontBit = 0 faceBit = 1 *************** *** 14,18 **** clrBit = 3 addSizeBit = 4 ! toggleBit = 5 doFont = 1 doFace = 2 --- 14,18 ---- clrBit = 3 addSizeBit = 4 ! toggleBit = 5 doFont = 1 doFace = 2 *************** *** 21,25 **** doAll = 15 addSize = 16 ! doToggle = 32 EOLHook = 0 DRAWHook = 4 --- 21,25 ---- doAll = 15 addSize = 16 ! doToggle = 32 EOLHook = 0 DRAWHook = 4 *************** *** 27,31 **** HITTESTHook = 12 nWIDTHHook = 24 ! TextWidthHook = 28 intEOLHook = 0 intDrawHook = 1 --- 27,31 ---- HITTESTHook = 12 nWIDTHHook = 24 ! TextWidthHook = 28 intEOLHook = 0 intDrawHook = 1 *************** *** 35,39 **** intTextWidthHook = 7 intInlineInputTSMTEPreUpdateHook = 8 ! intInlineInputTSMTEPostUpdateHook = 9 teFAutoScroll = 0 teFTextBuffering = 1 --- 35,39 ---- intTextWidthHook = 7 intInlineInputTSMTEPreUpdateHook = 8 ! intInlineInputTSMTEPostUpdateHook = 9 teFAutoScroll = 0 teFTextBuffering = 1 *************** *** 42,57 **** teFUseWhiteBackground = 4 teFUseInlineInput = 5 ! teFInlineInputAutoScroll = 6 ! teFIdleWithEventLoopTimer = 7 teBitClear = 0 teBitSet = 1 ! teBitTest = -1 teWordSelect = 4 teWordDrag = 8 teFromFind = 12 ! teFromRecal = 16 teFind = 0 teHighlight = 1 teDraw = -1 ! teCaret = -2 ! teFUseTextServices = 4 --- 42,57 ---- teFUseWhiteBackground = 4 teFUseInlineInput = 5 ! teFInlineInputAutoScroll = 6 ! teFIdleWithEventLoopTimer = 7 teBitClear = 0 teBitSet = 1 ! teBitTest = -1 teWordSelect = 4 teWordDrag = 8 teFromFind = 12 ! teFromRecal = 16 teFind = 0 teHighlight = 1 teDraw = -1 ! teCaret = -2 ! teFUseTextServices = 4 Index: Windows.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/Carbon/Windows.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Windows.py 5 Dec 2003 23:59:37 -0000 1.2 --- Windows.py 18 Jul 2004 06:14:46 -0000 1.3 *************** *** 45,49 **** kStandardWindowDefinition = 0 kRoundWindowDefinition = 1 ! kFloatingWindowDefinition = 124 kDocumentWindowVariantCode = 0 kModalDialogVariantCode = 1 --- 45,49 ---- kStandardWindowDefinition = 0 kRoundWindowDefinition = 1 ! kFloatingWindowDefinition = 124 kDocumentWindowVariantCode = 0 kModalDialogVariantCode = 1 *************** *** 110,114 **** kWindowFloatSideFullZoomGrowProc = 1087 kWindowSheetProc = 1088 ! kWindowSheetAlertProc = 1120 kWindowSimpleProc = 1104 kWindowSimpleFrameProc = 1105 --- 110,114 ---- kWindowFloatSideFullZoomGrowProc = 1087 kWindowSheetProc = 1088 ! kWindowSheetAlertProc = 1120 kWindowSimpleProc = 1104 kWindowSimpleFrameProc = 1105 *************** *** 146,150 **** kWindowUpdateRgn = 34 kWindowOpaqueRgn = 35 ! kWindowGlobalPortRgn = 40 dialogKind = 2 userKind = 8 --- 146,150 ---- kWindowUpdateRgn = 34 kWindowOpaqueRgn = 35 ! kWindowGlobalPortRgn = 40 dialogKind = 2 userKind = 8 *************** *** 164,168 **** inProxyIcon = 12 inToolbarButton = 13 ! inStructure = 15 wNoHit = 0 wInContent = 1 --- 164,168 ---- inProxyIcon = 12 inToolbarButton = 13 ! inStructure = 15 wNoHit = 0 wInContent = 1 *************** *** 175,179 **** wInProxyIcon = 10 wInToolbarButton = 11 ! wInStructure = 13 kWindowMsgDraw = 0 kWindowMsgHitTest = 1 --- 175,179 ---- wInProxyIcon = 10 wInToolbarButton = 11 ! wInStructure = 13 kWindowMsgDraw = 0 kWindowMsgHitTest = 1 *************** *** 190,195 **** kWindowMsgSetupProxyDragImage = 12 kWindowMsgStateChanged = 13 ! kWindowMsgMeasureTitle = 14 ! kWindowMsgGetGrowImageRegion = 19 wDraw = 0 wHit = 1 --- 190,195 ---- kWindowMsgSetupProxyDragImage = 12 kWindowMsgStateChanged = 13 ! kWindowMsgMeasureTitle = 14 ! kWindowMsgGetGrowImageRegion = 19 wDraw = 0 wHit = 1 *************** *** 215,219 **** kWindowSupportsGetGrowImageRegion = (1 << 13) kWindowDefSupportsColorGrafPort = 0x40000002 ! kWindowIsOpaque = (1 << 14) kWindowSupportsSetGrowImageRegion = (1 << 13) deskPatID = 16 --- 215,219 ---- kWindowSupportsGetGrowImageRegion = (1 << 13) kWindowDefSupportsColorGrafPort = 0x40000002 ! kWindowIsOpaque = (1 << 14) kWindowSupportsSetGrowImageRegion = (1 << 13) deskPatID = 16 *************** *** 229,236 **** kStoredWindowSystemTag = FOUR_CHAR_CODE('appl') kStoredBasicWindowDescriptionID = FOUR_CHAR_CODE('sbas') ! kStoredWindowPascalTitleID = FOUR_CHAR_CODE('s255') kWindowDefProcPtr = 0 kWindowDefObjectClass = 1 ! kWindowDefProcID = 2 kWindowModalityNone = 0 kWindowModalitySystemModal = 1 --- 229,236 ---- kStoredWindowSystemTag = FOUR_CHAR_CODE('appl') kStoredBasicWindowDescriptionID = FOUR_CHAR_CODE('sbas') ! kStoredWindowPascalTitleID = FOUR_CHAR_CODE('s255') kWindowDefProcPtr = 0 kWindowDefObjectClass = 1 ! kWindowDefProcID = 2 kWindowModalityNone = 0 kWindowModalitySystemModal = 1 *************** *** 253,257 **** kScrollWindowNoOptions = 0 kScrollWindowInvalidate = (1L << 0) ! kScrollWindowEraseToPortBackground = (1L << 1) kWindowMenuIncludeRotate = 1 << 0 kWindowZoomTransitionEffect = 1 --- 253,257 ---- kScrollWindowNoOptions = 0 kScrollWindowInvalidate = (1L << 0) ! kScrollWindowEraseToPortBackground = (1L << 1) kWindowMenuIncludeRotate = 1 << 0 kWindowZoomTransitionEffect = 1 *************** *** 274,278 **** kWindowLatentVisibleCollapsedOwner = 1 << 4 kWindowLatentVisibleCollapsedGroup = 1 << 5 ! kWindowPropertyPersistent = 0x00000001 kWindowGroupAttrSelectable = kWindowGroupAttrSelectAsLayer kWindowGroupAttrPositionFixed = kWindowGroupAttrMoveTogether --- 274,278 ---- kWindowLatentVisibleCollapsedOwner = 1 << 4 kWindowLatentVisibleCollapsedGroup = 1 << 5 ! kWindowPropertyPersistent = 0x00000001 kWindowGroupAttrSelectable = kWindowGroupAttrSelectAsLayer kWindowGroupAttrPositionFixed = kWindowGroupAttrMoveTogether Index: __init__.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/Carbon/__init__.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** __init__.py 30 Dec 2002 22:04:21 -0000 1.1 --- __init__.py 18 Jul 2004 06:14:46 -0000 1.2 *************** *** 1 **** ! # Filter out warnings about signed/unsigned constants import warnings warnings.filterwarnings("ignore", "", FutureWarning, ".*Controls") warnings.filterwarnings("ignore", "", FutureWarning, ".*MacTextEditor") \ No newline at end of file --- 1 ---- ! # Filter out warnings about signed/unsigned constants import warnings warnings.filterwarnings("ignore", "", FutureWarning, ".*Controls") warnings.filterwarnings("ignore", "", FutureWarning, ".*MacTextEditor") From tim_one at users.sourceforge.net Sun Jul 18 08:16:10 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 08:16:12 2004 Subject: [Python-checkins] python/dist/src/Modules cgen.py,2.17,2.18 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31781 Modified Files: cgen.py Log Message: Whitespace normalization, via reindent.py. Index: cgen.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/cgen.py,v retrieving revision 2.17 retrieving revision 2.18 diff -C2 -d -r2.17 -r2.18 *** cgen.py 12 Feb 2004 17:35:14 -0000 2.17 --- cgen.py 18 Jul 2004 06:16:08 -0000 2.18 *************** *** 4,8 **** # Copyright (c) 1990-1995, Stichting Mathematisch Centrum. # All rights reserved. ! # # See the file "Misc/COPYRIGHT" for information on usage and # redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. --- 4,8 ---- # Copyright (c) 1990-1995, Stichting Mathematisch Centrum. # All rights reserved. ! # # See the file "Misc/COPYRIGHT" for information on usage and # redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. *************** *** 13,18 **** # # NOTE: You must first make a python binary without the "GL" option ! # before you can run this, when building Python for the first time. ! # See comments in the Makefile. # # XXX BUG return arrays generate wrong code --- 13,18 ---- # # NOTE: You must first make a python binary without the "GL" option ! # before you can run this, when building Python for the first time. ! # See comments in the Makefile. # # XXX BUG return arrays generate wrong code *************** *** 27,38 **** # def err(*args): ! savestdout = sys.stdout ! try: ! sys.stdout = sys.stderr ! for i in args: ! print i, ! print ! finally: ! sys.stdout = savestdout --- 27,38 ---- # def err(*args): ! savestdout = sys.stdout ! try: ! sys.stdout = sys.stderr ! for i in args: ! print i, ! print ! finally: ! sys.stdout = savestdout *************** *** 47,55 **** # def getnum(s): ! n = '' ! while s and s[0] in digits: ! n = n + s[0] ! s = s[1:] ! return n, s --- 47,55 ---- # def getnum(s): ! n = '' ! while s and s[0] in digits: ! n = n + s[0] ! s = s[1:] ! return n, s *************** *** 57,64 **** # def isnum(s): ! if not s: return False ! for c in s: ! if not c in digits: return False ! return True --- 57,64 ---- # def isnum(s): ! if not s: return False ! for c in s: ! if not c in digits: return False ! return True *************** *** 74,89 **** # Need to classify arguments as follows ! # simple input variable ! # simple output variable ! # input array ! # output array ! # input giving size of some array # # Array dimensions can be specified as follows ! # constant ! # argN ! # constant * argN ! # retval ! # constant * retval # # The dimensions given as constants * something are really --- 74,89 ---- # Need to classify arguments as follows ! # simple input variable ! # simple output variable ! # input array ! # output array ! # input giving size of some array # # Array dimensions can be specified as follows ! # constant ! # argN ! # constant * argN ! # retval ! # constant * retval # # The dimensions given as constants * something are really *************** *** 91,97 **** # # We have to consider three lists: ! # python input arguments ! # C stub arguments (in & out) ! # python output arguments (really return values) # # There is a mapping from python input arguments to the input arguments --- 91,97 ---- # # We have to consider three lists: ! # python input arguments ! # C stub arguments (in & out) ! # python output arguments (really return values) # # There is a mapping from python input arguments to the input arguments *************** *** 111,177 **** # def checkarg(type, arg): ! # ! # Turn "char *x" into "string x". ! # ! if type == 'char' and arg[0] == '*': ! type = 'string' ! arg = arg[1:] ! # ! # Check that the type is supported. ! # ! if type not in arg_types: ! raise arg_error, ('bad type', type) ! if type[:2] == 'u_': ! type = 'unsigned ' + type[2:] ! # ! # Split it in the mode (first character) and the rest. ! # ! mode, rest = arg[:1], arg[1:] ! # ! # The mode must be 's' for send (= input) or 'r' for return argument. ! # ! if mode not in ('r', 's'): ! raise arg_error, ('bad arg mode', mode) ! # ! # Is it a simple argument: if so, we are done. ! # ! if not rest: ! return type, mode, '', '' ! # ! # Not a simple argument; must be an array. ! # The 'rest' must be a subscript enclosed in [ and ]. ! # The subscript must be one of the following forms, ! # otherwise we don't handle it (where N is a number): ! # N ! # argN ! # retval ! # N*argN ! # N*retval ! # ! if rest[:1] <> '[' or rest[-1:] <> ']': ! raise arg_error, ('subscript expected', rest) ! sub = rest[1:-1] ! # ! # Is there a leading number? ! # ! num, sub = getnum(sub) ! if num: ! # There is a leading number ! if not sub: ! # The subscript is just a number ! return type, mode, num, '' ! if sub[:1] == '*': ! # There is a factor prefix ! sub = sub[1:] ! else: ! raise arg_error, ('\'*\' expected', sub) ! if sub == 'retval': ! # size is retval -- must be a reply argument ! if mode <> 'r': ! raise arg_error, ('non-r mode with [retval]', mode) ! elif not isnum(sub) and (sub[:3] <> 'arg' or not isnum(sub[3:])): ! raise arg_error, ('bad subscript', sub) ! # ! return type, mode, num, sub --- 111,177 ---- # def checkarg(type, arg): ! # ! # Turn "char *x" into "string x". ! # ! if type == 'char' and arg[0] == '*': ! type = 'string' ! arg = arg[1:] ! # ! # Check that the type is supported. ! # ! if type not in arg_types: ! raise arg_error, ('bad type', type) ! if type[:2] == 'u_': ! type = 'unsigned ' + type[2:] ! # ! # Split it in the mode (first character) and the rest. ! # ! mode, rest = arg[:1], arg[1:] ! # ! # The mode must be 's' for send (= input) or 'r' for return argument. ! # ! if mode not in ('r', 's'): ! raise arg_error, ('bad arg mode', mode) ! # ! # Is it a simple argument: if so, we are done. ! # ! if not rest: ! return type, mode, '', '' ! # ! # Not a simple argument; must be an array. ! # The 'rest' must be a subscript enclosed in [ and ]. ! # The subscript must be one of the following forms, ! # otherwise we don't handle it (where N is a number): ! # N ! # argN ! # retval ! # N*argN ! # N*retval ! # ! if rest[:1] <> '[' or rest[-1:] <> ']': ! raise arg_error, ('subscript expected', rest) ! sub = rest[1:-1] ! # ! # Is there a leading number? ! # ! num, sub = getnum(sub) ! if num: ! # There is a leading number ! if not sub: ! # The subscript is just a number ! return type, mode, num, '' ! if sub[:1] == '*': ! # There is a factor prefix ! sub = sub[1:] ! else: ! raise arg_error, ('\'*\' expected', sub) ! if sub == 'retval': ! # size is retval -- must be a reply argument ! if mode <> 'r': ! raise arg_error, ('non-r mode with [retval]', mode) ! elif not isnum(sub) and (sub[:3] <> 'arg' or not isnum(sub[3:])): ! raise arg_error, ('bad subscript', sub) ! # ! return type, mode, num, sub *************** *** 185,405 **** # def generate(type, func, database): ! # ! # Check that we can handle this case: ! # no variable size reply arrays yet ! # ! n_in_args = 0 ! n_out_args = 0 ! # ! for a_type, a_mode, a_factor, a_sub in database: ! if a_mode == 's': ! n_in_args = n_in_args + 1 ! elif a_mode == 'r': ! n_out_args = n_out_args + 1 ! else: ! # Can't happen ! raise arg_error, ('bad a_mode', a_mode) ! if (a_mode == 'r' and a_sub) or a_sub == 'retval': ! err('Function', func, 'too complicated:', ! a_type, a_mode, a_factor, a_sub) ! print '/* XXX Too complicated to generate code for */' ! return ! # ! functions.append(func) ! # ! # Stub header ! # ! print ! print 'static PyObject *' ! print 'gl_' + func + '(self, args)' ! print '\tPyObject *self;' ! print '\tPyObject *args;' ! print '{' ! # ! # Declare return value if any ! # ! if type <> 'void': ! print '\t' + type, 'retval;' ! # ! # Declare arguments ! # ! for i in range(len(database)): ! a_type, a_mode, a_factor, a_sub = database[i] ! print '\t' + a_type, ! brac = ket = '' ! if a_sub and not isnum(a_sub): ! if a_factor: ! brac = '(' ! ket = ')' ! print brac + '*', ! print 'arg' + repr(i+1) + ket, ! if a_sub and isnum(a_sub): ! print '[', a_sub, ']', ! if a_factor: ! print '[', a_factor, ']', ! print ';' ! # ! # Find input arguments derived from array sizes ! # ! for i in range(len(database)): ! a_type, a_mode, a_factor, a_sub = database[i] ! if a_mode == 's' and a_sub[:3] == 'arg' and isnum(a_sub[3:]): ! # Sending a variable-length array ! n = eval(a_sub[3:]) ! if 1 <= n <= len(database): ! b_type, b_mode, b_factor, b_sub = database[n-1] ! if b_mode == 's': ! database[n-1] = b_type, 'i', a_factor, repr(i) ! n_in_args = n_in_args - 1 ! # ! # Assign argument positions in the Python argument list ! # ! in_pos = [] ! i_in = 0 ! for i in range(len(database)): ! a_type, a_mode, a_factor, a_sub = database[i] ! if a_mode == 's': ! in_pos.append(i_in) ! i_in = i_in + 1 ! else: ! in_pos.append(-1) ! # ! # Get input arguments ! # ! for i in range(len(database)): ! a_type, a_mode, a_factor, a_sub = database[i] ! if a_type[:9] == 'unsigned ': ! xtype = a_type[9:] ! else: ! xtype = a_type ! if a_mode == 'i': ! # ! # Implicit argument; ! # a_factor is divisor if present, ! # a_sub indicates which arg (`database index`) ! # ! j = eval(a_sub) ! print '\tif', ! print '(!geti' + xtype + 'arraysize(args,', ! print repr(n_in_args) + ',', ! print repr(in_pos[j]) + ',', ! if xtype <> a_type: ! print '('+xtype+' *)', ! print '&arg' + repr(i+1) + '))' ! print '\t\treturn NULL;' ! if a_factor: ! print '\targ' + repr(i+1), ! print '= arg' + repr(i+1), ! print '/', a_factor + ';' ! elif a_mode == 's': ! if a_sub and not isnum(a_sub): ! # Allocate memory for varsize array ! print '\tif ((arg' + repr(i+1), '=', ! if a_factor: ! print '('+a_type+'(*)['+a_factor+'])', ! print 'PyMem_NEW(' + a_type, ',', ! if a_factor: ! print a_factor, '*', ! print a_sub, ')) == NULL)' ! print '\t\treturn PyErr_NoMemory();' ! print '\tif', ! if a_factor or a_sub: # Get a fixed-size array array ! print '(!geti' + xtype + 'array(args,', ! print repr(n_in_args) + ',', ! print repr(in_pos[i]) + ',', ! if a_factor: print a_factor, ! if a_factor and a_sub: print '*', ! if a_sub: print a_sub, ! print ',', ! if (a_sub and a_factor) or xtype <> a_type: ! print '('+xtype+' *)', ! print 'arg' + repr(i+1) + '))' ! else: # Get a simple variable ! print '(!geti' + xtype + 'arg(args,', ! print repr(n_in_args) + ',', ! print repr(in_pos[i]) + ',', ! if xtype <> a_type: ! print '('+xtype+' *)', ! print '&arg' + repr(i+1) + '))' ! print '\t\treturn NULL;' ! # ! # Begin of function call ! # ! if type <> 'void': ! print '\tretval =', func + '(', ! else: ! print '\t' + func + '(', ! # ! # Argument list ! # ! for i in range(len(database)): ! if i > 0: print ',', ! a_type, a_mode, a_factor, a_sub = database[i] ! if a_mode == 'r' and not a_factor: ! print '&', ! print 'arg' + repr(i+1), ! # ! # End of function call ! # ! print ');' ! # ! # Free varsize arrays ! # ! for i in range(len(database)): ! a_type, a_mode, a_factor, a_sub = database[i] ! if a_mode == 's' and a_sub and not isnum(a_sub): ! print '\tPyMem_DEL(arg' + repr(i+1) + ');' ! # ! # Return ! # ! if n_out_args: ! # ! # Multiple return values -- construct a tuple ! # ! if type <> 'void': ! n_out_args = n_out_args + 1 ! if n_out_args == 1: ! for i in range(len(database)): ! a_type, a_mode, a_factor, a_sub = database[i] ! if a_mode == 'r': ! break ! else: ! raise arg_error, 'expected r arg not found' ! print '\treturn', ! print mkobject(a_type, 'arg' + repr(i+1)) + ';' ! else: ! print '\t{ PyObject *v = PyTuple_New(', ! print n_out_args, ');' ! print '\t if (v == NULL) return NULL;' ! i_out = 0 ! if type <> 'void': ! print '\t PyTuple_SetItem(v,', ! print repr(i_out) + ',', ! print mkobject(type, 'retval') + ');' ! i_out = i_out + 1 ! for i in range(len(database)): ! a_type, a_mode, a_factor, a_sub = database[i] ! if a_mode == 'r': ! print '\t PyTuple_SetItem(v,', ! print repr(i_out) + ',', ! s = mkobject(a_type, 'arg' + repr(i+1)) ! print s + ');' ! i_out = i_out + 1 ! print '\t return v;' ! print '\t}' ! else: ! # ! # Simple function return ! # Return None or return value ! # ! if type == 'void': ! print '\tPy_INCREF(Py_None);' ! print '\treturn Py_None;' ! else: ! print '\treturn', mkobject(type, 'retval') + ';' ! # ! # Stub body closing brace ! # ! print '}' --- 185,405 ---- # def generate(type, func, database): ! # ! # Check that we can handle this case: ! # no variable size reply arrays yet ! # ! n_in_args = 0 ! n_out_args = 0 ! # ! for a_type, a_mode, a_factor, a_sub in database: ! if a_mode == 's': ! n_in_args = n_in_args + 1 ! elif a_mode == 'r': ! n_out_args = n_out_args + 1 ! else: ! # Can't happen ! raise arg_error, ('bad a_mode', a_mode) ! if (a_mode == 'r' and a_sub) or a_sub == 'retval': ! err('Function', func, 'too complicated:', ! a_type, a_mode, a_factor, a_sub) ! print '/* XXX Too complicated to generate code for */' ! return ! # ! functions.append(func) ! # ! # Stub header ! # ! print ! print 'static PyObject *' ! print 'gl_' + func + '(self, args)' ! print '\tPyObject *self;' ! print '\tPyObject *args;' ! print '{' ! # ! # Declare return value if any ! # ! if type <> 'void': ! print '\t' + type, 'retval;' ! # ! # Declare arguments ! # ! for i in range(len(database)): ! a_type, a_mode, a_factor, a_sub = database[i] ! print '\t' + a_type, ! brac = ket = '' ! if a_sub and not isnum(a_sub): ! if a_factor: ! brac = '(' ! ket = ')' ! print brac + '*', ! print 'arg' + repr(i+1) + ket, ! if a_sub and isnum(a_sub): ! print '[', a_sub, ']', ! if a_factor: ! print '[', a_factor, ']', ! print ';' ! # ! # Find input arguments derived from array sizes ! # ! for i in range(len(database)): ! a_type, a_mode, a_factor, a_sub = database[i] ! if a_mode == 's' and a_sub[:3] == 'arg' and isnum(a_sub[3:]): ! # Sending a variable-length array ! n = eval(a_sub[3:]) ! if 1 <= n <= len(database): ! b_type, b_mode, b_factor, b_sub = database[n-1] ! if b_mode == 's': ! database[n-1] = b_type, 'i', a_factor, repr(i) ! n_in_args = n_in_args - 1 ! # ! # Assign argument positions in the Python argument list ! # ! in_pos = [] ! i_in = 0 ! for i in range(len(database)): ! a_type, a_mode, a_factor, a_sub = database[i] ! if a_mode == 's': ! in_pos.append(i_in) ! i_in = i_in + 1 ! else: ! in_pos.append(-1) ! # ! # Get input arguments ! # ! for i in range(len(database)): ! a_type, a_mode, a_factor, a_sub = database[i] ! if a_type[:9] == 'unsigned ': ! xtype = a_type[9:] ! else: ! xtype = a_type ! if a_mode == 'i': ! # ! # Implicit argument; ! # a_factor is divisor if present, ! # a_sub indicates which arg (`database index`) ! # ! j = eval(a_sub) ! print '\tif', ! print '(!geti' + xtype + 'arraysize(args,', ! print repr(n_in_args) + ',', ! print repr(in_pos[j]) + ',', ! if xtype <> a_type: ! print '('+xtype+' *)', ! print '&arg' + repr(i+1) + '))' ! print '\t\treturn NULL;' ! if a_factor: ! print '\targ' + repr(i+1), ! print '= arg' + repr(i+1), ! print '/', a_factor + ';' ! elif a_mode == 's': ! if a_sub and not isnum(a_sub): ! # Allocate memory for varsize array ! print '\tif ((arg' + repr(i+1), '=', ! if a_factor: ! print '('+a_type+'(*)['+a_factor+'])', ! print 'PyMem_NEW(' + a_type, ',', ! if a_factor: ! print a_factor, '*', ! print a_sub, ')) == NULL)' ! print '\t\treturn PyErr_NoMemory();' ! print '\tif', ! if a_factor or a_sub: # Get a fixed-size array array ! print '(!geti' + xtype + 'array(args,', ! print repr(n_in_args) + ',', ! print repr(in_pos[i]) + ',', ! if a_factor: print a_factor, ! if a_factor and a_sub: print '*', ! if a_sub: print a_sub, ! print ',', ! if (a_sub and a_factor) or xtype <> a_type: ! print '('+xtype+' *)', ! print 'arg' + repr(i+1) + '))' ! else: # Get a simple variable ! print '(!geti' + xtype + 'arg(args,', ! print repr(n_in_args) + ',', ! print repr(in_pos[i]) + ',', ! if xtype <> a_type: ! print '('+xtype+' *)', ! print '&arg' + repr(i+1) + '))' ! print '\t\treturn NULL;' ! # ! # Begin of function call ! # ! if type <> 'void': ! print '\tretval =', func + '(', ! else: ! print '\t' + func + '(', ! # ! # Argument list ! # ! for i in range(len(database)): ! if i > 0: print ',', ! a_type, a_mode, a_factor, a_sub = database[i] ! if a_mode == 'r' and not a_factor: ! print '&', ! print 'arg' + repr(i+1), ! # ! # End of function call ! # ! print ');' ! # ! # Free varsize arrays ! # ! for i in range(len(database)): ! a_type, a_mode, a_factor, a_sub = database[i] ! if a_mode == 's' and a_sub and not isnum(a_sub): ! print '\tPyMem_DEL(arg' + repr(i+1) + ');' ! # ! # Return ! # ! if n_out_args: ! # ! # Multiple return values -- construct a tuple ! # ! if type <> 'void': ! n_out_args = n_out_args + 1 ! if n_out_args == 1: ! for i in range(len(database)): ! a_type, a_mode, a_factor, a_sub = database[i] ! if a_mode == 'r': ! break ! else: ! raise arg_error, 'expected r arg not found' ! print '\treturn', ! print mkobject(a_type, 'arg' + repr(i+1)) + ';' ! else: ! print '\t{ PyObject *v = PyTuple_New(', ! print n_out_args, ');' ! print '\t if (v == NULL) return NULL;' ! i_out = 0 ! if type <> 'void': ! print '\t PyTuple_SetItem(v,', ! print repr(i_out) + ',', ! print mkobject(type, 'retval') + ');' ! i_out = i_out + 1 ! for i in range(len(database)): ! a_type, a_mode, a_factor, a_sub = database[i] ! if a_mode == 'r': ! print '\t PyTuple_SetItem(v,', ! print repr(i_out) + ',', ! s = mkobject(a_type, 'arg' + repr(i+1)) ! print s + ');' ! i_out = i_out + 1 ! print '\t return v;' ! print '\t}' ! else: ! # ! # Simple function return ! # Return None or return value ! # ! if type == 'void': ! print '\tPy_INCREF(Py_None);' ! print '\treturn Py_None;' ! else: ! print '\treturn', mkobject(type, 'retval') + ';' ! # ! # Stub body closing brace ! # ! print '}' *************** *** 407,414 **** # def mkobject(type, arg): ! if type[:9] == 'unsigned ': ! type = type[9:] ! return 'mknew' + type + 'object((' + type + ') ' + arg + ')' ! return 'mknew' + type + 'object(' + arg + ')' --- 407,414 ---- # def mkobject(type, arg): ! if type[:9] == 'unsigned ': ! type = type[9:] ! return 'mknew' + type + 'object((' + type + ') ' + arg + ')' ! return 'mknew' + type + 'object(' + arg + ')' *************** *** 417,425 **** # usage: cgen [ -Dmach ... ] [ file ] for arg in sys.argv[1:]: ! if arg[:2] == '-D': ! defined_archs.append(arg[2:]) ! else: ! # Open optional file argument ! sys.stdin = open(arg, 'r') --- 417,425 ---- # usage: cgen [ -Dmach ... ] [ file ] for arg in sys.argv[1:]: ! if arg[:2] == '-D': ! defined_archs.append(arg[2:]) ! else: ! # Open optional file argument ! sys.stdin = open(arg, 'r') *************** *** 429,434 **** # Input is divided in two parts, separated by a line containing '%%'. ! # -- literally copied to stdout ! # -- stub definitions # Variable indicating the current input part. --- 429,434 ---- # Input is divided in two parts, separated by a line containing '%%'. ! # -- literally copied to stdout ! # -- stub definitions # Variable indicating the current input part. *************** *** 439,508 **** # while 1: ! try: ! line = raw_input() ! except EOFError: ! break ! # ! lno = lno+1 ! words = string.split(line) ! # ! if part == 1: ! # ! # In part 1, copy everything literally ! # except look for a line of just '%%' ! # ! if words == ['%%']: ! part = part + 1 ! else: ! # ! # Look for names of manually written ! # stubs: a single percent followed by the name ! # of the function in Python. ! # The stub name is derived by prefixing 'gl_'. ! # ! if words and words[0][0] == '%': ! func = words[0][1:] ! if (not func) and words[1:]: ! func = words[1] ! if func: ! functions.append(func) ! else: ! print line ! continue ! if not words: ! continue # skip empty line ! elif words[0] == 'if': ! # if XXX rest ! # if !XXX rest ! if words[1][0] == '!': ! if words[1][1:] in defined_archs: ! continue ! elif words[1] not in defined_archs: ! continue ! words = words[2:] ! if words[0] == '#include': ! print line ! elif words[0][:1] == '#': ! pass # ignore comment ! elif words[0] not in return_types: ! err('Line', lno, ': bad return type :', words[0]) ! elif len(words) < 2: ! err('Line', lno, ': no funcname :', line) ! else: ! if len(words) % 2 <> 0: ! err('Line', lno, ': odd argument list :', words[2:]) ! else: ! database = [] ! try: ! for i in range(2, len(words), 2): ! x = checkarg(words[i], words[i+1]) ! database.append(x) ! print ! print '/*', ! for w in words: print w, ! print '*/' ! generate(words[0], words[1], database) ! except arg_error, msg: ! err('Line', lno, ':', msg) --- 439,508 ---- # while 1: ! try: ! line = raw_input() ! except EOFError: ! break ! # ! lno = lno+1 ! words = string.split(line) ! # ! if part == 1: ! # ! # In part 1, copy everything literally ! # except look for a line of just '%%' ! # ! if words == ['%%']: ! part = part + 1 ! else: ! # ! # Look for names of manually written ! # stubs: a single percent followed by the name ! # of the function in Python. ! # The stub name is derived by prefixing 'gl_'. ! # ! if words and words[0][0] == '%': ! func = words[0][1:] ! if (not func) and words[1:]: ! func = words[1] ! if func: ! functions.append(func) ! else: ! print line ! continue ! if not words: ! continue # skip empty line ! elif words[0] == 'if': ! # if XXX rest ! # if !XXX rest ! if words[1][0] == '!': ! if words[1][1:] in defined_archs: ! continue ! elif words[1] not in defined_archs: ! continue ! words = words[2:] ! if words[0] == '#include': ! print line ! elif words[0][:1] == '#': ! pass # ignore comment ! elif words[0] not in return_types: ! err('Line', lno, ': bad return type :', words[0]) ! elif len(words) < 2: ! err('Line', lno, ': no funcname :', line) ! else: ! if len(words) % 2 <> 0: ! err('Line', lno, ': odd argument list :', words[2:]) ! else: ! database = [] ! try: ! for i in range(2, len(words), 2): ! x = checkarg(words[i], words[i+1]) ! database.append(x) ! print ! print '/*', ! for w in words: print w, ! print '*/' ! generate(words[0], words[1], database) ! except arg_error, msg: ! err('Line', lno, ':', msg) *************** *** 510,514 **** print 'static struct PyMethodDef gl_methods[] = {' for func in functions: ! print '\t{"' + func + '", gl_' + func + '},' print '\t{NULL, NULL} /* Sentinel */' print '};' --- 510,514 ---- print 'static struct PyMethodDef gl_methods[] = {' for func in functions: ! print '\t{"' + func + '", gl_' + func + '},' print '\t{NULL, NULL} /* Sentinel */' print '};' From tim_one at users.sourceforge.net Sun Jul 18 08:25:17 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 08:25:19 2004 Subject: [Python-checkins] python/dist/src/Doc/ext setup.py, 1.2, 1.3 test.py, 1.2, 1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/ext In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32520/ext Modified Files: setup.py test.py Log Message: Whitespace normalization, via reindent.py. Index: setup.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ext/setup.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** setup.py 28 Jun 2003 13:29:16 -0000 1.2 --- setup.py 18 Jul 2004 06:25:15 -0000 1.3 *************** *** 7,9 **** Extension("noddy4", ["noddy4.c"]), ]) - --- 7,8 ---- Index: test.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ext/test.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** test.py 28 Jun 2003 13:29:16 -0000 1.2 --- test.py 18 Jul 2004 06:25:15 -0000 1.3 *************** *** 212,214 **** import doctest, __main__ doctest.testmod(__main__) - --- 212,213 ---- From tim_one at users.sourceforge.net Sun Jul 18 08:25:17 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 08:25:21 2004 Subject: [Python-checkins] python/dist/src/Doc/ref reswords.py,1.2,1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/ref In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32520/ref Modified Files: reswords.py Log Message: Whitespace normalization, via reindent.py. Index: reswords.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ref/reswords.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** reswords.py 4 Dec 2001 20:39:36 -0000 1.2 --- reswords.py 18 Jul 2004 06:25:15 -0000 1.3 *************** *** 12,23 **** nrows = (nwords + ncols - 1) / ncols for irow in range(nrows): ! for icol in range(ncols): ! i = irow + icol * nrows ! if 0 <= i < nwords: ! word = words[i] ! else: ! word = "" ! print "%-*s" % (colwidth, word), ! print main() --- 12,23 ---- nrows = (nwords + ncols - 1) / ncols for irow in range(nrows): ! for icol in range(ncols): ! i = irow + icol * nrows ! if 0 <= i < nwords: ! word = words[i] ! else: ! word = "" ! print "%-*s" % (colwidth, word), ! print main() From tim_one at users.sourceforge.net Sun Jul 18 08:25:17 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 08:25:22 2004 Subject: [Python-checkins] python/dist/src/Doc/lib caseless.py, 1.2, 1.3 email-dir.py, 1.2, 1.3 minidom-example.py, 1.2, 1.3 required_1.py, 1.1, 1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32520/lib Modified Files: caseless.py email-dir.py minidom-example.py required_1.py Log Message: Whitespace normalization, via reindent.py. Index: caseless.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/caseless.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** caseless.py 12 Feb 2004 17:35:05 -0000 1.2 --- caseless.py 18 Jul 2004 06:25:15 -0000 1.3 *************** *** 46,50 **** else: print "not ok: no conflict between -h and -H" ! parser.add_option("-f", "--file", dest="file") #print repr(parser.get_option("-f")) --- 46,50 ---- else: print "not ok: no conflict between -h and -H" ! parser.add_option("-f", "--file", dest="file") #print repr(parser.get_option("-f")) *************** *** 59,62 **** assert options.file == "bar", options.file print "ok: case insensitive short options work" - - --- 59,60 ---- Index: email-dir.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/email-dir.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** email-dir.py 21 Nov 2003 20:28:15 -0000 1.2 --- email-dir.py 18 Jul 2004 06:25:15 -0000 1.3 *************** *** 67,71 **** sender = args[0] recips = args[1:] ! # Create the enclosing (outer) message outer = MIMEMultipart() --- 67,71 ---- sender = args[0] recips = args[1:] ! # Create the enclosing (outer) message outer = MIMEMultipart() Index: minidom-example.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/minidom-example.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** minidom-example.py 26 Oct 2001 19:50:26 -0000 1.2 --- minidom-example.py 18 Jul 2004 06:25:15 -0000 1.3 *************** *** 36,40 **** def handleSlides(slides): for slide in slides: ! handleSlide(slide) def handleSlide(slide): --- 36,40 ---- def handleSlides(slides): for slide in slides: ! handleSlide(slide) def handleSlide(slide): Index: required_1.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/required_1.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** required_1.py 6 Jan 2003 16:51:36 -0000 1.1 --- required_1.py 18 Jul 2004 06:25:15 -0000 1.2 *************** *** 4,12 **** def check_required (self, opt): ! option = self.get_option(opt) ! # Assumes the option's 'default' is set to None! ! if getattr(self.values, option.dest) is None: ! self.error("%s option not supplied" % option) --- 4,12 ---- def check_required (self, opt): ! option = self.get_option(opt) ! # Assumes the option's 'default' is set to None! ! if getattr(self.values, option.dest) is None: ! self.error("%s option not supplied" % option) From tim_one at users.sourceforge.net Sun Jul 18 08:25:18 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 08:25:26 2004 Subject: [Python-checkins] python/dist/src/Doc/tools/sgmlconv latex2esis.py, 1.32, 1.33 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/tools/sgmlconv In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32520/tools/sgmlconv Modified Files: latex2esis.py Log Message: Whitespace normalization, via reindent.py. Index: latex2esis.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/tools/sgmlconv/latex2esis.py,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** latex2esis.py 12 Feb 2004 17:35:05 -0000 1.32 --- latex2esis.py 18 Jul 2004 06:25:15 -0000 1.33 *************** *** 12,16 **** The format of the table is largely undocumented; see the commented ! headers where the table is specified in main(). There is no provision to load an alternate table from an external file. """ --- 12,16 ---- The format of the table is largely undocumented; see the commented ! headers where the table is specified in main(). There is no provision to load an alternate table from an external file. """ From tim_one at users.sourceforge.net Sun Jul 18 08:25:18 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 08:25:27 2004 Subject: [Python-checkins] python/dist/src/Doc/tools custlib.py, 1.3, 1.4 keywords.py, 1.3, 1.4 prechm.py, 1.19, 1.20 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/tools In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32520/tools Modified Files: custlib.py keywords.py prechm.py Log Message: Whitespace normalization, via reindent.py. Index: custlib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/tools/custlib.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** custlib.py 16 Oct 2002 14:59:02 -0000 1.3 --- custlib.py 18 Jul 2004 06:25:15 -0000 1.4 *************** *** 11,19 **** for modname in sys.builtin_module_names: modules[modname] = modname ! for dir in sys.path: # Look for *.py files filelist = glob.glob(os.path.join(dir, '*.py')) ! for file in filelist: path, file = os.path.split(file) base, ext = os.path.splitext(file) --- 11,19 ---- for modname in sys.builtin_module_names: modules[modname] = modname ! for dir in sys.path: # Look for *.py files filelist = glob.glob(os.path.join(dir, '*.py')) ! for file in filelist: path, file = os.path.split(file) base, ext = os.path.splitext(file) *************** *** 21,28 **** # Look for shared library files ! filelist = (glob.glob(os.path.join(dir, '*.so')) + glob.glob(os.path.join(dir, '*.sl')) + glob.glob(os.path.join(dir, '*.o')) ) ! for file in filelist: path, file = os.path.split(file) base, ext = os.path.splitext(file) --- 21,28 ---- # Look for shared library files ! filelist = (glob.glob(os.path.join(dir, '*.so')) + glob.glob(os.path.join(dir, '*.sl')) + glob.glob(os.path.join(dir, '*.o')) ) ! for file in filelist: path, file = os.path.split(file) base, ext = os.path.splitext(file) *************** *** 55,59 **** # Write the boilerplate ! # XXX should be fancied up. print """\documentstyle[twoside,11pt,myformat]{report} \\title{Python Library Reference} --- 55,59 ---- # Write the boilerplate ! # XXX should be fancied up. print """\documentstyle[twoside,11pt,myformat]{report} \\title{Python Library Reference} *************** *** 70,77 **** {\\parskip = 0mm \\tableofcontents} \\pagebreak\\pagenumbering{arabic}""" ! ! for modname in mlist: print "\\input{lib%s}" % (modname,) ! # Write the end print """\\input{custlib.ind} % Index --- 70,77 ---- {\\parskip = 0mm \\tableofcontents} \\pagebreak\\pagenumbering{arabic}""" ! ! for modname in mlist: print "\\input{lib%s}" % (modname,) ! # Write the end print """\\input{custlib.ind} % Index Index: keywords.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/tools/keywords.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** keywords.py 16 Oct 2002 15:27:02 -0000 1.3 --- keywords.py 18 Jul 2004 06:25:15 -0000 1.4 *************** *** 5,19 **** l = [] try: ! while 1: ! l = l + raw_input().split() except EOFError: ! pass l.sort() for x in l[:]: ! while l.count(x) > 1: l.remove(x) ncols = 5 nrows = (len(l)+ncols-1)/ncols for i in range(nrows): ! for j in range(i, len(l), nrows): ! print l[j].ljust(10), ! print --- 5,19 ---- l = [] try: ! while 1: ! l = l + raw_input().split() except EOFError: ! pass l.sort() for x in l[:]: ! while l.count(x) > 1: l.remove(x) ncols = 5 nrows = (len(l)+ncols-1)/ncols for i in range(nrows): ! for j in range(i, len(l), nrows): ! print l[j].ljust(10), ! print Index: prechm.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/tools/prechm.py,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** prechm.py 18 Jun 2004 08:27:36 -0000 1.19 --- prechm.py 18 Jul 2004 06:25:15 -0000 1.20 *************** *** 439,444 **** def usage(): ! print usage_mode ! sys.exit(0) def do_it(args = None): --- 439,444 ---- def usage(): ! print usage_mode ! sys.exit(0) def do_it(args = None): From tim_one at users.sourceforge.net Sun Jul 18 08:25:37 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 08:25:40 2004 Subject: [Python-checkins] python/dist/src/PC testpy.py,1.2,1.3 Message-ID: Update of /cvsroot/python/python/dist/src/PC In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32578 Modified Files: testpy.py Log Message: Whitespace normalization, via reindent.py. Index: testpy.py =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/testpy.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** testpy.py 19 May 1997 14:16:12 -0000 1.2 --- testpy.py 18 Jul 2004 06:25:33 -0000 1.3 *************** *** 6,32 **** try: ! import string except: ! print """Could not import the standard "string" module. ! Please check your PYTHONPATH environment variable.""" ! sys.exit(1) try: ! import regex_syntax except: ! print """Could not import the standard "regex_syntax" module. If this is ! a PC, you should add the dos_8x3 directory to your PYTHONPATH.""" ! sys.exit(1) import os for dir in sys.path: ! file = os.path.join(dir, "string.py") ! if os.path.isfile(file): ! test = os.path.join(dir, "test") ! if os.path.isdir(test): ! # Add the "test" directory to PYTHONPATH. ! sys.path = sys.path + [test] ! import regrtest # Standard Python tester. regrtest.main() --- 6,32 ---- try: ! import string except: ! print """Could not import the standard "string" module. ! Please check your PYTHONPATH environment variable.""" ! sys.exit(1) try: ! import regex_syntax except: ! print """Could not import the standard "regex_syntax" module. If this is ! a PC, you should add the dos_8x3 directory to your PYTHONPATH.""" ! sys.exit(1) import os for dir in sys.path: ! file = os.path.join(dir, "string.py") ! if os.path.isfile(file): ! test = os.path.join(dir, "test") ! if os.path.isdir(test): ! # Add the "test" directory to PYTHONPATH. ! sys.path = sys.path + [test] ! import regrtest # Standard Python tester. regrtest.main() From tim_one at users.sourceforge.net Sun Jul 18 08:25:53 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 08:25:55 2004 Subject: [Python-checkins] python/dist/src/PCbuild build_ssl.py,1.2,1.3 Message-ID: Update of /cvsroot/python/python/dist/src/PCbuild In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32605 Modified Files: build_ssl.py Log Message: Whitespace normalization, via reindent.py. Index: build_ssl.py =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/build_ssl.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** build_ssl.py 3 Dec 2002 21:00:29 -0000 1.2 --- build_ssl.py 18 Jul 2004 06:25:50 -0000 1.3 *************** *** 119,123 **** # to exclude any "nmake" commands and then execute. tempname = "ms\\32all_py.bat" ! in_bat = open("ms\\32all.bat") temp_bat = open(tempname,"w") --- 119,123 ---- # to exclude any "nmake" commands and then execute. tempname = "ms\\32all_py.bat" ! in_bat = open("ms\\32all.bat") temp_bat = open(tempname,"w") From tim_one at users.sourceforge.net Sun Jul 18 08:27:15 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 08:27:18 2004 Subject: [Python-checkins] python/dist/src/PCbuild .cvsignore,1.4,1.5 Message-ID: Update of /cvsroot/python/python/dist/src/PCbuild In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32688 Modified Files: .cvsignore Log Message: Ignore input files for encoding tests (these aren't checked in). Index: .cvsignore =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/.cvsignore,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** .cvsignore 22 Apr 2004 17:11:49 -0000 1.4 --- .cvsignore 18 Jul 2004 06:27:12 -0000 1.5 *************** *** 14,15 **** --- 14,27 ---- *-temp-* *.suo + NormalizationTest-3.2.0.txt + JOHAB.TXT + EUC-KR.TXT + EUC-JP.TXT + EUC-JISX0213.TXT + EUC-CN.TXT + CP950.TXT + CP949.TXT + CP936.TXT + CP932.TXT + BIG5HKSCS.TXT + BIG5.TXT From tim_one at users.sourceforge.net Sun Jul 18 08:28:01 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 08:28:03 2004 Subject: [Python-checkins] python/dist/src/PCbuild .cvsignore,1.5,1.6 Message-ID: Update of /cvsroot/python/python/dist/src/PCbuild In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32766 Modified Files: .cvsignore Log Message: Ignore more encoding input files. Index: .cvsignore =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/.cvsignore,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** .cvsignore 18 Jul 2004 06:27:12 -0000 1.5 --- .cvsignore 18 Jul 2004 06:27:59 -0000 1.6 *************** *** 26,27 **** --- 26,29 ---- BIG5HKSCS.TXT BIG5.TXT + SHIFT_JISX0213.TXT + SHIFTJIS.TXT From tim_one at users.sourceforge.net Sun Jul 18 08:34:16 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 08:34:18 2004 Subject: [Python-checkins] python/dist/src/Lib/plat-atheos IN.py,1.2,1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/plat-atheos In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv949 Modified Files: IN.py Log Message: Repair bizarre generated Python. Index: IN.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-atheos/IN.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** IN.py 18 Jul 2004 06:14:44 -0000 1.2 --- IN.py 18 Jul 2004 06:34:13 -0000 1.3 *************** *** 942,944 **** def IN6_IS_ADDR_MC_ORGLOCAL(a): return \ ! def IN6_IS_ADDR_MC_GLOBAL(a): return \ --- 942,944 ---- def IN6_IS_ADDR_MC_ORGLOCAL(a): return \ ! def IN6_IS_ADDR_MC_GLOBAL(a): return From tim_one at users.sourceforge.net Sun Jul 18 08:35:23 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 08:35:27 2004 Subject: [Python-checkins] python/dist/src/Lib/plat-linux2 IN.py,1.6,1.7 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/plat-linux2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1054 Modified Files: IN.py Log Message: Repair bizarre generated Python. Index: IN.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-linux2/IN.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** IN.py 18 Jul 2004 06:14:45 -0000 1.6 --- IN.py 18 Jul 2004 06:35:21 -0000 1.7 *************** *** 613,615 **** def IN6_IS_ADDR_MC_ORGLOCAL(a): return \ ! def IN6_IS_ADDR_MC_GLOBAL(a): return \ --- 613,615 ---- def IN6_IS_ADDR_MC_ORGLOCAL(a): return \ ! def IN6_IS_ADDR_MC_GLOBAL(a): return From ForrestBarnet at mail-shot-response.co.uk Sun Jul 18 11:09:37 2004 From: ForrestBarnet at mail-shot-response.co.uk (Marion Zweig) Date: Sun Jul 18 10:09:07 2004 Subject: [Python-checkins] Software from Office XP downloadable INSTANTLY for under $50 Message-ID: An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-checkins/attachments/20040718/025dca3a/attachment.html From hyeshik at gmail.com Sun Jul 18 10:16:10 2004 From: hyeshik at gmail.com (Hye-Shik Chang) Date: Sun Jul 18 10:16:13 2004 Subject: [Python-checkins] python/dist/src/PC config.c,1.47,1.48 In-Reply-To: References: Message-ID: <4f0b69dc04071801161e931297@mail.gmail.com> On Sat, 17 Jul 2004 22:06:33 -0700, tim_one@users.sourceforge.net wrote: > Update of /cvsroot/python/python/dist/src/PC > In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23589/PC > > Modified Files: > config.c > Log Message: > Woo hoo! All the encoding tests pass on Windows (& I downloaded the > 14 input files needed to run all of them). > Thanks for fixing cjkcodecs to build in Windows again. I'll rearrange cjkcodecs.h to get rid of the problem you described, soon. :) Hye-Shik From perky at users.sourceforge.net Sun Jul 18 10:35:45 2004 From: perky at users.sourceforge.net (perky@users.sourceforge.net) Date: Sun Jul 18 10:35:48 2004 Subject: [Python-checkins] python/dist/src/Modules/cjkcodecs mappings_cns11643.h, 1.1, NONE Message-ID: Update of /cvsroot/python/python/dist/src/Modules/cjkcodecs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13587/Modules/cjkcodecs Removed Files: mappings_cns11643.h Log Message: Remove unused CNS-11643 mapping which shouldn't merged into main Python yet. --- mappings_cns11643.h DELETED --- From perky at users.sourceforge.net Sun Jul 18 10:45:18 2004 From: perky at users.sourceforge.net (perky@users.sourceforge.net) Date: Sun Jul 18 10:45:21 2004 Subject: [Python-checkins] python/dist/src/PCbuild pythoncore.vcproj, 1.13, 1.14 Message-ID: Update of /cvsroot/python/python/dist/src/PCbuild In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14539/PCbuild Modified Files: pythoncore.vcproj Log Message: cjkcodecs/mapdata_*.c are removed by the recent import CJKCodecs 1.1. Index: pythoncore.vcproj =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/pythoncore.vcproj,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** pythoncore.vcproj 18 Jul 2004 03:48:47 -0000 1.13 --- pythoncore.vcproj 18 Jul 2004 08:45:15 -0000 1.14 *************** *** 1,2412 **** ! ! ! ! [...4783 lines suppressed...] ! Name="Release|Win32"> ! ! ! ! ! ! ! ! ! ! From perky at users.sourceforge.net Sun Jul 18 10:53:22 2004 From: perky at users.sourceforge.net (perky@users.sourceforge.net) Date: Sun Jul 18 10:53:25 2004 Subject: [Python-checkins] python/dist/src/PCbuild pythoncore.vcproj, 1.14, 1.15 Message-ID: Update of /cvsroot/python/python/dist/src/PCbuild In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15414 Modified Files: pythoncore.vcproj Log Message: Oops -kb bit had been in my CVS/Entries. Converting it to plain text again. Sorry. Index: pythoncore.vcproj =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/pythoncore.vcproj,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** pythoncore.vcproj 18 Jul 2004 08:45:15 -0000 1.14 --- pythoncore.vcproj 18 Jul 2004 08:53:18 -0000 1.15 *************** *** 1,2400 **** ! ! ! ! [...4771 lines suppressed...] ! Name="Release|Win32"> ! ! ! ! ! ! ! ! ! ! From perky at users.sourceforge.net Sun Jul 18 17:02:47 2004 From: perky at users.sourceforge.net (perky@users.sourceforge.net) Date: Sun Jul 18 17:02:49 2004 Subject: [Python-checkins] python/dist/src/Modules/cjkcodecs cjkcodecs.h, 1.3, 1.4 Message-ID: Update of /cvsroot/python/python/dist/src/Modules/cjkcodecs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2497 Modified Files: cjkcodecs.h Log Message: Replace an extern magic to assigning declared pointer from array's. And unifdef(1) compatibility blocks. Index: cjkcodecs.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/cjkcodecs/cjkcodecs.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** cjkcodecs.h 18 Jul 2004 04:26:10 -0000 1.3 --- cjkcodecs.h 18 Jul 2004 15:02:45 -0000 1.4 *************** *** 58,69 **** }; ! /* There are really static, and (re)declared so later by the expansions ! * of the BEGIN_MAPPINGS_LIST and BEGIN_CODECS_LIST macros, but it's ! * not legal C to declare a static array of unknown size. It would be ! * better if the code were rearranged so as to not require declaration ! * of these names before the macros define them. ! */ ! extern const MultibyteCodec codec_list[]; ! extern const struct dbcs_map mapping_list[]; #define CODEC_INIT(encoding) \ --- 58,63 ---- }; ! static const MultibyteCodec *codec_list; ! static const struct dbcs_map *mapping_list; #define CODEC_INIT(encoding) \ *************** *** 202,212 **** #endif ! #define BEGIN_MAPPINGS_LIST static const struct dbcs_map mapping_list[] = { #define MAPPING_ENCONLY(enc) {#enc, (void*)enc##_encmap, NULL}, #define MAPPING_DECONLY(enc) {#enc, NULL, (void*)enc##_decmap}, #define MAPPING_ENCDEC(enc) {#enc, (void*)enc##_encmap, (void*)enc##_decmap}, ! #define END_MAPPINGS_LIST {"", NULL, NULL} }; ! #define BEGIN_CODECS_LIST static const MultibyteCodec codec_list[] = { #define _STATEFUL_METHODS(enc) \ enc##_encode, \ --- 196,209 ---- #endif ! #define BEGIN_MAPPINGS_LIST static const struct dbcs_map _mapping_list[] = { #define MAPPING_ENCONLY(enc) {#enc, (void*)enc##_encmap, NULL}, #define MAPPING_DECONLY(enc) {#enc, NULL, (void*)enc##_decmap}, #define MAPPING_ENCDEC(enc) {#enc, (void*)enc##_encmap, (void*)enc##_decmap}, ! #define END_MAPPINGS_LIST \ ! {"", NULL, NULL} }; \ ! static const struct dbcs_map *mapping_list = \ ! (const struct dbcs_map *)_mapping_list; ! #define BEGIN_CODECS_LIST static const MultibyteCodec _codec_list[] = { #define _STATEFUL_METHODS(enc) \ enc##_encode, \ *************** *** 232,236 **** _STATELESS_METHODS(enc) \ }, ! #define END_CODECS_LIST {"", NULL,} }; static PyObject * --- 229,236 ---- _STATELESS_METHODS(enc) \ }, ! #define END_CODECS_LIST \ ! {"", NULL,} }; \ ! static const MultibyteCodec *codec_list = \ ! (const MultibyteCodec *)_codec_list; static PyObject * *************** *** 255,264 **** const MultibyteCodec *codec; const char *enc; - #ifdef NO_METH_O - PyObject *args = encoding; - - if (!PyArg_ParseTuple(args, "O:getcodec", &encoding)) - return NULL; - #endif if (!PyString_Check(encoding)) { --- 255,258 ---- *************** *** 287,295 **** return NULL; - #if PY_VERSION_HEX >= 0x02020000 r = PyObject_CallFunctionObjArgs(cofunc, codecobj, NULL); - #else - r = PyObject_CallFunction(cofunc, "O", codecobj); - #endif Py_DECREF(codecobj); --- 281,285 ---- *************** *** 298,306 **** static struct PyMethodDef __methods[] = { - #ifndef NO_METH_O {"getcodec", (PyCFunction)getcodec, METH_O, ""}, - #else - {"getcodec", (PyCFunction)getcodec, METH_VARARGS, ""}, - #endif {NULL, NULL}, }; --- 288,292 ---- From perky at users.sourceforge.net Sun Jul 18 17:36:33 2004 From: perky at users.sourceforge.net (perky@users.sourceforge.net) Date: Sun Jul 18 17:36:37 2004 Subject: [Python-checkins] python/dist/src/PC/VC6 pythoncore.dsp,1.11,1.12 Message-ID: Update of /cvsroot/python/python/dist/src/PC/VC6 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8057/PC/VC6 Modified Files: pythoncore.dsp Log Message: Teach VC6 project file about the new cjkcodecs structure. Index: pythoncore.dsp =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/VC6/pythoncore.dsp,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** pythoncore.dsp 8 Jun 2004 20:32:58 -0000 1.11 --- pythoncore.dsp 18 Jul 2004 15:36:31 -0000 1.12 *************** *** 94,146 **** # Begin Source File - SOURCE=..\..\Modules\cjkcodecs\_big5.c - # End Source File - # Begin Source File - SOURCE=..\..\Modules\_bisectmodule.c # End Source File # Begin Source File ! SOURCE=..\..\Modules\_codecsmodule.c ! # End Source File ! # Begin Source File ! ! SOURCE=..\..\Modules\cjkcodecs\_cp932.c ! # End Source File ! # Begin Source File ! ! SOURCE=..\..\Modules\cjkcodecs\_cp949.c # End Source File # Begin Source File ! SOURCE=..\..\Modules\cjkcodecs\_cp950.c # End Source File # Begin Source File ! SOURCE=..\..\Modules\_csv.c # End Source File # Begin Source File ! SOURCE=..\..\Modules\cjkcodecs\_euc_jisx0213.c # End Source File # Begin Source File ! SOURCE=..\..\Modules\cjkcodecs\_euc_jp.c # End Source File # Begin Source File ! SOURCE=..\..\Modules\cjkcodecs\_euc_kr.c # End Source File # Begin Source File ! SOURCE=..\..\Modules\cjkcodecs\_gb18030.c # End Source File # Begin Source File ! SOURCE=..\..\Modules\cjkcodecs\_gb2312.c # End Source File # Begin Source File ! SOURCE=..\..\Modules\cjkcodecs\_gbk.c # End Source File # Begin Source File --- 94,134 ---- # Begin Source File SOURCE=..\..\Modules\_bisectmodule.c # End Source File # Begin Source File ! SOURCE=..\..\Modules\cjkcodecs\_codecs_cn.c # End Source File # Begin Source File ! SOURCE=..\..\Modules\cjkcodecs\_codecs_hk.c # End Source File # Begin Source File ! SOURCE=..\..\Modules\cjkcodecs\_codecs_iso2022.c # End Source File # Begin Source File ! SOURCE=..\..\Modules\cjkcodecs\_codecs_jp.c # End Source File # Begin Source File ! SOURCE=..\..\Modules\cjkcodecs\_codecs_kr.c # End Source File # Begin Source File ! SOURCE=..\..\Modules\cjkcodecs\_codecs_tw.c # End Source File # Begin Source File ! SOURCE=..\..\Modules\cjkcodecs\_codecs_unicode.c # End Source File # Begin Source File ! SOURCE=..\..\Modules\_codecsmodule.c # End Source File # Begin Source File ! SOURCE=..\..\Modules\_csv.c # End Source File # Begin Source File *************** *** 154,189 **** # Begin Source File - SOURCE=..\..\Modules\cjkcodecs\_hz.c - # End Source File - # Begin Source File - - SOURCE=..\..\Modules\cjkcodecs\_iso2022_jp.c - # End Source File - # Begin Source File - - SOURCE=..\..\Modules\cjkcodecs\_iso2022_jp_1.c - # End Source File - # Begin Source File - - SOURCE=..\..\Modules\cjkcodecs\_iso2022_jp_2.c - # End Source File - # Begin Source File - - SOURCE=..\..\Modules\cjkcodecs\_iso2022_jp_3.c - # End Source File - # Begin Source File - - SOURCE=..\..\Modules\cjkcodecs\_iso2022_jp_ext.c - # End Source File - # Begin Source File - - SOURCE=..\..\Modules\cjkcodecs\_iso2022_kr.c - # End Source File - # Begin Source File - - SOURCE=..\..\Modules\cjkcodecs\_johab.c - # End Source File - # Begin Source File - SOURCE=..\..\Modules\_localemodule.c # End Source File --- 142,145 ---- *************** *** 194,205 **** # Begin Source File - SOURCE=..\..\Modules\cjkcodecs\_shift_jis.c - # End Source File - # Begin Source File - - SOURCE=..\..\Modules\cjkcodecs\_shift_jisx0213.c - # End Source File - # Begin Source File - SOURCE=..\..\Modules\_sre.c # End Source File --- 150,153 ---- *************** *** 456,475 **** # Begin Source File - SOURCE=..\..\Modules\cjkcodecs\mapdata_ja_JP.c - # End Source File - # Begin Source File - - SOURCE=..\..\Modules\cjkcodecs\mapdata_ko_KR.c - # End Source File - # Begin Source File - - SOURCE=..\..\Modules\cjkcodecs\mapdata_zh_CN.c - # End Source File - # Begin Source File - - SOURCE=..\..\Modules\cjkcodecs\mapdata_zh_TW.c - # End Source File - # Begin Source File - SOURCE=..\..\Python\marshal.c # End Source File --- 404,407 ---- From tim_one at users.sourceforge.net Sun Jul 18 18:56:40 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 18:56:48 2004 Subject: [Python-checkins] python/dist/src/Demo/threads Generator.py, 1.1, 1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Demo/threads In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20201 Modified Files: Generator.py Log Message: Whitespace normalization. Had to break guido's lock on rev 1.1 to do this, but I'm sure it wasn't locked intentionally. Index: Generator.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/threads/Generator.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Generator.py 3 May 1994 14:15:01 -0000 1.1 --- Generator.py 18 Jul 2004 16:56:37 -0000 1.2 *************** *** 6,84 **** class Generator: ! # Constructor ! def __init__(self, func, args): ! self.getlock = thread.allocate_lock() ! self.putlock = thread.allocate_lock() ! self.getlock.acquire() ! self.putlock.acquire() ! self.func = func ! self.args = args ! self.done = 0 ! self.killed = 0 ! thread.start_new_thread(self._start, ()) ! # Internal routine ! def _start(self): ! try: ! self.putlock.acquire() ! if not self.killed: ! try: ! apply(self.func, (self,) + self.args) ! except Killed: ! pass ! finally: ! if not self.killed: ! self.done = 1 ! self.getlock.release() ! # Called by producer for each value; raise Killed if no more needed ! def put(self, value): ! if self.killed: ! raise TypeError, 'put() called on killed generator' ! self.value = value ! self.getlock.release() # Resume consumer thread ! self.putlock.acquire() # Wait for next get() call ! if self.killed: ! raise Killed ! # Called by producer to get next value; raise EOFError if no more ! def get(self): ! if self.killed: ! raise TypeError, 'get() called on killed generator' ! self.putlock.release() # Resume producer thread ! self.getlock.acquire() # Wait for value to appear ! if self.done: ! raise EOFError # Say there are no more values ! return self.value ! # Called by consumer if no more values wanted ! def kill(self): ! if self.killed: ! raise TypeError, 'kill() called on killed generator' ! self.killed = 1 ! self.putlock.release() ! # Clone constructor ! def clone(self): ! return Generator(self.func, self.args) def pi(g): ! k, a, b, a1, b1 = 2L, 4L, 1L, 12L, 4L ! while 1: ! # Next approximation ! p, q, k = k*k, 2L*k+1L, k+1L ! a, b, a1, b1 = a1, b1, p*a+q*a1, p*b+q*b1 ! # Print common digits ! d, d1 = a/b, a1/b1 ! while d == d1: ! g.put(int(d)) ! a, a1 = 10L*(a%b), 10L*(a1%b1) ! d, d1 = a/b, a1/b1 def test(): ! g = Generator(pi, ()) ! g.kill() ! g = Generator(pi, ()) ! for i in range(10): print g.get(), ! print ! h = g.clone() ! g.kill() ! while 1: ! print h.get(), test() --- 6,84 ---- class Generator: ! # Constructor ! def __init__(self, func, args): ! self.getlock = thread.allocate_lock() ! self.putlock = thread.allocate_lock() ! self.getlock.acquire() ! self.putlock.acquire() ! self.func = func ! self.args = args ! self.done = 0 ! self.killed = 0 ! thread.start_new_thread(self._start, ()) ! # Internal routine ! def _start(self): ! try: ! self.putlock.acquire() ! if not self.killed: ! try: ! apply(self.func, (self,) + self.args) ! except Killed: ! pass ! finally: ! if not self.killed: ! self.done = 1 ! self.getlock.release() ! # Called by producer for each value; raise Killed if no more needed ! def put(self, value): ! if self.killed: ! raise TypeError, 'put() called on killed generator' ! self.value = value ! self.getlock.release() # Resume consumer thread ! self.putlock.acquire() # Wait for next get() call ! if self.killed: ! raise Killed ! # Called by producer to get next value; raise EOFError if no more ! def get(self): ! if self.killed: ! raise TypeError, 'get() called on killed generator' ! self.putlock.release() # Resume producer thread ! self.getlock.acquire() # Wait for value to appear ! if self.done: ! raise EOFError # Say there are no more values ! return self.value ! # Called by consumer if no more values wanted ! def kill(self): ! if self.killed: ! raise TypeError, 'kill() called on killed generator' ! self.killed = 1 ! self.putlock.release() ! # Clone constructor ! def clone(self): ! return Generator(self.func, self.args) def pi(g): ! k, a, b, a1, b1 = 2L, 4L, 1L, 12L, 4L ! while 1: ! # Next approximation ! p, q, k = k*k, 2L*k+1L, k+1L ! a, b, a1, b1 = a1, b1, p*a+q*a1, p*b+q*b1 ! # Print common digits ! d, d1 = a/b, a1/b1 ! while d == d1: ! g.put(int(d)) ! a, a1 = 10L*(a%b), 10L*(a1%b1) ! d, d1 = a/b, a1/b1 def test(): ! g = Generator(pi, ()) ! g.kill() ! g = Generator(pi, ()) ! for i in range(10): print g.get(), ! print ! h = g.clone() ! g.kill() ! while 1: ! print h.get(), test() From tim_one at users.sourceforge.net Sun Jul 18 19:34:06 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 18 19:34:08 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_itertools.py, 1.30, 1.31 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25183/Lib/test Modified Files: test_itertools.py Log Message: test_sf_950057's gen1() used an assert statement, which caused the test to fail when running with -O. Changed to raise AssertionError instead. Index: test_itertools.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_itertools.py,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** test_itertools.py 8 May 2004 19:49:42 -0000 1.30 --- test_itertools.py 18 Jul 2004 17:34:03 -0000 1.31 *************** *** 653,657 **** yield 1 hist.append(1) ! assert False hist.append(2) --- 653,657 ---- yield 1 hist.append(1) ! raise AssertionError hist.append(2) From loewis at users.sourceforge.net Sun Jul 18 20:36:21 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun Jul 18 20:36:24 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_sax.py, 1.24.16.2, 1.24.16.3 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1908/Lib/test Modified Files: Tag: release23-maint test_sax.py Log Message: Remove test for #919008. Users may have old PyXML versions installed, in which case the test will fail. For the mainline, the test should stay, and the minimum required PyXML version needs to be raised. Index: test_sax.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_sax.py,v retrieving revision 1.24.16.2 retrieving revision 1.24.16.3 diff -C2 -d -r1.24.16.2 -r1.24.16.3 *** test_sax.py 1 Jun 2004 12:58:18 -0000 1.24.16.2 --- test_sax.py 18 Jul 2004 18:36:18 -0000 1.24.16.3 *************** *** 490,528 **** return 0 - def test_sax_parse_exception_str(): - # pass various values from a locator to the SAXParseException to - # make sure that the __str__() doesn't fall apart when None is - # passed instead of an integer line and column number - # - # use "normal" values for the locator: - str(SAXParseException("message", None, - DummyLocator(1, 1))) - # use None for the line number: - str(SAXParseException("message", None, - DummyLocator(None, 1))) - # use None for the column number: - str(SAXParseException("message", None, - DummyLocator(1, None))) - # use None for both: - str(SAXParseException("message", None, - DummyLocator(None, None))) - return 1 - - class DummyLocator: - def __init__(self, lineno, colno): - self._lineno = lineno - self._colno = colno - - def getPublicId(self): - return "pubid" - - def getSystemId(self): - return "sysid" - - def getLineNumber(self): - return self._lineno - - def getColumnNumber(self): - return self._colno # =========================================================================== --- 490,493 ---- From akuchling at users.sourceforge.net Mon Jul 19 01:45:01 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Mon Jul 19 01:45:08 2004 Subject: [Python-checkins] python/dist/src/Lib FCNTL.py,1.1,NONE Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20045 Removed Files: FCNTL.py Log Message: Remove FCNTL.py, following python-dev discussion --- FCNTL.py DELETED --- From tim_one at users.sourceforge.net Mon Jul 19 01:58:19 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Mon Jul 19 01:58:22 2004 Subject: [Python-checkins] python/dist/src/Lib tempfile.py,1.59,1.60 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21386/Lib Modified Files: tempfile.py Log Message: Record that FCNTL.py has gone away; remove FCNTL hack in tempfile.py; another hack remains in test___all__.py, but the problem that one addresses is more general than *just* FCNTL, so leaving it alone. Index: tempfile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/tempfile.py,v retrieving revision 1.59 retrieving revision 1.60 diff -C2 -d -r1.59 -r1.60 *** tempfile.py 10 Nov 2003 02:16:36 -0000 1.59 --- tempfile.py 18 Jul 2004 23:58:16 -0000 1.60 *************** *** 39,53 **** try: import fcntl as _fcntl ! # If PYTHONCASEOK is set on Windows, stinking FCNTL.py gets ! # imported, and we don't get an ImportError then. Provoke ! # an AttributeError instead in that case. ! _fcntl.fcntl ! except (ImportError, AttributeError): def _set_cloexec(fd): pass else: def _set_cloexec(fd): ! try: flags = _fcntl.fcntl(fd, _fcntl.F_GETFD, 0) ! except IOError: pass else: # flags read successfully, modify --- 39,51 ---- try: import fcntl as _fcntl ! except ImportError: def _set_cloexec(fd): pass else: def _set_cloexec(fd): ! try: ! flags = _fcntl.fcntl(fd, _fcntl.F_GETFD, 0) ! except IOError: ! pass else: # flags read successfully, modify From tim_one at users.sourceforge.net Mon Jul 19 01:58:20 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Mon Jul 19 01:58:25 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1043,1.1044 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21386/Misc Modified Files: NEWS Log Message: Record that FCNTL.py has gone away; remove FCNTL hack in tempfile.py; another hack remains in test___all__.py, but the problem that one addresses is more general than *just* FCNTL, so leaving it alone. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1043 retrieving revision 1.1044 diff -C2 -d -r1.1043 -r1.1044 *** NEWS 18 Jul 2004 03:06:26 -0000 1.1043 --- NEWS 18 Jul 2004 23:58:17 -0000 1.1044 *************** *** 35,38 **** --- 35,43 ---- ------- + - The obsolete FCNTL.py has been deleted. The builtin fcntl module + has been available (on platforms that support fcntl) since Python + 1.5a3, and all FCNTL.py did is export fcntl's names, after generating + a deprecation warning telling you to use fcntl directly. + - Several new unicode codecs are added: big5hkscs, euc_jis_2004, iso2022_jp_2004, shift_jis_2004. From nnorwitz at users.sourceforge.net Mon Jul 19 02:09:01 2004 From: nnorwitz at users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Mon Jul 19 02:09:03 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_gettext.py, 1.16, 1.17 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23043/Lib/test Modified Files: test_gettext.py Log Message: Don't try to create the directory if it already exists, otherwise the test fails Index: test_gettext.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_gettext.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** test_gettext.py 20 May 2003 17:28:54 -0000 1.16 --- test_gettext.py 19 Jul 2004 00:08:59 -0000 1.17 *************** *** 67,71 **** class GettextBaseTest(unittest.TestCase): def setUp(self): ! os.makedirs(LOCALEDIR) fp = open(MOFILE, 'wb') fp.write(base64.decodestring(GNU_MO_DATA)) --- 67,72 ---- class GettextBaseTest(unittest.TestCase): def setUp(self): ! if not os.path.isdir(LOCALEDIR): ! os.makedirs(LOCALEDIR) fp = open(MOFILE, 'wb') fp.write(base64.decodestring(GNU_MO_DATA)) From rhettinger at users.sourceforge.net Mon Jul 19 02:10:27 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Mon Jul 19 02:10:29 2004 Subject: [Python-checkins] python/dist/src/Modules collectionsmodule.c, 1.21, 1.22 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23276 Modified Files: collectionsmodule.c Log Message: Silence a GCC unused variable warning in debug builds. Index: collectionsmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/collectionsmodule.c,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** collectionsmodule.c 15 Jul 2004 21:32:18 -0000 1.21 --- collectionsmodule.c 19 Jul 2004 00:10:24 -0000 1.22 *************** *** 451,456 **** PyObject_ClearWeakRefs((PyObject *) deque); if (deque->leftblock != NULL) { ! int err = deque_clear(deque); ! assert(err == 0); assert(deque->leftblock != NULL); PyMem_Free(deque->leftblock); --- 451,455 ---- PyObject_ClearWeakRefs((PyObject *) deque); if (deque->leftblock != NULL) { ! deque_clear(deque); assert(deque->leftblock != NULL); PyMem_Free(deque->leftblock); From nnorwitz at users.sourceforge.net Mon Jul 19 03:39:56 2004 From: nnorwitz at users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Mon Jul 19 03:40:00 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libos.tex,1.138,1.139 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2708/lib Modified Files: libos.tex Log Message: Get doc to build (add missing backslash) Index: libos.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libos.tex,v retrieving revision 1.138 retrieving revision 1.139 diff -C2 -d -r1.138 -r1.139 *** libos.tex 15 Jul 2004 05:46:37 -0000 1.138 --- libos.tex 19 Jul 2004 01:39:54 -0000 1.139 *************** *** 596,600 **** \end{datadesc} ! begin{datadesc}{O_DSYNC} \dataline{O_RSYNC} \dataline{O_SYNC} --- 596,600 ---- \end{datadesc} ! \begin{datadesc}{O_DSYNC} \dataline{O_RSYNC} \dataline{O_SYNC} From perky at users.sourceforge.net Mon Jul 19 08:39:40 2004 From: perky at users.sourceforge.net (perky@users.sourceforge.net) Date: Mon Jul 19 08:39:43 2004 Subject: [Python-checkins] python/dist/src/Lib/test regrtest.py,1.154,1.155 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1905 Modified Files: regrtest.py Log Message: test_codecmaps_hk is also expected to be skipped when a mapping file isn't available. (Spotted by Raymond Hettinger) Index: regrtest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/regrtest.py,v retrieving revision 1.154 retrieving revision 1.155 diff -C2 -d -r1.154 -r1.155 *** regrtest.py 1 Jul 2004 11:01:31 -0000 1.154 --- regrtest.py 19 Jul 2004 06:39:37 -0000 1.155 *************** *** 989,992 **** --- 989,993 ---- from test import test_codecmaps_cn, test_codecmaps_jp from test import test_codecmaps_kr, test_codecmaps_tw + from test import test_codecmaps_hk self.valid = False *************** *** 1007,1011 **** self.expected.add('test_timeout') ! for cc in ('cn', 'jp', 'kr', 'tw'): if eval('test_codecmaps_' + cc).skip_expected: self.expected.add('test_codecmaps_' + cc) --- 1008,1012 ---- self.expected.add('test_timeout') ! for cc in ('cn', 'jp', 'kr', 'tw', 'hk'): if eval('test_codecmaps_' + cc).skip_expected: self.expected.add('test_codecmaps_' + cc) From theller at users.sourceforge.net Mon Jul 19 11:45:49 2004 From: theller at users.sourceforge.net (theller@users.sourceforge.net) Date: Mon Jul 19 11:45:52 2004 Subject: [Python-checkins] python/dist/src/Lib/distutils/command bdist_wininst.py, 1.50, 1.51 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils/command In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28757 Modified Files: bdist_wininst.py Log Message: The binary layout of cfgdata has changed, so the magic number has to change as well. Add a comment explaining this. Index: bdist_wininst.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/bdist_wininst.py,v retrieving revision 1.50 retrieving revision 1.51 diff -C2 -d -r1.50 -r1.51 *** bdist_wininst.py 18 Jul 2004 06:14:42 -0000 1.50 --- bdist_wininst.py 19 Jul 2004 09:45:46 -0000 1.51 *************** *** 254,259 **** cfgdata = cfgdata + "\0" file.write(cfgdata) header = struct.pack(" Update of /cvsroot/python/python/dist/src/PC/bdist_wininst In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30434 Modified Files: install.c Log Message: The binary layout of cfgdata has changed, so the magic number has to change as well. Display an additional message box when a mismatch is detected. Index: install.c =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/bdist_wininst/install.c,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** install.c 14 Jul 2004 15:17:04 -0000 1.9 --- install.c 19 Jul 2004 09:57:58 -0000 1.10 *************** *** 956,960 **** } ! if (pmd->tag != 0x1234567A || ofs < 0) { return FALSE; } --- 956,964 ---- } ! if (pmd->tag != 0x1234567B) { ! return SystemError(0, ! "Invalid cfgdata magic number (see bdist_wininst.py)"); ! } ! if (ofs < 0) { return FALSE; } From theller at users.sourceforge.net Mon Jul 19 12:07:31 2004 From: theller at users.sourceforge.net (theller@users.sourceforge.net) Date: Mon Jul 19 12:07:33 2004 Subject: [Python-checkins] python/dist/src/Lib/distutils/command wininst-7.1.exe, 1.4, 1.5 wininst-6.exe, 1.4, 1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils/command In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31859 Modified Files: wininst-7.1.exe wininst-6.exe Log Message: The binary layout of cfgdata has changed, so the magic number has to change as well. Recompiled binaries after this change. Index: wininst-7.1.exe =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/wininst-7.1.exe,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 Binary files /tmp/cvsDz0jtv and /tmp/cvsDfMziA differ Index: wininst-6.exe =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/wininst-6.exe,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 Binary files /tmp/cvs2Y3APD and /tmp/cvsSck2II differ From nascheme at users.sourceforge.net Mon Jul 19 17:37:26 2004 From: nascheme at users.sourceforge.net (nascheme@users.sourceforge.net) Date: Mon Jul 19 17:37:30 2004 Subject: [Python-checkins] python/dist/src/Lib cgi.py,1.78,1.79 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19298/Lib Modified Files: cgi.py Log Message: Don't return spurious empty fields if 'keep_empty_values' is True. Fixes SF bug #990307. Index: cgi.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/cgi.py,v retrieving revision 1.78 retrieving revision 1.79 diff -C2 -d -r1.78 -r1.79 *** cgi.py 21 Mar 2004 22:16:15 -0000 1.78 --- cgi.py 19 Jul 2004 15:37:24 -0000 1.79 *************** *** 210,213 **** --- 210,215 ---- r = [] for name_value in pairs: + if not name_value and not strict_parsing: + continue nv = name_value.split('=', 1) if len(nv) != 2: From nascheme at users.sourceforge.net Mon Jul 19 17:37:42 2004 From: nascheme at users.sourceforge.net (nascheme@users.sourceforge.net) Date: Mon Jul 19 17:37:46 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_cgi.py,1.7,1.8 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19325/Lib/test Modified Files: test_cgi.py Log Message: Don't return spurious empty fields if 'keep_empty_values' is True. Fixes SF bug #990307. Index: test_cgi.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_cgi.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** test_cgi.py 30 Jul 2002 23:26:01 -0000 1.7 --- test_cgi.py 19 Jul 2004 15:37:40 -0000 1.8 *************** *** 56,60 **** # a string with the query and a dictionary with the expected result. ! parse_test_cases = [ ("", ValueError("bad query field: ''")), ("&", ValueError("bad query field: ''")), --- 56,74 ---- # a string with the query and a dictionary with the expected result. ! parse_qsl_test_cases = [ ! ("", []), ! ("&", []), ! ("&&", []), ! ("=", [('', '')]), ! ("=a", [('', 'a')]), ! ("a", [('a', '')]), ! ("a=", [('a', '')]), ! ("a=", [('a', '')]), ! ("&a=b", [('a', 'b')]), ! ("a=a+b&b=b+c", [('a', 'a b'), ('b', 'b c')]), ! ("a=1&a=2", [('a', '1'), ('a', '2')]), ! ] ! ! parse_strict_test_cases = [ ("", ValueError("bad query field: ''")), ("&", ValueError("bad query field: ''")), *************** *** 115,119 **** def main(): ! for orig, expect in parse_test_cases: # Test basic parsing print repr(orig) --- 129,138 ---- def main(): ! for orig, expect in parse_qsl_test_cases: ! result = cgi.parse_qsl(orig, keep_blank_values=True) ! print repr(orig), '=>', result ! verify(result == expect, "Error parsing %s" % repr(orig)) ! ! for orig, expect in parse_strict_test_cases: # Test basic parsing print repr(orig) From nascheme at users.sourceforge.net Mon Jul 19 17:37:54 2004 From: nascheme at users.sourceforge.net (nascheme@users.sourceforge.net) Date: Mon Jul 19 17:37:57 2004 Subject: [Python-checkins] python/dist/src/Lib/test/output test_cgi,1.2,1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test/output In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19350/Lib/test/output Modified Files: test_cgi Log Message: Don't return spurious empty fields if 'keep_empty_values' is True. Fixes SF bug #990307. Index: test_cgi =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/output/test_cgi,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** test_cgi 15 Sep 2000 20:06:57 -0000 1.2 --- test_cgi 19 Jul 2004 15:37:52 -0000 1.3 *************** *** 1,3 **** --- 1,14 ---- test_cgi + '' => [] + '&' => [] + '&&' => [] + '=' => [('', '')] + '=a' => [('', 'a')] + 'a' => [('a', '')] + 'a=' => [('a', '')] + 'a=' => [('a', '')] + '&a=b' => [('a', 'b')] + 'a=a+b&b=b+c' => [('a', 'a b'), ('b', 'b c')] + 'a=1&a=2' => [('a', '1'), ('a', '2')] '' '&' From nascheme at users.sourceforge.net Mon Jul 19 17:38:14 2004 From: nascheme at users.sourceforge.net (nascheme@users.sourceforge.net) Date: Mon Jul 19 17:38:17 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1044,1.1045 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19447/Misc Modified Files: NEWS Log Message: Don't return spurious empty fields if 'keep_empty_values' is True. Fixes SF bug #990307. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1044 retrieving revision 1.1045 diff -C2 -d -r1.1044 -r1.1045 *** NEWS 18 Jul 2004 23:58:17 -0000 1.1044 --- NEWS 19 Jul 2004 15:38:11 -0000 1.1045 *************** *** 95,98 **** --- 95,102 ---- that provide thread-local data. + - Bug #990307: when keep_empty_values is True, cgi.parse_qsl() + no longer returns spurious empty fields. + + Tools/Demos ----------- From nascheme at users.sourceforge.net Mon Jul 19 18:29:18 2004 From: nascheme at users.sourceforge.net (nascheme@users.sourceforge.net) Date: Mon Jul 19 18:29:21 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1045,1.1046 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28866/Misc Modified Files: NEWS Log Message: Check the type of values returned by __int__, __float__, __long__, __oct__, and __hex__. Raise TypeError if an invalid type is returned. Note that PyNumber_Int and PyNumber_Long can still return ints or longs. Fixes SF bug #966618. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1045 retrieving revision 1.1046 diff -C2 -d -r1.1045 -r1.1046 *** NEWS 19 Jul 2004 15:38:11 -0000 1.1045 --- NEWS 19 Jul 2004 16:29:16 -0000 1.1046 *************** *** 29,32 **** --- 29,37 ---- - Compiler now treats None as a constant. + - The type of values returned by __int__, __float__, __long__, + __oct__, and __hex__ are now checked. Returning an invalid type + will cause a TypeError to be raised. This matches the behavior of + Jython. + Extension modules ----------------- From nascheme at users.sourceforge.net Mon Jul 19 18:29:20 2004 From: nascheme at users.sourceforge.net (nascheme@users.sourceforge.net) Date: Mon Jul 19 18:29:24 2004 Subject: [Python-checkins] python/dist/src/Python bltinmodule.c,2.312,2.313 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28866/Python Modified Files: bltinmodule.c Log Message: Check the type of values returned by __int__, __float__, __long__, __oct__, and __hex__. Raise TypeError if an invalid type is returned. Note that PyNumber_Int and PyNumber_Long can still return ints or longs. Fixes SF bug #966618. Index: bltinmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/bltinmodule.c,v retrieving revision 2.312 retrieving revision 2.313 diff -C2 -d -r2.312 -r2.313 *** bltinmodule.c 7 Jul 2004 17:44:11 -0000 2.312 --- bltinmodule.c 19 Jul 2004 16:29:17 -0000 2.313 *************** *** 963,966 **** --- 963,967 ---- { PyNumberMethods *nb; + PyObject *res; if ((nb = v->ob_type->tp_as_number) == NULL || *************** *** 970,974 **** return NULL; } ! return (*nb->nb_hex)(v); } --- 971,983 ---- return NULL; } ! res = (*nb->nb_hex)(v); ! if (res && !PyString_Check(res)) { ! PyErr_Format(PyExc_TypeError, ! "__hex__ returned non-string (type %.200s)", ! res->ob_type->tp_name); ! Py_DECREF(res); ! return NULL; ! } ! return res; } *************** *** 1179,1182 **** --- 1188,1192 ---- { PyNumberMethods *nb; + PyObject *res; if (v == NULL || (nb = v->ob_type->tp_as_number) == NULL || *************** *** 1186,1190 **** return NULL; } ! return (*nb->nb_oct)(v); } --- 1196,1208 ---- return NULL; } ! res = (*nb->nb_oct)(v); ! if (res && !PyString_Check(res)) { ! PyErr_Format(PyExc_TypeError, ! "__oct__ returned non-string (type %.200s)", ! res->ob_type->tp_name); ! Py_DECREF(res); ! return NULL; ! } ! return res; } From nascheme at users.sourceforge.net Mon Jul 19 18:29:19 2004 From: nascheme at users.sourceforge.net (nascheme@users.sourceforge.net) Date: Mon Jul 19 18:29:25 2004 Subject: [Python-checkins] python/dist/src/Objects abstract.c, 2.130, 2.131 intobject.c, 2.111, 2.112 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28866/Objects Modified Files: abstract.c intobject.c Log Message: Check the type of values returned by __int__, __float__, __long__, __oct__, and __hex__. Raise TypeError if an invalid type is returned. Note that PyNumber_Int and PyNumber_Long can still return ints or longs. Fixes SF bug #966618. Index: abstract.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/abstract.c,v retrieving revision 2.130 retrieving revision 2.131 diff -C2 -d -r2.130 -r2.131 *** abstract.c 12 May 2004 21:35:06 -0000 2.130 --- abstract.c 19 Jul 2004 16:29:16 -0000 2.131 *************** *** 966,971 **** #endif m = o->ob_type->tp_as_number; ! if (m && m->nb_int) ! return m->nb_int(o); if (!PyObject_AsCharBuffer(o, &buffer, &buffer_len)) return int_from_string((char*)buffer, buffer_len); --- 966,980 ---- #endif m = o->ob_type->tp_as_number; ! if (m && m->nb_int) { ! PyObject *res = m->nb_int(o); ! if (res && (!PyInt_Check(res) && !PyLong_Check(res))) { ! PyErr_Format(PyExc_TypeError, ! "__int__ returned non-int (type %.200s)", ! res->ob_type->tp_name); ! Py_DECREF(res); ! return NULL; ! } ! return res; ! } if (!PyObject_AsCharBuffer(o, &buffer, &buffer_len)) return int_from_string((char*)buffer, buffer_len); *************** *** 1023,1028 **** #endif m = o->ob_type->tp_as_number; ! if (m && m->nb_long) ! return m->nb_long(o); if (!PyObject_AsCharBuffer(o, &buffer, &buffer_len)) return long_from_string(buffer, buffer_len); --- 1032,1046 ---- #endif m = o->ob_type->tp_as_number; ! if (m && m->nb_long) { ! PyObject *res = m->nb_long(o); ! if (res && (!PyInt_Check(res) && !PyLong_Check(res))) { ! PyErr_Format(PyExc_TypeError, ! "__long__ returned non-long (type %.200s)", ! res->ob_type->tp_name); ! Py_DECREF(res); ! return NULL; ! } ! return res; ! } if (!PyObject_AsCharBuffer(o, &buffer, &buffer_len)) return long_from_string(buffer, buffer_len); *************** *** 1048,1053 **** if (!PyString_Check(o)) { m = o->ob_type->tp_as_number; ! if (m && m->nb_float) ! return m->nb_float(o); } return PyFloat_FromString(o, NULL); --- 1066,1080 ---- if (!PyString_Check(o)) { m = o->ob_type->tp_as_number; ! if (m && m->nb_float) { ! PyObject *res = m->nb_float(o); ! if (res && !PyFloat_Check(res)) { ! PyErr_Format(PyExc_TypeError, ! "__float__ returned non-float (type %.200s)", ! res->ob_type->tp_name); ! Py_DECREF(res); ! return NULL; ! } ! return res; ! } } return PyFloat_FromString(o, NULL); Index: intobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/intobject.c,v retrieving revision 2.111 retrieving revision 2.112 diff -C2 -d -r2.111 -r2.112 *** intobject.c 26 Jun 2004 23:22:57 -0000 2.111 --- intobject.c 19 Jul 2004 16:29:16 -0000 2.112 *************** *** 949,958 **** return NULL; if (!PyInt_Check(tmp)) { - if (!PyLong_Check(tmp)) { - PyErr_SetString(PyExc_ValueError, - "value can't be converted to int"); - Py_DECREF(tmp); - return NULL; - } ival = PyLong_AsLong(tmp); if (ival == -1 && PyErr_Occurred()) { --- 949,952 ---- From nascheme at users.sourceforge.net Mon Jul 19 18:29:18 2004 From: nascheme at users.sourceforge.net (nascheme@users.sourceforge.net) Date: Mon Jul 19 18:29:27 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_class.py,1.11,1.12 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28866/Lib/test Modified Files: test_class.py Log Message: Check the type of values returned by __int__, __float__, __long__, __oct__, and __hex__. Raise TypeError if an invalid type is returned. Note that PyNumber_Int and PyNumber_Long can still return ints or longs. Fixes SF bug #966618. Index: test_class.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_class.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** test_class.py 20 Oct 2003 14:01:51 -0000 1.11 --- test_class.py 19 Jul 2004 16:29:15 -0000 1.12 *************** *** 44,52 **** "pos", "abs", - "int", - "long", - "float", - "oct", - "hex", # generic operations --- 44,47 ---- *************** *** 59,62 **** --- 54,62 ---- # "str", # "repr", + # "int", + # "long", + # "float", + # "oct", + # "hex", # These are separate because they can influence the test of other methods. *************** *** 82,85 **** --- 82,105 ---- return "AllTests" + def __int__(self, *args): + print "__int__:", args + return 1 + + def __float__(self, *args): + print "__float__:", args + return 1.0 + + def __long__(self, *args): + print "__long__:", args + return 1L + + def __oct__(self, *args): + print "__oct__:", args + return '01' + + def __hex__(self, *args): + print "__hex__:", args + return '0x1' + def __cmp__(self, *args): print "__cmp__:", args *************** *** 196,214 **** +testme abs(testme) ! if sys.platform[:4] != 'java': ! int(testme) ! long(testme) ! float(testme) ! oct(testme) ! hex(testme) ! else: ! # Jython enforced that these methods return ! # a value of the expected type. ! print "__int__: ()" ! print "__long__: ()" ! print "__float__: ()" ! print "__oct__: ()" ! print "__hex__: ()" ! # And the rest... --- 216,224 ---- +testme abs(testme) ! int(testme) ! long(testme) ! float(testme) ! oct(testme) ! hex(testme) # And the rest... *************** *** 255,258 **** --- 265,316 ---- + # return values of some method are type-checked + class BadTypeClass: + def __int__(self): + return None + __float__ = __int__ + __long__ = __int__ + __str__ = __int__ + __repr__ = __int__ + __oct__ = __int__ + __hex__ = __int__ + + def check_exc(stmt, exception): + """Raise TestFailed if executing 'stmt' does not raise 'exception' + """ + try: + exec stmt + except exception: + pass + else: + raise TestFailed, "%s should raise %s" % (stmt, exception) + + check_exc("int(BadTypeClass())", TypeError) + check_exc("float(BadTypeClass())", TypeError) + check_exc("long(BadTypeClass())", TypeError) + check_exc("str(BadTypeClass())", TypeError) + check_exc("repr(BadTypeClass())", TypeError) + check_exc("oct(BadTypeClass())", TypeError) + check_exc("hex(BadTypeClass())", TypeError) + + # mixing up ints and longs is okay + class IntLongMixClass: + def __int__(self): + return 0L + + def __long__(self): + return 0 + + try: + int(IntLongMixClass()) + except TypeError: + raise TestFailed, "TypeError should not be raised" + + try: + long(IntLongMixClass()) + except TypeError: + raise TestFailed, "TypeError should not be raised" + + # Test correct errors from hash() on objects with comparisons but no __hash__ *************** *** 265,279 **** def __cmp__(self, other): return 0 ! try: hash(C1()) ! except TypeError: pass ! else: raise TestFailed, "hash(C1()) should raise an exception" class C2: def __eq__(self, other): return 1 ! try: hash(C2()) ! except TypeError: pass ! else: raise TestFailed, "hash(C2()) should raise an exception" ! # Test for SF bug 532646 --- 323,332 ---- def __cmp__(self, other): return 0 ! check_exc("hash(C1())", TypeError) class C2: def __eq__(self, other): return 1 ! check_exc("hash(C2())", TypeError) # Test for SF bug 532646 From loewis at users.sourceforge.net Mon Jul 19 18:33:30 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Mon Jul 19 18:33:33 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libstring.tex, 1.52.8.1, 1.52.8.2 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30198 Modified Files: Tag: release23-maint libstring.tex Log Message: Patch #993187: Make rstrip doc similar to lstrip. Index: libstring.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libstring.tex,v retrieving revision 1.52.8.1 retrieving revision 1.52.8.2 diff -C2 -d -r1.52.8.1 -r1.52.8.2 *** libstring.tex 18 Nov 2003 19:48:41 -0000 1.52.8.1 --- libstring.tex 19 Jul 2004 16:33:27 -0000 1.52.8.2 *************** *** 255,259 **** string this method is called on. \versionchanged[The \var{chars} parameter was added. The \var{chars} ! parameter cannot be passed in 2.2 versions]{2.2.3} \end{funcdesc} --- 255,259 ---- string this method is called on. \versionchanged[The \var{chars} parameter was added. The \var{chars} ! parameter cannot be passed in earlier 2.2 versions]{2.2.3} \end{funcdesc} From loewis at users.sourceforge.net Mon Jul 19 18:34:04 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Mon Jul 19 18:34:07 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libstring.tex,1.57,1.58 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30565 Modified Files: libstring.tex Log Message: Patch #993187: Make rstrip doc similar to lstrip. Backported to 2.3. Index: libstring.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libstring.tex,v retrieving revision 1.57 retrieving revision 1.58 diff -C2 -d -r1.57 -r1.58 *** libstring.tex 21 Mar 2004 16:59:59 -0000 1.57 --- libstring.tex 19 Jul 2004 16:34:01 -0000 1.58 *************** *** 272,276 **** string this method is called on. \versionchanged[The \var{chars} parameter was added. The \var{chars} ! parameter cannot be passed in 2.2 versions]{2.2.3} \end{funcdesc} --- 272,276 ---- string this method is called on. \versionchanged[The \var{chars} parameter was added. The \var{chars} ! parameter cannot be passed in earlier 2.2 versions]{2.2.3} \end{funcdesc} From neal at metaslash.com Mon Jul 19 18:37:35 2004 From: neal at metaslash.com (Neal Norwitz) Date: Mon Jul 19 18:37:40 2004 Subject: [Python-checkins] python/dist/src/Python bltinmodule.c, 2.312, 2.313 In-Reply-To: References: Message-ID: <20040719163735.GE25168@epoch.metaslash.com> On Mon, Jul 19, 2004 at 09:29:20AM -0700, nascheme@users.sourceforge.net wrote: > ! res = (*nb->nb_hex)(v); > ! if (res && !PyString_Check(res)) { > ! PyErr_Format(PyExc_TypeError, > ! "__hex__ returned non-string (type %.200s)", > ! res->ob_type->tp_name); > ! Py_DECREF(res); > ! return NULL; > ! } > ! return res; Should hex/oct be allowed to return Unicode? Neal From mal at egenix.com Mon Jul 19 18:41:32 2004 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jul 19 18:41:38 2004 Subject: [Python-checkins] python/dist/src/Python bltinmodule.c, 2.312, 2.313 In-Reply-To: <20040719163735.GE25168@epoch.metaslash.com> References: <20040719163735.GE25168@epoch.metaslash.com> Message-ID: <40FBF9BC.1000506@egenix.com> Neal Norwitz wrote: > On Mon, Jul 19, 2004 at 09:29:20AM -0700, nascheme@users.sourceforge.net wrote: > > >>! res = (*nb->nb_hex)(v); >>! if (res && !PyString_Check(res)) { >>! PyErr_Format(PyExc_TypeError, >>! "__hex__ returned non-string (type %.200s)", >>! res->ob_type->tp_name); >>! Py_DECREF(res); >>! return NULL; >>! } >>! return res; > > Should hex/oct be allowed to return Unicode? -0 hex/oct values fit nicely into ASCII... unless you want to use more fancy code points for the numbers in there :-) -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jul 19 2004) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From loewis at users.sourceforge.net Mon Jul 19 18:42:22 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Mon Jul 19 18:42:25 2004 Subject: [Python-checkins] python/dist/src setup.py,1.193,1.194 Message-ID: Update of /cvsroot/python/python/dist/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31978 Modified Files: setup.py Log Message: Patch #993173: Enable audioop on 64-bit platforms. Index: setup.py =================================================================== RCS file: /cvsroot/python/python/dist/src/setup.py,v retrieving revision 1.193 retrieving revision 1.194 diff -C2 -d -r1.193 -r1.194 *** setup.py 18 Jul 2004 05:56:06 -0000 1.193 --- setup.py 19 Jul 2004 16:42:19 -0000 1.194 *************** *** 408,415 **** # These represent audio samples or images as strings: # Disabled on 64-bit platforms if sys.maxint != 9223372036854775807L: # Operations on audio samples - exts.append( Extension('audioop', ['audioop.c']) ) # Operations on images exts.append( Extension('imageop', ['imageop.c']) ) --- 408,418 ---- # These represent audio samples or images as strings: + # According to #993173, this one should actually work fine on + # 64-bit platforms. + exts.append( Extension('audioop', ['audioop.c']) ) + # Disabled on 64-bit platforms if sys.maxint != 9223372036854775807L: # Operations on audio samples # Operations on images exts.append( Extension('imageop', ['imageop.c']) ) From loewis at users.sourceforge.net Mon Jul 19 18:42:22 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Mon Jul 19 18:42:27 2004 Subject: [Python-checkins] python/dist/src/Modules Setup.dist,1.45,1.46 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31978/Modules Modified Files: Setup.dist Log Message: Patch #993173: Enable audioop on 64-bit platforms. Index: Setup.dist =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/Setup.dist,v retrieving revision 1.45 retrieving revision 1.46 diff -C2 -d -r1.45 -r1.46 *** Setup.dist 18 Jul 2004 03:06:27 -0000 1.45 --- Setup.dist 19 Jul 2004 16:42:20 -0000 1.46 *************** *** 224,227 **** --- 224,228 ---- # Multimedia modules -- off by default. # These don't work for 64-bit platforms!!! + # #993173 says audioop works on 64-bit platforms, though. # These represent audio samples or images as strings: From nnorwitz at users.sourceforge.net Mon Jul 19 18:55:10 2004 From: nnorwitz at users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Mon Jul 19 18:55:14 2004 Subject: [Python-checkins] python/dist/src setup.py,1.194,1.195 Message-ID: Update of /cvsroot/python/python/dist/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2231 Modified Files: setup.py Log Message: Move comment that goes along with audioop Index: setup.py =================================================================== RCS file: /cvsroot/python/python/dist/src/setup.py,v retrieving revision 1.194 retrieving revision 1.195 diff -C2 -d -r1.194 -r1.195 *** setup.py 19 Jul 2004 16:42:19 -0000 1.194 --- setup.py 19 Jul 2004 16:55:07 -0000 1.195 *************** *** 408,411 **** --- 408,412 ---- # These represent audio samples or images as strings: + # Operations on audio samples # According to #993173, this one should actually work fine on # 64-bit platforms. *************** *** 414,418 **** # Disabled on 64-bit platforms if sys.maxint != 9223372036854775807L: - # Operations on audio samples # Operations on images exts.append( Extension('imageop', ['imageop.c']) ) --- 415,418 ---- From loewis at users.sourceforge.net Mon Jul 19 19:01:36 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Mon Jul 19 19:01:39 2004 Subject: [Python-checkins] python/dist/src/Modules socketmodule.c, 1.295, 1.296 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3115/Modules Modified Files: socketmodule.c Log Message: Patch #984654: Add more address family constants. Index: socketmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/socketmodule.c,v retrieving revision 1.295 retrieving revision 1.296 diff -C2 -d -r1.295 -r1.296 *** socketmodule.c 10 Jul 2004 23:39:35 -0000 1.295 --- socketmodule.c 19 Jul 2004 17:01:20 -0000 1.296 *************** *** 3833,3836 **** --- 3833,3840 ---- PyModule_AddIntConstant(m, "AF_BRIDGE", AF_BRIDGE); #endif + #ifdef AF_ATMPVC + /* ATM PVCs */ + PyModule_AddIntConstant(m, "AF_ATMPVC", AF_ATMPVC); + #endif #ifdef AF_AAL5 /* Reserved for Werner's ATM */ *************** *** 3848,3851 **** --- 3852,3911 ---- PyModule_AddIntConstant(m, "AF_ROSE", AF_ROSE); #endif + #ifdef AF_DECnet + /* Reserved for DECnet project */ + PyModule_AddIntConstant(m, "AF_DECnet", AF_DECnet); + #endif + #ifdef AF_NETBEUI + /* Reserved for 802.2LLC project */ + PyModule_AddIntConstant(m, "AF_NETBEUI", AF_NETBEUI); + #endif + #ifdef AF_SECURITY + /* Security callback pseudo AF */ + PyModule_AddIntConstant(m, "AF_SECURITY", AF_SECURITY); + #endif + #ifdef AF_KEY + /* PF_KEY key management API */ + PyModule_AddIntConstant(m, "AF_KEY", AF_KEY); + #endif + #ifdef AF_NETLINK + /* */ + PyModule_AddIntConstant(m, "AF_NETLINK", AF_NETLINK); + #endif + #ifdef AF_ROUTE + /* Alias to emulate 4.4BSD */ + PyModule_AddIntConstant(m, "AF_ROUTE", AF_ROUTE); + #endif + #ifdef AF_ASH + /* Ash */ + PyModule_AddIntConstant(m, "AF_ASH", AF_ASH); + #endif + #ifdef AF_ECONET + /* Acorn Econet */ + PyModule_AddIntConstant(m, "AF_ECONET", AF_ECONET); + #endif + #ifdef AF_ATMSVC + /* ATM SVCs */ + PyModule_AddIntConstant(m, "AF_ATMSVC", AF_ATMSVC); + #endif + #ifdef AF_SNA + /* Linux SNA Project (nutters!) */ + PyModule_AddIntConstant(m, "AF_SNA", AF_SNA); + #endif + #ifdef AF_IRDA + /* IRDA sockets */ + PyModule_AddIntConstant(m, "AF_IRDA", AF_IRDA); + #endif + #ifdef AF_PPPOX + /* PPPoX sockets */ + PyModule_AddIntConstant(m, "AF_PPPOX", AF_PPPOX); + #endif + #ifdef AF_WANPIPE + /* Wanpipe API Sockets */ + PyModule_AddIntConstant(m, "AF_WANPIPE", AF_WANPIPE); + #endif + #ifdef AF_LLC + /* Linux LLC */ + PyModule_AddIntConstant(m, "AF_LLC", AF_LLC); + #endif #ifdef USE_BLUETOOTH From guido at python.org Mon Jul 19 19:19:24 2004 From: guido at python.org (Guido van Rossum) Date: Mon Jul 19 19:19:30 2004 Subject: [Python-Dev] Re: [Python-checkins] python/dist/src/Python bltinmodule.c, 2.312, 2.313 In-Reply-To: Your message of "Mon, 19 Jul 2004 12:37:35 EDT." <20040719163735.GE25168@epoch.metaslash.com> References: <20040719163735.GE25168@epoch.metaslash.com> Message-ID: <200407191719.i6JHJOk03240@guido.python.org> > On Mon, Jul 19, 2004 at 09:29:20AM -0700, nascheme@users.sourceforge.net wrote: > > > ! res = (*nb->nb_hex)(v); > > ! if (res && !PyString_Check(res)) { > > ! PyErr_Format(PyExc_TypeError, > > ! "__hex__ returned non-string (type %.200s)", > > ! res->ob_type->tp_name); > > ! Py_DECREF(res); > > ! return NULL; > > ! } > > ! return res; > > Should hex/oct be allowed to return Unicode? What would the point be? I don't know of any hexadecimal or octal digits that aren't ASCII. --Guido van Rossum (home page: http://www.python.org/~guido/) From neal at metaslash.com Mon Jul 19 19:39:28 2004 From: neal at metaslash.com (Neal Norwitz) Date: Mon Jul 19 19:39:39 2004 Subject: [Python-Dev] Re: [Python-checkins] python/dist/src/Python bltinmodule.c, 2.312, 2.313 In-Reply-To: <200407191719.i6JHJOk03240@guido.python.org> References: <20040719163735.GE25168@epoch.metaslash.com> <200407191719.i6JHJOk03240@guido.python.org> Message-ID: <20040719173928.GG25168@epoch.metaslash.com> On Mon, Jul 19, 2004 at 10:19:24AM -0700, Guido van Rossum wrote: > > > Should hex/oct be allowed to return Unicode? > > What would the point be? I don't know of any hexadecimal or octal > digits that aren't ASCII. I wasn't paying close enough attention. Originally, I was thinking about consistency, but on second thought I agree it's not worthwhile. Neal From goodger at users.sourceforge.net Mon Jul 19 20:09:00 2004 From: goodger at users.sourceforge.net (goodger@users.sourceforge.net) Date: Mon Jul 19 20:09:04 2004 Subject: [Python-checkins] python/nondist/peps pep-0331.txt, NONE, 1.1 pep-0000.txt, 1.274, 1.275 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15134 Modified Files: pep-0000.txt Added Files: pep-0331.txt Log Message: added PEP 331, Locale-Independent Float/String Conversions, by Christian R. Reis --- NEW FILE: pep-0331.txt --- PEP: 331 Title: Locale-Independent Float/String Conversions Version: $Revision: 1.1 $ Last-Modified: $Date: 2004/07/19 18:08:57 $ Author: Christian R. Reis Status: Draft Type: Standards Track Content-Type: text/plain Created: 19-Jul-2003 Python-Version: 2.4 Post-History: 21-Jul-2003, 13-Aug-2003, 18-Jun-2004 Abstract Support for the LC_NUMERIC locale category in Python 2.3 is implemented only in Python-space. This causes inconsistent behavior and thread-safety issues for applications that use extension modules and libraries implemented in C that parse and generate floats from strings. This document proposes a plan for removing this inconsistency by providing and using substitute locale-agnostic functions as necessary. Introduction Python provides generic localization services through the locale module, which among other things allows localizing the display and conversion process of numeric types. Locale categories, such as LC_TIME and LC_COLLATE, allow configuring precisely what aspects of the application are to be localized. The LC_NUMERIC category specifies formatting for non-monetary numeric information, such as the decimal separator in float and fixed-precision numbers. Localization of the LC_NUMERIC category is currently implemented only in Python-space; C libraries invoked from the Python runtime are unaware of Python's LC_NUMERIC setting. This is done to avoid changing the behavior of certain low-level functions that are used by the Python parser and related code [2]. However, this presents a problem for extension modules that wrap C libraries. Applications that use these extension modules will inconsistently display and convert floating-point values. James Henstridge, the author of PyGTK [3], has additionally pointed out that the setlocale() function also presents thread-safety issues, since a thread may call the C library setlocale() outside of the GIL, and cause Python to parse and generate floats incorrectly. Rationale The inconsistency between Python and C library localization for LC_NUMERIC is a problem for any localized application using C extensions. The exact nature of the problem will vary depending on the application, but it will most likely occur when parsing or formatting a floating-point value. Example Problem The initial problem that motivated this PEP is related to the GtkSpinButton [4] widget in the GTK+ UI toolkit, wrapped by the PyGTK module. The widget can be set to numeric mode, and when this occurs, characters typed into it are evaluated as a number. Problems occur when LC_NUMERIC is set to a locale with a float separator that differs from the C locale's standard (for instance, `,' instead of `.' for the Brazilian locale pt_BR). Because LC_NUMERIC is not set at the libc level, float values are displayed incorrectly (using `.' as a separator) in the spinbutton's text entry, and it is impossible to enter fractional values using the `,' separator. This small example demonstrates reduced usability for localized applications using this toolkit when coded in Python. Proposal Martin v. Löwis commented on the initial constraints for an acceptable solution to the problem on python-dev: - LC_NUMERIC can be set at the C library level without breaking the parser. - float() and str() stay locale-unaware. - locale-aware str() and atof() stay in the locale module. An analysis of the Python source suggests that the following functions currently depend on LC_NUMERIC being set to the C locale: - Python/compile.c:parsenumber() - Python/marshal.c:r_object() - Objects/complexobject.c:complex_to_buf() - Objects/complexobject.c:complex_subtype_from_string() - Objects/floatobject.c:PyFloat_FromString() - Objects/floatobject.c:format_float() - Objects/stringobject.c:formatfloat() - Modules/stropmodule.c:strop_atof() - Modules/cPickle.c:load_float() The proposed approach is to implement LC_NUMERIC-agnostic functions for converting from (strtod()/atof()) and to (snprintf()) float formats, using these functions where the formatting should not vary according to the user-specified locale. The locale module should also be changed to remove the special-casing for LC_NUMERIC. This change should also solve the aforementioned thread-safety problems. Potential Code Contributions This problem was initially reported as a problem in the GTK+ libraries [5]; since then it has been correctly diagnosed as an inconsistency in Python's implementation. However, in a fortunate coincidence, the glib library (developed primarily for GTK+, not to be confused with the GNU C library) implements a number of LC_NUMERIC-agnostic functions (for an example, see [6]) for reasons similar to those presented in this paper. In the same GTK+ problem report, Havoc Pennington suggested that the glib authors would be willing to contribute this code to the PSF, which would simplify implementation of this PEP considerably. Alex Larsson, the original author of the glib code, submitted a PSF Contributor Agreement [7] on 2003-08-20 [8] to ensure the code could be safely integrated. [XXX: was the agreement actually received and accepted?] Risks There may be cross-platform issues with the provided locale-agnostic functions, though this risk is low given that the code supplied simply reverses any locale-dependent changes made to floating-point numbers. Martin and Guido pointed out potential copyright issues with the contributed code. I believe we will have no problems in this area as members of the GTK+ and glib teams have said they are fine with relicensing the code, and a PSF contributor agreement has been mailed in to ensure this safety. Tim Peters has pointed out [9] that there are situations involving threading in which the proposed change is insufficient to solve the problem completely. A complete solution, however, does not currently exist. Implementation An implementation was developed by Gustavo Carneiro , and attached to Sourceforge.net bug 744665 [10] The final patch [11] was integrated into Python CVS by Martin v. Löwis on 2004-06-08, as stated in the bug report. References [1] PEP 1, PEP Purpose and Guidelines, Warsaw, Hylton http://www.python.org/peps/pep-0001.html [2] Python locale documentation for embedding, http://www.python.org/doc/current/lib/embedding-locale.html [3] PyGTK homepage, http://www.daa.com.au/~james/pygtk/ [4] GtkSpinButton screenshot (demonstrating problem), http://www.async.com.br/~kiko/spin.png [5] GNOME bug report, http://bugzilla.gnome.org/show_bug.cgi?id=114132 [6] Code submission of g_ascii_strtod and g_ascii_dtostr (later renamed g_ascii_formatd) by Alex Larsson, http://mail.gnome.org/archives/gtk-devel-list/2001-October/msg00114.html [7] PSF Contributor Agreement, http://www.python.org/psf/psf-contributor-agreement.html [8] Alex Larsson's email confirming his agreement was mailed in, http://mail.python.org/pipermail/python-dev/2003-August/037755.html [9] Tim Peters' email summarizing LC_NUMERIC trouble with Spambayes, http://mail.python.org/pipermail/python-dev/2003-September/037898.html [10] Python bug report, http://www.python.org/sf/774665 [11] Integrated LC_NUMERIC-agnostic patch, https://sourceforge.net/tracker/download.php?group_id=5470&atid=305470&file_id=89685&aid=774665 Copyright This document has been placed in the public domain. Local Variables: mode: indented-text indent-tabs-mode: nil sentence-end-double-space: t fill-column: 70 End: Index: pep-0000.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0000.txt,v retrieving revision 1.274 retrieving revision 1.275 diff -C2 -d -r1.274 -r1.275 *** pep-0000.txt 6 Jul 2004 01:15:33 -0000 1.274 --- pep-0000.txt 19 Jul 2004 18:08:56 -0000 1.275 *************** *** 123,126 **** --- 123,127 ---- S 325 Resource-Release Support for Generators Pedroni S 330 Python Bytecode Verification Pelletier + S 331 Locale-Independent Float/String conversions Reis S 754 IEEE 754 Floating Point Special Values Warnes *************** *** 354,357 **** --- 355,359 ---- SR 329 Treating Builtins as Constants in the Standard Library Hettinger S 330 Python Bytecode Verification Pelletier + S 331 Locale-Independent Float/String conversions Reis SR 666 Reject Foolish Indentation Creighton S 754 IEEE 754 Floating Point Special Values Warnes *************** *** 431,434 **** --- 433,437 ---- Reedy, Terry tjreedy@udel.edu Reifschneider, Sean jafo-pep@tummy.com + Reis, Christian R. kiko@async.com.br Riehl, Jonathan jriehl@spaceship.com van Rossum, Guido (GvR) guido@python.org From goodger at users.sourceforge.net Mon Jul 19 21:02:17 2004 From: goodger at users.sourceforge.net (goodger@users.sourceforge.net) Date: Mon Jul 19 21:02:19 2004 Subject: [Python-checkins] python/nondist/peps pep2html.py,1.51,1.52 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28272 Modified Files: pep2html.py Log Message: allow https URI scheme in links Index: pep2html.py =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep2html.py,v retrieving revision 1.51 retrieving revision 1.52 diff -C2 -d -r1.51 -r1.52 *** pep2html.py 2 Apr 2004 19:20:13 -0000 1.51 --- pep2html.py 19 Jul 2004 19:02:14 -0000 1.52 *************** *** 70,74 **** ' "http://www.w3.org/TR/REC-html40/loose.dtd">') ! fixpat = re.compile("((http|ftp):[-_a-zA-Z0-9/.+~:?#$=&,]+)|(pep-\d+(.txt)?)|" "(RFC[- ]?(?P\d+))|" "(PEP\s+(?P\d+))|" --- 70,74 ---- ' "http://www.w3.org/TR/REC-html40/loose.dtd">') ! fixpat = re.compile("((https?|ftp):[-_a-zA-Z0-9/.+~:?#$=&,]+)|(pep-\d+(.txt)?)|" "(RFC[- ]?(?P\d+))|" "(PEP\s+(?P\d+))|" From goodger at users.sourceforge.net Mon Jul 19 21:05:03 2004 From: goodger at users.sourceforge.net (goodger@users.sourceforge.net) Date: Mon Jul 19 21:05:12 2004 Subject: [Python-checkins] python/nondist/peps pep2html.py,1.52,1.53 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28742 Modified Files: pep2html.py Log Message: allow https URI scheme in links, continued Index: pep2html.py =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep2html.py,v retrieving revision 1.52 retrieving revision 1.53 diff -C2 -d -r1.52 -r1.53 *** pep2html.py 19 Jul 2004 19:02:14 -0000 1.52 --- pep2html.py 19 Jul 2004 19:05:01 -0000 1.53 *************** *** 97,101 **** text = match.group(0) link = None ! if text.startswith('http:') or text.startswith('ftp:'): # Strip off trailing punctuation. Pattern taken from faqwiz. ltext = list(text) --- 97,102 ---- text = match.group(0) link = None ! if (text.startswith('http:') or text.startswith('https:') ! or text.startswith('ftp:')): # Strip off trailing punctuation. Pattern taken from faqwiz. ltext = list(text) From goodger at users.sourceforge.net Tue Jul 20 01:09:06 2004 From: goodger at users.sourceforge.net (goodger@users.sourceforge.net) Date: Tue Jul 20 01:09:09 2004 Subject: [Python-checkins] python/nondist/peps pep-0331.txt,1.1,1.2 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12984 Modified Files: pep-0331.txt Log Message: update from Christian R. Reis Index: pep-0331.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0331.txt,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** pep-0331.txt 19 Jul 2004 18:08:57 -0000 1.1 --- pep-0331.txt 19 Jul 2004 23:09:04 -0000 1.2 *************** *** 130,136 **** Alex Larsson, the original author of the glib code, submitted a PSF Contributor Agreement [7] on 2003-08-20 [8] to ensure the code ! could be safely integrated. ! ! [XXX: was the agreement actually received and accepted?] --- 130,135 ---- Alex Larsson, the original author of the glib code, submitted a PSF Contributor Agreement [7] on 2003-08-20 [8] to ensure the code ! could be safely integrated; this agreement has been received and ! accepted. From perky at users.sourceforge.net Tue Jul 20 03:42:09 2004 From: perky at users.sourceforge.net (perky@users.sourceforge.net) Date: Tue Jul 20 03:42:11 2004 Subject: [Python-checkins] python/dist/src setup.py,1.195,1.196 Message-ID: Update of /cvsroot/python/python/dist/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4964 Modified Files: setup.py Log Message: ossaudiodev is available on FreeBSD 5 too. Index: setup.py =================================================================== RCS file: /cvsroot/python/python/dist/src/setup.py,v retrieving revision 1.195 retrieving revision 1.196 diff -C2 -d -r1.195 -r1.196 *** setup.py 19 Jul 2004 16:55:07 -0000 1.195 --- setup.py 20 Jul 2004 01:42:06 -0000 1.196 *************** *** 783,787 **** exts.append( Extension('linuxaudiodev', ['linuxaudiodev.c']) ) ! if platform in ('linux2', 'freebsd4'): exts.append( Extension('ossaudiodev', ['ossaudiodev.c']) ) --- 783,787 ---- exts.append( Extension('linuxaudiodev', ['linuxaudiodev.c']) ) ! if platform in ('linux2', 'freebsd4', 'freebsd5'): exts.append( Extension('ossaudiodev', ['ossaudiodev.c']) ) From bcannon at users.sourceforge.net Tue Jul 20 04:28:32 2004 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Tue Jul 20 04:28:36 2004 Subject: [Python-checkins] python/dist/src/Lib site.py,1.63,1.64 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10656/Lib Modified Files: site.py Log Message: Fix bug in addsitedir() to properly handle the lack of a second argument. Fixed to keep backwards-compatibility for the undocumented function. Closes bug #986795. Index: site.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/site.py,v retrieving revision 1.63 retrieving revision 1.64 diff -C2 -d -r1.63 -r1.64 *** site.py 9 Jul 2004 23:38:18 -0000 1.63 --- site.py 20 Jul 2004 02:28:28 -0000 1.64 *************** *** 125,129 **** fullname = os.path.join(sitedir, name) try: ! f = file(fullname, "rU") except IOError: return --- 125,129 ---- fullname = os.path.join(sitedir, name) try: ! f = open(fullname, "rU") except IOError: return *************** *** 150,154 **** 'sitedir'""" if known_paths is None: ! d = _init_pathinfo() reset = 1 else: --- 150,154 ---- 'sitedir'""" if known_paths is None: ! known_paths = _init_pathinfo() reset = 1 else: *************** *** 163,167 **** names.sort() for name in names: ! if name[-4:] == os.extsep + "pth": addpackage(sitedir, name, known_paths) if reset: --- 163,167 ---- names.sort() for name in names: ! if name.endswith(os.extsep + "pth"): addpackage(sitedir, name, known_paths) if reset: From loewis at users.sourceforge.net Tue Jul 20 09:54:59 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Tue Jul 20 09:55:02 2004 Subject: [Python-checkins] python/nondist/sandbox/msi msi.py,1.14,1.15 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/msi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18115 Modified Files: msi.py Log Message: Do not attempt to install pythonxy.dll into system32 for an unpriviliged user. Index: msi.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/msi/msi.py,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** msi.py 15 Jul 2004 17:37:11 -0000 1.14 --- msi.py 20 Jul 2004 07:54:56 -0000 1.15 *************** *** 250,255 **** add_data(db, "InstallExecuteSequence", [("InitialTargetDir", 'TARGETDIR=""', 750), ! ("SetDLLDirToSystem32", 'DLLDIR="" and ALLUSERS', 751), ! ("SetDLLDirToTarget", 'DLLDIR="" and not ALLUSERS', 752), ]) add_data(db, "AdminExecuteSequence", --- 250,255 ---- add_data(db, "InstallExecuteSequence", [("InitialTargetDir", 'TARGETDIR=""', 750), ! ("SetDLLDirToSystem32", 'DLLDIR="" and (ALLUSERS and Privileged)', 751), ! ("SetDLLDirToTarget", 'DLLDIR="" and not (ALLUSERS and Privileged)', 752), ]) add_data(db, "AdminExecuteSequence", *************** *** 474,478 **** # Alternative texts if AdminInstall is not available c=advanced.text("Unprivileged", 135, 90, 160, 50, 3, ! "Installing Python for all users is not possible, because you lack privileges.") c.condition("Hide", "Privileged") c=advanced.text("W9X", 135, 80, 160, 90, 3, --- 474,478 ---- # Alternative texts if AdminInstall is not available c=advanced.text("Unprivileged", 135, 90, 160, 50, 3, ! "Installing Python for all users is not possible, because you lack privileges. Python will be installed for you only.") c.condition("Hide", "Privileged") c=advanced.text("W9X", 135, 80, 160, 90, 3, *************** *** 482,486 **** c = advanced.cancel("Ok", "AdminInstall", name="OK") c.event("DoAction", "SetDLLDirToTarget", 'WhichUsers="JUSTME"', 1) ! c.event("DoAction", "SetDLLDirToSystem32", 'WhichUsers="ALL"', 2) c.event("EndDialog", "Return", order = 3) --- 482,486 ---- c = advanced.cancel("Ok", "AdminInstall", name="OK") c.event("DoAction", "SetDLLDirToTarget", 'WhichUsers="JUSTME"', 1) ! c.event("DoAction", "SetDLLDirToSystem32", 'WhichUsers="ALL" and (Windows9x or Privileged)', 2) c.event("EndDialog", "Return", order = 3) From loewis at users.sourceforge.net Tue Jul 20 10:52:51 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Tue Jul 20 10:52:54 2004 Subject: [Python-checkins] python/nondist/sandbox/msi msilib.py,1.7,1.8 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/msi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25608 Modified Files: msilib.py Log Message: Check for version 2 of MSI merge. Index: msilib.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/msi/msilib.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** msilib.py 1 Feb 2004 18:03:36 -0000 1.7 --- msilib.py 20 Jul 2004 08:52:48 -0000 1.8 *************** *** 4,8 **** import win32com.client.gencache import win32com.client ! import pythoncom from win32com.client import constants import re, string, os, sets, glob, popen2, sys, _winreg --- 4,8 ---- import win32com.client.gencache import win32com.client ! import pythoncom, pywintypes from win32com.client import constants import re, string, os, sets, glob, popen2, sys, _winreg *************** *** 54,58 **** def EnsureMSM(): ! win32com.client.gencache.EnsureModule('{0ADDA82F-2C26-11D2-AD65-00A0C9AF11A6}', 0, 1, 0) _Installer=None --- 54,61 ---- def EnsureMSM(): ! try: ! win32com.client.gencache.EnsureModule('{0ADDA82F-2C26-11D2-AD65-00A0C9AF11A6}', 0, 1, 0) ! except pywintypes.com_error: ! win32com.client.gencache.EnsureModule('{0ADDA82F-2C26-11D2-AD65-00A0C9AF11A6}', 0, 2, 0) _Installer=None From loewis at users.sourceforge.net Tue Jul 20 16:38:02 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Tue Jul 20 16:38:05 2004 Subject: [Python-checkins] python/dist/src/PCbuild _bsddb.vcproj, 1.2, 1.3 _socket.vcproj, 1.2, 1.3 _ssl.vcproj, 1.2, 1.3 _testcapi.vcproj, 1.2, 1.3 _tkinter.vcproj, 1.2, 1.3 bz2.vcproj, 1.3, 1.4 pcbuild.sln, 1.2, 1.3 pyexpat.vcproj, 1.2, 1.3 python.vcproj, 1.2, 1.3 pythoncore.vcproj, 1.15, 1.16 pythonw.vcproj, 1.2, 1.3 readme.txt, 1.54, 1.55 select.vcproj, 1.2, 1.3 unicodedata.vcproj, 1.2, 1.3 winsound.vcproj, 1.2, 1.3 zlib.vcproj, 1.5, 1.6 Message-ID: Update of /cvsroot/python/python/dist/src/PCbuild In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13808 Modified Files: _bsddb.vcproj _socket.vcproj _ssl.vcproj _testcapi.vcproj _tkinter.vcproj bz2.vcproj pcbuild.sln pyexpat.vcproj python.vcproj pythoncore.vcproj pythonw.vcproj readme.txt select.vcproj unicodedata.vcproj winsound.vcproj zlib.vcproj Log Message: Add Itanium targets. Index: _bsddb.vcproj =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/_bsddb.vcproj,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** _bsddb.vcproj 15 Jun 2004 18:18:19 -0000 1.2 --- _bsddb.vcproj 20 Jul 2004 14:37:47 -0000 1.3 *************** *** 146,149 **** --- 146,223 ---- Name="VCAuxiliaryManagedWrapperGeneratorTool"/> + + + + + + + + + + + + + + + *************** *** 168,171 **** --- 242,253 ---- PreprocessorDefinitions="NDEBUG;WIN32;_WINDOWS;$(NoInherit)"/> + + + Index: _socket.vcproj =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/_socket.vcproj,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** _socket.vcproj 15 Jun 2004 18:18:19 -0000 1.2 --- _socket.vcproj 20 Jul 2004 14:37:47 -0000 1.3 *************** *** 144,147 **** --- 144,220 ---- Name="VCAuxiliaryManagedWrapperGeneratorTool"/> + + + + + + + + + + + + + + + *************** *** 166,169 **** --- 239,250 ---- PreprocessorDefinitions="NDEBUG;WIN32;_WINDOWS;$(NoInherit)"/> + + + Index: _ssl.vcproj =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/_ssl.vcproj,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** _ssl.vcproj 15 Jun 2004 18:18:19 -0000 1.2 --- _ssl.vcproj 20 Jul 2004 14:37:47 -0000 1.3 *************** *** 38,41 **** --- 38,54 ---- Output="_ssl_d.pyd"/> + + + Index: _testcapi.vcproj =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/_testcapi.vcproj,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** _testcapi.vcproj 15 Jun 2004 18:18:19 -0000 1.2 --- _testcapi.vcproj 20 Jul 2004 14:37:47 -0000 1.3 *************** *** 141,144 **** --- 141,215 ---- Name="VCAuxiliaryManagedWrapperGeneratorTool"/> + + + + + + + + + + + + + + + *************** *** 164,167 **** --- 235,246 ---- BasicRuntimeChecks="3"/> + + + Index: _tkinter.vcproj =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/_tkinter.vcproj,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** _tkinter.vcproj 15 Jun 2004 18:18:19 -0000 1.2 --- _tkinter.vcproj 20 Jul 2004 14:37:47 -0000 1.3 *************** *** 146,149 **** --- 146,223 ---- Name="VCAuxiliaryManagedWrapperGeneratorTool"/> + + + + + + + + + + + + + + + *************** *** 168,171 **** --- 242,253 ---- PreprocessorDefinitions="_DEBUG;WIN32;_WINDOWS;WITH_APPINIT;$(NoInherit)"/> + + + + + + Index: bz2.vcproj =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/bz2.vcproj,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** bz2.vcproj 15 Jun 2004 18:18:19 -0000 1.3 --- bz2.vcproj 20 Jul 2004 14:37:47 -0000 1.4 *************** *** 153,156 **** --- 153,233 ---- Name="VCAuxiliaryManagedWrapperGeneratorTool"/> + + + + + + + + + + + + + + + *************** *** 175,178 **** --- 252,263 ---- PreprocessorDefinitions="NDEBUG;WIN32;_WINDOWS;$(NoInherit)"/> + + + Index: pcbuild.sln =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/pcbuild.sln,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** pcbuild.sln 28 Jun 2004 15:24:23 -0000 1.2 --- pcbuild.sln 20 Jul 2004 14:37:47 -0000 1.3 *************** *** 84,87 **** --- 84,88 ---- Debug = Debug Release = Release + ReleaseItanium = ReleaseItanium EndGlobalSection GlobalSection(ProjectConfiguration) = postSolution *************** *** 90,153 **** --- 91,185 ---- {E1DBB220-D64B-423D-A545-539A55AA7FE2}.Release.ActiveCfg = Release|Win32 {E1DBB220-D64B-423D-A545-539A55AA7FE2}.Release.Build.0 = Release|Win32 + {E1DBB220-D64B-423D-A545-539A55AA7FE2}.ReleaseItanium.ActiveCfg = ReleaseItanium|Win32 + {E1DBB220-D64B-423D-A545-539A55AA7FE2}.ReleaseItanium.Build.0 = ReleaseItanium|Win32 {324F66C2-44D0-4D50-B979-F9DAE7FD36DB}.Debug.ActiveCfg = Debug|Win32 {324F66C2-44D0-4D50-B979-F9DAE7FD36DB}.Debug.Build.0 = Debug|Win32 {324F66C2-44D0-4D50-B979-F9DAE7FD36DB}.Release.ActiveCfg = Release|Win32 {324F66C2-44D0-4D50-B979-F9DAE7FD36DB}.Release.Build.0 = Release|Win32 + {324F66C2-44D0-4D50-B979-F9DAE7FD36DB}.ReleaseItanium.ActiveCfg = ReleaseItanium|Win32 + {324F66C2-44D0-4D50-B979-F9DAE7FD36DB}.ReleaseItanium.Build.0 = ReleaseItanium|Win32 {8E85BA54-8A47-4C8B-B72E-8E17579CC6D7}.Debug.ActiveCfg = Debug|Win32 {8E85BA54-8A47-4C8B-B72E-8E17579CC6D7}.Debug.Build.0 = Debug|Win32 {8E85BA54-8A47-4C8B-B72E-8E17579CC6D7}.Release.ActiveCfg = Release|Win32 {8E85BA54-8A47-4C8B-B72E-8E17579CC6D7}.Release.Build.0 = Release|Win32 + {8E85BA54-8A47-4C8B-B72E-8E17579CC6D7}.ReleaseItanium.ActiveCfg = ReleaseItanium|Win32 + {8E85BA54-8A47-4C8B-B72E-8E17579CC6D7}.ReleaseItanium.Build.0 = ReleaseItanium|Win32 {59CBF474-9E06-4C50-9142-C44A118BB447}.Debug.ActiveCfg = Debug|Win32 {59CBF474-9E06-4C50-9142-C44A118BB447}.Debug.Build.0 = Debug|Win32 {59CBF474-9E06-4C50-9142-C44A118BB447}.Release.ActiveCfg = Release|Win32 {59CBF474-9E06-4C50-9142-C44A118BB447}.Release.Build.0 = Release|Win32 + {59CBF474-9E06-4C50-9142-C44A118BB447}.ReleaseItanium.ActiveCfg = ReleaseItanium|Win32 + {59CBF474-9E06-4C50-9142-C44A118BB447}.ReleaseItanium.Build.0 = ReleaseItanium|Win32 {5B51DFF7-5DC0-41F8-8791-A4AB7114A151}.Debug.ActiveCfg = Debug|Win32 {5B51DFF7-5DC0-41F8-8791-A4AB7114A151}.Debug.Build.0 = Debug|Win32 {5B51DFF7-5DC0-41F8-8791-A4AB7114A151}.Release.ActiveCfg = Release|Win32 {5B51DFF7-5DC0-41F8-8791-A4AB7114A151}.Release.Build.0 = Release|Win32 + {5B51DFF7-5DC0-41F8-8791-A4AB7114A151}.ReleaseItanium.ActiveCfg = ReleaseItanium|Win32 + {5B51DFF7-5DC0-41F8-8791-A4AB7114A151}.ReleaseItanium.Build.0 = ReleaseItanium|Win32 {AC557788-6354-43F7-BE05-C9C8C59A344A}.Debug.ActiveCfg = Debug|Win32 {AC557788-6354-43F7-BE05-C9C8C59A344A}.Debug.Build.0 = Debug|Win32 {AC557788-6354-43F7-BE05-C9C8C59A344A}.Release.ActiveCfg = Release|Win32 {AC557788-6354-43F7-BE05-C9C8C59A344A}.Release.Build.0 = Release|Win32 + {AC557788-6354-43F7-BE05-C9C8C59A344A}.ReleaseItanium.ActiveCfg = ReleaseItanium|Win32 + {AC557788-6354-43F7-BE05-C9C8C59A344A}.ReleaseItanium.Build.0 = ReleaseItanium|Win32 {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.Debug.ActiveCfg = Debug|Win32 {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.Debug.Build.0 = Debug|Win32 {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.Release.ActiveCfg = Release|Win32 {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.Release.Build.0 = Release|Win32 + {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.ReleaseItanium.ActiveCfg = Release|Win32 + {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.ReleaseItanium.Build.0 = Release|Win32 {7E551393-3C43-47F8-9F3F-5BC368A6C487}.Debug.ActiveCfg = Debug|Win32 {7E551393-3C43-47F8-9F3F-5BC368A6C487}.Debug.Build.0 = Debug|Win32 {7E551393-3C43-47F8-9F3F-5BC368A6C487}.Release.ActiveCfg = Release|Win32 {7E551393-3C43-47F8-9F3F-5BC368A6C487}.Release.Build.0 = Release|Win32 + {7E551393-3C43-47F8-9F3F-5BC368A6C487}.ReleaseItanium.ActiveCfg = ReleaseItanium|Win32 + {7E551393-3C43-47F8-9F3F-5BC368A6C487}.ReleaseItanium.Build.0 = ReleaseItanium|Win32 {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.Debug.ActiveCfg = Debug|Win32 {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.Debug.Build.0 = Debug|Win32 {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.Release.ActiveCfg = Release|Win32 {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.Release.Build.0 = Release|Win32 + {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.ReleaseItanium.ActiveCfg = ReleaseItanium|Win32 + {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.ReleaseItanium.Build.0 = ReleaseItanium|Win32 {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.Debug.ActiveCfg = Debug|Win32 {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.Debug.Build.0 = Debug|Win32 {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.Release.ActiveCfg = Release|Win32 {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.Release.Build.0 = Release|Win32 + {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.ReleaseItanium.ActiveCfg = ReleaseItanium|Win32 + {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.ReleaseItanium.Build.0 = ReleaseItanium|Win32 {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.Debug.ActiveCfg = Debug|Win32 {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.Debug.Build.0 = Debug|Win32 {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.Release.ActiveCfg = Release|Win32 {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.Release.Build.0 = Release|Win32 + {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.ReleaseItanium.ActiveCfg = ReleaseItanium|Win32 + {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.ReleaseItanium.Build.0 = ReleaseItanium|Win32 {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.Debug.ActiveCfg = Debug|Win32 {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.Debug.Build.0 = Debug|Win32 {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.Release.ActiveCfg = Release|Win32 {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.Release.Build.0 = Release|Win32 + {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.ReleaseItanium.ActiveCfg = ReleaseItanium|Win32 + {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.ReleaseItanium.Build.0 = ReleaseItanium|Win32 {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.Debug.ActiveCfg = Debug|Win32 {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.Debug.Build.0 = Debug|Win32 {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.Release.ActiveCfg = Release|Win32 {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.Release.Build.0 = Release|Win32 + {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.ReleaseItanium.ActiveCfg = ReleaseItanium|Win32 + {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.ReleaseItanium.Build.0 = ReleaseItanium|Win32 {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.Debug.ActiveCfg = Debug|Win32 {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.Debug.Build.0 = Debug|Win32 {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.Release.ActiveCfg = Release|Win32 {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.Release.Build.0 = Release|Win32 + {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.ReleaseItanium.ActiveCfg = Release|Win32 {51F35FAE-FB92-4B2C-9187-1542C065AD77}.Debug.ActiveCfg = Debug|Win32 {51F35FAE-FB92-4B2C-9187-1542C065AD77}.Debug.Build.0 = Debug|Win32 {51F35FAE-FB92-4B2C-9187-1542C065AD77}.Release.ActiveCfg = Release|Win32 {51F35FAE-FB92-4B2C-9187-1542C065AD77}.Release.Build.0 = Release|Win32 + {51F35FAE-FB92-4B2C-9187-1542C065AD77}.ReleaseItanium.ActiveCfg = ReleaseItanium|Win32 + {51F35FAE-FB92-4B2C-9187-1542C065AD77}.ReleaseItanium.Build.0 = ReleaseItanium|Win32 {680CDC79-9CCA-4282-9A8D-927CB0DB55B2}.Debug.ActiveCfg = Debug|Win32 {680CDC79-9CCA-4282-9A8D-927CB0DB55B2}.Debug.Build.0 = Debug|Win32 {680CDC79-9CCA-4282-9A8D-927CB0DB55B2}.Release.ActiveCfg = Release|Win32 {680CDC79-9CCA-4282-9A8D-927CB0DB55B2}.Release.Build.0 = Release|Win32 + {680CDC79-9CCA-4282-9A8D-927CB0DB55B2}.ReleaseItanium.ActiveCfg = Release|Win32 + {680CDC79-9CCA-4282-9A8D-927CB0DB55B2}.ReleaseItanium.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionItems) = postSolution Index: pyexpat.vcproj =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/pyexpat.vcproj,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** pyexpat.vcproj 15 Jun 2004 18:18:19 -0000 1.2 --- pyexpat.vcproj 20 Jul 2004 14:37:47 -0000 1.3 *************** *** 144,147 **** --- 144,220 ---- Name="VCAuxiliaryManagedWrapperGeneratorTool"/> + + + + + + + + + + + + + + + *************** *** 166,169 **** --- 239,250 ---- PreprocessorDefinitions="NDEBUG;WIN32;_WINDOWS;XML_NS;XML_DTD;BYTEORDER=1234;XML_CONTEXT_BYTES=1024;XML_STATIC;HAVE_MEMMOVE;$(NoInherit)"/> + + + + + + + + + + + + Index: python.vcproj =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/python.vcproj,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** python.vcproj 15 Jun 2004 18:18:19 -0000 1.2 --- python.vcproj 20 Jul 2004 14:37:47 -0000 1.3 *************** *** 138,141 **** --- 138,210 ---- Name="VCAuxiliaryManagedWrapperGeneratorTool"/> + + + + + + + + + + + + + + + *************** *** 164,167 **** --- 233,244 ---- BrowseInformation="1"/> + + + + + + Index: pythoncore.vcproj =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/pythoncore.vcproj,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** pythoncore.vcproj 18 Jul 2004 08:53:18 -0000 1.15 --- pythoncore.vcproj 20 Jul 2004 14:37:47 -0000 1.16 *************** *** 148,151 **** --- 148,225 ---- Name="VCAuxiliaryManagedWrapperGeneratorTool"/> + [...1773 lines suppressed...] + AdditionalIncludeDirectories="" + PreprocessorDefinitions="NDEBUG;WIN32;_WINDOWS;USE_DL_EXPORT;$(NoInherit)"/> + + + + Index: pythonw.vcproj =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/pythonw.vcproj,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** pythonw.vcproj 15 Jun 2004 18:18:19 -0000 1.2 --- pythonw.vcproj 20 Jul 2004 14:37:48 -0000 1.3 *************** *** 140,143 **** --- 140,214 ---- Name="VCAuxiliaryManagedWrapperGeneratorTool"/> + + + + + + + + + + + + + + + *************** *** 160,163 **** --- 231,241 ---- AdditionalIncludeDirectories="\Pyinst\python\PC"/> + + + + + + Index: readme.txt =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/readme.txt,v retrieving revision 1.54 retrieving revision 1.55 diff -C2 -d -r1.54 -r1.55 *** readme.txt 2 Jul 2004 08:58:46 -0000 1.54 --- readme.txt 20 Jul 2004 14:37:48 -0000 1.55 *************** *** 288,291 **** --- 288,306 ---- this by hand. + Building for Itanium + -------------------- + + The project files support a ReleaseItanium configuration which creates + Win64/Itanium binaries. For this to work, you need to install the Platform + SDK, in particular the 64-bit support. This includes an Itanium compiler + (future releases of the SDK likely include an AMD64 compiler as well). + In addition, you need the Visual Studio plugin for external C compilers, + from http://sf.net/projects/vsextcomp. The plugin will wrap cl.exe, to + locate the proper target compiler, and convert compiler options + accordingly. + + The Itanium build has seen little testing. The SDK compiler reports a lot + of warnings about conversion from size_t to int, which will be fixed in + future Python releases. YOUR OWN EXTENSION DLLs Index: select.vcproj =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/select.vcproj,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** select.vcproj 15 Jun 2004 18:18:19 -0000 1.2 --- select.vcproj 20 Jul 2004 14:37:48 -0000 1.3 *************** *** 146,149 **** --- 146,223 ---- Name="VCAuxiliaryManagedWrapperGeneratorTool"/> + + + + + + + + + + + + + + + *************** *** 168,171 **** --- 242,253 ---- PreprocessorDefinitions="_DEBUG;WIN32;_WINDOWS;$(NoInherit)"/> + + + Index: unicodedata.vcproj =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/unicodedata.vcproj,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** unicodedata.vcproj 15 Jun 2004 18:18:19 -0000 1.2 --- unicodedata.vcproj 20 Jul 2004 14:37:48 -0000 1.3 *************** *** 141,144 **** --- 141,215 ---- Name="VCAuxiliaryManagedWrapperGeneratorTool"/> + + + + + + + + + + + + + + + *************** *** 164,167 **** --- 235,246 ---- BasicRuntimeChecks="3"/> + + + Index: winsound.vcproj =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/winsound.vcproj,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** winsound.vcproj 15 Jun 2004 18:18:19 -0000 1.2 --- winsound.vcproj 20 Jul 2004 14:37:48 -0000 1.3 *************** *** 143,146 **** --- 143,218 ---- Name="VCAuxiliaryManagedWrapperGeneratorTool"/> + + + + + + + + + + + + + + + *************** *** 166,169 **** --- 238,249 ---- PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;WINSOUND_EXPORTS;$(NoInherit)"/> + + + Index: zlib.vcproj =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/zlib.vcproj,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** zlib.vcproj 15 Jun 2004 18:18:19 -0000 1.5 --- zlib.vcproj 20 Jul 2004 14:37:48 -0000 1.6 *************** *** 155,158 **** --- 155,236 ---- Name="VCAuxiliaryManagedWrapperGeneratorTool"/> + + + + + + + + + + + + + + + From nnorwitz at users.sourceforge.net Tue Jul 20 23:54:20 2004 From: nnorwitz at users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Tue Jul 20 23:54:23 2004 Subject: [Python-checkins] python/dist/src/Lib tarfile.py,1.11,1.12 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9308/Lib Modified Files: tarfile.py Log Message: SF #846659, fix bufsize violation and GNU longname/longlink extensions Index: tarfile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/tarfile.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** tarfile.py 10 Jul 2004 22:02:11 -0000 1.11 --- tarfile.py 20 Jul 2004 21:54:17 -0000 1.12 *************** *** 354,358 **** if self.type != "tar": self.buf += self.cmp.flush() - self.__write("") # Write remaining blocks to output self.fileobj.write(self.buf) self.buf = "" --- 354,357 ---- *************** *** 1776,1779 **** --- 1775,1780 ---- which contain the longname as a null terminated string. """ + name += NUL + tarinfo = TarInfo() tarinfo.name = "././@LongLink" *************** *** 1784,1787 **** --- 1785,1789 ---- # write extended header self.fileobj.write(tarinfo.tobuf()) + self.offset += BLOCKSIZE # write name blocks self.fileobj.write(name) From nnorwitz at users.sourceforge.net Tue Jul 20 23:54:20 2004 From: nnorwitz at users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Tue Jul 20 23:54:25 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_tarfile.py, 1.11, 1.12 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9308/Lib/test Modified Files: test_tarfile.py Log Message: SF #846659, fix bufsize violation and GNU longname/longlink extensions Index: test_tarfile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_tarfile.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** test_tarfile.py 12 Jun 2003 19:16:58 -0000 1.11 --- test_tarfile.py 20 Jul 2004 21:54:18 -0000 1.12 *************** *** 206,209 **** --- 206,297 ---- sep = '|' + class WriteGNULongTest(unittest.TestCase): + """This testcase checks for correct creation of GNU Longname + and Longlink extensions. + + It creates a tarfile and adds empty members with either + long names, long linknames or both and compares the size + of the tarfile with the expected size. + + It checks for SF bug #812325 in TarFile._create_gnulong(). + + While I was writing this testcase, I noticed a second bug + in the same method: + Long{names,links} weren't null-terminated which lead to + bad tarfiles when their length was a multiple of 512. This + is tested as well. + """ + + def setUp(self): + self.tar = tarfile.open(tmpname(), "w") + self.tar.posix = False + + def tearDown(self): + self.tar.close() + + def _length(self, s): + blocks, remainder = divmod(len(s) + 1, 512) + if remainder: + blocks += 1 + return blocks * 512 + + def _calc_size(self, name, link=None): + # initial tar header + count = 512 + + if len(name) > tarfile.LENGTH_NAME: + # gnu longname extended header + longname + count += 512 + count += self._length(name) + + if link is not None and len(link) > tarfile.LENGTH_LINK: + # gnu longlink extended header + longlink + count += 512 + count += self._length(link) + + return count + + def _test(self, name, link=None): + tarinfo = tarfile.TarInfo(name) + if link: + tarinfo.linkname = link + tarinfo.type = tarfile.LNKTYPE + + self.tar.addfile(tarinfo) + + v1 = self._calc_size(name, link) + v2 = self.tar.offset + self.assertEqual(v1, v2, "GNU longname/longlink creation failed") + + def test_longname_1023(self): + self._test(("longnam/" * 127) + "longnam") + + def test_longname_1024(self): + self._test(("longnam/" * 127) + "longname") + + def test_longname_1025(self): + self._test(("longnam/" * 127) + "longname_") + + def test_longlink_1023(self): + self._test("name", ("longlnk/" * 127) + "longlnk") + + def test_longlink_1024(self): + self._test("name", ("longlnk/" * 127) + "longlink") + + def test_longlink_1025(self): + self._test("name", ("longlnk/" * 127) + "longlink_") + + def test_longnamelink_1023(self): + self._test(("longnam/" * 127) + "longnam", + ("longlnk/" * 127) + "longlnk") + + def test_longnamelink_1024(self): + self._test(("longnam/" * 127) + "longname", + ("longlnk/" * 127) + "longlink") + + def test_longnamelink_1025(self): + self._test(("longnam/" * 127) + "longname_", + ("longlnk/" * 127) + "longlink_") + # Gzip TestCases class ReadTestGzip(ReadTest): *************** *** 246,250 **** ReadStreamTest, WriteTest, ! WriteStreamTest ] --- 334,339 ---- ReadStreamTest, WriteTest, ! WriteStreamTest, ! WriteGNULongTest, ] From nnorwitz at users.sourceforge.net Tue Jul 20 23:54:21 2004 From: nnorwitz at users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Tue Jul 20 23:54:27 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1046,1.1047 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9308/Misc Modified Files: NEWS Log Message: SF #846659, fix bufsize violation and GNU longname/longlink extensions Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1046 retrieving revision 1.1047 diff -C2 -d -r1.1046 -r1.1047 *** NEWS 19 Jul 2004 16:29:16 -0000 1.1046 --- NEWS 20 Jul 2004 21:54:18 -0000 1.1047 *************** *** 40,43 **** --- 40,46 ---- ------- + - Patch #846659. Fix an error in tarfile.py when using + GNU longname/longlink creation. + - The obsolete FCNTL.py has been deleted. The builtin fcntl module has been available (on platforms that support fcntl) since Python From nnorwitz at users.sourceforge.net Wed Jul 21 00:07:53 2004 From: nnorwitz at users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Wed Jul 21 00:07:56 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1047,1.1048 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12094/Misc Modified Files: NEWS Log Message: SF #857297 and 916874, improve handling of hard links when extracting Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1047 retrieving revision 1.1048 diff -C2 -d -r1.1047 -r1.1048 *** NEWS 20 Jul 2004 21:54:18 -0000 1.1047 --- NEWS 20 Jul 2004 22:07:44 -0000 1.1048 *************** *** 40,43 **** --- 40,46 ---- ------- + - Bug #857297/Patch #916874. Fix an error when extracting a hard link + from a tarfile. + - Patch #846659. Fix an error in tarfile.py when using GNU longname/longlink creation. From nnorwitz at users.sourceforge.net Wed Jul 21 00:07:53 2004 From: nnorwitz at users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Wed Jul 21 00:07:57 2004 Subject: [Python-checkins] python/dist/src/Lib tarfile.py,1.12,1.13 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12094/Lib Modified Files: tarfile.py Log Message: SF #857297 and 916874, improve handling of hard links when extracting Index: tarfile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/tarfile.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** tarfile.py 20 Jul 2004 21:54:17 -0000 1.12 --- tarfile.py 20 Jul 2004 22:07:43 -0000 1.13 *************** *** 1295,1298 **** --- 1295,1302 ---- tarinfo = self.getmember(member) + # Prepare the link target for makelink(). + if tarinfo.islnk(): + tarinfo._link_target = os.path.join(path, tarinfo.linkname) + try: self._extract_member(tarinfo, os.path.join(path, tarinfo.name)) *************** *** 1467,1471 **** os.symlink(linkpath, targetpath) else: ! os.link(linkpath, targetpath) except AttributeError: if tarinfo.issym(): --- 1471,1476 ---- os.symlink(linkpath, targetpath) else: ! # See extract(). ! os.link(tarinfo._link_target, targetpath) except AttributeError: if tarinfo.issym(): From nnorwitz at users.sourceforge.net Wed Jul 21 00:07:53 2004 From: nnorwitz at users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Wed Jul 21 00:07:59 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_tarfile.py, 1.12, 1.13 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12094/Lib/test Modified Files: test_tarfile.py Log Message: SF #857297 and 916874, improve handling of hard links when extracting Index: test_tarfile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_tarfile.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** test_tarfile.py 20 Jul 2004 21:54:18 -0000 1.12 --- test_tarfile.py 20 Jul 2004 22:07:44 -0000 1.13 *************** *** 294,297 **** --- 294,315 ---- ("longlnk/" * 127) + "longlink_") + class ExtractHardlinkTest(BaseTest): + + def test_hardlink(self): + """Test hardlink extraction (bug #857297) + """ + # Prevent errors from being caught + self.tar.errorlevel = 1 + + self.tar.extract("0-REGTYPE", dirname()) + try: + # Extract 1-LNKTYPE which is a hardlink to 0-REGTYPE + self.tar.extract("1-LNKTYPE", dirname()) + except EnvironmentError, e: + import errno + if e.errno == errno.ENOENT: + self.fail("hardlink not extracted properly") + + # Gzip TestCases class ReadTestGzip(ReadTest): *************** *** 338,341 **** --- 356,362 ---- ] + if hasattr(os, "link"): + tests.append(ExtractHardlinkTest) + if gzip: tests.extend([ From nnorwitz at users.sourceforge.net Wed Jul 21 00:23:04 2004 From: nnorwitz at users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Wed Jul 21 00:23:07 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libtarfile.tex,1.3,1.4 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16250/Doc/lib Modified Files: libtarfile.tex Log Message: SF #918101, allow files >= 8 GB using GNU extension Index: libtarfile.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libtarfile.tex,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** libtarfile.tex 13 Jan 2004 23:41:32 -0000 1.3 --- libtarfile.tex 20 Jul 2004 22:23:02 -0000 1.4 *************** *** 257,265 **** If true, create a \POSIX{} 1003.1-1990 compliant archive. GNU extensions are not used, because they are not part of the \POSIX{} ! standard. This limits the length of filenames to at most 256 and ! link names to 100 characters. A \exception{ValueError} is raised ! if a pathname exceeds this limit. If false, create a GNU tar ! compatible archive. It will not be \POSIX{} compliant, but can ! store pathnames of unlimited length. \end{memberdesc} --- 257,266 ---- If true, create a \POSIX{} 1003.1-1990 compliant archive. GNU extensions are not used, because they are not part of the \POSIX{} ! standard. This limits the length of filenames to at most 256, ! link names to 100 characters and the maximum file size to 8 ! gigabytes. A \exception{ValueError} is raised if a file exceeds ! this limit. If false, create a GNU tar compatible archive. It ! will not be \POSIX{} compliant, but can store files without any ! of the above restrictions. \end{memberdesc} From nnorwitz at users.sourceforge.net Wed Jul 21 00:23:05 2004 From: nnorwitz at users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Wed Jul 21 00:23:10 2004 Subject: [Python-checkins] python/dist/src/Lib tarfile.py,1.13,1.14 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16250/Lib Modified Files: tarfile.py Log Message: SF #918101, allow files >= 8 GB using GNU extension Index: tarfile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/tarfile.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** tarfile.py 20 Jul 2004 22:07:43 -0000 1.13 --- tarfile.py 20 Jul 2004 22:23:02 -0000 1.14 *************** *** 656,664 **** """ tarinfo = cls() ! tarinfo.name = nts(buf[0:100]) tarinfo.mode = int(buf[100:108], 8) tarinfo.uid = int(buf[108:116],8) tarinfo.gid = int(buf[116:124],8) ! tarinfo.size = long(buf[124:136], 8) tarinfo.mtime = long(buf[136:148], 8) tarinfo.chksum = int(buf[148:156], 8) --- 656,674 ---- """ tarinfo = cls() ! tarinfo.name = nts(buf[0:100]) tarinfo.mode = int(buf[100:108], 8) tarinfo.uid = int(buf[108:116],8) tarinfo.gid = int(buf[116:124],8) ! ! # There are two possible codings for the size field we ! # have to discriminate, see comment in tobuf() below. ! if buf[124] != chr(0200): ! tarinfo.size = long(buf[124:136], 8) ! else: ! tarinfo.size = 0L ! for i in range(11): ! tarinfo.size <<= 8 ! tarinfo.size += ord(buf[125 + i]) ! tarinfo.mtime = long(buf[136:148], 8) tarinfo.chksum = int(buf[148:156], 8) *************** *** 690,703 **** """Return a tar header block as a 512 byte string. """ ! name = self.name # The following code was contributed by Detlef Lannert. parts = [] for value, fieldsize in ( ! (name, 100), ("%07o" % (self.mode & 07777), 8), ("%07o" % self.uid, 8), ("%07o" % self.gid, 8), ! ("%011o" % self.size, 12), ("%011o" % self.mtime, 12), (" ", 8), --- 700,725 ---- """Return a tar header block as a 512 byte string. """ ! # Prefer the size to be encoded as 11 octal ascii digits ! # which is the most portable. If the size exceeds this ! # limit (>= 8 GB), encode it as an 88-bit value which is ! # a GNU tar feature. ! if self.size <= MAXSIZE_MEMBER: ! size = "%011o" % self.size ! else: ! s = self.size ! size = "" ! for i in range(11): ! size = chr(s & 0377) + size ! s >>= 8 ! size = chr(0200) + size # The following code was contributed by Detlef Lannert. parts = [] for value, fieldsize in ( ! (self.name, 100), ("%07o" % (self.mode & 07777), 8), ("%07o" % self.uid, 8), ("%07o" % self.gid, 8), ! (size, 12), ("%011o" % self.mtime, 12), (" ", 8), *************** *** 1237,1241 **** if tarinfo.size > MAXSIZE_MEMBER: ! raise ValueError, "file is too large (>8GB)" if len(tarinfo.linkname) > LENGTH_LINK: --- 1259,1267 ---- if tarinfo.size > MAXSIZE_MEMBER: ! if self.posix: ! raise ValueError, "file is too large (>= 8 GB)" ! else: ! self._dbg(2, "tarfile: Created GNU tar largefile header") ! if len(tarinfo.linkname) > LENGTH_LINK: From nnorwitz at users.sourceforge.net Wed Jul 21 00:31:37 2004 From: nnorwitz at users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Wed Jul 21 00:31:39 2004 Subject: [Python-checkins] python/dist/src/Lib tarfile.py,1.14,1.15 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18452/Lib Modified Files: tarfile.py Log Message: Remove unused variables Index: tarfile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/tarfile.py,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** tarfile.py 20 Jul 2004 22:23:02 -0000 1.14 --- tarfile.py 20 Jul 2004 22:31:34 -0000 1.15 *************** *** 1655,1660 **** """ buf = "" - name = None - linkname = None count = tarinfo.size while count > 0: --- 1655,1658 ---- From nnorwitz at users.sourceforge.net Wed Jul 21 00:34:39 2004 From: nnorwitz at users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Wed Jul 21 00:34:42 2004 Subject: [Python-checkins] python/dist/src/Modules timemodule.c,2.142,2.143 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19311/Modules Modified Files: timemodule.c Log Message: Fix SF #994580, typo in time.tzsets docstring. Backport candidate Index: timemodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/timemodule.c,v retrieving revision 2.142 retrieving revision 2.143 diff -C2 -d -r2.142 -r2.143 *** timemodule.c 20 Jun 2004 02:50:16 -0000 2.142 --- timemodule.c 20 Jul 2004 22:34:37 -0000 2.143 *************** *** 592,596 **** Initialize, or reinitialize, the local timezone to the value stored in\n\ os.environ['TZ']. The TZ environment variable should be specified in\n\ ! standard Uniz timezone format as documented in the tzset man page\n\ (eg. 'US/Eastern', 'Europe/Amsterdam'). Unknown timezones will silently\n\ fall back to UTC. If the TZ environment variable is not set, the local\n\ --- 592,596 ---- Initialize, or reinitialize, the local timezone to the value stored in\n\ os.environ['TZ']. The TZ environment variable should be specified in\n\ ! standard Unix timezone format as documented in the tzset man page\n\ (eg. 'US/Eastern', 'Europe/Amsterdam'). Unknown timezones will silently\n\ fall back to UTC. If the TZ environment variable is not set, the local\n\ From nnorwitz at users.sourceforge.net Wed Jul 21 03:41:17 2004 From: nnorwitz at users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Wed Jul 21 03:41:20 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libfcntl.tex,1.35,1.36 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20479/Doc/lib Modified Files: libfcntl.tex Log Message: SF #994605, fcntl example is broken The last call to fcntl (which wasn't changed) doesn't work for me, but the first part works now. Backport candidate. Index: libfcntl.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libfcntl.tex,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** libfcntl.tex 30 Jun 2004 21:06:45 -0000 1.35 --- libfcntl.tex 21 Jul 2004 01:41:14 -0000 1.36 *************** *** 152,159 **** \begin{verbatim} ! import struct, fcntl ! f = file(...) ! rv = fcntl(f, fcntl.F_SETFL, os.O_NDELAY) lockdata = struct.pack('hhllhh', fcntl.F_WRLCK, 0, 0, 0, 0, 0) --- 152,159 ---- \begin{verbatim} ! import struct, fcntl, os ! f = open(...) ! rv = fcntl.fcntl(f, fcntl.F_SETFL, os.O_NDELAY) lockdata = struct.pack('hhllhh', fcntl.F_WRLCK, 0, 0, 0, 0, 0) From bcannon at users.sourceforge.net Wed Jul 21 04:22:00 2004 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Wed Jul 21 04:22:03 2004 Subject: [Python-checkins] python/dist/src/Lib threading.py,1.43,1.44 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25825/Lib Modified Files: threading.py Log Message: Fix bug where a KeyError was raised if -O was being used for the interpreter and Thread.__delete() was called after a Thread instance was created. Problem resulted from a currentThread() call in an 'assert' statement being optimized out and dummy_thread.get_ident() always returning -1 and thus overwriting the entry for the _MainThread() instance created in 'threading' at import time. Closes bug #993394. Index: threading.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/threading.py,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -d -r1.43 -r1.44 *** threading.py 14 Jul 2004 19:07:15 -0000 1.43 --- threading.py 21 Jul 2004 02:21:57 -0000 1.44 *************** *** 494,499 **** def __delete(self): _active_limbo_lock.acquire() ! del _active[_get_ident()] _active_limbo_lock.release() --- 494,531 ---- def __delete(self): + """Remove the current thread from the dict of currently running + threads. + + Must take care to not raise an exception if dummy_thread is being used + (and thus this module is being used as an instance of dummy_threading). + Since dummy_thread.get_ident() always returns -1 since there is only one + thread if dummy_thread is being used. This means that if any Thread + instances are created they will overwrite any other threads registered. + + This is an issue with this method, though, since an instance of + _MainThread is always created by 'threading'. This gets overwritten the + instant an instance of Thread is created; both threads will have -1 as + their value from dummy_thread.get_ident() and thus have the same key in + the dict. This means that when the _MainThread instance created by + 'threading' tries to clean itself up when atexit calls this method it + gets a key error if another Thread instance was created since that + removed the only thing with the key of -1. + + This all means that KeyError from trying to delete something from + _active if dummy_threading is being used is a red herring. But since + it isn't if dummy_threading is *not* being used then don't hide the + exception. Also don't need to worry about issues from interpreter + shutdown and sys not being defined because the call is protected by a + blanket try/except block where that could be a problem. + + """ _active_limbo_lock.acquire() ! if _sys.modules.has_key('dummy_threading'): ! try: ! del _active[_get_ident()] ! except KeyError: ! pass ! else: ! del _active[_get_ident()] _active_limbo_lock.release() From bcannon at users.sourceforge.net Wed Jul 21 04:22:00 2004 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Wed Jul 21 04:22:05 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1048,1.1049 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25825/Misc Modified Files: NEWS Log Message: Fix bug where a KeyError was raised if -O was being used for the interpreter and Thread.__delete() was called after a Thread instance was created. Problem resulted from a currentThread() call in an 'assert' statement being optimized out and dummy_thread.get_ident() always returning -1 and thus overwriting the entry for the _MainThread() instance created in 'threading' at import time. Closes bug #993394. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1048 retrieving revision 1.1049 diff -C2 -d -r1.1048 -r1.1049 *** NEWS 20 Jul 2004 22:07:44 -0000 1.1048 --- NEWS 21 Jul 2004 02:21:58 -0000 1.1049 *************** *** 40,43 **** --- 40,47 ---- ------- + - Bug #993394. Fix a possible red herring of KeyError in 'threading' being + raised during interpreter shutdown from a registered function with atexit + when dummy_threading is being used. + - Bug #857297/Patch #916874. Fix an error when extracting a hard link from a tarfile. From montanaro at users.sourceforge.net Wed Jul 21 04:47:13 2004 From: montanaro at users.sourceforge.net (montanaro@users.sourceforge.net) Date: Wed Jul 21 04:47:16 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libsocksvr.tex,1.17,1.18 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28852 Modified Files: libsocksvr.tex Log Message: fix typo, highlight True/False correctly Index: libsocksvr.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libsocksvr.tex,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** libsocksvr.tex 22 Nov 2002 14:29:42 -0000 1.17 --- libsocksvr.tex 21 Jul 2004 02:47:10 -0000 1.18 *************** *** 107,111 **** \begin{datadesc}{allow_reuse_address} Whether the server will allow the reuse of an address. This defaults ! to \code{False}, and can be set in subclasses to change the policy. \end{datadesc} --- 107,111 ---- \begin{datadesc}{allow_reuse_address} Whether the server will allow the reuse of an address. This defaults ! to \constant{False}, and can be set in subclasses to change the policy. \end{datadesc} *************** *** 171,178 **** \begin{funcdesc}{verify_request}{request, client_address} ! Must return a Boolean value; if the value is true, the request will be ! processed, and if it's false, the request will be denied. This function can be overridden to implement access controls for a server. ! The default implementation always return true. \end{funcdesc} --- 171,178 ---- \begin{funcdesc}{verify_request}{request, client_address} ! Must return a Boolean value; if the value is \constant{True}, the request will be ! processed, and if it's \constant{False}, the request will be denied. This function can be overridden to implement access controls for a server. ! The default implementation always returns \constant{True}. \end{funcdesc} From bcannon at users.sourceforge.net Wed Jul 21 04:55:56 2004 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Wed Jul 21 04:55:59 2004 Subject: [Python-checkins] python/dist/src/Lib threading.py, 1.38.6.2, 1.38.6.3 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29871/Lib Modified Files: Tag: release23-maint threading.py Log Message: dummy_threading when run with -O would raise a KeyError in Thread.__delete() when called by atexit thanks to dummy_thread always returning -1 for dummy_thread.get_ident(). Since exception was not an issue, it is now caught and tossed. Closes bug #993394. Index: threading.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/threading.py,v retrieving revision 1.38.6.2 retrieving revision 1.38.6.3 diff -C2 -d -r1.38.6.2 -r1.38.6.3 *** threading.py 4 Jul 2004 18:35:56 -0000 1.38.6.2 --- threading.py 21 Jul 2004 02:55:54 -0000 1.38.6.3 *************** *** 493,498 **** def __delete(self): _active_limbo_lock.acquire() ! del _active[_get_ident()] _active_limbo_lock.release() --- 493,530 ---- def __delete(self): + """Remove the current thread from the dict of currently running + threads. + + Must take care to not raise an exception if dummy_thread is being used + (and thus this module is being used as an instance of dummy_threading). + Since dummy_thread.get_ident() always returns -1 since there is only one + thread if dummy_thread is being used. This means that if any Thread + instances are created they will overwrite any other threads registered. + + This is an issue with this method, though, since an instance of + _MainThread is always created by 'threading'. This gets overwritten the + instant an instance of Thread is created; both threads will have -1 as + their value from dummy_thread.get_ident() and thus have the same key in + the dict. This means that when the _MainThread instance created by + 'threading' tries to clean itself up when atexit calls this method it + gets a key error if another Thread instance was created since that + removed the only thing with the key of -1. + + This all means that KeyError from trying to delete something from + _active if dummy_threading is being used is a red herring. But since + it isn't if dummy_threading is *not* being used then don't hide the + exception. Also don't need to worry about issues from interpreter + shutdown and sys not being defined because the call is protected by a + blanket try/except block where that could be a problem. + + """ _active_limbo_lock.acquire() ! if _sys.modules.has_key('dummy_threading'): ! try: ! del _active[_get_ident()] ! except KeyError: ! pass ! else: ! del _active[_get_ident()] _active_limbo_lock.release() From bcannon at users.sourceforge.net Wed Jul 21 04:55:57 2004 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Wed Jul 21 04:56:03 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS, 1.831.4.133, 1.831.4.134 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29871/Misc Modified Files: Tag: release23-maint NEWS Log Message: dummy_threading when run with -O would raise a KeyError in Thread.__delete() when called by atexit thanks to dummy_thread always returning -1 for dummy_thread.get_ident(). Since exception was not an issue, it is now caught and tossed. Closes bug #993394. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.831.4.133 retrieving revision 1.831.4.134 diff -C2 -d -r1.831.4.133 -r1.831.4.134 *** NEWS 12 Jul 2004 13:10:45 -0000 1.831.4.133 --- NEWS 21 Jul 2004 02:55:54 -0000 1.831.4.134 *************** *** 44,47 **** --- 44,52 ---- ------- + - Bug #993394. A KeyError was being raised by Thread.__delete() for + dummy_threading when called by atexit if an instance of Thread was created in + an interpreter running in -O. The exception was of no importance and thus is + now thrown away if raised. + - Bug #930024: posixpath.realpath() now detects loops from symlinks and returns the longest path before the loop begins. From kbk at users.sourceforge.net Wed Jul 21 05:34:00 2004 From: kbk at users.sourceforge.net (kbk@users.sourceforge.net) Date: Wed Jul 21 05:34:04 2004 Subject: [Python-checkins] python/dist/src/Lib/idlelib EditorWindow.py, 1.60, 1.61 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/idlelib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3448 Modified Files: EditorWindow.py Log Message: EditorWindow.py was not finding the .chm help file on Windows. Typo at Rev 1.54. Python Bug 990954 Index: EditorWindow.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/EditorWindow.py,v retrieving revision 1.60 retrieving revision 1.61 diff -C2 -d -r1.60 -r1.61 *** EditorWindow.py 15 Jul 2004 04:54:57 -0000 1.60 --- EditorWindow.py 21 Jul 2004 03:33:58 -0000 1.61 *************** *** 62,66 **** 'Doc', 'index.html') elif sys.platform[:3] == 'win': ! chmfile = os.path.join(sys.prefix, "Python%d%d.chm" % sys.version_info[:2]) if os.path.isfile(chmfile): dochome = chmfile --- 62,67 ---- 'Doc', 'index.html') elif sys.platform[:3] == 'win': ! chmfile = os.path.join(sys.prefix, 'Doc', ! 'Python%d%d.chm' % sys.version_info[:2]) if os.path.isfile(chmfile): dochome = chmfile From tim_one at users.sourceforge.net Wed Jul 21 05:36:54 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Wed Jul 21 05:36:57 2004 Subject: [Python-checkins] python/dist/src/Lib threading.py,1.44,1.45 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3345/Lib Modified Files: threading.py Log Message: Thread.__delete: Discussion of internal obscurities belongs in comments rather than in docstrings. Rewrote so that _active_limbo_lock is released no matter what happens (it could have been left locked if _sys got None'd out). Use "in" in preference to has_key() for dict lookup. Don't bother looking for 'dummy_threading' in sys.modules unless KeyError is raised. Since the heart of the method is the del, do that in only one place. Index: threading.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/threading.py,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** threading.py 21 Jul 2004 02:21:57 -0000 1.44 --- threading.py 21 Jul 2004 03:36:52 -0000 1.45 *************** *** 494,532 **** def __delete(self): ! """Remove the current thread from the dict of currently running ! threads. ! ! Must take care to not raise an exception if dummy_thread is being used ! (and thus this module is being used as an instance of dummy_threading). ! Since dummy_thread.get_ident() always returns -1 since there is only one ! thread if dummy_thread is being used. This means that if any Thread ! instances are created they will overwrite any other threads registered. ! ! This is an issue with this method, though, since an instance of ! _MainThread is always created by 'threading'. This gets overwritten the ! instant an instance of Thread is created; both threads will have -1 as ! their value from dummy_thread.get_ident() and thus have the same key in ! the dict. This means that when the _MainThread instance created by ! 'threading' tries to clean itself up when atexit calls this method it ! gets a key error if another Thread instance was created since that ! removed the only thing with the key of -1. ! This all means that KeyError from trying to delete something from ! _active if dummy_threading is being used is a red herring. But since ! it isn't if dummy_threading is *not* being used then don't hide the ! exception. Also don't need to worry about issues from interpreter ! shutdown and sys not being defined because the call is protected by a ! blanket try/except block where that could be a problem. - """ _active_limbo_lock.acquire() ! if _sys.modules.has_key('dummy_threading'): try: del _active[_get_ident()] except KeyError: ! pass ! else: ! del _active[_get_ident()] ! _active_limbo_lock.release() def join(self, timeout=None): --- 494,529 ---- def __delete(self): ! "Remove current thread from the dict of currently running threads." ! # Notes about running with dummy_thread: ! # ! # Must take care to not raise an exception if dummy_thread is being ! # used (and thus this module is being used as an instance of ! # dummy_threading). dummy_thread.get_ident() always returns -1 since ! # there is only one thread if dummy_thread is being used. Thus ! # len(_active) is always <= 1 here, and any Thread instance created ! # overwrites the (if any) thread currently registered in _active. ! # ! # An instance of _MainThread is always created by 'threading'. This ! # gets overwritten the instant an instance of Thread is created; both ! # threads return -1 from dummy_thread.get_ident() and thus have the ! # same key in the dict. So when the _MainThread instance created by ! # 'threading' tries to clean itself up when atexit calls this method ! # it gets a KeyError if another Thread instance was created. ! # ! # This all means that KeyError from trying to delete something from ! # _active if dummy_threading is being used is a red herring. But ! # since it isn't if dummy_threading is *not* being used then don't ! # hide the exception. _active_limbo_lock.acquire() ! try: try: del _active[_get_ident()] except KeyError: ! if 'dummy_threading' not in _sys.modules: ! raise ! finally: ! _active_limbo_lock.release() def join(self, timeout=None): From bcannon at users.sourceforge.net Wed Jul 21 07:08:35 2004 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Wed Jul 21 07:08:42 2004 Subject: [Python-checkins] python/dist/src/Lib threading.py, 1.38.6.3, 1.38.6.4 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14616/Lib Modified Files: Tag: release23-maint threading.py Log Message: Backport Tim's cleanup of the previous commit to fix Thread.__delete() . Index: threading.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/threading.py,v retrieving revision 1.38.6.3 retrieving revision 1.38.6.4 diff -C2 -d -r1.38.6.3 -r1.38.6.4 *** threading.py 21 Jul 2004 02:55:54 -0000 1.38.6.3 --- threading.py 21 Jul 2004 05:08:32 -0000 1.38.6.4 *************** *** 493,531 **** def __delete(self): ! """Remove the current thread from the dict of currently running ! threads. ! ! Must take care to not raise an exception if dummy_thread is being used ! (and thus this module is being used as an instance of dummy_threading). ! Since dummy_thread.get_ident() always returns -1 since there is only one ! thread if dummy_thread is being used. This means that if any Thread ! instances are created they will overwrite any other threads registered. ! ! This is an issue with this method, though, since an instance of ! _MainThread is always created by 'threading'. This gets overwritten the ! instant an instance of Thread is created; both threads will have -1 as ! their value from dummy_thread.get_ident() and thus have the same key in ! the dict. This means that when the _MainThread instance created by ! 'threading' tries to clean itself up when atexit calls this method it ! gets a key error if another Thread instance was created since that ! removed the only thing with the key of -1. ! This all means that KeyError from trying to delete something from ! _active if dummy_threading is being used is a red herring. But since ! it isn't if dummy_threading is *not* being used then don't hide the ! exception. Also don't need to worry about issues from interpreter ! shutdown and sys not being defined because the call is protected by a ! blanket try/except block where that could be a problem. - """ _active_limbo_lock.acquire() ! if _sys.modules.has_key('dummy_threading'): try: del _active[_get_ident()] except KeyError: ! pass ! else: ! del _active[_get_ident()] ! _active_limbo_lock.release() def join(self, timeout=None): --- 493,528 ---- def __delete(self): ! "Remove current thread from the dict of currently running threads." ! # Notes about running with dummy_thread: ! # ! # Must take care to not raise an exception if dummy_thread is being ! # used (and thus this module is being used as an instance of ! # dummy_threading). dummy_thread.get_ident() always returns -1 since ! # there is only one thread if dummy_thread is being used. Thus ! # len(_active) is always <= 1 here, and any Thread instance created ! # overwrites the (if any) thread currently registered in _active. ! # ! # An instance of _MainThread is always created by 'threading'. This ! # gets overwritten the instant an instance of Thread is created; both ! # threads return -1 from dummy_thread.get_ident() and thus have the ! # same key in the dict. So when the _MainThread instance created by ! # 'threading' tries to clean itself up when atexit calls this method ! # it gets a KeyError if another Thread instance was created. ! # ! # This all means that KeyError from trying to delete something from ! # _active if dummy_threading is being used is a red herring. But ! # since it isn't if dummy_threading is *not* being used then don't ! # hide the exception. _active_limbo_lock.acquire() ! try: try: del _active[_get_ident()] except KeyError: ! if 'dummy_threading' not in _sys.modules: ! raise ! finally: ! _active_limbo_lock.release() def join(self, timeout=None): From loewis at users.sourceforge.net Wed Jul 21 07:34:51 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Wed Jul 21 07:34:55 2004 Subject: [Python-checkins] python/dist/src/Python pythonrun.c, 2.195.6.5, 2.195.6.6 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17877/Python Modified Files: Tag: release23-maint pythonrun.c Log Message: Patch #984714: Properly diagnose E_DECODE errors. Index: pythonrun.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/pythonrun.c,v retrieving revision 2.195.6.5 retrieving revision 2.195.6.6 diff -C2 -d -r2.195.6.5 -r2.195.6.6 *** pythonrun.c 22 Mar 2004 20:41:47 -0000 2.195.6.5 --- pythonrun.c 21 Jul 2004 05:34:47 -0000 2.195.6.6 *************** *** 1483,1486 **** --- 1483,1489 ---- } } + if (msg == NULL) + msg = "unknown decode error"; + break; } default: From loewis at users.sourceforge.net Wed Jul 21 07:35:05 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Wed Jul 21 07:35:07 2004 Subject: [Python-checkins] python/dist/src/Python pythonrun.c,2.206,2.207 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18000/Python Modified Files: pythonrun.c Log Message: Patch #984714: Properly diagnose E_DECODE errors. Backported to 2.3. Index: pythonrun.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/pythonrun.c,v retrieving revision 2.206 retrieving revision 2.207 diff -C2 -d -r2.206 -r2.207 *** pythonrun.c 7 Jul 2004 17:44:12 -0000 2.206 --- pythonrun.c 21 Jul 2004 05:35:02 -0000 2.207 *************** *** 1472,1475 **** --- 1472,1478 ---- } } + if (msg == NULL) + msg = "unknown decode error"; + break; } default: From akuchling at users.sourceforge.net Wed Jul 21 14:30:22 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Wed Jul 21 14:30:26 2004 Subject: [Python-checkins] python/nondist/peps pep-0331.txt,1.2,1.3 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13858 Modified Files: pep-0331.txt Log Message: Fix typo Index: pep-0331.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0331.txt,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** pep-0331.txt 19 Jul 2004 23:09:04 -0000 1.2 --- pep-0331.txt 21 Jul 2004 12:30:07 -0000 1.3 *************** *** 156,160 **** An implementation was developed by Gustavo Carneiro , and attached to Sourceforge.net bug 744665 [10] The final patch [11] was integrated into Python CVS by Martin v. --- 156,160 ---- An implementation was developed by Gustavo Carneiro , and attached to Sourceforge.net bug 774665 [10] The final patch [11] was integrated into Python CVS by Martin v. From akuchling at users.sourceforge.net Wed Jul 21 14:41:56 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Wed Jul 21 14:41:59 2004 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew24.tex, 1.70, 1.71 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15495 Modified Files: whatsnew24.tex Log Message: Add PEP 331; add constancy of None; minor edits Index: whatsnew24.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew24.tex,v retrieving revision 1.70 retrieving revision 1.71 diff -C2 -d -r1.70 -r1.71 *** whatsnew24.tex 17 Jul 2004 13:53:48 -0000 1.70 --- whatsnew24.tex 21 Jul 2004 12:41:38 -0000 1.71 *************** *** 1,3 **** - \documentclass{howto} \usepackage{distutils} --- 1,2 ---- *************** *** 445,448 **** --- 444,485 ---- %====================================================================== + \section{PEP 331: Locale-Independent Float/String Conversions} + + The \module{locale} modules lets Python software select various + conversions and display conventions that are localized to a particular + country or language. However, the module was careful to not change + the numeric locale because various functions in Python's + implementation required that the numeric locale remain set to the + \code{'C'} locale. Often this was because the code was using the C library's + \cfunction{atof()} function. + + Not setting the numeric locale caused trouble for extensions that used + third-party C libraries, however, because they wouldn't have the + correct locale set. The motivating example was GTK+, whose user + interface widgets weren't displaying numbers in the current locale. + + The solution described in the PEP is to add three new functions to the + Python API that perform ASCII-only conversions, ignoring the locale + setting: + + \begin{itemize} + \item \cfunction{PyOS_ascii_strtod(\var{str}, \var{ptr})} + and \cfunction{PyOS_ascii_atof(\var{str}, \var{ptr})} + both convert a string to a C \ctype{double}. + \item \cfunction{PyOS_ascii_formatd(\var{buffer}, \var{buf_len}, \var{format}, \var{d})} converts a \ctype{double} to an ASCII string. + \end{itemize} + + The code for these functions came from the GLib library + (\url{http://developer.gnome.org/arch/gtk/glib.html}), whose + developers kindly relicensed the relevant functions and donated them + to the Python Software Foundation. The \module{locale} module + can now change the numeric locale, letting extensions such as GTK+ + produce the correct results. + + \begin{seealso} + \seepep{331}{Locale-Independent Float/String Conversions}{Written by Christian R. Reis, and implemented by Gustavo Carneiro.} + \end{seealso} + + %====================================================================== \section{Other Language Changes} *************** *** 579,582 **** --- 616,622 ---- \end{verbatim} + \item \constant{None} is now a constant; code that binds a new value to + the name \samp{None} is now a syntax error. + \end{itemize} *************** *** 588,595 **** \item The inner loops for list and tuple slicing ! were optimized and now run about one-third faster. The inner ! loops were also optimized for dictionaries with performance ! boosts to \method{keys()}, \method{values()}, \method{items()}, ! \method{iterkeys()}, \method{itervalues()}, and \method{iteritems()}. \item The machinery for growing and shrinking lists was optimized for --- 628,635 ---- \item The inner loops for list and tuple slicing ! were optimized and now run about one-third faster. The inner loops ! were also optimized for dictionaries, resulting in performance boosts for ! \method{keys()}, \method{values()}, \method{items()}, ! \method{iterkeys()}, \method{itervalues()}, and \method{iteritems()}. \item The machinery for growing and shrinking lists was optimized for From akuchling at users.sourceforge.net Wed Jul 21 15:00:11 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Wed Jul 21 15:00:13 2004 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew24.tex, 1.71, 1.72 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17968 Modified Files: whatsnew24.tex Log Message: Update Decimal section to match the current module Index: whatsnew24.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew24.tex,v retrieving revision 1.71 retrieving revision 1.72 diff -C2 -d -r1.71 -r1.72 *** whatsnew24.tex 21 Jul 2004 12:41:38 -0000 1.71 --- whatsnew24.tex 21 Jul 2004 13:00:06 -0000 1.72 *************** *** 269,273 **** The inaccuracy isn't always visible when you print the number because ! the FP-to-decimal-string conversion is provided by the C library, and most C libraries try to produce sensible output, but the inaccuracy is still there and subsequent operations can magnify the error. --- 269,273 ---- The inaccuracy isn't always visible when you print the number because ! the FP-to-decimal-string conversion is provided by the C library and most C libraries try to produce sensible output, but the inaccuracy is still there and subsequent operations can magnify the error. *************** *** 320,325 **** >>> decimal.Decimal(str(f)) Decimal("1.1") ! >>> decimal.Decimal(repr(f)) ! Decimal("1.1000000000000001") \end{verbatim} --- 320,325 ---- >>> decimal.Decimal(str(f)) Decimal("1.1") ! >>> decimal.Decimal('%.12f' % f) ! Decimal("1.100000000000") \end{verbatim} *************** *** 338,346 **** Decimal("61.7956") >>> a/b ! Decimal("20.6473988") >>> a ** 2 Decimal("1275.9184") ! >>> a ** b ! Decimal("NaN") \end{verbatim} --- 338,348 ---- Decimal("61.7956") >>> a/b ! Decimal("20.64739884393063583815028902") >>> a ** 2 Decimal("1275.9184") ! >>> a**b ! Traceback (most recent call last): ! ... ! decimal.InvalidOperation: x ** (non-integer) \end{verbatim} *************** *** 359,364 **** \class{Decimal} numbers can be used with the \module{math} and ! \module{cmath} modules, though you'll get back a regular ! floating-point number and not a \class{Decimal}. Instances also have a \method{sqrt()} method: \begin{verbatim} --- 361,368 ---- \class{Decimal} numbers can be used with the \module{math} and ! \module{cmath} modules, but note that they'll be immediately converted to ! floating-point numbers before the operation is performed, resulting in ! a possible loss of precision and accuracy. You'll also get back a ! regular floating-point number and not a \class{Decimal}. \begin{verbatim} *************** *** 369,372 **** --- 373,383 ---- >>> cmath.sqrt(-d) 351364.18288201344j + \end{verbatim} + + Instances also have a \method{sqrt()} method that returns a + \class{Decimal}, but if you need other things such as trigonometric + functions you'll have to implement them. + + \begin{verbatim} >>> d.sqrt() Decimal("351364.1828820134592177245001") *************** *** 384,388 **** module has constants for the various possibilities: \constant{ROUND_DOWN}, \constant{ROUND_CEILING}, \constant{ROUND_HALF_EVEN}, and various others. ! \item \member{trap_enablers} is a dictionary specifying what happens on encountering certain error conditions: either an exception is raised or a value is returned. Some examples of error conditions are --- 395,399 ---- module has constants for the various possibilities: \constant{ROUND_DOWN}, \constant{ROUND_CEILING}, \constant{ROUND_HALF_EVEN}, and various others. ! \item \member{traps} is a dictionary specifying what happens on encountering certain error conditions: either an exception is raised or a value is returned. Some examples of error conditions are *************** *** 404,419 **** \end{verbatim} ! The default action for error conditions is to return a special value ! such as infinity or not-a-number, but you can request that exceptions ! be raised: \begin{verbatim} >>> decimal.Decimal(1) / decimal.Decimal(0) - Decimal("Infinity") - >>> decimal.getcontext().trap_enablers[decimal.DivisionByZero] = True - >>> decimal.Decimal(1) / decimal.Decimal(0) Traceback (most recent call last): ... decimal.DivisionByZero: x / 0 >>> \end{verbatim} --- 415,430 ---- \end{verbatim} ! The default action for error conditions is selectable; the module can ! either return a special value such as infinity or not-a-number, or ! exceptions can be raised: \begin{verbatim} >>> decimal.Decimal(1) / decimal.Decimal(0) Traceback (most recent call last): ... decimal.DivisionByZero: x / 0 + >>> decimal.getcontext().traps[decimal.DivisionByZero] = False + >>> decimal.Decimal(1) / decimal.Decimal(0) + Decimal("Infinity") >>> \end{verbatim} *************** *** 422,426 **** numbers such as \method{to_eng_string()} and \method{to_sci_string()}. ! \begin{seealso} \seepep{327}{Decimal Data Type}{Written by Facundo Batista and implemented --- 433,439 ---- numbers such as \method{to_eng_string()} and \method{to_sci_string()}. ! For more information, see the documentation for the \module{decimal} ! module, which includes a quick-start tutorial and a reference. ! \begin{seealso} \seepep{327}{Decimal Data Type}{Written by Facundo Batista and implemented From vsajip at users.sourceforge.net Wed Jul 21 16:40:14 2004 From: vsajip at users.sourceforge.net (vsajip@users.sourceforge.net) Date: Wed Jul 21 16:40:17 2004 Subject: [Python-checkins] python/dist/src/Doc/lib liblogging.tex,1.21,1.22 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2995 Modified Files: liblogging.tex Log Message: Added an extra example to the basic example section Index: liblogging.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/liblogging.tex,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** liblogging.tex 12 Jul 2004 15:48:04 -0000 1.21 --- liblogging.tex 21 Jul 2004 14:40:11 -0000 1.22 *************** *** 471,474 **** --- 471,495 ---- the \var{stream} argument is ignored. + Of course, you can put variable information in your output. To do this, + simply have the message be a format string and pass in additional arguments + containing the variable information, as in the following example: + + \begin{verbatim} + import logging + + logging.basicConfig(level=logging.DEBUG, + format='%(asctime)s %(levelname)-8s %(message)s', + datefmt='%a, %d %b %Y %H:%M:%S', + filename='/temp/myapp.log', + filemode='w') + logging.error('Pack my box with %d dozen %s', 12, 'liquor jugs') + \end{verbatim} + + which would result in + + \begin{verbatim} + Wed, 21 Jul 2004 15:35:16 ERROR Pack my box with 12 dozen liquor jugs + \end{verbatim} + \subsection{Handler Objects} From fdrake at users.sourceforge.net Wed Jul 21 18:25:39 2004 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Wed Jul 21 18:25:41 2004 Subject: [Python-checkins] python/dist/src/Doc/tut tut.tex, 1.196.8.20, 1.196.8.21 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/tut In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26142 Modified Files: Tag: release23-maint tut.tex Log Message: revise wording to avoid confusion for non-native English speakers Index: tut.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/tut/tut.tex,v retrieving revision 1.196.8.20 retrieving revision 1.196.8.21 diff -C2 -d -r1.196.8.20 -r1.196.8.21 *** tut.tex 12 Jun 2004 19:29:54 -0000 1.196.8.20 --- tut.tex 21 Jul 2004 16:25:35 -0000 1.196.8.21 *************** *** 690,694 **** >>> word[:2] # The first two characters 'He' ! >>> word[2:] # All but the first two characters 'lpA' \end{verbatim} --- 690,694 ---- >>> word[:2] # The first two characters 'He' ! >>> word[2:] # Everything except the first two characters 'lpA' \end{verbatim} From fdrake at users.sourceforge.net Wed Jul 21 19:18:22 2004 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Wed Jul 21 19:18:25 2004 Subject: [Python-checkins] python/dist/src/Doc/tut tut.tex,1.241,1.242 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/tut In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5979 Modified Files: tut.tex Log Message: revise wording to avoid confusion for non-native English speakers Index: tut.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/tut/tut.tex,v retrieving revision 1.241 retrieving revision 1.242 diff -C2 -d -r1.241 -r1.242 *** tut.tex 11 Jul 2004 12:49:47 -0000 1.241 --- tut.tex 21 Jul 2004 17:18:19 -0000 1.242 *************** *** 690,694 **** >>> word[:2] # The first two characters 'He' ! >>> word[2:] # All but the first two characters 'lpA' \end{verbatim} --- 690,694 ---- >>> word[:2] # The first two characters 'He' ! >>> word[2:] # Everything except the first two characters 'lpA' \end{verbatim} From fdrake at users.sourceforge.net Wed Jul 21 19:34:53 2004 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Wed Jul 21 19:34:57 2004 Subject: [Python-checkins] python/dist/src/Doc/tut tut.tex, 1.196.8.21, 1.196.8.22 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/tut In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10245/tut Modified Files: Tag: release23-maint tut.tex Log Message: revise wording to avoid confusion for non-native English speakers (second occurance of the same wording) Index: tut.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/tut/tut.tex,v retrieving revision 1.196.8.21 retrieving revision 1.196.8.22 diff -C2 -d -r1.196.8.21 -r1.196.8.22 *** tut.tex 21 Jul 2004 16:25:35 -0000 1.196.8.21 --- tut.tex 21 Jul 2004 17:34:49 -0000 1.196.8.22 *************** *** 751,755 **** >>> word[-2:] # The last two characters 'pA' ! >>> word[:-2] # All but the last two characters 'Hel' \end{verbatim} --- 751,755 ---- >>> word[-2:] # The last two characters 'pA' ! >>> word[:-2] # Everything except the last two characters 'Hel' \end{verbatim} From fdrake at users.sourceforge.net Wed Jul 21 19:36:50 2004 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Wed Jul 21 19:36:53 2004 Subject: [Python-checkins] python/dist/src/Doc/tut tut.tex,1.242,1.243 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/tut In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10647/tut Modified Files: tut.tex Log Message: revise wording to avoid confusion for non-native English speakers (second occurance of the same wording) Index: tut.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/tut/tut.tex,v retrieving revision 1.242 retrieving revision 1.243 diff -C2 -d -r1.242 -r1.243 *** tut.tex 21 Jul 2004 17:18:19 -0000 1.242 --- tut.tex 21 Jul 2004 17:36:47 -0000 1.243 *************** *** 751,755 **** >>> word[-2:] # The last two characters 'pA' ! >>> word[:-2] # All but the last two characters 'Hel' \end{verbatim} --- 751,755 ---- >>> word[-2:] # The last two characters 'pA' ! >>> word[:-2] # Everything except the last two characters 'Hel' \end{verbatim} From fdrake at users.sourceforge.net Wed Jul 21 20:53:09 2004 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Wed Jul 21 20:53:13 2004 Subject: [Python-checkins] python/dist/src/Lib/distutils/tests test_build_py.py, 1.2, 1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils/tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30525 Modified Files: test_build_py.py Log Message: elaborate package data test to make sure get_outputs() gives the right results when byte-code compilation is requested (in particular, make sure that package data doesn't get a bogus byte-code listing generated) Index: test_build_py.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/tests/test_build_py.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** test_build_py.py 25 Jun 2004 19:04:20 -0000 1.2 --- test_build_py.py 21 Jul 2004 18:53:06 -0000 1.3 *************** *** 35,38 **** --- 35,39 ---- cmd = build_py(dist) + cmd.compile = 1 cmd.ensure_finalized() self.assertEqual(cmd.package_data, dist.package_data) *************** *** 40,47 **** cmd.run() ! self.assertEqual(len(cmd.get_outputs()), 2) pkgdest = os.path.join(destination, "pkg") files = os.listdir(pkgdest) self.assert_("__init__.py" in files) self.assert_("README.txt" in files) --- 41,53 ---- cmd.run() ! # This makes sure the list of outputs includes byte-compiled ! # files for Python modules but not for package data files ! # (there shouldn't *be* byte-code files for those!). ! # ! self.assertEqual(len(cmd.get_outputs()), 3) pkgdest = os.path.join(destination, "pkg") files = os.listdir(pkgdest) self.assert_("__init__.py" in files) + self.assert_("__init__.pyc" in files) self.assert_("README.txt" in files) From akuchling at users.sourceforge.net Wed Jul 21 23:22:54 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Wed Jul 21 23:22:57 2004 Subject: [Python-checkins] python/nondist/peps pep-0263.txt,1.16,1.17 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv731 Modified Files: pep-0263.txt Log Message: [Bug #995522] Fix regex Index: pep-0263.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0263.txt,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** pep-0263.txt 21 Feb 2003 15:24:41 -0000 1.16 --- pep-0263.txt 21 Jul 2004 21:22:51 -0000 1.17 *************** *** 1,2 **** --- 1,3 ---- + PEP: 0263 Title: Defining Python Source Code Encodings *************** *** 53,57 **** More precisely, the first or second line must match the regular ! expression "coding[:=]\s*([\w-_.]+)". The first group of this expression is then interpreted as encoding name. If the encoding is unknown to Python, an error is raised during compilation. There --- 54,58 ---- More precisely, the first or second line must match the regular ! expression "coding[:=]\s*([-\w_.]+)". The first group of this expression is then interpreted as encoding name. If the encoding is unknown to Python, an error is raised during compilation. There From akuchling at users.sourceforge.net Wed Jul 21 23:34:47 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Wed Jul 21 23:34:50 2004 Subject: [Python-checkins] python/dist/src/Doc/mac undoc.tex,1.12,1.13 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/mac In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2970 Modified Files: undoc.tex Log Message: [Bug #990524] Fix typo Index: undoc.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/mac/undoc.tex,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** undoc.tex 4 Sep 2003 19:52:02 -0000 1.12 --- undoc.tex 21 Jul 2004 21:34:45 -0000 1.13 *************** *** 74,78 **** \section{\module{Nav} --- NavServices calls} ! \declaremodule{standard}{Nac} \platform{Mac} \modulesynopsis{Interface to Navigation Services.} --- 74,78 ---- \section{\module{Nav} --- NavServices calls} ! \declaremodule{standard}{Nav} \platform{Mac} \modulesynopsis{Interface to Navigation Services.} From akuchling at users.sourceforge.net Wed Jul 21 23:35:16 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Wed Jul 21 23:35:19 2004 Subject: [Python-checkins] python/dist/src/Doc/mac undoc.tex, 1.9.14.2, 1.9.14.3 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/mac In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3079 Modified Files: Tag: release23-maint undoc.tex Log Message: [Bug #990524] Fix typo Index: undoc.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/mac/undoc.tex,v retrieving revision 1.9.14.2 retrieving revision 1.9.14.3 diff -C2 -d -r1.9.14.2 -r1.9.14.3 *** undoc.tex 7 Aug 2003 16:10:28 -0000 1.9.14.2 --- undoc.tex 21 Jul 2004 21:35:13 -0000 1.9.14.3 *************** *** 74,78 **** \section{\module{Nav} --- NavServices calls} ! \declaremodule{standard}{Nac} \platform{Mac} \modulesynopsis{Interface to Navigation Services.} --- 74,78 ---- \section{\module{Nav} --- NavServices calls} ! \declaremodule{standard}{Nav} \platform{Mac} \modulesynopsis{Interface to Navigation Services.} From tim_one at users.sourceforge.net Thu Jul 22 02:54:40 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Thu Jul 22 02:54:43 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1049,1.1050 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6732/Misc Modified Files: NEWS Log Message: SF patch 995225: tarfile.py fix for bug #990325 Removes CVS keywords from this binary file, so that test_tarfile passes regardless of whether Python is checked out with -kk. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1049 retrieving revision 1.1050 diff -C2 -d -r1.1049 -r1.1050 *** NEWS 21 Jul 2004 02:21:58 -0000 1.1049 --- NEWS 22 Jul 2004 00:54:37 -0000 1.1050 *************** *** 48,52 **** - Patch #846659. Fix an error in tarfile.py when using ! GNU longname/longlink creation. - The obsolete FCNTL.py has been deleted. The builtin fcntl module --- 48,52 ---- - Patch #846659. Fix an error in tarfile.py when using ! GNU longname/longlink creation. - The obsolete FCNTL.py has been deleted. The builtin fcntl module *************** *** 145,151 **** ----- ! - The test data files for the decimal test suite are now installed on platforms that use the Makefile. Windows ------- --- 145,155 ---- ----- ! - The test data files for the decimal test suite are now installed on platforms that use the Makefile. + - SF patch 995225: The test file testtar.tar accidentally contained + CVS keywords (like $Id$), which could cause spurious failures in + test_tarfile.py depending on how the test file was checked out. + Windows ------- From tim_one at users.sourceforge.net Thu Jul 22 02:54:40 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Thu Jul 22 02:54:44 2004 Subject: [Python-checkins] python/dist/src/Lib/test testtar.tar,1.1,1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6732/Lib/test Modified Files: testtar.tar Log Message: SF patch 995225: tarfile.py fix for bug #990325 Removes CVS keywords from this binary file, so that test_tarfile passes regardless of whether Python is checked out with -kk. Index: testtar.tar =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/testtar.tar,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 Binary files /tmp/cvs9cHUfh and /tmp/cvsZX4okn differ From tim_one at users.sourceforge.net Thu Jul 22 03:46:45 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Thu Jul 22 03:46:48 2004 Subject: [Python-checkins] python/dist/src/Include boolobject.h, 1.7, 1.8 object.h, 2.127, 2.128 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13706/Include Modified Files: boolobject.h object.h Log Message: SF bug 994255: Py_RETURN_NONE causes too much warnings Rewrote Py_RETURN_{NONE, TRUE, FALSE} to expand to comma expressions rather than "do {} while(0)" thingies. The OP complained because he likes using MS /W4 sometimes, and then all his uses of these things generate nuisance warnings about testing a constant expression (in the "while(0)" part). Comma expressions don't have this problem (although it's a lucky accident that comma expressions suffice for these macros!). Index: boolobject.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/boolobject.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** boolobject.h 19 Oct 2003 22:58:10 -0000 1.7 --- boolobject.h 22 Jul 2004 01:46:43 -0000 1.8 *************** *** 25,30 **** /* Macros for returning Py_True or Py_False, respectively */ ! #define Py_RETURN_TRUE do {Py_INCREF(Py_True); return Py_True;} while (0) ! #define Py_RETURN_FALSE do {Py_INCREF(Py_False); return Py_False;} while (0) /* Function to return a bool from a C long */ --- 25,30 ---- /* Macros for returning Py_True or Py_False, respectively */ ! #define Py_RETURN_TRUE return Py_INCREF(Py_True), Py_True ! #define Py_RETURN_FALSE return Py_INCREF(Py_False), Py_False /* Function to return a bool from a C long */ Index: object.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/object.h,v retrieving revision 2.127 retrieving revision 2.128 diff -C2 -d -r2.127 -r2.128 *** object.h 14 Jul 2004 19:07:35 -0000 2.127 --- object.h 22 Jul 2004 01:46:43 -0000 2.128 *************** *** 651,655 **** /* Macro for returning Py_None from a function */ ! #define Py_RETURN_NONE do {Py_INCREF(Py_None); return Py_None;} while (0) /* --- 651,655 ---- /* Macro for returning Py_None from a function */ ! #define Py_RETURN_NONE return Py_INCREF(Py_None), Py_None /* From kyouryoku at sitteru.servebeer.com Thu Jul 22 16:37:24 2004 From: kyouryoku at sitteru.servebeer.com (kyouryoku@sitteru.servebeer.com) Date: Thu Jul 22 16:37:35 2004 Subject: [Python-checkins] =?utf-8?b?wpBswo3DiMKDQcKDaMKDwozCg1jCksKg?= Message-ID: <20040722143724.E9A441E4007@bag.python.org> *:??,??'?:*:??,? ?????? ?13??*:??,??'?:*:??,? ????????????????????????? ???????????????????????? ?????????????????????? ????????????????????????????????????????????? ??????????????????? ????????????????????????????????????? ????????????????????? ??????????????? ???????????????????????????????????????? ?????????????????? ???????????????????????? ??????????????????? ??????????????????????????? http://pc.gal-mail.com/?s01 ??????????????? http://pc.gal-mail.com/?s01 ???????????????????????????????????????? ??????????????????????????? ???????????????????????????? ???????????????????????No.1???? ????????????????????????????? ???????????????????????????????? ???ko!???????????????????????????? ?????????? http://gannba.servepics.com/?g02 ????????????????????????????????????? ????????????????????????????????? http://gannba.servepics.com/?g02 ???????????????????????????????????????? ?????? ????????????????????????????????? 9?????????????????? ???????????????????????????????????? ??????????????????? ???????????????????????????????????????? ?????????????????????????????????????? ????????????????????????? ??????????????????? From niemeyer at users.sourceforge.net Thu Jul 22 20:44:02 2004 From: niemeyer at users.sourceforge.net (niemeyer@users.sourceforge.net) Date: Thu Jul 22 20:44:05 2004 Subject: [Python-checkins] python/dist/src configure.in, 1.462, 1.463 pyconfig.h.in, 1.100, 1.101 Message-ID: Update of /cvsroot/python/python/dist/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3065 Modified Files: configure.in pyconfig.h.in Log Message: This change implements the following gettext features, as discussed recently in python-dev: In _locale module: - bind_textdomain_codeset() binding In gettext module: - bind_textdomain_codeset() function - lgettext(), lngettext(), ldgettext(), ldngettext(), which return translated strings encoded in preferred system encoding, if bind_textdomain_codeset() was not used. - Added equivalent functionality in translate() function and catalog classes. Every change was also documented. Index: configure.in =================================================================== RCS file: /cvsroot/python/python/dist/src/configure.in,v retrieving revision 1.462 retrieving revision 1.463 diff -C2 -d -r1.462 -r1.463 *** configure.in 16 Jul 2004 08:42:35 -0000 1.462 --- configure.in 22 Jul 2004 18:43:59 -0000 1.463 *************** *** 2045,2050 **** # checks for library functions ! AC_CHECK_FUNCS(alarm chown clock confstr ctermid execv \ ! fork fpathconf ftime ftruncate \ gai_strerror getgroups getlogin getloadavg getpeername getpgid getpid \ getpriority getpwent getsid getwd \ --- 2045,2050 ---- # checks for library functions ! AC_CHECK_FUNCS(alarm bind_textdomain_codeset chown clock confstr ctermid \ ! execv fork fpathconf ftime ftruncate \ gai_strerror getgroups getlogin getloadavg getpeername getpgid getpid \ getpriority getpwent getsid getwd \ Index: pyconfig.h.in =================================================================== RCS file: /cvsroot/python/python/dist/src/pyconfig.h.in,v retrieving revision 1.100 retrieving revision 1.101 diff -C2 -d -r1.100 -r1.101 *** pyconfig.h.in 7 Jul 2004 17:44:09 -0000 1.100 --- pyconfig.h.in 22 Jul 2004 18:43:59 -0000 1.101 *************** *** 38,41 **** --- 38,44 ---- #undef HAVE_ALTZONE + /* Define to 1 if you have the `bind_textdomain_codeset' function. */ + #undef HAVE_BIND_TEXTDOMAIN_CODESET + /* Define to 1 if you have the header file. */ #undef HAVE_BLUETOOTH_BLUETOOTH_H From niemeyer at users.sourceforge.net Thu Jul 22 20:44:02 2004 From: niemeyer at users.sourceforge.net (niemeyer@users.sourceforge.net) Date: Thu Jul 22 20:44:07 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libgettext.tex, 1.24, 1.25 liblocale.tex, 1.36, 1.37 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3065/Doc/lib Modified Files: libgettext.tex liblocale.tex Log Message: This change implements the following gettext features, as discussed recently in python-dev: In _locale module: - bind_textdomain_codeset() binding In gettext module: - bind_textdomain_codeset() function - lgettext(), lngettext(), ldgettext(), ldngettext(), which return translated strings encoded in preferred system encoding, if bind_textdomain_codeset() was not used. - Added equivalent functionality in translate() function and catalog classes. Every change was also documented. Index: libgettext.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libgettext.tex,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** libgettext.tex 10 Jul 2004 16:01:10 -0000 1.24 --- libgettext.tex 22 Jul 2004 18:43:59 -0000 1.25 *************** *** 52,55 **** --- 52,63 ---- \end{funcdesc} + \begin{funcdesc}{bind_textdomain_codeset}{domain\optional{, codeset}} + Bind the \var{domain} to \var{codeset}, changing the encoding of + strings returned by the \function{gettext()} family of functions. + If \var{codeset} is omitted, then the current binding is returned. + + \versionadded{2.4} + \end{funcdesc} + \begin{funcdesc}{textdomain}{\optional{domain}} Change or query the current global domain. If \var{domain} is *************** *** 65,68 **** --- 73,84 ---- \end{funcdesc} + \begin{funcdesc}{lgettext}{message} + Equivalent to \function{gettext()}, but the translation is returned + in the preferred system encoding, if no other encoding was explicitly + set with \function{bind_textdomain_codeset()}. + + \versionadded{2.4} + \end{funcdesc} + \begin{funcdesc}{dgettext}{domain, message} Like \function{gettext()}, but look the message up in the specified *************** *** 70,73 **** --- 86,97 ---- \end{funcdesc} + \begin{funcdesc}{ldgettext}{domain, message} + Equivalent to \function{dgettext()}, but the translation is returned + in the preferred system encoding, if no other encoding was explicitly + set with \function{bind_textdomain_codeset()}. + + \versionadded{2.4} + \end{funcdesc} + \begin{funcdesc}{ngettext}{singular, plural, n} *************** *** 88,91 **** --- 112,123 ---- \end{funcdesc} + \begin{funcdesc}{lngettext}{singular, plural, n} + Equivalent to \function{ngettext()}, but the translation is returned + in the preferred system encoding, if no other encoding was explicitly + set with \function{bind_textdomain_codeset()}. + + \versionadded{2.4} + \end{funcdesc} + \begin{funcdesc}{dngettext}{domain, singular, plural, n} Like \function{ngettext()}, but look the message up in the specified *************** *** 95,98 **** --- 127,139 ---- \end{funcdesc} + \begin{funcdesc}{ldngettext}{domain, singular, plural, n} + Equivalent to \function{dngettext()}, but the translation is returned + in the preferred system encoding, if no other encoding was explicitly + set with \function{bind_textdomain_codeset()}. + + \versionadded{2.4} + \end{funcdesc} + + Note that GNU \program{gettext} also defines a \function{dcgettext()} *************** *** 153,158 **** \begin{funcdesc}{translation}{domain\optional{, localedir\optional{, ! languages\optional{, ! class_,\optional{fallback}}}}} Return a \class{Translations} instance based on the \var{domain}, \var{localedir}, and \var{languages}, which are first passed to --- 194,199 ---- \begin{funcdesc}{translation}{domain\optional{, localedir\optional{, ! languages\optional{, class_\optional{, ! fallback\optional{, codeset}}}}}} Return a \class{Translations} instance based on the \var{domain}, \var{localedir}, and \var{languages}, which are first passed to *************** *** 162,166 **** is either \var{class_} if provided, otherwise \class{GNUTranslations}. The class's constructor must take a single ! file object argument. If multiple files are found, later files are used as fallbacks for --- 203,208 ---- is either \var{class_} if provided, otherwise \class{GNUTranslations}. The class's constructor must take a single ! file object argument. If provided, \var{codeset} will change the ! charset used to encode translated strings. If multiple files are found, later files are used as fallbacks for *************** *** 173,183 **** and returns a \class{NullTranslations} instance if \var{fallback} is true. \end{funcdesc} ! \begin{funcdesc}{install}{domain\optional{, localedir\optional{, unicode}}} This installs the function \function{_} in Python's builtin namespace, ! based on \var{domain}, and \var{localedir} which are passed to the ! function \function{translation()}. The \var{unicode} flag is passed to ! the resulting translation object's \method{install} method. As seen below, you usually mark the strings in your application that are --- 215,229 ---- and returns a \class{NullTranslations} instance if \var{fallback} is true. + + \versionchanged[Added the \var{codeset} parameter]{2.4} \end{funcdesc} ! \begin{funcdesc}{install}{domain\optional{, localedir\optional{, unicode ! \optional{, codeset}}}} This installs the function \function{_} in Python's builtin namespace, ! based on \var{domain}, \var{localedir}, and \var{codeset} which are ! passed to the function \function{translation()}. The \var{unicode} ! flag is passed to the resulting translation object's \method{install} ! method. As seen below, you usually mark the strings in your application that are *************** *** 192,195 **** --- 238,243 ---- Python's builtin namespace, so it is easily accessible in all modules of your application. + + \versionchanged[Added the \var{codeset} parameter]{2.4} \end{funcdesc} *************** *** 224,233 **** \begin{methoddesc}[NullTranslations]{gettext}{message} ! If a fallback has been set, forward \method{gettext} to the fallback. Otherwise, return the translated message. Overridden in derived classes. \end{methoddesc} \begin{methoddesc}[NullTranslations]{ugettext}{message} ! If a fallback has been set, forward \method{ugettext} to the fallback. Otherwise, return the translated message as a Unicode string. Overridden in derived classes. --- 272,288 ---- \begin{methoddesc}[NullTranslations]{gettext}{message} ! If a fallback has been set, forward \method{gettext()} to the fallback. ! Otherwise, return the translated message. Overridden in derived classes. ! \end{methoddesc} ! ! \begin{methoddesc}[NullTranslations]{lgettext}{message} ! If a fallback has been set, forward \method{lgettext()} to the fallback. Otherwise, return the translated message. Overridden in derived classes. + + \versionadded{2.4} \end{methoddesc} \begin{methoddesc}[NullTranslations]{ugettext}{message} ! If a fallback has been set, forward \method{ugettext()} to the fallback. Otherwise, return the translated message as a Unicode string. Overridden in derived classes. *************** *** 235,239 **** \begin{methoddesc}[NullTranslations]{ngettext}{singular, plural, n} ! If a fallback has been set, forward \method{ngettext} to the fallback. Otherwise, return the translated message. Overridden in derived classes. --- 290,294 ---- \begin{methoddesc}[NullTranslations]{ngettext}{singular, plural, n} ! If a fallback has been set, forward \method{ngettext()} to the fallback. Otherwise, return the translated message. Overridden in derived classes. *************** *** 241,246 **** \end{methoddesc} \begin{methoddesc}[NullTranslations]{ungettext}{singular, plural, n} ! If a fallback has been set, forward \method{ungettext} to the fallback. Otherwise, return the translated message as a Unicode string. Overridden in derived classes. --- 296,308 ---- \end{methoddesc} + \begin{methoddesc}[NullTranslations]{lngettext}{singular, plural, n} + If a fallback has been set, forward \method{ngettext()} to the fallback. + Otherwise, return the translated message. Overridden in derived classes. + + \versionadded{2.4} + \end{methoddesc} + \begin{methoddesc}[NullTranslations]{ungettext}{singular, plural, n} ! If a fallback has been set, forward \method{ungettext()} to the fallback. Otherwise, return the translated message as a Unicode string. Overridden in derived classes. *************** *** 257,260 **** --- 319,336 ---- \end{methoddesc} + \begin{methoddesc}[NullTranslations]{output_charset}{} + Return the ``protected'' \member{_output_charset} variable, which + defines the encoding used to return translated messages. + + \versionadded{2.4} + \end{methoddesc} + + \begin{methoddesc}[NullTranslations]{set_output_charset}{charset} + Change the ``protected'' \member{_output_charset} variable, which + defines the encoding used to return translated messages. + + \versionadded{2.4} + \end{methoddesc} + \begin{methoddesc}[NullTranslations]{install}{\optional{unicode}} If the \var{unicode} flag is false, this method installs *************** *** 324,327 **** --- 400,411 ---- \end{methoddesc} + \begin{methoddesc}[GNUTranslations]{lgettext}{message} + Equivalent to \method{gettext()}, but the translation is returned + in the preferred system encoding, if no other encoding was explicitly + set with \method{set_output_charset()}. + + \versionadded{2.4} + \end{methoddesc} + \begin{methoddesc}[GNUTranslations]{ugettext}{message} Look up the \var{message} id in the catalog and return the *************** *** 347,350 **** --- 431,442 ---- \end{methoddesc} + \begin{methoddesc}[GNUTranslations]{lngettext}{singular, plural, n} + Equivalent to \method{gettext()}, but the translation is returned + in the preferred system encoding, if no other encoding was explicitly + set with \method{set_output_charset()}. + + \versionadded{2.4} + \end{methoddesc} + \begin{methoddesc}[GNUTranslations]{ungettext}{singular, plural, n} Do a plural-forms lookup of a message id. \var{singular} is used as *************** *** 496,500 **** import gettext t = gettext.translation('spam', '/usr/share/locale') ! _ = t.gettext \end{verbatim} --- 588,592 ---- import gettext t = gettext.translation('spam', '/usr/share/locale') ! _ = t.lgettext \end{verbatim} *************** *** 634,637 **** --- 726,744 ---- use of command line switches. + \subsubsection{\function{gettext()} vs. \function{lgettext()}} + In Python 2.4 the \function{lgettext()} family of functions were + introduced. The intention of these functions is to provide an + alternative which is more compliant with the current + implementation of GNU gettext. Unlike \function{gettext()}, which + returns strings encoded with the same codeset used in the + translation file, \function{lgettext()} will return strings + encoded with the preferred system encoding, as returned by + \function{locale.getpreferredencoding()}. Also notice that + Python 2.4 introduces new functions to explicitly choose + the codeset used in translated strings. If a codeset is explicitly + set, even \function{lgettext()} will return translated strings in + the requested codeset, as would be expected in the GNU gettext + implementation. + \subsection{Acknowledgements} *************** *** 648,650 **** --- 755,758 ---- \item Fran\c cois Pinard \item Barry Warsaw + \item Gustavo Niemeyer \end{itemize} Index: liblocale.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/liblocale.tex,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** liblocale.tex 8 Jun 2004 18:52:41 -0000 1.36 --- liblocale.tex 22 Jul 2004 18:43:59 -0000 1.37 *************** *** 470,477 **** that provide this interface. It consists of the functions \function{gettext()}, \function{dgettext()}, \function{dcgettext()}, ! \function{textdomain()}, and \function{bindtextdomain()}. These are ! similar to the same functions in the \refmodule{gettext} module, but use ! the C library's binary format for message catalogs, and the C ! library's search algorithms for locating message catalogs. Python applications should normally find no need to invoke these --- 470,478 ---- that provide this interface. It consists of the functions \function{gettext()}, \function{dgettext()}, \function{dcgettext()}, ! \function{textdomain()}, \function{bindtextdomain()}, and ! \function{bind_textdomain_codeset()}. These are similar to the same ! functions in the \refmodule{gettext} module, but use the C library's ! binary format for message catalogs, and the C library's search ! algorithms for locating message catalogs. Python applications should normally find no need to invoke these *************** *** 479,483 **** exception to this rule are applications that link use additional C libraries which internally invoke \cfunction{gettext()} or ! \function{cdgettext()}. For these applications, it may be necessary to bind the text domain, so that the libraries can properly locate their message catalogs. --- 480,484 ---- exception to this rule are applications that link use additional C libraries which internally invoke \cfunction{gettext()} or ! \function{dcgettext()}. For these applications, it may be necessary to bind the text domain, so that the libraries can properly locate their message catalogs. From niemeyer at users.sourceforge.net Thu Jul 22 20:44:02 2004 From: niemeyer at users.sourceforge.net (niemeyer@users.sourceforge.net) Date: Thu Jul 22 20:44:09 2004 Subject: [Python-checkins] python/dist/src/Lib gettext.py,1.23,1.24 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3065/Lib Modified Files: gettext.py Log Message: This change implements the following gettext features, as discussed recently in python-dev: In _locale module: - bind_textdomain_codeset() binding In gettext module: - bind_textdomain_codeset() function - lgettext(), lngettext(), ldgettext(), ldngettext(), which return translated strings encoded in preferred system encoding, if bind_textdomain_codeset() was not used. - Added equivalent functionality in translate() function and catalog classes. Every change was also documented. Index: gettext.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/gettext.py,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** gettext.py 4 May 2004 09:21:43 -0000 1.23 --- gettext.py 22 Jul 2004 18:44:00 -0000 1.24 *************** *** 47,51 **** ! import copy, os, re, struct, sys from errno import ENOENT --- 47,51 ---- ! import locale, copy, os, re, struct, sys from errno import ENOENT *************** *** 172,175 **** --- 172,176 ---- self._info = {} self._charset = None + self._output_charset = None self._fallback = None if fp is not None: *************** *** 190,193 **** --- 191,199 ---- return message + def lgettext(self, message): + if self._fallback: + return self._fallback.lgettext(message) + return message + def ngettext(self, msgid1, msgid2, n): if self._fallback: *************** *** 198,201 **** --- 204,215 ---- return msgid2 + def lngettext(self, msgid1, msgid2, n): + if self._fallback: + return self._fallback.lngettext(msgid1, msgid2, n) + if n == 1: + return msgid1 + else: + return msgid2 + def ugettext(self, message): if self._fallback: *************** *** 217,220 **** --- 231,240 ---- return self._charset + def output_charset(self): + return self._output_charset + + def set_output_charset(self, charset): + self._output_charset = charset + def install(self, unicode=False): import __builtin__ *************** *** 316,327 **** return message # Encode the Unicode tmsg back to an 8-bit string, if possible ! if self._charset: return tmsg.encode(self._charset) return tmsg def ngettext(self, msgid1, msgid2, n): try: tmsg = self._catalog[(msgid1, self.plural(n))] ! if self._charset: return tmsg.encode(self._charset) return tmsg --- 336,362 ---- return message # Encode the Unicode tmsg back to an 8-bit string, if possible ! if self._output_charset: ! return tmsg.encode(self._output_charset) ! elif self._charset: return tmsg.encode(self._charset) return tmsg + def lgettext(self, message): + missing = object() + tmsg = self._catalog.get(message, missing) + if tmsg is missing: + if self._fallback: + return self._fallback.lgettext(message) + return message + if self._output_charset: + return tmsg.encode(self._output_charset) + return tmsg.encode(locale.getpreferredencoding()) + def ngettext(self, msgid1, msgid2, n): try: tmsg = self._catalog[(msgid1, self.plural(n))] ! if self._output_charset: ! return tmsg.encode(self._output_charset) ! elif self._charset: return tmsg.encode(self._charset) return tmsg *************** *** 334,337 **** --- 369,386 ---- return msgid2 + def lngettext(self, msgid1, msgid2, n): + try: + tmsg = self._catalog[(msgid1, self.plural(n))] + if self._output_charset: + return tmsg.encode(self._output_charset) + return tmsg.encode(locale.getpreferredencoding()) + except KeyError: + if self._fallback: + return self._fallback.lngettext(msgid1, msgid2, n) + if n == 1: + return msgid1 + else: + return msgid2 + def ugettext(self, message): missing = object() *************** *** 398,402 **** def translation(domain, localedir=None, languages=None, ! class_=None, fallback=False): if class_ is None: class_ = GNUTranslations --- 447,451 ---- def translation(domain, localedir=None, languages=None, ! class_=None, fallback=False, codeset=None): if class_ is None: class_ = GNUTranslations *************** *** 415,421 **** if t is None: t = _translations.setdefault(key, class_(open(mofile, 'rb'))) ! # Copy the translation object to allow setting fallbacks. ! # All other instance data is shared with the cached object. t = copy.copy(t) if result is None: result = t --- 464,473 ---- if t is None: t = _translations.setdefault(key, class_(open(mofile, 'rb'))) ! # Copy the translation object to allow setting fallbacks and ! # output charset. All other instance data is shared with the ! # cached object. t = copy.copy(t) + if codeset: + t.set_output_charset(codeset) if result is None: result = t *************** *** 425,430 **** ! def install(domain, localedir=None, unicode=False): ! translation(domain, localedir, fallback=True).install(unicode) --- 477,483 ---- ! def install(domain, localedir=None, unicode=False, codeset=None): ! t = translation(domain, localedir, fallback=True, codeset=codeset) ! t.install(unicode) *************** *** 432,435 **** --- 485,490 ---- # a mapping b/w domains and locale directories _localedirs = {} + # a mapping b/w domains and codesets + _localecodesets = {} # current global domain, `messages' used for compatibility w/ GNU gettext _current_domain = 'messages' *************** *** 450,464 **** def dgettext(domain, message): try: ! t = translation(domain, _localedirs.get(domain, None)) except IOError: return message return t.gettext(message) def dngettext(domain, msgid1, msgid2, n): try: ! t = translation(domain, _localedirs.get(domain, None)) except IOError: if n == 1: --- 505,535 ---- + def bind_textdomain_codeset(domain, codeset=None): + global _localecodesets + if codeset is not None: + _localecodesets[domain] = codeset + return _localecodesets.get(domain) + + def dgettext(domain, message): try: ! t = translation(domain, _localedirs.get(domain, None), ! codeset=_localecodesets.get(domain)) except IOError: return message return t.gettext(message) + def ldgettext(domain, message): + try: + t = translation(domain, _localedirs.get(domain, None), + codeset=_localecodesets.get(domain)) + except IOError: + return message + return t.lgettext(message) def dngettext(domain, msgid1, msgid2, n): try: ! t = translation(domain, _localedirs.get(domain, None), ! codeset=_localecodesets.get(domain)) except IOError: if n == 1: *************** *** 468,479 **** --- 539,564 ---- return t.ngettext(msgid1, msgid2, n) + def ldngettext(domain, msgid1, msgid2, n): + try: + t = translation(domain, _localedirs.get(domain, None), + codeset=_localecodesets.get(domain)) + except IOError: + if n == 1: + return msgid1 + else: + return msgid2 + return t.lngettext(msgid1, msgid2, n) def gettext(message): return dgettext(_current_domain, message) + def lgettext(message): + return ldgettext(_current_domain, message) def ngettext(msgid1, msgid2, n): return dngettext(_current_domain, msgid1, msgid2, n) + def lngettext(msgid1, msgid2, n): + return ldngettext(_current_domain, msgid1, msgid2, n) # dcgettext() has been deemed unnecessary and is not implemented. From niemeyer at users.sourceforge.net Thu Jul 22 20:44:03 2004 From: niemeyer at users.sourceforge.net (niemeyer@users.sourceforge.net) Date: Thu Jul 22 20:44:11 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1050,1.1051 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3065/Misc Modified Files: NEWS Log Message: This change implements the following gettext features, as discussed recently in python-dev: In _locale module: - bind_textdomain_codeset() binding In gettext module: - bind_textdomain_codeset() function - lgettext(), lngettext(), ldgettext(), ldngettext(), which return translated strings encoded in preferred system encoding, if bind_textdomain_codeset() was not used. - Added equivalent functionality in translate() function and catalog classes. Every change was also documented. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1050 retrieving revision 1.1051 diff -C2 -d -r1.1050 -r1.1051 *** NEWS 22 Jul 2004 00:54:37 -0000 1.1050 --- NEWS 22 Jul 2004 18:44:00 -0000 1.1051 *************** *** 34,37 **** --- 34,39 ---- Jython. + - Implemented bind_textdomain_codeset() in locale module. + Extension modules ----------------- *************** *** 113,116 **** --- 115,124 ---- no longer returns spurious empty fields. + - Implemented bind_textdomain_codeset() in gettext module. + + - Introduced in gettext module the l*gettext() family of functions, + which return translation strings encoded in the preferred encoding, + as informed by locale module's getpreferredencoding(). + Tools/Demos From niemeyer at users.sourceforge.net Thu Jul 22 20:44:04 2004 From: niemeyer at users.sourceforge.net (niemeyer@users.sourceforge.net) Date: Thu Jul 22 20:44:13 2004 Subject: [Python-checkins] python/dist/src/Modules _localemodule.c, 2.47, 2.48 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3065/Modules Modified Files: _localemodule.c Log Message: This change implements the following gettext features, as discussed recently in python-dev: In _locale module: - bind_textdomain_codeset() binding In gettext module: - bind_textdomain_codeset() function - lgettext(), lngettext(), ldgettext(), ldngettext(), which return translated strings encoded in preferred system encoding, if bind_textdomain_codeset() was not used. - Added equivalent functionality in translate() function and catalog classes. Every change was also documented. Index: _localemodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_localemodule.c,v retrieving revision 2.47 retrieving revision 2.48 diff -C2 -d -r2.47 -r2.48 *** _localemodule.c 15 Jul 2004 13:31:39 -0000 2.47 --- _localemodule.c 22 Jul 2004 18:44:01 -0000 2.48 *************** *** 650,653 **** --- 650,671 ---- } + #ifdef HAVE_BIND_TEXTDOMAIN_CODESET + PyDoc_STRVAR(bind_textdomain_codeset__doc__, + "bind_textdomain_codeset(domain, codeset) -> string\n" + "Bind the C library's domain to codeset."); + + static PyObject* + PyIntl_bind_textdomain_codeset(PyObject* self,PyObject*args) + { + char *domain,*codeset; + if (!PyArg_ParseTuple(args, "sz", &domain, &codeset)) + return NULL; + codeset = bind_textdomain_codeset(domain, codeset); + if (codeset) + return PyString_FromString(codeset); + Py_RETURN_NONE; + } + #endif + #endif *************** *** 679,682 **** --- 697,704 ---- {"bindtextdomain",(PyCFunction)PyIntl_bindtextdomain,METH_VARARGS, bindtextdomain__doc__}, + #ifdef HAVE_BIND_TEXTDOMAIN_CODESET + {"bind_textdomain_codeset",(PyCFunction)PyIntl_bind_textdomain_codeset, + METH_VARARGS, bind_textdomain_codeset__doc__}, + #endif #endif {NULL, NULL} From rhettinger at users.sourceforge.net Thu Jul 22 21:33:55 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Thu Jul 22 21:33:58 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libstdtypes.tex, 1.157, 1.158 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14655 Modified Files: libstdtypes.tex Log Message: SF bug #995983 and #995987: Documentation nits. Index: libstdtypes.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libstdtypes.tex,v retrieving revision 1.157 retrieving revision 1.158 diff -C2 -d -r1.157 -r1.158 *** libstdtypes.tex 1 Jul 2004 19:58:47 -0000 1.157 --- libstdtypes.tex 22 Jul 2004 19:33:53 -0000 1.158 *************** *** 1186,1189 **** --- 1186,1193 ---- superset of the second set (is a superset, but is not equal). + Instanceas of \class{set} are compared to instances of \class{frozenset} based + on their members. For example, \samp{set('abc') == frozenset('abc')} returns + \code{True}. + The subset and equality comparisons do not generalize to a complete ordering function. For example, any two disjoint sets are not equal and *************** *** 1196,1204 **** of the \method{list.sort()} method is undefined for lists of sets. ! For convenience in implementing sets of sets, the \method{__contains__()}, ! \method{remove()}, and \method{discard()} methods automatically match ! instances of the \class{set} class their \class{frozenset} counterparts ! inside a set. For example, \code{set('abc') in set([frozenset('abc')])} ! returns \code{True}. The following table lists operations available for \class{set} --- 1200,1206 ---- of the \method{list.sort()} method is undefined for lists of sets. ! Binary operations that mix \class{set} instances with \class{frozenset} ! return the type of the first operand. For example: ! \samp{frozenset('ab') | set('bc')} returns an instance of \class{frozenset}. The following table lists operations available for \class{set} From tim_one at users.sourceforge.net Fri Jul 23 04:48:28 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Fri Jul 23 04:48:31 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libdoctest.tex,1.20,1.21 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20913/Doc/lib Modified Files: libdoctest.tex Log Message: A few trivial edits. Index: libdoctest.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libdoctest.tex,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** libdoctest.tex 31 May 2004 19:00:59 -0000 1.20 --- libdoctest.tex 23 Jul 2004 02:48:24 -0000 1.21 *************** *** 155,159 **** \end{verbatim} ! If you want to test the module as the main module, you don't need to pass M to \function{testmod()}; in this case, it will test the current module. --- 155,159 ---- \end{verbatim} ! If you want to test the current module as the main module, you don't need to pass M to \function{testmod()}; in this case, it will test the current module. *************** *** 368,377 **** \begin{verbatim} ! >>> def f(x): ... r'''Backslashes in a raw docstring: m\n''' >>> print f.__doc__ Backslashes in a raw docstring: m\n \end{verbatim} ! Otherwise, the backslash will be interpreted as part of the string. E.g., the "\textbackslash" above would be interpreted as a newline --- 368,377 ---- \begin{verbatim} ! >>> def f(x): ... r'''Backslashes in a raw docstring: m\n''' >>> print f.__doc__ Backslashes in a raw docstring: m\n \end{verbatim} ! Otherwise, the backslash will be interpreted as part of the string. E.g., the "\textbackslash" above would be interpreted as a newline *************** *** 380,384 **** \begin{verbatim} ! >>> def f(x): ... '''Backslashes in a raw docstring: m\\n''' >>> print f.__doc__ --- 380,384 ---- \begin{verbatim} ! >>> def f(x): ... '''Backslashes in a raw docstring: m\\n''' >>> print f.__doc__ From tim_one at users.sourceforge.net Fri Jul 23 04:50:12 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Fri Jul 23 04:50:16 2004 Subject: [Python-checkins] python/dist/src setup.py,1.196,1.197 Message-ID: Update of /cvsroot/python/python/dist/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21581 Modified Files: setup.py Log Message: Whitespace normalization. Index: setup.py =================================================================== RCS file: /cvsroot/python/python/dist/src/setup.py,v retrieving revision 1.196 retrieving revision 1.197 diff -C2 -d -r1.196 -r1.197 *** setup.py 20 Jul 2004 01:42:06 -0000 1.196 --- setup.py 23 Jul 2004 02:50:10 -0000 1.197 *************** *** 409,413 **** # Operations on audio samples ! # According to #993173, this one should actually work fine on # 64-bit platforms. exts.append( Extension('audioop', ['audioop.c']) ) --- 409,413 ---- # Operations on audio samples ! # According to #993173, this one should actually work fine on # 64-bit platforms. exts.append( Extension('audioop', ['audioop.c']) ) From lemburg at users.sourceforge.net Fri Jul 23 12:10:00 2004 From: lemburg at users.sourceforge.net (lemburg@users.sourceforge.net) Date: Fri Jul 23 12:10:03 2004 Subject: [Python-checkins] python/dist/src/Tools/scripts gencodec.py, 1.8, 1.9 Message-ID: Update of /cvsroot/python/python/dist/src/Tools/scripts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11107 Modified Files: gencodec.py Log Message: Remove copyright notices from gencodec.py output. The script was originally used to create the initial set of codecs (and these were (c) CNRI). While the script itself still is (c) CNRI, the output certainly isn't anymore. Index: gencodec.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/scripts/gencodec.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** gencodec.py 2 Feb 2003 23:39:45 -0000 1.8 --- gencodec.py 23 Jul 2004 10:09:57 -0000 1.9 *************** *** 155,163 **** """ Python Character Mapping Codec generated from '%s' with gencodec.py. - Written by Marc-Andre Lemburg (mal@lemburg.com). - - (c) Copyright CNRI, All Rights Reserved. NO WARRANTY. - (c) Copyright 2000 Guido van Rossum. - """#" --- 155,158 ---- From theller at users.sourceforge.net Fri Jul 23 16:49:55 2004 From: theller at users.sourceforge.net (theller@users.sourceforge.net) Date: Fri Jul 23 16:49:58 2004 Subject: [Python-checkins] python/dist/src/Doc/api concrete.tex,1.47,1.48 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/api In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23778 Modified Files: concrete.tex Log Message: Fix an uncorrect function prototype. Will backport to release23-maint. BTW: Shouldn't it read PY_LONG_LONG instead of 'long long' ? Index: concrete.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/concrete.tex,v retrieving revision 1.47 retrieving revision 1.48 diff -C2 -d -r1.47 -r1.48 *** concrete.tex 17 Jul 2004 01:42:26 -0000 1.47 --- concrete.tex 23 Jul 2004 14:49:52 -0000 1.48 *************** *** 180,184 **** \end{cfuncdesc} ! \begin{cfuncdesc}{unsigned long}{PyInt_AsUnsignedLongLongMask}{PyObject *io} Will first attempt to cast the object to a \ctype{PyIntObject} or \ctype{PyLongObject}, if it is not already one, and then return its --- 180,184 ---- \end{cfuncdesc} ! \begin{cfuncdesc}{unsigned long long}{PyInt_AsUnsignedLongLongMask}{PyObject *io} Will first attempt to cast the object to a \ctype{PyIntObject} or \ctype{PyLongObject}, if it is not already one, and then return its From theller at users.sourceforge.net Fri Jul 23 16:51:09 2004 From: theller at users.sourceforge.net (theller@users.sourceforge.net) Date: Fri Jul 23 16:51:12 2004 Subject: [Python-checkins] python/dist/src/Doc/api concrete.tex, 1.25.10.8, 1.25.10.9 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/api In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23972 Modified Files: Tag: release23-maint concrete.tex Log Message: Fix an uncorrect function prototype. Backported from trunk. Index: concrete.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/concrete.tex,v retrieving revision 1.25.10.8 retrieving revision 1.25.10.9 diff -C2 -d -r1.25.10.8 -r1.25.10.9 *** concrete.tex 2 Jun 2004 12:45:46 -0000 1.25.10.8 --- concrete.tex 23 Jul 2004 14:51:06 -0000 1.25.10.9 *************** *** 176,180 **** \end{cfuncdesc} ! \begin{cfuncdesc}{unsigned long}{PyInt_AsUnsignedLongLongMask}{PyObject *io} Will first attempt to cast the object to a \ctype{PyIntObject} or \ctype{PyLongObject}, if it is not already one, and then return its --- 176,180 ---- \end{cfuncdesc} ! \begin{cfuncdesc}{unsigned long long}{PyInt_AsUnsignedLongLongMask}{PyObject *io} Will first attempt to cast the object to a \ctype{PyIntObject} or \ctype{PyLongObject}, if it is not already one, and then return its From lemburg at users.sourceforge.net Fri Jul 23 18:13:28 2004 From: lemburg at users.sourceforge.net (lemburg@users.sourceforge.net) Date: Fri Jul 23 18:13:31 2004 Subject: [Python-checkins] python/dist/src/Objects unicodeobject.c, 2.217, 2.218 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4921/Objects Modified Files: unicodeobject.c Log Message: Let u'%s' % obj try obj.__unicode__() first and fallback to obj.__str__(). Index: unicodeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/unicodeobject.c,v retrieving revision 2.217 retrieving revision 2.218 diff -C2 -d -r2.217 -r2.218 *** unicodeobject.c 15 Jul 2004 15:54:05 -0000 2.217 --- unicodeobject.c 23 Jul 2004 16:13:25 -0000 2.218 *************** *** 6884,6901 **** PyObject *unicode; if (c == 's') ! temp = PyObject_Str(v); else temp = PyObject_Repr(v); if (temp == NULL) goto onError; ! if (!PyString_Check(temp)) { ! /* XXX Note: this should never happen, since ! PyObject_Repr() and PyObject_Str() assure ! this */ ! Py_DECREF(temp); ! PyErr_SetString(PyExc_TypeError, ! "%s argument has non-string str()"); ! goto onError; ! } unicode = PyUnicode_Decode(PyString_AS_STRING(temp), PyString_GET_SIZE(temp), --- 6884,6896 ---- PyObject *unicode; if (c == 's') ! temp = PyObject_Unicode(v); else temp = PyObject_Repr(v); if (temp == NULL) goto onError; ! if (PyUnicode_Check(temp)) ! /* nothing to do */; ! else if (PyString_Check(temp)) { ! /* convert to string to Unicode */ unicode = PyUnicode_Decode(PyString_AS_STRING(temp), PyString_GET_SIZE(temp), *************** *** 6907,6910 **** --- 6902,6912 ---- goto onError; } + else { + Py_DECREF(temp); + PyErr_SetString(PyExc_TypeError, + "%s argument has non-string str()"); + goto onError; + } + } pbuf = PyUnicode_AS_UNICODE(temp); len = PyUnicode_GET_SIZE(temp); From lemburg at users.sourceforge.net Fri Jul 23 18:13:28 2004 From: lemburg at users.sourceforge.net (lemburg@users.sourceforge.net) Date: Fri Jul 23 18:13:35 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_unicode.py, 1.90, 1.91 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4921/Lib/test Modified Files: test_unicode.py Log Message: Let u'%s' % obj try obj.__unicode__() first and fallback to obj.__str__(). Index: test_unicode.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_unicode.py,v retrieving revision 1.90 retrieving revision 1.91 diff -C2 -d -r1.90 -r1.91 *** test_unicode.py 4 Jun 2004 04:24:54 -0000 1.90 --- test_unicode.py 23 Jul 2004 16:13:25 -0000 1.91 *************** *** 439,442 **** --- 439,450 ---- self.assertEqual(str(o), 'unicode(obj) is compatible to str()') + # %-formatting and .__unicode__() + self.assertEqual(u'%s' % + UnicodeCompat(u"u'%s' % obj uses obj.__unicode__()"), + u"u'%s' % obj uses obj.__unicode__()") + self.assertEqual(u'%s' % + UnicodeCompat(u"u'%s' % obj falls back to obj.__str__()"), + u"u'%s' % obj falls back to obj.__str__()") + for obj in (123, 123.45, 123L): self.assertEqual(unicode(obj), unicode(str(obj))) From lemburg at users.sourceforge.net Fri Jul 23 18:15:01 2004 From: lemburg at users.sourceforge.net (lemburg@users.sourceforge.net) Date: Fri Jul 23 18:15:04 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1051,1.1052 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5405/Misc Modified Files: NEWS Log Message: Add news item for u'%s' change. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1051 retrieving revision 1.1052 diff -C2 -d -r1.1051 -r1.1052 *** NEWS 22 Jul 2004 18:44:00 -0000 1.1051 --- NEWS 23 Jul 2004 16:14:57 -0000 1.1052 *************** *** 13,16 **** --- 13,19 ---- ----------------- + - u'%s' % obj will now try obj.__unicode__() first and fallback to + obj.__str__() if no __unicode__ method can be found. + - Patch #550732: Add PyArg_VaParseTupleAndKeywords(). Analogous to PyArg_VaParse(). Both are now documented. Thanks Greg Chapman. From loewis at users.sourceforge.net Fri Jul 23 18:54:04 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Fri Jul 23 18:54:07 2004 Subject: [Python-checkins] python/nondist/sandbox/msi msi.py,1.15,1.16 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/msi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11849 Modified Files: msi.py Log Message: Make python24.dll a shared dll. Index: msi.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/msi/msi.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** msi.py 20 Jul 2004 07:54:56 -0000 1.15 --- msi.py 23 Jul 2004 16:54:01 -0000 1.16 *************** *** 616,619 **** --- 616,621 ---- dlldir = Directory(db, cab, root, srcdir, "DLLDIR", ".") + dlldir.start_component("DLLDIR", flags = 8, + keyfile="python%s%s.dll" % (major, minor)) dlldir.add_file("PCBuild/python%s%s.dll" % (major, minor)) # XXX determine dependencies From theller at users.sourceforge.net Fri Jul 23 21:44:31 2004 From: theller at users.sourceforge.net (theller@users.sourceforge.net) Date: Fri Jul 23 21:44:34 2004 Subject: [Python-checkins] python/dist/src/Lib/distutils/command bdist_wininst.py, 1.51, 1.52 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils/command In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8017 Modified Files: bdist_wininst.py Log Message: bdist_wininst does now properly handle unicode strings or byte strings with umlauts in the author argument and others. Fixes sf # 993943. Index: bdist_wininst.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/bdist_wininst.py,v retrieving revision 1.51 retrieving revision 1.52 diff -C2 -d -r1.51 -r1.52 *** bdist_wininst.py 19 Jul 2004 09:45:46 -0000 1.51 --- bdist_wininst.py 23 Jul 2004 19:44:29 -0000 1.52 *************** *** 177,183 **** metadata = self.distribution.metadata ! # Write the [metadata] section. Values are written with ! # repr()[1:-1], so they do not contain unprintable characters, and ! # are not surrounded by quote chars. lines.append("[metadata]") --- 177,181 ---- metadata = self.distribution.metadata ! # Write the [metadata] section. lines.append("[metadata]") *************** *** 186,189 **** --- 184,191 ---- info = (metadata.long_description or '') + '\n' + # Escape newline characters + def escape(s): + return string.replace(s, "\n", "\\n") + for name in ["author", "author_email", "description", "maintainer", "maintainer_email", "name", "url", "version"]: *************** *** 191,196 **** if data: info = info + ("\n %s: %s" % \ ! (string.capitalize(name), data)) ! lines.append("%s=%s" % (name, repr(data)[1:-1])) # The [setup] section contains entries controlling --- 193,198 ---- if data: info = info + ("\n %s: %s" % \ ! (string.capitalize(name), escape(data))) ! lines.append("%s=%s" % (name, escape(data))) # The [setup] section contains entries controlling *************** *** 199,203 **** if self.install_script: lines.append("install_script=%s" % self.install_script) ! lines.append("info=%s" % repr(info)[1:-1]) lines.append("target_compile=%d" % (not self.no_target_compile)) lines.append("target_optimize=%d" % (not self.no_target_optimize)) --- 201,205 ---- if self.install_script: lines.append("install_script=%s" % self.install_script) ! lines.append("info=%s" % escape(info)) lines.append("target_compile=%d" % (not self.no_target_compile)) lines.append("target_optimize=%d" % (not self.no_target_optimize)) *************** *** 206,210 **** title = self.title or self.distribution.get_fullname() ! lines.append("title=%s" % repr(title)[1:-1]) import time import distutils --- 208,212 ---- title = self.title or self.distribution.get_fullname() ! lines.append("title=%s" % escape(title)) import time import distutils *************** *** 245,248 **** --- 247,259 ---- file.write(bitmapdata) + # Convert cfgdata from unicode to ascii, mbcs encoded + try: + unicode + except NameError: + pass + else: + if isinstance(cfgdata, unicode): + cfgdata = cfgdata.encode("mbcs") + # Append the pre-install script cfgdata = cfgdata + "\0" From theller at users.sourceforge.net Fri Jul 23 21:47:34 2004 From: theller at users.sourceforge.net (theller@users.sourceforge.net) Date: Fri Jul 23 21:47:37 2004 Subject: [Python-checkins] python/dist/src/Lib/distutils __init__.py, 1.24, 1.25 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8593 Modified Files: __init__.py Log Message: Make the distutils version number the same as the python version. It must be literally contained here, because it is still possible to install this distutils in older Python versions. Index: __init__.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/__init__.py,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** __init__.py 16 Jul 2004 18:14:37 -0000 1.24 --- __init__.py 23 Jul 2004 19:47:32 -0000 1.25 *************** *** 13,15 **** __revision__ = "$Id$" ! __version__ = "1.0.4" --- 13,15 ---- __revision__ = "$Id$" ! __version__ = "2.4.0" From theller at users.sourceforge.net Fri Jul 23 21:58:31 2004 From: theller at users.sourceforge.net (theller@users.sourceforge.net) Date: Fri Jul 23 21:58:36 2004 Subject: [Python-checkins] python/dist/src/Lib/distutils/command bdist_wininst.py, 1.52, 1.53 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils/command In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10820 Modified Files: bdist_wininst.py Log Message: Factored out a method to determine the final installer filename. Index: bdist_wininst.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/bdist_wininst.py,v retrieving revision 1.52 retrieving revision 1.53 diff -C2 -d -r1.52 -r1.53 *** bdist_wininst.py 23 Jul 2004 19:44:29 -0000 1.52 --- bdist_wininst.py 23 Jul 2004 19:58:28 -0000 1.53 *************** *** 225,237 **** cfgdata = self.get_inidata() ! if self.target_version: ! # if we create an installer for a specific python version, ! # it's better to include this in the name ! installer_name = os.path.join(self.dist_dir, ! "%s.win32-py%s.exe" % ! (fullname, self.target_version)) ! else: ! installer_name = os.path.join(self.dist_dir, ! "%s.win32.exe" % fullname) self.announce("creating %s" % installer_name) --- 225,229 ---- cfgdata = self.get_inidata() ! installer_name = self.get_installer_filename(fullname) self.announce("creating %s" % installer_name) *************** *** 281,284 **** --- 273,289 ---- # create_exe() + def get_installer_filename(self, fullname): + # Factored out to allow overriding in subclasses + if self.target_version: + # if we create an installer for a specific python version, + # it's better to include this in the name + installer_name = os.path.join(self.dist_dir, + "%s.win32-py%s.exe" % + (fullname, self.target_version)) + else: + installer_name = os.path.join(self.dist_dir, + "%s.win32.exe" % fullname) + # get_installer_filename() + def get_exe_bytes (self): from distutils.msvccompiler import get_build_version From qeen at 123123.servegame.com Sat Jul 24 15:24:23 2004 From: qeen at 123123.servegame.com (qeen@123123.servegame.com) Date: Sat Jul 24 15:24:24 2004 Subject: [Python-checkins] =?utf-8?b?wpBswo3DiMKDQcKDaMKDwozCg1jCksKg?= Message-ID: <20040724132423.7C45E1E4002@bag.python.org> *:??,??'?:*:??,? ?????? ?15??*:??,??'?:*:??,? ???????????(???)? ?????????? ??????????????????????????? ???????????????? ??????????????????????????????? ?????????????????????????? (????????????????????????) ???????????????????????????????? ?????????????????????????????????????? ????????????????? ?????????????????????????? ???????????????????????????? ??????????????????????????? ??????????????????????????????????????????? ?????????????????? ?????????????? ?????????????????????????????????? ???30?????????????????????????????? http://veryvery.myftp.org/?g02 ????????????????????? ???????????????????? http://veryvery.myftp.org/?g02 ??????????????????????????????????????????? ?????????????????? ?????????????????????????????? ???????????????????????No.1???? ????????????????????????????? ???????????????????????????????? ???ko!???????????????????????????? ?????????? http://gannba.servepics.com/?g02 ???????????????????????????????????????????? ??????????????????????????? http://gannba.servepics.com/?g02 ??????????????????????????????????????????? ???????????????????????? ??????????????????? ??????????????????????????? ?????????????1????????? http://pc.gal-mail.com/?s01 ??????????????? http://pc.gal-mail.com/?s01 ???????????????????????????????????????? ?????? ?????????????????????? ????????????PC??????? ????????????????????? ??????????? ????????????????????????????? ??????????????? ???????????????????????????????????????? ?????????????????????????????????????? ????????????????????????? ??????????????????? From ydtefoampgzs at homeworking.com Sat Jul 24 19:15:09 2004 From: ydtefoampgzs at homeworking.com (Aldo Ohara) Date: Sat Jul 24 18:11:37 2004 Subject: [Python-checkins] Buy Pain Relief Drugs Message-ID: An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-checkins/attachments/20040724/5c03dde6/attachment.htm From montanaro at users.sourceforge.net Sat Jul 24 21:54:46 2004 From: montanaro at users.sourceforge.net (montanaro@users.sourceforge.net) Date: Sat Jul 24 21:54:50 2004 Subject: [Python-checkins] python/dist/src/Lib mailbox.py,1.42,1.43 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15693 Modified Files: mailbox.py Log Message: add missing newlines to read/readline. fixes bug #996359. Index: mailbox.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/mailbox.py,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -d -r1.42 -r1.43 *** mailbox.py 7 Jul 2004 14:09:21 -0000 1.42 --- mailbox.py 24 Jul 2004 19:54:44 -0000 1.43 *************** *** 57,64 **** def read(self, length = None): ! self._read(length, self.fp.read) def readline(self, length = None): ! self._read(length, self.fp.readline) def readlines(self, sizehint = -1): --- 57,64 ---- def read(self, length = None): ! return self._read(length, self.fp.read) def readline(self, length = None): ! return self._read(length, self.fp.readline) def readlines(self, sizehint = -1): From montanaro at users.sourceforge.net Sat Jul 24 21:56:06 2004 From: montanaro at users.sourceforge.net (montanaro@users.sourceforge.net) Date: Sat Jul 24 21:56:09 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_mailbox.py, 1.9, 1.10 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16121 Modified Files: test_mailbox.py Log Message: added test for bug #996359. Index: test_mailbox.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_mailbox.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** test_mailbox.py 23 Jul 2002 19:03:56 -0000 1.9 --- test_mailbox.py 24 Jul 2004 19:56:03 -0000 1.10 *************** *** 11,23 **** pass ! DUMMY_MESSAGE = """\ From: some.body@dummy.domain To: me@my.domain This is a dummy message. """ - class MaildirTestCase(unittest.TestCase): --- 11,23 ---- pass ! FROM_ = "From some.body@dummy.domain Sat Jul 24 13:43:35 2004\n" DUMMY_MESSAGE = """\ From: some.body@dummy.domain To: me@my.domain + Subject: Simple Test This is a dummy message. """ class MaildirTestCase(unittest.TestCase): *************** *** 39,43 **** os.rmdir(self._dir) ! def createMessage(self, dir): t = int(time.time() % 1000000) pid = self._counter --- 39,43 ---- os.rmdir(self._dir) ! def createMessage(self, dir, mbox=False): t = int(time.time() % 1000000) pid = self._counter *************** *** 48,51 **** --- 48,53 ---- fp = open(tmpname, "w") self._msgfiles.append(tmpname) + if mbox: + fp.write(FROM_) fp.write(DUMMY_MESSAGE) fp.close() *************** *** 57,60 **** --- 59,63 ---- fp.close() self._msgfiles.append(newname) + return tmpname def test_empty_maildir(self): *************** *** 94,97 **** --- 97,112 ---- self.assert_(self.mbox.next() is None) + def test_unix_mbox(self): + ### should be better! + import email.Parser + fname = self.createMessage("cur", True) + n = 0 + for msg in mailbox.PortableUnixMailbox(open(fname), + email.Parser.Parser().parse): + n += 1 + self.assertEqual(msg["subject"], "Simple Test") + self.assertEqual(len(str(msg)), len(FROM_)+len(DUMMY_MESSAGE)) + self.assertEqual(n, 1) + # XXX We still need more tests! From gvanrossum at users.sourceforge.net Sat Jul 24 22:50:51 2004 From: gvanrossum at users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Sat Jul 24 22:50:54 2004 Subject: [Python-checkins] python/nondist/peps pep-0263.txt,1.17,1.18 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23164 Modified Files: pep-0263.txt Log Message: Remove leading blank line so pep2html recognizes this file. Index: pep-0263.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0263.txt,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** pep-0263.txt 21 Jul 2004 21:22:51 -0000 1.17 --- pep-0263.txt 24 Jul 2004 20:50:49 -0000 1.18 *************** *** 1,3 **** - PEP: 0263 Title: Defining Python Source Code Encodings --- 1,2 ---- From tim_one at users.sourceforge.net Sun Jul 25 01:00:27 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 25 01:00:31 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libmath.tex,1.31,1.32 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7213/Doc/lib Modified Files: libmath.tex Log Message: SF bug 996392: math and cmath docs don't specify radians Major rewrite of the math module docs. Slapped in "radians" where appropriate; grouped the functions into reasonable categories; supplied many more words to address common confusions about some of the subtler issues. Index: libmath.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libmath.tex,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** libmath.tex 28 Apr 2003 21:32:03 -0000 1.31 --- libmath.tex 24 Jul 2004 23:00:24 -0000 1.32 *************** *** 19,58 **** The following functions are provided by this module. Except ! when explicitly noted otherwise, all return values are floats: ! ! \begin{funcdesc}{acos}{x} ! Return the arc cosine of \var{x}. ! \end{funcdesc} ! ! \begin{funcdesc}{asin}{x} ! Return the arc sine of \var{x}. ! \end{funcdesc} ! ! \begin{funcdesc}{atan}{x} ! Return the arc tangent of \var{x}. ! \end{funcdesc} ! \begin{funcdesc}{atan2}{y, x} ! Return \code{atan(\var{y} / \var{x})}. ! \end{funcdesc} \begin{funcdesc}{ceil}{x} ! Return the ceiling of \var{x} as a float. ! \end{funcdesc} ! ! \begin{funcdesc}{cos}{x} ! Return the cosine of \var{x}. ! \end{funcdesc} ! ! \begin{funcdesc}{cosh}{x} ! Return the hyperbolic cosine of \var{x}. ! \end{funcdesc} ! ! \begin{funcdesc}{degrees}{x} ! Converts angle \var{x} from radians to degrees. ! \end{funcdesc} ! ! \begin{funcdesc}{exp}{x} ! Return \code{e**\var{x}}. \end{funcdesc} --- 19,29 ---- The following functions are provided by this module. Except ! when explicitly noted otherwise, all return values are floats. ! Number-theoretic and representation functions: \begin{funcdesc}{ceil}{x} ! Return the ceiling of \var{x} as a float, the smallest integer value ! greater than or equal to \var{x}. \end{funcdesc} *************** *** 62,66 **** \begin{funcdesc}{floor}{x} ! Return the floor of \var{x} as a float. \end{funcdesc} --- 33,38 ---- \begin{funcdesc}{floor}{x} ! Return the floor of \var{x} as a float, the largest integer value ! less than or equal to \var{x}. \end{funcdesc} *************** *** 68,94 **** Return \code{fmod(\var{x}, \var{y})}, as defined by the platform C library. Note that the Python expression \code{\var{x} \%\ \var{y}} may not return ! the same result. \end{funcdesc} \begin{funcdesc}{frexp}{x} - % Blessed by Tim. Return the mantissa and exponent of \var{x} as the pair \code{(\var{m}, \var{e})}. \var{m} is a float and \var{e} is an ! integer such that \code{\var{x} == \var{m} * 2**\var{e}}. If \var{x} is zero, returns \code{(0.0, 0)}, otherwise ! \code{0.5 <= abs(\var{m}) < 1}. \end{funcdesc} ! \begin{funcdesc}{hypot}{x, y} ! Return the Euclidean distance, \code{sqrt(\var{x}*\var{x} + \var{y}*\var{y})}. \end{funcdesc} ! \begin{funcdesc}{ldexp}{x, i} ! Return \code{\var{x} * (2**\var{i})}. \end{funcdesc} \begin{funcdesc}{log}{x\optional{, base}} ! Returns the logarithm of \var{x} to the given \var{base}. ! If the \var{base} is not specified, returns the natural logarithm of \var{x}. \versionchanged[\var{base} argument added]{2.3} \end{funcdesc} --- 40,93 ---- Return \code{fmod(\var{x}, \var{y})}, as defined by the platform C library. Note that the Python expression \code{\var{x} \%\ \var{y}} may not return ! the same result. The intent of the C standard is that ! \code{fmod(\var{x}, \var{y})} be exactly (mathematically; to infinite ! precision) equal to \code{\var{x} - \var{n}*\var{y}} for some integer ! \var{n} such that the result has the same sign as \var{x} and ! magnitude less than \code{abs(\var{y})}. Python's ! \code{\var{x} \%\ \var{y}} returns a result with the sign of ! \var{y} instead, and may not be exactly computable for float arguments. ! For example, \code{fmod(-1e-100, 1e100)} is \code{-1e-100}, but the ! result of Python's \code{-1e-100 \%\ 1e100} is \code{1e100-1e-100}, which ! cannot be represented exactly as a float, and rounds to the surprising ! \code{1e100}. For this reason, function \function{fmod()} is generally ! preferred when working with floats, while Python's ! \code{\var{x} \%\ \var{y}} is preferred when working with integers. \end{funcdesc} \begin{funcdesc}{frexp}{x} Return the mantissa and exponent of \var{x} as the pair \code{(\var{m}, \var{e})}. \var{m} is a float and \var{e} is an ! integer such that \code{\var{x} == \var{m} * 2**\var{e}} exactly. If \var{x} is zero, returns \code{(0.0, 0)}, otherwise ! \code{0.5 <= abs(\var{m}) < 1}. This is used to "pick apart" the ! internal representation of a float in a portable way. \end{funcdesc} ! \begin{funcdesc}{ldexp}{x, i} ! Return \code{\var{x} * (2**\var{i})}. This is essentially the inverse of ! function \function{frexp()}. \end{funcdesc} ! \begin{funcdesc}{modf}{x} ! Return the fractional and integer parts of \var{x}. Both results ! carry the sign of \var{x}, and both are floats. ! \end{funcdesc} ! ! Note that \function{frexp()} and \function{modf()} have a different ! call/return pattern than their C equivalents: they take a single ! argument and return a pair of values, rather than returning their ! second return value through an `output parameter' (there is no such ! thing in Python). ! ! Power and logarithmic functions: ! ! \begin{funcdesc}{exp}{x} ! Return \code{e**\var{x}}. \end{funcdesc} \begin{funcdesc}{log}{x\optional{, base}} ! Return the logarithm of \var{x} to the given \var{base}. ! If the \var{base} is not specified, return the natural logarithm of \var{x} ! (that is, the logarithm to base \emph{e}). \versionchanged[\var{base} argument added]{2.3} \end{funcdesc} *************** *** 98,128 **** \end{funcdesc} - \begin{funcdesc}{modf}{x} - Return the fractional and integer parts of \var{x}. Both results - carry the sign of \var{x}. The integer part is returned as a float. - \end{funcdesc} - \begin{funcdesc}{pow}{x, y} Return \code{\var{x}**\var{y}}. \end{funcdesc} ! \begin{funcdesc}{radians}{x} ! Converts angle \var{x} from degrees to radians. \end{funcdesc} ! \begin{funcdesc}{sin}{x} ! Return the sine of \var{x}. \end{funcdesc} ! \begin{funcdesc}{sinh}{x} ! Return the hyperbolic sine of \var{x}. \end{funcdesc} ! \begin{funcdesc}{sqrt}{x} ! Return the square root of \var{x}. \end{funcdesc} \begin{funcdesc}{tan}{x} ! Return the tangent of \var{x}. \end{funcdesc} --- 97,169 ---- \end{funcdesc} \begin{funcdesc}{pow}{x, y} Return \code{\var{x}**\var{y}}. \end{funcdesc} ! \begin{funcdesc}{sqrt}{x} ! Return the square root of \var{x}. \end{funcdesc} ! Trigonometric functions: ! ! \begin{funcdesc}{acos}{x} ! Return the arc cosine of \var{x}, in radians. \end{funcdesc} ! \begin{funcdesc}{asin}{x} ! Return the arc sine of \var{x}, in radians. \end{funcdesc} ! \begin{funcdesc}{atan}{x} ! Return the arc tangent of \var{x}, in radians. ! \end{funcdesc} ! ! \begin{funcdesc}{atan2}{y, x} ! Return \code{atan(\var{y} / \var{x})}, in radians. ! The result is between \code{-pi} and \code{pi}. ! The vector in the plane from the origin to point \code{(\var{x}, \var{y})} ! makes this angle with the positive X axis. ! The point of \function{atan2()} is that the signs of both inputs are ! known to it, so it can compute the correct quadrant for the angle. ! For example, \code{atan(1}) and \code{atan2(1, 1)} are both \code{pi/4}, ! but \code{atan2(-1, -1)} is \code{-3*pi/4}. ! \end{funcdesc} ! ! \begin{funcdesc}{cos}{x} ! Return the cosine of \var{x} radians. ! \end{funcdesc} ! ! \begin{funcdesc}{hypot}{x, y} ! Return the Euclidean norm, \code{sqrt(\var{x}*\var{x} + \var{y}*\var{y})}. ! This is the length of the vector from the origin to point ! \code{(\var{x}, \var{y})}. ! \end{funcdesc} ! ! \begin{funcdesc}{sin}{x} ! Return the sine of \var{x} radians. \end{funcdesc} \begin{funcdesc}{tan}{x} ! Return the tangent of \var{x} radians. ! \end{funcdesc} ! ! Angular conversion: ! ! \begin{funcdesc}{degrees}{x} ! Converts angle \var{x} from radians to degrees. ! \end{funcdesc} ! ! \begin{funcdesc}{radians}{x} ! Converts angle \var{x} from degrees to radians. ! \end{funcdesc} ! ! Hyerbolic functions: ! ! \begin{funcdesc}{cosh}{x} ! Return the hyperbolic cosine of \var{x}. ! \end{funcdesc} ! ! \begin{funcdesc}{sinh}{x} ! Return the hyperbolic sine of \var{x}. \end{funcdesc} *************** *** 131,140 **** \end{funcdesc} - Note that \function{frexp()} and \function{modf()} have a different - call/return pattern than their C equivalents: they take a single - argument and return a pair of values, rather than returning their - second return value through an `output parameter' (there is no such - thing in Python). - The module also defines two mathematical constants: --- 172,175 ---- From tim_one at users.sourceforge.net Sun Jul 25 01:00:29 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Jul 25 01:00:35 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1052,1.1053 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7213/Misc Modified Files: NEWS Log Message: SF bug 996392: math and cmath docs don't specify radians Major rewrite of the math module docs. Slapped in "radians" where appropriate; grouped the functions into reasonable categories; supplied many more words to address common confusions about some of the subtler issues. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1052 retrieving revision 1.1053 diff -C2 -d -r1.1052 -r1.1053 *** NEWS 23 Jul 2004 16:14:57 -0000 1.1052 --- NEWS 24 Jul 2004 23:00:24 -0000 1.1053 *************** *** 140,144 **** ------------- ! Improved the tutorial on creating types in C. - point out the importance of reassigning data members before --- 140,144 ---- ------------- ! - Improved the tutorial on creating types in C. - point out the importance of reassigning data members before *************** *** 149,152 **** --- 149,153 ---- - mention the labor saving Py_VISIT and Py_CLEAR macros. + - Major rewrite of the math module docs, to address common confusions. New platforms From loewis at users.sourceforge.net Sun Jul 25 11:49:29 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun Jul 25 11:49:31 2004 Subject: [Python-checkins] python/dist/src/PCbuild make_versioninfo.vcproj, 1.2, 1.3 Message-ID: Update of /cvsroot/python/python/dist/src/PCbuild In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12465 Modified Files: make_versioninfo.vcproj Log Message: Generate rc[_d].h after linking Index: make_versioninfo.vcproj =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/make_versioninfo.vcproj,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** make_versioninfo.vcproj 15 Jun 2004 18:18:19 -0000 1.2 --- make_versioninfo.vcproj 25 Jul 2004 09:49:26 -0000 1.3 *************** *** 4,7 **** --- 4,8 ---- Version="7.10" Name="make_versioninfo" + RootNamespace="make_versioninfo" SccProjectName="make_versioninfo" SccLocalPath=".."> *************** *** 58,62 **** HeaderFileName=""/> --- 59,64 ---- HeaderFileName=""/> *************** *** 123,127 **** HeaderFileName=""/> --- 125,130 ---- HeaderFileName=""/> From loewis at users.sourceforge.net Sun Jul 25 12:19:38 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun Jul 25 12:19:41 2004 Subject: [Python-checkins] python/nondist/sandbox/msi msi.py,1.16,1.17 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/msi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15666 Modified Files: msi.py Log Message: Put python24.dll into a separate component, so it can be removed independently from msvcr71. Also version it in the file table, so it overwrites older versions. Fixes #990945. Index: msi.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/msi/msi.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** msi.py 23 Jul 2004 16:54:01 -0000 1.16 --- msi.py 25 Jul 2004 10:19:36 -0000 1.17 *************** *** 616,624 **** dlldir = Directory(db, cab, root, srcdir, "DLLDIR", ".") ! dlldir.start_component("DLLDIR", flags = 8, ! keyfile="python%s%s.dll" % (major, minor)) ! dlldir.add_file("PCBuild/python%s%s.dll" % (major, minor)) # XXX determine dependencies version, lang = extract_msvcr71() dlldir.add_file("msvcr71.dll", src=os.path.abspath("msvcr71.dll"), version=version, language=lang) --- 616,629 ---- dlldir = Directory(db, cab, root, srcdir, "DLLDIR", ".") ! pydll = "python%s%s.dll" % (major, minor) ! pydllsrc = srcdir + "/PCBuild/" + pydll ! dlldir.start_component("DLLDIR", flags = 8, keyfile = pydll) ! installer = msilib.MakeInstaller() ! dlldir.add_file("PCBuild/python%s%s.dll" % (major, minor), ! version=installer.FileVersion(pydllsrc, 0), ! language=installer.FileVersion(pydllsrc, 1)) # XXX determine dependencies version, lang = extract_msvcr71() + dlldir.start_component("msvcr71", flags=8, keyfile="msvcr71.dll") dlldir.add_file("msvcr71.dll", src=os.path.abspath("msvcr71.dll"), version=version, language=lang) *************** *** 647,659 **** if files: lib.remove_pyc() ! if dir=='test' and parent.physical=='Lib': ! lib.add_file("185test.db") ! lib.add_file("audiotest.au") ! lib.add_file("cfgparser.1") ! lib.add_file("test.xml") ! lib.add_file("test.xml.out") ! lib.add_file("testtar.tar") ! lib.glob("*.uue") ! lib.add_file("readme.txt", src="README") if dir=='decimaltestdata': lib.glob("*.decTest") --- 652,664 ---- if files: lib.remove_pyc() ! if dir=='test' and parent.physical=='Lib': ! lib.add_file("185test.db") ! lib.add_file("audiotest.au") ! lib.add_file("cfgparser.1") ! lib.add_file("test.xml") ! lib.add_file("test.xml.out") ! lib.add_file("testtar.tar") ! lib.glob("*.uue") ! lib.add_file("readme.txt", src="README") if dir=='decimaltestdata': lib.glob("*.decTest") From tim_one at users.sourceforge.net Mon Jul 26 02:42:44 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Mon Jul 26 02:42:46 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libos.tex,1.139,1.140 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29015/Doc/lib Modified Files: libos.tex Log Message: SF bugs 996748: os.environ documentation should indicate unreliability Clarifed that os.environ is captured once; emphasized that it's better to assign to os.environ than to call putenv() directly (the putenv() docs said so, but the environ docs didn't). Index: libos.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libos.tex,v retrieving revision 1.139 retrieving revision 1.140 diff -C2 -d -r1.139 -r1.140 *** libos.tex 19 Jul 2004 01:39:54 -0000 1.139 --- libos.tex 26 Jul 2004 00:42:41 -0000 1.140 *************** *** 91,100 **** platforms), and is equivalent to \code{getenv("HOME")} in C. If the platform supports the \function{putenv()} function, this mapping may be used to modify the environment as well as query the environment. \function{putenv()} will be called automatically when ! the mapping is modified. \note{On some platforms, including ! FreeBSD and Mac OS X, setting \code{environ} may cause memory leaks. ! Refer to the system documentation for putenv.} If \function{putenv()} is not provided, this mapping may be passed to --- 91,109 ---- platforms), and is equivalent to \code{getenv("HOME")} in C. + This mapping is captured the first time the \module{os} module is + imported, typically during Python startup as part of processing + \file{site.py}. Changes to the environment made after this time are + not reflected in \code{os.environ}, except for changes made by modifying + \code{os.environ} directly. + If the platform supports the \function{putenv()} function, this mapping may be used to modify the environment as well as query the environment. \function{putenv()} will be called automatically when ! the mapping is modified. ! \note{Calling \function{putenv()} directly does not change ! \code{os.environ}, so it's better to modify \code{os.environ}.} ! \note{On some platforms, including FreeBSD and Mac OS X, setting ! \code{environ} may cause memory leaks. Refer to the system documentation ! for \cfunction{putenv()}.} If \function{putenv()} is not provided, this mapping may be passed to From tim_one at users.sourceforge.net Mon Jul 26 06:58:52 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Mon Jul 26 06:58:55 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libmath.tex,1.32,1.33 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28458/Doc/lib Modified Files: libmath.tex Log Message: Typo in new docs. Index: libmath.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libmath.tex,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** libmath.tex 24 Jul 2004 23:00:24 -0000 1.32 --- libmath.tex 26 Jul 2004 04:58:50 -0000 1.33 *************** *** 158,162 **** \end{funcdesc} ! Hyerbolic functions: \begin{funcdesc}{cosh}{x} --- 158,162 ---- \end{funcdesc} ! Hyperbolic functions: \begin{funcdesc}{cosh}{x} From tim_one at users.sourceforge.net Mon Jul 26 07:12:03 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Mon Jul 26 07:12:06 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libmath.tex,1.33,1.34 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30093/Doc/lib Modified Files: libmath.tex Log Message: Explain that most floats are actually integers. This is a common confusion for people using floor(), ceil() and modf(). Index: libmath.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libmath.tex,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** libmath.tex 26 Jul 2004 04:58:50 -0000 1.33 --- libmath.tex 26 Jul 2004 05:12:01 -0000 1.34 *************** *** 80,83 **** --- 80,91 ---- thing in Python). + For the \function{ceil()}, \function{floor()}, and \function{modf()} + functions, note that \emph{all} floating-point numbers of sufficiently + large magnitude are exact integers. Python floats typically carry no more + than 53 bits of precision (the same as the platform C double type), in + which case any float \var{x} with \code{abs(\var{x}) >= 2**52} + necessarily has no fractional bits. + + Power and logarithmic functions: From loewis at users.sourceforge.net Mon Jul 26 14:05:19 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Mon Jul 26 14:05:27 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libcrypt.tex,1.16,1.17 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23574 Modified Files: libcrypt.tex Log Message: Patch #997668: Correct explanation of salts. Will backport to 2.3. Index: libcrypt.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libcrypt.tex,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** libcrypt.tex 9 May 2001 15:50:17 -0000 1.16 --- libcrypt.tex 26 Jul 2004 12:05:16 -0000 1.17 *************** *** 18,21 **** --- 18,25 ---- attempting to crack \UNIX{} passwords with a dictionary. + Notice that the behavior of this module depends on the actual implementation + of the \manpage{crypt}{3}\index{crypt(3)} routine in the running system. + Therefore, any extensions available on the current implementation will also + be available on this module. \begin{funcdesc}{crypt}{word, salt} \var{word} will usually be a user's password as typed at a prompt or *************** *** 26,29 **** --- 30,37 ---- string, which will be composed of characters from the same alphabet as the salt (the first two characters represent the salt itself). + + Since a few \manpage{crypt}{3}\index{crypt(3)} extensions allow different + values, with different sizes in the \var{salt}, it is recommended to use + the full crypted password as salt when checking for a password. \end{funcdesc} *************** *** 41,45 **** raise "Sorry, currently no support for shadow passwords" cleartext = getpass.getpass() ! return crypt.crypt(cleartext, cryptedpasswd[:2]) == cryptedpasswd else: return 1 --- 49,53 ---- raise "Sorry, currently no support for shadow passwords" cleartext = getpass.getpass() ! return crypt.crypt(cleartext, cryptedpasswd) == cryptedpasswd else: return 1 From loewis at users.sourceforge.net Mon Jul 26 14:05:38 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Mon Jul 26 14:05:41 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libcrypt.tex, 1.16, 1.16.36.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23811 Modified Files: Tag: release23-maint libcrypt.tex Log Message: Patch #997668: Correct explanation of salts. Index: libcrypt.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libcrypt.tex,v retrieving revision 1.16 retrieving revision 1.16.36.1 diff -C2 -d -r1.16 -r1.16.36.1 *** libcrypt.tex 9 May 2001 15:50:17 -0000 1.16 --- libcrypt.tex 26 Jul 2004 12:05:35 -0000 1.16.36.1 *************** *** 18,21 **** --- 18,25 ---- attempting to crack \UNIX{} passwords with a dictionary. + Notice that the behavior of this module depends on the actual implementation + of the \manpage{crypt}{3}\index{crypt(3)} routine in the running system. + Therefore, any extensions available on the current implementation will also + be available on this module. \begin{funcdesc}{crypt}{word, salt} \var{word} will usually be a user's password as typed at a prompt or *************** *** 26,29 **** --- 30,37 ---- string, which will be composed of characters from the same alphabet as the salt (the first two characters represent the salt itself). + + Since a few \manpage{crypt}{3}\index{crypt(3)} extensions allow different + values, with different sizes in the \var{salt}, it is recommended to use + the full crypted password as salt when checking for a password. \end{funcdesc} *************** *** 41,45 **** raise "Sorry, currently no support for shadow passwords" cleartext = getpass.getpass() ! return crypt.crypt(cleartext, cryptedpasswd[:2]) == cryptedpasswd else: return 1 --- 49,53 ---- raise "Sorry, currently no support for shadow passwords" cleartext = getpass.getpass() ! return crypt.crypt(cleartext, cryptedpasswd) == cryptedpasswd else: return 1 From loewis at users.sourceforge.net Mon Jul 26 14:09:16 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Mon Jul 26 14:09:19 2004 Subject: [Python-checkins] python/dist/src/Lib/test regrtest.py,1.155,1.156 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24212 Modified Files: regrtest.py Log Message: Patch #995782: Add FreeBSD 5 expectations. Will backport to 2.3. Index: regrtest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/regrtest.py,v retrieving revision 1.155 retrieving revision 1.156 diff -C2 -d -r1.155 -r1.156 *** regrtest.py 19 Jul 2004 06:39:37 -0000 1.155 --- regrtest.py 26 Jul 2004 12:09:13 -0000 1.156 *************** *** 980,983 **** --- 980,984 ---- """, } + _expectations['freebsd5'] = _expectations['freebsd4'] class _ExpectedSkips: From loewis at users.sourceforge.net Mon Jul 26 14:09:42 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Mon Jul 26 14:09:43 2004 Subject: [Python-checkins] python/dist/src/Lib/test regrtest.py, 1.145, 1.145.4.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24344 Modified Files: Tag: release23-maint regrtest.py Log Message: Patch #995782: Add FreeBSD 5 expectations. Index: regrtest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/regrtest.py,v retrieving revision 1.145 retrieving revision 1.145.4.1 diff -C2 -d -r1.145 -r1.145.4.1 *** regrtest.py 23 Jul 2003 00:30:39 -0000 1.145 --- regrtest.py 26 Jul 2004 12:09:30 -0000 1.145.4.1 *************** *** 936,939 **** --- 936,940 ---- """, } + _expectations['freebsd5'] = _expectations['freebsd4'] class _ExpectedSkips: From loewis at users.sourceforge.net Mon Jul 26 14:40:52 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Mon Jul 26 14:40:57 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libnntplib.tex,1.29,1.30 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29230/Doc/lib Modified Files: libnntplib.tex Log Message: Patch #605370: Add description[s] for RFC 2980 compliance. Index: libnntplib.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libnntplib.tex,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** libnntplib.tex 19 Apr 2003 18:04:53 -0000 1.29 --- libnntplib.tex 26 Jul 2004 12:40:50 -0000 1.30 *************** *** 176,179 **** --- 176,196 ---- calling \method{write()} on it to store the lines of the command output. If \var{file} is supplied, then the returned \var{list} is an empty list. + + \begin{methoddesc}{descriptions}{grouppattern} + Send a \samp{LIST NEWSGROUPS} command, where \var{grouppattern} is a wildmat + string as specified in RFC2980 (it's essentially the same as DOS or UNIX + shell wildcard strings). Return a pair \code{(\var{response}, + \var{list})}, where \var{list} is a list of tuples containing + \code{(\var{name}, \var{title})}. + \end{methoddesc} + + \begin{methoddesc}{description}{group} + Get a description for a single group \var{group}. If more than one group + matches (if 'group' is a real wildmat string), return the first match. If no group + matches, return an empty string. + + This elides the response code from the server. If the response code is + needed, use \method{descriptions()}. + \end{methoddesc} *************** *** 295,298 **** --- 312,318 ---- This is an optional NNTP extension, and may not be supported by all servers. + + RFC2980 says ``It is suggested that this extension be deprecated''. Use + \method{descriptions()} or \method{description()} instead. \end{methoddesc} From loewis at users.sourceforge.net Mon Jul 26 14:41:07 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Mon Jul 26 14:41:09 2004 Subject: [Python-checkins] python/dist/src/Misc ACKS, 1.272, 1.273 NEWS, 1.1053, 1.1054 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29230/Misc Modified Files: ACKS NEWS Log Message: Patch #605370: Add description[s] for RFC 2980 compliance. Index: ACKS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/ACKS,v retrieving revision 1.272 retrieving revision 1.273 diff -C2 -d -r1.272 -r1.273 *** ACKS 10 Jul 2004 21:21:55 -0000 1.272 --- ACKS 26 Jul 2004 12:40:50 -0000 1.273 *************** *** 164,167 **** --- 164,168 ---- Tom Epperly Stoffel Erasmus + Jürgen A. Erhard Michael Ernst Ben Escoto Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1053 retrieving revision 1.1054 diff -C2 -d -r1.1053 -r1.1054 *** NEWS 24 Jul 2004 23:00:24 -0000 1.1053 --- NEWS 26 Jul 2004 12:40:50 -0000 1.1054 *************** *** 45,48 **** --- 45,51 ---- ------- + - nntplib has two new methods: description and descriptions. They + use a more RFC-compliant way of getting a newsgroup description. + - Bug #993394. Fix a possible red herring of KeyError in 'threading' being raised during interpreter shutdown from a registered function with atexit From loewis at users.sourceforge.net Mon Jul 26 14:41:06 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Mon Jul 26 14:41:11 2004 Subject: [Python-checkins] python/dist/src/Lib nntplib.py,1.37,1.38 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29230/Lib Modified Files: nntplib.py Log Message: Patch #605370: Add description[s] for RFC 2980 compliance. Index: nntplib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/nntplib.py,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** nntplib.py 12 Feb 2004 17:35:06 -0000 1.37 --- nntplib.py 26 Jul 2004 12:40:50 -0000 1.38 *************** *** 298,301 **** --- 298,337 ---- return resp, list + def description(self, group): + + """Get a description for a single group. If more than one + group matches ('group' is a pattern), return the first. If no + group matches, return an empty string. + + This elides the response code from the server, since it can + only be '215' or '285' (for xgtitle) anyway. If the response + code is needed, use the 'descriptions' method. + + NOTE: This neither checks for a wildcard in 'group' nor does + it check whether the group actually exists.""" + + resp, lines = self.descriptions(group) + if len(lines) == 0: + return "" + else: + return lines[0][1] + + def descriptions(self, group_pattern): + """Get descriptions for a range of groups.""" + line_pat = re.compile("^(?P[^ \t]+)[ \t]+(.*)$") + # Try the more std (acc. to RFC2980) LIST NEWSGROUPS first + resp, raw_lines = self.longcmd('LIST NEWSGROUPS ' + group_pattern) + if resp[:3] != "215": + # Now the deprecated XGTITLE. This either raises an error + # or succeeds with the same output structure as LIST + # NEWSGROUPS. + resp, raw_lines = self.longcmd('XGTITLE ' + group_pattern) + lines = [] + for raw_line in raw_lines: + match = line_pat.search(raw_line.strip()) + if match: + lines.append(match.group(1, 2)) + return resp, lines + def group(self, name): """Process a GROUP command. Argument: From loewis at users.sourceforge.net Mon Jul 26 14:45:21 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Mon Jul 26 14:45:24 2004 Subject: [Python-checkins] python/dist/src/Lib locale.py,1.27,1.28 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29940/Lib Modified Files: locale.py Log Message: Patch #962487: Don't crash for empty locale names. Index: locale.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/locale.py,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** locale.py 10 Apr 2004 16:39:32 -0000 1.27 --- locale.py 26 Jul 2004 12:45:18 -0000 1.28 *************** *** 338,342 **** for variable in envvars: localename = lookup(variable,None) ! if localename is not None: break else: --- 338,342 ---- for variable in envvars: localename = lookup(variable,None) ! if localename: break else: From loewis at users.sourceforge.net Mon Jul 26 14:46:02 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Mon Jul 26 14:46:05 2004 Subject: [Python-checkins] python/dist/src/Lib locale.py,1.25,1.25.10.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30108 Modified Files: Tag: release23-maint locale.py Log Message: Patch #962487: Don't crash for empty locale names. Index: locale.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/locale.py,v retrieving revision 1.25 retrieving revision 1.25.10.1 diff -C2 -d -r1.25 -r1.25.10.1 *** locale.py 30 Mar 2003 15:42:13 -0000 1.25 --- locale.py 26 Jul 2004 12:45:59 -0000 1.25.10.1 *************** *** 340,344 **** for variable in envvars: localename = lookup(variable,None) ! if localename is not None: break else: --- 340,344 ---- for variable in envvars: localename = lookup(variable,None) ! if localename: break else: From anthonybaxter at users.sourceforge.net Mon Jul 26 16:32:14 2004 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Mon Jul 26 16:32:17 2004 Subject: [Python-checkins] python/dist/src/Misc/RPM python-2.3.spec, 1.2.12.13, 1.2.12.14 Message-ID: Update of /cvsroot/python/python/dist/src/Misc/RPM In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16773 Modified Files: Tag: release23-maint python-2.3.spec Log Message: new .spec file, from #996316 Index: python-2.3.spec =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/RPM/Attic/python-2.3.spec,v retrieving revision 1.2.12.13 retrieving revision 1.2.12.14 diff -C2 -d -r1.2.12.13 -r1.2.12.14 *** python-2.3.spec 31 May 2004 19:38:08 -0000 1.2.12.13 --- python-2.3.spec 26 Jul 2004 14:32:11 -0000 1.2.12.14 *************** *** 26,29 **** --- 26,32 ---- %define config_ipv6 no + # Location of the HTML directory. + %define config_htmldir /var/www/html/python + ################################# # End of user-modifiable configs *************** *** 33,37 **** %define version 2.3.4 %define libvers 2.3 ! %define release 2pydotorg %define __prefix /usr --- 36,40 ---- %define version 2.3.4 %define libvers 2.3 ! %define release 3pydotorg %define __prefix /usr *************** *** 41,44 **** --- 44,48 ---- %define binsuffix %(if [ "%{config_binsuffix}" = none ]; then echo ; else echo "%{config_binsuffix}"; fi) %define include_tkinter %(if [ \\( "%{config_tkinter}" = auto -a -f /usr/bin/wish \\) -o "%{config_tkinter}" = yes ]; then echo 1; else echo 0; fi) + %define libdirname %(( uname -m | egrep -q '_64$' && [ -d /usr/lib64 ] && echo lib64 ) || echo lib) # detect if documentation is available *************** *** 128,131 **** --- 132,141 ---- %changelog + * Thu Jul 22 2004 Sean Reifschneider [2.3.4-3pydotorg] + - Paul Tiemann fixes for %{prefix}. + - Adding permission changes for directory as suggested by reimeika.ca + - Adding code to detect when it should be using lib64. + - Adding a define for the location of /var/www/html for docs. + * Thu May 27 2004 Sean Reifschneider [2.3.4-2pydotorg] - Including changes from Ian Holsman to build under Red Hat 7.3. *************** *** 214,221 **** # set the install path echo '[install_scripts]' >setup.cfg ! echo 'install_dir='"${RPM_BUILD_ROOT}/usr/bin" >>setup.cfg [ -d "$RPM_BUILD_ROOT" -a "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT ! mkdir -p $RPM_BUILD_ROOT%{__prefix}/lib/python%{libvers}/lib-dynload make prefix=$RPM_BUILD_ROOT%{__prefix} install --- 224,231 ---- # set the install path echo '[install_scripts]' >setup.cfg ! echo 'install_dir='"${RPM_BUILD_ROOT}%{__prefix}/bin" >>setup.cfg [ -d "$RPM_BUILD_ROOT" -a "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT ! mkdir -p $RPM_BUILD_ROOT%{__prefix}/%{libdirname}/python%{libvers}/lib-dynload make prefix=$RPM_BUILD_ROOT%{__prefix} install *************** *** 226,230 **** cd $RPM_BUILD_ROOT%{__prefix}/bin mv pydoc pydoc.old ! sed 's|#!.*|#!/usr/bin/env python'%{binsuffix}'|' \ pydoc.old >pydoc chmod 755 pydoc --- 236,240 ---- cd $RPM_BUILD_ROOT%{__prefix}/bin mv pydoc pydoc.old ! sed 's|#!.*|#!%{__prefix}/bin/env python'%{binsuffix}'|' \ pydoc.old >pydoc chmod 755 pydoc *************** *** 245,256 **** ######## # Tools ! echo '#!/bin/bash' >${RPM_BUILD_ROOT}%{_bindir}/idle%{binsuffix} ! echo 'exec %{__prefix}/bin/python%{binsuffix} /usr/lib/python%{libvers}/idlelib/idle.py' >>$RPM_BUILD_ROOT%{_bindir}/idle%{binsuffix} ! chmod 755 $RPM_BUILD_ROOT%{_bindir}/idle%{binsuffix} ! cp -a Tools $RPM_BUILD_ROOT%{__prefix}/lib/python%{libvers} # MAKE FILE LISTS rm -f mainpkg.files ! find "$RPM_BUILD_ROOT""%{__prefix}"/lib/python%{libvers}/lib-dynload -type f | sed "s|^${RPM_BUILD_ROOT}|/|" | grep -v -e '_tkinter.so$' >mainpkg.files --- 255,266 ---- ######## # Tools ! echo '#!/bin/bash' >${RPM_BUILD_ROOT}%{__prefix}/bin/idle%{binsuffix} ! echo 'exec %{__prefix}/bin/python%{binsuffix} %{__prefix}/%{libdirname}/python%{libvers}/idlelib/idle.py' >>$RPM_BUILD_ROOT%{__prefix}/bin/idle%{binsuffix} ! chmod 755 $RPM_BUILD_ROOT%{__prefix}/bin/idle%{binsuffix} ! cp -a Tools $RPM_BUILD_ROOT%{__prefix}/%{libdirname}/python%{libvers} # MAKE FILE LISTS rm -f mainpkg.files ! find "$RPM_BUILD_ROOT""%{__prefix}"/%{libdirname}/python%{libvers}/lib-dynload -type f | sed "s|^${RPM_BUILD_ROOT}|/|" | grep -v -e '_tkinter.so$' >mainpkg.files *************** *** 260,265 **** rm -f tools.files ! find "$RPM_BUILD_ROOT""%{__prefix}"/lib/python%{libvers}/idlelib \ ! "$RPM_BUILD_ROOT""%{__prefix}"/lib/python%{libvers}/Tools -type f | sed "s|^${RPM_BUILD_ROOT}|/|" >tools.files echo "%{__prefix}"/bin/idle%{binsuffix} >>tools.files --- 270,275 ---- rm -f tools.files ! find "$RPM_BUILD_ROOT""%{__prefix}"/%{libdirname}/python%{libvers}/idlelib \ ! "$RPM_BUILD_ROOT""%{__prefix}"/%{libdirname}/python%{libvers}/Tools -type f | sed "s|^${RPM_BUILD_ROOT}|/|" >tools.files echo "%{__prefix}"/bin/idle%{binsuffix} >>tools.files *************** *** 268,274 **** # Docs %if %{include_docs} ! mkdir -p "$RPM_BUILD_ROOT"/var/www/html/python ( ! cd "$RPM_BUILD_ROOT"/var/www/html/python bunzip2 < %{SOURCE1} | tar x ) --- 278,284 ---- # Docs %if %{include_docs} ! mkdir -p "$RPM_BUILD_ROOT"%{config_htmldir} ( ! cd "$RPM_BUILD_ROOT"%{config_htmldir} bunzip2 < %{SOURCE1} | tar x ) *************** *** 280,284 **** do FIXFILE="$file" ! sed 's|^#!.*python|#!/usr/bin/env python'"%{binsuffix}"'|' \ "$FIXFILE" >/tmp/fix-python-path.$$ cat /tmp/fix-python-path.$$ >"$FIXFILE" --- 290,294 ---- do FIXFILE="$file" ! sed 's|^#!.*python|#!%{__prefix}/bin/env python'"%{binsuffix}"'|' \ "$FIXFILE" >/tmp/fix-python-path.$$ cat /tmp/fix-python-path.$$ >"$FIXFILE" *************** *** 322,349 **** %{__prefix}/man/man1/python%{binsuffix}.1* ! %dir %{__prefix}/include/python%{libvers} ! %dir %{__prefix}/lib/python%{libvers}/ ! %{__prefix}/lib/python%{libvers}/*.txt ! %{__prefix}/lib/python%{libvers}/*.py* ! %{__prefix}/lib/python%{libvers}/pdb.doc ! %{__prefix}/lib/python%{libvers}/profile.doc ! %{__prefix}/lib/python%{libvers}/curses ! %{__prefix}/lib/python%{libvers}/distutils ! %{__prefix}/lib/python%{libvers}/encodings ! %{__prefix}/lib/python%{libvers}/plat-linux2 ! %{__prefix}/lib/python%{libvers}/site-packages ! %{__prefix}/lib/python%{libvers}/test ! %{__prefix}/lib/python%{libvers}/xml ! %{__prefix}/lib/python%{libvers}/email ! %{__prefix}/lib/python%{libvers}/compiler ! %{__prefix}/lib/python%{libvers}/bsddb ! %{__prefix}/lib/python%{libvers}/hotshot ! %{__prefix}/lib/python%{libvers}/logging ! %{__prefix}/lib/python%{libvers}/lib-old %files devel %defattr(-,root,root) %{__prefix}/include/python%{libvers}/*.h ! %{__prefix}/lib/python%{libvers}/config %files -f tools.files tools --- 332,359 ---- %{__prefix}/man/man1/python%{binsuffix}.1* ! %attr(755,root,root) %dir %{__prefix}/include/python%{libvers} ! %attr(755,root,root) %dir %{__prefix}/%{libdirname}/python%{libvers}/ ! %{__prefix}/%{libdirname}/python%{libvers}/*.txt ! %{__prefix}/%{libdirname}/python%{libvers}/*.py* ! %{__prefix}/%{libdirname}/python%{libvers}/pdb.doc ! %{__prefix}/%{libdirname}/python%{libvers}/profile.doc ! %{__prefix}/%{libdirname}/python%{libvers}/curses ! %{__prefix}/%{libdirname}/python%{libvers}/distutils ! %{__prefix}/%{libdirname}/python%{libvers}/encodings ! %{__prefix}/%{libdirname}/python%{libvers}/plat-linux2 ! %{__prefix}/%{libdirname}/python%{libvers}/site-packages ! %{__prefix}/%{libdirname}/python%{libvers}/test ! %{__prefix}/%{libdirname}/python%{libvers}/xml ! %{__prefix}/%{libdirname}/python%{libvers}/email ! %{__prefix}/%{libdirname}/python%{libvers}/compiler ! %{__prefix}/%{libdirname}/python%{libvers}/bsddb ! %{__prefix}/%{libdirname}/python%{libvers}/hotshot ! %{__prefix}/%{libdirname}/python%{libvers}/logging ! %{__prefix}/%{libdirname}/python%{libvers}/lib-old %files devel %defattr(-,root,root) %{__prefix}/include/python%{libvers}/*.h ! %{__prefix}/%{libdirname}/python%{libvers}/config %files -f tools.files tools *************** *** 353,358 **** %files tkinter %defattr(-,root,root) ! %{__prefix}/lib/python%{libvers}/lib-tk ! %{__prefix}/lib/python%{libvers}/lib-dynload/_tkinter.so* %endif --- 363,368 ---- %files tkinter %defattr(-,root,root) ! %{__prefix}/%{libdirname}/python%{libvers}/lib-tk ! %{__prefix}/%{libdirname}/python%{libvers}/lib-dynload/_tkinter.so* %endif *************** *** 360,363 **** %files docs %defattr(-,root,root) ! /var/www/html/python/* %endif --- 370,373 ---- %files docs %defattr(-,root,root) ! %{config_htmldir}/* %endif From fdrake at users.sourceforge.net Mon Jul 26 18:32:32 2004 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Mon Jul 26 18:32:36 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libbsddb.tex, 1.11.10.3, 1.11.10.4 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9493 Modified Files: Tag: release23-maint libbsddb.tex Log Message: fix information about what flag database files are opened with by default Index: libbsddb.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libbsddb.tex,v retrieving revision 1.11.10.3 retrieving revision 1.11.10.4 diff -C2 -d -r1.11.10.3 -r1.11.10.4 *** libbsddb.tex 7 Dec 2003 13:05:15 -0000 1.11.10.3 --- libbsddb.tex 26 Jul 2004 16:32:30 -0000 1.11.10.4 *************** *** 55,60 **** \var{filename}. The optional \var{flag} identifies the mode used to open the file. It may be ! \character{r} (read only, default), \character{w} (read-write) , ! \character{c} (read-write - create if necessary) or \character{n} (read-write - truncate to zero length). The other arguments are rarely used and are just passed to the low-level --- 55,60 ---- \var{filename}. The optional \var{flag} identifies the mode used to open the file. It may be ! \character{r} (read only), \character{w} (read-write), ! \character{c} (read-write - create if necessary, default) or \character{n} (read-write - truncate to zero length). The other arguments are rarely used and are just passed to the low-level *************** *** 71,76 **** \var{filename}. The optional \var{flag} identifies the mode used to open the file. It may be ! \character{r} (read only, default), \character{w} (read-write), ! \character{c} (read-write - create if necessary) or \character{n} (read-write - truncate to zero length). The other arguments are rarely used and are just passed to the low-level dbopen --- 71,76 ---- \var{filename}. The optional \var{flag} identifies the mode used to open the file. It may be ! \character{r} (read only), \character{w} (read-write), ! \character{c} (read-write - create if necessary, default) or \character{n} (read-write - truncate to zero length). The other arguments are rarely used and are just passed to the low-level dbopen *************** *** 87,92 **** \var{filename}. The optional \var{flag} identifies the mode used to open the file. It may be ! \character{r} (read only, default), \character{w} (read-write), ! \character{c} (read-write - create if necessary) or \character{n} (read-write - truncate to zero length). The other arguments are rarely used and are just passed to the low-level dbopen --- 87,92 ---- \var{filename}. The optional \var{flag} identifies the mode used to open the file. It may be ! \character{r} (read only), \character{w} (read-write), ! \character{c} (read-write - create if necessary; the default) or \character{n} (read-write - truncate to zero length). The other arguments are rarely used and are just passed to the low-level dbopen From fdrake at users.sourceforge.net Mon Jul 26 18:33:41 2004 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Mon Jul 26 18:33:45 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libbsddb.tex,1.16,1.17 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9630 Modified Files: libbsddb.tex Log Message: fix information about what flag database files are opened with by default Index: libbsddb.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libbsddb.tex,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** libbsddb.tex 24 Jun 2004 06:03:59 -0000 1.16 --- libbsddb.tex 26 Jul 2004 16:33:29 -0000 1.17 *************** *** 47,52 **** \var{filename}. The optional \var{flag} identifies the mode used to open the file. It may be ! \character{r} (read only, default), \character{w} (read-write) , ! \character{c} (read-write - create if necessary) or \character{n} (read-write - truncate to zero length). The other arguments are rarely used and are just passed to the low-level --- 47,52 ---- \var{filename}. The optional \var{flag} identifies the mode used to open the file. It may be ! \character{r} (read only), \character{w} (read-write) , ! \character{c} (read-write - create if necessary; the default) or \character{n} (read-write - truncate to zero length). The other arguments are rarely used and are just passed to the low-level *************** *** 63,68 **** \var{filename}. The optional \var{flag} identifies the mode used to open the file. It may be ! \character{r} (read only, default), \character{w} (read-write), ! \character{c} (read-write - create if necessary) or \character{n} (read-write - truncate to zero length). The other arguments are rarely used and are just passed to the low-level dbopen --- 63,68 ---- \var{filename}. The optional \var{flag} identifies the mode used to open the file. It may be ! \character{r} (read only), \character{w} (read-write), ! \character{c} (read-write - create if necessary; the default) or \character{n} (read-write - truncate to zero length). The other arguments are rarely used and are just passed to the low-level dbopen *************** *** 79,84 **** \var{filename}. The optional \var{flag} identifies the mode used to open the file. It may be ! \character{r} (read only, default), \character{w} (read-write), ! \character{c} (read-write - create if necessary) or \character{n} (read-write - truncate to zero length). The other arguments are rarely used and are just passed to the low-level dbopen --- 79,84 ---- \var{filename}. The optional \var{flag} identifies the mode used to open the file. It may be ! \character{r} (read only), \character{w} (read-write), ! \character{c} (read-write - create if necessary; the default) or \character{n} (read-write - truncate to zero length). The other arguments are rarely used and are just passed to the low-level dbopen From fdrake at users.sourceforge.net Mon Jul 26 18:34:44 2004 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Mon Jul 26 18:34:47 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libbsddb.tex, 1.11.10.4, 1.11.10.5 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9943 Modified Files: Tag: release23-maint libbsddb.tex Log Message: minor cleanup of the previous change; now matches corresponding change on the trunk Index: libbsddb.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libbsddb.tex,v retrieving revision 1.11.10.4 retrieving revision 1.11.10.5 diff -C2 -d -r1.11.10.4 -r1.11.10.5 *** libbsddb.tex 26 Jul 2004 16:32:30 -0000 1.11.10.4 --- libbsddb.tex 26 Jul 2004 16:34:41 -0000 1.11.10.5 *************** *** 56,60 **** \var{flag} identifies the mode used to open the file. It may be \character{r} (read only), \character{w} (read-write), ! \character{c} (read-write - create if necessary, default) or \character{n} (read-write - truncate to zero length). The other arguments are rarely used and are just passed to the low-level --- 56,60 ---- \var{flag} identifies the mode used to open the file. It may be \character{r} (read only), \character{w} (read-write), ! \character{c} (read-write - create if necessary; the default) or \character{n} (read-write - truncate to zero length). The other arguments are rarely used and are just passed to the low-level *************** *** 72,76 **** \var{flag} identifies the mode used to open the file. It may be \character{r} (read only), \character{w} (read-write), ! \character{c} (read-write - create if necessary, default) or \character{n} (read-write - truncate to zero length). The other arguments are rarely used and are just passed to the low-level dbopen --- 72,76 ---- \var{flag} identifies the mode used to open the file. It may be \character{r} (read only), \character{w} (read-write), ! \character{c} (read-write - create if necessary; the default) or \character{n} (read-write - truncate to zero length). The other arguments are rarely used and are just passed to the low-level dbopen From fdrake at users.sourceforge.net Mon Jul 26 19:58:55 2004 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Mon Jul 26 19:58:59 2004 Subject: [Python-checkins] python/dist/src/Doc/tools update-docs.sh, 1.10.16.1, 1.10.16.2 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/tools In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26066/tools Modified Files: Tag: release23-maint update-docs.sh Log Message: Save the uploaded documentation tarball (already done on the trunk). Index: update-docs.sh =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/tools/update-docs.sh,v retrieving revision 1.10.16.1 retrieving revision 1.10.16.2 diff -C2 -d -r1.10.16.1 -r1.10.16.2 *** update-docs.sh 13 Jul 2004 17:09:54 -0000 1.10.16.1 --- update-docs.sh 26 Jul 2004 17:58:53 -0000 1.10.16.2 *************** *** 29,31 **** rmdir $TMPDIR rm -rf $DOCTYPE-temp || exit $? ! rm "$UPDATES" || exit $? --- 29,31 ---- rmdir $TMPDIR rm -rf $DOCTYPE-temp || exit $? ! mv "$UPDATES" python-docs-$DOCTYPE.tar.bz2 || exit $? From akuchling at users.sourceforge.net Mon Jul 26 20:52:57 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Mon Jul 26 20:53:00 2004 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew24.tex, 1.72, 1.73 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5729 Modified Files: whatsnew24.tex Log Message: [Bug #997166] Fix example Index: whatsnew24.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew24.tex,v retrieving revision 1.72 retrieving revision 1.73 diff -C2 -d -r1.72 -r1.73 *** whatsnew24.tex 21 Jul 2004 13:00:06 -0000 1.72 --- whatsnew24.tex 26 Jul 2004 18:52:48 -0000 1.73 *************** *** 592,599 **** [11, 12, 13, 14, 15, 16, 17, 18, 19] >>> L # original is left unchanged ! [9,7,8,3,2,4,1,6,5] ! ! >>> sorted('Monte Python') # any iterable may be an input ! [' ', 'M', 'P', 'e', 'h', 'n', 'n', 'o', 'o', 't', 't', 'y'] >>> # List the contents of a dict sorted by key values --- 592,598 ---- [11, 12, 13, 14, 15, 16, 17, 18, 19] >>> L # original is left unchanged ! [9,7,8,3,2,4,1,6,5] ! >>> sorted('Monty Python') # any iterable may be an input ! [' ', 'M', 'P', 'h', 'n', 'n', 'o', 'o', 't', 't', 'y', 'y'] >>> # List the contents of a dict sorted by key values *************** *** 1050,1054 **** The author would like to thank the following people for offering suggestions, corrections and assistance with various drafts of this ! article: Raymond Hettinger. \end{document} --- 1049,1053 ---- The author would like to thank the following people for offering suggestions, corrections and assistance with various drafts of this ! article: Michael Dyck, Raymond Hettinger. \end{document} From akuchling at users.sourceforge.net Mon Jul 26 21:25:56 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Mon Jul 26 21:25:59 2004 Subject: [Python-checkins] python/dist/src/Doc/api refcounting.tex,1.3,1.4 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/api In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12419 Modified Files: refcounting.tex Log Message: Two typo fixes Index: refcounting.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/refcounting.tex,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** refcounting.tex 14 Jul 2004 19:07:35 -0000 1.3 --- refcounting.tex 26 Jul 2004 19:25:54 -0000 1.4 *************** *** 47,54 **** \NULL, in which case the macro has no effect; otherwise the effect is the same as for \cfunction{Py_DECREF()}, except that the argument ! is also set to \NULL. The warning for \cfunction{Py_DECREF()}, does not apply with respect to the object passed because the macro carefully uses a temporary variable and sets the argument to \NULL ! before decrementing it's reference count. It is a good idea to use this macro whenever decrementing the value --- 47,54 ---- \NULL, in which case the macro has no effect; otherwise the effect is the same as for \cfunction{Py_DECREF()}, except that the argument ! is also set to \NULL. The warning for \cfunction{Py_DECREF()} does not apply with respect to the object passed because the macro carefully uses a temporary variable and sets the argument to \NULL ! before decrementing its reference count. It is a good idea to use this macro whenever decrementing the value From akuchling at users.sourceforge.net Mon Jul 26 21:28:48 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Mon Jul 26 21:28:51 2004 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew24.tex, 1.73, 1.74 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13112 Modified Files: whatsnew24.tex Log Message: Add some items Index: whatsnew24.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew24.tex,v retrieving revision 1.73 retrieving revision 1.74 diff -C2 -d -r1.73 -r1.74 *** whatsnew24.tex 26 Jul 2004 18:52:48 -0000 1.73 --- whatsnew24.tex 26 Jul 2004 19:28:46 -0000 1.74 *************** *** 839,842 **** --- 839,848 ---- bookmarking, windowing, or lookahead iterators. + \item A number of functions were added to the \module{locale} + module, such as \function{bind_textdomain_codeset()} to specify a + particular encoding, and a family of \function{l*gettext()} functions + that return messages in the chosen encoding. + (Contributed by Gustavo Niemeyer.) + \item The \module{logging} package's \function{basicConfig} function gained some keyword arguments to simplify log configuration. The *************** *** 859,862 **** --- 865,873 ---- be used to implement other rotating handlers. + \item The \module{nntplib} module's \class{NNTP} class gained + \method{description()} and \method{descriptions()} methods to retrieve + newsgroup descriptions for a single group or for a range of groups. + (Contributed by J\"urgen A. Erhard.) + \item The \module{operator} module gained two new functions, \function{attrgetter(\var{attr})} and \function{itemgetter(\var{index})}. *************** *** 960,963 **** --- 971,978 ---- \csimplemacro{Py_RETURN_TRUE}, and \csimplemacro{Py_RETURN_FALSE}. + \item Another new macro, \csimplemacro{Py_CLEAR(\var{obj})}, + decreases the reference count of \var{obj} and sets \var{obj} to the + null pointer. + \item A new function, \cfunction{PyTuple_Pack(\var{N}, \var{obj1}, \var{obj2}, ..., \var{objN})}, constructs tuples from a variable From loewis at users.sourceforge.net Tue Jul 27 07:07:20 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Tue Jul 27 07:07:25 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libimaplib.tex,1.26,1.27 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10583/Doc/lib Modified Files: libimaplib.tex Log Message: Patch #998149: imaplib deleteacl and myrights. Index: libimaplib.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libimaplib.tex,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** libimaplib.tex 20 May 2004 12:12:58 -0000 1.26 --- libimaplib.tex 27 Jul 2004 05:07:18 -0000 1.27 *************** *** 183,186 **** --- 183,190 ---- \end{methoddesc} + \begin{methoddesc}{deleteacl}{mailbox, who} + Delete the ACLs (remove any rights) set for who on mailbox. + \end{methoddesc} + \begin{methoddesc}{expunge}{} Permanently remove deleted items from selected mailbox. Generates an *************** *** 243,246 **** --- 247,254 ---- \end{methoddesc} + \begin{methoddes}{myrights}{mailbox} + Show my ACLs for a mailbox (i.e. the rights that I have on mailbox). + \end{methoddesc} + \begin{methoddesc}{namespace}{} Returns IMAP namespaces as defined in RFC2342. From loewis at users.sourceforge.net Tue Jul 27 07:07:22 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Tue Jul 27 07:07:27 2004 Subject: [Python-checkins] python/dist/src/Lib imaplib.py,1.70,1.71 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10583/Lib Modified Files: imaplib.py Log Message: Patch #998149: imaplib deleteacl and myrights. Index: imaplib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/imaplib.py,v retrieving revision 1.70 retrieving revision 1.71 diff -C2 -d -r1.70 -r1.71 *** imaplib.py 2 Jun 2004 00:42:36 -0000 1.70 --- imaplib.py 27 Jul 2004 05:07:18 -0000 1.71 *************** *** 47,50 **** --- 47,51 ---- 'CREATE': ('AUTH', 'SELECTED'), 'DELETE': ('AUTH', 'SELECTED'), + 'DELETEACL': ('AUTH', 'SELECTED'), 'EXAMINE': ('AUTH', 'SELECTED'), 'EXPUNGE': ('SELECTED',), *************** *** 53,56 **** --- 54,58 ---- 'GETQUOTA': ('AUTH', 'SELECTED'), 'GETQUOTAROOT': ('AUTH', 'SELECTED'), + 'MYRIGHTS': ('AUTH', 'SELECTED'), 'LIST': ('AUTH', 'SELECTED'), 'LOGIN': ('NONAUTH',), *************** *** 390,393 **** --- 392,401 ---- return self._simple_command('DELETE', mailbox) + def deleteacl(self, mailbox, who): + """Delete the ACLs (remove any rights) set for who on mailbox. + + (typ, [data]) = .deleteacl(mailbox, who) + """ + return self._simple_command('DELETEACL', mailbox, who) def expunge(self): *************** *** 519,522 **** --- 527,537 ---- return self._untagged_response(typ, dat, name) + def myrights(self, mailbox): + """Show my ACLs for a mailbox (i.e. the rights that I have on mailbox). + + (typ, [data]) = .myrights(mailbox) + """ + typ,dat = self._simple_command('MYRIGHTS', mailbox) + return self._untagged_response(typ, dat, 'MYRIGHTS') def namespace(self): From loewis at users.sourceforge.net Tue Jul 27 07:07:22 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Tue Jul 27 07:07:29 2004 Subject: [Python-checkins] python/dist/src/Misc ACKS, 1.273, 1.274 NEWS, 1.1054, 1.1055 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10583/Misc Modified Files: ACKS NEWS Log Message: Patch #998149: imaplib deleteacl and myrights. Index: ACKS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/ACKS,v retrieving revision 1.273 retrieving revision 1.274 diff -C2 -d -r1.273 -r1.274 *** ACKS 26 Jul 2004 12:40:50 -0000 1.273 --- ACKS 27 Jul 2004 05:07:19 -0000 1.274 *************** *** 329,332 **** --- 329,333 ---- Andrew Kuchling Vladimir Kushnir + Arnaud Mazin Cameron Laird Tino Lange Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1054 retrieving revision 1.1055 diff -C2 -d -r1.1054 -r1.1055 *** NEWS 26 Jul 2004 12:40:50 -0000 1.1054 --- NEWS 27 Jul 2004 05:07:19 -0000 1.1055 *************** *** 45,48 **** --- 45,50 ---- ------- + - imaplib has two new methods: deleteacl and myrights. + - nntplib has two new methods: description and descriptions. They use a more RFC-compliant way of getting a newsgroup description. From loewis at users.sourceforge.net Tue Jul 27 07:22:35 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Tue Jul 27 07:22:38 2004 Subject: [Python-checkins] python/dist/src/Lib/test pickletester.py, 1.56, 1.57 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12675/Lib/test Modified Files: pickletester.py Log Message: Patch #995766: Keyword argument support in cPickle. Index: pickletester.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/pickletester.py,v retrieving revision 1.56 retrieving revision 1.57 diff -C2 -d -r1.56 -r1.57 *** pickletester.py 28 Oct 2003 12:05:47 -0000 1.56 --- pickletester.py 27 Jul 2004 05:22:32 -0000 1.57 *************** *** 917,920 **** --- 917,930 ---- self.assertEqual(self.module.HIGHEST_PROTOCOL, 2) + def test_callapi(self): + from cStringIO import StringIO + f = StringIO() + # With and without keyword arguments + self.module.dump(123, f, -1) + self.module.dump(123, file=f, protocol=-1) + self.module.dumps(123, -1) + self.module.dumps(123, protocol=-1) + self.module.Pickler(f, -1) + self.module.Pickler(f, protocol=-1) class AbstractPersistentPicklerTests(unittest.TestCase): From loewis at users.sourceforge.net Tue Jul 27 07:22:35 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Tue Jul 27 07:22:39 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1055,1.1056 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12675/Misc Modified Files: NEWS Log Message: Patch #995766: Keyword argument support in cPickle. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1055 retrieving revision 1.1056 diff -C2 -d -r1.1055 -r1.1056 *** NEWS 27 Jul 2004 05:07:19 -0000 1.1055 --- NEWS 27 Jul 2004 05:22:33 -0000 1.1056 *************** *** 42,45 **** --- 42,47 ---- ----------------- + - cpickle now supports the same keyword arguments as pickle. + Library ------- From loewis at users.sourceforge.net Tue Jul 27 07:22:36 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Tue Jul 27 07:22:42 2004 Subject: [Python-checkins] python/dist/src/Modules cPickle.c,2.150,2.151 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12675/Modules Modified Files: cPickle.c Log Message: Patch #995766: Keyword argument support in cPickle. Index: cPickle.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/cPickle.c,v retrieving revision 2.150 retrieving revision 2.151 diff -C2 -d -r2.150 -r2.151 *** cPickle.c 8 Jun 2004 18:52:52 -0000 2.150 --- cPickle.c 27 Jul 2004 05:22:33 -0000 2.151 *************** *** 2851,2861 **** static PyObject * ! get_Pickler(PyObject *self, PyObject *args) { PyObject *file = NULL; int proto = 0; /* XXX ! * The documented signature is Pickler(file, proto=0), but this * accepts Pickler() and Pickler(integer) too. The meaning then * is clear as mud, undocumented, and not supported by pickle.py. --- 2851,2862 ---- static PyObject * ! get_Pickler(PyObject *self, PyObject *args, PyObject *kwds) { + static char *kwlist[] = {"file", "protocol", NULL}; PyObject *file = NULL; int proto = 0; /* XXX ! * The documented signature is Pickler(file, protocol=0), but this * accepts Pickler() and Pickler(integer) too. The meaning then * is clear as mud, undocumented, and not supported by pickle.py. *************** *** 2866,2870 **** PyErr_Clear(); proto = 0; ! if (!PyArg_ParseTuple(args, "O|i:Pickler", &file, &proto)) return NULL; } --- 2867,2872 ---- PyErr_Clear(); proto = 0; ! if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|i:Pickler", ! kwlist, &file, &proto)) return NULL; } *************** *** 5378,5390 **** */ ! /* dump(obj, file, proto=0). */ static PyObject * ! cpm_dump(PyObject *self, PyObject *args) { PyObject *ob, *file, *res = NULL; Picklerobject *pickler = 0; int proto = 0; ! if (!( PyArg_ParseTuple(args, "OO|i", &ob, &file, &proto))) goto finally; --- 5380,5394 ---- */ ! /* dump(obj, file, protocol=0). */ static PyObject * ! cpm_dump(PyObject *self, PyObject *args, PyObject *kwds) { + static char *kwlist[] = {"obj", "file", "protocol", NULL}; PyObject *ob, *file, *res = NULL; Picklerobject *pickler = 0; int proto = 0; ! if (!( PyArg_ParseTupleAndKeywords(args, kwds, "OO|i", kwlist, ! &ob, &file, &proto))) goto finally; *************** *** 5405,5417 **** ! /* dumps(obj, proto=0). */ static PyObject * ! cpm_dumps(PyObject *self, PyObject *args) { PyObject *ob, *file = 0, *res = NULL; Picklerobject *pickler = 0; int proto = 0; ! if (!( PyArg_ParseTuple(args, "O|i:dumps", &ob, &proto))) goto finally; --- 5409,5423 ---- ! /* dumps(obj, protocol=0). */ static PyObject * ! cpm_dumps(PyObject *self, PyObject *args, PyObject *kwds) { + static char *kwlist[] = {"obj", "protocol", NULL}; PyObject *ob, *file = 0, *res = NULL; Picklerobject *pickler = 0; int proto = 0; ! if (!( PyArg_ParseTupleAndKeywords(args, kwds, "O|i:dumps", kwlist, ! &ob, &proto))) goto finally; *************** *** 5514,5519 **** static struct PyMethodDef cPickle_methods[] = { ! {"dump", (PyCFunction)cpm_dump, METH_VARARGS, ! PyDoc_STR("dump(object, file, proto=0) -- " "Write an object in pickle format to the given file.\n" "\n" --- 5520,5525 ---- static struct PyMethodDef cPickle_methods[] = { ! {"dump", (PyCFunction)cpm_dump, METH_VARARGS | METH_KEYWORDS, ! PyDoc_STR("dump(obj, file, protocol=0) -- " "Write an object in pickle format to the given file.\n" "\n" *************** *** 5521,5526 **** }, ! {"dumps", (PyCFunction)cpm_dumps, METH_VARARGS, ! PyDoc_STR("dumps(object, proto=0) -- " "Return a string containing an object in pickle format.\n" "\n" --- 5527,5532 ---- }, ! {"dumps", (PyCFunction)cpm_dumps, METH_VARARGS | METH_KEYWORDS, ! PyDoc_STR("dumps(obj, protocol=0) -- " "Return a string containing an object in pickle format.\n" "\n" *************** *** 5534,5539 **** PyDoc_STR("loads(string) -- Load a pickle from the given string")}, ! {"Pickler", (PyCFunction)get_Pickler, METH_VARARGS, ! PyDoc_STR("Pickler(file, proto=0) -- Create a pickler.\n" "\n" "This takes a file-like object for writing a pickle data stream.\n" --- 5540,5545 ---- PyDoc_STR("loads(string) -- Load a pickle from the given string")}, ! {"Pickler", (PyCFunction)get_Pickler, METH_VARARGS | METH_KEYWORDS, ! PyDoc_STR("Pickler(file, protocol=0) -- Create a pickler.\n" "\n" "This takes a file-like object for writing a pickle data stream.\n" From akuchling at users.sourceforge.net Tue Jul 27 14:13:29 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Tue Jul 27 14:13:32 2004 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew24.tex, 1.74, 1.75 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12175 Modified Files: whatsnew24.tex Log Message: Add an item Index: whatsnew24.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew24.tex,v retrieving revision 1.74 retrieving revision 1.75 diff -C2 -d -r1.74 -r1.75 *** whatsnew24.tex 26 Jul 2004 19:28:46 -0000 1.74 --- whatsnew24.tex 27 Jul 2004 12:13:25 -0000 1.75 *************** *** 758,763 **** expense of a full sort. ! \item The \module{imaplib} module now supports IMAP's THREAD command. ! (Contributed by Yves Dionne.) \item The \module{itertools} module gained a --- 758,764 ---- expense of a full sort. ! \item The \module{imaplib} module now supports IMAP's THREAD command ! (contributed by Yves Dionne) and new \method{deleteacl()} and ! \method{myrights()} methods (contributed by Arnaud Mazin). \item The \module{itertools} module gained a From loewis at users.sourceforge.net Tue Jul 27 16:16:17 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Tue Jul 27 16:16:20 2004 Subject: [Python-checkins] python/dist/src/PC pyconfig.h,1.26,1.27 Message-ID: Update of /cvsroot/python/python/dist/src/PC In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2949 Modified Files: pyconfig.h Log Message: Properly check for Win64 compilers. Index: pyconfig.h =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/pyconfig.h,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** pyconfig.h 10 Feb 2004 16:50:19 -0000 1.26 --- pyconfig.h 27 Jul 2004 14:16:14 -0000 1.27 *************** *** 99,102 **** --- 99,106 ---- #ifdef _M_IX86 #define COMPILER _Py_PASTE_VERSION("64 bit (Intel)") + #elif defined(_M_IA64) + #define COMPILER _Py_PASTE_VERSION("64 bit (Itanium)") + #elif defined(_M_AMD64) + #define COMPILER _Py_PASTE_VERSION("64 bit (AMD64)") #else #define COMPILER _Py_PASTE_VERSION("64 bit (Unknown)") From loewis at users.sourceforge.net Tue Jul 27 17:03:55 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Tue Jul 27 17:03:58 2004 Subject: [Python-checkins] python/dist/src/Modules binascii.c,2.41,2.42 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11819 Modified Files: binascii.c Log Message: Switch arguments to memset (kudos to MSVC C4318 for finding that) Index: binascii.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/binascii.c,v retrieving revision 2.41 retrieving revision 2.42 diff -C2 -d -r2.41 -r2.42 *** binascii.c 6 Jun 2004 20:13:10 -0000 2.41 --- binascii.c 27 Jul 2004 15:03:53 -0000 2.42 *************** *** 1047,1051 **** return NULL; } ! memset(odata, datalen, 0); in = out = 0; --- 1047,1051 ---- return NULL; } ! memset(odata, 0, datalen); in = out = 0; *************** *** 1221,1225 **** return NULL; } ! memset(odata, odatalen, 0); in = out = linelen = 0; --- 1221,1225 ---- return NULL; } ! memset(odata, 0, odatalen); in = out = linelen = 0; From loewis at users.sourceforge.net Tue Jul 27 17:57:26 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Tue Jul 27 17:57:30 2004 Subject: [Python-checkins] python/dist/src/PC pyconfig.h,1.27,1.28 Message-ID: Update of /cvsroot/python/python/dist/src/PC In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22726/PC Modified Files: pyconfig.h Log Message: Use intptr_t/uintptr_t on Windows Index: pyconfig.h =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/pyconfig.h,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** pyconfig.h 27 Jul 2004 14:16:14 -0000 1.27 --- pyconfig.h 27 Jul 2004 15:57:24 -0000 1.28 *************** *** 268,271 **** --- 268,276 ---- #define SIZEOF_LONG_LONG 8 + /* Atleast VC 7.1 has them. If some compiler does not provide them, + #ifdef appropriately .*/ + #define HAVE_UINTPTR_T 1 + #define HAVE_INTPTR_T 1 + #endif *************** *** 485,488 **** --- 490,496 ---- #define HAVE_STDARG_PROTOTYPES + /* Define if you have the header file. */ + #define HAVE_STDDEF_H 1 + /* Define if you have the header file. */ /* #undef HAVE_SYS_AUDIOIO_H */ From loewis at users.sourceforge.net Tue Jul 27 17:57:26 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Tue Jul 27 17:57:31 2004 Subject: [Python-checkins] python/dist/src/Include Python.h,2.64,2.65 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22726/Include Modified Files: Python.h Log Message: Use intptr_t/uintptr_t on Windows Index: Python.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/Python.h,v retrieving revision 2.64 retrieving revision 2.65 diff -C2 -d -r2.64 -r2.65 *** Python.h 27 Jun 2004 15:43:12 -0000 2.64 --- Python.h 27 Jul 2004 15:57:23 -0000 2.65 *************** *** 42,45 **** --- 42,50 ---- #endif + /* For uintptr_t, intptr_t */ + #ifdef HAVE_STDDEF_H + #include + #endif + /* CAUTION: Build setups should ensure that NDEBUG is defined on the * compiler command line when building Python in release mode; else From loewis at users.sourceforge.net Tue Jul 27 18:36:24 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Tue Jul 27 18:36:28 2004 Subject: [Python-checkins] python/nondist/sandbox/msi msi.py, 1.17, 1.18 msilib.py, 1.8, 1.9 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/msi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30988 Modified Files: msi.py msilib.py Log Message: Succeed even if Tcl is missing. Fix Itanium build. Index: msi.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/msi/msi.py,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** msi.py 25 Jul 2004 10:19:36 -0000 1.17 --- msi.py 27 Jul 2004 16:36:21 -0000 1.18 *************** *** 729,732 **** --- 729,734 ---- parent, phys, dir = tcldirs.pop() lib = Directory(db, cab, parent, phys, dir, "%s|%s" % (parent.make_short(dir), dir)) + if not os.path.exists(lib.absolute): + continue for f in os.listdir(lib.absolute): if os.path.isdir(os.path.join(lib.absolute, f)): Index: msilib.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/msi/msilib.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** msilib.py 20 Jul 2004 08:52:48 -0000 1.8 --- msilib.py 27 Jul 2004 16:36:21 -0000 1.9 *************** *** 294,298 **** si.SetProperty(PID_SUBJECT, ProductName) si.SetProperty(PID_AUTHOR, Manufacturer) ! si.SetProperty(PID_TEMPLATE, "Intel;1033") si.SetProperty(PID_REVNUMBER, ProductCode) # XXX should be package code si.SetProperty(PID_WORDCOUNT, 2) # long file names, compressed, original media --- 294,301 ---- si.SetProperty(PID_SUBJECT, ProductName) si.SetProperty(PID_AUTHOR, Manufacturer) ! if Win64: ! si.SetProperty(PID_TEMPLATE, "Intel64;1033") ! else: ! si.SetProperty(PID_TEMPLATE, "Intel;1033") si.SetProperty(PID_REVNUMBER, ProductCode) # XXX should be package code si.SetProperty(PID_WORDCOUNT, 2) # long file names, compressed, original media From tim_one at users.sourceforge.net Tue Jul 27 23:02:04 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Tue Jul 27 23:02:07 2004 Subject: [Python-checkins] python/dist/src/Lib gzip.py,1.40,1.41 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19290/Lib Modified Files: gzip.py Log Message: Added a new fileno() method. ZODB's repozo.py wants this so it can apply os.fsync() to the GzipFile backup files it creates. Index: gzip.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/gzip.py,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -d -r1.40 -r1.41 *** gzip.py 12 Feb 2004 17:35:06 -0000 1.40 --- gzip.py 27 Jul 2004 21:02:01 -0000 1.41 *************** *** 6,10 **** # based on Andrew Kuchling's minigzip.py distributed with the zlib module ! import struct, sys, time import zlib import __builtin__ --- 6,10 ---- # based on Andrew Kuchling's minigzip.py distributed with the zlib module ! import os, struct, sys, time import zlib import __builtin__ *************** *** 335,338 **** --- 335,346 ---- self.fileobj.flush() + def fileno(self): + """Invoke the underlying file object's fileno() method. + + This will raise AttributeError if the underlying file object + doesn't support fileno(). + """ + return self.fileobj.fileno() + def isatty(self): return False From tim_one at users.sourceforge.net Tue Jul 27 23:02:04 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Tue Jul 27 23:02:09 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_gzip.py,1.11,1.12 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19290/Lib/test Modified Files: test_gzip.py Log Message: Added a new fileno() method. ZODB's repozo.py wants this so it can apply os.fsync() to the GzipFile backup files it creates. Index: test_gzip.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_gzip.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** test_gzip.py 9 Aug 2002 16:37:35 -0000 1.11 --- test_gzip.py 27 Jul 2004 21:02:02 -0000 1.12 *************** *** 17,22 **** """ ! f = gzip.GzipFile(filename, 'wb') ; f.write(data1 * 50) ; f.close() f = gzip.GzipFile(filename, 'r') ; d = f.read() ; f.close() verify(d == data1*50) --- 17,30 ---- """ ! f = gzip.GzipFile(filename, 'wb') ; f.write(data1 * 50) ! ! # Try flush and fileno. ! f.flush() ! f.fileno() ! if hasattr(os, 'fsync'): ! os.fsync(f.fileno()) ! f.close() + # Try reading. f = gzip.GzipFile(filename, 'r') ; d = f.read() ; f.close() verify(d == data1*50) From tim_one at users.sourceforge.net Tue Jul 27 23:02:06 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Tue Jul 27 23:02:18 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1056,1.1057 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19290/Misc Modified Files: NEWS Log Message: Added a new fileno() method. ZODB's repozo.py wants this so it can apply os.fsync() to the GzipFile backup files it creates. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1056 retrieving revision 1.1057 diff -C2 -d -r1.1056 -r1.1057 *** NEWS 27 Jul 2004 05:22:33 -0000 1.1056 --- NEWS 27 Jul 2004 21:02:02 -0000 1.1057 *************** *** 47,50 **** --- 47,54 ---- ------- + - gzip.GzipFile has a new fileno() method, to retrieve the handle of the + underlying file object (provided it has a fileno() method). This is + needed if you want to use os.fsync() on a GzipFile. + - imaplib has two new methods: deleteacl and myrights. From tim_one at users.sourceforge.net Tue Jul 27 23:05:23 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Tue Jul 27 23:05:25 2004 Subject: [Python-checkins] python/dist/src/Lib gzip.py,1.41,1.42 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20466/Lib Modified Files: gzip.py Log Message: Ack, removed useless import of os I just introduced. Index: gzip.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/gzip.py,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** gzip.py 27 Jul 2004 21:02:01 -0000 1.41 --- gzip.py 27 Jul 2004 21:05:21 -0000 1.42 *************** *** 6,10 **** # based on Andrew Kuchling's minigzip.py distributed with the zlib module ! import os, struct, sys, time import zlib import __builtin__ --- 6,10 ---- # based on Andrew Kuchling's minigzip.py distributed with the zlib module ! import struct, sys, time import zlib import __builtin__ From nnorwitz at users.sourceforge.net Wed Jul 28 04:34:15 2004 From: nnorwitz at users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Wed Jul 28 04:34:22 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libimaplib.tex,1.27,1.28 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14039/Doc/lib Modified Files: libimaplib.tex Log Message: Add versionadded info Index: libimaplib.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libimaplib.tex,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** libimaplib.tex 27 Jul 2004 05:07:18 -0000 1.27 --- libimaplib.tex 28 Jul 2004 02:34:12 -0000 1.28 *************** *** 185,188 **** --- 185,189 ---- \begin{methoddesc}{deleteacl}{mailbox, who} Delete the ACLs (remove any rights) set for who on mailbox. + \versionadded{2.4} \end{methoddesc} *************** *** 249,252 **** --- 250,254 ---- \begin{methoddes}{myrights}{mailbox} Show my ACLs for a mailbox (i.e. the rights that I have on mailbox). + \versionadded{2.4} \end{methoddesc} From anthonybaxter at users.sourceforge.net Wed Jul 28 05:08:12 2004 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Wed Jul 28 05:08:15 2004 Subject: [Python-checkins] python/nondist/peps pep-0320.txt,1.14,1.15 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19327 Modified Files: pep-0320.txt Log Message: updated schedule Index: pep-0320.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0320.txt,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** pep-0320.txt 1 Jul 2004 12:42:30 -0000 1.14 --- pep-0320.txt 28 Jul 2004 03:08:09 -0000 1.15 *************** *** 2,6 **** Title: Python 2.4 Release Schedule Version: $Revision$ ! Author: Barry Warsaw and Raymond Hettinger Status: Incomplete Type: Informational --- 2,6 ---- Title: Python 2.4 Release Schedule Version: $Revision$ ! Author: Barry Warsaw, Raymond Hettinger and Anthony Baxter Status: Incomplete Type: Informational *************** *** 20,38 **** rough target for the first alpha is July 2004. - land generator expressions -- first week of May (this PEP seems to - be the largest potential source of upheaval, so it should go - in well before the alpha release). - alpha 1 -- second week of July 2004 - alpha 2 -- four weeks later - beta 1 -- TBD (perhaps August) depending on the number of bugs - in the alphas. - final -- September? This will depend on how the alphas and betas - go, and might be pushed back if several rounds of bugfixing are needed. - - Release Manager Anthony Baxter Completed features for 2.4 --- 20,37 ---- rough target for the first alpha is July 2004. Release Manager Anthony Baxter + Martin von Lowis is building the Windows installers, Fred the + doc packages, Sean the RPMs. + + Release Schedule + + July 9: alpha 1 [completed] + + August 5/6: alpha 2 + + August 26/27: alpha 3 or beta 1 Completed features for 2.4 *************** *** 57,70 **** Add two statistical/reduction functions, nlargest() and nsmallest() to the heapq module. Planned features for 2.4 PEP 292 Simpler String Substitutions to be implemented as a module. ! PEP 318: Function/method decorator syntax PEP 328: Imports: Multi-line and Absolute/Relative. (Still quite ! controversial.) Deprecate and/or remove the modules listed in PEP 4 (posixfile, --- 56,74 ---- Add two statistical/reduction functions, nlargest() and nsmallest() to the heapq module. + + Python's windows installer now uses MSI Planned features for 2.4 + These features are all planned for 2.4b1, but have not yet landed. + PEP 292 Simpler String Substitutions to be implemented as a module. ! PEP 318: Function/method decorator syntax, using @syntax PEP 328: Imports: Multi-line and Absolute/Relative. (Still quite ! controversial.) No-one has stepped forward to champion this, so it's ! looking like it might not make it in. Deprecate and/or remove the modules listed in PEP 4 (posixfile, *************** *** 82,89 **** packages such as pyopenssl. ! AST-based compiler: if this branch can land in the trunk by early ! May, it can go in. Otherwise it can wait for a future release. ! This will not be in 2.4, but will land on the trunk some time after ! 2.4 final is out, for inclusion in 2.5. --- 86,98 ---- packages such as pyopenssl. ! Deferred until 2.5: ! ! - AST-based compiler: this branch was not completed in time for ! 2.4, but will land on the trunk some time after 2.4 final is ! out, for inclusion in 2.5. ! ! - reST is going to be used a lot in Zope3. Maybe it could become ! a standard library module? (Since reST's author thinks it's too ! instable, I'm inclined not to do this.) *************** *** 145,152 **** longer certain this is easy or even right.) - - reST is going to be used a lot in Zope3. Maybe it could become - a standard library module? (Since reST's author thinks it's too - instable, I'm inclined not to do this.) - - Decide on a clearer deprecation policy (especially for modules) and act on it. For a start, see this message from Neil Norwitz: --- 154,157 ---- From perky at users.sourceforge.net Wed Jul 28 11:36:55 2004 From: perky at users.sourceforge.net (perky@users.sourceforge.net) Date: Wed Jul 28 11:37:00 2004 Subject: [Python-checkins] python/dist/src/Modules/cjkcodecs _codecs_unicode.c, 1.1, NONE Message-ID: Update of /cvsroot/python/python/dist/src/Modules/cjkcodecs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9601 Removed Files: _codecs_unicode.c Log Message: Remove CJKCodecs implementation of UTF-7 and UTF-8 codec which aren't intended to be part of Python distributiuon. This was accidently imported on mass converting from standalone version of CJKCodecs. --- _codecs_unicode.c DELETED --- From perky at users.sourceforge.net Wed Jul 28 11:39:57 2004 From: perky at users.sourceforge.net (perky@users.sourceforge.net) Date: Wed Jul 28 11:40:00 2004 Subject: [Python-checkins] python/dist/src/PC config.c,1.48,1.49 Message-ID: Update of /cvsroot/python/python/dist/src/PC In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10188 Modified Files: config.c Log Message: Add missing _codecs_iso2022 module of cjkcodecs. I'll add unittest for it soon. Index: config.c =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/config.c,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -d -r1.48 -r1.49 *** config.c 18 Jul 2004 05:06:31 -0000 1.48 --- config.c 28 Jul 2004 09:39:54 -0000 1.49 *************** *** 60,63 **** --- 60,64 ---- extern void init_codecs_cn(void); extern void init_codecs_hk(void); + extern void init_codecs_iso2022(void); extern void init_codecs_jp(void); extern void init_codecs_kr(void); *************** *** 133,136 **** --- 134,138 ---- {"_codecs_cn", init_codecs_cn}, {"_codecs_hk", init_codecs_hk}, + {"_codecs_iso2022", init_codecs_iso2022}, {"_codecs_jp", init_codecs_jp}, {"_codecs_kr", init_codecs_kr}, From perky at users.sourceforge.net Wed Jul 28 11:45:22 2004 From: perky at users.sourceforge.net (perky@users.sourceforge.net) Date: Wed Jul 28 11:45:25 2004 Subject: [Python-checkins] python/dist/src/PC/VC6 pythoncore.dsp,1.12,1.13 Message-ID: Update of /cvsroot/python/python/dist/src/PC/VC6 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11079/PC/VC6 Modified Files: pythoncore.dsp Log Message: Remove unused source file from Windows project files. Index: pythoncore.dsp =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/VC6/pythoncore.dsp,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** pythoncore.dsp 18 Jul 2004 15:36:31 -0000 1.12 --- pythoncore.dsp 28 Jul 2004 09:45:19 -0000 1.13 *************** *** 122,129 **** # Begin Source File - SOURCE=..\..\Modules\cjkcodecs\_codecs_unicode.c - # End Source File - # Begin Source File - SOURCE=..\..\Modules\_codecsmodule.c # End Source File --- 122,125 ---- From perky at users.sourceforge.net Wed Jul 28 11:45:22 2004 From: perky at users.sourceforge.net (perky@users.sourceforge.net) Date: Wed Jul 28 11:45:27 2004 Subject: [Python-checkins] python/dist/src/PCbuild pythoncore.vcproj, 1.16, 1.17 Message-ID: Update of /cvsroot/python/python/dist/src/PCbuild In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11079/PCbuild Modified Files: pythoncore.vcproj Log Message: Remove unused source file from Windows project files. Index: pythoncore.vcproj =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/pythoncore.vcproj,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** pythoncore.vcproj 20 Jul 2004 14:37:47 -0000 1.16 --- pythoncore.vcproj 28 Jul 2004 09:45:20 -0000 1.17 *************** *** 248,254 **** - - Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18132 Modified Files: pep-0320.txt Log Message: Typo fix Index: pep-0320.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0320.txt,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** pep-0320.txt 28 Jul 2004 03:08:09 -0000 1.15 --- pep-0320.txt 28 Jul 2004 10:39:55 -0000 1.16 *************** *** 155,159 **** - Decide on a clearer deprecation policy (especially for modules) ! and act on it. For a start, see this message from Neil Norwitz: http://mail.python.org/pipermail/python-dev/2002-April/023165.html There seems insufficient interest in moving this further in an --- 155,159 ---- - Decide on a clearer deprecation policy (especially for modules) ! and act on it. For a start, see this message from Neal Norwitz: http://mail.python.org/pipermail/python-dev/2002-April/023165.html There seems insufficient interest in moving this further in an From montanaro at users.sourceforge.net Wed Jul 28 16:17:07 2004 From: montanaro at users.sourceforge.net (montanaro@users.sourceforge.net) Date: Wed Jul 28 16:17:10 2004 Subject: [Python-checkins] python/dist/src/Doc/api concrete.tex,1.48,1.49 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/api In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18498 Modified Files: concrete.tex Log Message: A little boolean music if you please, maestro... (Not sure I have the versionadded{} args quite right). Index: concrete.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/concrete.tex,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -d -r1.48 -r1.49 *** concrete.tex 23 Jul 2004 14:49:52 -0000 1.48 --- concrete.tex 28 Jul 2004 14:17:04 -0000 1.49 *************** *** 193,196 **** --- 193,230 ---- \end{cfuncdesc} + \subsubsection{Boolean Objects \label{boolObjects}} + + Booleans in Python are implemented as a subclass of integers. There + are only two booleans, \constant{Py_False} and \constant{Py_True}. As + such, the normal creation and deletion functions don't apply to + booleans. The following macros are available, however. + + \begin{cfuncdesc}{int}{PyBool_Check}{PyObject* o} + Returns true if \var{o} is of type \cdata{PyBool_Type}. + \versionadded{2.3} + \end{cfuncdesc} + + \begin{cfuncdesc}{Py_RETURN_FALSE} + Return Py_False from a function, properly incrementing its reference + count. + \versionadded{2.4} + \end{cfuncdesc} + + \begin{cfuncdesc}{Py_RETURN_TRUE} + Return Py_True from a function, properly incrementing its reference + count. + \versionadded{2.4} + \end{cfuncdesc} + + \begin{cfuncdesc}{int}{PyBool_Check}{PyObject* o} + Returns true if \var{o} is of type \cdata{PyBool_Type}. + \versionadded{2.3} + \end{cfuncdesc} + + \begin{cfuncdesc}{int}{PyBool_FromLong}{long v} + Returns \constant{Py_True} or \constant{Py_False} depending on the + truth value of \var{v}. + \versionadded{2.3} + \end{cfuncdesc} \subsection{Long Integer Objects \label{longObjects}} From fdrake at users.sourceforge.net Wed Jul 28 16:55:12 2004 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Wed Jul 28 16:55:27 2004 Subject: [Python-checkins] python/dist/src/Lib/distutils/command install_lib.py, 1.42, 1.43 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils/command In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25366 Modified Files: install_lib.py Log Message: Since build_py handles package data installation, the list of outputs can contain more than just .py files. Make sure we only report bytecode files for the .py files. Index: install_lib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/install_lib.py,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -d -r1.42 -r1.43 *** install_lib.py 19 Nov 2002 13:12:28 -0000 1.42 --- install_lib.py 28 Jul 2004 14:55:10 -0000 1.43 *************** *** 8,11 **** --- 8,16 ---- from distutils.errors import DistutilsOptionError + + # Extension for Python source files. + PYTHON_SOURCE_EXTENSION = os.extsep + "py" + + class install_lib (Command): *************** *** 156,159 **** --- 161,170 ---- bytecode_files = [] for py_file in py_filenames: + # Since build_py handles package data installation, the + # list of outputs can contain more than just .py files. + # Make sure we only report bytecode for the .py files. + ext = os.path.splitext(os.path.normcase(py_file))[1] + if ext != PYTHON_SOURCE_EXTENSION: + continue if self.compile: bytecode_files.append(py_file + "c") From akuchling at users.sourceforge.net Wed Jul 28 17:29:42 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Wed Jul 28 17:29:46 2004 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew24.tex, 1.75, 1.76 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30719 Modified Files: whatsnew24.tex Log Message: Add new encodings Index: whatsnew24.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew24.tex,v retrieving revision 1.75 retrieving revision 1.76 diff -C2 -d -r1.75 -r1.76 *** whatsnew24.tex 27 Jul 2004 12:13:25 -0000 1.75 --- whatsnew24.tex 28 Jul 2004 15:29:39 -0000 1.76 *************** *** 710,718 **** \begin{itemize} ! \item Chinese (PRC): gb2312, gbk, gb18030, hz \item Chinese (ROC): big5, cp950 ! \item Japanese: cp932, shift-jis, shift-jisx0213, euc-jp, euc-jisx0213, iso-2022-jp, iso-2022-jp-1, iso-2022-jp-2, ! iso-2022-jp-3, iso-2022-jp-ext \item Korean: cp949, euc-kr, johab, iso-2022-kr \end{itemize} --- 710,719 ---- \begin{itemize} ! \item Chinese (PRC): gb2312, gbk, gb18030, big5hkscs, hz \item Chinese (ROC): big5, cp950 ! \item Japanese: cp932, euc-jis-2004, euc-jp, euc-jisx0213, iso-2022-jp, iso-2022-jp-1, iso-2022-jp-2, ! iso-2022-jp-3, iso-2022-jp-ext, iso-2022-jp-2004, ! shift-jis, shift-jisx0213, shift-jis-2004 \item Korean: cp949, euc-kr, johab, iso-2022-kr \end{itemize} *************** *** 1065,1069 **** The author would like to thank the following people for offering suggestions, corrections and assistance with various drafts of this ! article: Michael Dyck, Raymond Hettinger. \end{document} --- 1066,1070 ---- The author would like to thank the following people for offering suggestions, corrections and assistance with various drafts of this ! article: Hye-Shik Chang, Michael Dyck, Raymond Hettinger. \end{document} From lemburg at users.sourceforge.net Wed Jul 28 17:35:33 2004 From: lemburg at users.sourceforge.net (lemburg@users.sourceforge.net) Date: Wed Jul 28 17:35:36 2004 Subject: [Python-checkins] python/dist/src/Lib/encodings aliases.py, 1.25, 1.26 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/encodings In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31455/Lib/encodings Modified Files: aliases.py Log Message: Added new codec hp-roman8 submitted as patch [ 996067 ] hp-roman8 codec. Index: aliases.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/encodings/aliases.py,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** aliases.py 18 Jul 2004 03:06:26 -0000 1.25 --- aliases.py 28 Jul 2004 15:35:29 -0000 1.26 *************** *** 18,21 **** --- 18,23 ---- aliases = { + # Please keep this list sorted alphabetically ! + # ascii codec '646' : 'ascii', *************** *** 245,248 **** --- 247,255 ---- 'hex' : 'hex_codec', + # hp_roman8 codec + 'roman8' : 'hp_roman8', + 'r8' : 'hp_roman8', + 'csHPRoman8' : 'hp_roman8', + # hz codec 'hzgb' : 'hz', From lemburg at users.sourceforge.net Wed Jul 28 17:37:19 2004 From: lemburg at users.sourceforge.net (lemburg@users.sourceforge.net) Date: Wed Jul 28 17:37:22 2004 Subject: [Python-checkins] python/dist/src/Lib/encodings hp_roman8.py, NONE, 1.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/encodings In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31698/Lib/encodings Added Files: hp_roman8.py Log Message: New codec: [ 996067 ] hp-roman8 codec --- NEW FILE: hp_roman8.py --- """ Python Character Mapping Codec generated from 'hp_roman8.txt' with gencodec.py. Based on data from ftp://dkuug.dk/i18n/charmaps/HP-ROMAN8 (Keld Simonsen) Original source: LaserJet IIP Printer User's Manual HP part no 33471-90901, Hewlet-Packard, June 1989. """#" import codecs ### Codec APIs class Codec(codecs.Codec): def encode(self,input,errors='strict'): return codecs.charmap_encode(input,errors,encoding_map) def decode(self,input,errors='strict'): return codecs.charmap_decode(input,errors,decoding_map) class StreamWriter(Codec,codecs.StreamWriter): pass class StreamReader(Codec,codecs.StreamReader): pass ### encodings module API def getregentry(): return (Codec().encode,Codec().decode,StreamReader,StreamWriter) ### Decoding Map decoding_map = codecs.make_identity_dict(range(256)) decoding_map.update({ 0x00a1: 0x00c0, # LATIN CAPITAL LETTER A WITH GRAVE 0x00a2: 0x00c2, # LATIN CAPITAL LETTER A WITH CIRCUMFLEX 0x00a3: 0x00c8, # LATIN CAPITAL LETTER E WITH GRAVE 0x00a4: 0x00ca, # LATIN CAPITAL LETTER E WITH CIRCUMFLEX 0x00a5: 0x00cb, # LATIN CAPITAL LETTER E WITH DIAERESIS 0x00a6: 0x00ce, # LATIN CAPITAL LETTER I WITH CIRCUMFLEX 0x00a7: 0x00cf, # LATIN CAPITAL LETTER I WITH DIAERESIS 0x00a8: 0x00b4, # ACUTE ACCENT 0x00a9: 0x02cb, # MODIFIER LETTER GRAVE ACCENT (Mandarin Chinese fourth tone) 0x00aa: 0x02c6, # MODIFIER LETTER CIRCUMFLEX ACCENT 0x00ab: 0x00a8, # DIAERESIS 0x00ac: 0x02dc, # SMALL TILDE 0x00ad: 0x00d9, # LATIN CAPITAL LETTER U WITH GRAVE 0x00ae: 0x00db, # LATIN CAPITAL LETTER U WITH CIRCUMFLEX 0x00af: 0x20a4, # LIRA SIGN 0x00b0: 0x00af, # MACRON 0x00b1: 0x00dd, # LATIN CAPITAL LETTER Y WITH ACUTE 0x00b2: 0x00fd, # LATIN SMALL LETTER Y WITH ACUTE 0x00b3: 0x00b0, # DEGREE SIGN 0x00b4: 0x00c7, # LATIN CAPITAL LETTER C WITH CEDILLA 0x00b5: 0x00e7, # LATIN SMALL LETTER C WITH CEDILLA 0x00b6: 0x00d1, # LATIN CAPITAL LETTER N WITH TILDE 0x00b7: 0x00f1, # LATIN SMALL LETTER N WITH TILDE 0x00b8: 0x00a1, # INVERTED EXCLAMATION MARK 0x00b9: 0x00bf, # INVERTED QUESTION MARK 0x00ba: 0x00a4, # CURRENCY SIGN 0x00bb: 0x00a3, # POUND SIGN 0x00bc: 0x00a5, # YEN SIGN 0x00bd: 0x00a7, # SECTION SIGN 0x00be: 0x0192, # LATIN SMALL LETTER F WITH HOOK 0x00bf: 0x00a2, # CENT SIGN 0x00c0: 0x00e2, # LATIN SMALL LETTER A WITH CIRCUMFLEX 0x00c1: 0x00ea, # LATIN SMALL LETTER E WITH CIRCUMFLEX 0x00c2: 0x00f4, # LATIN SMALL LETTER O WITH CIRCUMFLEX 0x00c3: 0x00fb, # LATIN SMALL LETTER U WITH CIRCUMFLEX 0x00c4: 0x00e1, # LATIN SMALL LETTER A WITH ACUTE 0x00c5: 0x00e9, # LATIN SMALL LETTER E WITH ACUTE 0x00c6: 0x00f3, # LATIN SMALL LETTER O WITH ACUTE 0x00c7: 0x00fa, # LATIN SMALL LETTER U WITH ACUTE 0x00c8: 0x00e0, # LATIN SMALL LETTER A WITH GRAVE 0x00c9: 0x00e8, # LATIN SMALL LETTER E WITH GRAVE 0x00ca: 0x00f2, # LATIN SMALL LETTER O WITH GRAVE 0x00cb: 0x00f9, # LATIN SMALL LETTER U WITH GRAVE 0x00cc: 0x00e4, # LATIN SMALL LETTER A WITH DIAERESIS 0x00cd: 0x00eb, # LATIN SMALL LETTER E WITH DIAERESIS 0x00ce: 0x00f6, # LATIN SMALL LETTER O WITH DIAERESIS 0x00cf: 0x00fc, # LATIN SMALL LETTER U WITH DIAERESIS 0x00d0: 0x00c5, # LATIN CAPITAL LETTER A WITH RING ABOVE 0x00d1: 0x00ee, # LATIN SMALL LETTER I WITH CIRCUMFLEX 0x00d2: 0x00d8, # LATIN CAPITAL LETTER O WITH STROKE 0x00d3: 0x00c6, # LATIN CAPITAL LETTER AE 0x00d4: 0x00e5, # LATIN SMALL LETTER A WITH RING ABOVE 0x00d5: 0x00ed, # LATIN SMALL LETTER I WITH ACUTE 0x00d6: 0x00f8, # LATIN SMALL LETTER O WITH STROKE 0x00d7: 0x00e6, # LATIN SMALL LETTER AE 0x00d8: 0x00c4, # LATIN CAPITAL LETTER A WITH DIAERESIS 0x00d9: 0x00ec, # LATIN SMALL LETTER I WITH GRAVE 0x00da: 0x00d6, # LATIN CAPITAL LETTER O WITH DIAERESIS 0x00db: 0x00dc, # LATIN CAPITAL LETTER U WITH DIAERESIS 0x00dc: 0x00c9, # LATIN CAPITAL LETTER E WITH ACUTE 0x00dd: 0x00ef, # LATIN SMALL LETTER I WITH DIAERESIS 0x00de: 0x00df, # LATIN SMALL LETTER SHARP S (German) 0x00df: 0x00d4, # LATIN CAPITAL LETTER O WITH CIRCUMFLEX 0x00e0: 0x00c1, # LATIN CAPITAL LETTER A WITH ACUTE 0x00e1: 0x00c3, # LATIN CAPITAL LETTER A WITH TILDE 0x00e2: 0x00e3, # LATIN SMALL LETTER A WITH TILDE 0x00e3: 0x00d0, # LATIN CAPITAL LETTER ETH (Icelandic) 0x00e4: 0x00f0, # LATIN SMALL LETTER ETH (Icelandic) 0x00e5: 0x00cd, # LATIN CAPITAL LETTER I WITH ACUTE 0x00e6: 0x00cc, # LATIN CAPITAL LETTER I WITH GRAVE 0x00e7: 0x00d3, # LATIN CAPITAL LETTER O WITH ACUTE 0x00e8: 0x00d2, # LATIN CAPITAL LETTER O WITH GRAVE 0x00e9: 0x00d5, # LATIN CAPITAL LETTER O WITH TILDE 0x00ea: 0x00f5, # LATIN SMALL LETTER O WITH TILDE 0x00eb: 0x0160, # LATIN CAPITAL LETTER S WITH CARON 0x00ec: 0x0161, # LATIN SMALL LETTER S WITH CARON 0x00ed: 0x00da, # LATIN CAPITAL LETTER U WITH ACUTE 0x00ee: 0x0178, # LATIN CAPITAL LETTER Y WITH DIAERESIS 0x00ef: 0x00ff, # LATIN SMALL LETTER Y WITH DIAERESIS 0x00f0: 0x00de, # LATIN CAPITAL LETTER THORN (Icelandic) 0x00f1: 0x00fe, # LATIN SMALL LETTER THORN (Icelandic) 0x00f2: 0x00b7, # MIDDLE DOT 0x00f3: 0x00b5, # MICRO SIGN 0x00f4: 0x00b6, # PILCROW SIGN 0x00f5: 0x00be, # VULGAR FRACTION THREE QUARTERS 0x00f6: 0x2014, # EM DASH 0x00f7: 0x00bc, # VULGAR FRACTION ONE QUARTER 0x00f8: 0x00bd, # VULGAR FRACTION ONE HALF 0x00f9: 0x00aa, # FEMININE ORDINAL INDICATOR 0x00fa: 0x00ba, # MASCULINE ORDINAL INDICATOR 0x00fb: 0x00ab, # LEFT-POINTING DOUBLE ANGLE QUOTATION MARK 0x00fc: 0x25a0, # BLACK SQUARE 0x00fd: 0x00bb, # RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK 0x00fe: 0x00b1, # PLUS-MINUS SIGN 0x00ff: None, }) ### Encoding Map encoding_map = codecs.make_encoding_map(decoding_map) From lemburg at users.sourceforge.net Wed Jul 28 17:37:57 2004 From: lemburg at users.sourceforge.net (lemburg@users.sourceforge.net) Date: Wed Jul 28 17:38:00 2004 Subject: [Python-checkins] python/dist/src/Misc ACKS,1.274,1.275 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31769/Misc Modified Files: ACKS Log Message: New codec: [ 996067 ] hp-roman8 codec Index: ACKS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/ACKS,v retrieving revision 1.274 retrieving revision 1.275 diff -C2 -d -r1.274 -r1.275 *** ACKS 27 Jul 2004 05:07:19 -0000 1.274 --- ACKS 28 Jul 2004 15:37:54 -0000 1.275 *************** *** 73,76 **** --- 73,77 ---- Dave Brennan Tom Bridgman + Richard Brodie Gary S. Brown Daniel Brotsky From theller at users.sourceforge.net Wed Jul 28 22:02:54 2004 From: theller at users.sourceforge.net (theller@users.sourceforge.net) Date: Wed Jul 28 22:02:57 2004 Subject: [Python-checkins] python/dist/src/PC msvcrtmodule.c,1.8,1.9 Message-ID: Update of /cvsroot/python/python/dist/src/PC In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17311 Modified Files: msvcrtmodule.c Log Message: Use PyMODINIT_FUNC. Index: msvcrtmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/msvcrtmodule.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** msvcrtmodule.c 31 Mar 2002 14:37:44 -0000 1.8 --- msvcrtmodule.c 28 Jul 2004 20:02:52 -0000 1.9 *************** *** 218,222 **** }; ! __declspec(dllexport) void initmsvcrt(void) { --- 218,222 ---- }; ! PyMODINIT_FUNC initmsvcrt(void) { From theller at users.sourceforge.net Wed Jul 28 22:04:40 2004 From: theller at users.sourceforge.net (theller@users.sourceforge.net) Date: Wed Jul 28 22:04:42 2004 Subject: [Python-checkins] python/dist/src/PC msvcrtmodule.c,1.8,1.8.16.1 Message-ID: Update of /cvsroot/python/python/dist/src/PC In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17709 Modified Files: Tag: release23-maint msvcrtmodule.c Log Message: Use PyMODINIT_FUNC. Index: msvcrtmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/msvcrtmodule.c,v retrieving revision 1.8 retrieving revision 1.8.16.1 diff -C2 -d -r1.8 -r1.8.16.1 *** msvcrtmodule.c 31 Mar 2002 14:37:44 -0000 1.8 --- msvcrtmodule.c 28 Jul 2004 20:04:37 -0000 1.8.16.1 *************** *** 218,222 **** }; ! __declspec(dllexport) void initmsvcrt(void) { --- 218,222 ---- }; ! PyMODINIT_FUNC initmsvcrt(void) { From montanaro at users.sourceforge.net Thu Jul 29 04:16:07 2004 From: montanaro at users.sourceforge.net (montanaro@users.sourceforge.net) Date: Thu Jul 29 04:16:10 2004 Subject: [Python-checkins] python/dist/src/Doc/api concrete.tex,1.49,1.50 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/api In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12401 Modified Files: concrete.tex Log Message: Add missing doc for Py_True/Py_False. Use the correct macro to define Py_RETURN_FALSE and Py_RETURN_TRUE. Index: concrete.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/concrete.tex,v retrieving revision 1.49 retrieving revision 1.50 diff -C2 -d -r1.49 -r1.50 *** concrete.tex 28 Jul 2004 14:17:04 -0000 1.49 --- concrete.tex 29 Jul 2004 02:16:04 -0000 1.50 *************** *** 205,219 **** \end{cfuncdesc} ! \begin{cfuncdesc}{Py_RETURN_FALSE} ! Return Py_False from a function, properly incrementing its reference ! count. \versionadded{2.4} ! \end{cfuncdesc} ! \begin{cfuncdesc}{Py_RETURN_TRUE} Return Py_True from a function, properly incrementing its reference count. \versionadded{2.4} ! \end{cfuncdesc} \begin{cfuncdesc}{int}{PyBool_Check}{PyObject* o} --- 205,229 ---- \end{cfuncdesc} ! \begin{cvardesc}{PyObject*}{Py_False} ! The Python \code{False} object. This object has no methods. It needs to ! be treated just like any other object with respect to reference counts. ! \end{cvardesc} ! ! \begin{cvardesc}{PyObject*}{Py_True} ! The Python \code{True} object. This object has no methods. It needs to ! be treated just like any other object with respect to reference counts. ! \end{cvardesc} ! ! \begin{csimplemacrodesc}{Py_RETURN_FALSE} ! Return \constant{Py_False} from a function, properly incrementing its ! reference count. \versionadded{2.4} ! \end{csimplemacrodesc} ! \begin{csimplemacrodesc}{Py_RETURN_TRUE} Return Py_True from a function, properly incrementing its reference count. \versionadded{2.4} ! \end{csimplemacrodesc} \begin{cfuncdesc}{int}{PyBool_Check}{PyObject* o} From tim_one at users.sourceforge.net Thu Jul 29 04:28:45 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Thu Jul 29 04:28:48 2004 Subject: [Python-checkins] python/dist/src/Objects listobject.c,2.207,2.208 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13639/Objects Modified Files: listobject.c Log Message: PyList_New(): we went to all the trouble of computing and bounds-checking the size_t nbytes, and passed nbytes to malloc, so it was confusing to effectively recompute the same thing from scratch in the memset call. Index: listobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/listobject.c,v retrieving revision 2.207 retrieving revision 2.208 diff -C2 -d -r2.207 -r2.208 *** listobject.c 15 Jul 2004 15:54:05 -0000 2.207 --- listobject.c 29 Jul 2004 02:28:42 -0000 2.208 *************** *** 60,63 **** --- 60,64 ---- PyListObject *op; size_t nbytes; + if (size < 0) { PyErr_BadInternalCall(); *************** *** 83,87 **** if (op->ob_item == NULL) return PyErr_NoMemory(); ! memset(op->ob_item, 0, sizeof(*op->ob_item) * size); } op->ob_size = size; --- 84,88 ---- if (op->ob_item == NULL) return PyErr_NoMemory(); ! memset(op->ob_item, 0, nbytes); } op->ob_size = size; From montanaro at users.sourceforge.net Thu Jul 29 04:29:26 2004 From: montanaro at users.sourceforge.net (montanaro@users.sourceforge.net) Date: Thu Jul 29 04:29:31 2004 Subject: [Python-checkins] python/dist/src/Doc/api concrete.tex, 1.25.10.9, 1.25.10.10 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/api In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13933 Modified Files: Tag: release23-maint concrete.tex Log Message: backport relevant bits of the bool api docs Index: concrete.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/concrete.tex,v retrieving revision 1.25.10.9 retrieving revision 1.25.10.10 diff -C2 -d -r1.25.10.9 -r1.25.10.10 *** concrete.tex 23 Jul 2004 14:51:06 -0000 1.25.10.9 --- concrete.tex 29 Jul 2004 02:29:24 -0000 1.25.10.10 *************** *** 190,193 **** --- 190,226 ---- + \subsubsection{Boolean Objects \label{boolObjects}} + + Booleans in Python are implemented as a subclass of integers. There + are only two booleans, \constant{Py_False} and \constant{Py_True}. As + such, the normal creation and deletion functions don't apply to + booleans. The following macros are available, however. + + \begin{cfuncdesc}{int}{PyBool_Check}{PyObject* o} + Returns true if \var{o} is of type \cdata{PyBool_Type}. + \versionadded{2.3} + \end{cfuncdesc} + + \begin{cvardesc}{PyObject*}{Py_False} + The Python \code{False} object. This object has no methods. It needs to + be treated just like any other object with respect to reference counts. + \end{cvardesc} + + \begin{cvardesc}{PyObject*}{Py_True} + The Python \code{True} object. This object has no methods. It needs to + be treated just like any other object with respect to reference counts. + \end{cvardesc} + + \begin{cfuncdesc}{int}{PyBool_Check}{PyObject* o} + Returns true if \var{o} is of type \cdata{PyBool_Type}. + \versionadded{2.3} + \end{cfuncdesc} + + \begin{cfuncdesc}{int}{PyBool_FromLong}{long v} + Returns \constant{Py_True} or \constant{Py_False} depending on the + truth value of \var{v}. + \versionadded{2.3} + \end{cfuncdesc} + \subsection{Long Integer Objects \label{longObjects}} From tim_one at users.sourceforge.net Thu Jul 29 04:29:28 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Thu Jul 29 04:29:34 2004 Subject: [Python-checkins] python/dist/src/Objects listobject.c,2.208,2.209 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13944/Objects Modified Files: listobject.c Log Message: Trimmed trailing whitespace. Index: listobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/listobject.c,v retrieving revision 2.208 retrieving revision 2.209 diff -C2 -d -r2.208 -r2.209 *** listobject.c 29 Jul 2004 02:28:42 -0000 2.208 --- listobject.c 29 Jul 2004 02:29:26 -0000 2.209 *************** *** 160,164 **** return -1; } ! if (list_resize(self, n+1) == -1) return -1; --- 160,164 ---- return -1; } ! if (list_resize(self, n+1) == -1) return -1; *************** *** 239,244 **** if (num_free_lists < MAXFREELISTS && PyList_CheckExact(op)) free_lists[num_free_lists++] = op; ! else ! op->ob_type->tp_free((PyObject *)op); Py_TRASHCAN_SAFE_END(op) } --- 239,244 ---- if (num_free_lists < MAXFREELISTS && PyList_CheckExact(op)) free_lists[num_free_lists++] = op; ! else ! op->ob_type->tp_free((PyObject *)op); Py_TRASHCAN_SAFE_END(op) } *************** *** 546,550 **** p += ihigh - ilow; if (d < 0) { ! memmove(&item[ihigh+d], &item[ihigh], (a->ob_size - ihigh)*sizeof(PyObject *)); list_resize(a, a->ob_size + d); --- 546,550 ---- p += ihigh - ilow; if (d < 0) { ! memmove(&item[ihigh+d], &item[ihigh], (a->ob_size - ihigh)*sizeof(PyObject *)); list_resize(a, a->ob_size + d); *************** *** 618,622 **** } ! if (list_resize(self, size*n) == -1) return NULL; --- 618,622 ---- } ! if (list_resize(self, size*n) == -1) return NULL; *************** *** 683,688 **** /* Special cases: ! 1) lists and tuples which can use PySequence_Fast ops ! 2) extending self to self requires making a copy first */ if (PyList_CheckExact(b) || PyTuple_CheckExact(b) || (PyObject *)self == b) { --- 683,688 ---- /* Special cases: ! 1) lists and tuples which can use PySequence_Fast ops ! 2) extending self to self requires making a copy first */ if (PyList_CheckExact(b) || PyTuple_CheckExact(b) || (PyObject *)self == b) { *************** *** 1722,1728 **** /* Special wrapper to support stable sorting using the decorate-sort-undecorate pattern. Holds a key which is used for comparisions and the original record ! which is returned during the undecorate phase. By exposing only the key ! during comparisons, the underlying sort stability characteristics are left ! unchanged. Also, if a custom comparison function is used, it will only see the key instead of a full record. */ --- 1722,1728 ---- /* Special wrapper to support stable sorting using the decorate-sort-undecorate pattern. Holds a key which is used for comparisions and the original record ! which is returned during the undecorate phase. By exposing only the key ! during comparisons, the underlying sort stability characteristics are left ! unchanged. Also, if a custom comparison function is used, it will only see the key instead of a full record. */ *************** *** 1739,1743 **** { if (!PyObject_TypeCheck(b, &sortwrapper_type)) { ! PyErr_SetString(PyExc_TypeError, "expected a sortwrapperobject"); return NULL; --- 1739,1743 ---- { if (!PyObject_TypeCheck(b, &sortwrapper_type)) { ! PyErr_SetString(PyExc_TypeError, "expected a sortwrapperobject"); return NULL; *************** *** 1778,1782 **** 0, /* tp_setattro */ 0, /* tp_as_buffer */ ! Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_RICHCOMPARE, /* tp_flags */ sortwrapper_doc, /* tp_doc */ --- 1778,1782 ---- 0, /* tp_setattro */ 0, /* tp_as_buffer */ ! Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_RICHCOMPARE, /* tp_flags */ sortwrapper_doc, /* tp_doc */ *************** *** 1793,1797 **** { sortwrapperobject *so; ! so = PyObject_New(sortwrapperobject, &sortwrapper_type); if (so == NULL) --- 1793,1797 ---- { sortwrapperobject *so; ! so = PyObject_New(sortwrapperobject, &sortwrapper_type); if (so == NULL) *************** *** 1809,1813 **** if (!PyObject_TypeCheck(so, &sortwrapper_type)) { ! PyErr_SetString(PyExc_TypeError, "expected a sortwrapperobject"); return NULL; --- 1809,1813 ---- if (!PyObject_TypeCheck(so, &sortwrapper_type)) { ! PyErr_SetString(PyExc_TypeError, "expected a sortwrapperobject"); return NULL; *************** *** 1843,1847 **** if (!PyObject_TypeCheck(x, &sortwrapper_type) || !PyObject_TypeCheck(y, &sortwrapper_type)) { ! PyErr_SetString(PyExc_TypeError, "expected a sortwrapperobject"); return NULL; --- 1843,1847 ---- if (!PyObject_TypeCheck(x, &sortwrapper_type) || !PyObject_TypeCheck(y, &sortwrapper_type)) { ! PyErr_SetString(PyExc_TypeError, "expected a sortwrapperobject"); return NULL; *************** *** 1884,1888 **** { cmpwrapperobject *co; ! co = PyObject_New(cmpwrapperobject, &cmpwrapper_type); if (co == NULL) --- 1884,1888 ---- { cmpwrapperobject *co; ! co = PyObject_New(cmpwrapperobject, &cmpwrapper_type); if (co == NULL) *************** *** 1949,1953 **** for (i=0 ; i < saved_ob_size ; i++) { value = saved_ob_item[i]; ! key = PyObject_CallFunctionObjArgs(keyfunc, value, NULL); if (key == NULL) { --- 1949,1953 ---- for (i=0 ; i < saved_ob_size ; i++) { value = saved_ob_item[i]; ! key = PyObject_CallFunctionObjArgs(keyfunc, value, NULL); if (key == NULL) { *************** *** 1958,1962 **** Py_DECREF(kvpair); } ! if (self->ob_item != empty_ob_item || self->ob_size) { /* If the list changed *as well* we --- 1958,1962 ---- Py_DECREF(kvpair); } ! if (self->ob_item != empty_ob_item || self->ob_size) { /* If the list changed *as well* we *************** *** 1969,1973 **** (PyObject *)NULL); } ! goto dsu_fail; } --- 1969,1973 ---- (PyObject *)NULL); } ! goto dsu_fail; } *************** *** 2503,2507 **** } ! memmove(self->ob_item + cur - i, self->ob_item + cur + 1, lim * sizeof(PyObject *)); --- 2503,2507 ---- } ! memmove(self->ob_item + cur - i, self->ob_item + cur + 1, lim * sizeof(PyObject *)); *************** *** 2535,2539 **** } else { ! seq = PySequence_Fast(value, "must assign iterable to extended slice"); if (!seq) --- 2535,2539 ---- } else { ! seq = PySequence_Fast(value, "must assign iterable to extended slice"); if (!seq) From tim_one at users.sourceforge.net Thu Jul 29 05:29:17 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Thu Jul 29 05:29:20 2004 Subject: [Python-checkins] python/dist/src/Include listobject.h,2.28,2.29 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22000/Include Modified Files: listobject.h Log Message: Document what the members of PyListObject are used for, and the crucial invariants they must satisfy. Index: listobject.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/listobject.h,v retrieving revision 2.28 retrieving revision 2.29 diff -C2 -d -r2.28 -r2.29 *** listobject.h 11 Mar 2004 09:13:12 -0000 2.28 --- listobject.h 29 Jul 2004 03:29:15 -0000 2.29 *************** *** 22,26 **** --- 22,35 ---- typedef struct { PyObject_VAR_HEAD + /* Vector of pointers to list elements. list[0] is ob_item{0], etc. */ PyObject **ob_item; + + /* ob_item contains space for 'allocated' elements. The number + * currently in use is ob_size. + * Invariants: + * 0 <= ob_size <= allocated + * len(list) == ob_size + * ob_item == NULL implies ob_size == allocated == 0 + */ int allocated; } PyListObject; From nnorwitz at users.sourceforge.net Thu Jul 29 05:49:01 2004 From: nnorwitz at users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Thu Jul 29 05:49:04 2004 Subject: [Python-checkins] python/dist/src/Doc/lib liblocale.tex,1.37,1.38 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24341/Doc/lib Modified Files: liblocale.tex Log Message: SF #998170, fix typo. Backport candidate Index: liblocale.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/liblocale.tex,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** liblocale.tex 22 Jul 2004 18:43:59 -0000 1.37 --- liblocale.tex 29 Jul 2004 03:48:59 -0000 1.38 *************** *** 87,91 **** {Symbol used to annotate a positive monetary value.} \lineiii{}{\code{'negative_sign'}} ! {Symbol used to annotate a nnegative monetary value.} \lineiii{}{\code{'frac_digits'}} {Number of fractional digits used in local formatting --- 87,91 ---- {Symbol used to annotate a positive monetary value.} \lineiii{}{\code{'negative_sign'}} ! {Symbol used to annotate a negative monetary value.} \lineiii{}{\code{'frac_digits'}} {Number of fractional digits used in local formatting From nnorwitz at users.sourceforge.net Thu Jul 29 05:55:58 2004 From: nnorwitz at users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Thu Jul 29 05:56:02 2004 Subject: [Python-checkins] python/dist/src/Modules Setup.dist,1.46,1.47 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25177/Modules Modified Files: Setup.dist Log Message: SF bug #999776, zlib home page wrong Backport candidate. Index: Setup.dist =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/Setup.dist,v retrieving revision 1.46 retrieving revision 1.47 diff -C2 -d -r1.46 -r1.47 *** Setup.dist 19 Jul 2004 16:42:20 -0000 1.46 --- Setup.dist 29 Jul 2004 03:55:56 -0000 1.47 *************** *** 463,467 **** # Andrew Kuchling's zlib module. # This require zlib 1.1.3 (or later). ! # See http://www.cdrom.com/pub/infozip/zlib/ #zlib zlibmodule.c -I$(prefix)/include -L$(exec_prefix)/lib -lz --- 463,467 ---- # Andrew Kuchling's zlib module. # This require zlib 1.1.3 (or later). ! # See http://www.gzip.org/zlib/ #zlib zlibmodule.c -I$(prefix)/include -L$(exec_prefix)/lib -lz From nnorwitz at users.sourceforge.net Thu Jul 29 05:55:59 2004 From: nnorwitz at users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Thu Jul 29 05:56:04 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_gzip.py,1.12,1.13 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25177/Lib/test Modified Files: test_gzip.py Log Message: SF bug #999776, zlib home page wrong Backport candidate. Index: test_gzip.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_gzip.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** test_gzip.py 27 Jul 2004 21:02:02 -0000 1.12 --- test_gzip.py 29 Jul 2004 03:55:56 -0000 1.13 *************** *** 13,17 **** data2 = """/* zlibmodule.c -- gzip-compatible data compression */ ! /* See http://www.cdrom.com/pub/infozip/zlib/ */ /* See http://www.winimage.com/zLibDll for Windows */ """ --- 13,17 ---- data2 = """/* zlibmodule.c -- gzip-compatible data compression */ ! /* See http://www.gzip.org/zlib/ /* See http://www.winimage.com/zLibDll for Windows */ """ From nnorwitz at users.sourceforge.net Thu Jul 29 05:55:58 2004 From: nnorwitz at users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Thu Jul 29 05:56:07 2004 Subject: [Python-checkins] python/dist/src/Misc BeOS-setup.py,1.6,1.7 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25177/Misc Modified Files: BeOS-setup.py Log Message: SF bug #999776, zlib home page wrong Backport candidate. Index: BeOS-setup.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/BeOS-setup.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** BeOS-setup.py 18 Jul 2004 06:04:36 -0000 1.6 --- BeOS-setup.py 29 Jul 2004 03:55:56 -0000 1.7 *************** *** 444,448 **** # Andrew Kuchling's zlib module. # This require zlib 1.1.3 (or later). ! # See http://www.cdrom.com/pub/infozip/zlib/ if (self.compiler.find_library_file(lib_dirs, 'z')): exts.append( Extension('zlib', ['zlibmodule.c'], --- 444,448 ---- # Andrew Kuchling's zlib module. # This require zlib 1.1.3 (or later). ! # See http://www.gzip.org/zlib/ if (self.compiler.find_library_file(lib_dirs, 'z')): exts.append( Extension('zlib', ['zlibmodule.c'], From tim_one at users.sourceforge.net Thu Jul 29 06:07:22 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Thu Jul 29 06:07:25 2004 Subject: [Python-checkins] python/dist/src/Include listobject.h,2.29,2.30 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25814/Include Modified Files: listobject.h Log Message: Fix obscure breakage (relative to 2.3) in listsort: the test for list mutation during list.sort() used to rely on that listobject.c always NULL'ed ob_item when ob_size fell to 0. That's no longer true, so the test for list mutation during a sort is no longer reliable. Changed the test to rely instead on that listobject.c now never NULLs-out ob_item after (if ever) ob_item gets a non-NULL value. This new assumption is also documented now, as a required invariant in listobject.h. The new assumption allowed some real simplification to some of the hairier code in listsort(), so is a Good Thing on that count. Index: listobject.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/listobject.h,v retrieving revision 2.29 retrieving revision 2.30 diff -C2 -d -r2.29 -r2.30 *** listobject.h 29 Jul 2004 03:29:15 -0000 2.29 --- listobject.h 29 Jul 2004 04:07:14 -0000 2.30 *************** *** 31,34 **** --- 31,37 ---- * len(list) == ob_size * ob_item == NULL implies ob_size == allocated == 0 + * If ob_item ever becomes non-NULL, it remains non-NULL for the + * life of the list object. The check for mutation in list.sort() + * relies on this odd detail. */ int allocated; From tim_one at users.sourceforge.net Thu Jul 29 06:07:22 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Thu Jul 29 06:07:26 2004 Subject: [Python-checkins] python/dist/src/Objects listobject.c,2.209,2.210 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25814/Objects Modified Files: listobject.c Log Message: Fix obscure breakage (relative to 2.3) in listsort: the test for list mutation during list.sort() used to rely on that listobject.c always NULL'ed ob_item when ob_size fell to 0. That's no longer true, so the test for list mutation during a sort is no longer reliable. Changed the test to rely instead on that listobject.c now never NULLs-out ob_item after (if ever) ob_item gets a non-NULL value. This new assumption is also documented now, as a required invariant in listobject.h. The new assumption allowed some real simplification to some of the hairier code in listsort(), so is a Good Thing on that count. Index: listobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/listobject.c,v retrieving revision 2.209 retrieving revision 2.210 diff -C2 -d -r2.209 -r2.210 *** listobject.c 29 Jul 2004 02:29:26 -0000 2.209 --- listobject.c 29 Jul 2004 04:07:15 -0000 2.210 *************** *** 1907,1911 **** int saved_ob_size, saved_allocated; PyObject **saved_ob_item; - PyObject **empty_ob_item; PyObject *compare = NULL; PyObject *result = NULL; /* guilty until proved innocent */ --- 1907,1910 ---- *************** *** 1942,1948 **** saved_ob_item = self->ob_item; saved_allocated = self->allocated; ! self->ob_size = 0; ! self->ob_item = empty_ob_item = PyMem_NEW(PyObject *, 0); ! self->allocated = 0; if (keyfunc != NULL) { --- 1941,1946 ---- saved_ob_item = self->ob_item; saved_allocated = self->allocated; ! self->ob_size = self->allocated = 0; ! self->ob_item = NULL; if (keyfunc != NULL) { *************** *** 1958,1973 **** Py_DECREF(kvpair); } - if (self->ob_item != empty_ob_item - || self->ob_size) { - /* If the list changed *as well* we - have two errors. We let the first - one "win", but we shouldn't let - what's in the list currently - leak. */ - (void)list_ass_slice( - self, 0, self->ob_size, - (PyObject *)NULL); - } - goto dsu_fail; } --- 1956,1959 ---- *************** *** 2045,2056 **** } ! if (self->ob_item != empty_ob_item || self->ob_size) { ! /* The user mucked with the list during the sort. */ ! (void)list_ass_slice(self, 0, self->ob_size, (PyObject *)NULL); ! if (result != NULL) { ! PyErr_SetString(PyExc_ValueError, ! "list modified during sort"); ! result = NULL; ! } } --- 2031,2040 ---- } ! if (self->ob_item != NULL && result != NULL) { ! /* The user mucked with the list during the sort, ! * and we don't already have another error to report. ! */ ! PyErr_SetString(PyExc_ValueError, "list modified during sort"); ! result = NULL; } *************** *** 2061,2066 **** dsu_fail: ! if (self->ob_item == empty_ob_item) ! PyMem_FREE(empty_ob_item); self->ob_size = saved_ob_size; self->ob_item = saved_ob_item; --- 2045,2052 ---- dsu_fail: ! if (self->ob_item != NULL) { ! (void)list_ass_slice(self, 0, self->ob_size, (PyObject *)NULL); ! PyMem_FREE(self->ob_item); ! } self->ob_size = saved_ob_size; self->ob_item = saved_ob_item; From rhettinger at users.sourceforge.net Thu Jul 29 08:06:36 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Thu Jul 29 08:06:40 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libfuncs.tex,1.166,1.167 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5440 Modified Files: libfuncs.tex Log Message: SF bug #997533: "disjunct" should be "disjoint" * Use plain wording in docs for id(). * Use normal quotation marks instead of single quotes in the description. Index: libfuncs.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libfuncs.tex,v retrieving revision 1.166 retrieving revision 1.167 diff -C2 -d -r1.166 -r1.167 *** libfuncs.tex 2 Jul 2004 06:41:04 -0000 1.166 --- libfuncs.tex 29 Jul 2004 06:06:34 -0000 1.167 *************** *** 510,517 **** \begin{funcdesc}{id}{object} ! Return the `identity' of an object. This is an integer (or long integer) which is guaranteed to be unique and constant for this ! object during its lifetime. Two objects whose lifetimes are ! disjunct may have the same \function{id()} value. (Implementation note: this is the address of the object.) \end{funcdesc} --- 510,517 ---- \begin{funcdesc}{id}{object} ! Return the ``identity'' of an object. This is an integer (or long integer) which is guaranteed to be unique and constant for this ! object during its lifetime. Two objects with non-overlapping lifetimes ! may have the same \function{id()} value. (Implementation note: this is the address of the object.) \end{funcdesc} From vsajip at users.sourceforge.net Thu Jul 29 11:19:32 2004 From: vsajip at users.sourceforge.net (vsajip@users.sourceforge.net) Date: Thu Jul 29 11:19:36 2004 Subject: [Python-checkins] python/dist/src/Lib/logging __init__.py, 1.17, 1.18 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/logging In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32277 Modified Files: __init__.py Log Message: Ignore exceptions which occur when closing files in shutdown() Index: __init__.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/logging/__init__.py,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** __init__.py 8 Jul 2004 10:22:35 -0000 1.17 --- __init__.py 29 Jul 2004 09:19:30 -0000 1.18 *************** *** 1257,1262 **** """ for h in _handlers.keys(): ! h.flush() ! h.close() #Let's try and shutdown automatically on application exit... --- 1257,1267 ---- """ for h in _handlers.keys(): ! #errors might occur, for example, if files are locked ! #we just ignore them ! try: ! h.flush() ! h.close() ! except: ! pass #Let's try and shutdown automatically on application exit... From arigo at users.sourceforge.net Thu Jul 29 12:56:57 2004 From: arigo at users.sourceforge.net (arigo@users.sourceforge.net) Date: Thu Jul 29 12:57:01 2004 Subject: [Python-checkins] python/dist/src/Objects listobject.c,2.210,2.211 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12444 Modified Files: listobject.c Log Message: Minor memory leak. Index: listobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/listobject.c,v retrieving revision 2.210 retrieving revision 2.211 diff -C2 -d -r2.210 -r2.211 *** listobject.c 29 Jul 2004 04:07:15 -0000 2.210 --- listobject.c 29 Jul 2004 10:56:55 -0000 2.211 *************** *** 537,540 **** --- 537,541 ---- if (recycle == NULL) { PyErr_NoMemory(); + Py_XDECREF(v_as_SF); return -1; } *************** *** 557,560 **** --- 558,562 ---- if (recycle != NULL) PyMem_DEL(recycle); + Py_XDECREF(v_as_SF); return -1; } From arigo at users.sourceforge.net Thu Jul 29 14:40:25 2004 From: arigo at users.sourceforge.net (arigo@users.sourceforge.net) Date: Thu Jul 29 14:40:28 2004 Subject: [Python-checkins] python/dist/src/Include listobject.h,2.30,2.31 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28350/Include Modified Files: listobject.h Log Message: * drop the unreasonable list invariant that ob_item should never come back to NULL during the lifetime of the object. * listobject.c nevertheless did not conform to the other invariants, either; fixed. * listobject.c now uses list_clear() as the obvious internal way to clear a list, instead of abusing list_ass_slice() for that. It makes it easier to enforce the invariant about ob_item == NULL. * listsort() sets allocated to -1 during sort; any mutation will set it to a value >= 0, so it is a safe way to detect mutation. A negative value for allocated does not cause a problem elsewhere currently. test_sort.py has a new test for this fix. * listsort() leak: if items were added to the list during the sort, AND if these items had a __del__ that puts still more stuff into the list, then this more stuff (and the PyObject** array to hold them) were overridden at the end of listsort() and never released. Index: listobject.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/listobject.h,v retrieving revision 2.30 retrieving revision 2.31 diff -C2 -d -r2.30 -r2.31 *** listobject.h 29 Jul 2004 04:07:14 -0000 2.30 --- listobject.h 29 Jul 2004 12:40:22 -0000 2.31 *************** *** 31,37 **** * len(list) == ob_size * ob_item == NULL implies ob_size == allocated == 0 ! * If ob_item ever becomes non-NULL, it remains non-NULL for the ! * life of the list object. The check for mutation in list.sort() ! * relies on this odd detail. */ int allocated; --- 31,35 ---- * len(list) == ob_size * ob_item == NULL implies ob_size == allocated == 0 ! * list.sort() temporarily sets allocated to -1 to detect mutations. */ int allocated; From arigo at users.sourceforge.net Thu Jul 29 14:40:25 2004 From: arigo at users.sourceforge.net (arigo@users.sourceforge.net) Date: Thu Jul 29 14:40:30 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_sort.py,1.12,1.13 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28350/Lib/test Modified Files: test_sort.py Log Message: * drop the unreasonable list invariant that ob_item should never come back to NULL during the lifetime of the object. * listobject.c nevertheless did not conform to the other invariants, either; fixed. * listobject.c now uses list_clear() as the obvious internal way to clear a list, instead of abusing list_ass_slice() for that. It makes it easier to enforce the invariant about ob_item == NULL. * listsort() sets allocated to -1 during sort; any mutation will set it to a value >= 0, so it is a safe way to detect mutation. A negative value for allocated does not cause a problem elsewhere currently. test_sort.py has a new test for this fix. * listsort() leak: if items were added to the list during the sort, AND if these items had a __del__ that puts still more stuff into the list, then this more stuff (and the PyObject** array to hold them) were overridden at the end of listsort() and never released. Index: test_sort.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_sort.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** test_sort.py 18 Jan 2004 20:29:55 -0000 1.12 --- test_sort.py 29 Jul 2004 12:40:22 -0000 1.13 *************** *** 151,154 **** --- 151,171 ---- self.assertEqual(L, range(50)) + def test_undetected_mutation(self): + # Python 2.4a1 did not always detect mutation + memorywaster = [] + for i in range(20): + def mutating_cmp(x, y): + L.append(3) + L.pop() + return cmp(x, y) + L = [1,2] + self.assertRaises(ValueError, L.sort, mutating_cmp) + def mutating_cmp(x, y): + L.append(3) + del L[:] + return cmp(x, y) + self.assertRaises(ValueError, L.sort, mutating_cmp) + memorywaster = [memorywaster] + #============================================================================== From arigo at users.sourceforge.net Thu Jul 29 14:40:25 2004 From: arigo at users.sourceforge.net (arigo@users.sourceforge.net) Date: Thu Jul 29 14:40:32 2004 Subject: [Python-checkins] python/dist/src/Objects listobject.c,2.211,2.212 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28350/Objects Modified Files: listobject.c Log Message: * drop the unreasonable list invariant that ob_item should never come back to NULL during the lifetime of the object. * listobject.c nevertheless did not conform to the other invariants, either; fixed. * listobject.c now uses list_clear() as the obvious internal way to clear a list, instead of abusing list_ass_slice() for that. It makes it easier to enforce the invariant about ob_item == NULL. * listsort() sets allocated to -1 during sort; any mutation will set it to a value >= 0, so it is a safe way to detect mutation. A negative value for allocated does not cause a problem elsewhere currently. test_sort.py has a new test for this fix. * listsort() leak: if items were added to the list during the sort, AND if these items had a __del__ that puts still more stuff into the list, then this more stuff (and the PyObject** array to hold them) were overridden at the end of listsort() and never released. Index: listobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/listobject.c,v retrieving revision 2.211 retrieving revision 2.212 diff -C2 -d -r2.211 -r2.212 *** listobject.c 29 Jul 2004 10:56:55 -0000 2.211 --- listobject.c 29 Jul 2004 12:40:23 -0000 2.212 *************** *** 487,490 **** --- 487,513 ---- static int + list_clear(PyListObject *a) + { + int i; + PyObject **item = a->ob_item; + if (item != NULL) { + /* Because XDECREF can recursively invoke operations on + this list, we make it empty first. */ + i = a->ob_size; + a->ob_size = 0; + a->ob_item = NULL; + a->allocated = 0; + while (--i >= 0) { + Py_XDECREF(item[i]); + } + PyMem_FREE(item); + } + /* Never fails; the return value can be ignored. + Note that there is no guarantee that the list is actually empty + at this point, because XDECREF may have populated it again! */ + return 0; + } + + static int list_ass_slice(PyListObject *a, int ilow, int ihigh, PyObject *v) { *************** *** 531,536 **** else if (ihigh > a->ob_size) ihigh = a->ob_size; ! item = a->ob_item; d = n - (ihigh-ilow); if (ihigh > ilow) { p = recycle = PyMem_NEW(PyObject *, (ihigh-ilow)); --- 554,564 ---- else if (ihigh > a->ob_size) ihigh = a->ob_size; ! d = n - (ihigh-ilow); + if (a->ob_size + d == 0) { + Py_XDECREF(v_as_SF); + return list_clear(a); + } + item = a->ob_item; if (ihigh > ilow) { p = recycle = PyMem_NEW(PyObject *, (ihigh-ilow)); *************** *** 577,584 **** PyMem_DEL(recycle); } - if (a->ob_size == 0 && a->ob_item != NULL) { - PyMem_FREE(a->ob_item); - a->ob_item = NULL; - } Py_XDECREF(v_as_SF); return 0; --- 605,608 ---- *************** *** 610,619 **** if (n < 1) { ! items = self->ob_item; ! self->ob_item = NULL; ! self->ob_size = 0; ! for (i = 0; i < size; i++) ! Py_XDECREF(items[i]); ! PyMem_DEL(items); Py_INCREF(self); return (PyObject *)self; --- 634,638 ---- if (n < 1) { ! (void)list_clear(self); Py_INCREF(self); return (PyObject *)self; *************** *** 1909,1912 **** --- 1928,1932 ---- int saved_ob_size, saved_allocated; PyObject **saved_ob_item; + PyObject **final_ob_item; PyObject *compare = NULL; PyObject *result = NULL; /* guilty until proved innocent */ *************** *** 1943,1948 **** saved_ob_item = self->ob_item; saved_allocated = self->allocated; ! self->ob_size = self->allocated = 0; self->ob_item = NULL; if (keyfunc != NULL) { --- 1963,1969 ---- saved_ob_item = self->ob_item; saved_allocated = self->allocated; ! self->ob_size = 0; self->ob_item = NULL; + self->allocated = -1; /* any operation will reset it to >= 0 */ if (keyfunc != NULL) { *************** *** 2033,2037 **** } ! if (self->ob_item != NULL && result != NULL) { /* The user mucked with the list during the sort, * and we don't already have another error to report. --- 2054,2058 ---- } ! if (self->allocated != -1 && result != NULL) { /* The user mucked with the list during the sort, * and we don't already have another error to report. *************** *** 2047,2057 **** dsu_fail: ! if (self->ob_item != NULL) { ! (void)list_ass_slice(self, 0, self->ob_size, (PyObject *)NULL); ! PyMem_FREE(self->ob_item); ! } self->ob_size = saved_ob_size; self->ob_item = saved_ob_item; self->allocated = saved_allocated; Py_XDECREF(compare); Py_XINCREF(result); --- 2068,2084 ---- dsu_fail: ! final_ob_item = self->ob_item; ! i = self->ob_size; self->ob_size = saved_ob_size; self->ob_item = saved_ob_item; self->allocated = saved_allocated; + if (final_ob_item != NULL) { + /* we cannot use list_clear() for this because it does not + guarantee that the list is really empty when it returns */ + while (--i >= 0) { + Py_XDECREF(final_ob_item[i]); + } + PyMem_FREE(final_ob_item); + } Py_XDECREF(compare); Py_XINCREF(result); *************** *** 2208,2218 **** } - static int - list_clear(PyListObject *lp) - { - (void) PyList_SetSlice((PyObject *)lp, 0, lp->ob_size, 0); - return 0; - } - static PyObject * list_richcompare(PyObject *v, PyObject *w, int op) --- 2235,2238 ---- *************** *** 2296,2303 **** return -1; /* Empty previous contents */ ! self->allocated = self->ob_size; ! if (self->ob_size != 0) { ! if (list_ass_slice(self, 0, self->ob_size, (PyObject *)NULL) != 0) ! return -1; } if (arg != NULL) { --- 2316,2321 ---- return -1; /* Empty previous contents */ ! if (self->ob_item != NULL) { ! (void)list_clear(self); } if (arg != NULL) { From rhettinger at users.sourceforge.net Fri Jul 30 01:31:33 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Fri Jul 30 01:31:37 2004 Subject: [Python-checkins] python/dist/src/Objects listobject.c,2.212,2.213 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21484 Modified Files: listobject.c Log Message: * Simplify and speed-up list_resize(). Relying on the newly documented invariants allows the ob_item != NULL check to be replaced with an assertion. * Added assertions to list_init() which document and verify that the tp_new slot establishes the invariants. This may preclude a future bug if a custom tp_new slot is written. Index: listobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/listobject.c,v retrieving revision 2.212 retrieving revision 2.213 diff -C2 -d -r2.212 -r2.213 *** listobject.c 29 Jul 2004 12:40:23 -0000 2.212 --- listobject.c 29 Jul 2004 23:31:29 -0000 2.213 *************** *** 20,26 **** */ ! if (self->allocated >= newsize && ! self->ob_size < newsize + 16 && ! self->ob_item != NULL) { self->ob_size = newsize; return 0; --- 20,25 ---- */ ! if (self->allocated >= newsize && self->ob_size < newsize + 16) { ! assert(self->ob_item != NULL || newsize == 0); self->ob_size = newsize; return 0; *************** *** 2315,2318 **** --- 2314,2322 ---- if (!PyArg_ParseTupleAndKeywords(args, kw, "|O:list", kwlist, &arg)) return -1; + + /* Verify list invariants established by PyType_GenericAlloc() */ + assert(0 <= self->ob_size && self->ob_size <= self->allocated); + assert(self->ob_item != NULL || self->allocated == 0); + /* Empty previous contents */ if (self->ob_item != NULL) { From arigo at users.sourceforge.net Fri Jul 30 13:20:20 2004 From: arigo at users.sourceforge.net (arigo@users.sourceforge.net) Date: Fri Jul 30 13:20:25 2004 Subject: [Python-checkins] python/dist/src/Objects listobject.c,2.213,2.214 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19327 Modified Files: listobject.c Log Message: What if you call lst.__init__() while it is being sorted? :-) The invariant checks would break. Index: listobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/listobject.c,v retrieving revision 2.213 retrieving revision 2.214 diff -C2 -d -r2.213 -r2.214 *** listobject.c 29 Jul 2004 23:31:29 -0000 2.213 --- listobject.c 30 Jul 2004 11:20:18 -0000 2.214 *************** *** 2316,2321 **** /* Verify list invariants established by PyType_GenericAlloc() */ ! assert(0 <= self->ob_size && self->ob_size <= self->allocated); ! assert(self->ob_item != NULL || self->allocated == 0); /* Empty previous contents */ --- 2316,2323 ---- /* Verify list invariants established by PyType_GenericAlloc() */ ! assert(0 <= self->ob_size); ! assert(self->ob_size <= self->allocated || self->allocated == -1); ! assert(self->ob_item != NULL || ! self->allocated == 0 || self->allocated == -1); /* Empty previous contents */ From arigo at users.sourceforge.net Fri Jul 30 13:38:25 2004 From: arigo at users.sourceforge.net (arigo@users.sourceforge.net) Date: Fri Jul 30 13:38:28 2004 Subject: [Python-checkins] python/dist/src/Objects listobject.c,2.214,2.215 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20768 Modified Files: listobject.c Log Message: This is a reorganization of list_ass_slice(). It should probably be reviewed, though I tried to be very careful. This is a slight simplification, and it adds a new feature: a small stack-allocated "recycled" array for the cases when we don't remove too many items. It allows PyList_SetSlice() to never fail if: * you are sure that the object is a list; and * you either do not remove more than 8 items, or clear the list. This makes a number of other places in the source code correct again -- there are some places that delete a single item without checking for MemoryErrors raised by PyList_SetSlice(), or that clear the whole list, and sometimes the context doesn't allow an error to be propagated. Index: listobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/listobject.c,v retrieving revision 2.214 retrieving revision 2.215 diff -C2 -d -r2.214 -r2.215 *** listobject.c 30 Jul 2004 11:20:18 -0000 2.214 --- listobject.c 30 Jul 2004 11:38:22 -0000 2.215 *************** *** 518,521 **** --- 518,522 ---- list. :-( */ PyObject **recycle, **p; + PyObject *recycled[8]; PyObject **item; PyObject **vitem = NULL; *************** *** 560,565 **** } item = a->ob_item; ! if (ihigh > ilow) { ! p = recycle = PyMem_NEW(PyObject *, (ihigh-ilow)); if (recycle == NULL) { PyErr_NoMemory(); --- 561,568 ---- } item = a->ob_item; ! /* recycle the ihigh-ilow items that we are about to remove */ ! s = (ihigh - ilow)*sizeof(PyObject *); ! if (s > sizeof(recycled)) { ! recycle = (PyObject **)PyMem_MALLOC(s); if (recycle == NULL) { PyErr_NoMemory(); *************** *** 569,588 **** } else ! p = recycle = NULL; ! if (d <= 0) { /* Delete -d items; recycle ihigh-ilow items */ ! memcpy(p, &item[ilow], (ihigh - ilow)*sizeof(PyObject *)); ! p += ihigh - ilow; ! if (d < 0) { ! memmove(&item[ihigh+d], &item[ihigh], ! (a->ob_size - ihigh)*sizeof(PyObject *)); ! list_resize(a, a->ob_size + d); ! item = a->ob_item; ! } } ! else { /* Insert d items; recycle ihigh-ilow items */ s = a->ob_size; if (list_resize(a, s+d) == -1) { ! if (recycle != NULL) ! PyMem_DEL(recycle); Py_XDECREF(v_as_SF); return -1; --- 572,589 ---- } else ! recycle = recycled; ! p = recycle + (ihigh - ilow); ! memcpy(recycle, &item[ilow], s); ! if (d < 0) { /* Delete -d items */ ! memmove(&item[ihigh+d], &item[ihigh], ! (a->ob_size - ihigh)*sizeof(PyObject *)); ! list_resize(a, a->ob_size + d); ! item = a->ob_item; } ! else if (d > 0) { /* Insert d items */ s = a->ob_size; if (list_resize(a, s+d) == -1) { ! if (recycle != recycled) ! PyMem_FREE(recycle); Py_XDECREF(v_as_SF); return -1; *************** *** 591,596 **** memmove(&item[ihigh+d], &item[ihigh], (s - ihigh)*sizeof(PyObject *)); - memcpy(p, &item[ilow], (ihigh - ilow)*sizeof(PyObject *)); - p += ihigh - ilow; } for (k = 0; k < n; k++, ilow++) { --- 592,595 ---- *************** *** 599,607 **** item[ilow] = w; } ! if (recycle) { ! while (--p >= recycle) ! Py_XDECREF(*p); ! PyMem_DEL(recycle); ! } Py_XDECREF(v_as_SF); return 0; --- 598,605 ---- item[ilow] = w; } ! while (--p >= recycle) ! Py_XDECREF(*p); ! if (recycle != recycled) ! PyMem_FREE(recycle); Py_XDECREF(v_as_SF); return 0; From loewis at users.sourceforge.net Fri Jul 30 18:08:52 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Fri Jul 30 18:08:56 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libnntplib.tex,1.30,1.31 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5653 Modified Files: libnntplib.tex Log Message: Add closing methoddesc. Add versionadded. Rewrap. Index: libnntplib.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libnntplib.tex,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** libnntplib.tex 26 Jul 2004 12:40:50 -0000 1.30 --- libnntplib.tex 30 Jul 2004 16:08:49 -0000 1.31 *************** *** 176,179 **** --- 176,180 ---- calling \method{write()} on it to store the lines of the command output. If \var{file} is supplied, then the returned \var{list} is an empty list. + \end{methoddesc} \begin{methoddesc}{descriptions}{grouppattern} *************** *** 183,196 **** \var{list})}, where \var{list} is a list of tuples containing \code{(\var{name}, \var{title})}. \end{methoddesc} \begin{methoddesc}{description}{group} Get a description for a single group \var{group}. If more than one group ! matches (if 'group' is a real wildmat string), return the first match. If no group ! matches, return an empty string. This elides the response code from the server. If the response code is needed, use \method{descriptions()}. \end{methoddesc} --- 184,200 ---- \var{list})}, where \var{list} is a list of tuples containing \code{(\var{name}, \var{title})}. + + \versionadded{2.4} \end{methoddesc} \begin{methoddesc}{description}{group} Get a description for a single group \var{group}. If more than one group ! matches (if 'group' is a real wildmat string), return the first match. ! If no group matches, return an empty string. This elides the response code from the server. If the response code is needed, use \method{descriptions()}. + \versionadded{2.4} \end{methoddesc} From loewis at users.sourceforge.net Fri Jul 30 18:09:22 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Fri Jul 30 18:09:25 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libimaplib.tex,1.28,1.29 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5791 Modified Files: libimaplib.tex Log Message: Fix typo. Index: libimaplib.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libimaplib.tex,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** libimaplib.tex 28 Jul 2004 02:34:12 -0000 1.28 --- libimaplib.tex 30 Jul 2004 16:09:19 -0000 1.29 *************** *** 248,252 **** \end{methoddesc} ! \begin{methoddes}{myrights}{mailbox} Show my ACLs for a mailbox (i.e. the rights that I have on mailbox). \versionadded{2.4} --- 248,252 ---- \end{methoddesc} ! \begin{methoddesc}{myrights}{mailbox} Show my ACLs for a mailbox (i.e. the rights that I have on mailbox). \versionadded{2.4} From Rhonda_Province at hotmail.com Fri Jul 30 20:26:46 2004 From: Rhonda_Province at hotmail.com (Wang Olivas) Date: Fri Jul 30 19:35:51 2004 Subject: [Python-checkins] Re: work Message-ID: <20040730173549.6249E1E4002@bag.python.org> An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-checkins/attachments/20040730/3478ab18/attachment.html From fdrake at users.sourceforge.net Fri Jul 30 20:57:58 2004 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Fri Jul 30 20:58:01 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libcmd.tex, 1.14, 1.14.14.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4344/lib Modified Files: Tag: release23-maint libcmd.tex Log Message: - make references to the readline module hyperlinks now that there is documentation to link to - document the termination condition for cmd.Cmd.cmdloop() - document the use of the return value for cmd.Cmd.do_*() methods Index: libcmd.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libcmd.tex,v retrieving revision 1.14 retrieving revision 1.14.14.1 diff -C2 -d -r1.14 -r1.14.14.1 *** libcmd.tex 6 Feb 2003 05:02:39 -0000 1.14 --- libcmd.tex 30 Jul 2004 18:57:55 -0000 1.14.14.1 *************** *** 12,16 **** later be wrapped in a more sophisticated interface. ! \begin{classdesc}{Cmd}{\optional{completekey},\optional{stdin},\optional{stdout}} A \class{Cmd} instance or subclass instance is a line-oriented interpreter framework. There is no good reason to instantiate --- 12,17 ---- later be wrapped in a more sophisticated interface. ! \begin{classdesc}{Cmd}{\optional{completekey\optional{, ! stdin\optional{, stdout}}}} A \class{Cmd} instance or subclass instance is a line-oriented interpreter framework. There is no good reason to instantiate *************** *** 21,25 **** The optional argument \var{completekey} is the \refmodule{readline} name of a completion key; it defaults to \kbd{Tab}. If \var{completekey} is ! not \code{None} and \module{readline} is available, command completion is done automatically. --- 22,26 ---- The optional argument \var{completekey} is the \refmodule{readline} name of a completion key; it defaults to \kbd{Tab}. If \var{completekey} is ! not \code{None} and \refmodule{readline} is available, command completion is done automatically. *************** *** 45,49 **** first prompt (this overrides the \member{intro} class member). ! If the \module{readline} module is loaded, input will automatically inherit \program{bash}-like history-list editing (e.g. \kbd{Control-P} scrolls back to the last command, \kbd{Control-N} forward to the next --- 46,50 ---- first prompt (this overrides the \member{intro} class member). ! If the \refmodule{readline} module is loaded, input will automatically inherit \program{bash}-like history-list editing (e.g. \kbd{Control-P} scrolls back to the last command, \kbd{Control-N} forward to the next *************** *** 60,63 **** --- 61,68 ---- method \method{do_shell()} (if such a method is defined). + This method will return when the \method{postcmd()} method returns a + true value. The \var{stop} argument to \method{postcmd()} is the + return value from the command's corresponding \method{do_*()} method. + If completion is enabled, completing commands will be done automatically, and completing of commands args is done by calling *************** *** 83,87 **** see the \method{precmd()} and \method{postcmd()} methods for useful execution hooks. The return value is a flag indicating whether ! interpretation of commands by the interpreter should stop. \end{methoddesc} --- 88,95 ---- see the \method{precmd()} and \method{postcmd()} methods for useful execution hooks. The return value is a flag indicating whether ! interpretation of commands by the interpreter should stop. If there ! is a \method{do_*()} method for the command \var{str}, the return ! value of that method is returned, otherwise the return value from the ! \method{default()} method is returned. \end{methoddesc} *************** *** 185,189 **** if false, \method{sys.stdout.write()} and \method{sys.stdin.readline()} are used. (This means that by ! importing \module{readline}, on systems that support it, the interpreter will automatically support Emacs-like line editing and command-history keystrokes.) --- 193,197 ---- if false, \method{sys.stdout.write()} and \method{sys.stdin.readline()} are used. (This means that by ! importing \refmodule{readline}, on systems that support it, the interpreter will automatically support Emacs-like line editing and command-history keystrokes.) From fdrake at users.sourceforge.net Fri Jul 30 20:58:57 2004 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Fri Jul 30 20:59:00 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libcmd.tex,1.15,1.16 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4537/lib Modified Files: libcmd.tex Log Message: - document the termination condition for cmd.Cmd.cmdloop() - document the use of the return value for cmd.Cmd.do_*() methods Index: libcmd.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libcmd.tex,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** libcmd.tex 31 Dec 2003 05:01:23 -0000 1.15 --- libcmd.tex 30 Jul 2004 18:58:54 -0000 1.16 *************** *** 61,64 **** --- 61,68 ---- method \method{do_shell()} (if such a method is defined). + This method will return when the \method{postcmd()} method returns a + true value. The \var{stop} argument to \method{postcmd()} is the + return value from the command's corresponding \method{do_*()} method. + If completion is enabled, completing commands will be done automatically, and completing of commands args is done by calling *************** *** 84,88 **** see the \method{precmd()} and \method{postcmd()} methods for useful execution hooks. The return value is a flag indicating whether ! interpretation of commands by the interpreter should stop. \end{methoddesc} --- 88,95 ---- see the \method{precmd()} and \method{postcmd()} methods for useful execution hooks. The return value is a flag indicating whether ! interpretation of commands by the interpreter should stop. If there ! is a \method{do_*()} method for the command \var{str}, the return ! value of that method is returned, otherwise the return value from the ! \method{default()} method is returned. \end{methoddesc} From fdrake at users.sourceforge.net Fri Jul 30 21:12:40 2004 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Fri Jul 30 21:12:45 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libimaplib.tex,1.29,1.30 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7327/lib Modified Files: libimaplib.tex Log Message: re-wrap paragraphs containing long lines Index: libimaplib.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libimaplib.tex,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** libimaplib.tex 30 Jul 2004 16:09:19 -0000 1.29 --- libimaplib.tex 30 Jul 2004 19:12:38 -0000 1.30 *************** *** 7,15 **** \sectionauthor{Piers Lauder}{piers@communitysolutions.com.au} ! % Based on HTML documentation by Piers Lauder ; % converted by Fred L. Drake, Jr. . % Revised by ESR, January 2000. % Changes for IMAP4_SSL by Tino Lange , March 2002 ! % Changes for IMAP4_stream by Piers Lauder , November 2002 \indexii{IMAP4}{protocol} --- 7,17 ---- \sectionauthor{Piers Lauder}{piers@communitysolutions.com.au} ! % Based on HTML documentation by Piers Lauder ! % ; % converted by Fred L. Drake, Jr. . % Revised by ESR, January 2000. % Changes for IMAP4_SSL by Tino Lange , March 2002 ! % Changes for IMAP4_stream by Piers Lauder ! % , November 2002 \indexii{IMAP4}{protocol} *************** *** 17,21 **** \indexii{IMAP4_stream}{protocol} ! This module defines three classes, \class{IMAP4}, \class{IMAP4_SSL} and \class{IMAP4_stream}, which encapsulate a connection to an IMAP4 server and implement a large subset of the IMAP4rev1 client protocol as defined in \rfc{2060}. It is backward --- 19,24 ---- \indexii{IMAP4_stream}{protocol} ! This module defines three classes, \class{IMAP4}, \class{IMAP4_SSL} ! and \class{IMAP4_stream}, which encapsulate a connection to an IMAP4 server and implement a large subset of the IMAP4rev1 client protocol as defined in \rfc{2060}. It is backward *************** *** 23,27 **** \samp{STATUS} command is not supported in IMAP4. ! Three classes are provided by the \module{imaplib} module, \class{IMAP4} is the base class: \begin{classdesc}{IMAP4}{\optional{host\optional{, port}}} --- 26,31 ---- \samp{STATUS} command is not supported in IMAP4. ! Three classes are provided by the \module{imaplib} module, ! \class{IMAP4} is the base class: \begin{classdesc}{IMAP4}{\optional{host\optional{, port}}} *************** *** 48,65 **** \begin{excdesc}{IMAP4.readonly} ! This exception is raised when a writable mailbox has its status changed by the server. This is a ! sub-class of \exception{IMAP4.error}. Some other client now has write permission, ! and the mailbox will need to be re-opened to re-obtain write permission. \end{excdesc} There's also a subclass for secure connections: ! \begin{classdesc}{IMAP4_SSL}{\optional{host\optional{, port\optional{, keyfile\optional{, certfile}}}}} ! This is a subclass derived from \class{IMAP4} that connects over an SSL encrypted socket ! (to use this class you need a socket module that was compiled with SSL support). ! If \var{host} is not specified, \code{''} (the local host) is used. ! If \var{port} is omitted, the standard IMAP4-over-SSL port (993) is used. ! \var{keyfile} and \var{certfile} are also optional - they can contain a PEM formatted ! private key and certificate chain file for the SSL connection. \end{classdesc} --- 52,73 ---- \begin{excdesc}{IMAP4.readonly} ! This exception is raised when a writable mailbox has its status ! changed by the server. This is a sub-class of ! \exception{IMAP4.error}. Some other client now has write permission, ! and the mailbox will need to be re-opened to re-obtain write ! permission. \end{excdesc} There's also a subclass for secure connections: ! \begin{classdesc}{IMAP4_SSL}{\optional{host\optional{, port\optional{, ! keyfile\optional{, certfile}}}}} ! This is a subclass derived from \class{IMAP4} that connects over an ! SSL encrypted socket (to use this class you need a socket module that ! was compiled with SSL support). If \var{host} is not specified, ! \code{''} (the local host) is used. If \var{port} is omitted, the ! standard IMAP4-over-SSL port (993) is used. \var{keyfile} and ! \var{certfile} are also optional - they can contain a PEM formatted ! private key and certificate chain file for the SSL connection. \end{classdesc} *************** *** 68,72 **** \begin{classdesc}{IMAP4_stream}{command} This is a subclass derived from \class{IMAP4} that connects ! to the \code{stdin/stdout} file descriptors created by passing \var{command} to \code{os.popen2()}. \versionadded{2.3} \end{classdesc} --- 76,81 ---- \begin{classdesc}{IMAP4_stream}{command} This is a subclass derived from \class{IMAP4} that connects ! to the \code{stdin/stdout} file descriptors created by passing ! \var{command} to \code{os.popen2()}. \versionadded{2.3} \end{classdesc} *************** *** 145,151 **** Authenticate command --- requires response processing. ! \var{mechanism} specifies which authentication mechanism is to ! be used - it should appear in the instance variable \code{capabilities} in the ! form \code{AUTH=mechanism}. \var{authobject} must be a callable object: --- 154,160 ---- Authenticate command --- requires response processing. ! \var{mechanism} specifies which authentication mechanism is to be ! used - it should appear in the instance variable \code{capabilities} ! in the form \code{AUTH=mechanism}. \var{authobject} must be a callable object: *************** *** 232,237 **** \begin{methoddesc}{login_cram_md5}{user, password} ! Force use of \samp{CRAM-MD5} authentication when identifying the client to protect the password. ! Will only work if the server \samp{CAPABILITY} response includes the phrase \samp{AUTH=CRAM-MD5}. \versionadded{2.3} \end{methoddesc} --- 241,247 ---- \begin{methoddesc}{login_cram_md5}{user, password} ! Force use of \samp{CRAM-MD5} authentication when identifying the ! client to protect the password. Will only work if the server ! \samp{CAPABILITY} response includes the phrase \samp{AUTH=CRAM-MD5}. \versionadded{2.3} \end{methoddesc} *************** *** 265,269 **** Opens socket to \var{port} at \var{host}. The connection objects established by this method ! will be used in the \code{read}, \code{readline}, \code{send}, and \code{shutdown} methods. You may override this method. \end{methoddesc} --- 275,280 ---- Opens socket to \var{port} at \var{host}. The connection objects established by this method ! will be used in the \code{read}, \code{readline}, \code{send}, and ! \code{shutdown} methods. You may override this method. \end{methoddesc} *************** *** 356,369 **** \begin{methoddesc}{sort}{sort_criteria, charset, search_criterion\optional{, ...}} ! The \code{sort} command is a variant of \code{search} with sorting semantics for ! the results. Returned data contains a space ! separated list of matching message numbers. Sort has two arguments before the \var{search_criterion} ! argument(s); a parenthesized list of \var{sort_criteria}, and the searching \var{charset}. ! Note that unlike \code{search}, the searching \var{charset} argument is mandatory. ! There is also a \code{uid sort} command which corresponds to \code{sort} the way ! that \code{uid search} corresponds to \code{search}. ! The \code{sort} command first searches the mailbox for messages that match the given searching criteria using the charset argument for the interpretation of strings in the searching criteria. It then --- 367,381 ---- \begin{methoddesc}{sort}{sort_criteria, charset, search_criterion\optional{, ...}} ! The \code{sort} command is a variant of \code{search} with sorting ! semantics for the results. Returned data contains a space separated ! list of matching message numbers. Sort has two arguments before the \var{search_criterion} ! argument(s); a parenthesized list of \var{sort_criteria}, and the ! searching \var{charset}. Note that unlike \code{search}, the ! searching \var{charset} argument is mandatory. There is also a ! \code{uid sort} command which corresponds to \code{sort} the way ! that \code{uid search} corresponds to \code{search}. The ! \code{sort} command first searches the mailbox for messages that match the given searching criteria using the charset argument for the interpretation of strings in the searching criteria. It then *************** *** 385,406 **** \end{methoddesc} ! \begin{methoddesc}{thread}{threading_algorithm, charset, search_criterion\optional{, ...}} ! The \code{thread} command is a variant of \code{search} with threading semantics for ! the results. Returned data contains a space separated list of thread members. ! Thread members consist of zero or more messages numbers, delimited by spaces, ! indicating successive parent and child. Thread has two arguments before the \var{search_criterion} ! argument(s); a \var{threading_algorithm}, and the searching \var{charset}. ! Note that unlike \code{search}, the searching \var{charset} argument is mandatory. ! There is also a \code{uid thread} command which corresponds to \code{thread} the way ! that \code{uid search} corresponds to \code{search}. ! The \code{thread} command first searches the mailbox for messages that ! match the given searching criteria using the charset argument for ! the interpretation of strings in the searching criteria. It thren ! returns the matching messages threaded according to the specified ! threading algorithm. This is an \samp{IMAP4rev1} extension command. \versionadded{2.4} --- 397,419 ---- \end{methoddesc} ! \begin{methoddesc}{thread}{threading_algorithm, charset, ! search_criterion\optional{, ...}} ! The \code{thread} command is a variant of \code{search} with ! threading semantics for the results. Returned data contains a space separated list of thread members. ! Thread members consist of zero or more messages numbers, delimited ! by spaces, indicating successive parent and child. Thread has two arguments before the \var{search_criterion} ! argument(s); a \var{threading_algorithm}, and the searching ! \var{charset}. Note that unlike \code{search}, the searching ! \var{charset} argument is mandatory. There is also a \code{uid ! thread} command which corresponds to \code{thread} the way that ! \code{uid search} corresponds to \code{search}. The \code{thread} ! command first searches the mailbox for messages that match the given ! searching criteria using the charset argument for the interpretation ! of strings in the searching criteria. It thren returns the matching ! messages threaded according to the specified threading algorithm. This is an \samp{IMAP4rev1} extension command. \versionadded{2.4} From tim_one at users.sourceforge.net Sat Jul 31 02:19:45 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sat Jul 31 02:19:49 2004 Subject: [Python-checkins] python/dist/src/Lib difflib.py,1.21,1.22 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25634/Lib Modified Files: difflib.py Log Message: Repair typo in docstring. Index: difflib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/difflib.py,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** difflib.py 10 Jul 2004 23:54:07 -0000 1.21 --- difflib.py 31 Jul 2004 00:19:43 -0000 1.22 *************** *** 601,605 **** Where T is the total number of elements in both sequences, and ! M is the number of matches, this is 2,0*M / T. Note that this is 1 if the sequences are identical, and 0 if they have nothing in common. --- 601,605 ---- Where T is the total number of elements in both sequences, and ! M is the number of matches, this is 2.0*M / T. Note that this is 1 if the sequences are identical, and 0 if they have nothing in common. From tim_one at users.sourceforge.net Sat Jul 31 04:24:22 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sat Jul 31 04:24:29 2004 Subject: [Python-checkins] python/dist/src/Objects listobject.c,2.215,2.216 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7074/Objects Modified Files: listobject.c Log Message: Armin asked for a list_ass_slice review in his checkin, so here's the result. list_resize(): Document the intent. Code is increasingly relying on subtle aspects of its behavior, and they deserve to be spelled out. list_ass_slice(): A bit more simplification, by giving it a common error exit and initializing more values. Be clearer in comments about what "size" means (# of elements? # of bytes?). While the number of elements in a list slice must fit in an int, there's no guarantee that the number of bytes occupied by the slice will. That malloc() and memmove() take size_t arguments is a hint about that . So changed to use size_t where appropriate. ihigh - ilow should always be >= 0, but we never asserted that. We do now. The loop decref'ing the recycled slice had a subtle insecurity: C doesn't guarantee that a pointer one slot *before* an array will compare "less than" to a pointer within the array (it does guarantee that a pointer one beyond the end of the array compares as expected). This was actually an issue in KSR's C implementation, so isn't purely theoretical. Python probably has other "go backwards" loops with a similar glitch. list_clear() is OK (it marches an integer backwards, not a pointer). Index: listobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/listobject.c,v retrieving revision 2.215 retrieving revision 2.216 diff -C2 -d -r2.215 -r2.216 *** listobject.c 30 Jul 2004 11:38:22 -0000 2.215 --- listobject.c 31 Jul 2004 02:24:20 -0000 2.216 *************** *** 9,12 **** --- 9,25 ---- #endif + /* Ensure ob_item has room for at least newsize elements, and set + * ob_size to newsize. If newsize > ob_size on entry, the content + * of the new slots at exit is undefined heap trash; it's the caller's + * responsiblity to overwrite them with sane values. + * The number of allocated elements may grow, shrink, or stay the same. + * Failure is impossible if newsize <= self.allocated on entry, although + * that partly relies on an assumption that the system realloc() never + * fails when passed a number of bytes <= the number of bytes last + * allocated (the C standard doesn't guarantee this, but it's hard to + * imagine a realloc implementation where it wouldn't be true). + * Note that self->ob_item may change, and even if newsize is less + * than ob_size on entry. + */ static int list_resize(PyListObject *self, int newsize) *************** *** 19,23 **** current size, then proceed with the realloc() to shrink the list. */ - if (self->allocated >= newsize && self->ob_size < newsize + 16) { assert(self->ob_item != NULL || newsize == 0); --- 32,35 ---- *************** *** 517,529 **** we temporarily copy the items that are deleted from the list. :-( */ - PyObject **recycle, **p; PyObject *recycled[8]; PyObject **item; PyObject **vitem = NULL; PyObject *v_as_SF = NULL; /* PySequence_Fast(v) */ ! int n; /* Size of replacement list */ int d; /* Change in size */ int k; /* Loop index */ ! int s; #define b ((PyListObject *)v) if (v == NULL) --- 529,543 ---- we temporarily copy the items that are deleted from the list. :-( */ PyObject *recycled[8]; + PyObject **recycle = recycled; /* will allocate more if needed */ PyObject **item; PyObject **vitem = NULL; PyObject *v_as_SF = NULL; /* PySequence_Fast(v) */ ! int n; /* # of elements in replacement list */ ! int norig; /* # of elements in list getting replaced */ int d; /* Change in size */ int k; /* Loop index */ ! size_t s; ! int result = -1; /* guilty until proved innocent */ #define b ((PyListObject *)v) if (v == NULL) *************** *** 532,546 **** if (a == b) { /* Special case "a[i:j] = a" -- copy b first */ - int ret; v = list_slice(b, 0, b->ob_size); if (v == NULL) ! return -1; ! ret = list_ass_slice(a, ilow, ihigh, v); Py_DECREF(v); ! return ret; } v_as_SF = PySequence_Fast(v, "can only assign an iterable"); if(v_as_SF == NULL) ! return -1; n = PySequence_Fast_GET_SIZE(v_as_SF); vitem = PySequence_Fast_ITEMS(v_as_SF); --- 546,559 ---- if (a == b) { /* Special case "a[i:j] = a" -- copy b first */ v = list_slice(b, 0, b->ob_size); if (v == NULL) ! return result; ! result = list_ass_slice(a, ilow, ihigh, v); Py_DECREF(v); ! return result; } v_as_SF = PySequence_Fast(v, "can only assign an iterable"); if(v_as_SF == NULL) ! goto Error; n = PySequence_Fast_GET_SIZE(v_as_SF); vitem = PySequence_Fast_ITEMS(v_as_SF); *************** *** 550,553 **** --- 563,567 ---- else if (ilow > a->ob_size) ilow = a->ob_size; + if (ihigh < ilow) ihigh = ilow; *************** *** 555,559 **** ihigh = a->ob_size; ! d = n - (ihigh-ilow); if (a->ob_size + d == 0) { Py_XDECREF(v_as_SF); --- 569,575 ---- ihigh = a->ob_size; ! norig = ihigh - ilow; ! assert(norig >= 0); ! d = n - norig; if (a->ob_size + d == 0) { Py_XDECREF(v_as_SF); *************** *** 561,578 **** } item = a->ob_item; ! /* recycle the ihigh-ilow items that we are about to remove */ ! s = (ihigh - ilow)*sizeof(PyObject *); if (s > sizeof(recycled)) { recycle = (PyObject **)PyMem_MALLOC(s); if (recycle == NULL) { PyErr_NoMemory(); ! Py_XDECREF(v_as_SF); ! return -1; } } - else - recycle = recycled; - p = recycle + (ihigh - ilow); memcpy(recycle, &item[ilow], s); if (d < 0) { /* Delete -d items */ memmove(&item[ihigh+d], &item[ihigh], --- 577,591 ---- } item = a->ob_item; ! /* recycle the items that we are about to remove */ ! s = norig * sizeof(PyObject *); if (s > sizeof(recycled)) { recycle = (PyObject **)PyMem_MALLOC(s); if (recycle == NULL) { PyErr_NoMemory(); ! goto Error; } } memcpy(recycle, &item[ilow], s); + if (d < 0) { /* Delete -d items */ memmove(&item[ihigh+d], &item[ihigh], *************** *** 583,592 **** else if (d > 0) { /* Insert d items */ s = a->ob_size; ! if (list_resize(a, s+d) == -1) { ! if (recycle != recycled) ! PyMem_FREE(recycle); ! Py_XDECREF(v_as_SF); ! return -1; ! } item = a->ob_item; memmove(&item[ihigh+d], &item[ihigh], --- 596,601 ---- else if (d > 0) { /* Insert d items */ s = a->ob_size; ! if (list_resize(a, s+d) < 0) ! goto Error; item = a->ob_item; memmove(&item[ihigh+d], &item[ihigh], *************** *** 598,607 **** item[ilow] = w; } ! while (--p >= recycle) ! Py_XDECREF(*p); if (recycle != recycled) PyMem_FREE(recycle); Py_XDECREF(v_as_SF); ! return 0; #undef b } --- 607,625 ---- item[ilow] = w; } ! /* Convoluted: there's some obscure reason for wanting to do ! * the decrefs "backwards", but C doesn't guarantee you can compute ! * a pointer to one slot *before* an allocated vector. So checking ! * for item >= recycle is incorrect. ! */ ! for (item = recycle + norig; item > recycle; ) { ! --item; ! Py_XDECREF(*item); ! } ! result = 0; ! Error: if (recycle != recycled) PyMem_FREE(recycle); Py_XDECREF(v_as_SF); ! return result; #undef b } From tim_one at users.sourceforge.net Sat Jul 31 04:54:44 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sat Jul 31 04:54:47 2004 Subject: [Python-checkins] python/dist/src/Objects listobject.c,2.216,2.217 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11098/Objects Modified Files: listobject.c Log Message: list_ass_slice(): The difference between "recycle" and "recycled" was impossible to remember, so renamed one to something obvious. Headed off potential signed-vs-unsigned compiler complaints I introduced by changing the type of a vrbl to unsigned. Removed the need for the tedious explanation about "backward pointer loops" by looping on an int instead. Index: listobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/listobject.c,v retrieving revision 2.216 retrieving revision 2.217 diff -C2 -d -r2.216 -r2.217 *** listobject.c 31 Jul 2004 02:24:20 -0000 2.216 --- listobject.c 31 Jul 2004 02:54:42 -0000 2.217 *************** *** 529,534 **** we temporarily copy the items that are deleted from the list. :-( */ ! PyObject *recycled[8]; ! PyObject **recycle = recycled; /* will allocate more if needed */ PyObject **item; PyObject **vitem = NULL; --- 529,534 ---- we temporarily copy the items that are deleted from the list. :-( */ ! PyObject *recycle_on_stack[8]; ! PyObject **recycle = recycle_on_stack; /* will allocate more if needed */ PyObject **item; PyObject **vitem = NULL; *************** *** 537,541 **** int norig; /* # of elements in list getting replaced */ int d; /* Change in size */ ! int k; /* Loop index */ size_t s; int result = -1; /* guilty until proved innocent */ --- 537,541 ---- int norig; /* # of elements in list getting replaced */ int d; /* Change in size */ ! int k; size_t s; int result = -1; /* guilty until proved innocent */ *************** *** 579,583 **** /* recycle the items that we are about to remove */ s = norig * sizeof(PyObject *); ! if (s > sizeof(recycled)) { recycle = (PyObject **)PyMem_MALLOC(s); if (recycle == NULL) { --- 579,583 ---- /* recycle the items that we are about to remove */ s = norig * sizeof(PyObject *); ! if (s > sizeof(recycle_on_stack)) { recycle = (PyObject **)PyMem_MALLOC(s); if (recycle == NULL) { *************** *** 595,604 **** } else if (d > 0) { /* Insert d items */ ! s = a->ob_size; ! if (list_resize(a, s+d) < 0) goto Error; item = a->ob_item; memmove(&item[ihigh+d], &item[ihigh], ! (s - ihigh)*sizeof(PyObject *)); } for (k = 0; k < n; k++, ilow++) { --- 595,604 ---- } else if (d > 0) { /* Insert d items */ ! k = a->ob_size; ! if (list_resize(a, k+d) < 0) goto Error; item = a->ob_item; memmove(&item[ihigh+d], &item[ihigh], ! (k - ihigh)*sizeof(PyObject *)); } for (k = 0; k < n; k++, ilow++) { *************** *** 607,622 **** item[ilow] = w; } ! /* Convoluted: there's some obscure reason for wanting to do ! * the decrefs "backwards", but C doesn't guarantee you can compute ! * a pointer to one slot *before* an allocated vector. So checking ! * for item >= recycle is incorrect. ! */ ! for (item = recycle + norig; item > recycle; ) { ! --item; ! Py_XDECREF(*item); ! } result = 0; Error: ! if (recycle != recycled) PyMem_FREE(recycle); Py_XDECREF(v_as_SF); --- 607,615 ---- item[ilow] = w; } ! for (k = norig - 1; k >= 0; --k) ! Py_XDECREF(recycle[k]); result = 0; Error: ! if (recycle != recycle_on_stack) PyMem_FREE(recycle); Py_XDECREF(v_as_SF); From judikendrick at egpo.net Sat Jul 31 07:46:37 2004 From: judikendrick at egpo.net (renaldo bogle) Date: Sat Jul 31 10:01:46 2004 Subject: [Python-checkins] be yo`ung again Message-ID: <741801c476c1$bf0c8150$eec18428@judikendrick> bemisaal'bdeswilldagutsys terpree~ u`'s^a dr--u.,gs & n,e`_xtday sh^^ipp^~ing~ _ euc-jmakati http://kcr.hjk.sarcoma9511pi11.us/f74/ The letters 'G' and 'W' -----Original Message----- From: Delana Ellis [mailto:mw@aotd.com] To: jerald bergen; raymon youngblut; marshall maki Sent: Monday, February, 2004 9:56 PM Subject: be yo'ung again madhatter,sgijpeg~ We'll try it, anyway, said the Wizard Good-by! Good-by! repeated Rob, and in a gorgeous flash of color the Demon disappeared, leaving the boy alone in the room with his new and wonderful possessions how many times must a man look up aburrado10antelucana52aca\averear,ara`cnido desde\osa. From gward at users.sourceforge.net Sat Jul 31 18:15:47 2004 From: gward at users.sourceforge.net (gward@users.sourceforge.net) Date: Sat Jul 31 18:15:50 2004 Subject: [Python-checkins] python/dist/src/Lib optparse.py,1.8,1.9 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14464/Lib Modified Files: optparse.py Log Message: Upgrade optparse module and tests to Optik 1.5a1: * add expansion of default values in help text: the string "%default" in an option's help string is expanded to str() of that option's default value, or "none" if no default value. * bug #955889: option default values that happen to be strings are now processed in the same way as values from the command line; this allows generation of nicer help when using custom types. Can be disabled with parser.set_process_default_values(False). * bug #960515: don't crash when generating help for callback options that specify 'type', but not 'dest' or 'metavar'. * feature #815264: change the default help format for short options that take an argument from e.g. "-oARG" to "-o ARG"; add set_short_opt_delimiter() and set_long_opt_delimiter() methods to HelpFormatter to allow (slight) customization of the formatting. * patch #736940: internationalize Optik: all built-in user- targeted literal strings are passed through gettext.gettext(). (If you want translations (.po files), they're not included with Python -- you'll find them in the Optik source distribution from http://optik.sourceforge.net/ .) * bug #878453: respect $COLUMNS environment variable for wrapping help output. * feature #988122: expand "%prog" in the 'description' passed to OptionParser, just like in the 'usage' and 'version' strings. (This is *not* done in the 'description' passed to OptionGroup.) Index: optparse.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/optparse.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** optparse.py 1 Apr 2004 07:40:35 -0000 1.8 --- optparse.py 31 Jul 2004 16:15:44 -0000 1.9 *************** *** 17,27 **** # it is automatically generated from the Optik source code. ! __version__ = "1.4.1+" __all__ = ['Option', 'SUPPRESS_HELP', 'SUPPRESS_USAGE', - 'STD_HELP_OPTION', - 'STD_VERSION_OPTION', 'Values', [...1652 lines suppressed...] *************** *** 1391,1398 **** return possibilities[0] elif not possibilities: ! raise BadOptionError("no such option: %s" % s) else: # More than one possible completion: ambiguous prefix. ! raise BadOptionError("ambiguous option: %s (%s?)" % (s, ", ".join(possibilities))) --- 1549,1556 ---- return possibilities[0] elif not possibilities: ! raise BadOptionError(_("no such option: %s") % s) else: # More than one possible completion: ambiguous prefix. ! raise BadOptionError(_("ambiguous option: %s (%s?)") % (s, ", ".join(possibilities))) From gward at users.sourceforge.net Sat Jul 31 18:15:47 2004 From: gward at users.sourceforge.net (gward@users.sourceforge.net) Date: Sat Jul 31 18:15:54 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_optparse.py, 1.3, 1.4 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14464/Lib/test Modified Files: test_optparse.py Log Message: Upgrade optparse module and tests to Optik 1.5a1: * add expansion of default values in help text: the string "%default" in an option's help string is expanded to str() of that option's default value, or "none" if no default value. * bug #955889: option default values that happen to be strings are now processed in the same way as values from the command line; this allows generation of nicer help when using custom types. Can be disabled with parser.set_process_default_values(False). * bug #960515: don't crash when generating help for callback options that specify 'type', but not 'dest' or 'metavar'. * feature #815264: change the default help format for short options that take an argument from e.g. "-oARG" to "-o ARG"; add set_short_opt_delimiter() and set_long_opt_delimiter() methods to HelpFormatter to allow (slight) customization of the formatting. * patch #736940: internationalize Optik: all built-in user- targeted literal strings are passed through gettext.gettext(). (If you want translations (.po files), they're not included with Python -- you'll find them in the Optik source distribution from http://optik.sourceforge.net/ .) * bug #878453: respect $COLUMNS environment variable for wrapping help output. * feature #988122: expand "%prog" in the 'description' passed to OptionParser, just like in the 'usage' and 'version' strings. (This is *not* done in the 'description' passed to OptionGroup.) Index: test_optparse.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_optparse.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** test_optparse.py 1 Apr 2004 07:40:35 -0000 1.3 --- test_optparse.py 31 Jul 2004 16:15:44 -0000 1.4 *************** *** 21,32 **** TitledHelpFormatter, OptionParser, OptionContainer, OptionGroup, \ SUPPRESS_HELP, SUPPRESS_USAGE, OptionError, OptionConflictError, \ ! BadOptionError, OptionValueError ! from optparse import _match_abbrev ! ! # Do the right thing with boolean values for all known Python versions. ! try: ! True, False ! except NameError: ! (True, False) = (1, 0) class BaseTest(unittest.TestCase): --- 21,25 ---- TitledHelpFormatter, OptionParser, OptionContainer, OptionGroup, \ SUPPRESS_HELP, SUPPRESS_USAGE, OptionError, OptionConflictError, \ ! BadOptionError, OptionValueError, _match_abbrev class BaseTest(unittest.TestCase): *************** *** 61,108 **** return (options, positional_args) ! def assertRaises(self, func, expected_exception, expected_output, ! get_output=None, ! funcargs=[], funckwargs={}): """Assert the expected exception is raised when calling a function. Also check whether the right error message is given for a given error. ! Keyword arguments: ! func -- The function to be called. ! expected_exception -- The exception that should be raised. ! expected_output -- The output we expect to see. ! get_output -- The function to call to get the output. ! funcargs -- The arguments `func` should be called with. ! funckwargs -- The keyword arguments `func` should be called with. Returns the exception raised for further testing. """ if get_output is None: get_output = self.exception try: ! out = func(*funcargs, **funckwargs) except expected_exception, err: ! output = get_output(err) ! self.failUnless(output.find(expected_output) != -1, ! """ ! Message was: ! %(output)s ! Should contain: ! %(expected_output)s ! Function called: ! %(func)s ! With args/kwargs: ! %(funcargs)s/%(funckwargs)s""" % locals()) return err else: ! self.fail(""" ! No %(expected_exception)s raised. ! Function called: ! %(func)s ! With args/kwargs: ! %(funcargs)s/%(funckwargs)s""" % locals ()) # -- Functions to be used as the get_output argument to assertRaises ------ --- 54,113 ---- return (options, positional_args) ! def assertRaises(self, ! func, ! args, ! kwargs, ! expected_exception, ! expected_output, ! get_output=None, ! exact_match=False): """Assert the expected exception is raised when calling a function. Also check whether the right error message is given for a given error. ! Arguments: ! func -- the function to call ! args -- positional arguments to `func` ! kwargs -- keyword arguments to `func` ! expected_exception -- exception that should be raised ! expected_output -- output we expect to see ! get_output -- function to call to get the output ! exact_match -- whether output must exactly match expected output, ! or merely contain it Returns the exception raised for further testing. """ + if args is None: + args = () + if kwargs is None: + kwargs = {} if get_output is None: get_output = self.exception try: ! out = func(*args, **kwargs) except expected_exception, err: ! actual_output = get_output(err) ! if exact_match: ! match = actual_output == expected_exception ! else: ! match = actual_output.find(expected_output) != -1 ! ! self.assert_(match, ! """mismatched output ! expected output: ! '''%(expected_output)s''' ! actual output: ! '''%(actual_output)s''' ! """ % locals()) return err else: ! self.fail("""expected exception %(expected_exception)s not raised ! called %(func)r ! with args %(args)r ! and kwargs %(kwargs)r ! """ % locals ()) # -- Functions to be used as the get_output argument to assertRaises ------ *************** *** 114,134 **** return sys.stdout.getvalue() # -- Assertions used in more than one class -------------------- def assertParseFail(self, cmdline_args, expected_output): """Assert the parser fails with the expected message.""" ! self.assertRaises(self.parser.parse_args, SystemExit, expected_output, ! funcargs=[cmdline_args]) def assertStdoutEquals(self, cmdline_args, expected_output): """Assert the parser prints the expected output on stdout.""" sys.stdout = StringIO() ! self.assertRaises(self.parser.parse_args, SystemExit, expected_output, ! self.redirected_stdout, [cmdline_args]) sys.stdout = sys.__stdout__ def assertTypeError(self, func, expected_output, *args): """Assert a TypeError is raised when executing func.""" ! self.assertRaises(func, TypeError, expected_output, funcargs=args) # -- Test make_option() aka Option ------------------------------------- --- 119,154 ---- return sys.stdout.getvalue() + def redirected_stderr(self, err): + return sys.stderr.getvalue() + # -- Assertions used in more than one class -------------------- def assertParseFail(self, cmdline_args, expected_output): """Assert the parser fails with the expected message.""" ! sys.stderr = StringIO() ! self.assertRaises(self.parser.parse_args, (cmdline_args,), None, ! SystemExit, expected_output, ! self.redirected_stderr) ! sys.stderr = sys.__stderr__ def assertStdoutEquals(self, cmdline_args, expected_output): """Assert the parser prints the expected output on stdout.""" sys.stdout = StringIO() ! self.assertRaises(self.parser.parse_args, (cmdline_args,), None, ! SystemExit, expected_output, ! self.redirected_stdout) sys.stdout = sys.__stdout__ def assertTypeError(self, func, expected_output, *args): """Assert a TypeError is raised when executing func.""" ! self.assertRaises(func, args, None, TypeError, expected_output) ! ! def assertHelp(self, parser, expected_help): ! actual_help = parser.format_help() ! if actual_help != expected_help: ! raise self.failureException( ! 'help text failure; expected:\n"' + ! expected_help + '"; got:\n"' + ! actual_help + '"\n') # -- Test make_option() aka Option ------------------------------------- *************** *** 143,148 **** def assertOptionError(self, expected_output, args=[], kwargs={}): ! self.assertRaises(make_option, OptionError, expected_output, ! funcargs=args, funckwargs=kwargs) def test_opt_string_empty(self): --- 163,168 ---- def assertOptionError(self, expected_output, args=[], kwargs={}): ! self.assertRaises(make_option, args, kwargs, ! OptionError, expected_output) def test_opt_string_empty(self): *************** *** 176,179 **** --- 196,201 ---- self.assertOptionError("invalid option type: 'foo'", ["-b"], {'type': 'foo'}) + self.assertOptionError("invalid option type: 'tuple'", + ["-b"], {'type': tuple}) def test_no_type_for_action(self): *************** *** 305,310 **** def test_remove_nonexistent(self): ! self.assertRaises(self.parser.remove_option, ValueError, ! "no such option 'foo'", funcargs=['foo']) # -- Test parser.parse_args() ------------------------------------------ --- 327,528 ---- def test_remove_nonexistent(self): ! self.assertRaises(self.parser.remove_option, ('foo',), None, ! ValueError, "no such option 'foo'") ! ! class TestTypeAliases(BaseTest): ! def setUp(self): ! self.parser = OptionParser() ! ! def test_type_aliases(self): ! self.parser.add_option("-x", type=int) ! self.parser.add_option("-s", type=str) ! self.parser.add_option("-t", type="str") ! self.assertEquals(self.parser.get_option("-x").type, "int") ! self.assertEquals(self.parser.get_option("-s").type, "string") ! self.assertEquals(self.parser.get_option("-t").type, "string") ! ! ! # Custom type for testing processing of default values. ! _time_units = { 's' : 1, 'm' : 60, 'h' : 60*60, 'd' : 60*60*24 } ! ! def _check_duration(option, opt, value): ! try: ! if value[-1].isdigit(): ! return int(value) ! else: ! return int(value[:-1]) * _time_units[value[-1]] ! except ValueError, IndexError: ! raise OptionValueError( ! 'option %s: invalid duration: %r' % (opt, value)) ! ! class DurationOption(Option): ! TYPES = Option.TYPES + ('duration',) ! TYPE_CHECKER = copy.copy(Option.TYPE_CHECKER) ! TYPE_CHECKER['duration'] = _check_duration ! ! class TestDefaultValues(BaseTest): ! def setUp(self): ! self.parser = OptionParser() ! self.parser.add_option("-v", "--verbose", default=True) ! self.parser.add_option("-q", "--quiet", dest='verbose') ! self.parser.add_option("-n", type="int", default=37) ! self.parser.add_option("-m", type="int") ! self.parser.add_option("-s", default="foo") ! self.parser.add_option("-t") ! self.parser.add_option("-u", default=None) ! self.expected = { 'verbose': True, ! 'n': 37, ! 'm': None, ! 's': "foo", ! 't': None, ! 'u': None } ! ! def test_basic_defaults(self): ! self.assertEqual(self.parser.get_default_values(), self.expected) ! ! def test_mixed_defaults_post(self): ! self.parser.set_defaults(n=42, m=-100) ! self.expected.update({'n': 42, 'm': -100}) ! self.assertEqual(self.parser.get_default_values(), self.expected) ! ! def test_mixed_defaults_pre(self): ! self.parser.set_defaults(x="barf", y="blah") ! self.parser.add_option("-x", default="frob") ! self.parser.add_option("-y") ! ! self.expected.update({'x': "frob", 'y': "blah"}) ! self.assertEqual(self.parser.get_default_values(), self.expected) ! ! self.parser.remove_option("-y") ! self.parser.add_option("-y", default=None) ! self.expected.update({'y': None}) ! self.assertEqual(self.parser.get_default_values(), self.expected) ! ! def test_process_default(self): ! self.parser.option_class = DurationOption ! self.parser.add_option("-d", type="duration", default=300) ! self.parser.add_option("-e", type="duration", default="6m") ! self.parser.set_defaults(n="42") ! self.expected.update({'d': 300, 'e': 360, 'n': 42}) ! self.assertEqual(self.parser.get_default_values(), self.expected) ! ! self.parser.set_process_default_values(False) ! self.expected.update({'d': 300, 'e': "6m", 'n': "42"}) ! self.assertEqual(self.parser.get_default_values(), self.expected) ! ! ! class TestProgName(BaseTest): ! """ ! Test that %prog expands to the right thing in usage, version, ! and help strings. ! """ ! ! def assertUsage(self, parser, expected_usage): ! self.assertEqual(parser.get_usage(), expected_usage) ! ! def assertVersion(self, parser, expected_version): ! self.assertEqual(parser.get_version(), expected_version) ! ! ! def test_default_progname(self): ! # Make sure that program name taken from sys.argv[0] by default. ! sys.argv[0] = "/foo/bar/baz.py" ! parser = OptionParser("usage: %prog ...", version="%prog 1.2") ! expected_usage = "usage: baz.py ...\n" ! self.assertUsage(parser, expected_usage) ! self.assertVersion(parser, "baz.py 1.2") ! self.assertHelp(parser, ! expected_usage + "\n" + ! "options:\n" ! " --version show program's version number and exit\n" ! " -h, --help show this help message and exit\n") ! ! def test_custom_progname(self): ! parser = OptionParser(prog="thingy", ! version="%prog 0.1", ! usage="%prog arg arg") ! parser.remove_option("-h") ! parser.remove_option("--version") ! expected_usage = "usage: thingy arg arg\n" ! self.assertUsage(parser, expected_usage) ! self.assertVersion(parser, "thingy 0.1") ! self.assertHelp(parser, expected_usage + "\n") ! ! ! class TestExpandDefaults(BaseTest): ! def setUp(self): ! self.parser = OptionParser(prog="test") ! self.help_prefix = """\ ! usage: test [options] ! ! options: ! -h, --help show this help message and exit ! """ ! self.file_help = "read from FILE [default: %default]" ! self.expected_help_file = self.help_prefix + \ ! " -f FILE, --file=FILE read from FILE [default: foo.txt]\n" ! self.expected_help_none = self.help_prefix + \ ! " -f FILE, --file=FILE read from FILE [default: none]\n" ! ! def test_option_default(self): ! self.parser.add_option("-f", "--file", ! default="foo.txt", ! help=self.file_help) ! self.assertHelp(self.parser, self.expected_help_file) ! ! def test_parser_default_1(self): ! self.parser.add_option("-f", "--file", ! help=self.file_help) ! self.parser.set_default('file', "foo.txt") ! self.assertHelp(self.parser, self.expected_help_file) ! ! def test_parser_default_2(self): ! self.parser.add_option("-f", "--file", ! help=self.file_help) ! self.parser.set_defaults(file="foo.txt") ! self.assertHelp(self.parser, self.expected_help_file) ! ! def test_no_default(self): ! self.parser.add_option("-f", "--file", ! help=self.file_help) ! self.assertHelp(self.parser, self.expected_help_none) ! ! def test_default_none_1(self): ! self.parser.add_option("-f", "--file", ! default=None, ! help=self.file_help) ! self.assertHelp(self.parser, self.expected_help_none) ! ! def test_default_none_2(self): ! self.parser.add_option("-f", "--file", ! help=self.file_help) ! self.parser.set_defaults(file=None) ! self.assertHelp(self.parser, self.expected_help_none) ! ! def test_float_default(self): ! self.parser.add_option( ! "-p", "--prob", ! help="blow up with probability PROB [default: %default]") ! self.parser.set_defaults(prob=0.43) ! expected_help = self.help_prefix + \ ! " -p PROB, --prob=PROB blow up with probability PROB [default: 0.43]\n" ! self.assertHelp(self.parser, expected_help) ! ! def test_alt_expand(self): ! self.parser.add_option("-f", "--file", ! default="foo.txt", ! help="read from FILE [default: *DEFAULT*]") ! self.parser.formatter.default_tag = "*DEFAULT*" ! self.assertHelp(self.parser, self.expected_help_file) ! ! def test_no_expand(self): ! self.parser.add_option("-f", "--file", ! default="foo.txt", ! help="read from %default file") ! self.parser.formatter.default_tag = None ! expected_help = self.help_prefix + \ ! " -f FILE, --file=FILE read from %default file\n" ! self.assertHelp(self.parser, expected_help) ! # -- Test parser.parse_args() ------------------------------------------ *************** *** 319,323 **** def test_required_value(self): ! self.assertParseFail(["-a"], "-a option requires a value") def test_invalid_integer(self): --- 537,541 ---- def test_required_value(self): ! self.assertParseFail(["-a"], "-a option requires an argument") def test_invalid_integer(self): *************** *** 581,585 **** def test_nargs_required_values(self): self.assertParseFail(["--point", "1.0", "3.5"], ! "--point option requires 3 values") class TestNArgsAppend(BaseTest): --- 799,803 ---- def test_nargs_required_values(self): self.assertParseFail(["--point", "1.0", "3.5"], ! "--point option requires 3 arguments") class TestNArgsAppend(BaseTest): *************** *** 598,602 **** def test_nargs_append_required_values(self): self.assertParseFail(["-f4,3"], ! "-f option requires 2 values") def test_nargs_append_simple(self): --- 816,820 ---- def test_nargs_append_required_values(self): self.assertParseFail(["-f4,3"], ! "-f option requires 2 arguments") def test_nargs_append_simple(self): *************** *** 613,632 **** sys.argv[0] = oldargv - def test_version_with_prog_keyword(self): - oldargv = sys.argv[0] - sys.argv[0] = "./foo/bar" - self.parser = OptionParser(usage=SUPPRESS_USAGE, version="%prog 0.1", - prog="splat") - self.assertStdoutEquals(["--version"], "splat 0.1\n") - sys.argv[0] = oldargv - - def test_version_with_prog_attribute(self): - oldargv = sys.argv[0] - sys.argv[0] = "./foo/bar" - self.parser = OptionParser(usage=SUPPRESS_USAGE, version="%prog 0.1") - self.parser.prog = "splat" - self.assertStdoutEquals(["--version"], "splat 0.1\n") - sys.argv[0] = oldargv - def test_no_version(self): self.parser = OptionParser(usage=SUPPRESS_USAGE) --- 831,834 ---- *************** *** 674,679 **** group = OptionGroup(self.parser, "Spam") group.parser = OptionParser() ! self.assertRaises(self.parser.add_option_group, ValueError, ! "invalid OptionGroup (wrong parser)", funcargs=[group]) def test_group_manipulate(self): --- 876,881 ---- group = OptionGroup(self.parser, "Spam") group.parser = OptionParser() ! self.assertRaises(self.parser.add_option_group, (group,), None, ! ValueError, "invalid OptionGroup (wrong parser)") def test_group_manipulate(self): *************** *** 795,799 **** []) ! class TestCallBackExtraArgs(BaseTest): def setUp(self): options = [make_option("-p", "--point", action="callback", --- 997,1016 ---- []) ! def test_callback_help(self): ! # This test was prompted by SF bug #960515 -- the point is ! # not to inspect the help text, just to make sure that ! # format_help() doesn't crash. ! parser = OptionParser(usage=SUPPRESS_USAGE) ! parser.remove_option("-h") ! parser.add_option("-t", "--test", action="callback", ! callback=lambda: None, type="string", ! help="foo") ! ! expected_help = ("options:\n" ! " -t TEST, --test=TEST foo\n") ! self.assertHelp(parser, expected_help) ! ! ! class TestCallbackExtraArgs(BaseTest): def setUp(self): options = [make_option("-p", "--point", action="callback", *************** *** 820,824 **** []) ! class TestCallBackMeddleArgs(BaseTest): def setUp(self): options = [make_option(str(x), action="callback", --- 1037,1041 ---- []) ! class TestCallbackMeddleArgs(BaseTest): def setUp(self): options = [make_option(str(x), action="callback", *************** *** 849,853 **** [2]) ! class TestCallBackManyArgs(BaseTest): def setUp(self): options = [make_option("-a", "--apple", action="callback", nargs=2, --- 1066,1070 ---- [2]) ! class TestCallbackManyArgs(BaseTest): def setUp(self): options = [make_option("-a", "--apple", action="callback", nargs=2, *************** *** 871,878 **** "-b", "1", "2", "3", "--bob", "-666", "42", "0"], ! {}, []) ! class TestCallBackCheckAbbrev(BaseTest): def setUp(self): self.parser = OptionParser() --- 1088,1095 ---- "-b", "1", "2", "3", "--bob", "-666", "42", "0"], ! {"apple": None, "bob": None}, []) ! class TestCallbackCheckAbbrev(BaseTest): def setUp(self): self.parser = OptionParser() *************** *** 886,890 **** self.assertParseOK(["--foo"], {}, []) ! class TestCallBackVarArgs(BaseTest): def setUp(self): options = [make_option("-a", type="int", nargs=2, dest="a"), --- 1103,1107 ---- self.assertParseOK(["--foo"], {}, []) ! class TestCallbackVarArgs(BaseTest): def setUp(self): options = [make_option("-a", type="int", nargs=2, dest="a"), *************** *** 951,961 **** """Use the default conflict resolution for Optik 1.2: error.""" def assert_conflict_error(self, func): ! err = self.assertRaises(func, OptionConflictError, ! "option -v/--version: conflicting option " ! "string(s): -v", ! funcargs=["-v", "--version"], ! funckwargs={'action':"callback", ! 'callback':self.show_version, ! 'help':"show version"}) self.assertEqual(err.msg, "conflicting option string(s): -v") --- 1168,1177 ---- """Use the default conflict resolution for Optik 1.2: error.""" def assert_conflict_error(self, func): ! err = self.assertRaises( ! func, ("-v", "--version"), {'action' : "callback", ! 'callback' : self.show_version, ! 'help' : "show version"}, ! OptionConflictError, ! "option -v/--version: conflicting option string(s): -v") self.assertEqual(err.msg, "conflicting option string(s): -v") *************** *** 970,976 **** def test_no_such_conflict_handler(self): ! self.assertRaises(self.parser.set_conflict_handler, ValueError, ! "invalid conflict_resolution value 'foo'", ! funcargs=['foo']) --- 1186,1192 ---- def test_no_such_conflict_handler(self): ! self.assertRaises( ! self.parser.set_conflict_handler, ('foo',), None, ! ValueError, "invalid conflict_resolution value 'foo'") *************** *** 1083,1088 **** --- 1299,1356 ---- # -- Other testing. ---------------------------------------------------- + _expected_help_basic = """\ + usage: bar.py [options] + + options: + -a APPLE throw APPLEs at basket + -b NUM, --boo=NUM shout "boo!" NUM times (in order to frighten away all the + evil spirits that cause trouble and mayhem) + --foo=FOO store FOO in the foo list for later fooing + -h, --help show this help message and exit + """ + + _expected_help_long_opts_first = """\ + usage: bar.py [options] + + options: + -a APPLE throw APPLEs at basket + --boo=NUM, -b NUM shout "boo!" NUM times (in order to frighten away all the + evil spirits that cause trouble and mayhem) + --foo=FOO store FOO in the foo list for later fooing + --help, -h show this help message and exit + """ + + _expected_help_title_formatter = """\ + Usage + ===== + bar.py [options] + + options + ======= + -a APPLE throw APPLEs at basket + --boo=NUM, -b NUM shout "boo!" NUM times (in order to frighten away all the + evil spirits that cause trouble and mayhem) + --foo=FOO store FOO in the foo list for later fooing + --help, -h show this help message and exit + """ + + _expected_help_short_lines = """\ + usage: bar.py [options] + + options: + -a APPLE throw APPLEs at basket + -b NUM, --boo=NUM shout "boo!" NUM times (in order to + frighten away all the evil spirits + that cause trouble and mayhem) + --foo=FOO store FOO in the foo list for later + fooing + -h, --help show this help message and exit + """ + class TestHelp(BaseTest): def setUp(self): + self.parser = self.make_parser(80) + + def make_parser(self, columns): options = [ make_option("-a", type="string", dest='a', *************** *** 1096,1102 **** help="store FOO in the foo list for later fooing"), ] ! ! usage = "%prog [options]" ! self.parser = OptionParser(usage=usage, option_list=options) def assertHelpEquals(self, expected_output): --- 1364,1369 ---- help="store FOO in the foo list for later fooing"), ] ! os.environ['COLUMNS'] = str(columns) ! return OptionParser(option_list=options) def assertHelpEquals(self, expected_output): *************** *** 1110,1169 **** def test_help(self): ! self.assertHelpEquals("""\ ! usage: bar.py [options] ! ! options: ! -aAPPLE throw APPLEs at basket ! -bNUM, --boo=NUM shout "boo!" NUM times (in order to frighten away all ! the evil spirits that cause trouble and mayhem) ! --foo=FOO store FOO in the foo list for later fooing ! -h, --help show this help message and exit ! """) def test_help_old_usage(self): self.parser.set_usage("usage: %prog [options]") ! self.assertHelpEquals("""\ ! usage: bar.py [options] ! ! options: ! -aAPPLE throw APPLEs at basket ! -bNUM, --boo=NUM shout "boo!" NUM times (in order to frighten away all ! the evil spirits that cause trouble and mayhem) ! --foo=FOO store FOO in the foo list for later fooing ! -h, --help show this help message and exit ! """) def test_help_long_opts_first(self): self.parser.formatter.short_first = 0 ! self.assertHelpEquals("""\ ! usage: bar.py [options] ! ! options: ! -aAPPLE throw APPLEs at basket ! --boo=NUM, -bNUM shout "boo!" NUM times (in order to frighten away all ! the evil spirits that cause trouble and mayhem) ! --foo=FOO store FOO in the foo list for later fooing ! --help, -h show this help message and exit ! """) def test_help_title_formatter(self): self.parser.formatter = TitledHelpFormatter() ! self.assertHelpEquals("""\ ! Usage ! ===== ! bar.py [options] ! options ! ======= ! -aAPPLE throw APPLEs at basket ! --boo=NUM, -bNUM shout "boo!" NUM times (in order to frighten away all ! the evil spirits that cause trouble and mayhem) ! --foo=FOO store FOO in the foo list for later fooing ! --help, -h show this help message and exit ! """) def test_help_description_groups(self): self.parser.set_description( ! "This is the program description. This program has " "an option group as well as single options.") --- 1377,1404 ---- def test_help(self): ! self.assertHelpEquals(_expected_help_basic) def test_help_old_usage(self): self.parser.set_usage("usage: %prog [options]") ! self.assertHelpEquals(_expected_help_basic) def test_help_long_opts_first(self): self.parser.formatter.short_first = 0 ! self.assertHelpEquals(_expected_help_long_opts_first) def test_help_title_formatter(self): self.parser.formatter = TitledHelpFormatter() ! self.assertHelpEquals(_expected_help_title_formatter) ! def test_wrap_columns(self): ! # Ensure that wrapping respects $COLUMNS environment variable. ! # Need to reconstruct the parser, since that's the only time ! # we look at $COLUMNS. ! self.parser = self.make_parser(60) ! self.assertHelpEquals(_expected_help_short_lines) def test_help_description_groups(self): self.parser.set_description( ! "This is the program description for %prog. %prog has " "an option group as well as single options.") *************** *** 1178,1196 **** usage: bar.py [options] ! This is the program description. This program has an option group as well as ! single options. options: ! -aAPPLE throw APPLEs at basket ! -bNUM, --boo=NUM shout "boo!" NUM times (in order to frighten away all ! the evil spirits that cause trouble and mayhem) ! --foo=FOO store FOO in the foo list for later fooing ! -h, --help show this help message and exit Dangerous Options: ! Caution: use of these options is at your own risk. It is believed that ! some of them bite. ! -g Group option. """) class TestMatchAbbrev(BaseTest): def test_match_abbrev(self): --- 1413,1436 ---- usage: bar.py [options] ! This is the program description for bar.py. bar.py has an option group as ! well as single options. ! options: ! -a APPLE throw APPLEs at basket ! -b NUM, --boo=NUM shout "boo!" NUM times (in order to frighten away all the ! evil spirits that cause trouble and mayhem) ! --foo=FOO store FOO in the foo list for later fooing ! -h, --help show this help message and exit Dangerous Options: ! Caution: use of these options is at your own risk. It is believed ! that some of them bite. ! ! -g Group option. """) + + + class TestMatchAbbrev(BaseTest): def test_match_abbrev(self): *************** *** 1206,1218 **** wordmap = {"--foz": None, "--foo": None, "--fie": None} possibilities = ", ".join(wordmap.keys()) ! self.assertRaises(_match_abbrev, BadOptionError, ! "ambiguous option: --f (%s?)" % possibilities, ! funcargs=[s, wordmap]) ! def test_main(): mod = sys.modules[__name__] ! test_support.run_unittest( ! *[getattr(mod, name) for name in dir(mod) if name.startswith('Test')] ! ) if __name__ == '__main__': --- 1446,1466 ---- wordmap = {"--foz": None, "--foo": None, "--fie": None} possibilities = ", ".join(wordmap.keys()) ! self.assertRaises( ! _match_abbrev, (s, wordmap), None, ! BadOptionError, "ambiguous option: --f (%s?)" % possibilities) ! ! def _testclasses(): mod = sys.modules[__name__] ! return [getattr(mod, name) for name in dir(mod) if name.startswith('Test')] ! ! def suite(): ! suite = unittest.TestSuite() ! for testclass in _testclasses(): ! suite.addTest(unittest.makeSuite(testclass)) ! return suite ! ! def test_main(): ! test_support.run_suite(suite()) if __name__ == '__main__': From gward at users.sourceforge.net Sat Jul 31 18:16:17 2004 From: gward at users.sourceforge.net (gward@users.sourceforge.net) Date: Sat Jul 31 18:16:19 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1057,1.1058 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14612/Misc Modified Files: NEWS Log Message: Mention upgrade of optparse to Optik 1.5a1. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1057 retrieving revision 1.1058 diff -C2 -d -r1.1057 -r1.1058 *** NEWS 27 Jul 2004 21:02:02 -0000 1.1057 --- NEWS 31 Jul 2004 16:16:11 -0000 1.1058 *************** *** 135,138 **** --- 135,169 ---- as informed by locale module's getpreferredencoding(). + - optparse module (and tests) upgraded to Optik 1.5a1. Changes: + + - Add expansion of default values in help text: the string + "%default" in an option's help string is expanded to str() of + that option's default value, or "none" if no default value. + + - Bug #955889: option default values that happen to be strings are + now processed in the same way as values from the command line; this + allows generation of nicer help when using custom types. Can + be disabled with parser.set_process_default_values(False). + + - Bug #960515: don't crash when generating help for callback + options that specify 'type', but not 'dest' or 'metavar'. + + - Feature #815264: change the default help format for short options + that take an argument from e.g. "-oARG" to "-o ARG"; add + set_short_opt_delimiter() and set_long_opt_delimiter() methods to + HelpFormatter to allow (slight) customization of the formatting. + + - Patch #736940: internationalize Optik: all built-in user- + targeted literal strings are passed through gettext.gettext(). (If + you want translations (.po files), they're not included with Python + -- you'll find them in the Optik source distribution from + http://optik.sourceforge.net/ .) + + - Bug #878453: respect $COLUMNS environment variable for + wrapping help output. + + - Feature #988122: expand "%prog" in the 'description' passed + to OptionParser, just like in the 'usage' and 'version' strings. + (This is *not* done in the 'description' passed to OptionGroup.) Tools/Demos From tim_one at users.sourceforge.net Sat Jul 31 23:14:31 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sat Jul 31 23:14:35 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_optparse.py, 1.4, 1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24750/Lib/test Modified Files: test_optparse.py Log Message: Be more careful about reverting mutuations to system-wide (sys) variables. This fixes 15 spurious test failures on Windows (probably all due to the test leaving a wrong path in sys.argv[0], which then prevented regrtest.py from finding the expected-output files for tests running after test_optparse). Index: test_optparse.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_optparse.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** test_optparse.py 31 Jul 2004 16:15:44 -0000 1.4 --- test_optparse.py 31 Jul 2004 21:14:28 -0000 1.5 *************** *** 126,142 **** def assertParseFail(self, cmdline_args, expected_output): """Assert the parser fails with the expected message.""" ! sys.stderr = StringIO() ! self.assertRaises(self.parser.parse_args, (cmdline_args,), None, ! SystemExit, expected_output, ! self.redirected_stderr) ! sys.stderr = sys.__stderr__ def assertStdoutEquals(self, cmdline_args, expected_output): """Assert the parser prints the expected output on stdout.""" ! sys.stdout = StringIO() ! self.assertRaises(self.parser.parse_args, (cmdline_args,), None, ! SystemExit, expected_output, ! self.redirected_stdout) ! sys.stdout = sys.__stdout__ def assertTypeError(self, func, expected_output, *args): --- 126,148 ---- def assertParseFail(self, cmdline_args, expected_output): """Assert the parser fails with the expected message.""" ! save_stderr = sys.stderr ! try: ! sys.stderr = StringIO() ! self.assertRaises(self.parser.parse_args, (cmdline_args,), None, ! SystemExit, expected_output, ! self.redirected_stderr) ! finally: ! sys.stderr = save_stderr def assertStdoutEquals(self, cmdline_args, expected_output): """Assert the parser prints the expected output on stdout.""" ! save_stdout = sys.stdout ! try: ! sys.stdout = StringIO() ! self.assertRaises(self.parser.parse_args, (cmdline_args,), None, ! SystemExit, expected_output, ! self.redirected_stdout) ! finally: ! sys.stdout = save_stdout def assertTypeError(self, func, expected_output, *args): *************** *** 427,440 **** def test_default_progname(self): # Make sure that program name taken from sys.argv[0] by default. ! sys.argv[0] = "/foo/bar/baz.py" ! parser = OptionParser("usage: %prog ...", version="%prog 1.2") ! expected_usage = "usage: baz.py ...\n" ! self.assertUsage(parser, expected_usage) ! self.assertVersion(parser, "baz.py 1.2") ! self.assertHelp(parser, ! expected_usage + "\n" + ! "options:\n" ! " --version show program's version number and exit\n" ! " -h, --help show this help message and exit\n") def test_custom_progname(self): --- 433,451 ---- def test_default_progname(self): # Make sure that program name taken from sys.argv[0] by default. ! save_argv = sys.argv[:] ! try: ! # XXX Should the path be hard-coding forward-slashes? ! sys.argv[0] = "/foo/bar/baz.py" ! parser = OptionParser("usage: %prog ...", version="%prog 1.2") ! expected_usage = "usage: baz.py ...\n" ! self.assertUsage(parser, expected_usage) ! self.assertVersion(parser, "baz.py 1.2") ! self.assertHelp(parser, ! expected_usage + "\n" + ! "options:\n" ! " --version show program's version number and exit\n" ! " -h, --help show this help message and exit\n") ! finally: ! sys.argv[:] = save_argv def test_custom_progname(self): From tim_one at users.sourceforge.net Sat Jul 31 23:17:52 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sat Jul 31 23:17:56 2004 Subject: [Python-checkins] python/dist/src/Lib/encodings hp_roman8.py, 1.1, 1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/encodings In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25454/Lib/encodings Modified Files: hp_roman8.py Log Message: Whitespace normalization. Index: hp_roman8.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/encodings/hp_roman8.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** hp_roman8.py 28 Jul 2004 15:37:16 -0000 1.1 --- hp_roman8.py 31 Jul 2004 21:17:36 -0000 1.2 *************** *** 38,136 **** decoding_map = codecs.make_identity_dict(range(256)) decoding_map.update({ ! 0x00a1: 0x00c0, # LATIN CAPITAL LETTER A WITH GRAVE ! 0x00a2: 0x00c2, # LATIN CAPITAL LETTER A WITH CIRCUMFLEX ! 0x00a3: 0x00c8, # LATIN CAPITAL LETTER E WITH GRAVE ! 0x00a4: 0x00ca, # LATIN CAPITAL LETTER E WITH CIRCUMFLEX ! 0x00a5: 0x00cb, # LATIN CAPITAL LETTER E WITH DIAERESIS ! 0x00a6: 0x00ce, # LATIN CAPITAL LETTER I WITH CIRCUMFLEX ! 0x00a7: 0x00cf, # LATIN CAPITAL LETTER I WITH DIAERESIS ! 0x00a8: 0x00b4, # ACUTE ACCENT ! 0x00a9: 0x02cb, # MODIFIER LETTER GRAVE ACCENT (Mandarin Chinese fourth tone) ! 0x00aa: 0x02c6, # MODIFIER LETTER CIRCUMFLEX ACCENT ! 0x00ab: 0x00a8, # DIAERESIS ! 0x00ac: 0x02dc, # SMALL TILDE ! 0x00ad: 0x00d9, # LATIN CAPITAL LETTER U WITH GRAVE ! 0x00ae: 0x00db, # LATIN CAPITAL LETTER U WITH CIRCUMFLEX ! 0x00af: 0x20a4, # LIRA SIGN ! 0x00b0: 0x00af, # MACRON ! 0x00b1: 0x00dd, # LATIN CAPITAL LETTER Y WITH ACUTE ! 0x00b2: 0x00fd, # LATIN SMALL LETTER Y WITH ACUTE ! 0x00b3: 0x00b0, # DEGREE SIGN ! 0x00b4: 0x00c7, # LATIN CAPITAL LETTER C WITH CEDILLA ! 0x00b5: 0x00e7, # LATIN SMALL LETTER C WITH CEDILLA ! 0x00b6: 0x00d1, # LATIN CAPITAL LETTER N WITH TILDE ! 0x00b7: 0x00f1, # LATIN SMALL LETTER N WITH TILDE ! 0x00b8: 0x00a1, # INVERTED EXCLAMATION MARK ! 0x00b9: 0x00bf, # INVERTED QUESTION MARK ! 0x00ba: 0x00a4, # CURRENCY SIGN ! 0x00bb: 0x00a3, # POUND SIGN ! 0x00bc: 0x00a5, # YEN SIGN ! 0x00bd: 0x00a7, # SECTION SIGN ! 0x00be: 0x0192, # LATIN SMALL LETTER F WITH HOOK ! 0x00bf: 0x00a2, # CENT SIGN ! 0x00c0: 0x00e2, # LATIN SMALL LETTER A WITH CIRCUMFLEX ! 0x00c1: 0x00ea, # LATIN SMALL LETTER E WITH CIRCUMFLEX ! 0x00c2: 0x00f4, # LATIN SMALL LETTER O WITH CIRCUMFLEX ! 0x00c3: 0x00fb, # LATIN SMALL LETTER U WITH CIRCUMFLEX ! 0x00c4: 0x00e1, # LATIN SMALL LETTER A WITH ACUTE ! 0x00c5: 0x00e9, # LATIN SMALL LETTER E WITH ACUTE ! 0x00c6: 0x00f3, # LATIN SMALL LETTER O WITH ACUTE ! 0x00c7: 0x00fa, # LATIN SMALL LETTER U WITH ACUTE ! 0x00c8: 0x00e0, # LATIN SMALL LETTER A WITH GRAVE ! 0x00c9: 0x00e8, # LATIN SMALL LETTER E WITH GRAVE ! 0x00ca: 0x00f2, # LATIN SMALL LETTER O WITH GRAVE ! 0x00cb: 0x00f9, # LATIN SMALL LETTER U WITH GRAVE ! 0x00cc: 0x00e4, # LATIN SMALL LETTER A WITH DIAERESIS ! 0x00cd: 0x00eb, # LATIN SMALL LETTER E WITH DIAERESIS ! 0x00ce: 0x00f6, # LATIN SMALL LETTER O WITH DIAERESIS ! 0x00cf: 0x00fc, # LATIN SMALL LETTER U WITH DIAERESIS ! 0x00d0: 0x00c5, # LATIN CAPITAL LETTER A WITH RING ABOVE ! 0x00d1: 0x00ee, # LATIN SMALL LETTER I WITH CIRCUMFLEX ! 0x00d2: 0x00d8, # LATIN CAPITAL LETTER O WITH STROKE ! 0x00d3: 0x00c6, # LATIN CAPITAL LETTER AE ! 0x00d4: 0x00e5, # LATIN SMALL LETTER A WITH RING ABOVE ! 0x00d5: 0x00ed, # LATIN SMALL LETTER I WITH ACUTE ! 0x00d6: 0x00f8, # LATIN SMALL LETTER O WITH STROKE ! 0x00d7: 0x00e6, # LATIN SMALL LETTER AE ! 0x00d8: 0x00c4, # LATIN CAPITAL LETTER A WITH DIAERESIS ! 0x00d9: 0x00ec, # LATIN SMALL LETTER I WITH GRAVE ! 0x00da: 0x00d6, # LATIN CAPITAL LETTER O WITH DIAERESIS ! 0x00db: 0x00dc, # LATIN CAPITAL LETTER U WITH DIAERESIS ! 0x00dc: 0x00c9, # LATIN CAPITAL LETTER E WITH ACUTE ! 0x00dd: 0x00ef, # LATIN SMALL LETTER I WITH DIAERESIS ! 0x00de: 0x00df, # LATIN SMALL LETTER SHARP S (German) ! 0x00df: 0x00d4, # LATIN CAPITAL LETTER O WITH CIRCUMFLEX ! 0x00e0: 0x00c1, # LATIN CAPITAL LETTER A WITH ACUTE ! 0x00e1: 0x00c3, # LATIN CAPITAL LETTER A WITH TILDE ! 0x00e2: 0x00e3, # LATIN SMALL LETTER A WITH TILDE ! 0x00e3: 0x00d0, # LATIN CAPITAL LETTER ETH (Icelandic) ! 0x00e4: 0x00f0, # LATIN SMALL LETTER ETH (Icelandic) ! 0x00e5: 0x00cd, # LATIN CAPITAL LETTER I WITH ACUTE ! 0x00e6: 0x00cc, # LATIN CAPITAL LETTER I WITH GRAVE ! 0x00e7: 0x00d3, # LATIN CAPITAL LETTER O WITH ACUTE ! 0x00e8: 0x00d2, # LATIN CAPITAL LETTER O WITH GRAVE ! 0x00e9: 0x00d5, # LATIN CAPITAL LETTER O WITH TILDE ! 0x00ea: 0x00f5, # LATIN SMALL LETTER O WITH TILDE ! 0x00eb: 0x0160, # LATIN CAPITAL LETTER S WITH CARON ! 0x00ec: 0x0161, # LATIN SMALL LETTER S WITH CARON ! 0x00ed: 0x00da, # LATIN CAPITAL LETTER U WITH ACUTE ! 0x00ee: 0x0178, # LATIN CAPITAL LETTER Y WITH DIAERESIS ! 0x00ef: 0x00ff, # LATIN SMALL LETTER Y WITH DIAERESIS ! 0x00f0: 0x00de, # LATIN CAPITAL LETTER THORN (Icelandic) ! 0x00f1: 0x00fe, # LATIN SMALL LETTER THORN (Icelandic) ! 0x00f2: 0x00b7, # MIDDLE DOT ! 0x00f3: 0x00b5, # MICRO SIGN ! 0x00f4: 0x00b6, # PILCROW SIGN ! 0x00f5: 0x00be, # VULGAR FRACTION THREE QUARTERS ! 0x00f6: 0x2014, # EM DASH ! 0x00f7: 0x00bc, # VULGAR FRACTION ONE QUARTER ! 0x00f8: 0x00bd, # VULGAR FRACTION ONE HALF ! 0x00f9: 0x00aa, # FEMININE ORDINAL INDICATOR ! 0x00fa: 0x00ba, # MASCULINE ORDINAL INDICATOR ! 0x00fb: 0x00ab, # LEFT-POINTING DOUBLE ANGLE QUOTATION MARK ! 0x00fc: 0x25a0, # BLACK SQUARE ! 0x00fd: 0x00bb, # RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK ! 0x00fe: 0x00b1, # PLUS-MINUS SIGN ! 0x00ff: None, }) --- 38,136 ---- decoding_map = codecs.make_identity_dict(range(256)) decoding_map.update({ ! 0x00a1: 0x00c0, # LATIN CAPITAL LETTER A WITH GRAVE ! 0x00a2: 0x00c2, # LATIN CAPITAL LETTER A WITH CIRCUMFLEX ! 0x00a3: 0x00c8, # LATIN CAPITAL LETTER E WITH GRAVE ! 0x00a4: 0x00ca, # LATIN CAPITAL LETTER E WITH CIRCUMFLEX ! 0x00a5: 0x00cb, # LATIN CAPITAL LETTER E WITH DIAERESIS ! 0x00a6: 0x00ce, # LATIN CAPITAL LETTER I WITH CIRCUMFLEX ! 0x00a7: 0x00cf, # LATIN CAPITAL LETTER I WITH DIAERESIS ! 0x00a8: 0x00b4, # ACUTE ACCENT ! 0x00a9: 0x02cb, # MODIFIER LETTER GRAVE ACCENT (Mandarin Chinese fourth tone) ! 0x00aa: 0x02c6, # MODIFIER LETTER CIRCUMFLEX ACCENT ! 0x00ab: 0x00a8, # DIAERESIS ! 0x00ac: 0x02dc, # SMALL TILDE ! 0x00ad: 0x00d9, # LATIN CAPITAL LETTER U WITH GRAVE ! 0x00ae: 0x00db, # LATIN CAPITAL LETTER U WITH CIRCUMFLEX ! 0x00af: 0x20a4, # LIRA SIGN ! 0x00b0: 0x00af, # MACRON ! 0x00b1: 0x00dd, # LATIN CAPITAL LETTER Y WITH ACUTE ! 0x00b2: 0x00fd, # LATIN SMALL LETTER Y WITH ACUTE ! 0x00b3: 0x00b0, # DEGREE SIGN ! 0x00b4: 0x00c7, # LATIN CAPITAL LETTER C WITH CEDILLA ! 0x00b5: 0x00e7, # LATIN SMALL LETTER C WITH CEDILLA ! 0x00b6: 0x00d1, # LATIN CAPITAL LETTER N WITH TILDE ! 0x00b7: 0x00f1, # LATIN SMALL LETTER N WITH TILDE ! 0x00b8: 0x00a1, # INVERTED EXCLAMATION MARK ! 0x00b9: 0x00bf, # INVERTED QUESTION MARK ! 0x00ba: 0x00a4, # CURRENCY SIGN ! 0x00bb: 0x00a3, # POUND SIGN ! 0x00bc: 0x00a5, # YEN SIGN ! 0x00bd: 0x00a7, # SECTION SIGN ! 0x00be: 0x0192, # LATIN SMALL LETTER F WITH HOOK ! 0x00bf: 0x00a2, # CENT SIGN ! 0x00c0: 0x00e2, # LATIN SMALL LETTER A WITH CIRCUMFLEX ! 0x00c1: 0x00ea, # LATIN SMALL LETTER E WITH CIRCUMFLEX ! 0x00c2: 0x00f4, # LATIN SMALL LETTER O WITH CIRCUMFLEX ! 0x00c3: 0x00fb, # LATIN SMALL LETTER U WITH CIRCUMFLEX ! 0x00c4: 0x00e1, # LATIN SMALL LETTER A WITH ACUTE ! 0x00c5: 0x00e9, # LATIN SMALL LETTER E WITH ACUTE ! 0x00c6: 0x00f3, # LATIN SMALL LETTER O WITH ACUTE ! 0x00c7: 0x00fa, # LATIN SMALL LETTER U WITH ACUTE ! 0x00c8: 0x00e0, # LATIN SMALL LETTER A WITH GRAVE ! 0x00c9: 0x00e8, # LATIN SMALL LETTER E WITH GRAVE ! 0x00ca: 0x00f2, # LATIN SMALL LETTER O WITH GRAVE ! 0x00cb: 0x00f9, # LATIN SMALL LETTER U WITH GRAVE ! 0x00cc: 0x00e4, # LATIN SMALL LETTER A WITH DIAERESIS ! 0x00cd: 0x00eb, # LATIN SMALL LETTER E WITH DIAERESIS ! 0x00ce: 0x00f6, # LATIN SMALL LETTER O WITH DIAERESIS ! 0x00cf: 0x00fc, # LATIN SMALL LETTER U WITH DIAERESIS ! 0x00d0: 0x00c5, # LATIN CAPITAL LETTER A WITH RING ABOVE ! 0x00d1: 0x00ee, # LATIN SMALL LETTER I WITH CIRCUMFLEX ! 0x00d2: 0x00d8, # LATIN CAPITAL LETTER O WITH STROKE ! 0x00d3: 0x00c6, # LATIN CAPITAL LETTER AE ! 0x00d4: 0x00e5, # LATIN SMALL LETTER A WITH RING ABOVE ! 0x00d5: 0x00ed, # LATIN SMALL LETTER I WITH ACUTE ! 0x00d6: 0x00f8, # LATIN SMALL LETTER O WITH STROKE ! 0x00d7: 0x00e6, # LATIN SMALL LETTER AE ! 0x00d8: 0x00c4, # LATIN CAPITAL LETTER A WITH DIAERESIS ! 0x00d9: 0x00ec, # LATIN SMALL LETTER I WITH GRAVE ! 0x00da: 0x00d6, # LATIN CAPITAL LETTER O WITH DIAERESIS ! 0x00db: 0x00dc, # LATIN CAPITAL LETTER U WITH DIAERESIS ! 0x00dc: 0x00c9, # LATIN CAPITAL LETTER E WITH ACUTE ! 0x00dd: 0x00ef, # LATIN SMALL LETTER I WITH DIAERESIS ! 0x00de: 0x00df, # LATIN SMALL LETTER SHARP S (German) ! 0x00df: 0x00d4, # LATIN CAPITAL LETTER O WITH CIRCUMFLEX ! 0x00e0: 0x00c1, # LATIN CAPITAL LETTER A WITH ACUTE ! 0x00e1: 0x00c3, # LATIN CAPITAL LETTER A WITH TILDE ! 0x00e2: 0x00e3, # LATIN SMALL LETTER A WITH TILDE ! 0x00e3: 0x00d0, # LATIN CAPITAL LETTER ETH (Icelandic) ! 0x00e4: 0x00f0, # LATIN SMALL LETTER ETH (Icelandic) ! 0x00e5: 0x00cd, # LATIN CAPITAL LETTER I WITH ACUTE ! 0x00e6: 0x00cc, # LATIN CAPITAL LETTER I WITH GRAVE ! 0x00e7: 0x00d3, # LATIN CAPITAL LETTER O WITH ACUTE ! 0x00e8: 0x00d2, # LATIN CAPITAL LETTER O WITH GRAVE ! 0x00e9: 0x00d5, # LATIN CAPITAL LETTER O WITH TILDE ! 0x00ea: 0x00f5, # LATIN SMALL LETTER O WITH TILDE ! 0x00eb: 0x0160, # LATIN CAPITAL LETTER S WITH CARON ! 0x00ec: 0x0161, # LATIN SMALL LETTER S WITH CARON ! 0x00ed: 0x00da, # LATIN CAPITAL LETTER U WITH ACUTE ! 0x00ee: 0x0178, # LATIN CAPITAL LETTER Y WITH DIAERESIS ! 0x00ef: 0x00ff, # LATIN SMALL LETTER Y WITH DIAERESIS ! 0x00f0: 0x00de, # LATIN CAPITAL LETTER THORN (Icelandic) ! 0x00f1: 0x00fe, # LATIN SMALL LETTER THORN (Icelandic) ! 0x00f2: 0x00b7, # MIDDLE DOT ! 0x00f3: 0x00b5, # MICRO SIGN ! 0x00f4: 0x00b6, # PILCROW SIGN ! 0x00f5: 0x00be, # VULGAR FRACTION THREE QUARTERS ! 0x00f6: 0x2014, # EM DASH ! 0x00f7: 0x00bc, # VULGAR FRACTION ONE QUARTER ! 0x00f8: 0x00bd, # VULGAR FRACTION ONE HALF ! 0x00f9: 0x00aa, # FEMININE ORDINAL INDICATOR ! 0x00fa: 0x00ba, # MASCULINE ORDINAL INDICATOR ! 0x00fb: 0x00ab, # LEFT-POINTING DOUBLE ANGLE QUOTATION MARK ! 0x00fc: 0x25a0, # BLACK SQUARE ! 0x00fd: 0x00bb, # RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK ! 0x00fe: 0x00b1, # PLUS-MINUS SIGN ! 0x00ff: None, }) From tim_one at users.sourceforge.net Sat Jul 31 23:18:09 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sat Jul 31 23:18:11 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_optparse.py, 1.5, 1.6 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25454/Lib/test Modified Files: test_optparse.py Log Message: Whitespace normalization. Index: test_optparse.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_optparse.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** test_optparse.py 31 Jul 2004 21:14:28 -0000 1.5 --- test_optparse.py 31 Jul 2004 21:17:37 -0000 1.6 *************** *** 60,64 **** expected_exception, expected_output, ! get_output=None, exact_match=False): """Assert the expected exception is raised when calling a function. --- 60,64 ---- expected_exception, expected_output, ! get_output=None, exact_match=False): """Assert the expected exception is raised when calling a function. *************** *** 347,351 **** self.assertEquals(self.parser.get_option("-s").type, "string") self.assertEquals(self.parser.get_option("-t").type, "string") ! # Custom type for testing processing of default values. --- 347,351 ---- self.assertEquals(self.parser.get_option("-s").type, "string") self.assertEquals(self.parser.get_option("-t").type, "string") ! # Custom type for testing processing of default values. *************** *** 504,508 **** help=self.file_help) self.assertHelp(self.parser, self.expected_help_none) ! def test_default_none_2(self): self.parser.add_option("-f", "--file", --- 504,508 ---- help=self.file_help) self.assertHelp(self.parser, self.expected_help_none) ! def test_default_none_2(self): self.parser.add_option("-f", "--file", *************** *** 1376,1380 **** ] os.environ['COLUMNS'] = str(columns) ! return OptionParser(option_list=options) def assertHelpEquals(self, expected_output): --- 1376,1380 ---- ] os.environ['COLUMNS'] = str(columns) ! return OptionParser(option_list=options) def assertHelpEquals(self, expected_output): *************** *** 1442,1446 **** ! class TestMatchAbbrev(BaseTest): --- 1442,1446 ---- ! class TestMatchAbbrev(BaseTest): From tim_one at users.sourceforge.net Sat Jul 31 23:53:22 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sat Jul 31 23:53:25 2004 Subject: [Python-checkins] python/dist/src/Objects listobject.c,2.217,2.218 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28970/Objects Modified Files: listobject.c Log Message: list_ass_slice(): Document the obscure new intent that deleting a slice of no more than 8 elements cannot fail. listpop(): Take advantage of that its calls to list_resize() and list_ass_slice() can't fail. This is assert'ed in a debug build now, but in an icky way. That is, you can't say: assert(some_call() >= 0); because then some_call() won't occur at all in a release build. So it has to be a big pile of #ifdefs on Py_DEBUG (yuck), or the pleasant: status = some_call(); assert(status >= 0); But in that case, compilers may whine in a release build, because status appears unused then. I'm not certain the ugly trick I used here will convince all compilers to shut up about status (status is always "used" now, as the first (ignored) clause in a comma expression). Index: listobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/listobject.c,v retrieving revision 2.217 retrieving revision 2.218 diff -C2 -d -r2.217 -r2.218 *** listobject.c 31 Jul 2004 02:54:42 -0000 2.217 --- listobject.c 31 Jul 2004 21:53:19 -0000 2.218 *************** *** 520,523 **** --- 520,529 ---- } + /* a[ilow:ihigh] = v if v != NULL. + * del a[ilow:ihigh] if v == NULL. + * + * Special speed gimmick: when v is NULL and ihigh - ilow <= 8, it's + * guaranteed the call cannot fail. + */ static int list_ass_slice(PyListObject *a, int ilow, int ihigh, PyObject *v) *************** *** 824,827 **** --- 830,834 ---- int i = -1; PyObject *v, *arg = NULL; + int status; if (!PyArg_UnpackTuple(args, "pop", 0, 1, &arg)) *************** *** 846,859 **** v = self->ob_item[i]; if (i == self->ob_size - 1) { ! if (list_resize(self, self->ob_size - 1) == -1) ! return NULL; ! return v; } Py_INCREF(v); ! if (list_ass_slice(self, i, i+1, (PyObject *)NULL) != 0) { ! Py_DECREF(v); ! return NULL; ! } ! return v; } --- 853,867 ---- v = self->ob_item[i]; if (i == self->ob_size - 1) { ! status = list_resize(self, self->ob_size - 1); ! assert(status >= 0); ! return v; /* and v now owns the reference the list had */ } Py_INCREF(v); ! status = list_ass_slice(self, i, i+1, (PyObject *)NULL); ! assert(status >= 0); ! /* Use status, so that in a release build compilers don't ! * complain about the unused name. ! */ ! return status, v; }