| 
									
										
										
										
											2008-05-20 21:35:26 +00:00
										 |  |  | from test import support | 
					
						
							| 
									
										
										
										
											2012-03-02 18:12:43 +01:00
										 |  |  | import array | 
					
						
							| 
									
										
										
										
											2013-07-11 22:20:47 +03:00
										 |  |  | import io | 
					
						
							| 
									
										
										
										
											2001-08-29 02:28:42 +00:00
										 |  |  | import marshal | 
					
						
							|  |  |  | import sys | 
					
						
							| 
									
										
										
										
											2003-08-02 15:02:33 +00:00
										 |  |  | import unittest | 
					
						
							|  |  |  | import os | 
					
						
							| 
									
										
										
										
											2011-05-27 09:08:01 -05:00
										 |  |  | import types | 
					
						
							| 
									
										
										
										
											2001-08-29 02:28:42 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-06 08:58:56 +02:00
										 |  |  | try: | 
					
						
							|  |  |  |     import _testcapi | 
					
						
							|  |  |  | except ImportError: | 
					
						
							|  |  |  |     _testcapi = None | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-07-10 11:37:44 +00:00
										 |  |  | class HelperMixin: | 
					
						
							|  |  |  |     def helper(self, sample, *extra): | 
					
						
							|  |  |  |         new = marshal.loads(marshal.dumps(sample, *extra)) | 
					
						
							|  |  |  |         self.assertEqual(sample, new) | 
					
						
							|  |  |  |         try: | 
					
						
							| 
									
										
										
										
											2010-10-13 02:40:26 +00:00
										 |  |  |             with open(support.TESTFN, "wb") as f: | 
					
						
							| 
									
										
										
										
											2007-07-10 11:37:44 +00:00
										 |  |  |                 marshal.dump(sample, f, *extra) | 
					
						
							| 
									
										
										
										
											2010-10-13 02:40:26 +00:00
										 |  |  |             with open(support.TESTFN, "rb") as f: | 
					
						
							| 
									
										
										
										
											2007-07-10 11:37:44 +00:00
										 |  |  |                 new = marshal.load(f) | 
					
						
							|  |  |  |             self.assertEqual(sample, new) | 
					
						
							|  |  |  |         finally: | 
					
						
							| 
									
										
										
										
											2008-05-20 21:35:26 +00:00
										 |  |  |             support.unlink(support.TESTFN) | 
					
						
							| 
									
										
										
										
											2007-07-10 11:37:44 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | class IntTestCase(unittest.TestCase, HelperMixin): | 
					
						
							| 
									
										
										
										
											2003-08-02 15:02:33 +00:00
										 |  |  |     def test_ints(self): | 
					
						
							| 
									
										
										
										
											2013-04-13 22:41:09 +02:00
										 |  |  |         # Test a range of Python ints larger than the machine word size. | 
					
						
							|  |  |  |         n = sys.maxsize ** 2 | 
					
						
							| 
									
										
										
										
											2003-08-02 15:02:33 +00:00
										 |  |  |         while n: | 
					
						
							|  |  |  |             for expected in (-n, n): | 
					
						
							| 
									
										
										
										
											2007-07-10 11:37:44 +00:00
										 |  |  |                 self.helper(expected) | 
					
						
							| 
									
										
										
										
											2013-04-13 22:46:33 +02:00
										 |  |  |             n = n >> 1 | 
					
						
							| 
									
										
										
										
											2003-08-02 15:02:33 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-15 17:41:05 +02:00
										 |  |  |     def test_int64(self): | 
					
						
							|  |  |  |         # Simulate int marshaling with TYPE_INT64. | 
					
						
							|  |  |  |         maxint64 = (1 << 63) - 1 | 
					
						
							|  |  |  |         minint64 = -maxint64-1 | 
					
						
							|  |  |  |         for base in maxint64, minint64, -maxint64, -(minint64 >> 1): | 
					
						
							|  |  |  |             while base: | 
					
						
							|  |  |  |                 s = b'I' + int.to_bytes(base, 8, 'little', signed=True) | 
					
						
							|  |  |  |                 got = marshal.loads(s) | 
					
						
							|  |  |  |                 self.assertEqual(base, got) | 
					
						
							|  |  |  |                 if base == -1:  # a fixed-point for shifting right 1 | 
					
						
							|  |  |  |                     base = 0 | 
					
						
							|  |  |  |                 else: | 
					
						
							|  |  |  |                     base >>= 1 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         got = marshal.loads(b'I\xfe\xdc\xba\x98\x76\x54\x32\x10') | 
					
						
							|  |  |  |         self.assertEqual(got, 0x1032547698badcfe) | 
					
						
							|  |  |  |         got = marshal.loads(b'I\x01\x23\x45\x67\x89\xab\xcd\xef') | 
					
						
							|  |  |  |         self.assertEqual(got, -0x1032547698badcff) | 
					
						
							|  |  |  |         got = marshal.loads(b'I\x08\x19\x2a\x3b\x4c\x5d\x6e\x7f') | 
					
						
							|  |  |  |         self.assertEqual(got, 0x7f6e5d4c3b2a1908) | 
					
						
							|  |  |  |         got = marshal.loads(b'I\xf7\xe6\xd5\xc4\xb3\xa2\x91\x80') | 
					
						
							|  |  |  |         self.assertEqual(got, -0x7f6e5d4c3b2a1909) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-08-02 15:02:33 +00:00
										 |  |  |     def test_bool(self): | 
					
						
							|  |  |  |         for b in (True, False): | 
					
						
							| 
									
										
										
										
											2007-07-10 11:37:44 +00:00
										 |  |  |             self.helper(b) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class FloatTestCase(unittest.TestCase, HelperMixin): | 
					
						
							| 
									
										
										
										
											2003-08-02 15:02:33 +00:00
										 |  |  |     def test_floats(self): | 
					
						
							|  |  |  |         # Test a few floats | 
					
						
							|  |  |  |         small = 1e-25 | 
					
						
							| 
									
										
										
										
											2007-12-04 23:02:19 +00:00
										 |  |  |         n = sys.maxsize * 3.7e250 | 
					
						
							| 
									
										
										
										
											2003-08-02 15:02:33 +00:00
										 |  |  |         while n > small: | 
					
						
							|  |  |  |             for expected in (-n, n): | 
					
						
							| 
									
										
										
										
											2007-07-10 11:37:44 +00:00
										 |  |  |                 self.helper(float(expected)) | 
					
						
							| 
									
										
										
										
											2003-08-02 15:02:33 +00:00
										 |  |  |             n /= 123.4567 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         f = 0.0 | 
					
						
							| 
									
										
										
										
											2005-06-03 14:41:55 +00:00
										 |  |  |         s = marshal.dumps(f, 2) | 
					
						
							| 
									
										
										
										
											2001-08-29 02:28:42 +00:00
										 |  |  |         got = marshal.loads(s) | 
					
						
							| 
									
										
										
										
											2003-08-02 15:02:33 +00:00
										 |  |  |         self.assertEqual(f, got) | 
					
						
							| 
									
										
										
										
											2005-06-03 14:41:55 +00:00
										 |  |  |         # and with version <= 1 (floats marshalled differently then) | 
					
						
							|  |  |  |         s = marshal.dumps(f, 1) | 
					
						
							| 
									
										
										
										
											2005-06-03 22:40:27 +00:00
										 |  |  |         got = marshal.loads(s) | 
					
						
							|  |  |  |         self.assertEqual(f, got) | 
					
						
							| 
									
										
										
										
											2003-08-02 15:02:33 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-12-04 23:02:19 +00:00
										 |  |  |         n = sys.maxsize * 3.7e-250 | 
					
						
							| 
									
										
										
										
											2003-08-02 15:02:33 +00:00
										 |  |  |         while n < small: | 
					
						
							|  |  |  |             for expected in (-n, n): | 
					
						
							|  |  |  |                 f = float(expected) | 
					
						
							| 
									
										
										
										
											2007-07-10 11:37:44 +00:00
										 |  |  |                 self.helper(f) | 
					
						
							|  |  |  |                 self.helper(f, 1) | 
					
						
							| 
									
										
										
										
											2003-08-02 15:02:33 +00:00
										 |  |  |             n *= 123.4567 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-07-10 11:37:44 +00:00
										 |  |  | class StringTestCase(unittest.TestCase, HelperMixin): | 
					
						
							| 
									
										
										
										
											2003-08-02 15:02:33 +00:00
										 |  |  |     def test_unicode(self): | 
					
						
							| 
									
										
										
										
											2007-07-10 11:37:44 +00:00
										 |  |  |         for s in ["", "Andr\xe8 Previn", "abc", " "*10000]: | 
					
						
							|  |  |  |             self.helper(marshal.loads(marshal.dumps(s))) | 
					
						
							| 
									
										
										
										
											2003-08-02 15:02:33 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     def test_string(self): | 
					
						
							| 
									
										
										
										
											2007-07-10 11:37:44 +00:00
										 |  |  |         for s in ["", "Andr\xe8 Previn", "abc", " "*10000]: | 
					
						
							|  |  |  |             self.helper(s) | 
					
						
							| 
									
										
										
										
											2003-08-02 15:02:33 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-10-08 02:46:15 +00:00
										 |  |  |     def test_bytes(self): | 
					
						
							| 
									
										
										
										
											2007-05-09 00:01:30 +00:00
										 |  |  |         for s in [b"", b"Andr\xe8 Previn", b"abc", b" "*10000]: | 
					
						
							| 
									
										
										
										
											2007-10-08 02:46:15 +00:00
										 |  |  |             self.helper(s) | 
					
						
							| 
									
										
										
										
											2004-01-18 20:29:55 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-08-02 15:02:33 +00:00
										 |  |  | class ExceptionTestCase(unittest.TestCase): | 
					
						
							|  |  |  |     def test_exceptions(self): | 
					
						
							|  |  |  |         new = marshal.loads(marshal.dumps(StopIteration)) | 
					
						
							|  |  |  |         self.assertEqual(StopIteration, new) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class CodeTestCase(unittest.TestCase): | 
					
						
							|  |  |  |     def test_code(self): | 
					
						
							| 
									
										
										
										
											2007-02-25 20:55:47 +00:00
										 |  |  |         co = ExceptionTestCase.test_exceptions.__code__ | 
					
						
							| 
									
										
										
										
											2003-08-02 15:02:33 +00:00
										 |  |  |         new = marshal.loads(marshal.dumps(co)) | 
					
						
							|  |  |  |         self.assertEqual(co, new) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-05-26 21:41:42 +00:00
										 |  |  |     def test_many_codeobjects(self): | 
					
						
							|  |  |  |         # Issue2957: bad recursion count on code objects | 
					
						
							|  |  |  |         count = 5000    # more than MAX_MARSHAL_STACK_DEPTH | 
					
						
							|  |  |  |         codes = (ExceptionTestCase.test_exceptions.__code__,) * count | 
					
						
							|  |  |  |         marshal.loads(marshal.dumps(codes)) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-05-27 09:08:01 -05:00
										 |  |  |     def test_different_filenames(self): | 
					
						
							|  |  |  |         co1 = compile("x", "f1", "exec") | 
					
						
							|  |  |  |         co2 = compile("y", "f2", "exec") | 
					
						
							|  |  |  |         co1, co2 = marshal.loads(marshal.dumps((co1, co2))) | 
					
						
							|  |  |  |         self.assertEqual(co1.co_filename, "f1") | 
					
						
							|  |  |  |         self.assertEqual(co2.co_filename, "f2") | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     @support.cpython_only | 
					
						
							|  |  |  |     def test_same_filename_used(self): | 
					
						
							|  |  |  |         s = """def f(): pass\ndef g(): pass""" | 
					
						
							|  |  |  |         co = compile(s, "myfile", "exec") | 
					
						
							|  |  |  |         co = marshal.loads(marshal.dumps(co)) | 
					
						
							|  |  |  |         for obj in co.co_consts: | 
					
						
							|  |  |  |             if isinstance(obj, types.CodeType): | 
					
						
							|  |  |  |                 self.assertIs(co.co_filename, obj.co_filename) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-07-10 11:37:44 +00:00
										 |  |  | class ContainerTestCase(unittest.TestCase, HelperMixin): | 
					
						
							| 
									
										
										
										
											2003-08-02 15:02:33 +00:00
										 |  |  |     d = {'astring': 'foo@bar.baz.spam', | 
					
						
							|  |  |  |          'afloat': 7283.43, | 
					
						
							|  |  |  |          'anint': 2**20, | 
					
						
							| 
									
										
										
										
											2007-01-15 16:59:06 +00:00
										 |  |  |          'ashortlong': 2, | 
					
						
							| 
									
										
										
										
											2003-08-02 15:02:33 +00:00
										 |  |  |          'alist': ['.zyx.41'], | 
					
						
							|  |  |  |          'atuple': ('.zyx.41',)*10, | 
					
						
							|  |  |  |          'aboolean': False, | 
					
						
							| 
									
										
										
										
											2007-07-10 11:37:44 +00:00
										 |  |  |          'aunicode': "Andr\xe8 Previn" | 
					
						
							| 
									
										
										
										
											2003-08-02 15:02:33 +00:00
										 |  |  |          } | 
					
						
							| 
									
										
										
										
											2007-07-10 11:37:44 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-08-02 15:02:33 +00:00
										 |  |  |     def test_dict(self): | 
					
						
							| 
									
										
										
										
											2007-07-10 11:37:44 +00:00
										 |  |  |         self.helper(self.d) | 
					
						
							| 
									
										
										
										
											2004-01-18 20:29:55 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-08-02 15:02:33 +00:00
										 |  |  |     def test_list(self): | 
					
						
							| 
									
										
										
										
											2007-07-10 11:37:44 +00:00
										 |  |  |         self.helper(list(self.d.items())) | 
					
						
							| 
									
										
										
										
											2003-08-02 15:02:33 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     def test_tuple(self): | 
					
						
							| 
									
										
										
										
											2007-07-10 11:37:44 +00:00
										 |  |  |         self.helper(tuple(self.d.keys())) | 
					
						
							| 
									
										
										
										
											2005-01-11 03:03:27 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     def test_sets(self): | 
					
						
							|  |  |  |         for constructor in (set, frozenset): | 
					
						
							| 
									
										
										
										
											2007-07-10 11:37:44 +00:00
										 |  |  |             self.helper(constructor(self.d.keys())) | 
					
						
							| 
									
										
										
										
											2004-01-18 20:29:55 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-23 14:15:48 +01:00
										 |  |  |     @support.cpython_only | 
					
						
							|  |  |  |     def test_empty_frozenset_singleton(self): | 
					
						
							|  |  |  |         # marshal.loads() must reuse the empty frozenset singleton | 
					
						
							|  |  |  |         obj = frozenset() | 
					
						
							|  |  |  |         obj2 = marshal.loads(marshal.dumps(obj)) | 
					
						
							|  |  |  |         self.assertIs(obj2, obj) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-02 18:12:43 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | class BufferTestCase(unittest.TestCase, HelperMixin): | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def test_bytearray(self): | 
					
						
							|  |  |  |         b = bytearray(b"abc") | 
					
						
							|  |  |  |         self.helper(b) | 
					
						
							|  |  |  |         new = marshal.loads(marshal.dumps(b)) | 
					
						
							|  |  |  |         self.assertEqual(type(new), bytes) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def test_memoryview(self): | 
					
						
							|  |  |  |         b = memoryview(b"abc") | 
					
						
							|  |  |  |         self.helper(b) | 
					
						
							|  |  |  |         new = marshal.loads(marshal.dumps(b)) | 
					
						
							|  |  |  |         self.assertEqual(type(new), bytes) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def test_array(self): | 
					
						
							|  |  |  |         a = array.array('B', b"abc") | 
					
						
							|  |  |  |         new = marshal.loads(marshal.dumps(a)) | 
					
						
							|  |  |  |         self.assertEqual(new, b"abc") | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-08-02 15:02:33 +00:00
										 |  |  | class BugsTestCase(unittest.TestCase): | 
					
						
							|  |  |  |     def test_bug_5888452(self): | 
					
						
							|  |  |  |         # Simple-minded check for SF 588452: Debug build crashes | 
					
						
							|  |  |  |         marshal.dumps([128] * 1000) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-03-26 15:09:27 +00:00
										 |  |  |     def test_patch_873224(self): | 
					
						
							| 
									
										
										
										
											2018-07-05 12:19:19 +03:00
										 |  |  |         self.assertRaises(Exception, marshal.loads, b'0') | 
					
						
							|  |  |  |         self.assertRaises(Exception, marshal.loads, b'f') | 
					
						
							| 
									
										
										
										
											2007-01-15 16:59:06 +00:00
										 |  |  |         self.assertRaises(Exception, marshal.loads, marshal.dumps(2**65)[:-1]) | 
					
						
							| 
									
										
										
										
											2004-03-26 15:09:27 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-12-20 12:25:57 +00:00
										 |  |  |     def test_version_argument(self): | 
					
						
							|  |  |  |         # Python 2.4.0 crashes for any call to marshal.dumps(x, y) | 
					
						
							| 
									
										
										
										
											2010-11-20 19:04:17 +00:00
										 |  |  |         self.assertEqual(marshal.loads(marshal.dumps(5, 0)), 5) | 
					
						
							|  |  |  |         self.assertEqual(marshal.loads(marshal.dumps(5, 1)), 5) | 
					
						
							| 
									
										
										
										
											2004-12-20 12:25:57 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-06-13 18:28:46 +00:00
										 |  |  |     def test_fuzz(self): | 
					
						
							|  |  |  |         # simple test that it's at least not *totally* trivial to | 
					
						
							|  |  |  |         # crash from bad marshal data | 
					
						
							| 
									
										
										
										
											2018-07-05 12:19:19 +03:00
										 |  |  |         for i in range(256): | 
					
						
							|  |  |  |             c = bytes([i]) | 
					
						
							| 
									
										
										
										
											2005-06-13 18:28:46 +00:00
										 |  |  |             try: | 
					
						
							|  |  |  |                 marshal.loads(c) | 
					
						
							|  |  |  |             except Exception: | 
					
						
							|  |  |  |                 pass | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-19 18:02:10 -07:00
										 |  |  |     def test_loads_recursion(self): | 
					
						
							| 
									
										
										
										
											2018-07-05 11:17:20 +03:00
										 |  |  |         def run_tests(N, check): | 
					
						
							|  |  |  |             # (((...None...),),) | 
					
						
							|  |  |  |             check(b')\x01' * N + b'N') | 
					
						
							|  |  |  |             check(b'(\x01\x00\x00\x00' * N + b'N') | 
					
						
							|  |  |  |             # [[[...None...]]] | 
					
						
							|  |  |  |             check(b'[\x01\x00\x00\x00' * N + b'N') | 
					
						
							|  |  |  |             # {None: {None: {None: ...None...}}} | 
					
						
							|  |  |  |             check(b'{N' * N + b'N' + b'0' * N) | 
					
						
							|  |  |  |             # frozenset([frozenset([frozenset([...None...])])]) | 
					
						
							|  |  |  |             check(b'>\x01\x00\x00\x00' * N + b'N') | 
					
						
							|  |  |  |         # Check that the generated marshal data is valid and marshal.loads() | 
					
						
							|  |  |  |         # works for moderately deep nesting | 
					
						
							|  |  |  |         run_tests(100, marshal.loads) | 
					
						
							|  |  |  |         # Very deeply nested structure shouldn't blow the stack | 
					
						
							|  |  |  |         def check(s): | 
					
						
							|  |  |  |             self.assertRaises(ValueError, marshal.loads, s) | 
					
						
							|  |  |  |         run_tests(2**20, check) | 
					
						
							| 
									
										
										
										
											2013-03-19 18:02:10 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												Merged revisions 55407-55513 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/p3yk
................
  r55413 | fred.drake | 2007-05-17 12:30:10 -0700 (Thu, 17 May 2007) | 1 line
  fix argument name in documentation; match the implementation
................
  r55430 | jack.diederich | 2007-05-18 06:39:59 -0700 (Fri, 18 May 2007) | 1 line
  Implements class decorators, PEP 3129.
................
  r55432 | guido.van.rossum | 2007-05-18 08:09:41 -0700 (Fri, 18 May 2007) | 2 lines
  obsubmit.
................
  r55434 | guido.van.rossum | 2007-05-18 09:39:10 -0700 (Fri, 18 May 2007) | 3 lines
  Fix bug in test_inspect.  (I presume this is how it should be fixed;
  Jack Diedrich, please verify.)
................
  r55460 | brett.cannon | 2007-05-20 00:31:57 -0700 (Sun, 20 May 2007) | 4 lines
  Remove the imageop module.  With imgfile already removed in Python 3.0 and
  rgbimg gone in Python 2.6 the unit tests themselves were made worthless.  Plus
  third-party libraries perform the same function much better.
................
  r55469 | neal.norwitz | 2007-05-20 11:28:20 -0700 (Sun, 20 May 2007) | 118 lines
  Merged revisions 55324-55467 via svnmerge from
  svn+ssh://pythondev@svn.python.org/python/trunk
  ........
    r55348 | georg.brandl | 2007-05-15 13:19:34 -0700 (Tue, 15 May 2007) | 4 lines
    HTML-escape the plain traceback in cgitb's HTML output, to prevent
    the traceback inadvertently or maliciously closing the comment and
    injecting HTML into the error page.
  ........
    r55372 | neal.norwitz | 2007-05-15 21:33:50 -0700 (Tue, 15 May 2007) | 6 lines
    Port rev 55353 from Guido:
    Add what looks like a necessary call to PyErr_NoMemory() when PyMem_MALLOC()
    fails.
    Will backport.
  ........
    r55377 | neal.norwitz | 2007-05-15 22:06:33 -0700 (Tue, 15 May 2007) | 1 line
    Mention removal of some directories for obsolete platforms
  ........
    r55380 | brett.cannon | 2007-05-15 22:50:03 -0700 (Tue, 15 May 2007) | 2 lines
    Change the maintainer of the BeOS port.
  ........
    r55383 | georg.brandl | 2007-05-16 06:44:18 -0700 (Wed, 16 May 2007) | 2 lines
    Bug #1719995: don't use deprecated method in sets example.
  ........
    r55386 | neal.norwitz | 2007-05-16 13:05:11 -0700 (Wed, 16 May 2007) | 5 lines
    Fix bug in marshal where bad data would cause a segfault due to
    lack of an infinite recursion check.
    Contributed by Damien Miller at Google.
  ........
    r55389 | brett.cannon | 2007-05-16 15:42:29 -0700 (Wed, 16 May 2007) | 6 lines
    Remove the gopherlib module.  It has been raising a DeprecationWarning since
    Python 2.5.
    Also remove gopher support from urllib/urllib2.  As both imported gopherlib the
    usage of the support would have raised a DeprecationWarning.
  ........
    r55394 | raymond.hettinger | 2007-05-16 18:08:04 -0700 (Wed, 16 May 2007) | 1 line
    calendar.py gets no benefit from xrange() instead of range()
  ........
    r55395 | brett.cannon | 2007-05-16 19:02:56 -0700 (Wed, 16 May 2007) | 3 lines
    Complete deprecation of BaseException.message.  Some subclasses were directly
    accessing the message attribute instead of using the descriptor.
  ........
    r55396 | neal.norwitz | 2007-05-16 23:11:36 -0700 (Wed, 16 May 2007) | 4 lines
    Reduce the max stack depth to see if this fixes the segfaults on
    Windows and some other boxes.  If this is successful, this rev should
    be backported.  I'm not sure how close to the limit we should push this.
  ........
    r55397 | neal.norwitz | 2007-05-16 23:23:50 -0700 (Wed, 16 May 2007) | 4 lines
    Set the depth to something very small to try to determine if the
    crashes on Windows are really due to the stack size or possibly
    some other problem.
  ........
    r55398 | neal.norwitz | 2007-05-17 00:04:46 -0700 (Thu, 17 May 2007) | 4 lines
    Last try for tweaking the max stack depth.  5000 was the original value,
    4000 didn't work either.  1000 does work on Windows.  If 2000 works,
    that will hopefully be a reasonable balance.
  ........
    r55412 | fred.drake | 2007-05-17 12:29:58 -0700 (Thu, 17 May 2007) | 1 line
    fix argument name in documentation; match the implementation
  ........
    r55427 | neal.norwitz | 2007-05-17 22:47:16 -0700 (Thu, 17 May 2007) | 1 line
    Verify neither dumps or loads overflow the stack and segfault.
  ........
    r55446 | collin.winter | 2007-05-18 16:11:24 -0700 (Fri, 18 May 2007) | 1 line
    Backport PEP 3110's new 'except' syntax to 2.6.
  ........
    r55448 | raymond.hettinger | 2007-05-18 18:11:16 -0700 (Fri, 18 May 2007) | 1 line
    Improvements to NamedTuple's implementation, tests, and documentation
  ........
    r55449 | raymond.hettinger | 2007-05-18 18:50:11 -0700 (Fri, 18 May 2007) | 1 line
    Fix beginner mistake -- don't mix spaces and tabs.
  ........
    r55450 | neal.norwitz | 2007-05-18 20:48:47 -0700 (Fri, 18 May 2007) | 1 line
    Clear data so random memory does not get freed.  Will backport.
  ........
    r55452 | neal.norwitz | 2007-05-18 21:34:55 -0700 (Fri, 18 May 2007) | 3 lines
    Whoops, need to pay attention to those test failures.
    Move the clear to *before* the first use, not after.
  ........
    r55453 | neal.norwitz | 2007-05-18 21:35:52 -0700 (Fri, 18 May 2007) | 1 line
    Give some clue as to what happened if the test fails.
  ........
    r55455 | georg.brandl | 2007-05-19 11:09:26 -0700 (Sat, 19 May 2007) | 2 lines
    Fix docstring for add_package in site.py.
  ........
    r55458 | brett.cannon | 2007-05-20 00:09:50 -0700 (Sun, 20 May 2007) | 2 lines
    Remove the rgbimg module.  It has been deprecated since Python 2.5.
  ........
    r55465 | nick.coghlan | 2007-05-20 04:12:49 -0700 (Sun, 20 May 2007) | 1 line
    Fix typo in example (should be backported, but my maintenance branch is woefully out of date)
  ........
