changeset: 106299:2bd2ef1696cf branch: 3.5 parent: 106293:75e341d79c99 user: Serhiy Storchaka date: Tue Jan 24 20:49:26 2017 +0200 files: Lib/test/test_compile.py Misc/NEWS Objects/codeobject.c description: Issue #29337: Fixed possible BytesWarning when compare the code objects. Warnings could be emitted at compile time. diff -r 75e341d79c99 -r 2bd2ef1696cf Lib/test/test_compile.py --- a/Lib/test/test_compile.py Tue Jan 24 00:26:56 2017 +0000 +++ b/Lib/test/test_compile.py Tue Jan 24 20:49:26 2017 +0200 @@ -634,6 +634,7 @@ f1 = ns['f1'] f2 = ns['f2'] self.assertIsNot(f1.__code__, f2.__code__) + self.assertNotEqual(f1.__code__, f2.__code__) self.check_constant(f1, const1) self.check_constant(f2, const2) self.assertEqual(repr(f1()), repr(const1)) @@ -642,6 +643,8 @@ check_different_constants(0, 0.0) check_different_constants(+0.0, -0.0) check_different_constants((0,), (0.0,)) + check_different_constants('a', b'a') + check_different_constants(('a',), (b'a',)) # check_different_constants() cannot be used because repr(-0j) is # '(-0-0j)', but when '(-0-0j)' is evaluated to 0j: we loose the sign. diff -r 75e341d79c99 -r 2bd2ef1696cf Misc/NEWS --- a/Misc/NEWS Tue Jan 24 00:26:56 2017 +0000 +++ b/Misc/NEWS Tue Jan 24 20:49:26 2017 +0200 @@ -10,6 +10,9 @@ Core and Builtins ----------------- +- Issue #29337: Fixed possible BytesWarning when compare the code objects. + Warnings could be emitted at compile time. + Library ------- diff -r 75e341d79c99 -r 2bd2ef1696cf Objects/codeobject.c --- a/Objects/codeobject.c Tue Jan 24 00:26:56 2017 +0000 +++ b/Objects/codeobject.c Tue Jan 24 20:49:26 2017 +0200 @@ -521,7 +521,7 @@ PyTuple_SET_ITEM(tuple, i, item_key); } - key = PyTuple_Pack(3, Py_TYPE(op), op, tuple); + key = PyTuple_Pack(2, tuple, op); Py_DECREF(tuple); } else if (PyFrozenSet_CheckExact(op)) { @@ -555,7 +555,7 @@ if (set == NULL) return NULL; - key = PyTuple_Pack(3, Py_TYPE(op), op, set); + key = PyTuple_Pack(2, set, op); Py_DECREF(set); return key; } @@ -566,7 +566,7 @@ if (obj_id == NULL) return NULL; - key = PyTuple_Pack(3, Py_TYPE(op), op, obj_id); + key = PyTuple_Pack(2, obj_id, op); Py_DECREF(obj_id); } return key;