Skip to content

Conversation

@idk-maybe-none
Copy link

Separate app.py into multiple files, and make that counting now accepts mathematical expressions
I'm not sure that it works on 100%,

Separate app.py into many files, and make that counting now accepts mathematical expressions
Oops, not that config, but atleast its not my testing bot token...
@Anonymous941
Copy link
Contributor

Why does counting accept mathematical expressions? Just for fun?

@Anonymous941
Copy link
Contributor

Also it's kind of hard to audit this, since it's such a large PR and git diff doesn't work. Not a huge deal but worth mentioning I guess

@idk-maybe-none
Copy link
Author

idk-maybe-none commented Oct 31, 2025

Why does counting accept mathematical expressions? Just for fun?

yes :trollface:

@ilovecats4606
Copy link
Contributor

Why does counting accept mathematical expressions? Just for fun?

yes

Mandi's bot added it and i dont see a problem with it its kinda funny

@Anonymous941
Copy link
Contributor

Why does counting accept mathematical expressions? Just for fun?

yes

Mandi's bot added it and i dont see a problem with it its kinda funny

I was just curious. Make sure people can't crash the bot by spamming 2^10000000 or something like that

@idk-maybe-none
Copy link
Author

2^10000000

I didn't think of that
I'll test

@idk-maybe-none
Copy link
Author

I think it's safe:

>>> evaluate("2**999999", {})
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: Exceeds the limit (4300) for integer string conversion; use sys.set_int_max_str_digits() to increase the limit

@Anonymous941
Copy link
Contributor

Anonymous941 commented Nov 2, 2025

That's a string conversion error, according to that it was still calculated somehow?? Maybe it used an approximation or the library uses ^ instead of **?

@Anonymous941
Copy link
Contributor

It turns out 2**999999 isn't large enough and somehow it can calculate it anyway, then fails to turn it into an integer. But running evaluate("2**10000000000") causes it to freeze.

@Anonymous941
Copy link
Contributor

expr.py has protection against DoS attacks, maybe you should use that instead...

@MandiHQ
Copy link

MandiHQ commented Nov 2, 2025

expr.py has protection against DoS attacks, maybe you should use that instead...

Updated my bot to be a bit more strict on the math equations and accept some more symbols.
Also, not coded in python.

@idk-maybe-none
Copy link
Author

That's a string conversion error, according to that it was still calculated somehow?? Maybe it used an approximation or the library uses ^ instead of **?

My bad, didn't read the error message, and thanks for alternative, I'll implement that tomorrow

@idk-maybe-none
Copy link
Author

Hello?

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

Successfully merging this pull request may close these issues.

4 participants