................
  r55472 | brett.cannon | 2007-05-20 12:06:18 -0700 (Sun, 20 May 2007) | 2 lines
  Remove imageop from the Windows build process.
................
  r55486 | neal.norwitz | 2007-05-20 23:59:52 -0700 (Sun, 20 May 2007) | 1 line
  Remove callable() builtin
................
  r55506 | neal.norwitz | 2007-05-22 00:43:29 -0700 (Tue, 22 May 2007) | 78 lines
  Merged revisions 55468-55505 via svnmerge from
  svn+ssh://pythondev@svn.python.org/python/trunk
  ........
    r55468 | neal.norwitz | 2007-05-20 11:06:27 -0700 (Sun, 20 May 2007) | 1 line
    rotor is long gone.
  ........
    r55470 | neal.norwitz | 2007-05-20 11:43:00 -0700 (Sun, 20 May 2007) | 1 line
    Update directories/files at the top-level.
  ........
    r55471 | brett.cannon | 2007-05-20 12:05:06 -0700 (Sun, 20 May 2007) | 2 lines
    Try to remove rgbimg from Windows builds.
  ........
    r55474 | brett.cannon | 2007-05-20 16:17:38 -0700 (Sun, 20 May 2007) | 4 lines
    Remove the macfs module.  This led to the deprecation of macostools.touched();
    it completely relied on macfs and is a no-op on OS X according to code
    comments.
  ........
    r55476 | brett.cannon | 2007-05-20 16:56:18 -0700 (Sun, 20 May 2007) | 3 lines
    Move imgfile import to the global namespace to trigger an import error ASAP to
    prevent creation of a test file.
  ........
    r55477 | brett.cannon | 2007-05-20 16:57:38 -0700 (Sun, 20 May 2007) | 3 lines
    Cause posixfile to raise a DeprecationWarning.  Documented as deprecated since
    Ptyhon 1.5.
  ........
    r55479 | andrew.kuchling | 2007-05-20 17:03:15 -0700 (Sun, 20 May 2007) | 1 line
    Note removed modules
  ........
    r55481 | martin.v.loewis | 2007-05-20 21:35:47 -0700 (Sun, 20 May 2007) | 2 lines
    Add Alexandre Vassalotti.
  ........
    r55482 | george.yoshida | 2007-05-20 21:41:21 -0700 (Sun, 20 May 2007) | 4 lines
    fix against r55474 [Remove the macfs module]
    Remove "libmacfs.tex" from Makefile.deps and mac/mac.tex.
  ........
    r55487 | raymond.hettinger | 2007-05-21 01:13:35 -0700 (Mon, 21 May 2007) | 1 line
    Replace assertion with straight error-checking.
  ........
    r55489 | raymond.hettinger | 2007-05-21 09:40:10 -0700 (Mon, 21 May 2007) | 1 line
    Allow all alphanumeric and underscores in type and field names.
  ........
    r55490 | facundo.batista | 2007-05-21 10:32:32 -0700 (Mon, 21 May 2007) | 5 lines
    Added timeout support to HTTPSConnection, through the
    socket.create_connection function. Also added a small
    test for this, and updated NEWS file.
  ........
    r55495 | georg.brandl | 2007-05-21 13:34:16 -0700 (Mon, 21 May 2007) | 2 lines
    Patch #1686487: you can now pass any mapping after '**' in function calls.
  ........
    r55502 | neal.norwitz | 2007-05-21 23:03:36 -0700 (Mon, 21 May 2007) | 1 line
    Document new params to HTTPSConnection
  ........
    r55504 | neal.norwitz | 2007-05-22 00:16:10 -0700 (Tue, 22 May 2007) | 1 line
    Stop using METH_OLDARGS
  ........
    r55505 | neal.norwitz | 2007-05-22 00:16:44 -0700 (Tue, 22 May 2007) | 1 line
    Stop using METH_OLDARGS implicitly
  ........
