Sure, changing getPath will solve an issue with corrupted (or better to tell filenames created using different encoding than unicode, like cp437).
On the other hand, everywhere, we expect getPath to return unicode string.
So code comparing string and bytes, will start to fail.
>>> if 'hello' in b'hello': print("hello!") ... Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: a bytes-like object is required, not 'str' >>> if b'hello' in 'hello': print("hello!") ... Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: 'in <string>' requires string as left operand, not bytes >>> if 'hello' in b'hello'.decode('utf-8'): print("hello!") ... hello!
One way or another, we need to make changes.
The code on previous posts, I think it was trying to solve exactly that issue. Let getPath return "valid" unicode using "surrogate" in SWIG.
No code is bad, but the if can get simpler, clear to maintain, yes let's go for it.
Let's sleep on it.