django/django — pull request #861 by ambv (2013-02-27 03:43:09+00:00)
Title: Python 3: make sure hashlib always gets bytes

Tests pass on 2.7 and 3.3 (double-checked this time, Carl ;-) ).

Occurrences and consequences without the patch:

- `utils.cache`: `CacheMiddleware` fails or every user
- `utils.crypto`: generating a random string on machines without a system PRNG fails
- `template.loaders.cached`: generating a cache key with template_dirs fails (although method to trigger the bug on a real application is unknown: `TEMPLATE_DIRS` are only used in `template.loaders.filesystem`)

There are tests for `utils.cache`. There are currently no tests for a PRNG-less `utils.crypto` and without mocking the `random` module there is no way of triggering this code. As for `template.loaders.cached` I could not find a path of execution that would lead to using the `template_dirs` kwarg (dead code?).

If you require tests for those two obscure latter cases, let me know.