................
											
										 
											2007-05-22 18:11:13 +00:00
										 |  |  |     def test_recursion_limit(self): | 
					
						
							|  |  |  |         # Create a deeply nested structure. | 
					
						
							|  |  |  |         head = last = [] | 
					
						
							|  |  |  |         # The max stack depth should match the value in Python/marshal.c. | 
					
						
							| 
									
										
										
										
											2018-06-04 13:25:00 -07:00
										 |  |  |         # BUG: https://bugs.python.org/issue33720 | 
					
						
							|  |  |  |         # Windows always limits the maximum depth on release and debug builds | 
					
						
							|  |  |  |         #if os.name == 'nt' and hasattr(sys, 'gettotalrefcount'): | 
					
						
							|  |  |  |         if os.name == 'nt': | 
					
						
							| 
									
										
										
										
											2014-11-01 15:15:16 -07:00
										 |  |  |             MAX_MARSHAL_STACK_DEPTH = 1000 | 
					
						
							| 
									
										
										
										
											2007-08-29 18:44:54 +00:00
										 |  |  |         else: | 
					
						
							|  |  |  |             MAX_MARSHAL_STACK_DEPTH = 2000 | 
					
						
							| 
									
										
											  
											
												Merged revisions 55407-55513 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/p3yk
................
  r55413 | fred.drake | 2007-05-17 12:30:10 -0700 (Thu, 17 May 2007) | 1 line
  fix argument name in documentation; match the implementation
................
  r55430 | jack.diederich | 2007-05-18 06:39:59 -0700 (Fri, 18 May 2007) | 1 line
  Implements class decorators, PEP 3129.
................
  r55432 | guido.van.rossum | 2007-05-18 08:09:41 -0700 (Fri, 18 May 2007) | 2 lines
  obsubmit.
................
  r55434 | guido.van.rossum | 2007-05-18 09:39:10 -0700 (Fri, 18 May 2007) | 3 lines
  Fix bug in test_inspect.  (I presume this is how it should be fixed;
  Jack Diedrich, please verify.)
................
  r55460 | brett.cannon | 2007-05-20 00:31:57 -0700 (Sun, 20 May 2007) | 4 lines
  Remove the imageop module.  With imgfile already removed in Python 3.0 and
  rgbimg gone in Python 2.6 the unit tests themselves were made worthless.  Plus
  third-party libraries perform the same function much better.
................
  r55469 | neal.norwitz | 2007-05-20 11:28:20 -0700 (Sun, 20 May 2007) | 118 lines
  Merged revisions 55324-55467 via svnmerge from
  svn+ssh://pythondev@svn.python.org/python/trunk
  ........
    r55348 | georg.brandl | 2007-05-15 13:19:34 -0700 (Tue, 15 May 2007) | 4 lines
    HTML-escape the plain traceback in cgitb's HTML output, to prevent
    the traceback inadvertently or maliciously closing the comment and
    injecting HTML into the error page.
  ........
    r55372 | neal.norwitz | 2007-05-15 21:33:50 -0700 (Tue, 15 May 2007) | 6 lines
    Port rev 55353 from Guido:
    Add what looks like a necessary call to PyErr_NoMemory() when PyMem_MALLOC()
    fails.
    Will backport.
  ........
    r55377 | neal.norwitz | 2007-05-15 22:06:33 -0700 (Tue, 15 May 2007) | 1 line
    Mention removal of some directories for obsolete platforms
  ........
    r55380 | brett.cannon | 2007-05-15 22:50:03 -0700 (Tue, 15 May 2007) | 2 lines
    Change the maintainer of the BeOS port.
  ........
    r55383 | georg.brandl | 2007-05-16 06:44:18 -0700 (Wed, 16 May 2007) | 2 lines
    Bug #1719995: don't use deprecated method in sets example.
  ........
    r55386 | neal.norwitz | 2007-05-16 13:05:11 -0700 (Wed, 16 May 2007) | 5 lines
    Fix bug in marshal where bad data would cause a segfault due to
    lack of an infinite recursion check.
    Contributed by Damien Miller at Google.
  ........
    r55389 | brett.cannon | 2007-05-16 15:42:29 -0700 (Wed, 16 May 2007) | 6 lines
    Remove the gopherlib module.  It has been raising a DeprecationWarning since
    Python 2.5.
    Also remove gopher support from urllib/urllib2.  As both imported gopherlib the
    usage of the support would have raised a DeprecationWarning.
  ........
    r55394 | raymond.hettinger | 2007-05-16 18:08:04 -0700 (Wed, 16 May 2007) | 1 line
    calendar.py gets no benefit from xrange() instead of range()
  ........
    r55395 | brett.cannon | 2007-05-16 19:02:56 -0700 (Wed, 16 May 2007) | 3 lines
    Complete deprecation of BaseException.message.  Some subclasses were directly
    accessing the message attribute instead of using the descriptor.
  ........
    r55396 | neal.norwitz | 2007-05-16 23:11:36 -0700 (Wed, 16 May 2007) | 4 lines
    Reduce the max stack depth to see if this fixes the segfaults on
    Windows and some other boxes.  If this is successful, this rev should
    be backported.  I'm not sure how close to the limit we should push this.
  ........
    r55397 | neal.norwitz | 2007-05-16 23:23:50 -0700 (Wed, 16 May 2007) | 4 lines
    Set the depth to something very small to try to determine if the
    crashes on Windows are really due to the stack size or possibly
    some other problem.
  ........
    r55398 | neal.norwitz | 2007-05-17 00:04:46 -0700 (Thu, 17 May 2007) | 4 lines
    Last try for tweaking the max stack depth.  5000 was the original value,
    4000 didn't work either.  1000 does work on Windows.  If 2000 works,
    that will hopefully be a reasonable balance.
  ........
    r55412 | fred.drake | 2007-05-17 12:29:58 -0700 (Thu, 17 May 2007) | 1 line
    fix argument name in documentation; match the implementation
  ........
    r55427 | neal.norwitz | 2007-05-17 22:47:16 -0700 (Thu, 17 May 2007) | 1 line
    Verify neither dumps or loads overflow the stack and segfault.
  ........
    r55446 | collin.winter | 2007-05-18 16:11:24 -0700 (Fri, 18 May 2007) | 1 line
    Backport PEP 3110's new 'except' syntax to 2.6.
  ........
    r55448 | raymond.hettinger | 2007-05-18 18:11:16 -0700 (Fri, 18 May 2007) | 1 line
    Improvements to NamedTuple's implementation, tests, and documentation
  ........
    r55449 | raymond.hettinger | 2007-05-18 18:50:11 -0700 (Fri, 18 May 2007) | 1 line
    Fix beginner mistake -- don't mix spaces and tabs.
  ........
    r55450 | neal.norwitz | 2007-05-18 20:48:47 -0700 (Fri, 18 May 2007) | 1 line
    Clear data so random memory does not get freed.  Will backport.
  ........
    r55452 | neal.norwitz | 2007-05-18 21:34:55 -0700 (Fri, 18 May 2007) | 3 lines
    Whoops, need to pay attention to those test failures.
    Move the clear to *before* the first use, not after.
  ........
    r55453 | neal.norwitz | 2007-05-18 21:35:52 -0700 (Fri, 18 May 2007) | 1 line
    Give some clue as to what happened if the test fails.
  ........
    r55455 | georg.brandl | 2007-05-19 11:09:26 -0700 (Sat, 19 May 2007) | 2 lines
    Fix docstring for add_package in site.py.
  ........
    r55458 | brett.cannon | 2007-05-20 00:09:50 -0700 (Sun, 20 May 2007) | 2 lines
    Remove the rgbimg module.  It has been deprecated since Python 2.5.
  ........
    r55465 | nick.coghlan | 2007-05-20 04:12:49 -0700 (Sun, 20 May 2007) | 1 line
    Fix typo in example (should be backported, but my maintenance branch is woefully out of date)
  ........
................
  r55472 | brett.cannon | 2007-05-20 12:06:18 -0700 (Sun, 20 May 2007) | 2 lines
  Remove imageop from the Windows build process.
................
  r55486 | neal.norwitz | 2007-05-20 23:59:52 -0700 (Sun, 20 May 2007) | 1 line
  Remove callable() builtin
................
  r55506 | neal.norwitz | 2007-05-22 00:43:29 -0700 (Tue, 22 May 2007) | 78 lines
  Merged revisions 55468-55505 via svnmerge from
  svn+ssh://pythondev@svn.python.org/python/trunk
  ........
    r55468 | neal.norwitz | 2007-05-20 11:06:27 -0700 (Sun, 20 May 2007) | 1 line
    rotor is long gone.
  ........
    r55470 | neal.norwitz | 2007-05-20 11:43:00 -0700 (Sun, 20 May 2007) | 1 line
    Update directories/files at the top-level.
  ........
    r55471 | brett.cannon | 2007-05-20 12:05:06 -0700 (Sun, 20 May 2007) | 2 lines
    Try to remove rgbimg from Windows builds.
  ........
    r55474 | brett.cannon | 2007-05-20 16:17:38 -0700 (Sun, 20 May 2007) | 4 lines
    Remove the macfs module.  This led to the deprecation of macostools.touched();
    it completely relied on macfs and is a no-op on OS X according to code
    comments.
  ........
    r55476 | brett.cannon | 2007-05-20 16:56:18 -0700 (Sun, 20 May 2007) | 3 lines
    Move imgfile import to the global namespace to trigger an import error ASAP to
    prevent creation of a test file.
  ........
    r55477 | brett.cannon | 2007-05-20 16:57:38 -0700 (Sun, 20 May 2007) | 3 lines
    Cause posixfile to raise a DeprecationWarning.  Documented as deprecated since
    Ptyhon 1.5.
  ........
    r55479 | andrew.kuchling | 2007-05-20 17:03:15 -0700 (Sun, 20 May 2007) | 1 line
    Note removed modules
  ........
    r55481 | martin.v.loewis | 2007-05-20 21:35:47 -0700 (Sun, 20 May 2007) | 2 lines
    Add Alexandre Vassalotti.
  ........
    r55482 | george.yoshida | 2007-05-20 21:41:21 -0700 (Sun, 20 May 2007) | 4 lines
    fix against r55474 [Remove the macfs module]
    Remove "libmacfs.tex" from Makefile.deps and mac/mac.tex.
  ........
    r55487 | raymond.hettinger | 2007-05-21 01:13:35 -0700 (Mon, 21 May 2007) | 1 line
    Replace assertion with straight error-checking.
  ........
    r55489 | raymond.hettinger | 2007-05-21 09:40:10 -0700 (Mon, 21 May 2007) | 1 line
    Allow all alphanumeric and underscores in type and field names.
  ........
    r55490 | facundo.batista | 2007-05-21 10:32:32 -0700 (Mon, 21 May 2007) | 5 lines
    Added timeout support to HTTPSConnection, through the
    socket.create_connection function. Also added a small
    test for this, and updated NEWS file.
  ........
    r55495 | georg.brandl | 2007-05-21 13:34:16 -0700 (Mon, 21 May 2007) | 2 lines
    Patch #1686487: you can now pass any mapping after '**' in function calls.
  ........
    r55502 | neal.norwitz | 2007-05-21 23:03:36 -0700 (Mon, 21 May 2007) | 1 line
    Document new params to HTTPSConnection
  ........
    r55504 | neal.norwitz | 2007-05-22 00:16:10 -0700 (Tue, 22 May 2007) | 1 line
    Stop using METH_OLDARGS
  ........
    r55505 | neal.norwitz | 2007-05-22 00:16:44 -0700 (Tue, 22 May 2007) | 1 line
    Stop using METH_OLDARGS implicitly
  ........
................
											
										 
											2007-05-22 18:11:13 +00:00
										 |  |  |         for i in range(MAX_MARSHAL_STACK_DEPTH - 2): | 
					
						
							|  |  |  |             last.append([0]) | 
					
						
							|  |  |  |             last = last[-1] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         # Verify we don't blow out the stack with dumps/load. | 
					
						
							|  |  |  |         data = marshal.dumps(head) | 
					
						
							|  |  |  |         new_head = marshal.loads(data) | 
					
						
							|  |  |  |         # Don't use == to compare objects, it can exceed the recursion limit. | 
					
						
							|  |  |  |         self.assertEqual(len(new_head), len(head)) | 
					
						
							|  |  |  |         self.assertEqual(len(new_head[0]), len(head[0])) | 
					
						
							|  |  |  |         self.assertEqual(len(new_head[-1]), len(head[-1])) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         last.append([0]) | 
					
						
							|  |  |  |         self.assertRaises(ValueError, marshal.dumps, head) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												Merged revisions 58886-58929 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
  r58892 | guido.van.rossum | 2007-11-06 15:32:56 -0800 (Tue, 06 Nov 2007) | 2 lines
  Add missing "return NULL" in overflow check in PyObject_Repr().
........
  r58893 | raymond.hettinger | 2007-11-06 17:13:09 -0800 (Tue, 06 Nov 2007) | 1 line
  Fix marshal's incorrect handling of subclasses of builtin types (backport candidate).
........
  r58895 | raymond.hettinger | 2007-11-06 18:26:17 -0800 (Tue, 06 Nov 2007) | 1 line
  Optimize dict.fromkeys() with dict inputs.  Useful for resetting bag/muliset counts for example.
........
  r58896 | raymond.hettinger | 2007-11-06 18:45:46 -0800 (Tue, 06 Nov 2007) | 1 line
  Add build option for faster loop execution.
........
  r58900 | nick.coghlan | 2007-11-07 03:57:51 -0800 (Wed, 07 Nov 2007) | 1 line
  Add missing NEWS entry
........
  r58905 | christian.heimes | 2007-11-07 09:50:54 -0800 (Wed, 07 Nov 2007) | 1 line
  Backported fix for bug #1392 from py3k branch r58903.
........
  r58906 | christian.heimes | 2007-11-07 10:30:22 -0800 (Wed, 07 Nov 2007) | 1 line
  Backport of Guido's review of my patch.
........
  r58908 | raymond.hettinger | 2007-11-07 18:52:43 -0800 (Wed, 07 Nov 2007) | 1 line
  Add set.isdisjoint()
........
  r58915 | raymond.hettinger | 2007-11-08 10:47:51 -0800 (Thu, 08 Nov 2007) | 1 line
  Reposition the decref (spotted by eagle-eye norwitz).
........
  r58920 | georg.brandl | 2007-11-09 04:31:43 -0800 (Fri, 09 Nov 2007) | 2 lines
  Fix seealso link to sets docs. Do not merge to Py3k.
........
  r58921 | georg.brandl | 2007-11-09 05:08:48 -0800 (Fri, 09 Nov 2007) | 2 lines
  Fix misleading example.
........
  r58923 | georg.brandl | 2007-11-09 09:33:23 -0800 (Fri, 09 Nov 2007) | 3 lines
  Correct a comment about testing methods - nowadays most
  tests don't run directly on import.
........
  r58924 | martin.v.loewis | 2007-11-09 14:56:30 -0800 (Fri, 09 Nov 2007) | 2 lines
  Add Amaury Forgeot d'Arc.
........
  r58925 | raymond.hettinger | 2007-11-09 15:14:44 -0800 (Fri, 09 Nov 2007) | 1 line
  Optimize common case for dict.fromkeys().
........
  r58927 | raymond.hettinger | 2007-11-09 17:54:03 -0800 (Fri, 09 Nov 2007) | 1 line
  Use a freelist to speed-up block allocation and deallocation in collections.deque().
........
  r58929 | guido.van.rossum | 2007-11-10 14:12:24 -0800 (Sat, 10 Nov 2007) | 3 lines
  Issue 1416.  Add getter, setter, deleter methods to properties that can be
  used as decorators to create fully-populated properties.
........
											
										 
											2007-11-10 23:39:45 +00:00
										 |  |  |     def test_exact_type_match(self): | 
					
						
							|  |  |  |         # Former bug: | 
					
						
							|  |  |  |         #   >>> class Int(int): pass | 
					
						
							|  |  |  |         #   >>> type(loads(dumps(Int()))) | 
					
						
							|  |  |  |         #   <type 'int'> | 
					
						
							|  |  |  |         for typ in (int, float, complex, tuple, list, dict, set, frozenset): | 
					
						
							| 
									
										
										
										
											2011-03-16 11:05:33 +02:00
										 |  |  |             # Note: str subclasses are not tested because they get handled | 
					
						
							| 
									
										
											  
											
												Merged revisions 58886-58929 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
  r58892 | guido.van.rossum | 2007-11-06 15:32:56 -0800 (Tue, 06 Nov 2007) | 2 lines
  Add missing "return NULL" in overflow check in PyObject_Repr().
........
  r58893 | raymond.hettinger | 2007-11-06 17:13:09 -0800 (Tue, 06 Nov 2007) | 1 line
  Fix marshal's incorrect handling of subclasses of builtin types (backport candidate).
........
  r58895 | raymond.hettinger | 2007-11-06 18:26:17 -0800 (Tue, 06 Nov 2007) | 1 line
  Optimize dict.fromkeys() with dict inputs.  Useful for resetting bag/muliset counts for example.
........
  r58896 | raymond.hettinger | 2007-11-06 18:45:46 -0800 (Tue, 06 Nov 2007) | 1 line
  Add build option for faster loop execution.
........
  r58900 | nick.coghlan | 2007-11-07 03:57:51 -0800 (Wed, 07 Nov 2007) | 1 line
  Add missing NEWS entry
........
  r58905 | christian.heimes | 2007-11-07 09:50:54 -0800 (Wed, 07 Nov 2007) | 1 line
  Backported fix for bug #1392 from py3k branch r58903.
........
  r58906 | christian.heimes | 2007-11-07 10:30:22 -0800 (Wed, 07 Nov 2007) | 1 line
  Backport of Guido's review of my patch.
........
  r58908 | raymond.hettinger | 2007-11-07 18:52:43 -0800 (Wed, 07 Nov 2007) | 1 line
  Add set.isdisjoint()
........
  r58915 | raymond.hettinger | 2007-11-08 10:47:51 -0800 (Thu, 08 Nov 2007) | 1 line
  Reposition the decref (spotted by eagle-eye norwitz).
........
  r58920 | georg.brandl | 2007-11-09 04:31:43 -0800 (Fri, 09 Nov 2007) | 2 lines
  Fix seealso link to sets docs. Do not merge to Py3k.
........
  r58921 | georg.brandl | 2007-11-09 05:08:48 -0800 (Fri, 09 Nov 2007) | 2 lines
  Fix misleading example.
........
  r58923 | georg.brandl | 2007-11-09 09:33:23 -0800 (Fri, 09 Nov 2007) | 3 lines
  Correct a comment about testing methods - nowadays most
  tests don't run directly on import.
........
  r58924 | martin.v.loewis | 2007-11-09 14:56:30 -0800 (Fri, 09 Nov 2007) | 2 lines
  Add Amaury Forgeot d'Arc.
........
  r58925 | raymond.hettinger | 2007-11-09 15:14:44 -0800 (Fri, 09 Nov 2007) | 1 line
  Optimize common case for dict.fromkeys().
........
  r58927 | raymond.hettinger | 2007-11-09 17:54:03 -0800 (Fri, 09 Nov 2007) | 1 line
  Use a freelist to speed-up block allocation and deallocation in collections.deque().
