maxcountryman/flask-bcrypt — pull request #19 by fgimian (2014-02-12 01:48:32+00:00)
Title: Python 3 support (another attempt)

Hey there,

My version of Python 3 support gets closer to passing all tests with one problem remaining; the **test_check_hash_unicode_is_utf8** test fails on Python 3.3. Unfortunately, I think it may be literally impossible to get this to work across versions.

The reason is that **'\xe2\x98\x83'** is interpreted as a pure string in Python 2.x and therefore the Bcrypt **hashpw** function treats it as such. On Python 3.x, it is treated as unicode and likely re-encoded by the hashpw function.

You may see the different results generated by hashpw below on both versions:

**Python 2.7**:

``` python
Python 2.7.3 (default, Apr 10 2013, 06:20:15)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import bcrypt
>>> bcrypt.hashpw('\xe2\x98\x83', '$2a$12$43ZhLeQrxZJx6DGLrKOj0u')
'$2a$12$43ZhLeQrxZJx6DGLrKOj0uHuLMhu4KxcqM5oYNlBfuJHaIyNHX2j6'
>>>
```

**Python 3.3**:

``` python
Python 3.3.3 (default, Dec 27 2013, 19:27:19)
[GCC 4.6.3] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import bcrypt
>>> bcrypt.hashpw('\xe2\x98\x83', '$2a$12$43ZhLeQrxZJx6DGLrKOj0u')
'$2a$12$43ZhLeQrxZJx6DGLrKOj0u1r.ztyYrn8eqOtMsAyx303JZwp0FkIG'
>>>
```

Please let me know your thoughts and whether or not you would be willing to remove this test and accept my proposed solution :smile:

All the best
Fotis