-
-
Notifications
You must be signed in to change notification settings - Fork 30.7k
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
Modernize Lib/platform.py code #79527
Comments
Lib/platform.py still contains code to support Python 2.3. It's maybe time to modernize it. platform imports subprocess since commit fc990e9. The two calls to os.popen() can now be replaced with subprocess.Popen. |
It's because the module was originally kept compatible with Python 1.5.2: https://www.python.org/dev/peps/pep-0291/#backward-compatible-packages-modules-and-tools |
While we are here, look at other outdated code:
Should we keep compatibility with 2.7? |
I don't think that the master branch (Python 3.8) has to be compatible with Python 2.7. |
Please keep Python 2.7 compatibility. It should be possible to copy the module back into Python 2.7 and use it there. This is not hard to do and allows it to fulfill its purpose as platform detection module even while part of the stdlib. |
I don't understand why someone would like to copy Lib/platform.py from the master branch to Python 2.7? Python 2.7 already provides the platform module, it's part of its standard library. platform.linux_distribution() function has been removed from master, so you cannot simply copy platform.py from master and use it in Python 2.7: it has a different API. |
Ok, let me add some history here: When I created the platform module it was clear that this would be I had developed this with a larger number of contributors outside Now in order to keep the module more or less up-to-date, it still This is why it has a special status and keep backwards compatibility This worked quite well, but for some systems such as the Linux That's why I was fine with removing the code again and leaving this Does it make more sense now ? |
I don't understand if you are describing the current status or the history here. Do you know users who don't use platform form the stdlib, but use a more recent copy? These users cannot get a more recent version of Python? When you talk about copying Lib/platform.py from master to Python 2.7, are you talking about the ability to copy platform.py from master into an application to get a more recent version on Python 2.7? If yes, I don't understand how you plan to add back the linux_distribution() feature? Sorry, I'm still lost :-( |
Another issue with Python 2 compatibility (I addition to platform.dist() removal) of Lib/platform.py from master: it uses re.ASCII which doesn't exist in Python 2.7. |
Fixed by commit b8e689a.
I wrote PR 11130 for that. Note: struct.calcsize('P') always works on Python 2.7 as well.
I don't know this module. This module imports many other modules like xml.parsers.expat. I don't think that the try/except ImportError hurts. Feel free to propose a PR if you want. |
I close the issue. I made that changes that I wanted :-) Serhiy: reopen the issue or open a new one if you want to remove the try/except ImportError around "import plistlib". |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: