[issue34850] Emit a syntax warning for "is" with a literal

2019-12-21 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: It cannot be suppressed by the code in the module caused a warning, because the warning is emitted at compile time. You need to silence it before compiling that module. Once you have compiled it, warning will no longer be emitted. --

[issue34850] Emit a syntax warning for "is" with a literal

2019-12-19 Thread thautwarm
thautwarm added the comment: Thanks. However, unfortunately, this warning seems impossible to suppress. Use following example: import warnings warnings.filterwarnings('ignore') warnings.warn(SyntaxWarning("test")) def f(x): return x is 5 print(f(5)) I succeeded in

[issue34850] Emit a syntax warning for "is" with a literal

2019-11-17 Thread Bachsau
Change by Bachsau : -- nosy: -Bachsau ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue34850] Emit a syntax warning for "is" with a literal

2019-11-17 Thread Ammar Askar
Ammar Askar added the comment: That would potentially let an invalid usage slip through, since you know what you're doing, you can suppress the warning with: warnings.filterwarnings('ignore', category=SyntaxWarning, message='"is" with a literal') -- nosy: +ammar2

[issue34850] Emit a syntax warning for "is" with a literal

2019-11-17 Thread thautwarm
thautwarm added the comment: What if using identity equality on integer literals is intended? I'm now trying to speed up the generated code via the integer interning mechanism told by https://docs.python.org/3/c-api/long.html#c.PyLong_FromLong . I think it okay to not complain when the

[issue34850] Emit a syntax warning for "is" with a literal

2019-06-10 Thread Brett Cannon
Change by Brett Cannon : -- nosy: +brett.cannon ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue34850] Emit a syntax warning for "is" with a literal

2019-06-10 Thread STINNER Victor
Change by STINNER Victor : -- nosy: -vstinner ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue34850] Emit a syntax warning for "is" with a literal

2019-06-09 Thread Gregory P. Smith
Change by Gregory P. Smith : -- nosy: -gregory.p.smith ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue34850] Emit a syntax warning for "is" with a literal

2019-06-09 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: > Should this also produce warnings for `list` / `dict` / `set` literals? No, because these cases are useless expressions, but they are not hidden bugs. The result is always False and does not rely on the implementation. > SyntaxWarnings should be raised

[issue34850] Emit a syntax warning for "is" with a literal

2019-06-09 Thread Steven D'Aprano
Steven D'Aprano added the comment: Bachsau, to respond to the substance of your comments: it is not the *primary* purpose of a compiler to teach, but compiler warnings on potentially wrong behaviour is a long-standing tradition in many languages, including Python. This is not the first

[issue34850] Emit a syntax warning for "is" with a literal

2019-06-09 Thread Terry J. Reedy
Terry J. Reedy added the comment: "This is bullshit." struck me as jarring and rude. I will stop there. -- ___ Python tracker ___

[issue34850] Emit a syntax warning for "is" with a literal

2019-06-09 Thread Terry J. Reedy
Change by Terry J. Reedy : -- nosy: -terry.reedy ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue34850] Emit a syntax warning for "is" with a literal

2019-06-09 Thread Steven D'Aprano
Steven D'Aprano added the comment: > (message from a code of conduct violating troll deleted) How did Bachsau violate the code of conduct, and what evidence do you have that they were anything but 100% sincere in their comments? >From where I am sitting, the only person violating the CoC is

[issue34850] Emit a syntax warning for "is" with a literal

2019-06-09 Thread Gregory P. Smith
Gregory P. Smith added the comment: (message from a code of conduct violating troll deleted) -- ___ Python tracker ___ ___

[issue34850] Emit a syntax warning for "is" with a literal

2019-06-09 Thread Gregory P. Smith
Change by Gregory P. Smith : -- Removed message: https://bugs.python.org/msg345086 ___ Python tracker ___ ___ Python-bugs-list

[issue34850] Emit a syntax warning for "is" with a literal

2019-06-09 Thread Bachsau
Bachsau added the comment: This is bullshit. SyntaxWarnings should be raised on problems with the *syntax* not for ProgrammerMightBeDumb errors. There are a whole lot of things a programmer not knowing the language could do wrong. But these are syntactically valid expressions and it is not

[issue34850] Emit a syntax warning for "is" with a literal

2019-04-13 Thread Anthony Sottile
Anthony Sottile added the comment: Should this also produce warnings for `list` / `dict` / `set` literals? ``` $ python3.8 Python 3.8.0a3 (default, Mar 27 2019, 03:46:44) [GCC 7.3.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> x is [] False >>> x is {}

[issue34850] Emit a syntax warning for "is" with a literal

2019-01-21 Thread STINNER Victor
STINNER Victor added the comment: The warning is emited twice, see: bpo-35798. -- nosy: +vstinner ___ Python tracker ___ ___

[issue34850] Emit a syntax warning for "is" with a literal

2019-01-17 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Thanks. -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker ___

[issue34850] Emit a syntax warning for "is" with a literal

2019-01-17 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: New changeset 3bcbedc9f1471d957a30a90f9d1251516b422416 by Serhiy Storchaka in branch 'master': bpo-34850: Emit a warning for "is" and "is not" with a literal. (GH-9642) https://github.com/python/cpython/commit/3bcbedc9f1471d957a30a90f9d1251516b422416

[issue34850] Emit a syntax warning for "is" with a literal

2019-01-17 Thread Gregory P. Smith
Gregory P. Smith added the comment: Lets move forward with this as a SyntaxWarning in 3.8 and see if anyone complains during the betas. -- ___ Python tracker ___

[issue34850] Emit a syntax warning for "is" with a literal

2019-01-11 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: If you are fine with this change Gregory, do you mind to withdraw your request and remove the DO-NOT-MERGE label on GitHub? As for DeprecationWarning vs SyntaxWarning: 1. It looks as misuse of DeprecationWarning. We do not plan to remove this feature in

[issue34850] Emit a syntax warning for "is" with a literal

2018-12-01 Thread Gregory P. Smith
Gregory P. Smith added the comment: Oh neat, I didn't realize that Nathaniel. That makes such warnings much more useful. I'm fine if you go ahead with this change. In the unlikely event it turns out to cause user annoyance problems in betas due to third party code that can't be updated,

[issue34850] Emit a syntax warning for "is" with a literal

2018-11-30 Thread Nathaniel Smith
Nathaniel Smith added the comment: > In my experience people are more likely to run code through a linter than > they are to ever run an interpreter with DeprecationWarning enabled. This used to be true, and it was a disaster. So there's been a lot of work to fix it, and it's not true

[issue34850] Emit a syntax warning for "is" with a literal

2018-11-30 Thread Barry A. Warsaw
Barry A. Warsaw added the comment: I'm actually fine either way. Consider me a solid ±0 -- ___ Python tracker ___ ___

[issue34850] Emit a syntax warning for "is" with a literal

2018-11-30 Thread Steven D'Aprano
Steven D'Aprano added the comment: Looks like we have a stand-off between core devs, and no BDFL to make a ruling. There is support for the feature from at least Barry and Raymond (although I think Guido was cool on the idea, maybe?). Gregory, do you feel strongly enough about this that

[issue34850] Emit a syntax warning for "is" with a literal

2018-11-30 Thread Gregory P. Smith
Gregory P. Smith added the comment: Given that linters like pylint can already detect the common case of this issue when using `is` and `is not` to compare to a literal where == or != seems more appropriate, I don't think a warning is very useful. In my experience people are more likely to

[issue34850] Emit a syntax warning for "is" with a literal

2018-11-30 Thread Nathaniel Smith
Nathaniel Smith added the comment: Would it be more acceptable to use a DeprecationWarning? It's not really the right thing because we're not planning to ever actually remove the functionality. But, we've already gone to a lot of trouble to try to show DeprecationWarnings specifically to

[issue34850] Emit a syntax warning for "is" with a literal

2018-11-30 Thread Guido van Rossum
Change by Guido van Rossum : -- nosy: -gvanrossum ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue34850] Emit a syntax warning for "is" with a literal

2018-11-30 Thread Terry J. Reedy
Terry J. Reedy added the comment: I like this proposal better than a separate test mode. But users will see compiler warnings for main modules and for packages recompiled for a new version or for a maintenance releases with a byte code bump, and for unprecompiled packages on systems that

[issue34850] Emit a syntax warning for "is" with a literal

2018-11-30 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Ping. -- ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue34850] Emit a syntax warning for "is" with a literal

2018-10-29 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Gregory, do you still have objections against adding these warnings? -- ___ Python tracker ___

[issue34850] Emit a syntax warning for "is" with a literal

2018-10-04 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: > Turn the check on only when PYTHONDEVMODE is set? This will reduce the value of this warning to zero. If the user doesn't know that using "is" with string or numerical literals is bad and doesn't use checkers, it is unlikely that he uses PYTHONDEVMODE.

[issue34850] Emit a syntax warning for "is" with a literal

2018-10-04 Thread Neil Schemenauer
Neil Schemenauer added the comment: > The problem with a SyntaxWarning is that the wrong people will see it. It > gets in the way of users of applications that happen to be written in Python. Turn the check on only when PYTHONDEVMODE is set? Seems like it solves the issue with the wrong

[issue34850] Emit a syntax warning for "is" with a literal

2018-10-02 Thread Raymond Hettinger
Raymond Hettinger added the comment: > I like this solution of a syntax warning for `is ` > and I agree that `== None` should not be a warning. +1 for me as well. Besides catching potential bugs, it will be of instant benefit for teaching Python. -- nosy: +rhettinger

[issue34850] Emit a syntax warning for "is" with a literal

2018-10-01 Thread Steven D'Aprano
Steven D'Aprano added the comment: Please move the "chaos" discussion to #34867 -- ___ Python tracker ___ ___ Python-bugs-list

[issue34850] Emit a syntax warning for "is" with a literal

2018-10-01 Thread Guido van Rossum
Guido van Rossum added the comment: Consider moving the chaos discussion to a new issue. On Mon, Oct 1, 2018 at 6:33 AM Steven D'Aprano wrote: > > Steven D'Aprano added the comment: > > On Sun, Sep 30, 2018 at 10:24:41PM +, Nathaniel Smith wrote: > > Would it make sense to implement a

[issue34850] Emit a syntax warning for "is" with a literal

2018-10-01 Thread Steven D'Aprano
Steven D'Aprano added the comment: On Sun, Sep 30, 2018 at 10:24:41PM +, Nathaniel Smith wrote: > Would it make sense to implement a "chaos" mode (that e.g. testing > tools could enable unconditionally), that disables the small integer > and small string caches? I'm not really sure that

[issue34850] Emit a syntax warning for "is" with a literal

2018-10-01 Thread Jakub Wilk
Change by Jakub Wilk : -- nosy: +jwilk ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue34850] Emit a syntax warning for "is" with a literal

2018-09-30 Thread Nathaniel Smith
Nathaniel Smith added the comment: Yeah, something like that. Or sys.enable_chaos_mode(), that pytest or whoever could call before running tests. -- ___ Python tracker ___

[issue34850] Emit a syntax warning for "is" with a literal

2018-09-30 Thread Gregory P. Smith
Gregory P. Smith added the comment: If we were to ship a "chaos" mode in the CPython interpreter itself, I assume you envision an interpreter flag and/or env var? If it required someone compiling the interpreter a special way I don't think it would be widely adopted within continuous

[issue34850] Emit a syntax warning for "is" with a literal

2018-09-30 Thread Nathaniel Smith
Nathaniel Smith added the comment: Would it make sense to implement a "chaos" mode (that e.g. testing tools could enable unconditionally), that disables the small integer and small string caches? -- nosy: +njs ___ Python tracker

[issue34850] Emit a syntax warning for "is" with a literal

2018-09-30 Thread miss-islington
miss-islington added the comment: New changeset cb0bec37dd8279555bc01fa03a259eaf7dbb6d5d by Miss Islington (bot) in branch '3.6': bpo-34850: Replace is with == in idlelib.iomenu (GH-9649) https://github.com/python/cpython/commit/cb0bec37dd8279555bc01fa03a259eaf7dbb6d5d --

[issue34850] Emit a syntax warning for "is" with a literal

2018-09-30 Thread miss-islington
miss-islington added the comment: New changeset 214c0b3d153c4bad14086888b9de0826a7abc083 by Miss Islington (bot) in branch '3.7': bpo-34850: Replace is with == in idlelib.iomenu (GH-9649) https://github.com/python/cpython/commit/214c0b3d153c4bad14086888b9de0826a7abc083 -- nosy:

[issue34850] Emit a syntax warning for "is" with a literal

2018-09-30 Thread Terry J. Reedy
Terry J. Reedy added the comment: To me, this issue is about unnecessary dependence on implementation details, with the particular example being 'is' versus '=='. Perhaps PEP8, Programming Recommendations, should have a new subsection 'Implementation Dependencies' to recommend against such

[issue34850] Emit a syntax warning for "is" with a literal

2018-09-30 Thread miss-islington
Change by miss-islington : -- pull_requests: +9042 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue34850] Emit a syntax warning for "is" with a literal

2018-09-30 Thread miss-islington
Change by miss-islington : -- pull_requests: +9041 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue34850] Emit a syntax warning for "is" with a literal

2018-09-30 Thread Terry J. Reedy
Terry J. Reedy added the comment: New changeset 5fa247d60d4f3f2b8c8ae8cb57363aca234344c2 by Terry Jan Reedy in branch 'master': bpo-34850: Replace is with == in idlelib.iomenu (GH-9649) https://github.com/python/cpython/commit/5fa247d60d4f3f2b8c8ae8cb57363aca234344c2 --

[issue34850] Emit a syntax warning for "is" with a literal

2018-09-30 Thread Terry J. Reedy
Change by Terry J. Reedy : -- pull_requests: +9040 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue34850] Emit a syntax warning for "is" with a literal

2018-09-30 Thread Guido van Rossum
Guido van Rossum added the comment: Yet, Greg’s point is that this only works if the developer tests their code with the new Python version. I’m not sure that his proposal is better though. I think static checkers are the better remedy. On Sun, Sep 30, 2018 at 10:02 AM Serhiy Storchaka

[issue34850] Emit a syntax warning for "is" with a literal

2018-09-30 Thread Barry A. Warsaw
Barry A. Warsaw added the comment: This is a nice approach to the problem. I completely agree that we cannot change `is` semantics. I'm okay with leaving it to checkers to catch `== None`. -- ___ Python tracker

[issue34850] Emit a syntax warning for "is" with a literal

2018-09-30 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: There is a large difference with the DeprecationWarning in the md5 and sha modules. A SyntaxWarning is emitted when the compiler compiles Python sources to bytecode. Since bytecode is cached in pyc files, you will see it at most once at first run of the

[issue34850] Emit a syntax warning for "is" with a literal

2018-09-30 Thread Gregory P. Smith
Gregory P. Smith added the comment: The problem with a SyntaxWarning is that the wrong people will see it. It gets in the way of users of applications that happen to be written in Python. scenarios: (a) A Python interpreter gets upgraded, and suddenly the _users_ of an application start

[issue34850] Emit a syntax warning for "is" with a literal

2018-09-30 Thread Xiang Zhang
Xiang Zhang added the comment: I have catched using `is` to do string equality check in our codebase by linters before. Not all my colleagues know what's not suitable here. The only common and suitable case I can think of is programmers are exploring CPython internals, like what

[issue34850] Emit a syntax warning for "is" with a literal

2018-09-30 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Suggestions about the wording of the warning message are welcome. -- ___ Python tracker ___

[issue34850] Emit a syntax warning for "is" with a literal

2018-09-30 Thread Steven D'Aprano
Steven D'Aprano added the comment: I like this solution of a syntax warning for `is ` and I agree that `== None` should not be a warning. (And for what its worth, I strongly disagree with making `is` a hybrid sometimes-check-identity-sometimes-check-equality operator.) -- nosy:

[issue34850] Emit a syntax warning for "is" with a literal

2018-09-30 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: It also fixes an incorrect use of "is" with an empty string in IDLE. -- assignee: -> terry.reedy components: +IDLE nosy: +terry.reedy ___ Python tracker

[issue34850] Emit a syntax warning for "is" with a literal

2018-09-30 Thread Serhiy Storchaka
Change by Serhiy Storchaka : -- keywords: +patch pull_requests: +9034 stage: -> patch review ___ Python tracker ___ ___

[issue34850] Emit a syntax warning for "is" with a literal

2018-09-30 Thread Serhiy Storchaka
New submission from Serhiy Storchaka : Gregory have noticed that the "is" and "is not" operator sometimes is used with string and numerical literals. This code "works" on CPython by accident, because of caching on different levels (small integers and strings caches, interned strings,