........
  r58929 | guido.van.rossum | 2007-11-10 14:12:24 -0800 (Sat, 10 Nov 2007) | 3 lines
  Issue 1416.  Add getter, setter, deleter methods to properties that can be
  used as decorators to create fully-populated properties.
........
											
										 
											2007-11-10 23:39:45 +00:00
										 |  |  |             # by marshal's routines for objects supporting the buffer API. | 
					
						
							|  |  |  |             subtyp = type('subtyp', (typ,), {}) | 
					
						
							|  |  |  |             self.assertRaises(ValueError, marshal.dumps, subtyp()) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												Merged revisions 62998-63003,63005-63006,63009-63012,63014-63017,63019-63020,63022-63024,63026-63029,63031-63041,63043-63045,63047-63054,63056-63062 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
  r62998 | andrew.kuchling | 2008-05-10 15:51:55 -0400 (Sat, 10 May 2008) | 7 lines
  #1858 from Tarek Ziade:
  Allow multiple repositories in .pypirc; see http://wiki.python.org/moin/EnhancedPyPI
  for discussion.
  The patch is slightly revised from Tarek's last patch: I've simplified
  the PyPIRCCommand.finalize_options() method to not look at sys.argv.
  Tests still pass.
........
  r63000 | alexandre.vassalotti | 2008-05-10 15:59:16 -0400 (Sat, 10 May 2008) | 5 lines
  Cleaned up io._BytesIO.write().
  I am amazed that the old code, for inserting null-bytes, actually
  worked. Who wrote that thing? Oh, it is me... doh.
........
  r63002 | brett.cannon | 2008-05-10 16:52:01 -0400 (Sat, 10 May 2008) | 2 lines
  Revert r62998 as it broke the build (seems distutils.config is missing).
........
  r63014 | andrew.kuchling | 2008-05-10 18:12:38 -0400 (Sat, 10 May 2008) | 1 line
  #1858: add distutils.config module
........
  r63027 | brett.cannon | 2008-05-10 21:09:32 -0400 (Sat, 10 May 2008) | 2 lines
  Flesh out the 3.0 deprecation to suggest using the ctypes module.
........
  r63028 | skip.montanaro | 2008-05-10 22:59:30 -0400 (Sat, 10 May 2008) | 4 lines
  Copied two versions of the example from the interactive session.  Delete
  one.
........
  r63037 | georg.brandl | 2008-05-11 03:02:17 -0400 (Sun, 11 May 2008) | 2 lines
  reload() takes the module itself.
........
  r63038 | alexandre.vassalotti | 2008-05-11 03:06:04 -0400 (Sun, 11 May 2008) | 4 lines
  Added test framework for handling module renames.
  Factored the import guard in test_py3kwarn.TestStdlibRemovals into
  a context manager, namely test_support.CleanImport.
........
  r63039 | georg.brandl | 2008-05-11 03:06:05 -0400 (Sun, 11 May 2008) | 2 lines
  #2742: ``''`` is not converted to NULL in getaddrinfo.
........
  r63040 | alexandre.vassalotti | 2008-05-11 03:08:12 -0400 (Sun, 11 May 2008) | 2 lines
  Fixed typo in a comment of test_support.CleanImport.
........
  r63041 | alexandre.vassalotti | 2008-05-11 03:10:25 -0400 (Sun, 11 May 2008) | 2 lines
  Removed a dead line of code.
........
  r63043 | georg.brandl | 2008-05-11 04:47:53 -0400 (Sun, 11 May 2008) | 2 lines
  #2812: document property.getter/setter/deleter.
........
  r63049 | georg.brandl | 2008-05-11 05:06:30 -0400 (Sun, 11 May 2008) | 2 lines
  #1153769: document PEP 237 changes to string formatting.
........
  r63050 | georg.brandl | 2008-05-11 05:11:40 -0400 (Sun, 11 May 2008) | 2 lines
  #2809: elaborate str.split docstring a bit.
........
  r63051 | georg.brandl | 2008-05-11 06:13:59 -0400 (Sun, 11 May 2008) | 2 lines
  Fix typo.
........
  r63052 | georg.brandl | 2008-05-11 06:33:27 -0400 (Sun, 11 May 2008) | 2 lines
  #2709: clarification.
........
  r63053 | georg.brandl | 2008-05-11 06:42:28 -0400 (Sun, 11 May 2008) | 2 lines
  #2659: add ``break_on_hyphens`` to TextWrapper.
........
  r63057 | georg.brandl | 2008-05-11 06:59:39 -0400 (Sun, 11 May 2008) | 2 lines
  #2741: clarification of value range for address_family.
........
  r63058 | georg.brandl | 2008-05-11 07:09:35 -0400 (Sun, 11 May 2008) | 2 lines
  #2452: timeout is used for all blocking operations.
........
  r63059 | andrew.kuchling | 2008-05-11 09:33:56 -0400 (Sun, 11 May 2008) | 2 lines
  #1792: Improve performance of marshal.dumps() on large objects by increasing
  the size of the buffer more quickly.
........
  r63060 | andrew.kuchling | 2008-05-11 10:00:00 -0400 (Sun, 11 May 2008) | 1 line
  #1858: re-apply patch for this, adding the missing files
........
  r63061 | benjamin.peterson | 2008-05-11 10:13:25 -0400 (Sun, 11 May 2008) | 2 lines
  Add the "until" command to pdb
........
  r63062 | georg.brandl | 2008-05-11 10:17:13 -0400 (Sun, 11 May 2008) | 2 lines
  Add some sentence endings.
........
											
										 
											2008-05-16 00:03:33 +00:00
										 |  |  |     # Issue #1792 introduced a change in how marshal increases the size of its | 
					
						
							|  |  |  |     # internal buffer; this test ensures that the new code is exercised. | 
					
						
							|  |  |  |     def test_large_marshal(self): | 
					
						
							|  |  |  |         size = int(1e6) | 
					
						
							|  |  |  |         testString = 'abc' * size | 
					
						
							|  |  |  |         marshal.dumps(testString) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-29 19:21:35 +00:00
										 |  |  |     def test_invalid_longs(self): | 
					
						
							|  |  |  |         # Issue #7019: marshal.loads shouldn't produce unnormalized PyLongs | 
					
						
							|  |  |  |         invalid_string = b'l\x02\x00\x00\x00\x00\x00\x00\x00' | 
					
						
							|  |  |  |         self.assertRaises(ValueError, marshal.loads, invalid_string) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-07-02 16:42:47 +01:00
										 |  |  |     def test_multiple_dumps_and_loads(self): | 
					
						
							|  |  |  |         # Issue 12291: marshal.load() should be callable multiple times | 
					
						
							|  |  |  |         # with interleaved data written by non-marshal code | 
					
						
							|  |  |  |         # Adapted from a patch by Engelbert Gruber. | 
					
						
							|  |  |  |         data = (1, 'abc', b'def', 1.0, (2, 'a', ['b', b'c'])) | 
					
						
							|  |  |  |         for interleaved in (b'', b'0123'): | 
					
						
							|  |  |  |             ilen = len(interleaved) | 
					
						
							|  |  |  |             positions = [] | 
					
						
							|  |  |  |             try: | 
					
						
							|  |  |  |                 with open(support.TESTFN, 'wb') as f: | 
					
						
							|  |  |  |                     for d in data: | 
					
						
							|  |  |  |                         marshal.dump(d, f) | 
					
						
							|  |  |  |                         if ilen: | 
					
						
							|  |  |  |                             f.write(interleaved) | 
					
						
							|  |  |  |                         positions.append(f.tell()) | 
					
						
							|  |  |  |                 with open(support.TESTFN, 'rb') as f: | 
					
						
							|  |  |  |                     for i, d in enumerate(data): | 
					
						
							|  |  |  |                         self.assertEqual(d, marshal.load(f)) | 
					
						
							|  |  |  |                         if ilen: | 
					
						
							|  |  |  |                             f.read(ilen) | 
					
						
							|  |  |  |                         self.assertEqual(positions[i], f.tell()) | 
					
						
							|  |  |  |             finally: | 
					
						
							|  |  |  |                 support.unlink(support.TESTFN) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-03 02:35:32 +01:00
										 |  |  |     def test_loads_reject_unicode_strings(self): | 
					
						
							|  |  |  |         # Issue #14177: marshal.loads() should not accept unicode strings | 
					
						
							|  |  |  |         unicode_string = 'T' | 
					
						
							|  |  |  |         self.assertRaises(TypeError, marshal.loads, unicode_string) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-07-11 22:20:47 +03:00
										 |  |  |     def test_bad_reader(self): | 
					
						
							|  |  |  |         class BadReader(io.BytesIO): | 
					
						
							| 
									
										
										
										
											2013-10-12 22:25:39 +02:00
										 |  |  |             def readinto(self, buf): | 
					
						
							|  |  |  |                 n = super().readinto(buf) | 
					
						
							| 
									
										
										
										
											2013-07-11 22:20:47 +03:00
										 |  |  |                 if n is not None and n > 4: | 
					
						
							| 
									
										
										
										
											2013-10-12 22:25:39 +02:00
										 |  |  |                     n += 10**6 | 
					
						
							|  |  |  |                 return n | 
					
						
							| 
									
										
										
										
											2013-07-11 22:20:47 +03:00
										 |  |  |         for value in (1.0, 1j, b'0123456789', '0123456789'): | 
					
						
							|  |  |  |             self.assertRaises(ValueError, marshal.load, | 
					
						
							|  |  |  |                               BadReader(marshal.dumps(value))) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-05 12:19:19 +03:00
										 |  |  |     def test_eof(self): | 
					
						
							| 
									
										
										
										
											2013-03-20 14:26:33 -07:00
										 |  |  |         data = marshal.dumps(("hello", "dolly", None)) | 
					
						
							|  |  |  |         for i in range(len(data)): | 
					
						
							|  |  |  |             self.assertRaises(EOFError, marshal.loads, data[0: i]) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-02-13 12:08:15 +02:00
										 |  |  | LARGE_SIZE = 2**31 | 
					
						
							|  |  |  | pointer_size = 8 if sys.maxsize > 0xFFFFFFFF else 4 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class NullWriter: | 
					
						
							|  |  |  |     def write(self, s): | 
					
						
							|  |  |  |         pass | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | @unittest.skipIf(LARGE_SIZE > sys.maxsize, "test cannot run on 32-bit systems") | 
					
						
							|  |  |  | class LargeValuesTestCase(unittest.TestCase): | 
					
						
							|  |  |  |     def check_unmarshallable(self, data): | 
					
						
							|  |  |  |         self.assertRaises(ValueError, marshal.dump, data, NullWriter()) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-01-10 13:37:54 +02:00
										 |  |  |     @support.bigmemtest(size=LARGE_SIZE, memuse=2, dry_run=False) | 
					
						
							| 
									
										
										
										
											2013-02-13 12:08:15 +02:00
										 |  |  |     def test_bytes(self, size): | 
					
						
							|  |  |  |         self.check_unmarshallable(b'x' * size) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-01-10 13:37:54 +02:00
										 |  |  |     @support.bigmemtest(size=LARGE_SIZE, memuse=2, dry_run=False) | 
					
						
							| 
									
										
										
										
											2013-02-13 12:08:15 +02:00
										 |  |  |     def test_str(self, size): | 
					
						
							|  |  |  |         self.check_unmarshallable('x' * size) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-01-10 13:37:54 +02:00
										 |  |  |     @support.bigmemtest(size=LARGE_SIZE, memuse=pointer_size + 1, dry_run=False) | 
					
						
							| 
									
										
										
										
											2013-02-13 12:08:15 +02:00
										 |  |  |     def test_tuple(self, size): | 
					
						
							|  |  |  |         self.check_unmarshallable((None,) * size) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-01-10 13:37:54 +02:00
										 |  |  |     @support.bigmemtest(size=LARGE_SIZE, memuse=pointer_size + 1, dry_run=False) | 
					
						
							| 
									
										
										
										
											2013-02-13 12:08:15 +02:00
										 |  |  |     def test_list(self, size): | 
					
						
							|  |  |  |         self.check_unmarshallable([None] * size) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     @support.bigmemtest(size=LARGE_SIZE, | 
					
						
							|  |  |  |             memuse=pointer_size*12 + sys.getsizeof(LARGE_SIZE-1), | 
					
						
							|  |  |  |             dry_run=False) | 
					
						
							|  |  |  |     def test_set(self, size): | 
					
						
							|  |  |  |         self.check_unmarshallable(set(range(size))) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     @support.bigmemtest(size=LARGE_SIZE, | 
					
						
							|  |  |  |             memuse=pointer_size*12 + sys.getsizeof(LARGE_SIZE-1), | 
					
						
							|  |  |  |             dry_run=False) | 
					
						
							|  |  |  |     def test_frozenset(self, size): | 
					
						
							|  |  |  |         self.check_unmarshallable(frozenset(range(size))) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-01-10 13:37:54 +02:00
										 |  |  |     @support.bigmemtest(size=LARGE_SIZE, memuse=2, dry_run=False) | 
					
						
							| 
									
										
										
										
											2013-02-13 12:08:15 +02:00
										 |  |  |     def test_bytearray(self, size): | 
					
						
							|  |  |  |         self.check_unmarshallable(bytearray(size)) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-19 18:02:10 -07:00
										 |  |  | def CollectObjectIDs(ids, obj): | 
					
						
							|  |  |  |     """Collect object ids seen in a structure""" | 
					
						
							|  |  |  |     if id(obj) in ids: | 
					
						
							|  |  |  |         return | 
					
						
							|  |  |  |     ids.add(id(obj)) | 
					
						
							|  |  |  |     if isinstance(obj, (list, tuple, set, frozenset)): | 
					
						
							|  |  |  |         for e in obj: | 
					
						
							|  |  |  |             CollectObjectIDs(ids, e) | 
					
						
							|  |  |  |     elif isinstance(obj, dict): | 
					
						
							|  |  |  |         for k, v in obj.items(): | 
					
						
							|  |  |  |             CollectObjectIDs(ids, k) | 
					
						
							|  |  |  |             CollectObjectIDs(ids, v) | 
					
						
							|  |  |  |     return len(ids) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class InstancingTestCase(unittest.TestCase, HelperMixin): | 
					
						
							|  |  |  |     intobj = 123321 | 
					
						
							|  |  |  |     floatobj = 1.2345 | 
					
						
							|  |  |  |     strobj = "abcde"*3 | 
					
						
							|  |  |  |     dictobj = {"hello":floatobj, "goodbye":floatobj, floatobj:"hello"} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def helper3(self, rsample, recursive=False, simple=False): | 
					
						
							|  |  |  |         #we have two instances | 
					
						
							|  |  |  |         sample = (rsample, rsample) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         n0 = CollectObjectIDs(set(), sample) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         s3 = marshal.dumps(sample, 3) | 
					
						
							|  |  |  |         n3 = CollectObjectIDs(set(), marshal.loads(s3)) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         #same number of instances generated | 
					
						
							|  |  |  |         self.assertEqual(n3, n0) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if not recursive: | 
					
						
							|  |  |  |             #can compare with version 2 | 
					
						
							|  |  |  |             s2 = marshal.dumps(sample, 2) | 
					
						
							|  |  |  |             n2 = CollectObjectIDs(set(), marshal.loads(s2)) | 
					
						
							|  |  |  |             #old format generated more instances | 
					
						
							|  |  |  |             self.assertGreater(n2, n0) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             #if complex objects are in there, old format is larger | 
					
						
							|  |  |  |             if not simple: | 
					
						
							|  |  |  |                 self.assertGreater(len(s2), len(s3)) | 
					
						
							|  |  |  |             else: | 
					
						
							|  |  |  |                 self.assertGreaterEqual(len(s2), len(s3)) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def testInt(self): | 
					
						
							|  |  |  |         self.helper(self.intobj) | 
					
						
							|  |  |  |         self.helper3(self.intobj, simple=True) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def testFloat(self): | 
					
						
							|  |  |  |         self.helper(self.floatobj) | 
					
						
							|  |  |  |         self.helper3(self.floatobj) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def testStr(self): | 
					
						
							|  |  |  |         self.helper(self.strobj) | 
					
						
							|  |  |  |         self.helper3(self.strobj) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def testDict(self): | 
					
						
							|  |  |  |         self.helper(self.dictobj) | 
					
						
							|  |  |  |         self.helper3(self.dictobj) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def testModule(self): | 
					
						
							|  |  |  |         with open(__file__, "rb") as f: | 
					
						
							|  |  |  |             code = f.read() | 
					
						
							|  |  |  |         if __file__.endswith(".py"): | 
					
						
							|  |  |  |             code = compile(code, __file__, "exec") | 
					
						
							|  |  |  |         self.helper(code) | 
					
						
							|  |  |  |         self.helper3(code) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def testRecursion(self): | 
					
						
							|  |  |  |         d = dict(self.dictobj) | 
					
						
							|  |  |  |         d["self"] = d | 
					
						
							|  |  |  |         self.helper3(d, recursive=True) | 
					
						
							|  |  |  |         l = [self.dictobj] | 
					
						
							|  |  |  |         l.append(l) | 
					
						
							|  |  |  |         self.helper3(l, recursive=True) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class CompatibilityTestCase(unittest.TestCase): | 
					
						
							|  |  |  |     def _test(self, version): | 
					
						
							|  |  |  |         with open(__file__, "rb") as f: | 
					
						
							|  |  |  |             code = f.read() | 
					
						
							|  |  |  |         if __file__.endswith(".py"): | 
					
						
							|  |  |  |             code = compile(code, __file__, "exec") | 
					
						
							|  |  |  |         data = marshal.dumps(code, version) | 
					
						
							|  |  |  |         marshal.loads(data) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def test0To3(self): | 
					
						
							|  |  |  |         self._test(0) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def test1To3(self): | 
					
						
							|  |  |  |         self._test(1) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def test2To3(self): | 
					
						
							|  |  |  |         self._test(2) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def test3To3(self): | 
					
						
							|  |  |  |         self._test(3) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class InterningTestCase(unittest.TestCase, HelperMixin): | 
					
						
							|  |  |  |     strobj = "this is an interned string" | 
					
						
							|  |  |  |     strobj = sys.intern(strobj) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def testIntern(self): | 
					
						
							|  |  |  |         s = marshal.loads(marshal.dumps(self.strobj)) | 
					
						
							|  |  |  |         self.assertEqual(s, self.strobj) | 
					
						
							|  |  |  |         self.assertEqual(id(s), id(self.strobj)) | 
					
						
							|  |  |  |         s2 = sys.intern(s) | 
					
						
							|  |  |  |         self.assertEqual(id(s2), id(s)) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def testNoIntern(self): | 
					
						
							|  |  |  |         s = marshal.loads(marshal.dumps(self.strobj, 2)) | 
					
						
							|  |  |  |         self.assertEqual(s, self.strobj) | 
					
						
							|  |  |  |         self.assertNotEqual(id(s), id(self.strobj)) | 
					
						
							|  |  |  |         s2 = sys.intern(s) | 
					
						
							|  |  |  |         self.assertNotEqual(id(s2), id(s)) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-06 08:58:56 +02:00
										 |  |  | @support.cpython_only | 
					
						
							|  |  |  | @unittest.skipUnless(_testcapi, 'requires _testcapi') | 
					
						
							|  |  |  | class CAPI_TestCase(unittest.TestCase, HelperMixin): | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def test_write_long_to_file(self): | 
					
						
							|  |  |  |         for v in range(marshal.version + 1): | 
					
						
							|  |  |  |             _testcapi.pymarshal_write_long_to_file(0x12345678, support.TESTFN, v) | 
					
						
							|  |  |  |             with open(support.TESTFN, 'rb') as f: | 
					
						
							|  |  |  |                 data = f.read() | 
					
						
							|  |  |  |             support.unlink(support.TESTFN) | 
					
						
							|  |  |  |             self.assertEqual(data, b'\x78\x56\x34\x12') | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def test_write_object_to_file(self): | 
					
						
							|  |  |  |         obj = ('\u20ac', b'abc', 123, 45.6, 7+8j, 'long line '*1000) | 
					
						
							|  |  |  |         for v in range(marshal.version + 1): | 
					
						
							|  |  |  |             _testcapi.pymarshal_write_object_to_file(obj, support.TESTFN, v) | 
					
						
							|  |  |  |             with open(support.TESTFN, 'rb') as f: | 
					
						
							|  |  |  |                 data = f.read() | 
					
						
							|  |  |  |             support.unlink(support.TESTFN) | 
					
						
							|  |  |  |             self.assertEqual(marshal.loads(data), obj) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def test_read_short_from_file(self): | 
					
						
							|  |  |  |         with open(support.TESTFN, 'wb') as f: | 
					
						
							|  |  |  |             f.write(b'\x34\x12xxxx') | 
					
						
							|  |  |  |         r, p = _testcapi.pymarshal_read_short_from_file(support.TESTFN) | 
					
						
							|  |  |  |         support.unlink(support.TESTFN) | 
					
						
							|  |  |  |         self.assertEqual(r, 0x1234) | 
					
						
							|  |  |  |         self.assertEqual(p, 2) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         with open(support.TESTFN, 'wb') as f: | 
					
						
							|  |  |  |             f.write(b'\x12') | 
					
						
							|  |  |  |         with self.assertRaises(EOFError): | 
					
						
							|  |  |  |             _testcapi.pymarshal_read_short_from_file(support.TESTFN) | 
					
						
							|  |  |  |         support.unlink(support.TESTFN) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def test_read_long_from_file(self): | 
					
						
							|  |  |  |         with open(support.TESTFN, 'wb') as f: | 
					
						
							|  |  |  |             f.write(b'\x78\x56\x34\x12xxxx') | 
					
						
							|  |  |  |         r, p = _testcapi.pymarshal_read_long_from_file(support.TESTFN) | 
					
						
							|  |  |  |         support.unlink(support.TESTFN) | 
					
						
							|  |  |  |         self.assertEqual(r, 0x12345678) | 
					
						
							|  |  |  |         self.assertEqual(p, 4) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         with open(support.TESTFN, 'wb') as f: | 
					
						
							|  |  |  |             f.write(b'\x56\x34\x12') | 
					
						
							|  |  |  |         with self.assertRaises(EOFError): | 
					
						
							|  |  |  |             _testcapi.pymarshal_read_long_from_file(support.TESTFN) | 
					
						
							|  |  |  |         support.unlink(support.TESTFN) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def test_read_last_object_from_file(self): | 
					
						
							|  |  |  |         obj = ('\u20ac', b'abc', 123, 45.6, 7+8j) | 
					
						
							|  |  |  |         for v in range(marshal.version + 1): | 
					
						
							|  |  |  |             data = marshal.dumps(obj, v) | 
					
						
							|  |  |  |             with open(support.TESTFN, 'wb') as f: | 
					
						
							|  |  |  |                 f.write(data + b'xxxx') | 
					
						
							|  |  |  |             r, p = _testcapi.pymarshal_read_last_object_from_file(support.TESTFN) | 
					
						
							|  |  |  |             support.unlink(support.TESTFN) | 
					
						
							|  |  |  |             self.assertEqual(r, obj) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             with open(support.TESTFN, 'wb') as f: | 
					
						
							|  |  |  |                 f.write(data[:1]) | 
					
						
							|  |  |  |             with self.assertRaises(EOFError): | 
					
						
							|  |  |  |                 _testcapi.pymarshal_read_last_object_from_file(support.TESTFN) | 
					
						
							|  |  |  |             support.unlink(support.TESTFN) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def test_read_object_from_file(self): | 
					
						
							|  |  |  |         obj = ('\u20ac', b'abc', 123, 45.6, 7+8j) | 
					
						
							|  |  |  |         for v in range(marshal.version + 1): | 
					
						
							|  |  |  |             data = marshal.dumps(obj, v) | 
					
						
							|  |  |  |             with open(support.TESTFN, 'wb') as f: | 
					
						
							|  |  |  |                 f.write(data + b'xxxx') | 
					
						
							|  |  |  |             r, p = _testcapi.pymarshal_read_object_from_file(support.TESTFN) | 
					
						
							|  |  |  |             support.unlink(support.TESTFN) | 
					
						
							|  |  |  |             self.assertEqual(r, obj) | 
					
						
							|  |  |  |             self.assertEqual(p, len(data)) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             with open(support.TESTFN, 'wb') as f: | 
					
						
							|  |  |  |                 f.write(data[:1]) | 
					
						
							|  |  |  |             with self.assertRaises(EOFError): | 
					
						
							|  |  |  |                 _testcapi.pymarshal_read_object_from_file(support.TESTFN) | 
					
						
							|  |  |  |             support.unlink(support.TESTFN) | 
					
						
							| 
									
										
											  
											
												Merged revisions 62998-63003,63005-63006,63009-63012,63014-63017,63019-63020,63022-63024,63026-63029,63031-63041,63043-63045,63047-63054,63056-63062 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
  r62998 | andrew.kuchling | 2008-05-10 15:51:55 -0400 (Sat, 10 May 2008) | 7 lines
  #1858 from Tarek Ziade:
  Allow multiple repositories in .pypirc; see http://wiki.python.org/moin/EnhancedPyPI
  for discussion.
  The patch is slightly revised from Tarek's last patch: I've simplified
  the PyPIRCCommand.finalize_options() method to not look at sys.argv.
  Tests still pass.
