This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: test_repr (test.test_functools.TestPartialC) failures
Type: behavior Stage: resolved
Components: Tests Versions: Python 3.4, Python 3.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: BreamoreBoy, berker.peksag, christian.heimes, ncoghlan, python-dev, rhettinger, serhiy.storchaka, vstinner
Priority: high Keywords: needs review, patch

Created on 2013-11-21 14:34 by christian.heimes, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
issue19681.patch serhiy.storchaka, 2013-11-21 18:06 review
test_functools_repr.patch vstinner, 2013-11-21 22:51 review
test_functools_repr2.patch vstinner, 2013-11-21 23:23 review
issue19681_2.patch serhiy.storchaka, 2013-12-09 16:44 review
Messages (19)
msg203632 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2013-11-21 14:34
test_repr of test.test_functools.TestPartialC fails sometimes because the test scenario depends on the order of items in a Python dict. The order is not stable and may change. Before PEP 456 was committed the order of items was stable most of the time. Nowadays the random seed has an impact on the order.

http://buildbot.python.org/all/builders/x86%20XP-4%203.x/builds/9609

======================================================================
FAIL: test_repr (test.test_functools.TestPartialC)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "D:\cygwin\home\db3l\buildarea\3.x.bolen-windows\build\lib\test\test_functools.py", line 174, in test_repr
    repr(f))
AssertionError: 'func[43 chars]D8>, b=<object object at 0x09D08B48>, a=<objec[20 chars]28>)' != 'func[43 chars]D8>, a=<object object at 0x09D08B28>, b=<objec[20 chars]48>)'
- functools.partial(<function capture at 0x0A2A72D8>, b=<object object at 0x09D08B48>, a=<object object at 0x09D08B28>)
+ functools.partial(<function capture at 0x0A2A72D8>, a=<object object at 0x09D08B28>, b=<object object at 0x09D08B48>)


======================================================================
FAIL: test_repr (test.test_functools.TestPartialCSubclass)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "D:\cygwin\home\db3l\buildarea\3.x.bolen-windows\build\lib\test\test_functools.py", line 174, in test_repr
    repr(f))
AssertionError: 'Part[41 chars]D8>, b=<object object at 0x09D08DC8>, a=<objec[20 chars]A8>)' != 'Part[41 chars]D8>, a=<object object at 0x09D08BA8>, b=<objec[20 chars]C8>)'
- PartialSubclass(<function capture at 0x0A2A72D8>, b=<object object at 0x09D08DC8>, a=<object object at 0x09D08BA8>)
+ PartialSubclass(<function capture at 0x0A2A72D8>, a=<object object at 0x09D08BA8>, b=<object object at 0x09D08DC8>)
msg203641 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2013-11-21 15:36
The issue is causing flaky build bots and should be resolved soonish. I don't know what's the best way to fix the problem. Either the test needs to change or partial_repr() must print the keys in sorted order.
msg203644 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2013-11-21 15:43
The repr test of userdict fails sometimes, too.

http://buildbot.python.org/all/builders/AMD64%20Ubuntu%20LTS%203.x/builds/3120/steps/test/logs/stdio

======================================================================
FAIL: test_all (test.test_userdict.UserDictTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/opt/python/3.x.langa-ubuntu/build/Lib/test/test_userdict.py", line 48, in test_all
    self.assertEqual(repr(u2), repr(d2))
AssertionError: "{'one': 1, 'two': 2}" != "{'two': 2, 'one': 1}"
- {'one': 1, 'two': 2}
+ {'two': 2, 'one': 1}
msg203646 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2013-11-21 15:48
See issue #19664 for userdict.
msg203661 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-11-21 18:06
Here is a patch for test_functools.
msg203690 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2013-11-21 22:51
permutation() looks overkill to me for such trivial test.

Here is a simpler approach: remove the second keyword :-) test_functools_repr.patch
msg203693 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2013-11-21 23:00
I'm for Victors patch. Let's not get too fancy with tests.
msg203695 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2013-11-21 23:02
I'm pretty sure the second keyword is there to ensure the repr includes the
appropriate commas. Can we just make a suitable dict and check the key
order?
msg203696 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2013-11-21 23:10
And actually re-reading the existing code to see it already works that
way... how can two dicts with the same keys, without any extra keys being
added and deleted in either have different iteration orders? If it's just a
matter of copying the original dict changing the order, then we should be
able to restore consistency by copying it when building the expected repr
as well.
msg203697 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2013-11-21 23:23
Ok, here is a different patch sorting keywords. So it still checks how the C code joins keyword parameters.
msg203698 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2013-11-21 23:26
Both keys happen to have the same LSB bytes. I have added "print(hash('a') & 7, hash('b') & 7)" to the code and run test tests multiple times:

$ ./python -m test -m test_repr test_functools
[1/1] test_functools
3 6
3 6
1 test OK.
$ ./python -m test -m test_repr test_functools
[1/1] test_functools
2 2
2 2
test test_functools failed -- multiple errors occurred; run in verbose mode for details
1 test failed:
    test_functools
msg203705 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-11-22 00:22
New changeset 18a44d65d34a by Christian Heimes in branch 'default':
Issue #19681: Apply a quick and minimal band-aid.
http://hg.python.org/cpython/rev/18a44d65d34a
msg205701 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-12-09 15:13
What is the status of this issue?
msg205702 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2013-12-09 15:17
It still needs a proper fix, though.
msg205710 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-12-09 16:44
If you don't like permutation() (which already imported in this file), here is a patch which uses explicit hardcoded permutations.
msg221690 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2014-06-27 14:48
The latest patch looks okay to my eye, can somebody do a formal commit review please.
msg234851 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2015-01-27 20:57
Ping.
msg234854 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2015-01-27 22:09
issue19681_2.patch LGTM.
msg236041 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2015-02-15 14:22
New changeset 138c2afd9f1f by Serhiy Storchaka in branch '3.4':
Issue #19681: Test the repr of partial with more than one keyword argument.
https://hg.python.org/cpython/rev/138c2afd9f1f

New changeset 6f80e8bcb5ad by Serhiy Storchaka in branch 'default':
Issue #19681: Test the repr of partial with more than one keyword argument.
https://hg.python.org/cpython/rev/6f80e8bcb5ad
History
Date User Action Args
2022-04-11 14:57:53adminsetgithub: 63880
2015-02-15 14:24:28serhiy.storchakasetstatus: open -> closed
resolution: fixed
stage: commit review -> resolved
2015-02-15 14:22:56python-devsetmessages: + msg236041
2015-01-27 22:09:27berker.peksagsetversions: + Python 3.5
nosy: + berker.peksag

messages: + msg234854

stage: patch review -> commit review
2015-01-27 20:57:04serhiy.storchakasetkeywords: + needs review

messages: + msg234851
stage: needs patch -> patch review
2014-06-27 14:48:49BreamoreBoysetnosy: + BreamoreBoy
messages: + msg221690
2013-12-09 16:44:49serhiy.storchakasetfiles: + issue19681_2.patch

messages: + msg205710
2013-12-09 15:17:12christian.heimessetmessages: + msg205702
2013-12-09 15:13:07serhiy.storchakasetmessages: + msg205701
2013-11-22 00:22:57python-devsetnosy: + python-dev
messages: + msg203705
2013-11-21 23:26:04christian.heimessetmessages: + msg203698
2013-11-21 23:23:58vstinnersetfiles: + test_functools_repr2.patch

messages: + msg203697
2013-11-21 23:10:51ncoghlansetmessages: + msg203696
2013-11-21 23:02:14ncoghlansetmessages: + msg203695
2013-11-21 23:00:11christian.heimessetmessages: + msg203693
2013-11-21 22:51:46vstinnersetfiles: + test_functools_repr.patch

messages: + msg203690
2013-11-21 18:06:19serhiy.storchakasetfiles: + issue19681.patch

nosy: + serhiy.storchaka
messages: + msg203661

keywords: + patch
2013-11-21 15:48:20vstinnersetmessages: + msg203646
2013-11-21 15:43:59christian.heimessetmessages: + msg203644
2013-11-21 15:36:55christian.heimessetpriority: normal -> high

nosy: + rhettinger, ncoghlan, vstinner
messages: + msg203641

type: behavior
stage: needs patch
2013-11-21 14:34:36christian.heimescreate