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

Incorrect message: "Invalid decimal literal" (python 3.10) #88943

Closed
aroberge mannequin opened this issue Jul 30, 2021 · 6 comments
Closed

Incorrect message: "Invalid decimal literal" (python 3.10) #88943

aroberge mannequin opened this issue Jul 30, 2021 · 6 comments
Assignees
Labels
3.10 only security fixes 3.11 only security fixes 3.12 bugs and security fixes type-bug An unexpected behavior, bug, or error

Comments

@aroberge
Copy link
Mannequin

aroberge mannequin commented Jul 30, 2021

BPO 44780
Nosy @aroberge, @serhiy-storchaka, @pablogsal

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = None
created_at = <Date 2021-07-30.14:52:34.235>
labels = ['3.10', '3.11']
title = 'Incorrect message: "Invalid decimal literal" (python 3.10)'
updated_at = <Date 2021-12-26.17:01:19.886>
user = 'https://github.com/aroberge'

bugs.python.org fields:

activity = <Date 2021-12-26.17:01:19.886>
actor = 'aroberge'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = []
creation = <Date 2021-07-30.14:52:34.235>
creator = 'aroberge'
dependencies = []
files = []
hgrepos = []
issue_num = 44780
keywords = []
message_count = 4.0
messages = ['398556', '398595', '398597', '409212']
nosy_count = 3.0
nosy_names = ['aroberge', 'serhiy.storchaka', 'pablogsal']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'open'
superseder = None
type = None
url = 'https://bugs.python.org/issue44780'
versions = ['Python 3.10', 'Python 3.11']

Linked PRs

@aroberge
Copy link
Mannequin Author

aroberge mannequin commented Jul 30, 2021

Consider the following:

>> a = (1‚ 2) # not a comma, but unicode character.

Using Python 3.9 (and earlier), we get the following correct information

>>> a = (12)
  File "<stdin>", line 1
    a = (1‚ 2)
          ^
SyntaxError: invalid character '‚' (U+201A)

Using Python 3.10, we get the following incorrect information instead:

>>> a = (12)
  File "<stdin>", line 1
    a = (1‚ 2)
         ^
SyntaxError: invalid decimal literal

@aroberge aroberge mannequin added the 3.10 only security fixes label Jul 30, 2021
@aroberge
Copy link
Mannequin Author

aroberge mannequin commented Jul 30, 2021

Here's another related case.

Python 3.9:

>>> a = 1½
  File "<stdin>", line 1
    a = 1½
         ^
SyntaxError: invalid character '½' (U+00BD)

Python 3.10
>>> a = 1½
  File "<stdin>", line 1
    a = 1½
        ^
SyntaxError: invalid decimal literal

@aroberge
Copy link
Mannequin Author

aroberge mannequin commented Jul 30, 2021

Third case. Showing only the output for Python 3.10

>>> a = 37   # entered with a space around ⁄
  File "<stdin>", line 1
    a = 3 ⁄ 7
          ^
SyntaxError: invalid character '⁄' (U+2044)
>>> a = 37    # no added space
  File "<stdin>", line 1
    a = 3⁄7
        ^
SyntaxError: invalid decimal literal

= =
In the terminal, the integers 3 and 7 look the same with or without spaces around the ⁄ character, known as FRACTION SLASH.

@aroberge
Copy link
Mannequin Author

aroberge mannequin commented Dec 26, 2021

The last of these three cases (with FRACTION SLASH) is fixed 3.10.1.

The other two are still present in 3.10.1 and in 3.11.0a3

@aroberge aroberge mannequin added 3.11 only security fixes labels Dec 26, 2021
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
@CC-Kitten
Copy link

another case -
item1_quantity was working just fine assigned as int(input()) and input()
now all of a sudden it is not working correctly

item1_name = input('Enter food item name:\n')

item1_price = float(input('Enter item price:\n'))

item1_quantity = int(input('Enter item quantity:\n'))

item2_name = input('Enter second food item name:\n')

item2_price = float(input('Enter second item price:\n'))

item2_quantity = input('Enter second item quantity:\n')

#assigning variable for calculations of item1 and item2

item1_total = item1_quantity * item1_price
item2_total = item2_quantity * item2_price

#began with print statement of receipt header
print('Receipt')
print('')
#creating print statements with f strings
#to display name and quantity/price of item(s) 1 & 2 equaling total price of each item

print(f'{item1_quantity} {item1_name} @ ${item1_price.2f} = ${item1_total:.2f}')
print(f'{item2_quantity} {item2_name} @ ${item2_price.2f} = ${item2_total:.2f}\n')

@serhiy-storchaka
Copy link
Member

@CC-Kitten, I do not see how your problem is related to this issue. Please open a new issue. Also, it would help if you explain how it "is not working correctly": what is the difference in the behavior between different Python versions, what exactly versions.

@serhiy-storchaka serhiy-storchaka added 3.12 bugs and security fixes type-bug An unexpected behavior, bug, or error labels Sep 24, 2022
@serhiy-storchaka serhiy-storchaka self-assigned this Sep 24, 2022
serhiy-storchaka added a commit to serhiy-storchaka/cpython that referenced this issue Sep 7, 2023
…lows a numerical literal

It now points on the invalid non-ASCII character, not on the valid numerical literal.
serhiy-storchaka added a commit that referenced this issue Sep 7, 2023
… numerical literal (GH-109081)

It now points on the invalid non-ASCII character, not on the valid numerical literal.
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Sep 7, 2023
…lows a numerical literal (pythonGH-109081)

It now points on the invalid non-ASCII character, not on the valid numerical literal.
(cherry picked from commit b2729e9)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
serhiy-storchaka added a commit to serhiy-storchaka/cpython that referenced this issue Sep 7, 2023
…hat follows a numerical literal (pythonGH-109081)

It now points on the invalid non-ASCII character, not on the valid numerical literal..
(cherry picked from commit b2729e9)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
serhiy-storchaka added a commit that referenced this issue Sep 7, 2023
…llows a numerical literal (GH-109081) (GH-109091)

It now points on the invalid non-ASCII character, not on the valid numerical literal.
(cherry picked from commit b2729e9)
Yhg1s pushed a commit that referenced this issue Oct 2, 2023
…llows a numerical literal (GH-109081) (#109090)

gh-88943: Improve syntax error for non-ASCII character that follows a numerical literal (GH-109081)

It now points on the invalid non-ASCII character, not on the valid numerical literal.
(cherry picked from commit b2729e9)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.10 only security fixes 3.11 only security fixes 3.12 bugs and security fixes type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants