Good work on the last issue! I found another bug!
Describe the bug
I noticed that in some instances a .exe
would not be added to the firewall. It happens when a a folder has non alphanumeric characters in it. An example would be the character โ
. Some characters like ยฉ
. Not all nonalphanumeric characters seem to cause a problem though.
To Reproduce
- Have a folder with a special character in it like:
โ
- Allow/Deny access via context menu on that specific folder
Expected behavior
No error or maybe a notification.
Error Log
Here are some error logs:
root - ERROR - Runtime error is "'charmap' codec can't encode characters in position 59-60:
character maps to <undefined>",
see full traceback bellow:
Traceback (most recent call last):
File "src\cmdWorker.py", line 86, in access_handler
print(Path(y))
File "encodings\cp1252.py", line 19, in encode
UnicodeEncodeError: 'charmap' codec can't encode characters in position 59-60: character maps to <undefined>
Traceback (most recent call last):
File "main.py", line 63, in <module>
File "src\logger.py", line 7, in actionLogger
print(actionLogged)
File "encodings\cp1252.py", line 19, in encode
UnicodeEncodeError: 'charmap' codec can't encode character '\u253c' in position 64: character maps to <undefined>
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "main.py", line 86, in <module>
File "src\logger.py", line 27, in logException
actionLogger(f'Exception logged, runtime error is "{Critical}"')
File "src\logger.py", line 7, in actionLogger
print(actionLogged)
File "encodings\cp1252.py", line 19, in encode
UnicodeEncodeError: 'charmap' codec can't encode character '\u253c' in position 138: character maps to <undefined>
Desktop (please complete the following information):
- OS: Microsoft Windows 11 Education
- Version 10.0.22000 Build 22000
Additional context
Now I had a look at the source code at line:
if z in Path(y).suffix and Path(y).stem not in ignoredFiles:
print(Path(y))
allFiles.append(Path(y))
The error seems to be at the print()
statement from what I can tell. This might be an error in the library you are using (from pathlib import Path
), when the Path(y)
is converted to a string.
Some libraries allow to set the encoding like, io
:
import io
with io.open(filename,'r',encoding='utf8') as f:
text = f.read()
But I did not look into the pathlib
library further. It could also be that the error logs are inconclusive and the error happens somewhere further up the chain, you could debug it and see what happens.
A few options could be:
- Find out if you can set encoding for the library
- Try catch exception and skip folder if it happens (so at least other folders are added)
- Maybe a message would be good
- Use another library that handles characters correctly
Have fun!