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

RangeError: expected 50 to 50, found 0 #10

Closed
rajjeet opened this issue Feb 9, 2020 · 12 comments
Closed

RangeError: expected 50 to 50, found 0 #10

rajjeet opened this issue Feb 9, 2020 · 12 comments

Comments

@rajjeet
Copy link

rajjeet commented Feb 9, 2020

Tried the following code:

from mgz import header, body
from os import fstat

with open('C:\\Users\\rajje\\PycharmProjects\\helloworld\\replay.aoe2record', 'rb') as data:
    eof = fstat(data.fileno()).st_size
    header.parse_stream(data)
    while data.tell() < eof:
        body.operation.parse_stream(data)

Go this error:

Traceback (most recent call last):
  File "C:\Users\rajje\PycharmProjects\helloworld\venv\lib\site-packages\construct\core.py", line 1042, in _parse
    obj.append(self.subcon._parse(stream, context._, path))
  File "C:\Users\rajje\PycharmProjects\helloworld\venv\lib\site-packages\construct\core.py", line 867, in _parse
    subobj = sc._parse(stream, context, path)
  File "C:\Users\rajje\PycharmProjects\helloworld\venv\lib\site-packages\construct\core.py", line 1235, in _parse
    pad = _read_stream(stream, padlen)
  File "C:\Users\rajje\PycharmProjects\helloworld\venv\lib\site-packages\construct\core.py", line 67, in _read_stream
    data = stream.read(length)
OverflowError: Python int too large to convert to C ssize_t

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\rajje\PycharmProjects\helloworld\venv\lib\site-packages\construct\core.py", line 2784, in _parse
    return self.subcon._parse(stream, context, path)
  File "C:\Users\rajje\PycharmProjects\helloworld\venv\lib\site-packages\construct\core.py", line 867, in _parse
    subobj = sc._parse(stream, context, path)
  File "C:\Users\rajje\PycharmProjects\helloworld\venv\lib\site-packages\construct\core.py", line 1050, in _parse
    raise RangeError("expected %d to %d, found %d" % (min, max, len(obj)))
construct.core.RangeError: expected 50 to 50, found 0

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "app.py", line 6, in <module>
    header.parse_stream(data)
  File "C:\Users\rajje\PycharmProjects\helloworld\venv\lib\site-packages\construct\core.py", line 171, in parse_stream
    return self._parse(stream, context2, "(parsing)")
  File "C:\Users\rajje\PycharmProjects\helloworld\venv\lib\site-packages\construct\core.py", line 867, in _parse
    subobj = sc._parse(stream, context, path)
  File "C:\Users\rajje\PycharmProjects\helloworld\venv\lib\site-packages\construct\core.py", line 295, in _parse
    return self.subcon._parse(stream, context, path)
  File "C:\Users\rajje\PycharmProjects\helloworld\venv\lib\site-packages\construct\core.py", line 867, in _parse
    subobj = sc._parse(stream, context, path)
  File "C:\Users\rajje\PycharmProjects\helloworld\venv\lib\site-packages\construct\core.py", line 295, in _parse
    return self.subcon._parse(stream, context, path)
  File "C:\Users\rajje\PycharmProjects\helloworld\venv\lib\site-packages\mgz\util.py", line 36, in _parse
    return self.subcon._parse(new_stream, context, path)
  File "C:\Users\rajje\PycharmProjects\helloworld\venv\lib\site-packages\construct\core.py", line 357, in _parse
    return self.subcon.parse(data, context)
  File "C:\Users\rajje\PycharmProjects\helloworld\venv\lib\site-packages\construct\core.py", line 158, in parse
    return self.parse_stream(BytesIO(data), context, **kw)
  File "C:\Users\rajje\PycharmProjects\helloworld\venv\lib\site-packages\construct\core.py", line 171, in parse_stream
    return self._parse(stream, context2, "(parsing)")
  File "C:\Users\rajje\PycharmProjects\helloworld\venv\lib\site-packages\construct\core.py", line 867, in _parse
    subobj = sc._parse(stream, context, path)
  File "C:\Users\rajje\PycharmProjects\helloworld\venv\lib\site-packages\construct\core.py", line 2788, in _parse
    raise e.__class__("%s\n    %s" % (e, path))
construct.core.RangeError: expected 50 to 50, found 0
    (parsing) -> map_info
@happyleavesaoc
Copy link
Owner

Hi, can you please provide the replay file? DE support is a bit rough right now since there is not a lot of sample data available.

@rajjeet
Copy link
Author

rajjeet commented Feb 10, 2020

https://drive.google.com/open?id=1Oh8d8WSk0M44Qyk9q9T4qgD-oxsITlUA

I wanted to build an offline analytical tool, trying to parse the binary file.

@happyleavesaoc
Copy link
Owner

Thanks for the rec. I've replicated the issue. Something has recently changed in the DE rec structure. I will attempt to update the parser.

@happyleavesaoc
Copy link
Owner

I took a look at the rec. Player 2 is an AI, which changes how the initial struct is formatted (mgz/header/de.py). I attempted a few things to get it working, but there's more complexity than I have time right now.

Human-only recs are working (I fixed a few other issues as indicated in my previous response).

@rajjeet
Copy link
Author

rajjeet commented Feb 15, 2020

Tried with this replay with a multiplayer 1v1 ranked de: https://drive.google.com/open?id=1k-61dFAEc-bFBqRfNEK22IwqXnn4ysMe

Got this exception:

Traceback (most recent call last):
  File "C:\Users\rajje\PycharmProjects\helloworld\venv\lib\site-packages\construct\core.py", line 2844, in _decode
    return self.decoding[obj]
KeyError: 4

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\rajje\PycharmProjects\helloworld\venv\lib\site-packages\construct\core.py", line 1042, in _parse
    obj.append(self.subcon._parse(stream, context._, path))
  File "C:\Users\rajje\PycharmProjects\helloworld\venv\lib\site-packages\construct\core.py", line 311, in _parse
    return self._decode(self.subcon._parse(stream, context, path), context)
  File "C:\Users\rajje\PycharmProjects\helloworld\venv\lib\site-packages\construct\core.py", line 2849, in _decode
    raise MappingError("no decoding mapping for %r" % (obj,))
construct.core.MappingError: no decoding mapping for 4

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\rajje\PycharmProjects\helloworld\venv\lib\site-packages\construct\core.py", line 2784, in _parse
    return self.subcon._parse(stream, context, path)
  File "C:\Users\rajje\PycharmProjects\helloworld\venv\lib\site-packages\construct\core.py", line 867, in _parse
    subobj = sc._parse(stream, context, path)
  File "C:\Users\rajje\PycharmProjects\helloworld\venv\lib\site-packages\construct\core.py", line 1050, in _parse
    raise RangeError("expected %d to %d, found %d" % (min, max, len(obj)))
construct.core.RangeError: expected 7 to 7, found 3

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\rajje\PycharmProjects\helloworld\venv\lib\site-packages\construct\core.py", line 1042, in _parse
    obj.append(self.subcon._parse(stream, context._, path))
  File "C:\Users\rajje\PycharmProjects\helloworld\venv\lib\site-packages\construct\core.py", line 2784, in _parse
    return self.subcon._parse(stream, context, path)
  File "C:\Users\rajje\PycharmProjects\helloworld\venv\lib\site-packages\construct\core.py", line 867, in _parse
    subobj = sc._parse(stream, context, path)
  File "C:\Users\rajje\PycharmProjects\helloworld\venv\lib\site-packages\construct\core.py", line 2788, in _parse
    raise e.__class__("%s\n    %s" % (e, path))
construct.core.RangeError: expected 7 to 7, found 3
    (parsing) -> initial -> players -> attributes

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\rajje\PycharmProjects\helloworld\venv\lib\site-packages\construct\core.py", line 2784, in _parse
    return self.subcon._parse(stream, context, path)
  File "C:\Users\rajje\PycharmProjects\helloworld\venv\lib\site-packages\construct\core.py", line 867, in _parse
    subobj = sc._parse(stream, context, path)
  File "C:\Users\rajje\PycharmProjects\helloworld\venv\lib\site-packages\construct\core.py", line 1050, in _parse
    raise RangeError("expected %d to %d, found %d" % (min, max, len(obj)))
construct.core.RangeError: expected 7 to 7, found 0

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "app.py", line 6, in <module>
    header.parse_stream(data)
  File "C:\Users\rajje\PycharmProjects\helloworld\venv\lib\site-packages\construct\core.py", line 171, in parse_stream
    return self._parse(stream, context2, "(parsing)")
  File "C:\Users\rajje\PycharmProjects\helloworld\venv\lib\site-packages\construct\core.py", line 867, in _parse
    subobj = sc._parse(stream, context, path)
  File "C:\Users\rajje\PycharmProjects\helloworld\venv\lib\site-packages\construct\core.py", line 295, in _parse
    return self.subcon._parse(stream, context, path)
  File "C:\Users\rajje\PycharmProjects\helloworld\venv\lib\site-packages\construct\core.py", line 867, in _parse
    subobj = sc._parse(stream, context, path)
  File "C:\Users\rajje\PycharmProjects\helloworld\venv\lib\site-packages\construct\core.py", line 295, in _parse
    return self.subcon._parse(stream, context, path)
  File "C:\Users\rajje\PycharmProjects\helloworld\venv\lib\site-packages\mgz\util.py", line 36, in _parse
    return self.subcon._parse(new_stream, context, path)
  File "C:\Users\rajje\PycharmProjects\helloworld\venv\lib\site-packages\construct\core.py", line 357, in _parse
    return self.subcon.parse(data, context)
  File "C:\Users\rajje\PycharmProjects\helloworld\venv\lib\site-packages\construct\core.py", line 158, in parse
    return self.parse_stream(BytesIO(data), context, **kw)
  File "C:\Users\rajje\PycharmProjects\helloworld\venv\lib\site-packages\construct\core.py", line 171, in parse_stream
    return self._parse(stream, context2, "(parsing)")
  File "C:\Users\rajje\PycharmProjects\helloworld\venv\lib\site-packages\construct\core.py", line 867, in _parse
    subobj = sc._parse(stream, context, path)
  File "C:\Users\rajje\PycharmProjects\helloworld\venv\lib\site-packages\construct\core.py", line 2788, in _parse
    raise e.__class__("%s\n    %s" % (e, path))
construct.core.RangeError: expected 7 to 7, found 0
    (parsing) -> initial

Process finished with exit code 1

@rajjeet
Copy link
Author

rajjeet commented Feb 15, 2020

Also, do you have a DE replay that works with this parser? Thanks for this work btw.

@chesteripz
Copy link
Contributor

chesteripz commented Feb 16, 2020

Hi, can you please provide the replay file? DE support is a bit rough right now since there is not a lot of sample data available.

What kind of sample data would you prefer?

Also, do you have a DE replay that works with this parser? Thanks for this work btw.

This one can be parsed successfully. (only summary module, the parse_stream seems to have some problems right now)

MP Replay v101.101.34793.0 @2020.02.13 213505 (1).zip

@rajjeet
Copy link
Author

rajjeet commented Feb 16, 2020

@chesteripz With the MP replay I linked, I'm getting an error while trying parse the header or the body using the following code:

from mgz import header, body
from os import fstat

with open('./mp-replay.aoe2record', 'rb') as data:
    eof = fstat(data.fileno()).st_size
    header.parse_stream(data)
    while data.tell() < eof:
        body.operation.parse_stream(data)

I'm on python @3.6.2

@happyleavesaoc
Copy link
Owner

I'm tracking this issue. Thanks for reporting.

@happyleavesaoc
Copy link
Owner

@rajjeet Took a look at your rec, mp-replay.aoe2record. It's from an older version of DE. Commit 247c246 can parse it. DE rec formats change somewhat frequently and this module isn't backwards compatible (theoretically it could be, but that's more work than I care to do). I expect the format to stabilize soon anyway. Also, FYI, that rec is an unranked lobby-hosted 3v3, not a ranked 1v1. Sorry you're having so much trouble getting this to work!

@chesteripz By sample data I just mean recs, ideally in bulk. The rec you posted should work with parse_stream , let me know what problem you're having.

@chesteripz
Copy link
Contributor

chesteripz commented Feb 17, 2020

When I try to use parse_stream, I've got the same error

never mind, I opened the older file

@happyleavesaoc
Copy link
Owner

Closing. Feel free to re-open if you're still experiencing an issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants