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.

classification
Title: "continue" inside "try" (PR#177)
Type: enhancement Stage:
Components: Interpreter Core Versions:
process
Status: closed Resolution: later
Dependencies: Superseder:
Assigned To: fdrake Nosy List: fdrake, jhylton, nobody, twouters
Priority: low Keywords:

Created on 2000-08-01 21:12 by anonymous, last changed 2022-04-10 16:02 by admin. This issue is now closed.

Messages (7)
msg720 - (view) Author: Nobody/Anonymous (nobody) Date: 2000-08-01 21:12
Jitterbug-Id: 177
Submitted-By: simonb@logical.co.za
Date: Tue, 11 Jan 2000 05:17:37 -0500 (EST)
Version: 1-5-2
OS: NT 4.0


Hi there

I don't know if this is a bug, or is intentional behaviour for a specific
reason.

The following code produces a syntax error about the continue not being within a
looping structure rather than a prefectly silly infinite loop...

while 1:
  try:
    continue
  except:
    pass

where the following works as one would expect...

while 1:
  try:
    raise 1
  except:
    continue

I figure that there is more likely a sane reason for this behaviour than being a
bug, but I am curious.

Thanks
Simon



====================================================================
Audit trail:
Wed Jan 12 18:11:45 2000	guido	changed notes
Wed Jan 12 18:11:45 2000	guido	moved from incoming to request
msg721 - (view) Author: Nobody/Anonymous (nobody) Date: 2000-08-01 21:12
From: "Tim Peters" <tim_one@email.msn.com>
Subject: RE: [Python-bugs-list] Syntax (PR#177)
Date: Tue, 11 Jan 2000 12:10:17 -0500

[Simon Barratt, putting "continue" in a "try" block]
> I don't know if this is a bug, or is intentional behaviour
> for a specific reason.

Actually, it's a bit of both <wink>.  See the Language Reference Manual's
section on the "continue" statement, particularly the footnote:

    The restriction on occurring in the try clause is
    implementer's laziness and will eventually be lifted.

It's been this way (and documented) forever; it's simply hard to implement
given the current structure of the interpreter loop.

Rest assured there's nothing *conceptually* wrong with putting continue in a
try!  It's simply an implementation restriction; the error msg should
probably make that clearer.  IIRC, JPython doesn't have this restriction.
"Someday" it will get repaired in CPython too.


msg722 - (view) Author: Nobody/Anonymous (nobody) Date: 2000-08-01 21:12
It's a zero-priority bug (i.e. not likely to be fixed).
msg723 - (view) Author: Thomas Wouters (twouters) * (Python committer) Date: 2000-08-03 20:00
Like the bot said, low priority 'to be fixed' bug.
msg724 - (view) Author: Jeremy Hylton (jhylton) (Python triager) Date: 2000-09-07 22:05
Please do triage on this bug.
msg725 - (view) Author: Fred Drake (fdrake) (Python committer) Date: 2000-09-08 16:37
Improved exception messages when 'continue' is in a 'try' block, checked in as Python/compile.c revision 2.141.  This still doesn't do the "right thing" by implementing 'continue' in this context, but makes it easier for users to understand the exception.
msg726 - (view) Author: Fred Drake (fdrake) (Python committer) Date: 2000-10-03 15:45
Added this to PEP 42; closing the bug report.
History
Date User Action Args
2022-04-10 16:02:13adminsetgithub: 32831
2000-08-01 21:12:34anonymouscreate