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

variable six.PY3 -- is time bomb :) #22

Closed
benjaminp opened this issue Mar 14, 2013 · 10 comments
Closed

variable six.PY3 -- is time bomb :) #22

benjaminp opened this issue Mar 14, 2013 · 10 comments

Comments

@benjaminp
Copy link
Owner

Originally reported by: Andrej Antonov (Bitbucket: polymorphm, GitHub: polymorphm)


good day!

variable six.PY3 -- is time bomb :)

file six.py now has code:

# True if we are running on Python 3.
PY3 = sys.version_info[0] == 3

...but must be somewhere like:

# True if we are running on Python version at least 3.
PY3 = sys.version_info[0] >= 3

thanks in advance! (and sorry for my bad english :))


@benjaminp
Copy link
Owner Author

It would be inaccurate to have a true PY3 variable in hypothetical Python 4. six will be long dead and forgotten by the time Python 4 rolls around. (At that point I will have to write "twelve".)

@benjaminp
Copy link
Owner Author

Original comment by Andrej Antonov (Bitbucket: polymorphm, GitHub: polymorphm):


ok :) .. I can only hope that in the "twelve" will be code line:

PY4 = sys.version_info[0] >= 4

or

PY4 = sys.version_info[0] != 3

@benjaminp
Copy link
Owner Author

Original comment by Collin Anderson (Bitbucket: collinmanderson, GitHub: Unknown):


"six will be long dead and forgotten by the time Python 4 rolls around." -- I hope :). There may be people who hold out until 2020 before starting to use six, and Python 4 is scheduled for 2023.

@benjaminp
Copy link
Owner Author

Why do you think Python 4 is scheduled?

@benjaminp
Copy link
Owner Author

Original comment by Collin Anderson (Bitbucket: collinmanderson, GitHub: Unknown):


Sorry. "Scheduled" is the wrong work. I'm just referring to Nick's estimate http://developerblog.redhat.com/2014/09/17/why-python-4-0-wont-be-like-python-3-0/

Anyway, I suppose there's no rush in dealing with the issue now.

@benjaminp
Copy link
Owner Author

Original comment by astrofrog (Bitbucket: astrofrog, GitHub: astrofrog):


Just for info, I wrote a blog post today on the use of six.PY3 and sys.version_info[0] == 3:

http://astrofrog.github.io/blog/2016/01/12/stop-writing-python-4-incompatible-code/

In my opinion, PY3 is fine as it is and it would be weird for PY3 to be True on Python 4. The better solution is just to write code like:

if six.PY2:
    # Python 2 code
else:
    # Python 3 code

@stxlvt
Copy link

stxlvt commented Dec 5, 2017

I want to add my partial support to @astrofrog and @polymorphm on this issue. I repeated the github search, and find close to one million matches for if six.PY3. And that's just one of several equivalent ways to write it. I would also like to link to this related issue for context.

I think it's unrealistic to expect enough of those people to fix their code in the roughly 3.5 years remaining until we may start seeing development releases of python 4.0, and I think both python 2.7 and six will still be alive and kicking when that time comes.

Look how everybody uses the PY3 constant as if it was called NOT_PY2. I feel confident in saying that none of those who write it intends it to mean if PY3 and not PY4. I agree with astrofrog that it would be weird for it to behave as @polymorphm suggests when it's called PY3, but even so I think in this case practicality beats purity and the actual usage should guide this decision. The code search clearly shows that it would break expectations for PY3 to be False on python 4. Therefore you really ought to change the definition to

PY3 = sys.version_info[0] >= 3

... and update the documentation to match.

@stxlvt
Copy link

stxlvt commented Dec 12, 2017

I notice did not mention @benjaminp in the above comment, so he likely didn't see it and can't consider reopening this issue. Hence this comment.

@jaraco
Copy link
Contributor

jaraco commented Jan 12, 2020

PY3 is still a time bomb and I'm starting to get pull requests to remove the use of PY3. I can't tell you how excited I am about the long tail of pull requests to replace PY3 with PY2. :(

@benjaminp
Copy link
Owner Author

What other people spend their time making PRs for is rather out of my hands.

nedko pushed a commit to LADI/py-six that referenced this issue Nov 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants