modsys: Implement sys.version.

The logic appears to be that (at least beginning of) sys.versions is the
version of reference Python language implemented, not version of particular
implementation.

Also, bump set versions at 3.4.0, based on @dpgeorge preference.
This commit is contained in:
Paul Sokolovsky 2014-04-14 01:46:45 +03:00
parent 58676fc2c7
commit bbae42d62f
2 changed files with 5 additions and 1 deletions

View File

@ -6,6 +6,7 @@
#include "runtime.h" #include "runtime.h"
#include "objlist.h" #include "objlist.h"
#include "objtuple.h" #include "objtuple.h"
#include "objstr.h"
#if MICROPY_ENABLE_MOD_SYS #if MICROPY_ENABLE_MOD_SYS
@ -20,13 +21,15 @@ mp_obj_list_t mp_sys_path_obj;
mp_obj_list_t mp_sys_argv_obj; mp_obj_list_t mp_sys_argv_obj;
#define I(n) MP_OBJ_NEW_SMALL_INT(n) #define I(n) MP_OBJ_NEW_SMALL_INT(n)
// TODO: CPython is now at 5-element array, but save 2 els so far... // TODO: CPython is now at 5-element array, but save 2 els so far...
STATIC const mp_obj_tuple_t mp_sys_version_info_obj = {{&mp_type_tuple}, 3, {I(3), I(3), I(5)}}; STATIC const mp_obj_tuple_t mp_sys_version_info_obj = {{&mp_type_tuple}, 3, {I(3), I(4), I(0)}};
#undef I #undef I
STATIC const MP_DEFINE_STR_OBJ(version_obj, "3.4.0");
STATIC const mp_map_elem_t mp_module_sys_globals_table[] = { STATIC const mp_map_elem_t mp_module_sys_globals_table[] = {
{ MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_sys) }, { MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_sys) },
{ MP_OBJ_NEW_QSTR(MP_QSTR_path), (mp_obj_t)&mp_sys_path_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_path), (mp_obj_t)&mp_sys_path_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_argv), (mp_obj_t)&mp_sys_argv_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_argv), (mp_obj_t)&mp_sys_argv_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_version), (mp_obj_t)&version_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_version_info), (mp_obj_t)&mp_sys_version_info_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_version_info), (mp_obj_t)&mp_sys_version_info_obj },
#if MP_ENDIANNESS_LITTLE #if MP_ENDIANNESS_LITTLE
{ MP_OBJ_NEW_QSTR(MP_QSTR_byteorder), MP_OBJ_NEW_QSTR(MP_QSTR_little) }, { MP_OBJ_NEW_QSTR(MP_QSTR_byteorder), MP_OBJ_NEW_QSTR(MP_QSTR_little) },

View File

@ -280,6 +280,7 @@ Q(little)
Q(stdin) Q(stdin)
Q(stdout) Q(stdout)
Q(stderr) Q(stderr)
Q(version)
Q(version_info) Q(version_info)
#endif #endif