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

PEP 0515 (Underscores in Numeric Literals) not taken into account when reading headers. #592

Open
Aycon3296 opened this issue Mar 14, 2024 · 1 comment
Labels

Comments

@Aycon3296
Copy link

Aycon3296 commented Mar 14, 2024

Describe the error
Underscores are accepted as numbers when reading service sections.

For playback
Try to read any title that contains an underscore. For example "WELL" header item in:

~Version Information
#---------------------------------------------------------------- ---------------
VERS. 1.20: CWLS log ASCII Standard - VERSION 1.20
WRAP. YES : Multiple lines per depth step
~Well Information
#---------------------------------------------------------------- ---------------
#MNEM.UNIT DATA TYPE INFORMATION
#--------- -------------------------- -------------- ---------
STRT .M 74 : Start depth
STOP .M 1855 : Stop depth
STEP .M 0.2000 : Step
NULL. -9999 : Null value
COMP. COMPANY: Test
WELL. WELL: 321_04

Expected Behavior
The title will be read as a string with underscores, but not as a number.

Software Versions (fill in the following information):

  • Python version: 3.10.5

Additional context
Due to https://www.python.org/dev/peps/pep-0515/ numbers containing underscores are now considered real numbers. So if you use int(value) inside a try/catch block to check whether the message read is a number, you will run into problems parsing strings like this "WELL . WELL : 321_04" (In "~W" sections).
You could check for "_" signs in the read fragment before doing this. And if the "_" signs are present, then conclude that the fragment read is str instead of int.

@Aycon3296 Aycon3296 added the bug label Mar 14, 2024
@kinverarity1
Copy link
Owner

kinverarity1 commented Mar 14, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants