8000 Use stream position instead of counting read bytes. by tonyroberts · Pull Request #199 · pythonnet/pythonnet · GitHub
[go: up one dir, main page]

Skip to content

Use stream position instead of counting read bytes. #199

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

Merged
merged 1 commit into from
Apr 4, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Use stream position instead of counting read bytes.
FileStream.Read returns (bytes read, buffer), not just bytes read as the
buffer is passed by reference. This is a bit unintuative, but checking the
position is clear and less error prone.
  • Loading branch information
tonyroberts committed Apr 4, 2016
commit 88b3d278803f5211bda8d53c7b85fb2bb0623a2b
5 changes: 2 additions & 3 deletions demo/wordpad.py
67BF
Original file line number Diff line number Diff line change
Expand Up @@ -316,11 +316,10 @@ def OpenDocument(self):

buff = System.Array.CreateInstance(System.Byte, 1024)
data = []
read = -1

while (read != 0):
while stream.Position < stream.Length:
buff.Initialize()
read = stream.Read(buff, 0, 1024)
stream.Read(buff, 0, 1024)
temp = Encoding.ASCII.GetString(buff, 0, 1024)
data.append(temp)

Expand Down
0