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

Tbuffer in turtle allows negative size #66067

Closed
LitaCho mannequin opened this issue Jun 25, 2014 · 9 comments
Closed

Tbuffer in turtle allows negative size #66067

LitaCho mannequin opened this issue Jun 25, 2014 · 9 comments
Assignees

Comments

@LitaCho
Copy link
Mannequin

LitaCho mannequin commented Jun 25, 2014

BPO 21868
Nosy @rhettinger
Files
  • undobuffer_fix.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/rhettinger'
    closed_at = <Date 2014-07-21.04:33:08.800>
    created_at = <Date 2014-06-25.07:10:25.257>
    labels = []
    title = 'Tbuffer in turtle allows negative size'
    updated_at = <Date 2014-07-21.04:33:08.799>
    user = 'https://bugs.python.org/LitaCho'

    bugs.python.org fields:

    activity = <Date 2014-07-21.04:33:08.799>
    actor = 'rhettinger'
    assignee = 'rhettinger'
    closed = True
    closed_date = <Date 2014-07-21.04:33:08.800>
    closer = 'rhettinger'
    components = []
    creation = <Date 2014-06-25.07:10:25.257>
    creator = 'Lita.Cho'
    dependencies = []
    files = ['35778']
    hgrepos = []
    issue_num = 21868
    keywords = ['patch', 'needs review']
    message_count = 9.0
    messages = ['221530', '221556', '221571', '222224', '222231', '222810', '223556', '223557', '223558']
    nosy_count = 4.0
    nosy_names = ['rhettinger', 'jesstess', 'python-dev', 'Lita.Cho']
    pr_nums = []
    priority = 'high'
    resolution = 'fixed'
    stage = 'patch review'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue21868'
    versions = ['Python 2.7', 'Python 3.4', 'Python 3.5']

    @LitaCho
    Copy link
    Mannequin Author

    LitaCho mannequin commented Jun 25, 2014

    Currently, you can set the undobuffer size to negative numbers. Aka, the Tbuffer can be set to negative.

    s = turtle.Screen()
    raw = turtle.RawTurtle(s)
    raw.setundobuffer(-10)
    raw.undobuffer.bufsize == -10 <-- returns True

    This should not be possible. Tbuffer should not be allowed to have negative inputs. If the value is less than 0, it should just default to 0 or None. Otherwise, when you call undo, turtle just crashes.

    @LitaCho
    Copy link
    Mannequin Author

    LitaCho mannequin commented Jun 25, 2014

    Here is a patch for this bug. Basically, when a user gives 0 and below, it doesn't create a TBuffer. Then "undo" does the right thing.

    @rhettinger rhettinger self-assigned this Jun 25, 2014
    @LitaCho
    Copy link
    Mannequin Author

    LitaCho mannequin commented Jun 25, 2014

    I should clarify. The right thing being that calling undo does nothing, and turtle keeps on running. This is the default behaviour when setundobuffer is called with no size.

    @LitaCho
    Copy link
    Mannequin Author

    LitaCho mannequin commented Jul 3, 2014

    Hey Raymond, just wanted to ping you to see if you had a chance to review this patch yet. Thanks!

    @rhettinger
    Copy link
    Contributor

    I looked at this and marked it as high priority (crashes are an unacceptable outcome). The patch looks fine but I haven't had a chance to test it yet. If it passes muster, I'll apply it shortly (I'm overseas traveling this week).

    In the meantime, can you mark the "versions" in the tracker so I'll know in advance whether this applies to 2.7, 3.4 and 3.5? Thanks.

    @LitaCho
    Copy link
    Mannequin Author

    LitaCho mannequin commented Jul 11, 2014

    Hi Raymond! Just wanted to check if you had time to test this yet. I ran the tests through the Turtle tests I wrote (bpo-21914), but those are still pending approval.

    This is off topic, but I also didn't realize till now that you gave a talk about "Transforming Code into Beautiful, Idiomatic Python", which is super awesome! Getting a patch reviewed by you is super exciting! :)

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Jul 21, 2014

    New changeset 847a0e74c4cc by Raymond Hettinger in branch '2.7':
    Issue bpo-21868: Prevent turtle crash due to invalid undo buffer size.
    http://hg.python.org/cpython/rev/847a0e74c4cc

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Jul 21, 2014

    New changeset 02b25ec13c94 by Raymond Hettinger in branch '3.4':
    Issue bpo-21868: Prevent turtle crash due to invalid undo buffer size.
    http://hg.python.org/cpython/rev/02b25ec13c94

    @rhettinger
    Copy link
    Contributor

    Thanks for the patch Lita. This was a nice fix.

    @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
    None yet
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant