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

adapter.{json,xml}: make (de-)serialization interfaces coherent #251

Merged

Commits on Mar 13, 2024

  1. adapter.{json,xml}: make (de-)serialization interfaces coherent

    lxml supports paths already, no modification is necessary there.
    However, the `lxml.etree.ElementTree.write()` function requires
    `BinaryIO`, i.e. files opened with the 'b' mode. While it would be
    possible to access the underlying binary buffer of files opened in text
    mode via `open()`, this isn't possible for `io.StringIO()`, as it
    doesn't have the `buffer` property. Thus, even if we could support files
    opened via `open()` in text mode, we couldn't annotate the XML
    serialization functions with `TextIO`, as `io.StringIO()` remains
    unsupported. Because of that, I decided to not support `TextIO` for the
    XML serialization.
    
    The builtin JSON module only supports file handles, with the
    `json.dump()` method only supporting `TextIO` and `json.load()`
    supporting `TextIO` and `BinaryIO`. Thus, the JSON adapter is modified
    to `open()` given paths, while the JSON serialization is additionally
    modified to wrap `BinaryIO` with `io.TextIOWrapper`.
    
    Fix #42
    jkhsjdhjs committed Mar 13, 2024
    Configuration menu
    Copy the full SHA
    268285b View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    790bc7b View commit details
    Browse the repository at this point in the history
  3. test.adater.xml.test_xml_deserialization: simplify

    ... by using `StringIO` instead of `BytesIO`.
    jkhsjdhjs committed Mar 13, 2024
    Configuration menu
    Copy the full SHA
    40b420c View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    77846ff View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    d448667 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    81e0903 View commit details
    Browse the repository at this point in the history