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

SpooledTemporayFile.truncate should take size parameter #54166

Closed
rfk mannequin opened this issue Sep 27, 2010 · 11 comments
Closed

SpooledTemporayFile.truncate should take size parameter #54166

rfk mannequin opened this issue Sep 27, 2010 · 11 comments
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@rfk
Copy link
Mannequin

rfk mannequin commented Sep 27, 2010

BPO 9957
Nosy @birkenfeld, @ncoghlan, @pitrou, @merwok, @bitdancer
Files
  • spooledtemporaryfile_truncate.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 = None
    closed_at = <Date 2012-10-06.22:34:03.975>
    created_at = <Date 2010-09-27.02:02:29.910>
    labels = ['type-bug', 'library']
    title = 'SpooledTemporayFile.truncate should take size parameter'
    updated_at = <Date 2012-10-06.22:34:03.953>
    user = 'https://bugs.python.org/rfk'

    bugs.python.org fields:

    activity = <Date 2012-10-06.22:34:03.953>
    actor = 'r.david.murray'
    assignee = 'none'
    closed = True
    closed_date = <Date 2012-10-06.22:34:03.975>
    closer = 'r.david.murray'
    components = ['Library (Lib)']
    creation = <Date 2010-09-27.02:02:29.910>
    creator = 'rfk'
    dependencies = []
    files = ['19032']
    hgrepos = []
    issue_num = 9957
    keywords = ['patch']
    message_count = 11.0
    messages = ['117436', '117469', '117477', '148281', '148283', '148335', '148339', '148340', '171701', '172255', '172256']
    nosy_count = 8.0
    nosy_names = ['georg.brandl', 'ncoghlan', 'pitrou', 'eric.araujo', 'r.david.murray', 'rfk', 'python-dev', 'Wael.Al.Jishi']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue9957'
    versions = ['Python 3.3']

    @rfk
    Copy link
    Mannequin Author

    rfk mannequin commented Sep 27, 2010

    Both file.truncate() and StringIO.truncate() accept an optional "size" parameter to truncate the file to a specific size. SpooledTemporaryFile should accept a similar parameter and pass it on.

    The only tricky part is that truncate can potentially increase the size of a file, so it needs to check the max size and rollover if appropriate.

    Patch is against py3k branch; should work on trunk modulo the use of b"xxx" in the tests.

    @rfk rfk mannequin added type-bug An unexpected behavior, bug, or error stdlib Python modules in the Lib dir labels Sep 27, 2010
    @ned-deily ned-deily added type-feature A feature request or enhancement and removed type-bug An unexpected behavior, bug, or error labels Sep 27, 2010
    @merwok
    Copy link
    Member

    merwok commented Sep 27, 2010

    Thank you for the report and patch. Not sure if this a bug or a new feature.

    Patch looks good, thanks for including a test too!. Can you also edit the documentation?

    (There are very minor whitespace nits in the patch, but I leave it to Georg to fix them or ignore them.)

    @rfk
    Copy link
    Mannequin Author

    rfk mannequin commented Sep 27, 2010

    I went looking for places to update the documentation but the description of SpooledTemporaryFile doesn't go into any detail of its methods, so I haven't added anything. New patch fixes some whitespace issues.

    I'd like to argue that this is a bug, since SpooledTemporaryFile is documented as "operates exactly as TemporaryFile() does", and TemporaryFile.truncate accepts a "size" parameter.

    @merwok
    Copy link
    Member

    merwok commented Nov 24, 2011

    Patch looks good to me, but I’d like another review.

    @merwok merwok added type-bug An unexpected behavior, bug, or error and removed type-feature A feature request or enhancement labels Nov 24, 2011
    @pitrou
    Copy link
    Member

    pitrou commented Nov 24, 2011

    Looks ok to me as well. I think this is a new feature, so 3.3-only IMHO.

    @merwok
    Copy link
    Member

    merwok commented Nov 25, 2011

    Okay, then stable branches need a doc/docstring patch to remove the statement that SpooledTemporaryFile “operates exactly as TemporaryFile does”. Ryan, would you like to do that patch too?

    Antoine, will you commit?

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Nov 25, 2011

    New changeset 5a6911930bad by Antoine Pitrou in branch 'default':
    Issue bpo-9957: SpooledTemporaryFile.truncate() now accepts an optional size parameter, as other file-like objects.
    http://hg.python.org/cpython/rev/5a6911930bad

    @pitrou
    Copy link
    Member

    pitrou commented Nov 25, 2011

    Committed, thank you. By the way, Ryan, we now use Mercurial for developing, the Subversion repository is obsolete (see the devguide for more info).

    @WaelAlJishi
    Copy link
    Mannequin

    WaelAlJishi mannequin commented Oct 1, 2012

    Shouldn't this issue be closed, or is there more to be done?

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Oct 6, 2012

    New changeset 63c3a3f28b42 by R David Murray in branch '2.7':
    bpo-9957: document that SpooledTemporaryFile.truncate does not take size arg
    http://hg.python.org/cpython/rev/63c3a3f28b42

    New changeset 145480af0d78 by R David Murray in branch '3.2':
    bpo-9957: document that SpooledTemporaryFile.truncate does not take size arg
    http://hg.python.org/cpython/rev/145480af0d78

    New changeset 76feae02f48f by R David Murray in branch '3.3':
    bpo-9957: document that SpooledTemporaryFile.truncate now accepts a size arg
    http://hg.python.org/cpython/rev/76feae02f48f

    New changeset c7840999b65d by R David Murray in branch 'default':
    merge bpo-9957: document that SpooledTemporaryFile.truncate now accepts a size arg
    http://hg.python.org/cpython/rev/c7840999b65d

    @bitdancer
    Copy link
    Member

    bitdancer commented Oct 6, 2012

    I have made the doc changes.

    @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
    stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    4 participants