Commit Graph

8098 Commits

Author SHA1 Message Date
Damien George
6d221fe284 docs/library/uos: Add description of uos.ilistdir() function. 2017-05-10 12:44:21 +10:00
Damien George
d70f688f25 extmod/vfs: Use MP_S_IFDIR, MP_S_IFREG consts instead of magic numbers. 2017-05-10 12:30:34 +10:00
Damien George
f1609bc843 ports: Add ilistdir in uos module. 2017-05-10 12:13:53 +10:00
Damien George
852c215d76 tests/extmod/vfs: Update tests to reflect new ilistdir() method. 2017-05-10 11:39:29 +10:00
Damien George
d4cd4831b0 extmod/vfs_fat: Replace listdir() with implementation of ilistdir().
VfsFat no longer has the listdir() method.  Rather, if listdir()
functionality is needed then one should use uos.listdir() which will call
VfsFat.ilistdir().
2017-05-10 11:39:28 +10:00
Damien George
87283c1974 extmod/vfs: Implement mp_vfs_ilistdir().
uos.ilistdir() is the core function, returning an iterator that yields
3-tuples.  uos.listdir() is implemented in terms of ilistdir().
2017-05-10 11:39:28 +10:00
Paul Sokolovsky
edc02bd952 unix/main: Implement -m option for packages. 2017-05-09 14:22:21 +03:00
Damien George
9bd67d9fbc tests/extmod: Make some vfs tests fully unmount FSs before running.
Otherwise the existing FSs can interfere with the tests, and in some
cases the tests can write to the real FS on the device.
2017-05-09 15:50:40 +10:00
Tom Collins
d00d062af2 tests/basics/lexer: Add lexer tests for input starting with newlines. 2017-05-09 14:48:00 +10:00
Tom Collins
2998647c4e py/lexer: Simplify lexer startup by using dummy bytes and next_char().
Now consistently uses the EOL processing ("\r" and "\r\n" convert to "\n")
and EOF processing (ensure "\n" before EOF) provided by next_char().

In particular the lexer can now correctly handle input that starts with CR.
2017-05-09 14:43:23 +10:00
Damien George
e711e2d44a tests/basics: Add memoryview test for big ints. 2017-05-09 10:49:19 +10:00
Damien George
2e9e14980d tests/basics: Update array test for big-int with lL typecodes. 2017-05-09 10:46:43 +10:00
Damien George
6cfa61a4cc py/binary: Handle storing big-ints to all arrays types.
Prior to this patch only 'q' and 'Q' type arrays could store big-int
values.  With this patch any big int that is stored to an array is handled
by the big-int implementation, regardless of the typecode of the array.
This allows arrays to work with all type sizes on all architectures.
2017-05-09 10:41:00 +10:00
Paul Sokolovsky
4a4490ffcc py/modio: resource_stream: Implement "package" param handling. 2017-05-06 18:42:35 +03:00
Paul Sokolovsky
c1e0eb7afe unix/main: Don't allow to specify too small heap size.
This will lead to crash like:

FATAL: uncaught NLR 80a5420

On x86_32, the minimum heap size is smaller, but not 2 times, so just
use value which works for x86_64.
2017-05-06 11:43:37 +03:00
Damien George
0986675451 stmhal: Convert all module and method tables to use MP_ROM macros. 2017-05-06 17:03:40 +10:00
Damien George
084824f866 tests: Move super-as-local test from cpydiff to basic tests.
It's now possible to use the name "super" as a local variable.
2017-05-06 11:01:57 +10:00
Damien George
dce7dd4259 tests/micropython: Add test for int.from_bytes with many zero bytes. 2017-05-06 10:29:09 +10:00
Damien George
58bb73e010 py/objint: In int.from_bytes, only create big-int if really needed.
This patch ensures that int.from_bytes only creates a big-int if necessary,
by checking the value for a small-int overflow as it's being parsed.
2017-05-06 10:29:09 +10:00
Tom Collins
288ea06e7c lib/utils/pyexec: Update event-driven REPL to match non-event REPL.
Don't print dupe ">>> " prompt when starting event-driven REPL.  Clear
incomplete line in transition from raw to friendly REPL.
2017-05-05 22:15:47 +10:00
Damien George
e62235f8c7 esp8266: Change default settings to mount flash at root dir. 2017-05-05 20:15:10 +10:00
Damien George
1b3e372418 tests/extmod: Add some more VFS tests. 2017-05-05 20:15:10 +10:00
Damien George
6c8b57a902 tests/extmod: Add more tests for VFS FAT. 2017-05-05 20:15:10 +10:00
Damien George
c9a3a68a49 extmod/vfs: Allow a VFS to be mounted at the root dir.
This patch allows mounting of VFS objects right at the root directory, eg
os.mount(vfs, '/').  It still allows VFS's to be mounted at a path within
the root, eg os.mount(vfs, '/flash'), and such mount points will override
any paths within a VFS that is mounted at the root.
2017-05-05 20:15:10 +10:00
Paul Sokolovsky
d4c070415a tools/upip: Upgrade to 1.2.
Memory optimizations and error handling improvements.
2017-05-05 13:12:19 +03:00
Paul Sokolovsky
12ea06567c tests/cpydiff/core_function_unpacking: Fill in workaround. 2017-05-04 00:48:48 +03:00
Paul Sokolovsky
92657c671f tests/cpydiff/core_import_split_ns_pkgs: Test for split namespace packages. 2017-05-03 17:16:19 +03:00
Paul Sokolovsky
3923f96dc6 tests/cpydiff/core_import_path: Test showing difference in package.__path__. 2017-05-03 12:22:53 +03:00
stijn
ab4a8618cf msvc: Workaround parser bug in older MSBuild versions
Versions prior to v14.0 have a bug in parsing item functions when used
within a condition: https://github.com/Microsoft/msbuild/issues/368.
Since commit [db9c2e3] this results in an error when building MicroPython
with for example VS2013.
Fix this by creating an intermediate property.
2017-05-03 10:41:53 +10:00
stijn
5b57ae985f mpy-cross: Fix compiler detection for including windows/fmode.c
fmode.c should only be included for builds targetting 'pure' windows, i.e.
msvc or mingw builds but not when using msys or cygwin's gcc (see #2298).
Just checking if the OS is windows and UNAME doesn't have msys stil leaves
the gate open for builds with cygwin's gcc since UNAME there is e.g.
CYGWIN_NT-6.1-WOW.
Fix this by checking for 'mingw' explicitly in the compiler version; both
gcc and clang have the -dumpmachine flag so the check should be ok for
all platforms.
2017-05-03 10:37:51 +10:00
Paul Sokolovsky
7d4ba9d257 tests/io/resource_stream: Add test for uio.resource_stream(). 2017-05-03 01:47:14 +03:00
Paul Sokolovsky
d7da2dba07 py/modio: Implement uio.resource_stream(package, resource_path).
The with semantics of this function is close to
pkg_resources.resource_stream() function from setuptools, which
is the canonical way to access non-source files belonging to a package
(resources), regardless of what medium the package uses (e.g. individual
source files vs zip archive). In the case of MicroPython, this function
allows to access resources which are frozen into the executable, besides
accessing resources in the file system.

