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

Restore compat.py in master/2.X #3443

Closed
wants to merge 8 commits into from
Closed

Conversation

mcdonc
Copy link
Member

@mcdonc mcdonc commented Dec 29, 2018

Yeah it was never an API. But we used it a lot, and apps that depend on it can't immediately migrate wholesale to py3 only. It's maybe a bit fundamentalist to remove it. Maybe it should be an API.

@mmerickel
Copy link
Member

mmerickel commented Dec 29, 2018

I did at little research before deleting it and at least the main pyramid addons I use didn't depend on it. I'm sure it broke substanced though. With respect to "yeah it was never an API" it actually was an api and removing it was part of the bw-incompat changes in 2.x. We just forgot to update the changelog (for any of the changes, even dropping py2) in #3421. I opened #3444 to remind me to do that before any release.

I'm not going to put up much fight against this but I will say that I think it shouldn't be here. At the very least this module should raise a deprecation warning with an intent to remove at some point. Either that or please update Pyramid's codebase to use the functions in this module and remove the copies I added to pyramid.util. IMO addons should vendor in their own compat or use six or whatever. I really don't want to have code in Pyramid that Pyramid doesn't use and doesn't have great tests, but if they are deprecated I'm less worried about it.

@digitalresistor
Copy link
Member

I'm a 👎 on bringing pyramid.compat back, and I am saying that as someone that uses it quite a bit in his own code bases. Although so far the migration has been pretty simple because removing py2 compat means not needing this module anymore.

@mcdonc
Copy link
Member Author

mcdonc commented Dec 29, 2018

I'm a on bringing pyramid.compat back, and I am saying that as someone that uses it quite a bit in his own code bases. Although so far the migration has been pretty simple because removing py2 compat means not needing this module anymore.

Understood for personal codebases but frameworky bits like pyramid_debugtoolbar can't really just up and ditch Python 2.X unless we declare some sort of flag day. Alternately, wee could change it so it had its own compat stuff. But it's just easier for people (and us) if it doesn't break when they use it with 3.X or 2.X so we don't need to make noise Pyramid 2.X compat releases of things when it would continue to work just fine if compat was there.

@mcdonc
Copy link
Member Author

mcdonc commented Dec 29, 2018

I'm not going to put up much fight against this but I will say that I think it shouldn't be here. At the very least this module should raise a deprecation warning with an intent to remove at some point. Either that or please update Pyramid's codebase to use the functions in this module and remove the copies I added to pyramid.util. IMO addons should vendor in their own compat or use six or whatever. I really don't want to have code in Pyramid that Pyramid doesn't use and doesn't have great tests, but if they are deprecated I'm less worried about it.

Deprecation warnings sound like a good idea to me. But as should be clear by me not just checking this in on master, I'm willing to defer too.

@mmerickel
Copy link
Member

Understood for personal codebases but frameworky bits like pyramid_debugtoolbar can't really just up and ditch Python 2.X unless we declare some sort of flag day.

Answering this part in a vacuum, unrelated to this PR: this is less of a problem than you might think thanks to the python_requires metadata. We could technically (of course it's a fairly irresponsible) drop py2 on a minor version and it wouldn't affect anyone using a remotely modern (8-ish) version of pip where it simply wouldn't install the new release. Dropping it on a major version though shouldn't be an issue and is something I'd plan to do to addons as they get maintained.

As far as this PR goes, I'm +0 merging this with deprecation warnings.

@digitalresistor
Copy link
Member

pyramid_debugtoolbar can be updated to support only Python 3.x too, so it is imho less of an issue, or it could even for its next release vendor its own version of compat.py into an existing point release and then the next major version is Py3 only.

It feels really weird to me to keep this around when it is no longer internally used by Pyramid, especially when we are doing a major version jump specifically because we are breaking backwards compatibility by removing Python 2 support.

@mcdonc
Copy link
Member Author

mcdonc commented Dec 30, 2018

It feels really weird to me to keep this around when it is no longer internally used by Pyramid, especially when we are doing a major version jump specifically because we are breaking backwards compatibility by removing Python 2 support.

But the intent of supporting only Py 3 isn't to explicitly break Py 2 compatibility. It's not being done as a political statement, it's being done to decrease maintainer burden. If we could move to Py 3 without breaking bw compat in any way, we would. The burden of maintaining compat.py is close to zero, and if having it around keeps things working for people who want to support Py 2 and Py 3 versions of their software that depends on Pyramid, I see no practical reason to remove it. IMO, the license to break bw compat should be relatively conservative even at major version bumps, esp. when it doesn't hurt us in any way.

@mmerickel
Copy link
Member

If you want to keep it that's fine. Please either 1) add the deprecation warning and pick some version where you're cool with removing it, or 2) bring it back to the standard it was at before I removed it in #3421. It had api docs and full tests before which this PR omits. In either scenario, a decision needs to be made where the code lives. Either in pyramid.compat or in pyramid.util. Maintaining copies in both places isn't going to fly. Personally I'd say that pyramid.compat should be a thin shim just importing the functions from pyramid.util and a deprecation warning added to pyramid.compat.

@mmerickel
Copy link
Member

I found at least that pyramid_mako is using pyramid.compat. Pylons/pyramid_mako#41

@digitalresistor
Copy link
Member

I haven't given pyramid_mako much love.

@mmerickel
Copy link
Member

@mcdonc what's the plan?

@mcdonc
Copy link
Member Author

mcdonc commented Feb 13, 2019

Sorry for the late reply. What's attached now to this PR is I think the only stuff that was there before (and is required) with some updates to the docs.

@mmerickel
Copy link
Member

Awesome. We now have some duplicate methods defined in pyramid.util. The last step in this PR is that I think we should re-export those from pyramid.compat instead of maintaining these copies.


class NewStyle(object):
def run(self): # pragma: no cover
return 'OK'
Copy link
Member

Choose a reason for hiding this comment

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

Python 3 only has new-style classes, some of these tests can be removed.

``s.decode(encoding, errors)``, otherwise return ``s``"""
if isinstance(s, binary_type):
return s.decode(encoding, errors)
return s
Copy link
Member

Choose a reason for hiding this comment

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

These functions are already defined in pyramid.util. Please import them from there and re-export them instead of re-defining them here.

@mmerickel
Copy link
Member

reopen this if you feel like addressing comments

@mmerickel mmerickel closed this May 2, 2019
@digitalresistor digitalresistor deleted the feature.restore-compat-in-2x branch August 1, 2020 21:53
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