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

parse_string_unsafe() fails to parse strings with Bit or Byte unit #106

Open
Mercury37 opened this issue Apr 29, 2024 · 1 comment
Open

Comments

@Mercury37
Copy link

Expected behaviour

I was expecting parse_string_unsafe() to parse all of the following units, but at the very least the ones that parse_string() can parse:

  • b
  • bit
  • Bit
  • bits
  • Bits
  • B
  • byte
  • Byte
  • bytes
  • Bytes

Actual behaviour

parse_string_unsafe() fails for all strings consisting of a number and any of the above units:

parse_string_unsafe("1 b")

Results in an error message:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "D:\Python\Lib\site-packages\bitmath\__init__.py", line 1552, in parse_string_unsafe
    raise ValueError("The unit %s is not a valid bitmath unit" % unit)
ValueError: The unit B is not a valid bitmath unit

Similarly:

parse_string_unsafe("1 Byte")

Produces:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "D:\Python\Lib\site-packages\bitmath\__init__.py", line 1552, in parse_string_unsafe
    raise ValueError("The unit %s is not a valid bitmath unit" % unit)
ValueError: The unit ByteB is not a valid bitmath unit

The other units listed behave in the same way.

Versions

  • bitmath: 1.3.3.1 (PyPi)
  • Windows 10
  • Python 3.12.1
@tbielawa
Copy link
Owner

tbielawa commented Jun 2, 2024

Hi there, I see your issue here and I will be looking at things here again soon. 2023 was especially busy for me and I am just now getting settled into a place where I can get back to work here. Thanks for your patience.

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

No branches or pull requests

2 participants