Commit Graph

2177 Commits

Author SHA1 Message Date
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
b6b8f6ec9c Have stdlib::get_module_inits() use maplit::hashmap! 2019-06-16 10:33:47 -05:00
coolreader18
743adf10de Merge branch 'master' into coolreader18/comptime-pycompilation 2019-06-16 09:05:34 -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
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
8143b69165 Change imp_get_frozen_object 2019-06-14 11:31:39 -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
12a3028806 Import all from_list in one __import__ call 2019-06-14 08:27:49 +03: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
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
Aviv Palivoda
1de9f73bd0 Optimize already loaded modules 2019-06-11 22:54:54 +03:00
Aviv Palivoda
ea8e28026b Simplify objmodule 2019-06-11 13:13:32 +03:00
Aviv Palivoda
603ef1ad05 Support from_list 2019-06-10 21:45:05 +03:00
Aviv Palivoda
e1472f2277 Add sys.dont_write_bytecode 2019-06-10 19:18:32 +03:00
Aviv Palivoda
03735a6d26 Add optional parameters to compile 2019-06-10 19:18:32 +03:00
Aviv Palivoda
8dec522f96 compile source may be bytes 2019-06-10 19:18:32 +03:00
Aviv Palivoda
10828e01fb Set sys.pycache_prefix to None 2019-06-10 19:18:32 +03:00
Aviv Palivoda
b567464378 Add ModuleNotFoundError to builtins 2019-06-10 19:18:32 +03:00
Aviv Palivoda
d9d0ea1834 Fix os to _os in class 2019-06-10 19:18:32 +03:00
Aviv Palivoda
5584733cda Add sys.path_importer_cache 2019-06-10 19:18:32 +03:00
Aviv Palivoda
c8248c3211 Expose __name__ in __dict__ 2019-06-10 19:18:32 +03:00
Aviv Palivoda
375790e142 objmodule should have a dict 2019-06-10 19:18:32 +03:00
Aviv Palivoda
fe0284aa05 Add new to objmodule and change __name__ to property 2019-06-10 19:18:32 +03:00
Aviv Palivoda
6615e811c0 Collapse concat 2019-06-10 19:18:32 +03:00
Aviv Palivoda
5c53e58547 Print frozen import file name in stacktrace 2019-06-10 19:18:32 +03:00
Aviv Palivoda
0e76dbb749 Add needed methods to _thread 2019-06-10 19:18:32 +03:00
Aviv Palivoda
2817214c88 Remove unused imports 2019-06-10 19:18:32 +03:00
Aviv Palivoda
7f61125866 Use _bootstrap.py __import__ 2019-06-10 19:18:32 +03:00