def make_pyc(cls, space, co, mtime): data = marshal.dumps(co) if type(mtime) is type(0.0): # Mac mtimes need a bit of special casing if mtime < 0x7fffffff: mtime = int(mtime) else: mtime = int(-0x100000000L + long(mtime)) s = StringIO() try: _w_long(s, get_pyc_magic(space)) except AttributeError: import imp s.write(imp.get_magic()) pyc = s.getvalue() + struct.pack("<i", int(mtime)) + data return pyc
def test_long_writes(self): pathname = str(udir.join('test.dat')) stream = streamio.open_file_as_stream(pathname, "wb") try: importing._w_long(stream, 42) importing._w_long(stream, 12312) importing._w_long(stream, 128397198) finally: stream.close() stream = streamio.open_file_as_stream(pathname, "rb") try: res = importing._r_long(stream) assert res == 42 res = importing._r_long(stream) assert res == 12312 res = importing._r_long(stream) assert res == 128397198 finally: stream.close()