Giter VIP home page Giter VIP logo

Comments (5)

andyalmandhunter avatar andyalmandhunter commented on August 21, 2024

I think this is more than an issue of what downstream clients expect. The addition of .decode breaks SplitReader.read() if you pass a num, because a subset of bytes from a valid utf-8 encoded string is not necessarily itself a valid utf-8 encoded string.

from splits.

drudd avatar drudd commented on August 21, 2024

I think the return is always in units of num characters, whatever the encoding.
https://github.com/stitchfix/splits/blob/master/splits/readers.py#L65

I'm not sure if num is supposed to refer to bytes...

from splits.

drudd avatar drudd commented on August 21, 2024

I don't think the problem is returning a subset of bytes that are not a valid utf-8 string, but rather we read is now returning in units of characters and not bytes.

read definition:
https://docs.python.org/2/library/stdtypes.html#file.read

from splits.

andyalmandhunter avatar andyalmandhunter commented on August 21, 2024

It looks like SplitReader.read calls file.read asking for num bytes, and then tries to decode those bytes. It also tries to do this repeatedly until it has num characters to return, but on each iteration .decode will be passed num - len(val) bytes, which isn't guaranteed to work.

Maybe I should make a new issue, because as you noted there are also issues caused downstream by the return type.

from splits.

andyalmandhunter avatar andyalmandhunter commented on August 21, 2024

See #23

from splits.

Related Issues (4)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.