Paul Sokolovsky
6582d64d01
modstruct: Refactor to support both LE and BE packed structs.
11 years ago
Damien George
f31b6ff334
tests: Add test for multi-comparison.
11 years ago
Paul Sokolovsky
978607aeff
objfun: Fix default arguments filling loop, was broken in presense of kwargs.
11 years ago
Paul Sokolovsky
e9db840480
py: Start implementing "struct" module.
Only calcsize() and unpack() functions provided so far, for little-endian
byte order. Format strings don't support repition spec (like "2b3i").
Unfortunately, dealing with all the various binary type sizes and alignments
will lead to quite a bloated "binary" helper functions - if optimizing for
speed. Need to think if using dynamic parametrized algos makes more sense.
11 years ago
Damien George
a157e4caba
py: str.join can now take arbitrary iterable as argument.
11 years ago
Damien George
13d6739cc7
py: Generators can have their locals closed over.
11 years ago
Damien George
2bf7c09222
py: Properly implement deletion of locals and derefs, and detect errors.
Needed to reinstate 2 delete opcodes, to specifically check that a local
is not deleted twice.
11 years ago
Paul Sokolovsky
a985b4593d
objint: Implement int.from_bytes() class method and .to_bytes() method.
These two are apprerently the most concise and efficient way to convert
int to/from bytes in Python. The alternatives are struct and array modules,
but methods using them are more verbose in Python code and less efficient
in memory/cycles.
11 years ago
Damien George
2b0091983f
tests: Oops: fix del-attr.
11 years ago
Damien George
f4c9b33abf
py: Remove DELETE_SUBSCR opcode, combine with STORE_SUBSCR.
This makes the runtime and object APIs more consistent. mp_store_subscr
functionality now moved into objects (ie list and dict store_item).
11 years ago
Paul Sokolovsky
4dcb605ac4
py: Make bytearray a proper type.
11 years ago
xbe
3d9a39e211
py: Implement str.[r]index() and add tests for them.
11 years ago
Damien George
495d781a36
py: implement UNPACK_EX byte code (for: a, *b, c = d)
11 years ago
Paul Sokolovsky
b9cf3d3730
bytearray: Support bytearray(int) constructor.
To create bytearray of given length.
11 years ago
Andrew Scheller
12968fb6b2
Display \r and \t escape codes in string repr
11 years ago
Dave Hylands
c4029e5079
Add string formatting support for longlong and mpz.
11 years ago
Andrew Scheller
1ff6011abc
Modify set tests to print sorted sets directly
instead of creating temporary lists and sorting those in-place
11 years ago
Andrew Scheller
a1a9ab2b2c
Add tests for sorted() function
and check that sorted(list) produces same output as list.sort()
11 years ago
Paul Sokolovsky
4d2238d2ce
tests: Fix more tests which depend on order of elements in set.
11 years ago
Paul Sokolovsky
bd6f3d31d2
tests: Fix few tests which depend on order of elements in set.
11 years ago
Damien George
07e24a6294
tests: Fix tests with sets to print sorted set.
11 years ago
Damien George
ff715429ea
py: Fix str.replace for case when arg 0 or 1 is empty string.
11 years ago
Paul Sokolovsky
b4dea46d8b
tests: Fix few tests which depend on order of elements in dict.
With dict being unordered of course.
11 years ago
Paul Sokolovsky
e2adff3608
tests/dict2.py: Add combined test for dict(dict) and dict equality.
11 years ago
Damien George
deed087e2c
py: str.split: handle non-default separator.
11 years ago
Damien George
2a037408af
tests: Add test to check issue #429 .
11 years ago
Damien George
95004e5114
py: Fix delete operation on map/dict and set objects.
Hash table can now be completely full (ie now NULL entry) before a
resize is triggered. Use sentinel value to indicate delete entry in the
table.
11 years ago
Dave Hylands
f81a49e464
Allow floating point arguments with %d,i,u,o,x,X formats
11 years ago
Damien George
b6ec51bbf0
tests: Add test for dict delete. It fails.
11 years ago
Paul Sokolovsky
bfb7d6a26d
py: Support 3-arg getattr() builtin (with default value).
11 years ago
Paul Sokolovsky
438d504e27
objtype: Add equality test for type types.
11 years ago
Paul Sokolovsky
91cbe6033a
py: Allow types to be hashable.
Quite natural to have d[int] = handle_int .
11 years ago
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