-
Notifications
You must be signed in to change notification settings - Fork 21
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
hello,I find something wrong in you code.. #3
Labels
Comments
Could you please upload some torrent file that lead to those error? You
can email it to me if you like. Thanks for your help. :)
ltfychrise <notifications@github.com> 于 2018年4月6日周五 09:43写道:
… When I using you project to parser a torrent file,I got some wrong,here is
my found, mybe it can help you ~
- _seek_back nerver rollback _pos
def _seek_back(self, count):
self._content.seek(-count, 1)
#my_code_here
self._pos = self._pos - count
- the encoding element in torrent files maybe wrong,using charset
instead
def _next_string(self, decode=True):
length = self._next_int(b':')
raw = self._read_byte(length)
if decode:
#my code here
self._encoding = chardet.detect(raw)["encoding"]
if raw == b'':
string = self._next_string()
else:
string = raw.decode(self._encoding)
return string
return raw
- _next_int maybe the negative number.
like this:
file-mediali-1ei-1ei-1ei-1ei-1ei-1ei-1ei-1ei-1ei-1ei-1ei-1ei-1ei-1ei-1ei-1ei-1ei-1ei-1ei-1ei-1ei-1ei-1ei-1ei-1ei-1ei-1ei-1ei-1ei-1ei-1ei-1ei-1ei-1ei-1ei-1ei-1ei-1ei-1ei-1ei-1ei-1ei-1ei-1ei-1ei0ei-1ei-1ee
def _next_int(self, end=END_INDICATOR):
#以END_INDICATOR为分隔符读出字符串个数
negative = False
value = 0
char = self._read_byte(1)
while char != end:
#my_code
if char == b'-':
char = self._read_byte(1)
negative = True
# noinspection PyTypeChecker
if not b'0' <= char <= b'9':
raise InvalidTorrentFileException(self._pos)
value = value * 10 + int(char) - int(b'0')
char = self._read_byte(1)
#my_code
if negative:
value = -value
return value
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#3>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AHdc8ZVRzx2Q1P8F6NRs3JxQnOEpUwPJks5tlshOgaJpZM4TJZVg>
.
|
I realized that these problems are very easy to reproduce and don't need test files anymore. I will fix these issues and add acknowledgments to the ReadMe. |
7sDream
pushed a commit
that referenced
this issue
Apr 6, 2018
- Fixed: Support negative int - Fixed: seek_back not move pos - Added: Auto encoding
7sDream
pushed a commit
that referenced
this issue
Apr 6, 2018
All three bug/enhancement be fixed/added in version 0.1.4. |
thank you so much ~ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When I using you project to parser a torrent file , I got some wrong,here is my found, mybe it can help you ~
The text was updated successfully, but these errors were encountered: