Skip to content

Conversation

@RobbeSneyders
Copy link
Contributor

This pull request prepares the internal subpackage for Python 3 support. This PR is part of a series in which all subpackages will be updated using the same approach.
This approach has been documented here and the first pull request in the series (Futurize coders subpackage) demonstrating this approach can be found at #5053.

R: @aaltay @tvalentyn

@RobbeSneyders
Copy link
Contributor Author

retest this please

import logging
import threading
import weakref
from builtins import next
Copy link
Contributor

@tvalentyn tvalentyn May 17, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to understand the reason for adding from builtins import next. Is it done by a conversion tool because we have an occurrence of next(v_iter) in the file, and the tool cannot infer whether or not v_iter implements a custom iterator? If yes: will such changes be required by linter?

Is my understanding correct that as long as v_iter.__class__ does not implement a custom iterator (and it is not, in our case), the code without the import is still equivalent in Python 2 and Python 3?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is indeed done by the automatic conversion of future.
And you're right, it isn't necessary here. Lint doesn't seem to complain either, so we can remove this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm... the change is harmless, I totally don't mind it. I am a little concerned that we might not be able to enforce consistency in the codebase, and automatically catch when such changes are required. Say, tomorrow somebody adds a usage of next in against an object passed into the method, and we can't tell if the object will has the iterator implemented in Py3-compliant way, so then there would be a difference in behavior between py2 and py3, and importing next would make a difference, but if linter does not catch it, chances are reviewers won't notice it either.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked again, and it seems like the linter checks for .next() calls on objects. So we should be safe.

@tvalentyn
Copy link
Contributor

retest this please

@tvalentyn
Copy link
Contributor

Let's see if the Py3 linter kicks in.

@RobbeSneyders
Copy link
Contributor Author

RobbeSneyders commented May 17, 2018

The linter did run before pushing my new changes.

Copy link
Member

@aaltay aaltay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally LGTM, could you rebase please?

[tox]
# new environments will be excluded by default unless explicitly added to envlist.
envlist = py27,py27-{gcp,cython,lint,lint3},py3-lint,docs
#envlist = py27,py27-{gcp,cython,lint,lint3},py3-lint,docs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My mistake.

@aaltay aaltay merged commit 15600d6 into apache:master May 22, 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.

3 participants