Avro
  1. Avro
  2. AVRO-854

python DataFileWriter and DataFileReader should implement __enter__ and __exit__

    Details

    • Type: New Feature New Feature
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.5.1
    • Fix Version/s: 1.6.2
    • Component/s: python
    • Labels:
      None
    • Tags:
      python

      Description

      I think The python classes

      avio.datafile.DataFileWriter
      avio.datafile.DataFileReader
      

      should implement the methods

      __enter__
      __exit__
      

      So that they can be used in with statements as context managers

      see http://docs.python.org/release/2.5.2/lib/typecontextmanager.html

        Activity

        Jeremy Lewi created issue -
        Harsh J made changes -
        Field Original Value New Value
        Assignee Harsh J [ qwertymaniac ]
        Harsh J made changes -
        Attachment AVRO-854.patch [ 12509175 ]
        Harsh J made changes -
        Status Open [ 1 ] Patch Available [ 10002 ]
        Hide
        Harsh J added a comment -

        Implemented a simple context manager (enter provides the instance itself, no frills, and exit closes the file if there was no exception waiting to be rethrown after) and added a test that runs for python > 2.5 (2.5 has with statement as a future import).

        Ran tests with python 2.5 and python 2.6, and both pass (former skips it).

        Show
        Harsh J added a comment - Implemented a simple context manager (enter provides the instance itself, no frills, and exit closes the file if there was no exception waiting to be rethrown after) and added a test that runs for python > 2.5 (2.5 has with statement as a future import). Ran tests with python 2.5 and python 2.6, and both pass (former skips it).
        Hide
        Harsh J added a comment -

        Hi, do let me know if there are any comments on the patch you'd like me to address.

        Show
        Harsh J added a comment - Hi, do let me know if there are any comments on the patch you'd like me to address.
        Hide
        Jeremy Lewi added a comment -

        Looks good to me. Thanks for implementing this.

        Show
        Jeremy Lewi added a comment - Looks good to me. Thanks for implementing this.
        Hide
        Doug Cutting added a comment -

        I committed this. Thanks, Harsh!

        Show
        Doug Cutting added a comment - I committed this. Thanks, Harsh!
        Doug Cutting made changes -
        Status Patch Available [ 10002 ] Resolved [ 5 ]
        Fix Version/s 1.6.2 [ 12319074 ]
        Resolution Fixed [ 1 ]
        Doug Cutting made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open Patch Available Patch Available
        180d 8h 51m 1 Harsh J 03/Jan/12 06:37
        Patch Available Patch Available Resolved Resolved
        20d 17h 6m 1 Doug Cutting 23/Jan/12 23:43
        Resolved Resolved Closed Closed
        22d 1h 2m 1 Doug Cutting 15/Feb/12 00:46

          People

          • Assignee:
            Harsh J
            Reporter:
            Jeremy Lewi
          • Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development