Comments (5)
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.
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.
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.
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.
See #23
from splits.
Related Issues (4)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from splits.