GH-139914: Handle stack growth direction on HPPA (GH-140028)

Adapted from a patch for Python 3.14 submitted to the Debian BTS by John
https://bugs.debian.org/1105111#20

Co-authored-by: John David Anglin <dave.anglin@bell.net>
This commit is contained in:
Stefano Rivera 2025-11-17 05:41:22 -08:00 committed by GitHub
parent 336366fd7c
commit f6dd9c12a8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 94 additions and 5 deletions

View file

@ -1048,9 +1048,14 @@ def get_sp():
this_sp = _testinternalcapi.get_stack_pointer()
lower_sp = _testcapi.pyobject_vectorcall(get_sp, (), ())
self.assertLess(lower_sp, this_sp)
if _testcapi._Py_STACK_GROWS_DOWN:
self.assertLess(lower_sp, this_sp)
safe_margin = this_sp - lower_sp
else:
self.assertGreater(lower_sp, this_sp)
safe_margin = lower_sp - this_sp
# Add an (arbitrary) extra 25% for safety
safe_margin = (this_sp - lower_sp) * 5 / 4
safe_margin = safe_margin * 5 / 4
self.assertLess(safe_margin, _testinternalcapi.get_stack_margin())
@skip_on_s390x