Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
e5a3759f
Commit
e5a3759f
authored
Oct 25, 2014
by
Paul Sokolovsky
Browse files
py: Factor out mp_obj_is_package() function.
parent
8becca7c
Changes
3
Hide whitespace changes
Inline
Side-by-side
py/builtinimport.c
View file @
e5a3759f
...
...
@@ -55,6 +55,12 @@
#define PATH_SEP_CHAR '/'
bool
mp_obj_is_package
(
mp_obj_t
module
)
{
mp_obj_t
dest
[
2
];
mp_load_method_maybe
(
module
,
MP_QSTR___path__
,
dest
);
return
dest
[
0
]
!=
MP_OBJ_NULL
;
}
STATIC
mp_import_stat_t
stat_dir_or_file
(
vstr_t
*
path
)
{
//printf("stat %s\n", vstr_str(path));
mp_import_stat_t
stat
=
mp_import_stat
(
vstr_str
(
path
));
...
...
py/obj.h
View file @
e5a3759f
...
...
@@ -555,6 +555,8 @@ typedef struct _mp_obj_module_t {
mp_obj_dict_t
*
globals
;
}
mp_obj_module_t
;
mp_obj_dict_t
*
mp_obj_module_get_globals
(
mp_obj_t
self_in
);
// check if given module object is a package
bool
mp_obj_is_package
(
mp_obj_t
module
);
// staticmethod and classmethod types; defined here so we can make const versions
// this structure is used for instances of both staticmethod and classmethod
...
...
py/runtime.c
View file @
e5a3759f
...
...
@@ -1098,8 +1098,7 @@ import_error:
}
// See if it's a package, then can try FS import
mp_load_method_maybe
(
module
,
MP_QSTR___path__
,
dest
);
if
(
dest
[
0
]
==
MP_OBJ_NULL
)
{
if
(
!
mp_obj_is_package
(
module
))
{
goto
import_error
;
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment