Skip to content

doom.first_prime_with_3_digits() returns None #2

@tpsjr7

Description

@tpsjr7

I installed cataclysm with pip today.
I have a simple main.py

from cataclysm import doom
uhoh = doom.first_prime_with_3_digits()
print(uhoh)

I can see that it called open api (3.5) and it generated the code and put it here datafiles/cataclysm/code/function_first_prime_with_3_digits.yml

"signatures":
  "first_prime_with_3_digits-0-0": |-
    def is_prime(n):
        if n < 2:
            return False
        for i in range(2, int(n ** 0.5) + 1):
            if n % i == 0:
                return False
        return True

    def first_prime_with_3_digits():
        for i in range(100, 1000):
            if is_prime(i):
                return i

When I step in the debugger, I can see that up to the exec(code, ldict) that the "code" variable looks like this

def is_prime(n):
    if n < 2:
        return False
    for i in range(2, int(n ** 0.5) + 1):
        if n % i == 0:
            return False
    return True

def first_prime_with_3_digits():
    for i in range(100, 1000):
        if is_prime(i):
            return i

and the ldict has {'_exec_return_values': None, 'args_in': (), 'kwargs_in': {}}
https://github.com/Mattie/cataclysm/blob/master/cataclysm/doomed.py#L83

but after the exec, the ldict['_exec_return_values'] evaluates to None instead of the expected value of 101.

This happens with other functions I've tried.

I'm running Windows and python 3.11.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions