Recent py3k version has new feature "hash randomization" it solves some security issues. But has some drawbacks, for instance, dict.items() order is now unknown. So it breaks randomly some doctests that rely on exact order of dict items. vitja@mchome:~/python$ ./py3k/bin/python -c "print({'a':1, 'b':2})" {'b': 2, 'a': 1} vitja@mchome:~/python$ ./py3k/bin/python -c "print({'a':1, 'b':2})" {'a': 1, 'b': 2} As a workaround we can set PYTHONHASHSEED environment variable to zero for all cyhon-*-tests targets This also affects generated code it internally depends on order of items returned by dict.items() -- vitja.
On 23 February 2012 20:52, Vitja Makarov <vitja.makarov@gmail.com> wrote:
Recent py3k version has new feature "hash randomization" it solves some security issues. But has some drawbacks, for instance, dict.items() order is now unknown. So it breaks randomly some doctests that rely on exact order of dict items.
vitja@mchome:~/python$ ./py3k/bin/python -c "print({'a':1, 'b':2})" {'b': 2, 'a': 1} vitja@mchome:~/python$ ./py3k/bin/python -c "print({'a':1, 'b':2})" {'a': 1, 'b': 2}
As a workaround we can set PYTHONHASHSEED environment variable to zero for all cyhon-*-tests targets
This also affects generated code it internally depends on order of items returned by dict.items()
Any code or test that relies on dictionary order is wrong, really. So I assume any pyregr issues will be fixed by the CPython test suite? If there are any such failing tests in Cython we should simply fix them.
-- vitja. _______________________________________________ cython-devel mailing list cython-devel@python.org http://mail.python.org/mailman/listinfo/cython-devel
2012/2/24 mark florisson <markflorisson88@gmail.com>:
On 23 February 2012 20:52, Vitja Makarov <vitja.makarov@gmail.com> wrote:
Recent py3k version has new feature "hash randomization" it solves some security issues. But has some drawbacks, for instance, dict.items() order is now unknown. So it breaks randomly some doctests that rely on exact order of dict items.
vitja@mchome:~/python$ ./py3k/bin/python -c "print({'a':1, 'b':2})" {'b': 2, 'a': 1} vitja@mchome:~/python$ ./py3k/bin/python -c "print({'a':1, 'b':2})" {'a': 1, 'b': 2}
As a workaround we can set PYTHONHASHSEED environment variable to zero for all cyhon-*-tests targets
This also affects generated code it internally depends on order of items returned by dict.items()
Any code or test that relies on dictionary order is wrong, really. So I assume any pyregr issues will be fixed by the CPython test suite? If there are any such failing tests in Cython we should simply fix them.
Yes, you're right but I'm not sure how many tests may be broken. I don't think we want to fix them before release. Now I've added # Disable python hash randomization export PYTHONHASHSEED=0 to cython-devel-tests and it worked. It's not that easy to fix, here is simple doctest: def test_foo(): """ >>> test_foo() {'a': 1, 'b': 2} """ return {'a': 1, 'b': 2} You can't use dicts in doctests anymore there are few options instead: 1. Compare sorted items(), e.g. sorted(test_foo().items()) 2. Inplace compare test_foo() == {...} -- vitja.
Vitja Makarov, 24.02.2012 06:24:
2012/2/24 mark florisson <markflorisson88@gmail.com>:
On 23 February 2012 20:52, Vitja Makarov <vitja.makarov@gmail.com> wrote:
Recent py3k version has new feature "hash randomization" it solves some security issues. But has some drawbacks, for instance, dict.items() order is now unknown. So it breaks randomly some doctests that rely on exact order of dict items.
vitja@mchome:~/python$ ./py3k/bin/python -c "print({'a':1, 'b':2})" {'b': 2, 'a': 1} vitja@mchome:~/python$ ./py3k/bin/python -c "print({'a':1, 'b':2})" {'a': 1, 'b': 2}
As a workaround we can set PYTHONHASHSEED environment variable to zero for all cyhon-*-tests targets
This also affects generated code it internally depends on order of items returned by dict.items()
Any code or test that relies on dictionary order is wrong, really. So I assume any pyregr issues will be fixed by the CPython test suite?
Definitely.
If there are any such failing tests in Cython we should simply fix them.
Yes, you're right but I'm not sure how many tests may be broken. I don't think we want to fix them before release. Now I've added
# Disable python hash randomization export PYTHONHASHSEED=0
to cython-devel-tests and it worked.
That should only be a work-around until all tests are fixed, though.
It's not that easy to fix, here is simple doctest:
def test_foo(): """ >>> test_foo() {'a': 1, 'b': 2} """ return {'a': 1, 'b': 2}
You can't use dicts in doctests anymore there are few options instead: 1. Compare sorted items(), e.g. sorted(test_foo().items()) 2. Inplace compare test_foo() == {...}
I always use 1) because it gives you better test failure output in doctests. Stefan
2012/2/24 Stefan Behnel <stefan_ml@behnel.de>:
Vitja Makarov, 24.02.2012 06:24:
2012/2/24 mark florisson <markflorisson88@gmail.com>:
On 23 February 2012 20:52, Vitja Makarov <vitja.makarov@gmail.com> wrote:
Recent py3k version has new feature "hash randomization" it solves some security issues. But has some drawbacks, for instance, dict.items() order is now unknown. So it breaks randomly some doctests that rely on exact order of dict items.
vitja@mchome:~/python$ ./py3k/bin/python -c "print({'a':1, 'b':2})" {'b': 2, 'a': 1} vitja@mchome:~/python$ ./py3k/bin/python -c "print({'a':1, 'b':2})" {'a': 1, 'b': 2}
As a workaround we can set PYTHONHASHSEED environment variable to zero for all cyhon-*-tests targets
This also affects generated code it internally depends on order of items returned by dict.items()
Any code or test that relies on dictionary order is wrong, really. So I assume any pyregr issues will be fixed by the CPython test suite?
Definitely.
Ok, I'll take a look.
If there are any such failing tests in Cython we should simply fix them.
Yes, you're right but I'm not sure how many tests may be broken. I don't think we want to fix them before release. Now I've added
# Disable python hash randomization export PYTHONHASHSEED=0
to cython-devel-tests and it worked.
That should only be a work-around until all tests are fixed, though.
It's not that easy to fix, here is simple doctest:
def test_foo(): """ >>> test_foo() {'a': 1, 'b': 2} """ return {'a': 1, 'b': 2}
You can't use dicts in doctests anymore there are few options instead: 1. Compare sorted items(), e.g. sorted(test_foo().items()) 2. Inplace compare test_foo() == {...}
I always use 1) because it gives you better test failure output in doctests.
-- vitja.
2012/2/24 Vitja Makarov <vitja.makarov@gmail.com>:
2012/2/24 Stefan Behnel <stefan_ml@behnel.de>:
Vitja Makarov, 24.02.2012 06:24:
2012/2/24 mark florisson <markflorisson88@gmail.com>:
On 23 February 2012 20:52, Vitja Makarov <vitja.makarov@gmail.com> wrote:
Recent py3k version has new feature "hash randomization" it solves some security issues. But has some drawbacks, for instance, dict.items() order is now unknown. So it breaks randomly some doctests that rely on exact order of dict items.
vitja@mchome:~/python$ ./py3k/bin/python -c "print({'a':1, 'b':2})" {'b': 2, 'a': 1} vitja@mchome:~/python$ ./py3k/bin/python -c "print({'a':1, 'b':2})" {'a': 1, 'b': 2}
As a workaround we can set PYTHONHASHSEED environment variable to zero for all cyhon-*-tests targets
This also affects generated code it internally depends on order of items returned by dict.items()
Any code or test that relies on dictionary order is wrong, really. So I assume any pyregr issues will be fixed by the CPython test suite?
Definitely.
Ok, I'll take a look.
If there are any such failing tests in Cython we should simply fix them.
Yes, you're right but I'm not sure how many tests may be broken. I don't think we want to fix them before release. Now I've added
# Disable python hash randomization export PYTHONHASHSEED=0
to cython-devel-tests and it worked.
That should only be a work-around until all tests are fixed, though.
It's not that easy to fix, here is simple doctest:
def test_foo(): """ >>> test_foo() {'a': 1, 'b': 2} """ return {'a': 1, 'b': 2}
You can't use dicts in doctests anymore there are few options instead: 1. Compare sorted items(), e.g. sorted(test_foo().items()) 2. Inplace compare test_foo() == {...}
I always use 1) because it gives you better test failure output in doctests.
I fixed tests. -- vitja.
participants (3)
-
mark florisson -
Stefan Behnel -
Vitja Makarov