scarletcafe / jishaku

A debugging and testing cog for discord.py rewrite bots.
https://jishaku.readthedocs.io/en/latest/
MIT License
543 stars 182 forks source link

Fix math domain error #169

Closed yaakiyu closed 2 years ago

yaakiyu commented 2 years ago

when memory bytes was't gotten collectly

Rationale

When memory bytes was't gotten collectly, the jsk command wouldn't run.

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/dist-packages/discord/ext/commands/core.py", line 168, in wrapped
    ret = await coro(*args, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/jishaku/features/root_command.py", line 102, in jsk
    f"{natural_size(mem.uss)} of which unique to this process.")
  File "/usr/local/lib/python3.9/dist-packages/jishaku/features/root_command.py", line 46, in natural_size
    power = int(math.log(size_in_bytes, 1024))
ValueError: math domain error

I checked mem.uss and returned 0. Maybe because the bot is runnning on WSL, but I want to run jsk command. So I created a pull request. I'm Japanese, so my English may look clumsy. Sorry.

Summary of changes made

Only put try and except ValueError: power=0.

Checklist