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

Fix division in tabnanny #60682

Closed
serhiy-storchaka opened this issue Nov 15, 2012 · 7 comments
Closed

Fix division in tabnanny #60682

serhiy-storchaka opened this issue Nov 15, 2012 · 7 comments
Assignees
Labels
easy stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@serhiy-storchaka
Copy link
Member

BPO 16478
Nosy @birkenfeld, @jcea, @ezio-melotti, @serhiy-storchaka
Files
  • tabnanny_div.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/ezio-melotti'
    closed_at = <Date 2012-11-16.11:19:41.757>
    created_at = <Date 2012-11-15.15:46:58.435>
    labels = ['easy', 'type-bug', 'library']
    title = 'Fix division in tabnanny'
    updated_at = <Date 2012-12-14.02:41:08.154>
    user = 'https://github.com/serhiy-storchaka'

    bugs.python.org fields:

    activity = <Date 2012-12-14.02:41:08.154>
    actor = 'jcea'
    assignee = 'ezio.melotti'
    closed = True
    closed_date = <Date 2012-11-16.11:19:41.757>
    closer = 'ezio.melotti'
    components = ['Demos and Tools', 'Library (Lib)']
    creation = <Date 2012-11-15.15:46:58.435>
    creator = 'serhiy.storchaka'
    dependencies = []
    files = ['27989']
    hgrepos = []
    issue_num = 16478
    keywords = ['patch', 'easy']
    message_count = 7.0
    messages = ['175622', '175669', '175677', '175678', '175679', '175680', '175681']
    nosy_count = 5.0
    nosy_names = ['georg.brandl', 'jcea', 'ezio.melotti', 'python-dev', 'serhiy.storchaka']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue16478'
    versions = ['Python 3.2', 'Python 3.3', 'Python 3.4']

    @serhiy-storchaka
    Copy link
    Member Author

    Tabnanny should use floor division in calculation, the comment says about this. But in the current Python 3 code "/" was not changed to "//".

    @serhiy-storchaka serhiy-storchaka added stdlib Python modules in the Lib dir easy type-bug An unexpected behavior, bug, or error labels Nov 15, 2012
    @birkenfeld
    Copy link
    Member

    Well, sounds reasonable since we're working with an integer number of spaces :)

    @ezio-melotti
    Copy link
    Member

    The patch looks OK, buy can you provide a way to reproduce the error (if you get any)?
    Should we add tests for tabnanny?
    I tried to get an error from tabnanny but the only thing I got was a ResourceWarning (that can be easily fixed by a finally: f.close() near the end of the check() method).
    I also noticed that tabnanny doesn't detect any problem with:
    if 0:
    \t\t\t\t\t\t\tprint(1)
    else:
    print(2)
    if 1:
    print()
    else:
    \t \t print()

    @serhiy-storchaka
    Copy link
    Member Author

    The patch looks OK, buy can you provide a way to reproduce the error (if you get any)?

    No, I have not any. I am even not sure tabnanny works at all. But this bug is obvious. So, let's fix it and go on.

    Should we add tests for tabnanny?

    This will be good, but it is a different issue. I'm not ready to write a test.

    I tried to get an error from tabnanny but the only thing I got was a ResourceWarning (that can be easily fixed by a finally: f.close() near the end of the check() method).

    I can't see a ResourceWarning. A "finally: f.close()" already exists near the end of the check() method.

    @ezio-melotti
    Copy link
    Member

    I can't see a ResourceWarning. A "finally: f.close()" already
    exists near the end of the check() method.

    Looks like it was added in 3.3.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Nov 16, 2012

    New changeset fc17fdd42c66 by Ezio Melotti in branch '3.2':
    bpo-16478: use floor division in tabnanny and fix a ResourceWarning. Patch by Serhiy Storchaka.
    http://hg.python.org/cpython/rev/fc17fdd42c66

    New changeset d7558e4015a4 by Ezio Melotti in branch '3.3':
    bpo-16478: merge with 3.2.
    http://hg.python.org/cpython/rev/d7558e4015a4

    New changeset 377a50f8cb8b by Ezio Melotti in branch 'default':
    bpo-16478: merge with 3.3.
    http://hg.python.org/cpython/rev/377a50f8cb8b

    @ezio-melotti
    Copy link
    Member

    Applied the patch on all 3 branches and fixed the resource warning in 3.2.
    Thanks for the report and the patch!

    @ezio-melotti ezio-melotti self-assigned this Nov 16, 2012
    @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
    easy stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants