Damien George
6902eeda25
py: Add m_malloc_fail function to handle memory allocation error.
A malloc/realloc fail now throws MemoryError.
11 years ago
Dave Hylands
6756a37a77
Implements most of str.modulo
The alternate form for floating point doesn't work yet.
The %(name)s form doesn't work yet.
11 years ago
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).
11 years ago
Paul Sokolovsky
ad1bac63f7
tests/string-format: Add test for formatting ints with float format.
Fail currently.
11 years ago
Damien George
10e21b9770
Add more tests.
11 years ago
Damien George
93b7faa29a
py: Factor out static/class method unwrapping code; add tests.
11 years ago
Damien George
4881566874
py: Add support for sep and end keywords in print.
11 years ago
Damien George
084ef373fb
py: Fix math.{ceil,floor,trunc} to return int.
11 years ago
Dave Hylands
7adc2e0431
Turn off full tests in string-format.py
Add some basic coverage tests
11 years ago
Paul Sokolovsky
51413c8cb6
tests: Add test for implicit float to int conversion (not allowed!)
11 years ago
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
11 years ago
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.
11 years ago
Paul Sokolovsky
4db727afea
objstr: Very basic implementation of % string formatting operator.
11 years ago
Damien George
3ff2d03891
py: Fix bug in optimised for .. range.
Don't store final, failing value to the loop variable. This fix also
makes for .. range a bit more efficient, as it uses less store/load
pairs for the loop variable.
11 years ago
Paul Sokolovsky
183faa3b13
tests: Add testcase for multiple inheritance.
11 years ago
Paul Sokolovsky
6ded55a61f
py: Properly implement divide-by-zero handling.
"1/0" is sacred idiom, the shortest way to break program execution
(sys.exit() is too long).
11 years ago
Paul Sokolovsky
f7eaf605c0
py: Fix "TypeError: 'iterator' object is not iterable", doh.
11 years ago
Paul Sokolovsky
f39d3b93da
py: Implement support for generalized generator protocol.
Iterators and ducktype objects can now be arguments of yield from.
11 years ago
Damien George
230fec77d7
py: Implement positional and keyword args via * and **.
Extends previous implementation with * for function calls to * and **
for both function and method calls.
11 years ago
Paul Sokolovsky
7fafb28f6d
objgenerator: Handle default args to generator functions.
Addresses #397 .
11 years ago
Paul Sokolovsky
55ca075cab
vm: Implement CALL_FUNCTION_VAR opcode (foo(*(1, 2, 3))).
11 years ago
Damien George
010043caaf
Add "tracing" to try-reraise2.py test. It now fails.
11 years ago
Paul Sokolovsky
0c904df8e6
vm: Save current active exception on opening new try block.
Required to reraise correct exceptions in except block, regardless if more
try blocks with active exceptions happen in the same except block.
P.S. This "automagic reraise" appears to be quite wasteful feature of Python
- we need to save pending exception just in case it *might* be reraised.
Instead, programmer could explcitly capture exception to a variable using
"except ... as var", and reraise that. So, consider disabling argless raise
support as an optimization.
11 years ago
Paul Sokolovsky
d109676ec0
py: Reraising exception possible only in except block.
11 years ago
Damien George
75f71584a6
tests: Remove unimplemented exceptions from testing.
11 years ago
Paul Sokolovsky
e7286ef2c7
tests: Add "with" statement testcases.
11 years ago
Paul Sokolovsky
3c2b2acd8c
tests: Add testcases for yield from.
11 years ago
Paul Sokolovsky
e9137b94f2
py: Implement getattr() builtin.
11 years ago
Paul Sokolovsky
2447a5b582
py: Support closures with default args.
11 years ago
Damien George
66eaf84b8c
py: Replace mp_const_stop_iteration object with MP_OBJ_NULL.
11 years ago
Paul Sokolovsky
c403076ef8
vm: Implement raise statement w/o args (reraising last exception).
11 years ago
Paul Sokolovsky
962b1cd1b1
objgenerator: Implement return with value and .close() method.
Return with value gets converted to StopIteration(value). Implementation
keeps optimizing against creating of possibly unneeded exception objects,
so there're considerable refactoring to implement these features.
11 years ago
Damien George
ffb5cfc8d8
py: Removed some unnecessary exception objects.
They still exist in commented-out form in objexcept.c if they are ever
needed.
11 years ago
Paul Sokolovsky
9512e9e817
objexcept: Add "args" exception attribute, as well as StopIteration.value.
11 years ago
Paul Sokolovsky
7f8b31345b
rt_load_method(): Add missing qstr_str() when getting type name.
11 years ago
xbe
17a5a83fb4
Implement str.rfind() and add tests for it.
11 years ago
Paul Sokolovsky
f909034400
py: Implement support for "except Exception as var" clause.
For this, needed to implement DELETE_NAME bytecode (because var bound
in except clause is automatically deleted at its end).
http://docs.python.org/3/reference/compound_stmts.html#except :
"When an exception has been assigned using as target, it is cleared at
the end of the except clause."
11 years ago
Rachel Dowdall
2d15deebdc
Fixed floor division on mp ints and small ints. Added a floordivide test case.
11 years ago
Rachel Dowdall
56402796d8
Fixed floor division on mp ints and small ints. Added a floordivide test case.
11 years ago
Rachel Dowdall
cde8631f15
Fixed modulo operator on ints and mp ints to agree with python. Added intdivmod.c and tests/basics/modulo.py.
11 years ago
Paul Sokolovsky
48caa09a9d
objgenerator: Implement .throw() method to throw exceptions into generator.
11 years ago
Paul Sokolovsky
61fd20f168
objgenerator: Implement throwing exceptions out of generator.
11 years ago
Paul Sokolovsky
c0abc28aa1
objgenerator: Keep exception stack within generator object, like value stack.
This is required to properly handle exceptions across yields.
11 years ago
Rachel Dowdall
721c55dced
Added exception hierarchy except for OSError and UnicodeError (requires arguments). Comment out the errors that aren't needed if memory becomes an issue.
11 years ago
Rachel Dowdall
249b9c761d
Fixed broken math functions that return bool and added some more.
11 years ago
Paul Sokolovsky
1ecea7c753
py: Make 'bytes' be a proper type, support standard constructor args.
11 years ago
Paul Sokolovsky
42901554db
objint_longlong: Add regression test for improper inplace op implementation.
11 years ago
xbe
4504ea8007
Implement str.rpartition and add tests for it.
11 years ago
xbe
613a8e3edf
Implement str.partition and add tests for it.
11 years ago
Damien George
1609f85582
Rename test so that it doesn't clash with Python math module.
11 years ago