Avoid linear runtime of ShareableList.__getitem__ and
ShareableList.__setitem__ by storing running allocated bytes in
ShareableList._allocated_bytes instead of the number of bytes for
a particular stored item.
Co-authored-by: Antoine Pitrou <antoine@python.org>
Fixes Issue39285
The example incorrectly returned True for match.
Furthermore the example is ambiguous in its usage of PureWindowsPath.
Windows is case-insensitve, however the underlying match functionality
utilizes fnmatch.fnmatchcase.
Automerge-Triggered-By: @pitrou
* Use ast module to find class definition
* Add NEWS entry
* Fix class with multiple children and move decorator code to the method
* Fix PR comments
1. Use node.decorator_list to select decorators
2. Remove unwanted variables in ClassVisitor
3. Simplify stack management as per review
* Add test for nested functions and async calls
* Fix pydoc test since comments are returned now correctly
* Set event loop policy as None to fix environment related change
* Refactor visit_AsyncFunctionDef and tests
* Refactor to use local variables and fix tests
* Add patch attribution
* Use self.addCleanup for asyncio
* Rename ClassVisitor to ClassFinder and fix asyncio cleanup
* Return first class inside conditional in case of multiple definitions. Remove decorator for class source.
* Add docstring to make the test correct
* Modify NEWS entry regarding decorators
* Return decorators too for bpo-15856
* Move ast and the class source code to top. Use proper Exception.
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 PY_INT64_T with int64_t
* Replace PY_UINT32_T with uint32_t
* Replace PY_UINT64_T with uint64_t
sha3module.c no longer checks if PY_UINT64_T is defined since it's
always defined and uint64_t is always available on platforms
supported by Python.
Add random.randbytes() function and random.Random.randbytes()
method to generate random bytes.
Modify secrets.token_bytes() to use SystemRandom.randbytes()
rather than calling directly os.urandom().
Rename also genrand_int32() to genrand_uint32(), since it returns an
unsigned 32-bit integer, not a signed integer.
The _random module is now built with Py_BUILD_CORE_MODULE defined.
Add a new internal pycore_byteswap.h header file with the following
functions:
* _Py_bswap16()
* _Py_bswap32()
* _Py_bswap64()
Use these functions in _ctypes, sha256 and sha512 modules,
and also use in the UTF-32 encoder.
sha256, sha512 and _ctypes modules are now built with the internal
C API.
The names "member" and "container" for the arguments are also used in the module and shown with the help() function, and are immediately understandable in this context, contrary to "first" and "second".
* 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.
When there is a SyntaxError after reading the last input character from
the tokenizer and if no newline follows it, the error message used to be
`unexpected EOF while parsing`, which is wrong.
Avoid a temporary buffer to create a bytes string: use
PyBytes_FromStringAndSize() to directly allocate a bytes object.
Cleanup also the code: PEP 7 formatting, move variable definitions
closer to where they are used. Fix assertion checking "j" index.