........
  r63000 | alexandre.vassalotti | 2008-05-10 15:59:16 -0400 (Sat, 10 May 2008) | 5 lines
  Cleaned up io._BytesIO.write().
  I am amazed that the old code, for inserting null-bytes, actually
  worked. Who wrote that thing? Oh, it is me... doh.
........
  r63002 | brett.cannon | 2008-05-10 16:52:01 -0400 (Sat, 10 May 2008) | 2 lines
  Revert r62998 as it broke the build (seems distutils.config is missing).
........
  r63014 | andrew.kuchling | 2008-05-10 18:12:38 -0400 (Sat, 10 May 2008) | 1 line
  #1858: add distutils.config module
........
  r63027 | brett.cannon | 2008-05-10 21:09:32 -0400 (Sat, 10 May 2008) | 2 lines
  Flesh out the 3.0 deprecation to suggest using the ctypes module.
........
  r63028 | skip.montanaro | 2008-05-10 22:59:30 -0400 (Sat, 10 May 2008) | 4 lines
  Copied two versions of the example from the interactive session.  Delete
  one.
........
  r63037 | georg.brandl | 2008-05-11 03:02:17 -0400 (Sun, 11 May 2008) | 2 lines
  reload() takes the module itself.
........
  r63038 | alexandre.vassalotti | 2008-05-11 03:06:04 -0400 (Sun, 11 May 2008) | 4 lines
  Added test framework for handling module renames.
  Factored the import guard in test_py3kwarn.TestStdlibRemovals into
  a context manager, namely test_support.CleanImport.
........
  r63039 | georg.brandl | 2008-05-11 03:06:05 -0400 (Sun, 11 May 2008) | 2 lines
  #2742: ``''`` is not converted to NULL in getaddrinfo.
........
  r63040 | alexandre.vassalotti | 2008-05-11 03:08:12 -0400 (Sun, 11 May 2008) | 2 lines
  Fixed typo in a comment of test_support.CleanImport.
........
  r63041 | alexandre.vassalotti | 2008-05-11 03:10:25 -0400 (Sun, 11 May 2008) | 2 lines
  Removed a dead line of code.
........
  r63043 | georg.brandl | 2008-05-11 04:47:53 -0400 (Sun, 11 May 2008) | 2 lines
  #2812: document property.getter/setter/deleter.
........
  r63049 | georg.brandl | 2008-05-11 05:06:30 -0400 (Sun, 11 May 2008) | 2 lines
  #1153769: document PEP 237 changes to string formatting.
........
  r63050 | georg.brandl | 2008-05-11 05:11:40 -0400 (Sun, 11 May 2008) | 2 lines
  #2809: elaborate str.split docstring a bit.
........
  r63051 | georg.brandl | 2008-05-11 06:13:59 -0400 (Sun, 11 May 2008) | 2 lines
  Fix typo.
........
  r63052 | georg.brandl | 2008-05-11 06:33:27 -0400 (Sun, 11 May 2008) | 2 lines
  #2709: clarification.
........
  r63053 | georg.brandl | 2008-05-11 06:42:28 -0400 (Sun, 11 May 2008) | 2 lines
  #2659: add ``break_on_hyphens`` to TextWrapper.
........
  r63057 | georg.brandl | 2008-05-11 06:59:39 -0400 (Sun, 11 May 2008) | 2 lines
  #2741: clarification of value range for address_family.
........
  r63058 | georg.brandl | 2008-05-11 07:09:35 -0400 (Sun, 11 May 2008) | 2 lines
  #2452: timeout is used for all blocking operations.
........
  r63059 | andrew.kuchling | 2008-05-11 09:33:56 -0400 (Sun, 11 May 2008) | 2 lines
  #1792: Improve performance of marshal.dumps() on large objects by increasing
  the size of the buffer more quickly.
........
  r63060 | andrew.kuchling | 2008-05-11 10:00:00 -0400 (Sun, 11 May 2008) | 1 line
  #1858: re-apply patch for this, adding the missing files
........
  r63061 | benjamin.peterson | 2008-05-11 10:13:25 -0400 (Sun, 11 May 2008) | 2 lines
  Add the "until" command to pdb
........
  r63062 | georg.brandl | 2008-05-11 10:17:13 -0400 (Sun, 11 May 2008) | 2 lines
  Add some sentence endings.
........
											
										 
											2008-05-16 00:03:33 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-08-02 15:02:33 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | if __name__ == "__main__": | 
					
						
							| 
									
										
										
										
											2015-02-06 08:58:56 +02:00
										 |  |  |     unittest.main() |