[issue46941] Bug or plug not removed (The operator "is")

2022-03-06 Thread Eric V. Smith


Eric V. Smith  added the comment:

As others have noted, the behavior is intentional, so I'm closing this.

--
nosy: +Dennis Sweeney, Jelle Zijlstra, eric.smith
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46941] Bug or plug not removed (The operator "is")

2022-03-06 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

The code in the screenshot looks correct.



>>> i = 0
>>> i is int
False
>>> type(i) is int
True

The code above does not get warning because "int" is a variable.  This kind of 
comparison is always allowed and will work reliably.



>>> i is 0
:1: SyntaxWarning: "is" with a literal. Did you mean "=="?
True

The above code generates a warning because 0 is a numeric literal and there may 
be more than one instance of that literal.  While this kind of comparison is 
allowed, it is unreliable because numeric literals are not guaranteed to be 
singletons:

>>> x = 600
>>> (x + x) is 1200
:1: SyntaxWarning: "is" with a literal. Did you mean "=="?
False



The reliable and correct way to test numeric values with an equality:

>>> x + x == 1200
True

--
nosy: +rhettinger -Dennis Sweeney, Jelle Zijlstra

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46941] Bug or plug not removed (The operator "is")

2022-03-06 Thread Dennis Sweeney


Dennis Sweeney  added the comment:

In the future, please copy and paste the relevant code and errors as text. 
Images of code are harder for screen-readers for the visually impaired, harder 
to copy-and-paste to verify, and are more likely to be perceived as spam.

Your code is essentially this:

>>> i = 0
>>> i is 0
:1: SyntaxWarning: "is" with a literal. Did you mean "=="?
True

This warning isn't a "stub", it was intentionally added in GH-9642. The warning 
exists because comparing numbers with `is` is generally unsafe (numbers should 
be compared using `==` instead), and can lead to unpredictable results, 
especially if using a different Python implementation (e.g. PyPy or RustPython 
or Jython rather than CPython).

--
nosy: +Dennis Sweeney

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46941] Bug or plug not removed (The operator "is")

2022-03-06 Thread Jelle Zijlstra


Jelle Zijlstra  added the comment:

I don't understand what you are referring to. What do you think is wrong?

--
nosy: +Jelle Zijlstra

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46941] Bug or plug not removed (The operator "is")

2022-03-06 Thread Роман Слабицкий

New submission from Роман Слабицкий :

I understand it's a stub that hasn't been removed, so it's a message from the C 
language that Python runs on in principle.

--
components: Interpreter Core
files: изображение_2022-03-07_023751.png
messages: 414630
nosy: semina054
priority: normal
severity: normal
status: open
title: Bug or plug not removed (The operator "is")
type: behavior
versions: Python 3.9
Added file: https://bugs.python.org/file50659/изображение_2022-03-07_023751.png

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com