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

Fix for "NoneType object has no attribute group" error #38

Open
Bobidobi opened this issue Jan 31, 2025 · 0 comments
Open

Fix for "NoneType object has no attribute group" error #38

Bobidobi opened this issue Jan 31, 2025 · 0 comments

Comments

@Bobidobi
Copy link

Bobidobi commented Jan 31, 2025

Tested on latest miniconda with Python 3.10.16

Unsloth throws error:
AttributeError: 'NoneType' object has no attribute 'group'
Which links to

n = len(re.search(r"\n([ ]{1,})return compiled_fn", source).group(1))

I suggest adding safecheck as described in pyrhon docs

match = re.search(r"\n([ ]{1,})return compiled_fn", source)
if match:
    n = len(match.group(1))
else:
    n = 0

That code fixed it for me
P.S. Sorry, i'm not pushing commit, because i'm not a good programmer, maybe there is a more elegant solution to that error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant