Commit Graph

3118 Commits

Author SHA1 Message Date
Michel Heily
64af5c43df Add some test snippets for modulo string formatting 2019-06-17 19:35:09 +03:00
Michel Heily
adccfa63cf Fix bugs when parsing format specifiers with key mappings.
* Algorithm used for parsing the key from "%(key)d" format did not
handle multiple parenthesis correctly.

* Second problem is that they way we calculated number of consumed chars
was based on str::find, making the code vulnerable to false-positives.
2019-06-17 19:35:09 +03:00
Michel Heily
6fe2c43bf7 Move lambda to its own function in do_cformat 2019-06-17 19:35:09 +03:00
Michel Heily
fca4178353 Avoid unnecessary allocation in modulo formatting 2019-06-17 19:35:09 +03:00
Michel Heily
5d38b9b624 Simplify error handling for CFormatString::from_str 2019-06-17 19:35:09 +03:00
Michel Heily
8d612f3a36 Add %c formatting 2019-06-17 19:35:09 +03:00
Michel Heily
8e880b9bdd cformat: Fix a bug when formatting unicode strings
String::len() returns number of bytes and not number of chars, so it
doens't work as expected for unicode strings.

Also, added a test that would have triggered the bug.
2019-06-17 19:35:09 +03:00
Michel Heily
e374aff0bc Support '*' for width and precsision for printf-style formatting 2019-06-17 19:35:09 +03:00
Michel Heily
d5ffecea32 objstr: Improve errors for modulo format 2019-06-17 19:35:09 +03:00
Michel Heily
dc77728dbc cformat: Add some unittests.
Also, this commit fixes some bugs that were found using said unittests.
2019-06-17 19:35:09 +03:00
Michel Heily
481b044883 Support modulo formatting of numbers and string types 2019-06-17 19:35:09 +03:00
Michel Heily
fe6c1488d9 Start implementing str.__mod__ 2019-06-17 19:35:09 +03:00
Michel Heily
f27265cf8a Add get_value for objtuple 2019-06-17 19:35:09 +03:00
Michel Heily
d74e126246 Add parser for C printf-style format strings
This commit is a part of a series of future commits that will resolve #1007 .
Code is based on vm/src/format.rs.
2019-06-17 19:35:09 +03:00
Windel Bouwman
73edde66f7 Merge pull request #1037 from RustPython/coolreader18/option-source_path
Make CodeObject.source_path an Option<String>
2019-06-17 16:58:48 +02:00
coolreader18
b74b65d37e Make CodeObject.source_path an Option<String> 2019-06-16 19:59:04 -05:00
coolreader18
9b3521904a Update bench.rs to use vm.compile() 2019-06-16 15:47:27 -05:00
Windel Bouwman
8b0089e258 Merge pull request #1036 from RustPython/coolreader18/stdlib-mods-maplit
Use maplit::hashmap! for stdlib::get_module_inits()
2019-06-16 19:21:05 +02:00
coolreader18
b6b8f6ec9c Have stdlib::get_module_inits() use maplit::hashmap! 2019-06-16 10:33:47 -05:00
Windel Bouwman
ffeaf2d06a Merge pull request #1034 from RustPython/coolreader18/comptime-pycompilation
Allow compiling Python code to bytecode at compile-time
2019-06-16 17:28:02 +02:00
coolreader18
743adf10de Merge branch 'master' into coolreader18/comptime-pycompilation 2019-06-16 09:05:34 -05:00
coolreader18
d3927ff30e Merge pull request #1033 from palaviv/open-flags
Support more open flags
2019-06-16 00:34:45 -05:00
coolreader18
1814977c45 Add doc comments 2019-06-15 20:19:59 -05:00
coolreader18
6b9bbf3ea4 Change TODO 2019-06-15 13:23:04 -05:00
coolreader18
75c2e4ae9b Remove lazy_static, just store as a CodeObject 2019-06-15 11:31:30 -05:00
Aviv Palivoda
92ad30ef6a Add mode argument to os.open 2019-06-15 17:02:46 +03:00
Aviv Palivoda
82f83ef345 Support more open flags 2019-06-15 16:22:51 +03:00
coolreader18
241f5190cc Formatting 2019-06-15 00:30:14 -05:00
coolreader18
b5ba62fe94 Add lazy_static argument 2019-06-14 21:17:12 -05:00
coolreader18
48966a76e2 Make py_compile_bytecode!() an expression 2019-06-14 18:20:02 -05:00
coolreader18
7817cecc49 Merge pull request #1031 from palaviv/reversed
Support reversed on sequence
2019-06-14 15:23:35 -05:00
coolreader18
7e68f9924e Make Location's fields private again 2019-06-14 14:52:30 -05:00
coolreader18
4d0eb06724 Default source_path 2019-06-14 12:40:01 -05:00
coolreader18
d2cde9a3bf Use bincode to deserialize into a CodeObject 2019-06-14 12:26:35 -05:00
coolreader18
8143b69165 Change imp_get_frozen_object 2019-06-14 11:31:39 -05:00
coolreader18
9a09a92f31 Merge pull request #1030 from palaviv/import-from-list
Import all from_list in one call
2019-06-14 10:56:01 -05:00
coolreader18
e592f3d888 Add py_compile_bytecode! macro 2019-06-14 10:42:45 -05:00
Aviv Palivoda
60e799727f Support reversed on sequence 2019-06-14 15:25:24 +03:00
Aviv Palivoda
e61fa6dd74 Use Iterator to create from_list 2019-06-14 08:49:20 +03:00
Aviv Palivoda
4938c03d6f Improve compiler import 2019-06-14 08:45:30 +03:00
Aviv Palivoda
12a3028806 Import all from_list in one __import__ call 2019-06-14 08:27:49 +03:00
coolreader18
8b894a11fb Merge pull request #1029 from RustPython/coolreader18/rustpython_compiler
Split off bytecode compilation into a separate crate
2019-06-13 15:48:11 -04:00
coolreader18
bfd6145d5f Use RUSTPYTHONPATH in ouroboros instructions 2019-06-13 12:34:30 -05:00
coolreader18
c2502bf8ef Add doc comments and individual compile functions 2019-06-12 22:04:59 -05:00
coolreader18
45bb2bd263 Split off bytecode compilation into a separate crate 2019-06-12 21:43:43 -05:00
Windel Bouwman
3f343aff6c Merge pull request #1018 from palaviv/imp3
Importlib
2019-06-12 16:21:26 +02:00
coolreader18
02821324b7 Merge pull request #1028 from RustPython/coolreader18/update-deps1
Update cargo dependencies
2019-06-11 18:07:09 -05:00
coolreader18
cb2fe657a9 Merge pull request #1014 from mkurnikov/cleanup-get-method-error-handling
Cleanup get_method() error handling
2019-06-11 17:43:58 -05:00
coolreader18
07c6a90045 Update cargo dependencies 2019-06-11 16:00:35 -05:00
Aviv Palivoda
1de9f73bd0 Optimize already loaded modules 2019-06-11 22:54:54 +03:00