This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients serhiy.storchaka, vstinner, yselivanov
Date 2016-01-26.22:33:02
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1453847582.53.0.0969666623432.issue26204@psf.upfronthosting.co.za>
In-reply-to
Content
> Maybe the compiler should emit a warning to say that the code doesn't make sense at all and is ignored?

Oh ok, now I recall a similar issue that I posted 3 years ago: issue #17516, "Dead code should be removed".

Example of suspicious code:

def func():
   func2(),

func() calls func2() and then create a tuple of 1 item with the func2() result. See my changeset 33bdd0a985b9 for examples in the Python source code. The parser or compiler should maybe help to developer to catch such strange code :-)

In some cases, the code really contains code explicitly dead:

def test_func():
   return
   do_real_stuff()

do_real_stuff() is never called. Maybe it was a deliberate choice, maybe it was a mistake in a very old code base, bug introduced after multiple refactoring, and high turn over in a team? Again, we should emit a warning on such case?

Hum, these warnings have a larger scope than this specific issue (don't emit LOAD_CONST for constants in expressions).

See also the related thread on python-dev for the specific case of triple quoted strings ("""string"""): https://mail.python.org/pipermail/python-dev/2013-March/124925.html

It was admitted that it's a convenient way to insert a comment and it must not emit a warning (at least, not by default?)
History
Date User Action Args
2016-01-26 22:33:02vstinnersetrecipients: + vstinner, serhiy.storchaka, yselivanov
2016-01-26 22:33:02vstinnersetmessageid: <1453847582.53.0.0969666623432.issue26204@psf.upfronthosting.co.za>
2016-01-26 22:33:02vstinnerlinkissue26204 messages
2016-01-26 22:33:02vstinnercreate