Crash during unitest
mtribiere opened this issue · 3 comments
I use this library in a project, and use the CMake/Ninja combo to unittest it.
On Linux no issues, but on Windows I have a crash. Probalby some issues with the Powershell encoding.
Thanks for your help.
Environment:
- Windows 10
- Python 3.12.0
- CMake/Ninja combo
Log:
ERROR: test_md5_sums_valid (tests.test_cesam.TestCesamDownloadFolder.test_md5_sums_valid)
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\Program Files\Python312\Lib\unittest\mock.py", line 1387, in patched
return func(*newargs, **newkeywargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Tools\DEV\libcesam\tests\test_cesam.py", line 666, in test_md5_sums_valid
test_folder = cesam.download_folder(test_folder)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Tools\DEV\libcesam\libcesam\cesam.py", line 246, in download_folder
with alive_bar(len(["test"])) as bar:
File "C:\Program Files\Python312\Lib\contextlib.py", line 144, in __exit__
next(self.gen)
File "C:\Tools\DEV\libcesam\venv\Lib\site-packages\alive_progress\core\progress.py", line 364, in __alive_bar
alive_repr()
File "C:\Tools\DEV\libcesam\venv\Lib\site-packages\alive_progress\core\progress.py", line 165, in alive_repr
run.last_len = print_cells(fragments, term.cols(), term, run.last_len)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Tools\DEV\libcesam\venv\Lib\site-packages\alive_progress\utils\cells.py", line 109, in print_cells
term.write(join_cells(fragment))
File "C:\Program Files\Python312\Lib\encodings\cp1252.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_table)[0]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeEncodeError: 'charmap' codec can't encode characters in position 1-2: character maps to <undefined>
That's unfortunate, I know. But sadly, I don't know what to do to circumvent these weird windows incompatibilities...
I'd say perhaps you could try WSL2. Since it is a linux environment it should work flawlessly.
If everything else fails, I think you'd have to use both the classic
bar and spinner, since they only use ASCII characters.
hi ! i do not have a working windows python env to test this but i faced a similar issue while web scraping a while back and adding a bunch of encoding="utf-8"
helped me a lot
you could try to git clone ... && cd ... && pip install -e .
then modify each open(..., mode=...)
in this file alive_progress/tools/unicode_breaks.py
with
with open(..., mode=..., encoding="utf-8") as ...:
...
if this does not fix anything then i would definitely recommand quitting python on windows /s
i also should mention any king of standalone binary made with the alive-progress dependency (pyinstall-ing your code base for example) would need additionnal care since some configuration file are not automatically imported or packed
JIT compiling could in some way produce a similar issue, i'm not an expert though these are suppositions
Thanks @ThomasByr, but I think the unicode "breaks" tool has nothing to do with it since it is not used on the alive_bar
impl at all.