Commit Graph

182 Commits

Author SHA1 Message Date
Christian Heimes cb2b3c8d35
bpo-40280: Emscripten has no support for subprocesses (GH-29872)
Fixes ``platform`` and ``help()`` on emscripten.

Signed-off-by: Christian Heimes <christian@python.org>

Automerge-Triggered-By: GH:tiran
2021-12-02 01:17:37 -08:00
Christian Clauss 745c9d9dfc
Fix typos in the Lib directory (GH-28775)
Fix typos in the Lib directory as identified by codespell.

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
2021-10-06 16:13:48 -07:00
Omer Katz 778b07565e
Remove compatibility check for Python versions below 2.2. (GH-28314)
`os.path.realpath()` already exists in all our supported Python versions.
There's no longer a need to check if it exists or not.

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2021-09-17 15:36:41 +02:00
Inada Naoki 3e4cb7f40f
platform: Import subprocess in function. (GH-27610) 2021-08-05 14:04:01 +09:00
Konstantin-Glukhov 0ee0a740e1
bpo-44572: On Windows, disconnect STDIN in platform._syscmd_ver() to prevent erroneous STDIN consumption (GH-27092) 2021-07-13 20:21:48 +01:00
Binbin 17b16e13bb
Fix typos in multiple files (GH-26689)
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
2021-06-12 22:47:44 -04:00
Shreyan Avigyan 2a3f4899c6
bpo-43284: Update platform.win32_ver to use _syscmd_ver instead of sys.getwindowsversion() (GH-25500)
The sys module uses the kernel32.dll version number, which can vary from the "actual" Windows version.
Since the best option for getting the version is WMI (which is expensive), we switch back to launching cmd.exe (which is also expensive, but a lot less code on our part).
sys.getwindowsversion() is not updated to avoid launching executables from that module.
2021-04-22 17:43:37 +01:00
Kurochan d9142831ba
handle empty string in variable executable in platform.libc_ver() (#23140) 2021-01-02 17:03:53 +01:00
Jason R. Coombs a6fd0f414c
bpo-42163, bpo-42189, bpo-42659: Support uname_tuple._replace (for all but processor) (#23010)
* Add test capturing missed expectation with uname_result._replace.

* bpo-42163: Override uname_result._make to allow uname_result._replace to work (for everything but 'processor'.

* Replace hard-coded length with one derived from the definition.

* Add test capturing missed expectation with copy/deepcopy on namedtuple (bpo-42189).

* bpo-42189: Exclude processor parameter when constructing uname_result.

* In _make, rely on __new__ to strip processor.

* Add blurb.

* iter is not necessary here.

* Rely on num_fields in __new__

* Add test for slices on uname

* Add test for copy and pickle.

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>

* import pickle

* Fix equality test after pickling.

* Simply rely on __reduce__ for pickling.

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2020-12-31 14:08:03 -05:00
Victor Stinner bfda4f5776
bpo-28468: Fix typo in _os_release_candidates (GH-23913)
Automerge-Triggered-By: GH:tiran
2020-12-23 08:35:53 -08:00
Christian Heimes 5c73afc36e
bpo-28468: Add platform.freedesktop_os_release() (GH-23492)
Add platform.freedesktop_os_release() function to parse freedesktop.org
os-release files.

Signed-off-by: Christian Heimes <christian@python.org>
Co-authored-by: Victor Stinner <vstinner@python.org>
2020-11-30 22:34:45 +01:00
Victor Stinner 5776663675
bpo-42029: Remove IRIX code (GH-23023)
IRIX code was slowy removed in Python 2.4 (--with-sgi-dl), Python 3.3
(Irix threads), and Python 3.7.
2020-10-29 15:16:23 +01:00
Jason R. Coombs 2c3d508c5f
bpo-40570: Improve compatibility of uname_result with late-bound .platform (#20015)
* bpo-40570: Improve compatibility of uname_result with late-bound .platform.

* Add test capturing ability to cast uname to a tuple.
2020-05-09 10:12:41 -04:00
Dennis Sweeney 1e7e4519a8
bpo-40459: Fix NameError in platform.py (GH-19855) 2020-05-05 11:33:17 +09:00
Jason R. Coombs 518835f335
bpo-35967 resolve platform.processor late (GH-12239)
* Replace flag-flip indirection with direct inspection

* Use any for simpler code

* Avoid flag flip and set results directly.

* Resolve processor in a single function.

* Extract processor handling into a namespace (class)

* Remove _syscmd_uname, unused

* Restore platform.processor behavior to match prior expectation (reliant on uname -p in a subprocess).

* Extract '_unknown_as_blank' function.

* Override uname_result to resolve the processor late.

* Add a test intended to capture the expected values from 'uname -p'

* Instead of trying to keep track of all of the possible outputs on different systems (probably a fool's errand), simply assert that except for the known platform variance, uname().processor matches the output of 'uname -p'

* Use a skipIf directive

* Use contextlib.suppress to suppress the error. Inline strip call.

* 📜🤖 Added by blurb_it.

* Remove use of contextlib.suppress (it would fail with NameError if it had any effect). Rely on _unknown_as_blank to replace unknown with blank.

Co-authored-by: blurb-it[bot] <blurb-it[bot]@users.noreply.github.com>
2020-04-16 08:28:09 -04:00
Victor Stinner a719c8f4bd
bpo-35389: platform.platform() calls libc_ver() without executable (GH-14418)
When libc_ver() is called with an executable, the
os.confstr('CS_GNU_LIBC_VERSION') fast-path cannot be taken. Modify
platform.platform() to call libc_ver() without executable, instead of
calling libc_ver(sys.executable), since sys.executable is already the
default value.
2019-06-27 09:04:28 +02:00
penguindustin 9646630895 bpo-36766: Typos in docs and code comments (GH-13116) 2019-05-06 14:57:17 -04:00
Paul Monson 62dfd7d6fe bpo-35920: Windows 10 ARM32 platform support (GH-11774) 2019-04-25 18:36:45 +00:00
Steve Dower d307d05350
Fixes platform.win32_ver on non-Windows platforms (GH-12912) 2019-04-22 11:40:12 -07:00
Victor Stinner 60875db2f6
bpo-35516: platform.system_alias() don't replace Darwin (GH-11207)
Add a comment explaining why system_alias() doesn't alias Darwin to
macOS.
2018-12-18 19:51:35 +01:00
Victor Stinner 0af9c33262
bpo-35348: Fix platform.architecture() (GH-11159)
Make platform.architecture() parsing of "file" command output more
reliable:

* Add the "-b" option to the "file" command to omit the filename;
* Force the usage of the C locale;
* Search also the "shared object" pattern.

Co-Authored-By: Serhiy Storchaka <storchaka@gmail.com>
2018-12-17 18:47:24 +01:00
Victor Stinner 4aa917c5fe
bpo-35346: Cleanup platform.architecture() (GH-11130)
struct.calcsize('P') now always works.
2018-12-14 13:14:10 +01:00
Victor Stinner b0e0877629
bpo-35346: Drop Mac OS 9 support from platform (GH-10959)
Drop Mac OS 9 and Rhapsody support from the platform module:

* Rhapsody: last release in 2000
* Mac OS 9: last release in 2001
2018-12-12 17:48:08 +01:00
Victor Stinner 3a521f0b61
bpo-35346, platform: replace os.popen() with subprocess (GH-10786)
Replace os.popen() with subprocess.check_output() in the platform module:

* platform.uname() (its _syscmd_ver() helper function) now redirects
  stderr to DEVNULL.
* Remove platform.DEV_NULL.
* _syscmd_uname() and _syscmd_file() no longer catch AttributeError.
  The "except AttributeError:" was only needed in Python 2, when
  os.popen() was not always available. In Python 3,
  subprocess.check_output() is always available.
2018-12-07 11:10:33 +01:00
Victor Stinner ea0ca218b0
bpo-35344: platform.platform() uses mac_ver() on macOS (GH-10780)
On macOS, platform.platform() now uses mac_ver(), if it returns a
non-empty release string, to get the macOS version rather than darwin
version.
2018-12-05 22:41:52 +01:00
Victor Stinner 476b113ed8
bpo-35389: platform.libc_ver() uses os.confstr() (GH-10891)
platform.libc_ver() now uses os.confstr('CS_GNU_LIBC_VERSION') if
available and the *executable* parameter is not set. The default
value of the libc_ver() *executable* parameter becomes None.

Quick benchmark on Fedora 29:

python3 -m perf command ./python -S -c 'import platform; platform.libc_ver()'
94.9 ms +- 4.3 ms -> 33.2 ms +- 1.4 ms: 2.86x faster (-65%)
2018-12-05 14:04:52 +01:00
Victor Stinner b8e689a6e8
bpo-35346, platform: import subprocess in _syscmd_file() (GH-10892)
Only platform._syscmd_file() uses subprocess. Move subprocess import
inside this function to reduce the number of imports at Python
startup.

Remove also warnings import which is no longer needed.
2018-12-04 17:18:12 +01:00
Victor Stinner 73104fa1e6
bpo-35345: Remove platform.popen() (GH-10781)
Remove platform.popen() function, it was deprecated since Python 3.3:
use os.popen() instead.

Rename also the "Removed" section to "API and Feature Removals"
of What's New in Python 3.8.
2018-11-29 09:58:20 +01:00
Victor Stinner 7cc1fa40b7
bpo-28167: Remove platform._dist_try_harder() (GH-10787)
platform._dist_try_harder() was an helper function
for platform.linux_distribution() which has been removed by the
commit 8b94b41ab7.
2018-11-29 03:14:03 +01:00
Serhiy Storchaka 7d81e8f599
bpo-26544: Get rid of dependence from distutils in platform. (GH-8356) 2018-08-27 13:29:51 +03:00
Serhiy Storchaka 2a9b8babf0
bpo-26544: Fixed implementation of platform.libc_ver(). (GH-7684) 2018-07-09 11:47:45 +03:00
Petr Viktorin 8b94b41ab7
bpo-28167: Remove platform.linux_distribution (GH-6871)
* test_ssl: Remove skip_if_broken_ubuntu_ssl

We no longer support OpenSSL 0.9.8.15.15.

* bpo-28167: Remove platform.linux_distribution
2018-05-16 11:51:18 -04:00
Matthias Bussonnier 9eb40bc38d bpo-28167: bump platform.linux_distribution removal to 3.8 (GH-6669)
Also bump PendingDeprecationWarning to DeprecationWarning.
2018-05-15 11:17:00 -04:00
Victor Stinner fe2d5babba
bpo-32159: Remove tools for CVS and Subversion (#4615)
CPython migrated from CVS to Subversion, to Mercurial, and then to
Git. CVS and Subversion are not more used to develop CPython.

* platform module: drop support for sys.subversion. The
  sys.subversion attribute has been removed in Python 3.3.
* Remove Misc/svnmap.txt
* Remove Tools/scripts/svneol.py
* Remove Tools/scripts/treesync.py
2017-11-28 22:29:32 +01:00
Ned Deily 5c4b0d063a bpo-27593: Get SCM build info from git instead of hg. (#446)
sys.version and the platform module python_build(),
python_branch(), and python_revision() functions now use
git information rather than hg when building from a repo.

Based on original patches by Brett Cannon and Steve Dower.
2017-03-04 00:19:55 -05:00
Matthias Bussonnier 6059ce45aa bpo-27788 : synchronise platform.py version number (#246)
Was bumped in the docstring by b9f4feab1b
but not in `__version__`
2017-02-24 11:47:34 +01:00
Steve Dower 74f4af7ac3 Issue #27932: Prevent memory leak in win32_ver(). 2016-09-17 17:27:48 -07:00
Steve Dower 81994006f5 Merge from 3.5 2016-09-10 11:53:34 -07:00
Steve Dower f028d9f71a Issue #27932: Backs out change 2016-09-10 11:52:18 -07:00
Steve Dower 6a294a54de Issue #27932: Fixes memory leak in platform.win32_ver() 2016-09-09 18:01:25 -07:00
Steve Dower 1588a3b377 Issue #27932: Fixes memory leak in platform.win32_ver() 2016-09-09 18:04:26 -07:00
Steve Dower 41519b2ca8 Issue #26513: Fixes platform module detection of Windows Server 2016-09-09 09:46:56 -07:00
Steve Dower 7bcf7931fc Issue #26513: Fixes platform module detection of Windows Server 2016-09-09 09:47:09 -07:00
R David Murray 44b548dda8 #27364: fix "incorrect" uses of escape character in the stdlib.
And most of the tools.

Patch by Emanual Barry, reviewed by me, Serhiy Storchaka, and
Martin Panter.
2016-09-08 13:59:53 -04:00
Larry Hastings 10108a7b9a Issue #27355: Removed support for Windows CE. It was never finished,
and Windows CE is no longer a relevant platform for Python.
2016-09-05 15:11:23 -07:00
Martin Panter eb9957065a Issue #27626: Spelling fixes in docs, comments and internal names
Based on patch by Ville Skyttä.
2016-07-28 01:11:04 +00:00
Martin Panter 4e50553823 Issue #21313: Tolerate truncated buildinfo in sys.version 2016-06-08 06:12:22 +00:00
Berker Peksag 8d8221f0d6 Issue #26041: Remove "will be removed in Python 3.7" from description messages
We will keep platform.dist() and platform.linux_distribution() to make porting
from Python 2 easier.

Patch by Kumaripaba Miyurusara Athukorala.
2016-04-24 03:32:24 +03:00
Steve Dower 126c9c17ef Issue #26513: Fixes platform module detection of Windows Server 2016-03-12 08:06:23 -08:00
Steve Dower 5b1640cd2b Merge from 3.4 2015-09-22 17:35:42 -07:00