mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
GH-123996: Explicitly mark 'self_or_null' as an array of size 1 to ensure that it is kept in memory for calls (GH-124003)
This commit is contained in:
parent
3ea51fa2e3
commit
4ed7d1d6ac
7 changed files with 344 additions and 327 deletions
|
@ -164,6 +164,8 @@ class StackOffset:
|
|||
class StackError(Exception):
|
||||
pass
|
||||
|
||||
def array_or_scalar(var: StackItem | Local) -> str:
|
||||
return "array" if var.is_array() else "scalar"
|
||||
|
||||
class Stack:
|
||||
def __init__(self) -> None:
|
||||
|
@ -177,10 +179,15 @@ class Stack:
|
|||
indirect = "&" if var.is_array() else ""
|
||||
if self.variables:
|
||||
popped = self.variables.pop()
|
||||
if var.is_array() ^ popped.is_array():
|
||||
raise StackError(
|
||||
f"Array mismatch when popping '{popped.name}' from stack to assign to '{var.name}'. "
|
||||
f"Expected {array_or_scalar(var)} got {array_or_scalar(popped)}"
|
||||
)
|
||||
if popped.size != var.size:
|
||||
raise StackError(
|
||||
f"Size mismatch when popping '{popped.name}' from stack to assign to {var.name}. "
|
||||
f"Expected {var.size} got {popped.size}"
|
||||
f"Size mismatch when popping '{popped.name}' from stack to assign to '{var.name}'. "
|
||||
f"Expected {var_size(var)} got {var_size(popped.item)}"
|
||||
)
|
||||
if var.name in UNUSED:
|
||||
if popped.name not in UNUSED and popped.name in self.defined:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue