diff --git a/include/pocketpy/common/serialize.h b/include/pocketpy/common/serialize.h index 7250724d..7baa436c 100644 --- a/include/pocketpy/common/serialize.h +++ b/include/pocketpy/common/serialize.h @@ -37,9 +37,11 @@ void* c11_deserializer__read_bytes(c11_deserializer* self, int size); c11_serializer__write_bytes(self, &value, sizeof(T)); \ } \ static inline T c11_deserializer__read_##name(c11_deserializer* self){ \ - T* p = (T*)(self->data + self->index); \ + const void* p = self->data + self->index; \ self->index += sizeof(T); \ - return *p; \ + T retval;\ + memcpy(&retval, p, sizeof(T)); \ + return retval; \ } DEF_ATOMIC_INLINE_RW(i8, int8_t) diff --git a/tests/922_py_compile.py b/tests/922_py_compile.py index be414a5f..2dd76616 100644 --- a/tests/922_py_compile.py +++ b/tests/922_py_compile.py @@ -1,13 +1,14 @@ from py_compile import compile -import os -if not os.path.exists('tmp'): - os.mkdir('tmp') +try: + import os +except ImportError: + print('os is not enabled, skipping test...') + exit(0) -compile('python/heapq.py', 'tmp/heapq1.pyc') -assert os.path.exists('tmp/heapq1.pyc') +compile('python/heapq.py', 'heapq1.pyc') +assert os.path.exists('heapq1.pyc') -os.chdir('tmp') import heapq1 import heapq