EskoSalaka/mtgtools

Invalid set code throws python error instead of warning

quarklark opened this issue · 1 comments

Importing a card list from string with an invalid set code throws the following error:

TypeError: category must be a Warning subclass, not 'str'

Expected was to receive a warning message.

It looks like the error is coming from PCardList.py:1234, which has an extra self.api_type argument.

I seem to have resolved it by removing that extra argument. Here's how I did it.

Original line 1234: warnings.warn(self.api_type, msg.format(self.api_type, line))
New line 1234: warnings.warn(msg.format(self.api_type, line))

Sorry I don't have time to figure out a PR for this project - I'm not familiar enough with Python. Hope this helps

Ahhh yeah, there is of course a bug, the first argument to warnings.warn must be the message and thse second should be the Warning category.

Thanks for the report!