Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3.x ignores sys.tracebacklimit=0 #56485

Closed
ggenellina mannequin opened this issue Jun 7, 2011 · 8 comments
Closed

3.x ignores sys.tracebacklimit=0 #56485

ggenellina mannequin opened this issue Jun 7, 2011 · 8 comments
Assignees
Labels
3.7 (EOL) end of life easy interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error

Comments

@ggenellina
Copy link
Mannequin

ggenellina mannequin commented Jun 7, 2011

BPO 12276
Nosy @terryjreedy, @amauryfa, @vstinner, @tiran, @serhiy-storchaka, @matrixise, @ChillarAnand
Superseder
  • bpo-31949: Bugs in PyTraceBack_Print()
  • Files
  • tracebacklimitbug.py
  • Limit-traceback-if-sys.tracebacklimit-is-set.patch
  • Limit-traceback-if-sys.tracebacklimit-is-set.patch
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/serhiy-storchaka'
    closed_at = <Date 2017-11-20.18:05:52.629>
    created_at = <Date 2011-06-07.08:48:21.244>
    labels = ['interpreter-core', 'easy', 'type-bug', '3.7']
    title = '3.x ignores sys.tracebacklimit=0'
    updated_at = <Date 2017-11-20.18:05:52.628>
    user = 'https://bugs.python.org/ggenellina'

    bugs.python.org fields:

    activity = <Date 2017-11-20.18:05:52.628>
    actor = 'serhiy.storchaka'
    assignee = 'serhiy.storchaka'
    closed = True
    closed_date = <Date 2017-11-20.18:05:52.629>
    closer = 'serhiy.storchaka'
    components = ['Interpreter Core']
    creation = <Date 2011-06-07.08:48:21.244>
    creator = 'ggenellina'
    dependencies = []
    files = ['22269', '46053', '46110']
    hgrepos = []
    issue_num = 12276
    keywords = ['patch', 'easy']
    message_count = 8.0
    messages = ['137792', '137793', '137794', '137893', '138147', '284084', '284463', '305597']
    nosy_count = 8.0
    nosy_names = ['terry.reedy', 'amaury.forgeotdarc', 'ggenellina', 'vstinner', 'christian.heimes', 'serhiy.storchaka', 'matrixise', 'chillaranand']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = 'resolved'
    status = 'closed'
    superseder = '31949'
    type = 'behavior'
    url = 'https://bugs.python.org/issue12276'
    versions = ['Python 3.6', 'Python 3.7']

    @ggenellina
    Copy link
    Mannequin Author

    ggenellina mannequin commented Jun 7, 2011

    Python 3.x doesn't honor sys.tracebacklimit=0

    According to
    http://docs.python.org/py3k/library/sys.html#sys.tracebacklimit
    when set to 0, it should not print any stack trace, but it does.

    Python 3.2 (r32:88445, Feb 20 2011, 21:29:02) [MSC v.1500 32 bit (Intel)] on win
    32
    Type "help", "copyright", "credits" or "license" for more information.
    p3> import sys
    p3> sys.tracebacklimit = 0
    p3>
    p3> def f(x):
    ...   return f(x-1) if x else 0/0
    ...
    p3> f(5)
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "<stdin>", line 2, in f
      File "<stdin>", line 2, in f
      File "<stdin>", line 2, in f
      File "<stdin>", line 2, in f
      File "<stdin>", line 2, in f
      File "<stdin>", line 2, in f
    ZeroDivisionError: division by zero
    p3>

    @ggenellina ggenellina mannequin added the interpreter-core (Objects, Python, Grammar, and Parser dirs) label Jun 7, 2011
    @ggenellina
    Copy link
    Mannequin Author

    ggenellina mannequin commented Jun 7, 2011

    Originally reported by Thorsten Kampe in comp.lang.python 2011-5-27
    <http://permalink.gmane.org/gmane.comp.python.general/691496\>

    @amauryfa
    Copy link
    Member

    amauryfa commented Jun 7, 2011

    This was changed a long time ago with 565012d1123d

    @ggenellina
    Copy link
    Mannequin Author

    ggenellina mannequin commented Jun 8, 2011

    Is this the intended behavior then? I don't get the rationale for that change.

    There is no way to completely supress traceback information now; for sys.tracebacklimit to be of any significance, it must be >= 1; 0 and negative values behave the same as it not being set (that is, a full traceback is printed).

    @terryjreedy
    Copy link
    Member

    Either code or doc must change (with 'version changed' note). Doc: "The default is 1000. When set to 0 or less, all traceback information is suppressed and only the exception type and value are printed."

    Christian's patch: "values <= 0 are replaced with a default value to avoid infinite recursion and other issues." Default is 1000.

    I do not see the logic of changing 'nothing' to 'everything'. I am puzzled how printing nothing causes infinite recursion.

    @terryjreedy terryjreedy added the docs Documentation in the Doc dir label Jun 11, 2011
    @berkerpeksag berkerpeksag added easy type-bug An unexpected behavior, bug, or error labels Aug 5, 2016
    @ChillarAnand
    Copy link
    Mannequin

    ChillarAnand mannequin commented Dec 27, 2016

    This patch fixes the issue. I have also added 2 test cases to make sure it works.

    @ChillarAnand
    Copy link
    Mannequin

    ChillarAnand mannequin commented Jan 2, 2017

    Update patch with better assertions

    @serhiy-storchaka
    Copy link
    Member

    Do you mind to create a pull request on GitHub Anand?

    bpo-31949 fixes this and several other bugs in PyTraceBack_Print(), but it may be worth to fix this bug first, especially if the patch contains tests.

    @serhiy-storchaka serhiy-storchaka added 3.7 (EOL) end of life and removed docs Documentation in the Doc dir labels Nov 5, 2017
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.7 (EOL) end of life easy interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    4 participants