* 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>
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>
Co-authored-by: Lawrence D’Anna <lawrence_danna@apple.com>
* Add support for macOS 11 and Apple Silicon (aka arm64)
As a side effect of this work use the system copy of libffi on macOS, and remove the vendored copy
* Support building on recent versions of macOS while deploying to older versions
This allows building installers on macOS 11 while still supporting macOS 10.9.
The uname binary on Android does not support -p [1]. Here is a sample
log:
```
0:06:03 load avg: 0.56 [254/421/8] test_platform failed -- running: test_asyncio (5 min 53 sec)
uname: Unknown option p (see "uname --help")
test test_platform failed -- Traceback (most recent call last):
File "/data/local/tmp/lib/python3.9/test/test_platform.py", line 170, in test_uname_processor
proc_res = subprocess.check_output(['uname', '-p'], text=True).strip()
File "/data/local/tmp/lib/python3.9/subprocess.py", line 420, in check_output
return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
File "/data/local/tmp/lib/python3.9/subprocess.py", line 524, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['uname', '-p']' returned non-zero exit status 1.
```
[1] https://android.googlesource.com/platform/external/toybox/+/refs/heads/master/toys/posix/uname.c
Automerge-Triggered-By: @jaraco
* 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>
* bpo-35967: Make test more lenient to satisfy build bots.
* Update Lib/test/test_platform.py
Co-Authored-By: Kyle Stanley <aeros167@gmail.com>
* Expect '' for 'unknown'
Co-authored-by: Kyle Stanley <aeros167@gmail.com>
* 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.
Moreover, the following tests now check the child process exit code:
* test_os.PtyTests
* test_mailbox.test_lock_conflict()
* test_tempfile.test_process_awareness()
* test_uuid.testIssue8621()
* multiprocessing resource tracker tests
sys._base_executable is now always defined on all platforms, and can be overridden through configuration.
Also adds test.support.PythonSymlink to encapsulate platform-specific logic for symlinking sys.executable
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.
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%)
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.
* Add support.MS_WINDOWS: True if Python is running on Microsoft Windows.
* Add support.MACOS: True if Python is running on Apple macOS.
* Replace support.is_android with support.ANDROID
* Replace support.is_jython with support.JYTHON
* Cleanup code to initialize unix_shell
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
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.
`mkdir -p` and `os.makedirs()` functionality. When true, ignore
FileExistsErrors. Patch by Berker Peksag.
(With minor cleanups, additional tests, doc tweaks, etc. by Barry)
Also:
* Remove some unused imports in test_pathlib.py reported by pyflakes.
encoding with the surrogateescape error handler, instead of decoding from the
locale encoding in strict mode. It fixes the function on Fedora 19 which is
probably the first major distribution release with a non-ASCII name. Patch
written by Toshio Kuratomi.