New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove randomness dependency on PYTHONHASHSEED #363
Comments
Thank for the report @adamchainz I think The issue is with specific providers that declare weighted elements as Additionally, I think this is something that should be mentioned in docs, including examples and docstrings. |
Just realized |
I wouldn't exclude dropping support for 2.6, but I need @joke2k 's opinion on that. |
You could always introduce a Python 2.6 dependency on the |
Thanks @kevin-brown , probably the best solution |
FWIW, dropping support for python 2.6 would also allows us to stop including importing |
+1 for dropping 2.6. Anyone who wants to stay on 2.6 at this point is more likely just maintaining an app and not writing something new, so they can just use an old version of |
Ref joke2k#363, required so we can use `OrderedDict` without an extra dependency, plus it's super old and insecure.
Ref joke2k#363, required so we can use `OrderedDict` without an extra dependency, plus it's super old and insecure.
Ref #363, required so we can use `OrderedDict` without an extra dependency, plus it's super old and insecure.
Address #363. Replace `dicts` with `OrderedDict`s
I think this might have been fixed in #384. Leaving this open for now in case I've missined something. I will close next week is there's nothing wrong |
Only allow providers to use `OrderedDict`s, to avoid any more `PYTHONHASHSEED` problems. Ref joke2k#363.
Awesome, thanks for the tedious PR. I started on one but there were so many dicts to convert, then I was away for a bit. One thing my local changes make is to ban |
Only allow providers to use `OrderedDict`s, to avoid any more `PYTHONHASHSEED` problems. Ref #363.
Only allow providers to use `OrderedDict`s, to avoid any more `PYTHONHASHSEED` problems. Ref joke2k#363.
Only allow providers to use `OrderedDict`s, to avoid any more `PYTHONHASHSEED` problems. Ref joke2k#363.
Only allow providers to use `OrderedDict`s, to avoid any more `PYTHONHASHSEED` problems. Ref joke2k#363.
Only allow providers to use `OrderedDict`s, to avoid any more `PYTHONHASHSEED` problems. Ref joke2k#363.
Only allow providers to use `OrderedDict`s, to avoid any more `PYTHONHASHSEED` problems. Ref #363. # Conflicts: # faker/providers/__init__.py # faker/tests/__init__.py
Today I was informed by the error message that the |
@timschwab Thanks for pointing that out. Being able to use |
@timschwab did you ever get around to writing that change? |
Hey @fdemmer unfortunately no, I got pulled away from the project. |
We're using
faker
extensively in our test suite withfactory-boy
to generate dummy data. I love it! To help with repeatability in tests, I developed the pytest pluginpytest-randomly
to allow re-using therandom
seed between test runs, so if they fail we can reuse the seed to get back the same random data fromfaker
and debug the test.Unfortunately we're moving from Python 2 to 3 and this includes activating
PYTHONHASHSEED
by default. We're currently trying to add it on Python 2 so that we're ready.Since
PYTHONHASHSEED
means that dictionary iteration order is random, it means that anything that depends on this breaks. This is generally good as if you really depend on the iteration order, you should use a different data structure.Unfortunately the way Faker generates some random data (specifically I've found
random_element
when using adict
) is affected by dictionary iteration order. This means that fixing the random seed for therandom
module isn't enough, and one would need to fixPYTHONHASHSEED
too. What a pain! It's also quite hard to do since there isn't a way inside a python process to query what the value ofPYTHONHASHSEED
is, unless it was explicitly set as an environment variable as opposed to set to'random'
.I think it would be better if Faker just didn't depend on dictionary iteration order, so its random data is also repeatable. This should be possible in most cases by swapping
dict
forOrderedDict
.The text was updated successfully, but these errors were encountered: