summaryrefslogtreecommitdiffstatshomepage
path: root/py/builtinimport.c
Commit message (Collapse)AuthorAge
* Add license header to (almost) all files.Damien George2014-05-03
| | | | | | | Blanket wide to all .c and .h files. Some files originating from ST are difficult to deal with (license wise) so it was left out of those. Also merged modpyb.h, modos.h, modstm.h and modtime.h in stmhal/.
* py: Use <alloca.h> for alloca()stijn2014-05-03
| | | | | | | | alloca() is declared in alloca.h which als happens to be included by stdlib.h. On mingw however it resides in malloc.h only. So if we include alloca.h directly, and add an alloca.h for mingw in it's port directory we can get rid of the mingw-specific define to include malloc.h and the other ports are happy as well.
* py, unix: Make "mpconfig.h" be first included, as other headers depend on it.Paul Sokolovsky2014-05-02
| | | | Specifically, nlr.h does.
* builtinimport: If there was error compiling imported module, raise exception.Paul Sokolovsky2014-04-22
|
* py: Add win32-specific header for alloca().Paul Sokolovsky2014-04-20
|
* builtinimport: Add basic support for namespace packages.Paul Sokolovsky2014-04-15
| | | | | | | | | | That was easy - just avoid erroring out on seeing candidate dir for namespace package. That's far from being complete though - namespace packages should support importing portions of package from different sys.path entries, here we require first matching entry to contain all namespace package's portions. And yet, that's a way to put parts of the same Python package into multiple installable package - something we really need for *Micro*Python.
* py: Add more #if's for configurable MOD_SYS.Damien George2014-04-13
|
* Merge pull request #476 from pfalcon/static-sysDamien George2014-04-13
|\ | | | | Convert sys module to static allocation
| * py, unix: Convert sys module to static representation.Paul Sokolovsky2014-04-13
| |
* | py: Add traceback info to syntax errors.Damien George2014-04-13
|/ | | | Should fix issue #463.
* builtinimport: Implement relative imports.Paul Sokolovsky2014-04-12
|
* builtinimport: Set __path__ attribute ASAP as it's clear we have a package.Paul Sokolovsky2014-04-12
| | | | | This helps with handling "recursive" imports in sane manner, for example when foo/__init__.py has something like "from foo import submod".
* builtinimport: Set __path__ attribute on packages.Paul Sokolovsky2014-04-12
| | | | | | | Per https://docs.python.org/3.3/reference/import.html , this is the way to tell module from package: "Specifically, any module that contains a __path__ attribute is considered a package." And it for sure will be needed to implement relative imports.
* builtinimport: Elaborate debug output support.Paul Sokolovsky2014-04-12
|
* Remove exception name from inside the exception messageAndrew Scheller2014-04-09
| | | | | This prevents micropython printing exception messages like ImportError: ImportError: No module named 'foo'
* py: Add option to compiler to specify default code emitter.Damien George2014-04-06
| | | | Also add command line option to unix port to select emitter.
* py: Make globals and locals proper dictionary objects.Damien George2014-04-05
| | | | | | | | | | | Finishes addressing issue #424. In the end this was a very neat refactor that now makes things a lot more consistent across the py code base. It allowed some simplifications in certain places, now that everything is a dict object. Also converted builtins tables to dictionaries. This will be useful when we need to turn builtins into a proper module.
* py: Change module globals from mp_map_t* to mp_obj_dict_t*.Damien George2014-04-05
| | | | | | Towards addressing issue #424. Had a small increase to ROM usage (order 60 bytes).
* py: Change nlr_jump to nlr_raise, to aid in debugging.Damien George2014-04-05
| | | | | | This does not affect code size or performance when debugging turned off. To address issue #420.
* Merge map.h into obj.h.Damien George2014-03-30
| | | | | | Pretty much everyone needs to include map.h, since it's such an integral part of the Micro Python object implementation. Thus, the definitions are now in obj.h instead. map.h is removed.
* Rename rt_* to mp_*.Damien George2014-03-30
| | | | | | | Mostly just a global search and replace. Except rt_is_true which becomes mp_obj_is_true. Still would like to tidy up some of the names, but this will do for now.
* Proper support for registering builtin modules in ROM.Damien George2014-03-25
| | | | | Comes with some refactoring of code and renaming of files. All modules are now named mod*.[ch].
* py: Remove obsolete declarations; make mp_obj_get_array consistent.Damien George2014-03-24
|
* py: Clean up includes.xbe2014-03-17
| | | | Remove unnecessary includes. Add includes that improve portability.
* Add vstr_ins and vstr_cut_out; improve stmhal readline.Damien George2014-03-15
|
* __import__: Catch relative import attempts and throw NotImplementedError.Paul Sokolovsky2014-02-21
|
* import: Implement "from pkg.mod import sym" syntax properly.Paul Sokolovsky2014-02-20
| | | | | | | | http://docs.python.org/3.3/library/functions.html#__import__ : "When the name variable is of the form package.module, normally, the top-level package (the name up till the first dot) is returned, not the module named by name. However, when a non-empty fromlist argument is given, the module named by name is returned."
* builtinimport: Get the basic (and only basic) package imports work.Paul Sokolovsky2014-02-16
|
* builtinimport.c: Recognize "namespace package" and error out as unsupported.Paul Sokolovsky2014-02-16
| | | | | | See http://www.python.org/dev/peps/pep-0420/#specification for spec. See https://github.com/micropython/micropython/issues/298 for the discussion of the implemented behavior.
* Implement proper exception type hierarchy.Damien George2014-02-15
| | | | | | | | | | | | | | Each built-in exception is now a type, with base type BaseException. C exceptions are created by passing a pointer to the exception type to make an instance of. When raising an exception from the VM, an instance is created automatically if an exception type is raised (as opposed to an exception instance). Exception matching (RT_BINARY_OP_EXCEPTION_MATCH) is now proper. Handling of parse error changed to match new exceptions. mp_const_type renamed to mp_type_type for consistency.
* Make mp_obj_str_get_data return char* instead of byte*.Damien George2014-02-08
| | | | | Can't decide which is better for string type, char or byte pointer. Changing to char removes a few casts. Really need to do proper unicode.
* Implement fixed buffer vstrs; use them for import path.Damien George2014-02-06
|
* Search paths properly on import and execute __init__.py if it exists.Damien George2014-02-05
|
* Implement support for sys.path when loading modules.Paul Sokolovsky2014-02-05
| | | | | | | | sys.path is not initialized by rt_init(), that's left for platform-specific startup code. (For example, bare metal port may have some hardcoded defaults, and let user change sys.path directly; while port for OS with environment feature can take path from environment). If it's not explicitly initialized, modules will be imported only from a current directory.
* Expose __import__() function.Paul Sokolovsky2014-02-04
|
* Implement mp_parse_node_free; print properly repr(string).Damien George2014-01-25
|
* Second stage of qstr revamp: uPy str object can be qstr or not.Damien George2014-01-22
|
* Revamp qstrs: they now include length and hash.Damien George2014-01-21
| | | | | Can now have null bytes in strings. Can define ROM qstrs per port using qstrdefsport.h
* Implement modules as singletons Python semantics.Paul Sokolovsky2014-01-20
| | | | | | | | | | | | In Python, importing module several times returns same underlying module object. This also fixes import statement handling for builtin modules. There're still issues: 1. CPython exposes set of loaded modules as sys.modules, we may want to do that either. 2. Builtin modules are implicitly imported, which is not really correct. We should separate registering a (builtin) module and importing a module. CPython keeps builtin module names in sys.builtin_module_names .
* Add source file name and line number to error messages.Damien George2014-01-18
| | | | | Byte code has a map from byte-code offset to source-code line number, used to give better error messages.
* Convert parse errors to exceptions.Damien George2014-01-15
| | | | | Parser no longer prints an error, but instead returns an exception ID and message.
* Cleanup built-ins, and fix some compiler warnings/errors.Damien George2014-01-13
|
* Split qstr into pools, and put initial pool in ROM.Damien George2014-01-04
| | | | | | | | | | | | | | | | Qstr's are now split into a linked-list of qstr pools. This has 2 benefits: the first pool can be in ROM (huge benefit, since we no longer use RAM for the core qstrs), and subsequent pools use m_new for the next pool instead of m_renew (thus avoiding a huge single table for all the qstrs). Still would be better to use a hash table, but this scheme takes us part of the way (eventually convert the pools to hash tables). Also fixed bug with import. Also improved the way the module code is referenced (not magic number 1 anymore).
* Change mp_compile so that it returns a function object for the module.Damien George2014-01-03
|
* Basic implementation of import.Damien George2014-01-03
import works for simple cases. Still work to do on finding the right script, and setting globals/locals correctly when running an imported function.