What it's doing is taking the representation of an empty object, as should be used only for debugging purposes, treating that as a string, and then going on to parse that debugging representation string as a regex. It's absolutely bonkers.
It's like someone in Python going "oh, this object doesn't have a __str__ method defined, but I really need a string! Should I raise an exception? Fuck it, no, I'll just get whatever string I need out of __repr__ instead!"
View all comments
Show parent comment
2
u/dagbrown Mar 21 '24
It's not casting anything.
What it's doing is taking the representation of an empty object, as should be used only for debugging purposes, treating that as a string, and then going on to parse that debugging representation string as a regex. It's absolutely bonkers.
It's like someone in Python going "oh, this object doesn't have a
__str__method defined, but I really need a string! Should I raise an exception? Fuck it, no, I'll just get whatever string I need out of__repr__instead!"