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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Force integer division for truncation of stdout/stderr in dogwrap #267

Merged
merged 1 commit into from Jun 26, 2018

Conversation

glasnt
Copy link
Contributor

@glasnt glasnt commented May 2, 2018

馃憢

Observed behaviour:

When dogwrap runs in a Python 3 environment with submit_mode=all, and there is both stdout and stderr, the following error occurred:

    ...
    top_third=text[:max_len / 3],
TypeError: slice indices must be integers or None or have an __index__ method

Cause:

This is because in Python 3, int / int no longer returns an int, it returns a float. And floats are invalid index values.

Solution:

This integer division functionality can be forced by using // rather than / in both Python 3 and Python 2. (Tested in Python 2.7.12, Python 3.5.2; operator introduced in Python 2.2+ (PEP238)

This change has only been tested manually, because it doesn't appear dogwrap is currently being tested (please correct me if I'm wrong)

@glasnt
Copy link
Contributor Author

glasnt commented May 3, 2018

Oops, should have checked the existing PRs 馃槙

This is a partial duplicate of #260, but this PR includes a third change, ensuring all instances of division are forced to integer division

@thisiscab
Copy link

Good catch on the third change! :)

@yannmh
Copy link
Member

yannmh commented Jun 26, 2018

@glasnt @cabouffard thanks a lot for the fix 馃檱

@yannmh yannmh merged commit b1d20c4 into DataDog:master 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

3 participants