Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle non-UTF-8 device models #108

Merged
merged 1 commit into from
Jan 17, 2025

Conversation

jstasiak
Copy link
Contributor

@jstasiak jstasiak commented Sep 23, 2024

Took me a while to figure out why Fedora 40 installer was dying on me on a Wyse 3040 thin client and I finally narrowed it down to pyparted and found the associated issue (linked).

The fix proposed in the issue comments worked for me so I figured I'd send a PR.

Before:

>>> import parted
>>> parted.getDevice('/dev/mmcblk0').model
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/root/pyparted/build/lib.linux-x86_64-cpython-312/parted/device.py", line 69, in model
    return self.__device.model
           ^^^^^^^^^^^^^^^^^^^
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x92 in position 9: invalid start byte

After:

>>> import parted
>>> parted.getDevice('/dev/mmcblk0').model
'MMC H8G4a�'

Resolves: #76

Took me a while to figure out why Fedora 40 installer was dying on me
on a Wyse 3040 thin client and I finally narrowed it down to pyparted
and found the associated issue (linked).

The fix proposed in the issue comments worked for me so I figured I'd
send a PR.

Before:

    >>> import parted
    >>> parted.getDevice('/dev/mmcblk0').model
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/root/pyparted/build/lib.linux-x86_64-cpython-312/parted/device.py", line 69, in model
        return self.__device.model
               ^^^^^^^^^^^^^^^^^^^
    UnicodeDecodeError: 'utf-8' codec can't decode byte 0x92 in position 9: invalid start byte

After:

    >>> import parted
    >>> parted.getDevice('/dev/mmcblk0').model
    'MMC H8G4a�'

Resolves: dcantrell#76
Copy link
Owner

@dcantrell dcantrell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like the // comment style and prefer the /* */ style as you see in the rest of the code. But I will take this patch. I might change the comment style later though.

@dcantrell dcantrell merged commit ee4bf04 into dcantrell:main Jan 17, 2025
@jstasiak
Copy link
Contributor Author

Ugh, totally unintentional and I agree with you!

@jstasiak jstasiak deleted the handle-non-utf-8-model branch January 17, 2025 19:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Exception when returning non-UTF-8 model names
2 participants