pyne / pyne

PyNE: The Nuclear Engineering Toolkit
http://pyne.io/
Other
259 stars 176 forks source link

test_material.py - UnicodeDecodeError #1535

Open sturmk opened 2 weeks ago

sturmk commented 2 weeks ago

Describe the Bug
When using any functionality related to materials, I get an UnicodeDecodeError. Specifically, running the test test_material.py triggers this issue reliably.

To Reproduce
Run pyne tests.

Expected Behavior
No error.

Screenshots or Code Snippets

===================================================================== test session starts =====================================================================
platform linux -- Python 3.11.6, pytest-7.4.0, pluggy-1.2.0
rootdir: /home/karl/tools/pyne
collected 108 items                                                                                                                                           

test_material.py ............................................................F...............................................                           [100%]

========================================================================== FAILURES ===========================================================================
______________________________________________________________________ test_getitem_str _______________________________________________________________________

    def test_getitem_str():
        mat = Material(nucvec)
        assert mat["U235"] == 1.0
>       pytest.raises(RuntimeError, lambda: mat["word"])

test_material.py:769: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
test_material.py:769: in <lambda>
    pytest.raises(RuntimeError, lambda: mat["word"])
material.pyx:1485: in pyne.material._Material.__getitem__
    ???
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

>   ???
E   UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb2 in position 1: invalid start byte

nucname.pyx:188: UnicodeDecodeError
=================================================================== short test summary info ===================================================================
FAILED test_material.py::test_getitem_str - UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb2 in position 1: invalid start byte
================================================================ 1 failed, 107 passed in 0.47s ================================================================
Testing failed on test_material.py

Please complete the following information regarding your system:

welcome[bot] commented 2 weeks ago

Hi, and welcome to PyNE! :wave: Thanks for opening your first issue. We recommend that you include information such as the version of PyNE you're working with (eg, develop branch or a specific version), the platform you are operating on, the expected behavior, and the actual behavior you are bringing our attention to. The more deatil you provide, the better others in this community will be able to help you.

sturmk commented 2 weeks ago

Update: seems to be a general issue with Pyne on Ubuntu 23.10. On Ubuntu 22.04 LTS, installation and usage of pyne is flawless. This would also be interesting to try on the freshly released Ubuntu 24.04 LTS

gonuke commented 2 weeks ago

We'll definitely have to dig into the 24.04 and see what new surprises await!

ahnaf-tahmid-chowdhury commented 2 weeks ago

Python has been updated, and we need to update our code accordingly. The current logic of the code is that if it sends a RuntimeError, the test will pass. However, with the new update, I think, Python>3.10 also checks for a UnicodeDecodeError. Therefore, we need to modify our code to include this as well.

pytest.raises([RuntimeError, UnicodeDecodeError], lambda: mat["word"])