easygui icon indicating copy to clipboard operation
easygui copied to clipboard

TypeError: expected string or buffer

Open anomalous3 opened this issue 9 years ago • 1 comments

It looks like utils.py passes text that does not have a declared type to re.search, which can cause an error "TypeError: expected string or buffer". This can be corrected by changing lines 122,130, and 138 as follows: res = re.search('(?<=\[).(?=\])', text) to res = re.search('(?<=\[).(?=\])', str(text)) res = re.search('(?<=\[\[).(?=\]\])', text) to res = re.search('(?<=\[\[).(?=\]\])', str(text)) res = re.search('(?<=\[\<).+(?=\>\])', text) to res = re.search('(?<=\[\<).+(?=\>\])', str(text))

anomalous3 avatar Jun 08 '16 00:06 anomalous3

Can you explain your case for this? If you pass something that is not a string into a hotkey, the TypeError should be expected, in my opinion. I'm not seeing the benefit of trying to convert the type.

One problem that could occur by doing this is if someone unintentionally passes in an object that will be converted to something like "<class '__main__.MyClassName'>" and could potentially make debugging harder for someone.

It would probably be more useful to the user if an error were thrown... The error is descriptive enough for someone to immediately recognize the problem and they can pass in str(choice_arg) themselves if that's the desired behavior.

spyoungtech avatar Sep 23 '16 17:09 spyoungtech