Skip to content

pickling os.stat results round II #36205

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

Closed
mwhudson opened this issue Mar 5, 2002 · 6 comments
Closed

pickling os.stat results round II #36205

mwhudson opened this issue Mar 5, 2002 · 6 comments
Assignees
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs)

Comments

@mwhudson
Copy link

mwhudson commented Mar 5, 2002

BPO 526072
Nosy @mwhudson, @loewis
Files
  • structseq-pickle2.diff: fancier pickling for structseqs
  • structseq-pickle3.diff: forgot a decref
  • 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/mwhudson'
    closed_at = <Date 2002-03-06.17:14:11.000>
    created_at = <Date 2002-03-05.19:00:47.000>
    labels = ['interpreter-core']
    title = 'pickling os.stat results round II'
    updated_at = <Date 2002-03-06.17:14:11.000>
    user = 'https://github.com/mwhudson'

    bugs.python.org fields:

    activity = <Date 2002-03-06.17:14:11.000>
    actor = 'mwh'
    assignee = 'mwh'
    closed = True
    closed_date = None
    closer = None
    components = ['Interpreter Core']
    creation = <Date 2002-03-05.19:00:47.000>
    creator = 'mwh'
    dependencies = []
    files = ['4032', '4033']
    hgrepos = []
    issue_num = 526072
    keywords = ['patch']
    message_count = 6.0
    messages = ['39152', '39153', '39154', '39155', '39156', '39157']
    nosy_count = 2.0
    nosy_names = ['mwh', 'loewis']
    pr_nums = []
    priority = 'normal'
    resolution = 'accepted'
    stage = None
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue526072'
    versions = []

    @mwhudson
    Copy link
    Author

    mwhudson commented Mar 5, 2002

    Following discussion in patch bpo-462296, I've tried to
    implement what Martin suggested, i.e.

    1. structseq's contructors now take an additional,
      optional second argument which should be a dictionary.
      If any of the "invisible" fields are not specified by
      the sequence first argument, their values are looked
      for in this dict (if not found, None is used). Extra
      keys are ignored.

    2. structseq's __reduce__ methods return invisible
      fields in a dict.

    3. I also fix the bug I just submitted, namely bpo-526039.

    Martin, can you look the code over? I'm not sure it's
    maximally-sensibly written.

    WRT the finding-the-type-object issue: how about making
    os.stat_result.__name__ == "os.stat_result" rather than
    "posix.stat_result".

    @mwhudson mwhudson closed this as completed Mar 5, 2002
    @mwhudson mwhudson self-assigned this Mar 5, 2002
    @mwhudson mwhudson added the interpreter-core (Objects, Python, Grammar, and Parser dirs) label Mar 5, 2002
    @loewis
    Copy link
    Mannequin

    loewis mannequin commented Mar 6, 2002

    Logged In: YES
    user_id=21627

    There's no uploaded file! You have to check the
    checkbox labeled "Check to Upload & Attach File"
    when you upload a file.

    Please try again.

    (This is a SourceForge annoyance that we can do
    nothing about. :-( )

    @mwhudson
    Copy link
    Author

    mwhudson commented Mar 6, 2002

    Logged In: YES
    user_id=6656

    Oops, how embarrassing.

    I don't think I can blame sf for this one -- I think I just
    forgot.

    @mwhudson
    Copy link
    Author

    mwhudson commented Mar 6, 2002

    Logged In: YES
    user_id=6656

    I forgot a Py_DECREF. Look at the -pickle3.diff file.

    @loewis
    Copy link
    Mannequin

    loewis mannequin commented Mar 6, 2002

    Logged In: YES
    user_id=21627

    The patch looks ok to me. Renaming the type to
    os.stat_result is one option; the other option is to add a
    function os._make_stat_result, and have __reduce__ return
    this (much like object.__reduce__ returns copy_reg._reduce).
    Chose whichever you like more.

    [the missing-upload text is a canned response; I didn't
    actually type all that :-]

    @mwhudson
    Copy link
    Author

    mwhudson commented Mar 6, 2002

    Logged In: YES
    user_id=6656

    Checked in this patch as
    Objects/structseq.c revision 1.5.

    Custom pickle method for stat_results (and statvfs_results) in
    Lib/os.py revision 1.52
    (used an approach roughly like your suggestion -- which
    isn't what object.__reduce__ does, I think).

    Tests in
    Lib/test/pickletester.py revision 1.14

    I know about the canned response; I've been caught out by it
    on occasion but this time it was just me being dense.

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    interpreter-core (Objects, Python, Grammar, and Parser dirs)
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant