So, I have this unholy abomination of a program:
print((lambda raw, name_file: ((lambda start_time, total, lines, names: ((lambda parsed: ('\n'.join(str(10*(parsed[0][name]+parsed[1][name]/2)/total).ljust(6) + name for name in names)))(list(map(lambda x: __import__("collections").Counter(x), map(lambda x: list(map(lambda x: x[1], x)), [list(group[1]) for group in __import__("itertools").groupby(sorted([list(group[1])[0] for group in __import__("itertools").groupby(sorted(list(map(lambda x: [x[3], ' '.join([x[4], x[5], x[6]]), __import__("datetime").datetime.strptime(x[0] + ' ' + x[1], '%Y.%m.%d %H:%M:%S')], map(str.split, filter(lambda x: (any(name.strip() in x for name in names) and "OK ( 0 )" in x), lines))))), lambda x: (x[0], x[1]))], key = lambda x: (x[2], x[1], x[0])), lambda x: ((x[2] < start_time+__import__("datetime").timedelta(days=7)) + (x[2] < start_time+__import__("datetime").timedelta(days=14))))]))))))(__import__("datetime").datetime.strptime(raw.readline().strip(), '%d.%m.%Y %H:%M'), int(raw.readline()), map(lambda x: x.replace("Минчен", ""), raw.readlines()), list(map(str.strip, name_file.readlines())))))(raw = open("test.txt", "r"), name_file = open("names.txt", "r")))
(probably better on pastebin)
It almost works, but the way it does not work is very weird and looks like an interpreter bug to me.
Now, the only non-ASCII characters in the code are in the string "Минчен" in the end, and even then they are perfectly UTF-8-compatible, which is supposed to be the default encoding. Now, the problem is, Python throws this error:
Non-UTF-8 code starting with '\xd1' in file lulz.py on line 1, but no encoding declared;
And it's not just some weird encoding problem! If I remove the last "н" in the string, the program runs just fine; the moment I add any russian letter in it's place, the interpreter crashes. Even if I only add one linebreak before this place, anywhere, just so that this string is on the second line of the source code, the interpreter does not crash.
Of course, I can't provide a Minimal example, given how finicky and unstable this is, but I'm pretty sure this is not the expected behaviour. Is this a bug in the interpreter or am I doing something wrong?
BTW, it may require "names.txt" and "test.txt" to be present; if you want to test, you can create two empty files with these names.
UPD Even adding a space after any single (
makes everything work! Something is definitely wrong here.
UPD2 I am using Python 3.5.1
>>> python3 --version
Python 3.5.1
UPD3 here is my file.
UPD4 and here is a hexdump: http://pastebin.com/5R1rbtc3
UPD5 apparently, this problem can only be reproduced on a Mac. I feel like different behaviour on different platforms is not intended.