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

ezdxf.units.unit_name always returns unitless in some environment #1131

Closed
privet-kitty opened this issue Jul 27, 2024 · 0 comments · Fixed by #1132
Closed

ezdxf.units.unit_name always returns unitless in some environment #1131

privet-kitty opened this issue Jul 27, 2024 · 0 comments · Fixed by #1132

Comments

@privet-kitty
Copy link
Contributor

Thank you for maintaining this awesome package!

Describe the bug
ezdxf.units.unit_name should return the string of the unit name for a given integer of INSUNITS, but in some environment it always returns "unitless" regardless of an input.

I guess this happens in Python 3.11 or later because since then the behaviour of IntEnum.__str__ has been changed as follows:

https://docs.python.org/3/library/enum.html#enum.IntEnum

Changed in version 3.11: str() is now int.str() to better support the replacement of existing constants use-case. format() was already int.format() for that same reason.

(I think the implementation of unit_name can just use InsertUnits(enum).name instead of str().)

To Reproduce

print(ezdxf.units.unit_name(0))  # -> unitless
print(ezdxf.units.unit_name(1))  # -> unitless

As mentioned above, this should be reproduced in Python 3.11 (or later, but I haven't checked that).

Expected behavior

print(ezdxf.units.unit_name(0))  # -> Unitless
print(ezdxf.units.unit_name(1))  # -> Inches
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 a pull request may close this issue.

1 participant