Skip to content
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

Fix Dogwrap to support Python3 integer division #260

Closed
wants to merge 1 commit into from
Closed

Fix Dogwrap to support Python3 integer division #260

wants to merge 1 commit into from

Conversation

thisiscab
Copy link

In Python3, the / operator does a floating point division whereas
Python2 does an integer one.

Since the length of the content can yield a decimal number when
divided by 3 it throws the following error in Python3:

...
slice indices must be integers or None or have an __index__ method

The recommended way to do integer division is by using the // operator.
Based on the Python2 and Python3 specs, this ensures that this will do a
proper integer division (see link below).

I've personally tested this fix in both Python2 and Python3 and I've
been able to confirm that no errors are being thrown and that the event
get properly created in DataDog.

https://www.python.org/dev/peps/pep-0238/

In Python3, the `/` operator does a floating point division whereas
Python2 does an integer one.

Since the length of the content can yield a decimal number when
divided by 3 it throws the following error in Python3:

```
...
slice indices must be integers or None or have an __index__ method
```

The recommend way to do integer division is by using the `//` operator.
Based on the Python2 and Python3 specs, this ensure that this will do a
proper integer division (see link below).

I've personally tested this fix in both Python2 and Python3 and I've
been able to confirm that no errors are being thrown and that the event
get properly created in DataDog.

https://www.python.org/dev/peps/pep-0238/
@yannmh
Copy link
Member

yannmh commented Jun 26, 2018

Thanks again @cabouffard. The fix was merged with #267

@yannmh yannmh closed this Jun 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants