indeedeng / django-ptrack

Tracking pixel library for Django
Apache License 2.0
40 stars 17 forks source link

Issue with Python 3 #1

Closed ramashishb closed 6 years ago

ramashishb commented 6 years ago

Using ptrack with Python 3 is giving the following error-

nacl.exceptions.TypeError: SecretBox must be created from 32 bytes On debugging, the issue is with nacl/secret.py > SecretBox

    def __init__(self, key, encoder=encoding.RawEncoder):
        key = encoder.decode(key)
        if not isinstance(key, bytes):
            raise exc.TypeError("SecretBox must be created from 32 bytes")

The check for bytes for decoded key is evaluating to False in Python 3 (it evaluates to True in Python 2). One way is to convert string to bytes before passing it to SecretBox constructor. Any other idea?

latimer1 commented 6 years ago

TIL the fact about uf8 and byte strings. https://stackoverflow.com/questions/6224052/what-is-the-difference-between-a-string-and-a-byte-string Just to clarify, it looks like your merge request addresses this issue, or is there anything else I'm missing?

ramashishb commented 6 years ago

I think thats it. Python 3 has made the conversion explicit. So wherever there is a need to transfer or store the string, it expects it to be encoded properly.

On Tue, Mar 6, 2018 at 5:12 AM, latimer1 notifications@github.com wrote:

TIL the fact about uf8 and byte strings. https://stackoverflow.com/ questions/6224052/what-is-the-difference-between-a-string- and-a-byte-string Just to clarify, it looks like your merge request addresses this issue, or is there anything else I'm missing?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/indeedeng/django-ptrack/issues/1#issuecomment-370607877, or mute the thread https://github.com/notifications/unsubscribe-auth/ADFT-NwslnyFnqfQLFKOjw0qeTPaBuraks5tbc1ugaJpZM4SbYJ1 .

latimer1 commented 6 years ago

I've tested these changes on a python 2.7 project and everything seems good. What version of python did you use? I'm going to update the classifiers in setup.py. Also, would you be able to test building from this github repo to see if any issues. I'll release v1.2.0 in PyPI shortly.

ramashishb commented 6 years ago

Hi,

I've tested with Python 3.5. Are there instructions to build and test from github?

Thanks Ram

On Mar 7, 2018 5:27 AM, "latimer1" notifications@github.com wrote:

I've tested these changes on a python 2.7 project and everything seems good. What version of python did you use? I'm going to update the classifiers in setup.py. Also, would you be able to test building from this github repo to see if any issues. I'll release v1.2.0 in PyPI shortly.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/indeedeng/django-ptrack/issues/1#issuecomment-370972647, or mute the thread https://github.com/notifications/unsubscribe-auth/ADFT-KO711tCqrLaZ_F1y95vlsSOcfFdks5tbyJVgaJpZM4SbYJ1 .

latimer1 commented 6 years ago

pip install -e git+https://github.com/indeedeng/django-ptrack.git@master#egg=django-ptrack

You might need sudo in front of pip depending on your setup.

ramashishb commented 6 years ago

Thanks! I have done that from my fork. It works. Tested with Python 3.5.

On Mar 7, 2018 9:02 AM, "latimer1" notifications@github.com wrote:

pip install -e git+https://github.com/indeedeng/django-ptrack.git@ master#egg=django-ptrack

You might need sudo in front of pip depending on your setup.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/indeedeng/django-ptrack/issues/1#issuecomment-371011250, or mute the thread https://github.com/notifications/unsubscribe-auth/ADFT-GVZ-XF7atYsQ7z1eHRjhBuXzgaSks5tb1S1gaJpZM4SbYJ1 .

latimer1 commented 6 years ago

Great! thank you for all your help in submitting a patch and testing. I'll try to find some time tomorrow to make a new version release and I'll reply here when it is out.

ramashishb commented 6 years ago

Nice!

On Mar 7, 2018 9:11 AM, "latimer1" notifications@github.com wrote:

Great! thank you for all your help in submitting a patch and testing. I'll try to find some time tomorrow to make a new version release and I'll reply here when it is out.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/indeedeng/django-ptrack/issues/1#issuecomment-371012599, or mute the thread https://github.com/notifications/unsubscribe-auth/ADFT-ElYOb0RbBmfPm9FHW6GwWZ-ZPVvks5tb1b8gaJpZM4SbYJ1 .

latimer1 commented 6 years ago

1.2.0 is released https://pypi.python.org/pypi/django-ptrack

ramashishb commented 6 years ago

Thank you!

On Mar 8, 2018 3:40 AM, "latimer1" notifications@github.com wrote:

1.2.0 is released https://pypi.python.org/pypi/django-ptrack

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/indeedeng/django-ptrack/issues/1#issuecomment-371303198, or mute the thread https://github.com/notifications/unsubscribe-auth/ADFT-OVeaz0xMjifxpzp32k-B3SAxRIfks5tcFrugaJpZM4SbYJ1 .