Commit Graph

14599 Commits

Author SHA1 Message Date
Paul Sokolovsky
1d4d9ddd9e stmhal: Reimplement file support using stream protocol API.
This adds readline(), readall(), etc. methods. Also other fixes to make
Python API compliant and "with" support.
2014-04-03 22:14:29 +03:00
Paul Sokolovsky
34e1199b3a run-tests: Allow to override python3 command to use via environment var. 2014-04-03 22:09:12 +03:00
Paul Sokolovsky
c61ce96590 unix file: Implement context manager protocol (for "with" statement). 2014-04-03 22:09:05 +03:00
Paul Sokolovsky
98a627dc03 py: Add "io" module.
So far just includes "open" function, which should be supplied by a port.

TODO: Make the module #ifdef'ed.
2014-04-03 22:08:57 +03:00
Damien George
8270e3853d py: More robust int conversion and overflow checking. 2014-04-03 11:00:54 +00:00
Damien George
a58a7aefbd Merge pull request #417 from pfalcon/unix-enable-gc
unix: Enable GC.
2014-04-02 21:20:33 +01:00
Damien George
cc7085c1ce Merge branch 'fix-format-int' of github.com:dhylands/micropython into dhylands-fix-format-int
Conflicts:
	py/objstr.c
2014-04-02 20:37:05 +01:00
Dave Hylands
22fe4d7344 Fix str.format to work with {:f/g/e} and ints
Also fix objstr.c to compile when floats disabled.
2014-04-02 12:10:18 -07:00
Damien George
c322c5f07f py: Fix regress for printing of floats and #if.
Also change formating modifier in test script (it still passes with
original format though).
2014-04-02 20:04:15 +01:00
Damien George
a05f5dd952 Merge branch 'master' of github.com:micropython/micropython 2014-04-02 19:55:26 +01:00
Damien George
e90eefc84b stmhal: Fix servo object; add fpclassify to math functions. 2014-04-02 19:55:08 +01:00
Paul Sokolovsky
78e8e30c87 unix: Enable GC.
GC support for "unix" port was implemented some time ago, but still not
enabled.
2014-04-02 20:57:19 +03:00
Paul Sokolovsky
ad1bac63f7 tests/string-format: Add test for formatting ints with float format.
Fail currently.
2014-04-02 20:41:34 +03:00
Paul Sokolovsky
e807fa8d60 gc: Uses uint defined in misc.h. 2014-04-02 20:36:32 +03:00
Paul Sokolovsky
d440dc0513 unix: Use argv[0] for command name in usage. 2014-04-02 20:31:18 +03:00
Paul Sokolovsky
a55a5469c3 unix: Support #if-able impl-specific cmdline options.
For example, we still build w/o GC enabled, so cannot really set heap size.
2014-04-02 20:29:18 +03:00
Paul Sokolovsky
d4e7e06d7f unix: Properly recognize and report when script on cmdline not found.
Previosuly just silently exited.
2014-04-02 20:25:01 +03:00
Damien George
094d450003 py: Wrap compile_scope_inline_asm in #if; remove comment from misc.h. 2014-04-02 17:31:27 +01:00
Damien George
70f33cde48 py: Fix up so that it can compile without float. 2014-04-02 17:06:05 +01:00
Damien George
af6edc61bd py: Enable a jump optimisation in the compiler. 2014-04-02 16:12:28 +01:00
Damien George
882b363564 py: Move to Python 3.4.0 compatibility.
Very little has changed.  In Python 3.4 they removed the opcode
STORE_LOCALS, but in Micro Python we only ever used this for CPython
compatibility, so it was a trivial thing to remove.  It also allowed to
clean up some dead code (eg the 0xdeadbeef in class construction), and
now class builders use 1 less stack word.

Python 3.4.0 introduced the LOAD_CLASSDEREF opcode, which I have not
yet understood.  Still, all tests (apart from bytecode test) still pass.
Bytecode tests needs some more attention, but they are not that
important anymore.
2014-04-02 15:56:31 +01:00
Damien George
929a675a3d Change test scripts to use python3; bytecode tests use python3.4.
I upgraded to Python 3.4.0, so needed to make these changes.  Hopefully
the tests still run with Python 3.3.x (the scripts use python3 so are
agnostic as to the subversion).

Bytecode tests are tightly coupled to the Python version, and now some
fail against Python 3.4.
2014-04-02 15:31:39 +01:00
Damien George
4d4a7f5354 Merge branch 'pip-micropy' of github.com:pfalcon/micropython into pfalcon-pip-micropy 2014-04-02 15:14:28 +01:00
Damien George
a12be917a4 stmhal: Add timer module; move servo PWM from TIM2 to TIM5.
As per issue #257, servo is better on TIM5 because TIM2 is connected to
more GPIO.
2014-04-02 15:09:36 +01:00
Damien George
69dee59ce4 stmhal: Add backspace key to readline (along with delete key). 2014-04-02 14:28:58 +01:00
Damien George
10e21b9770 Add more tests. 2014-04-02 14:23:04 +01:00
Damien George
93b7faa29a py: Factor out static/class method unwrapping code; add tests. 2014-04-02 14:13:26 +01:00
Damien George
e4c834fc1e Add a test. 2014-04-02 13:32:37 +01:00
Damien George
b23fbb3126 py: Implement floating point power binop. 2014-04-02 12:26:49 +01:00
Damien George
660aef67c4 py: Allow multiple of str/list/tuple on left by an integer. 2014-04-02 12:22:07 +01:00
Paul Sokolovsky
802d505756 tools: Add pip-micropython to install packages in MicroPython-friendly way. 2014-04-02 12:49:07 +03:00
Damien George
4881566874 py: Add support for sep and end keywords in print. 2014-04-02 10:34:44 +01:00
Damien George
084ef373fb py: Fix math.{ceil,floor,trunc} to return int. 2014-04-01 21:21:50 +01:00
Damien George
e3e0500296 py: Make pfenv.c conform to code conventions. 2014-04-01 21:15:03 +01:00
Damien George
e8e8f212aa Merge pull request #412 from dhylands/pfenv-strn-stack
Pfenv strn stack
2014-04-01 20:55:27 +01:00
Damien George
ef13e2032d Merge pull request #410 from dhylands/fix-led
Fix pyb.Led(n) code to work properly.
2014-04-01 20:52:56 +01:00
Damien George
256afcf9f6 Merge pull request #411 from dhylands/pfenv-64-bit
Fix INT_BUF_SIZE to work with 32-bit and 64-bit
2014-04-01 20:18:14 +01:00
Paul Sokolovsky
380cc53bd9 Merge pull request #408 from dhylands/str-quick-tests
Turn off full tests in string-format.py
2014-04-02 03:13:51 +08:00
Dave Hylands
1c6b4b2e24 Reduce stack usage of pfenv_print_strn 2014-04-01 11:59:31 -07:00
Dave Hylands
80359aa96e Fix INT_BUF_SIZE to work with 32-bit and 64-bit 2014-04-01 11:03:44 -07:00
Dave Hylands
18d21d1abd Fix pyb.Led(n) code to work properly. 2014-04-01 10:41:22 -07:00
Dave Hylands
7adc2e0431 Turn off full tests in string-format.py
Add some basic coverage tests
2014-04-01 08:10:02 -07:00
Paul Sokolovsky
51413c8cb6 tests: Add test for implicit float to int conversion (not allowed!) 2014-04-01 13:50:16 +03:00
Damien George
e09320adb5 py: Remove implicit conversion from int to float. 2014-04-01 10:56:07 +01:00
Damien George
46330bd9b5 Merge pull request #407 from dhylands/str-format
Enhance str.format support
2014-04-01 10:48:58 +01:00
Dave Hylands
baf6f14deb Enhance str.format support
This adds support for almost everything (the comma isn't currently
supported).

The "unspecified" type with floats also doesn't behave exactly like
python.

Tested under unix with float and double
Spot tested on stmhal
2014-04-01 01:17:33 -07:00
Damien George
e44d26ae0c py: Implement __getattr__.
It's not completely satisfactory, because a failed call to __getattr__
should not raise an exception.

__setattr__ could be implemented, but it would slow down all stores to a
user created object.  Need to implement some caching system.
2014-03-31 22:57:56 +01:00
Paul Sokolovsky
4db727afea objstr: Very basic implementation of % string formatting operator. 2014-03-31 21:20:52 +03:00
Paul Sokolovsky
6ce78c4fae py: Wrap .__class__ handling in MICROPY_CPYTHON_COMPAT.
Because it's superfluos in the presence of type(), a remenant from Python's
"old classes".
2014-03-31 20:40:31 +03:00
Paul Sokolovsky
b509f73982 objtype: Wrap .__name__ handling in MICROPY_CPYTHON_COMPAT.
Because it's runtime reflection feature, not required for many apps.
Rant time:
Python could really use better str() vs repr() distinction, for example,
repr(type) could be "<class 'foo'>" (as it is now), and str(type) just
"foo". But alas, getting straight name requires adhoc attribute.
2014-03-31 20:40:31 +03:00