-
Notifications
You must be signed in to change notification settings - Fork 145
#63 cast players in TrackerEvent.__str__ #64
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
#63 cast players in TrackerEvent.__str__ #64
Conversation
@miguelgondu let me know if this is working for you in the general case |
Load a lotv replay and print all the events to ensure they print. The output from the prints have been redirected to a stream using StringIO and then checked for the last few events to occur.
@StoicLoofah I think I have updated and tested this change in: StoicLoofah#3 which if you accept you can then update this pull request I think? There was a rebase involved to bring it up to date with upstream to avoid a merge commit, which I haven't had to do before and might not work. |
63 trackerevent str error update
Logic issue with conditional import. StringIO.StringIO does not support usage of the with keyword.
At this point with all the extraneous commits, it might be worth squashing the commits when merging into ggtracker:upstream. Or maybe pulling your branch down and squashing into two commits if you want to keep the "authors" correct. :) |
Fix Python 2 issues with test_event_print.
@Gusgus01 thanks for the tip. I'm not too concerned about the exact commit history, so I will lazily merge as is. thanks for helping to validate and test this fix! |
print(event) | ||
self.assertIn("PlayerLeaveEvent", capturedOutput.getvalue()) | ||
sys.stdout = sys.__stdout__ | ||
sys.stdout = capturedOutput = StringIO() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The original with open() as form is safer in the face of exceptions... Was there a reason to move away from that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
StringIO.StringIO does not implement exit() I believe and can not be used with with() in python2. io.StringIO does and is what is being used in Python3 so could be used with with().
This addressed issue #63.
Looking into the issue, it appears that python3 handles format strings differently from python2. In this case, both
None
andnot None
values were failing because neither had properly implemented__format__
necessary for the alignment formatting provided. The easy fix is to cast to a string first, and that can be properly formatted.I considered adding
__format__
toEntity
, but I saw there was already something in there and got scared.sc2reader/sc2reader/objects.py
Line 157 in cc364ff
Maybe someone else will get around to it if this same issue comes up in a another place. At least this fix appears to work for now