This is initial stage of the implementation, which actually doesn't
implement "package" part of the semantics, just accesses frozen resources
from "root", or filesystem resource - from current dir.
2017-05-03 01:47:08 +03:00
Paul Sokolovsky
4c2fa83f2a zephyr/main: Remove superfluous include. 2017-05-02 23:35:13 +03:00
Paul Sokolovsky
b5159a9149 zephyr/mpconfigport.h: Enable line number information for scripts. 2017-05-02 23:33:16 +03:00
Paul Sokolovsky
c1b19115e5 tests/cpydiff/core_import_prereg: Fill in cause and workaround. 2017-05-02 14:12:52 +03:00
Paul Sokolovsky
8bb84cc627 tests/cpydiff/core_function_userattr: Clarify, fill in cause and workaround. 2017-05-02 03:43:21 +03:00
Paul Sokolovsky
58ecbc7752 tests/cpydiff/core_arguments: Fill in cause/workaround. 2017-05-02 03:36:47 +03:00
Paul Sokolovsky
674da04e2e zephyr/Makefile: Add debugserver Zephyr target. 2017-05-02 01:12:02 +03:00
Paul Sokolovsky
11bc21dfa8 unix/main: Ignore SIGPIPE signal, instead make EPIPE arrive.
Do not raise SIGPIPE, instead return EPIPE. Otherwise, e.g. writing
to peer-closed socket will lead to sudden termination of MicroPython
process. SIGPIPE is particularly nasty, because unix shell doesn't
print anything for it, so the above looks like completely sudden and
silent termination for unknown reason. Ignoring SIGPIPE is also what
CPython does. Note that this may lead to problems using MicroPython
scripts as pipe filters, but again, that's what CPython does. So,
scripts which want to follow unix shell pipe semantics (where SIGPIPE
means "pipe was requested to terminate, it's not an error"), should
catch EPIPE themselves.
2017-05-01 18:47:26 +03:00
Paul Sokolovsky
5db55e63f3 extmod/modlwip: ioctl POLL: Fix handling of peer closed socket.
Peer-closed socket is both readable and writable: read will return EOF,
write - error. Without this poll will hang on such socket.

Note that we don't return POLLHUP, based on argumentation in
http://www.greenend.org.uk/rjk/tech/poll.html that it should apply to
deeper disconnects, for example for networking, that would be link layer
disconnect (e.g. WiFi went down).
2017-05-01 18:20:09 +03:00
stijn
c41fe70ef2 windows/README: Add a note about stack usage for msvc
Add information as discussed in #2927 to the readme to make the easier
to discover.
2017-05-01 12:06:43 +02:00
stijn
fa823ea893 windows/README: Fix some typos and grammar 2017-05-01 11:58:47 +02:00
Paul Sokolovsky
e81f46940e tools/upip: Upgrade to 1.1.6, supports commented lines in requirements.txt. 2017-05-01 00:03:45 +03:00
Paul Sokolovsky
473e85e2da tools/mpy-tool: Make work if run from another directory.
By making sure we don't add relative paths to sys.path.
2017-05-01 00:01:30 +03:00
stijn
db9c2e310e msvc: Rebuild all qstrs when mpconfig headers are modified
Make qstr generation depend on modifications in mpconfigport.h, mpconfig.h
and makeqstrdata.py and if any of those change scan all source files for
qstrs again since they might have changed (for example typcially when
enabling new features in mpconfig.h).
This fixes #2982 for msvc builds.
2017-04-30 14:30:39 +03:00
stijn
8d865fa701 msvc: Do not define DEBUG for debug builds
It is not used anywhere and causes a warning about redefinition because
it is used in modutimeq.c
2017-04-30 14:28:37 +03:00
stijn
2f0ce2a6f5 py: Cleanup use of global DEBUG preprocessor definition
The standard preprocessor definition to differentiate debug and non-debug
builds is NDEBUG, not DEBUG, so don't rely on the latter:
- just delete the use of it in objint_longlong.c as it has been stale code
  for years anyway (since commit [c4029e5]): SUFFIX isn't used anywhere.
- replace DEBUG with MICROPY_DEBUG_NLR in nlr.h: it is rarely used anymore
  so can be off by default
2017-04-30 14:28:37 +03:00
Paul Sokolovsky
a7f5022591 windows/README: Convert to Markdown. 2017-04-30 00:41:24 +03:00
Paul Sokolovsky
4c2402e41e extmod/modlwip: getaddrinfo: Allow to accept all 6 standard params.
But warn if anything else but host/port is passed.
2017-04-29 18:56:39 +03:00
Paul Sokolovsky
de3a96ba17 extmod/moduselect: Implement ipoll() method for alloc-free polling.
Similar to the implementation added to unix port module previously.
2017-04-29 13:05:44 +03:00