[issue43151] is with literals in 3.8 release

2021-02-07 Thread Steven D'Aprano
Steven D'Aprano added the comment: Terry, this may be an IDLE issue, can you confirm whether or not the difference in behaviour is intentional? -- nosy: +terry.reedy resolution: not a bug -> stage: resolved -> status: closed -> open ___ Python tr

[issue43151] is with literals in 3.8 release

2021-02-07 Thread Gary Litvin
Gary Litvin added the comment: I noticed it in IDLE 3.8. I installed 3.8 because it is a fairly recent release described as "stable." Thanks to everyone for considering this. At 03:41 AM 2/7/2021, you wrote: >Dennis Sweeney added the comment: > >I think the strangeness is happening because

[issue43151] is with literals in 3.8 release

2021-02-07 Thread Dennis Sweeney
Dennis Sweeney added the comment: I think the strangeness is happening because sometimes, the warning is printed to stderr, while other times, IDLE's parser notices the "is " anti-pattern and raises a SyntaxError. See the attached screenshot for the IDLE output versus the console output for

[issue43151] is with literals in 3.8 release

2021-02-07 Thread Dennis Sweeney
Dennis Sweeney added the comment: There may be reason to re-open this. With Python 3.9.0, I see the inconsistent behavior that Gary describes only when using IDLE. So this is likely an IDLE issue. I attached a screenshot of the difference. -- Added file: https://bugs.python.org/file

[issue43151] is with literals in 3.8 release

2021-02-06 Thread Steven D'Aprano
Steven D'Aprano added the comment: Gary, I cannot replicate that inconsistency in 3.9.0. >>> x = "abc" >>> x is "abc" :1: SyntaxWarning: "is" with a literal. Did you mean "=="? True >>> if x is "abc": pass ... :1: SyntaxWarning: "is" with a literal. Did you mean "=="? I don't believe that

[issue43151] is with literals in 3.8 release

2021-02-06 Thread Gary Litvin
Gary Litvin added the comment: Thank you for your responses. I understand the difference between == and "is" and the intentional change in 3.8. My question is about what seems to be inconsistent treatment in x is 'a' and if a is 'a': ... At 12:49 AM 2/7/2021, Raymond Hettinger wrote: >Raymo

[issue43151] is with literals in 3.8 release

2021-02-06 Thread Raymond Hettinger
Raymond Hettinger added the comment: As Dennis says, this is an intentional behavior and will help you avoid bugs. -- nosy: +rhettinger resolution: -> not a bug stage: -> resolved status: open -> closed ___ Python tracker

[issue43151] is with literals in 3.8 release

2021-02-06 Thread Dennis Sweeney
Dennis Sweeney added the comment: This was a very intentional change from the commit 3bcbedc9f1471d957a30a90f9d1251516b422416 It's not safe to check `x is y` when x and y are strings. You should always use `x == y` for strings instead. In CPython, if the names x and y both refer to the same u

[issue43151] is with literals in 3.8 release

2021-02-06 Thread Gary Litvin
New submission from Gary Litvin : >>> x = 'a' >>> x is 'a' True >>> if x is 'a': print(x) SyntaxError: "is" with a literal. Did you mean "=="? How come? -- messages: 386575 nosy: garylitvin priority: normal severity: normal status: open title: is with literals in 3.8 release v