Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests stack #1

Open
pmp-p opened this issue Dec 13, 2023 · 1 comment
Open

tests stack #1

pmp-p opened this issue Dec 13, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@pmp-p
Copy link
Owner

pmp-p commented Dec 13, 2023

if 0:
    class T:...

SyntaxError: expected an expression, got class


context blocks: "as" label: pocketpy#187


def iteration():
    yield 1
    yield 2

N = iteration()
while next(N, None):
    pass

TypeError: expected 1 arguments, got 2

FIX:

    __next__ = next
    def next(it, default=0xdeadbeef):
        itrv = __next__(it)
        if itrv == StopIteration:
            if default == 0xdeadbeef:
                raise itrv
            return default
        return itrv

    __import__('builtins').next = next

def NEXT(it, default=StopIteration):
    pass

SyntaxError: default argument must be a literal


enumerate(())

SyntaxError: expected an expression, got )


while 1:
    break
else:
    print('while-else')
Traceback (most recent call last):

std::exception: invalid jump

FIX:

for _ in range(1):
    while 1:
        break
    else:
        continue
        print('while-else')

class dlproxy(object):
    def __init__(self, *argv, **env):
        self.__dlref = " ".join(map(str, argv))
        self.__lastc = "__init__"
        self.__serial = 0

    def __call__(self, callid, fn, *argv, **env):
        stack : list = [ callid, fn , argv, env ]
        print(f"{self.__dlref}.{fn}({argv},{env}) {callid=}")

    def __all(self, *argv, **env):
        self.__serial += 1
        return self.__call__(f"C{self.__serial}", self.__lastc, *argv, **env)

    def __getattr__(self, attr):
        self.__lastc = attr
        return self.__all

lib = dlproxy('lib')
lib.trap(1,2,3,key='value')

AttributeError: 'dlproxy' object has no attribute 'trap

FIX

attr = "trap"
argv = (1,2,3)
kw = {"key":'value'}
try:
    getattr(lib, attr)(*argv, **kw)
except AttributeError:
    lib.__getattr__(attr)(*argv, **kw)
del attr, argv, kw

def loc(a,b='b',c="c",**kw):
    print( locals())
loc("a")

NameError: name 'locals' is not defined


@pmp-p pmp-p added the bug Something isn't working label Dec 13, 2023
@pmp-p
Copy link
Owner Author

pmp-p commented Feb 17, 2024

split / rsplit implementations fake.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant