Compare commits

...

1004 Commits

Author SHA1 Message Date
Adam Kelly
1d1a931011 Move attributes dictionary to PyObject. 2019-03-05 17:09:48 +00:00
Adam Kelly
2d78425bab Add (unused) dict element to PyObject struct. 2019-03-05 16:27:51 +00:00
Adam Kelly
43118db1b0 Remove None and NotImplemented payloads and replace with NoPayload 2019-03-05 15:50:07 +00:00
Adam Kelly
647cb08d78 Remove special case for None payload from boolval. 2019-03-05 15:05:52 +00:00
Adam
d278fb841c Merge pull request #597 from RustPython/type_hints
Add type annotations to parser.
2019-03-05 14:43:30 +00:00
Ryan Liddle
b7c03b4be5 Merge pull request #601 from RustPython/ellipsis
Add ellipsis syntax.
2019-03-05 18:30:44 +11:00
Windel Bouwman
cb1b9d368f Merge pull request #602 from coolreader18/prep-wasm-npm
Prepare the wasm crate for publishing on npm
2019-03-05 07:25:10 +01:00
Windel Bouwman
81a85cc0bf Merge pull request #599 from palaviv/Fix-locals
Fix locals
2019-03-05 07:23:46 +01:00
Windel Bouwman
458ead0cbc Merge pull request #600 from adrian17/as_ratio
Add float.as_integer_ratio()
2019-03-05 07:22:38 +01:00
Windel Bouwman
883a4944c8 Merge pull request #598 from palaviv/dir-module
Fix module dir
2019-03-05 07:20:12 +01:00
Windel Bouwman
05929b3d7b Add ellipsis type, test and do rustfmt. 2019-03-05 07:19:00 +01:00
coolreader18
eefde87594 Cargo.lock update 2019-03-04 21:17:29 -06:00
Joey
006e975bc5 Update wasm/lib/README.md
Co-Authored-By: coolreader18 <33094578+coolreader18@users.noreply.github.com>
2019-03-04 17:16:02 -06:00
coolreader18
55cc653d9b Prepare the wasm crate for publishing on npm 2019-03-04 16:50:30 -06:00
Windel Bouwman
a26401707f Minor lexer simplifications. 2019-03-04 21:25:35 +01:00
Aviv Palivoda
a545e4392a Test locals indside a function 2019-03-04 22:17:41 +02:00
Windel Bouwman
e25742f184 Add ellipsis syntax. 2019-03-04 21:09:03 +01:00
Windel Bouwman
b50f0be910 Merge pull request #596 from RustPython/joey/complex-to-any
Convert complex to Any payload
2019-03-04 20:55:51 +01:00
Adrian Wielgosik
eed0b3ca45 Add float.as_integer_ratio() 2019-03-04 20:52:56 +01:00
Aviv Palivoda
da57730692 Fix get_locals 2019-03-04 21:52:20 +02:00
Aviv Palivoda
2d31e35844 Add test dir 2019-03-04 21:31:20 +02:00
Windel Bouwman
f7a22254a6 Add return annotation and fix tests in parser. 2019-03-04 20:29:34 +01:00
Aviv Palivoda
d24f79b17d dir show module content 2019-03-04 21:27:03 +02:00
Windel Bouwman
6544f60d9b Add type annotations to parser. 2019-03-04 19:24:34 +01:00
Adam
a7c3f85da7 Merge pull request #595 from palaviv/socket-user-macros
Use py_class and py_module macros in socket
2019-03-04 17:11:08 +00:00
Joey Hain
f820aeb1ea Convert complex payload 2019-03-04 09:04:24 -08:00
Aviv Palivoda
933c8dc792 Use py_module macro 2019-03-04 18:30:37 +02:00
Aviv Palivoda
d2061004a3 Use py_class macro 2019-03-04 18:27:33 +02:00
Windel Bouwman
38c43e0465 Merge pull request #590 from RustPython/exec
Proper construction of scope for exec/eval.
2019-03-04 16:57:12 +01:00
Adam
839f906927 Merge pull request #592 from RustPython/joey/improved-arg-errors
Improve error messages and add docs for new native function machinery
2019-03-04 14:42:18 +00:00
Adam
4ce0a7c216 Merge pull request #586 from RustPython/joey/float-range-any-payload
Convert more objects to `Any` payload
2019-03-04 14:40:06 +00:00
Adam Kelly
c4953ee9ec Remove new macro and inline check into make_scope. 2019-03-04 14:33:53 +00:00
Adam Kelly
0d4887abe6 Fix missing asserts and add (disabled) tests for things that don't work yet. 2019-03-04 14:32:52 +00:00
Adam Kelly
6548c365cb Use check_but_allow_none for exec/eval. 2019-03-04 14:32:52 +00:00
Adam Kelly
4dd0304712 Add check_but_allow_none macro for optional argument checking. 2019-03-04 14:32:52 +00:00
Adam Kelly
c5789a03a3 Proper construction of scope for exec/eval. 2019-03-04 14:32:52 +00:00
Adam
5d28f9bc36 Merge pull request #594 from skinny121/isinstance_2
Only use real isinstance/issubclass for built-ins
2019-03-04 14:31:43 +00:00
ben
b1a070acc2 Only use real isinstance/issubclass for builtins and move the real
versions to the vm.
2019-03-04 19:55:58 +13:00
Joey Hain
2d71f6de28 bytes and bytearray 2019-03-03 20:01:07 -08:00
Joey Hain
4e822ed6cd Improve error messages and add docs for new native function machinery 2019-03-03 12:52:51 -08:00
Windel Bouwman
9b7c0f78c8 Merge pull request #584 from palaviv/socket-udp
Socket UDP
2019-03-03 21:01:15 +01:00
Aviv Palivoda
283b331323 Use vm.ctx.new_tuple 2019-03-03 18:22:20 +02:00
Aviv Palivoda
f09f75ac8d Do implicit bind in socket.sendto 2019-03-03 18:15:14 +02:00
Aviv Palivoda
9b5ba068af Return addr in accept 2019-03-03 18:15:14 +02:00
Aviv Palivoda
86b60faa61 Add socket.{sendto, recvfrom} 2019-03-03 18:15:14 +02:00
Aviv Palivoda
e5d1d11c3e Add UDP to socket 2019-03-03 18:15:14 +02:00
Windel Bouwman
9271115db7 Introduce py_class macro to define classes. (#589)
* Introduce py_class macro to define classes.
* rustfmt
2019-03-03 13:25:00 +00:00
Joey
4f944d33ad Merge pull request #588 from arfan/master
fix typo in README.md, will to with
2019-03-02 19:44:21 -07:00
Abdul Arfan
0a68b7a3da fix typo in README.md, will to with 2019-03-03 09:18:08 +07:00
Joey Hain
e7fb116210 Convert more objects to Any payload 2019-03-02 13:27:00 -08:00
Joey Hain
4558dbf210 Fix build (rustfmt) 2019-03-02 13:25:42 -08:00
Windel Bouwman
b98926a0fb Merge pull request #572 from RustPython/joey/fun-with-functions
Derive types, arity, conversions and more from rust fns
2019-03-02 20:56:52 +01:00
Windel Bouwman
30ddb48037 Use PyResult at more places. 2019-03-02 14:10:46 +01:00
Windel Bouwman
8847081e8b Merge pull request #582 from palaviv/socket-any
Use PyObjectPayload::AnyRustValue for socket
2019-03-02 13:45:48 +01:00
Joey Hain
3478251d40 Merge remote-tracking branch 'origin/master' into joey/fun-with-functions
Conflicts:
      vm/src/lib.rs
      vm/src/pyobject.rs
      wasm/lib/src/vm_class.rs
2019-03-02 04:04:22 -08:00
Joey Hain
a70f251b6a PyNativeFuncFactory => IntoPyNativeFunc 2019-03-02 03:47:37 -08:00
Aviv Palivoda
af2f790d0d Use PyObjectPayload::AnyRustValue for socket 2019-03-02 12:26:23 +02:00
Aviv Palivoda
aed657173f Simplify socket_close 2019-03-02 12:26:23 +02:00
Aviv Palivoda
e4007f530e Add get_socket function 2019-03-02 12:25:59 +02:00
Windel Bouwman
7bb6f8fdaa Minor clippy fix. 2019-03-02 11:22:40 +01:00
Windel Bouwman
8f52e15d32 Minor clippy fixes. 2019-03-02 11:14:35 +01:00
Windel Bouwman
f3e29c8d5f Merge pull request #581 from coolreader18/wasm-example-crate-alert
Use alert() for the WASM example crate
2019-03-02 10:31:40 +01:00
Windel Bouwman
c8afeae0f7 Merge pull request #577 from RustPython/kill_scope_variant
Remove Scope variant from PyObject.
2019-03-02 10:30:41 +01:00
Windel Bouwman
5b39924389 Merge pull request #580 from coolreader18/fix-clippy-lints
Fix a bunch of clippy lints
2019-03-02 10:20:16 +01:00
coolreader18
5f8fb896d7 Fix lints in rustpython_wasm 2019-03-01 20:22:14 -06:00
coolreader18
c99e843769 Fix a clippy lint I missed 2019-03-01 20:13:50 -06:00
coolreader18
58e1533b12 Fix clippy lint for float_is_integer 2019-03-01 20:12:54 -06:00
coolreader18
f364ea5943 Fix a bunch of clippy lints 2019-03-01 18:41:45 -06:00
coolreader18
60603d250e Use alert() for the WASM example crate 2019-03-01 18:06:50 -06:00
Adam Kelly
9d6e9ac889 Move Scope from pyobject to frame. 2019-03-01 20:49:17 +00:00
Adam Kelly
c2e2441388 Remove Scope variant from PyObject. 2019-03-01 20:47:09 +00:00
Joey Hain
e2e3353441 Add factory impl for boxed fn and remove extra constructor 2019-03-01 11:39:52 -08:00
Windel Bouwman
387c21f285 Merge pull request #570 from coolreader18/wasm-vm-inject_module
Add an `injectModule` method to WASMVirtualMachine
2019-03-01 17:16:22 +01:00
Windel Bouwman
e34c8af793 Merge pull request #576 from adrian17/raise-type
Support raising exceptions without call
2019-03-01 17:00:14 +01:00
Adrian Wielgosik
1519426cb4 Support raising exceptions without call 2019-02-28 22:06:14 +01:00
Joey
990c29469a Merge remote-tracking branch 'origin/master' into joey/fun-with-functions
Conflicts:
      vm/src/pyobject.rs
2019-02-28 10:44:46 -08:00
Windel Bouwman
40c1a0f197 Merge pull request #562 from coolreader18/wasm-promise-class
[WASM] Add a Promise class to the browser module
2019-02-28 17:19:41 +01:00
Windel Bouwman
eaaafacd87 Merge pull request #554 from skinny121/isinstance
Call __instancecheck__ and __subclasscheck__
2019-02-28 17:14:12 +01:00
coolreader18
500f48621d Merge branch 'master' into wasm-promise-class 2019-02-28 07:29:17 -06:00
Ryan Liddle
de322689eb Merge pull request #573 from alexpantyukhin/fix_mut_warning
remove redundant mut
2019-02-28 21:07:00 +11:00
Ryan Liddle
f6e99d1e24 Merge pull request #574 from RustPython/fetch_ins
fetch_instruction can just return a reference.
2019-02-28 21:06:18 +11:00
Adam Kelly
786eb2cbfb fetch_instruction can just return a reference. 2019-02-28 08:33:43 +00:00
ben
5779124f11 rustfmt 2019-02-28 20:40:32 +13:00
ben
e30d91febc Swap naming of is{instance, subclass} <-> real_is{instance, subclass} 2019-02-28 20:32:57 +13:00
ben
52c32fab3a Call __instancecheck__ and __subclasscheck__ as part of isinstance and issubclass 2019-02-28 20:30:31 +13:00
Windel Bouwman
b0ee1947c7 Merge pull request #565 from alexpantyukhin/add_kwarg_handling_to_int
add kwarg handling for int
2019-02-28 07:36:08 +01:00
apantykhin
9081cb2b2c remove redundant mut 2019-02-28 06:35:08 +00:00
Windel Bouwman
56e55e87fe Merge pull request #568 from RustPython/framestack_2
Framestack 2
2019-02-28 07:33:04 +01:00
Windel Bouwman
6f2bbd2e4c Merge pull request #545 from palaviv/socket1
Socket improvments
2019-02-28 07:24:10 +01:00
Windel Bouwman
cca19cf71f Merge pull request #569 from coolreader18/wasm-alert
Add alert, confirm, and prompt to the browser module
2019-02-28 07:22:30 +01:00
Joey Hain
67f8c02087 cleanup 2019-02-27 20:05:04 -08:00
Joey Hain
713edc57ee Convert some objstring methods to new style. 2019-02-27 19:53:31 -08:00
Joey Hain
7f75e3ee8a Significant improvements to new function definition style
- PyRef<T> type for accepting references to payloads.
- Args<T> type for consuming remaining positional args
  (mirrors python `*args`).
- KwArgs<T> type for consuming remaining keyword args
  (mirrors python `*kwargs`).
- OptArg<T> type for consuming remaining keyword args
  (no python code equivalent, only possible in native functions like in cpython).
- PyIterable<T> for accepting an iterator over a sequence of Ts.
- Arity checking (but TypeError messages need work)
2019-02-27 19:53:20 -08:00
coolreader18
f6196126e4 Add an injectModule method to WASMVM 2019-02-27 19:25:06 -06:00
coolreader18
ea93fb871c Add alert, confirm, and prompt to the browser module 2019-02-27 17:38:24 -06:00
apantykhin
7e2c702c5e fix fmt 2019-02-27 21:22:24 +00:00
alexpantyukhin
d806a19c23 add kwarg handling for int 2019-02-27 19:58:32 +00:00
Aviv Palivoda
8087ccf274 Add socket.getsockname 2019-02-27 20:47:53 +02:00
coolreader18
e3db472f37 Fix merge conflicts 2019-02-27 12:44:42 -06:00
Adam Kelly
2cc9a606da Avoid double borrow in Frame.nth_value. 2019-02-27 18:23:39 +00:00
Aviv Palivoda
dc0bd73d12 Fix compiler warnings 2019-02-27 20:23:02 +02:00
Aviv Palivoda
4191ba67b3 Copy instead of clone 2019-02-27 20:19:10 +02:00
Aviv Palivoda
716eb4afca Add validation to connect and bind address 2019-02-27 19:54:39 +02:00
Aviv Palivoda
dff6b0be36 Rename sk to socket_kind 2019-02-27 19:54:39 +02:00
Aviv Palivoda
2bdbc40a45 socket.recv read amount of bytes asked 2019-02-27 19:50:31 +02:00
Adam Kelly
676130fc49 Use refcells in frames to solve frame mutability problem. 2019-02-27 10:47:33 +00:00
Adam Kelly
4dd6592aad Keep a stack of frames in the VM. 2019-02-27 10:47:33 +00:00
Windel Bouwman
6c8584cc11 Merge pull request #564 from alexpantyukhin/int_shifts
add overflow errors for int shifts.
2019-02-27 10:55:19 +01:00
alexpantyukhin
70ad78eb21 fix error messages. 2019-02-27 13:22:27 +04:00
Windel Bouwman
9404c7c657 Merge pull request #548 from rickyhan/new_vm_fns
Move set_item to DictProtocol
2019-02-27 09:40:12 +01:00
Windel Bouwman
d5976e2f83 Merge pull request #563 from coolreader18/demo-bits-and-bobs
Quality of life improvements for the demo.
2019-02-27 09:26:46 +01:00
Windel Bouwman
9a36951428 Merge pull request #559 from adrian17/list_sort
Add list.sort, sorted()
2019-02-27 09:24:22 +01:00
Windel Bouwman
28d5acc25c Merge pull request #552 from AaronRocinante/lexer_handle_random_byte
add lexer error
2019-02-27 08:13:19 +01:00
alexpantyukhin
15e6187583 add overflow errors for int shifts. 2019-02-27 11:11:38 +04:00
Windel Bouwman
f8e96394b7 Merge pull request #561 from rickyhan/rustfmt
Rustfmt
2019-02-27 08:11:33 +01:00
coolreader18
179304bc93 Update WASM example crate/app 2019-02-26 23:48:23 -06:00
coolreader18
c4513a176b Proper error handling for int to animationFrame id 2019-02-26 22:20:28 -06:00
coolreader18
b82e829c1f newline 2019-02-26 21:27:30 -06:00
coolreader18
717392c3c5 Scroll to the bottom of the demo when it gets updated 2019-02-26 21:21:43 -06:00
coolreader18
3df8f1c788 Update the snippet on page load; insert spaces when tab is pressed 2019-02-26 20:55:23 -06:00
coolreader18
1d193e7fc7 Convert between JS Promises and PyPromises 2019-02-26 20:37:59 -06:00
coolreader18
ba1c5d78aa Add a Promise class to the browser module 2019-02-26 20:28:25 -06:00
ricky han
21ebb03242 rust fmt 2019-02-26 18:38:16 -05:00
ricky han
ec93c55e6d rustfmt 2019-02-26 18:37:40 -05:00
ricky han
233f5d42fb Merge branch 'rustfmt' into new_vm_fns 2019-02-26 18:33:58 -05:00
ricky han
d5f0e25686 add rustfmt.toml 2019-02-26 18:32:27 -05:00
ricky han
30145ec6e2 cargo fmt 2019-02-26 17:47:03 -05:00
ricky han
830cc7e990 revert macro 2019-02-26 17:46:06 -05:00
ricky han
0a2aa1e64b fix compile 2019-02-26 17:39:56 -05:00
Ricky Han
0722487d16 Merge pull request #1 from RustPython/master
upstream
2019-02-26 17:21:57 -05:00
Windel Bouwman
d6242ac6e3 Use py_module macro on ast module. 2019-02-26 22:27:59 +01:00
Adrian Wielgosik
45da6b8af1 Add list.sort, sorted() 2019-02-26 22:03:45 +01:00
Aaron
267934bb49 fmt 2019-02-26 12:50:18 -08:00
Windel Bouwman
f2e60b24e1 Add initial platform module. 2019-02-26 21:42:38 +01:00
Windel Bouwman
a6341d3ec8 Merge pull request #558 from silmeth/io-import
fix io module being initialized multiple times
2019-02-26 21:03:47 +01:00
silmeth
5949a9bd13 fix io module being imported multiple times 2019-02-26 20:23:43 +01:00
Windel Bouwman
c33abe91e9 Use py_module macro at more places. 2019-02-26 19:53:58 +01:00
Windel Bouwman
2fc53a9440 Merge pull request #539 from coolreader18/wasm-browser-req_anim_frame
[WASM] Add requestAnimationFrame to browser module
2019-02-26 19:28:18 +01:00
Windel Bouwman
aa48718d0a Merge pull request #549 from coolreader18/rust-value-payload
Add AnyRustValue payload variant
2019-02-26 17:26:44 +01:00
Windel Bouwman
82e2ba19ab Merge pull request #550 from coolreader18/remove-console_error-crate
Remove the console_error_panic_hook crate from Cargo.toml
2019-02-26 17:23:55 +01:00
Windel Bouwman
53f54e4d76 Merge pull request #546 from rickyhan/master
Use closure instead of function pointer for StdlibInitFunc
2019-02-26 17:21:59 +01:00
Windel Bouwman
f8b9d19ccc Merge pull request #553 from RustPython/joey/refcell-in-payload
Remove outer RefCell from PyObjectRef
2019-02-26 17:18:59 +01:00
Windel Bouwman
c3309ee867 Merge pull request #555 from RustPython/dis_dis
Dis dis
2019-02-26 17:07:41 +01:00
Ricky Han
53eff6c9d7 revert 2019-02-26 05:11:38 -05:00
Adam Kelly
73a65a1c77 dis.rs - small refactor dis_dis. 2019-02-26 09:41:39 +00:00
Adam Kelly
79f43ad762 Add support for pulling __code__ out of a function (and a test that hits lots of instructions). 2019-02-26 09:41:39 +00:00
Adam Kelly
2c0016a171 Minimal definition of dis.dis. 2019-02-26 09:41:39 +00:00
Aaron
b1088c629c fmt 2019-02-26 00:55:16 -08:00
Joey Hain
b8eb4c38e8 Fix wasm 2019-02-25 23:10:06 -08:00
Joey Hain
bd3630260a fix socket 2019-02-25 22:22:45 -08:00
Joey Hain
3dcbc4d2aa Fix set 2019-02-25 22:20:15 -08:00
Ricky Han
138de0dfcd fix build error 2019-02-26 01:15:41 -05:00
Ricky Han
baf3fe4bec fix build error 2019-02-26 01:15:09 -05:00
Joey Hain
92fd12c9bd Fix scope 2019-02-25 22:07:08 -08:00
Joey Hain
d3646925ea Fix float() 2019-02-25 21:57:37 -08:00
Joey Hain
b28b164d75 Fix generators 2019-02-25 21:35:59 -08:00
Ricky Han
432b9dffaf cargo fmt 2019-02-26 00:34:40 -05:00
Ricky Han
93a6b4fef9 reverse kwargs order 2019-02-26 00:32:19 -05:00
Joey
587f871396 Merge pull request #542 from AaronRocinante/invalid_control_ret_yield
fix invalid break continue return yield
2019-02-25 21:28:17 -08:00
Joey Hain
e959908a49 Fix iterator 2019-02-25 21:26:15 -08:00
Aaron
b0bf93e530 add lexer error 2019-02-25 21:13:18 -08:00
Ricky Han
3fc583813a fix macro 2019-02-26 00:05:41 -05:00
Joey Hain
f10fa6db44 Remove outer RefCell from PyObjectRef 2019-02-25 21:01:37 -08:00
Ricky Han
88028dd8c5 cargo fmt 2019-02-25 23:41:17 -05:00
Ricky Han
b1c97ec877 refactor macros 2019-02-25 23:36:32 -05:00
Aaron
fee6a47d88 rever new_label() 2019-02-25 20:35:43 -08:00
Aaron
f037244641 fmt 2019-02-25 20:33:03 -08:00
Aaron
f965c49704 compiler flag in_function_def 2019-02-25 20:31:03 -08:00
coolreader18
d399faa425 Remove the console_error_panic_hook crate from Cargo.toml 2019-02-25 20:50:53 -06:00
coolreader18
dbfd0d4ade Fix "not all variants covered" error 2019-02-25 20:05:41 -06:00
coolreader18
dfa5e12b3c Add AnyRustValue payload variant 2019-02-25 19:22:16 -06:00
coolreader18
9066c73814 Try to trigger a successful Azure Pipelines build 2019-02-25 19:09:26 -06:00
Ricky Han
6f85a44f7c cargo fmt 2019-02-25 16:35:19 -05:00
Ricky Han
6752f67292 cargo fmt 2019-02-25 16:34:55 -05:00
Ricky Han
cf400501a1 move set_item to DictProtocol 2019-02-25 16:32:50 -05:00
Ricky Han
943ded07bd fix wasm 2019-02-25 15:23:40 -05:00
Ricky Han
293ffc072c merge upstream 2019-02-25 14:54:10 -05:00
Ricky Han
985e35bb16 use closure instead of function pointer 2019-02-25 14:49:20 -05:00
Aaron
4a7d2cb010 reset in_loop in class definition block 2019-02-25 09:42:02 -08:00
Aaron
2f0f1b0913 use boolean flag 2019-02-25 09:32:58 -08:00
Aaron
7610d44865 cargo fmt 2019-02-25 00:26:06 -08:00
Aaron
e9b0454f1c fix invalid break continue return yield 2019-02-25 00:12:15 -08:00
Windel Bouwman
027a6847e5 Merge pull request #525 from RustPython/joey/extractor-pattern
Use "extractor" pattern for native functions
2019-02-25 07:22:00 +01:00
Windel Bouwman
9e03b6908c Merge pull request #538 from RustPython/joey/f-string-conversion-flags
Support f-string conversion flags
2019-02-25 07:21:09 +01:00
Windel Bouwman
22928be01a Merge pull request #537 from coolreader18/wasm-fix-select
[WASM] Fix snippet selector's default selection
2019-02-25 07:14:01 +01:00
Windel Bouwman
2d1b45162d Merge pull request #529 from palaviv/socket
socket module
2019-02-25 07:11:32 +01:00
Joey Hain
f050acba73 f-strings: allow ':' and '!' to be used in the expression 2019-02-24 21:13:08 -08:00
coolreader18
1646b53c72 Add a comment explaining the weird dict 2019-02-24 21:28:25 -06:00
coolreader18
5dd2de0b1e Add requestAnimationFrame to browser module 2019-02-24 21:13:51 -06:00
Joey Hain
ddc154a1dd f-strings: support conversion flags 2019-02-24 14:37:59 -08:00
Joey Hain
d6e317b185 Move f-string parser into own module and clean up a bit 2019-02-24 13:01:25 -08:00
coolreader18
f2079807bd Fix snippet selector's default selection 2019-02-24 14:22:18 -06:00
Aviv Palivoda
c87cf90043 Add socket test 2019-02-24 22:20:20 +02:00
Aviv Palivoda
1322c8d6db Change socket parameters to match CPython 2019-02-24 22:20:07 +02:00
Aviv Palivoda
c84d35126e Add socket.{bind,listen,accept} 2019-02-24 21:35:47 +02:00
Aviv Palivoda
49837f57a7 Use Connection enum 2019-02-24 20:43:24 +02:00
Aviv Palivoda
8186c77eb2 Initial socket module 2019-02-24 20:43:24 +02:00
Joey
205bfb762d Merge pull request #532 from coolreader18/wasm-better-panic
[WASM] Make panic errors available from JS
2019-02-24 10:05:20 -08:00
coolreader18
9a7bb315e2 Merge branch 'master' into wasm-better-panic 2019-02-24 09:09:09 -06:00
Windel Bouwman
098675dfe1 Merge pull request #531 from coolreader18/wasm-fetch-builtin
[WASM] Add a `browser` module
2019-02-24 11:13:40 +01:00
Joey
cbcf7c3e75 Merge pull request #534 from AdamGS/new_float_attributes
Addred real property and is_integer function to float.
2019-02-23 22:19:37 -08:00
Joey Hain
2919d7f520 Initial arg type checking 2019-02-23 19:27:22 -08:00
Joey Hain
fb0384d24d Some prerequisite data types for arg checking 2019-02-23 18:16:24 -08:00
Joey Hain
a74cbbbe19 Impl PyNativeFuncFactory for up to 5-tuples 2019-02-23 18:16:18 -08:00
Joey Hain
c14a8302e8 Initial prototype of "extractor pattern" for native funcs 2019-02-23 18:16:02 -08:00
Adam Gutglick
f4e6e5dec8 Addred real property and is_integer function to float. 2019-02-24 04:02:24 +02:00
coolreader18
9d99f94a3f Add! 2019-02-23 16:21:10 -06:00
coolreader18
2b9adfea8a Add fetch demo snippet 2019-02-23 15:25:12 -06:00
coolreader18
7f626b50b9 Merge branch 'master' into wasm-fetch-builtin 2019-02-23 15:20:59 -06:00
Windel Bouwman
d44f1b3e29 Merge pull request #528 from coolreader18/multiple-demo-snippets
Allow for different demo snippets to be selected
2019-02-23 22:15:00 +01:00
coolreader18
ff66bb602e Follow clippy's advice 2019-02-23 15:05:52 -06:00
coolreader18
878c131af4 Make panic errors available and display them nicely for the demo 2019-02-23 14:52:02 -06:00
coolreader18
fd184a1e68 Add a WASM browser module with fetch() available 2019-02-23 13:58:19 -06:00
coolreader18
5a472e46aa Merge branch 'master' into wasm-fetch-builtin 2019-02-23 12:28:17 -06:00
coolreader18
6e8b88e1fd Add mandelbrot snippet 2019-02-23 11:05:51 -06:00
coolreader18
b89d95c4c6 Add fizzbuzz demo 2019-02-23 10:50:07 -06:00
coolreader18
4dde810e9c Move snippets directory 2019-02-23 10:22:36 -06:00
coolreader18
d02e8352ea Allow for multiple demo snippets to be selected 2019-02-23 09:17:00 -06:00
Windel Bouwman
c675a59288 Merge pull request #526 from palaviv/assertRaises
Add assertRaises context manager to testutils
2019-02-23 13:35:19 +01:00
Aviv Palivoda
b530733c1a Add assertRaises context manager to testutils 2019-02-23 13:11:26 +02:00
Windel Bouwman
7032de96d7 Merge pull request #311 from nhynes/compile-wasm
Allow compiling VM for wasm32-unknown-unknown
2019-02-23 10:42:09 +01:00
Windel Bouwman
b15ade1130 Merge pull request #267 from coolreader18/wasm-vm-class
Add a VirtualMachine class to the WASM library
2019-02-23 10:36:23 +01:00
Windel Bouwman
3f8f0e2ff4 Merge pull request #524 from palaviv/Improve-set-5
Add set.{__iter__,__ior__,__iand__,__isub__,__ixor__}
2019-02-23 08:50:26 +01:00
coolreader18
e0f222cf4f Don't hold on to a PyObjectRef from a python -> js closure 2019-02-23 00:20:15 -06:00
coolreader18
09e2a7a493 Add js_name for .set_stdout() 2019-02-23 00:02:12 -06:00
coolreader18
7fa0a0cee3 Fix open in new make_module 2019-02-22 22:59:15 -06:00
coolreader18
955d0b3a91 Merge branch 'master' into wasm-vm-class 2019-02-22 22:53:34 -06:00
coolreader18
65857e7261 Merge 2019-02-22 22:20:05 -06:00
Windel Bouwman
2d19486192 Merge pull request #520 from RustPython/py_module
Py module
2019-02-22 17:20:27 +01:00
Joey
2df741452b Merge pull request #523 from AdamGS/complex_and_ints_addition
Complex and ints addition
2019-02-22 07:34:47 -08:00
Aviv Palivoda
fc10560308 Add set.{__ior__,__iand__,__isub__,__ixor__} 2019-02-22 16:50:40 +02:00
Aviv Palivoda
7cf25440fa Add set.__iter__ 2019-02-22 16:25:55 +02:00
Adam Gutglick
f333c75fd6 Added the ability to do addition between complex numbers and ints. 2019-02-22 08:42:44 -05:00
coolreader18
9e176902b9 Use crate:: imports 2019-02-21 23:25:05 -06:00
Joey
c22fb58437 Merge pull request #521 from chapeupreto/patch-1
fix typos
2019-02-21 19:06:47 -08:00
Rod Elias
b518867220 fix typos 2019-02-21 23:41:43 -03:00
Adam Gutglick
38b4c10833 Added the ability to do addition between complex numbers and ints. 2019-02-21 19:28:46 -05:00
Joey
8f37b9f443 Merge pull request #519 from AdamGS/testutil_back_comp
Backwards compitability for python 3.5 to run tests.
2019-02-21 14:31:03 -08:00
Adam Kelly
0cbcc70359 builtins - use py_module. 2019-02-21 21:14:08 +00:00
Adam Kelly
2ab90b234a Fix unused variable warning in objint. 2019-02-21 21:05:46 +00:00
Adam Kelly
2c97a50e6e sys - use py_module. 2019-02-21 21:05:00 +00:00
Adam Kelly
d420c7f400 dis - use py_module. 2019-02-21 21:04:42 +00:00
Adam Gutglick
999ca431d5 Fixed typo. 2019-02-21 16:03:07 -05:00
Adam Gutglick
365680c272 Changed to syntax RustPython supports. 2019-02-21 15:55:18 -05:00
Windel Bouwman
7dd1eec936 Merge pull request #517 from palaviv/set-more-funcs
Add set.{pop,update,intersection_update,difference_update,symmetric_difference_update}
2019-02-21 20:53:41 +01:00
Windel Bouwman
565023f55b Merge pull request #518 from AdamGS/add_int_attributes
Added real/imag attributes to int type.
2019-02-21 20:52:06 +01:00
Windel Bouwman
5bd2db817f Merge pull request #516 from RustPython/joey/argcheck-objtype
Don't require objtype import to use arg_check! macro
2019-02-21 20:49:14 +01:00
Adam Gutglick
81a9e6984d Changed syntax in testutils.py that is introduced in 3.6 to a backwards compatible version. 2019-02-21 14:47:36 -05:00
Windel Bouwman
2c1afc4ef0 Merge pull request #513 from RustPython/py_module_macro
Py module macro
2019-02-21 20:47:35 +01:00
Windel Bouwman
1d3db316da Merge pull request #512 from RustPython/mod_dis
Mod dis
2019-02-21 20:44:27 +01:00
Windel Bouwman
7dfd8f0ebc Merge pull request #515 from RustPython/joey/compile-error-cleanup
Compile error message cleanup
2019-02-21 20:41:01 +01:00
Adam Gutglick
852dd1086a Added tests to imag/real attributes. 2019-02-21 14:11:23 -05:00
Adam Gutglick
0c1057f079 Added real/imag attributes to int type. 2019-02-21 13:46:18 -05:00
Aviv Palivoda
21b6616e8e Add set.symmetric_difference_update 2019-02-21 19:33:20 +02:00
Aviv Palivoda
1621d78326 Add set.difference_update 2019-02-21 19:02:05 +02:00
Aviv Palivoda
a4b814e9a7 Add set.intersection_update 2019-02-21 18:55:22 +02:00
Joey
eec76ef8e8 Don't require objtype import to use arg_check! macro 2019-02-21 08:38:02 -08:00
Aviv Palivoda
5f3664e87d Add set.update 2019-02-21 18:34:47 +02:00
Aviv Palivoda
a89b0593da Add set.pop 2019-02-21 18:34:47 +02:00
Joey
7e40b7f648 Compile error message cleanup 2019-02-21 08:27:35 -08:00
Adam
e2ee933256 Merge pull request #514 from RustPython/joey/crate-imports
Replace most relative imports with 2018-style crate imports
2019-02-21 15:29:38 +00:00
Adam Kelly
55148d7d5a Use py_module for random. 2019-02-21 14:06:57 +00:00
Adam Kelly
727b895930 Use py_module for math. 2019-02-21 14:06:57 +00:00
Adam Kelly
0175780cc3 py_module macro to make modules definitions more declarative. 2019-02-21 14:06:57 +00:00
Adam Kelly
5ebfd55b20 Add extremely minimal dis module. 2019-02-21 14:02:59 +00:00
Adam Kelly
4b03e6d706 Add Display implementation for CodeObject. 2019-02-21 14:02:59 +00:00
coolreader18
8c222af65b Include details about thread_local! for WASM 2019-02-20 22:33:52 -06:00
Joey
dc3a44f513 Merge pull request #502 from janczer/add_bytearray_lower_upper
Add bytearray.{lower, upper}
2019-02-20 15:49:50 -08:00
janczer
b833c08951 Add bytearray.{lower, upper} 2019-02-20 19:35:39 +01:00
Joey
df76ffe116 Replace most relative imports with 2018-style crate 2019-02-20 08:50:53 -08:00
Windel Bouwman
e058179b04 Merge pull request #458 from ZapAnton/2018_edition
Migrated the project to the Rust 2018 edition
2019-02-20 16:44:31 +01:00
Windel Bouwman
a2ff87b9d7 Merge pull request #506 from janczer/add_check_byte_value
Add checking if value more then 255 in bytearraya
2019-02-20 16:14:09 +01:00
Windel Bouwman
b7dfbebd2d Merge pull request #500 from crw5996/break-continue-fix
Break continue fix
2019-02-20 16:12:57 +01:00
Windel Bouwman
32daf638dc Merge pull request #507 from rmliddle/develop
Readme Update + Inheritance Fix on IO
2019-02-20 16:05:39 +01:00
Joey
b8cb9f73c5 Merge branch 'master' into add_check_byte_value 2019-02-20 06:40:58 -08:00
Joey
f588f58dd1 Merge pull request #503 from janczer/add_pop_bytearray
Add pop to bytearray
2019-02-20 06:33:10 -08:00
rmliddle
6be7623a94 Spelling Fix 2019-02-20 21:36:56 +11:00
Ryan Liddle
3bb00fa5db Merge pull request #505 from RustPython/fix-continue
Fix continue statement
2019-02-20 21:10:45 +11:00
rmliddle
2ad4dddd16 README Update 2019-02-20 21:00:50 +11:00
janczer
51f6ec2325 Add checking if value more then 255 in bytearraya 2019-02-20 07:10:42 +01:00
janczer
24176f7bbb Add more test for bytearray.pop and fix the panic message 2019-02-20 06:58:43 +01:00
janczer
bfdb82b5c1 Add pop to bytearray 2019-02-20 06:50:33 +01:00
Joey
9face190ab Fix continue statement 2019-02-19 19:40:34 -08:00
Joey
53bcd04f8a Merge pull request #499 from RustPython/break-from-nested-for-loops
Fix infinite loop when breaking from nested for loop
2019-02-19 18:33:11 -08:00
Joey
7c06cedf48 Merge pull request #504 from palaviv/fix-key-error
Add KeyError to builtins
2019-02-19 18:24:00 -08:00
chris
9092d1f30b Updated to fix corner case with inner function 2019-02-19 21:11:50 -05:00
chris
d3280429db Merge branch 'break-continue-fix' of https://github.com/crw5996/RustPython into break-continue-fix 2019-02-19 21:03:15 -05:00
chris
5b86b918f1 q!
Merge branch 'master' of https://github.com/RustPython/RustPython into break-continue-fix
2019-02-19 20:47:49 -05:00
coolreader18
8e5073e524 Convert bytes and bytearrays to Uint8Arrays 2019-02-19 17:58:57 -06:00
Joey
cd8c1efb6b Merge pull request #494 from janczer/add_clear_dict_bytes
Add dict.clear and bytes.clear
2019-02-19 15:46:32 -08:00
Chris Wood
a451e4a5b3 Hopefully fixed rustfmt issues 2019-02-19 14:48:23 -05:00
Aviv Palivoda
218cec98cb Add KeyError to builtins 2019-02-19 21:38:39 +02:00
janczer
2963dd5b66 Change error to panic in bytearray.clear 2019-02-19 20:38:38 +01:00
Windel Bouwman
ac95b61e3e Merge pull request #496 from adrian17/arg_check_comments
Document arg_check! macro a bit
2019-02-19 17:42:47 +01:00
rmliddle
724d9c6dcb Fixed Inheritance on String & BytesIO to reflect CPython 2019-02-19 20:41:43 +11:00
chris
6229efca24 Updated Compilation phase to detect whether or not we are currently inside of a loop or not. This is useful to determine whether or not we can use looping specific keywords such as break or continue. 2019-02-19 02:19:14 -05:00
chris
0cc898e19d Updated Compilation phase to detect whether or not we are currently inside of a loop or not. This is useful to determine whether or not we can use looping specific keywords such as break or continue. 2019-02-19 02:18:52 -05:00
janczer
d5c91a8de0 Move clear method from bytes to bytearray 2019-02-19 07:11:13 +01:00
Joey Hain
7965a63ba9 Fix infinite loop when breaking from nested for loop 2019-02-18 18:07:35 -08:00
coolreader18
d716313283 Add content_type option to headers 2019-02-18 15:54:06 -06:00
coolreader18
92a3733541 Add body option to fetch 2019-02-18 15:38:12 -06:00
coolreader18
4edca2121d Convert some fetch options to kwargs, add PyFuncArgs method 2019-02-18 15:25:52 -06:00
Adrian Wielgosik
e016b68552 Document arg_check! macro a bit 2019-02-18 19:59:28 +01:00
coolreader18
9c0bcc2bd7 Re-add WASM fetch builtin 2019-02-18 12:18:53 -06:00
coolreader18
634571fd2e Remove WASM fetch builtin 2019-02-18 12:16:43 -06:00
janczer
58369b6fbc Delete unnessesary code from dict.clear 2019-02-18 18:45:49 +01:00
janczer
85110f6fbf Add dict.clear and bytes.clear 2019-02-18 18:21:39 +01:00
Windel Bouwman
fcea8455fa Merge pull request #473 from janczer/add_list_copy
Add copy method to set object
2019-02-18 10:50:20 +01:00
Windel Bouwman
16832c8f8c Merge pull request #479 from calixteman/fix_equality
Fix issue with equality
2019-02-18 10:49:36 +01:00
Windel Bouwman
43d9fc5dc0 Merge branch 'master' into fix_equality 2019-02-18 08:12:12 +01:00
Windel Bouwman
a47e979f29 Merge branch 'master' into add_list_copy 2019-02-18 08:08:31 +01:00
Windel Bouwman
70d5cdbe3e Merge pull request #492 from OddCoincidence/inplace-ops
Support magic methods for in-place operations
2019-02-18 08:05:59 +01:00
Windel Bouwman
71f32ee9b0 Merge pull request #491 from calixteman/fix_ccov_badge
Fix typo in codecov.io badge
2019-02-18 07:58:32 +01:00
coolreader18
0d3d09072e Convert pyEval to use a WASM VM, allowing closures and stuff
Like variables carried across executions
2019-02-18 00:37:00 -06:00
Joey Hain
ddc7da4a9d Add test for in-place ops 2019-02-17 18:17:26 -08:00
Joey Hain
afabde26d5 coverage: try deleting old gcda files 2019-02-17 17:18:47 -08:00
coolreader18
101ee77dcc Improve error messages 2019-02-17 18:25:14 -06:00
coolreader18
74e713197a Clean up some code 2019-02-17 18:22:11 -06:00
Joey Hain
7abaea556a Micro-optimize list.__iadd__ 2019-02-17 14:30:38 -08:00
coolreader18
524470789f Add eval() method, rename run() to exec() 2019-02-17 13:19:19 -06:00
Joey Hain
dcb29ab1f0 Add list.__iadd__ 2019-02-17 10:54:25 -08:00
Joey Hain
b310d5e24b Use i-methods for in-place operations 2019-02-17 10:47:58 -08:00
coolreader18
bead3f67d0 Fix conversion from ArrayBuffer, allow array_buffer in fetch 2019-02-17 11:50:05 -06:00
Joey Hain
fe3f45f655 Implement remaining binop reverse fallbacks 2019-02-17 09:26:31 -08:00
coolreader18
416f088b32 Convert ArrayBuffers and TypedArrays to Python bytearrays 2019-02-17 11:22:29 -06:00
Calixte Denizet
b61730972e Fix typo in codecov.io badge 2019-02-17 17:07:49 +01:00
coolreader18
b043f2199f Fix js_py_typeerror 2019-02-17 09:14:06 -06:00
coolreader18
7405c842c8 Add some more options to fetch() 2019-02-17 08:49:19 -06:00
coolreader18
d0b4751ab2 Remove the VM pointer from the map when it's dropped 2019-02-17 08:08:22 -06:00
coolreader18
00bc9e9199 Convert fetch to use wasm_bindgen_futures 2019-02-17 01:12:38 -06:00
Windel Bouwman
1af9cc0173 Merge pull request #489 from OddCoincidence/decorator-paths
Allow attributes to be used as decorators
2019-02-17 08:01:25 +01:00
Windel Bouwman
cb2a807994 Merge pull request #486 from OddCoincidence/assert-raises
Reuse and improve ergonomics of assert_raises utility
2019-02-17 07:59:34 +01:00
Windel Bouwman
9d218bf806 Merge pull request #485 from calixteman/ccov
Code coverage for RustPython
2019-02-17 07:56:58 +01:00
Windel Bouwman
a92f4bbecc Merge pull request #487 from liranringel/azure-pipelines
Add Windows CI via Azure Pipelines
2019-02-17 07:54:31 +01:00
coolreader18
f00c3c8a7b Fix fetch builtin 2019-02-17 00:24:58 -06:00
coolreader18
a86069d9f2 Store the WASM id in the VirtualMachine, add a (broken) fetch builtin 2019-02-16 23:41:41 -06:00
coolreader18
3e22c4f146 Add print to default vm scope 2019-02-16 21:43:51 -06:00
Joey Hain
114d9df1d1 Allow attributes to be used as decorators 2019-02-16 19:43:25 -08:00
coolreader18
c83ff47f3a Fix error with new compile() and set_attr/item() 2019-02-16 21:31:10 -06:00
coolreader18
f55a8ead68 Merge branch 'master' into wasm-vm-class 2019-02-16 20:23:35 -06:00
coolreader18
6851767654 Fix RefCell borrowing errors 2019-02-16 20:18:27 -06:00
Calixte Denizet
6d646cc38e Add a codecov badge 2019-02-16 18:33:45 +01:00
Joey Hain
47e95486f0 Reuse and improve ergonomics of assert_raises utility
- Move assert_raises to testutils
- Add optional message argument, with reasonable default
- Reverse order of expr and exception type for readability
- Lambda argument no longer takes parameter
- Convert applicable snippets to use assert_raises
2019-02-16 09:32:42 -08:00
Liran Ringel
9b7160800b Fix os_info.py to pass on windows 2019-02-16 19:23:33 +02:00
Calixte Denizet
e86e108e67 Don't run tests in --release with code coverage 2019-02-16 18:19:52 +01:00
Liran Ringel
2554174697 Set up CI with Azure Pipelines 2019-02-16 18:34:45 +02:00
Calixte Denizet
31c5b5ed3d Workaround issue with grcov 2019-02-16 17:30:05 +01:00
Calixte Denizet
ce541a1ca5 Remove parenthesis 2019-02-16 15:55:41 +01:00
Calixte Denizet
1e3c2fbf18 Try again 2019-02-16 15:28:43 +01:00
Calixte Denizet
90184bcb90 Code coverage for RustPython 2019-02-16 14:54:29 +01:00
Calixte Denizet
5a154f9745 Fix list & tuple equality 2019-02-16 14:23:20 +01:00
Calixte Denizet
93c184a745 Fix fmt 2019-02-16 13:25:13 +01:00
Calixte Denizet
dd6b5b9aae Fix list_eq 2019-02-16 13:15:58 +01:00
Calixte Denizet
117c6c8494 Fix list_remove 2019-02-16 13:00:39 +01:00
Calixte Denizet
5d82e2c6b5 Fix equality check in list_count, list_index and list_contains 2019-02-16 12:45:57 +01:00
Calixte Denizet
bf19d652dc Fix issue with equality 2019-02-16 12:45:57 +01:00
Windel Bouwman
159daf061a Change scope from using set_item to set_attr. 2019-02-16 11:18:55 +01:00
Windel Bouwman
163a1311f7 Merge pull request #470 from janczer/add_remove_list
Add remvoe to list object
2019-02-16 10:27:27 +01:00
Windel Bouwman
26f9a7fe1a Merge pull request #483 from OddCoincidence/f-string-format-specs
Support format specs in f-strings
2019-02-16 08:35:21 +01:00
Windel Bouwman
eb55d20b4a Merge pull request #480 from janczer/fix_clippy_issues
Remove return, use function without closure
2019-02-16 08:31:26 +01:00
Windel Bouwman
ec6dc7ca4a Merge pull request #481 from evilpie/discard
implement set.discard
2019-02-16 08:30:57 +01:00
Windel Bouwman
0a70852b3f Merge pull request #478 from silmeth/int-division
big Integers division
2019-02-16 08:22:29 +01:00
Joey Hain
134c3b94a5 support format specs in f-strings 2019-02-15 18:18:44 -08:00
Joey Hain
5968c4d922 convert f-string parser to state machine 2019-02-15 18:14:33 -08:00
Ryan Liddle
7364866a8a Merge pull request #477 from RustPython/dict7
Remove support for module get_item
2019-02-16 11:11:52 +11:00
Tom Schuster
4762d654b4 implement set.discard 2019-02-15 20:46:00 +01:00
janczer
b9daabfc94 Remove return, use function without closure 2019-02-15 20:43:20 +01:00
janczer
c1f6d16079 Change iterator to for loop 2019-02-15 20:33:41 +01:00
silmeth
4a67bb9797 stop dividing the divisor if the remainder already disappeared 2019-02-15 20:08:28 +01:00
janczer
4726d6b8b0 Remove unwrap methods 2019-02-15 20:01:02 +01:00
silmeth
4cfd3a1cd0 get rid of unnecessary muts in objint::div_ints 2019-02-15 19:50:25 +01:00
janczer
1e92bb892e Fix fmt in set.copy 2019-02-15 19:48:48 +01:00
janczer
f45f307a55 Add copy method to list object 2019-02-15 19:48:48 +01:00
silmeth
8ed82a089f make big ints dividable if the result fits in a float 2019-02-15 19:43:00 +01:00
silmeth
0c626dd595 rename objstr::get_value_as_ref to objstr::borrow_value 2019-02-15 19:29:58 +01:00
Windel Bouwman
0c351ea76d Remove support for module get_item 2019-02-15 17:30:28 +01:00
Windel Bouwman
2d22a882ae Merge pull request #475 from palaviv/Add-set-funcs3
Add set.{union,intersection,difference,symmetric_difference}
2019-02-15 17:08:10 +01:00
Windel Bouwman
b785960a25 Merge pull request #461 from adrian17/arg_check_refactor
Refactor arg_check macro
2019-02-15 16:59:09 +01:00
janczer
9e719b6cb8 Move test to list.py 2019-02-15 16:53:36 +01:00
Windel Bouwman
a541b509a9 Merge branch 'master' into Add-set-funcs3 2019-02-15 16:53:10 +01:00
Windel Bouwman
1611aa42c1 Merge pull request #476 from palaviv/set-unhashable
set raises TypeError when unhashable element is passed in creation
2019-02-15 16:50:05 +01:00
Aviv Palivoda
412df7472f set raises TypeError when unhashable element is passed in creation 2019-02-15 15:34:55 +02:00
Aviv Palivoda
49e10ed497 Add set.symmetric_difference 2019-02-15 15:13:05 +02:00
Aviv Palivoda
938688cb69 Add set.difference 2019-02-15 15:13:05 +02:00
Aviv Palivoda
23ef487927 Add set.intersection 2019-02-15 15:13:05 +02:00
Aviv Palivoda
83c4eda62c Add set.union 2019-02-15 15:13:05 +02:00
janczer
2ac195e539 List remove, handle non exist element. Add new test 2019-02-15 08:49:58 +01:00
Windel Bouwman
48032a5110 Merge pull request #472 from OddCoincidence/int-float-rarithmetic
Add {int,float}.{__radd__,__rsub__,__rmul__,__rtruediv__}
2019-02-15 07:14:01 +01:00
Windel Bouwman
a2d4924909 Merge pull request #469 from janczer/fix_typos
Fix typos
2019-02-15 07:03:04 +01:00
Windel Bouwman
ddbd7d759f Merge pull request #471 from OddCoincidence/fstring-fixes-and-tests
Fix f-string edge case and add more tests
2019-02-15 07:02:27 +01:00
Joey Hain
c6ac393f84 Add {int,float}.{__radd__,__rsub__,__rmul__,__rtruediv__} 2019-02-14 21:21:30 -08:00
Joey Hain
fb4d55bd8f Fix f-string edge case and add more tests 2019-02-14 18:46:23 -08:00
janczer
358f9f764b Add remvoe to list object 2019-02-14 21:18:38 +01:00
janczer
89e947a04f Fix typos 2019-02-14 20:38:18 +01:00
Windel Bouwman
d76c86ed16 Merge pull request #468 from janczer/add_complex_real_imag
Add complex methods real and imag
2019-02-14 17:59:40 +01:00
janczer
2a2ddff14e Add complex methods real and imag 2019-02-14 16:56:32 +01:00
Windel Bouwman
518b37185e Merge pull request #466 from OddCoincidence/fstrings
Initial support for f-strings (i.e. strings with interpolated expressions)
2019-02-14 12:22:27 +01:00
ZapAnton
f1654cb890 Migrated the project to the Rust 2018 edition 2019-02-14 12:02:32 +03:00
Joey Hain
bc4e48ae61 Fix tests 2019-02-13 23:32:55 -08:00
Joey Hain
4ca3d3b507 Merge remote-tracking branch 'upstream/master' into fstrings 2019-02-13 23:16:40 -08:00
Joey Hain
a97e05a164 Add missing semicolon to Bytes rule 2019-02-13 23:11:54 -08:00
Joey Hain
7d743de43f fix another edge case 2019-02-13 22:28:16 -08:00
Windel Bouwman
33d272f795 Merge pull request #464 from holygits/internal-error-types
Introduce Parser and Compiler Errors
2019-02-14 07:07:21 +01:00
Joey Hain
400ad80b64 fstrings 2019-02-13 21:59:21 -08:00
holygits
570b28439a Fix tests 2019-02-14 12:31:20 +13:00
Nick Hynes
ae8dc46947 Allow compiling VM for wasm32-unknown-unknown 2019-02-13 23:22:03 +00:00
holygits
995fac12fd Remove stray file 2019-02-14 11:10:27 +13:00
Windel Bouwman
d048d0a0da Merge pull request #445 from RustPython/co_consts
Co consts
2019-02-13 22:59:53 +01:00
Windel Bouwman
116f5daae4 Merge pull request #450 from silmeth/microopt-print
Fix crashes on wrong kwargs types to print + microoptimize it
2019-02-13 22:59:07 +01:00
Windel Bouwman
a8873dbaff Merge pull request #460 from janczer/add_clear_method_set
Add clear method to set
2019-02-13 22:51:18 +01:00
holygits
f0d7c2bea9 Fix test 2019-02-14 10:46:48 +13:00
holygits
4453c3e561 Create error types for parser and compiler
Pass through locations and tokens in ParseError
2019-02-14 10:21:21 +13:00
Adam
b88b87f210 Merge pull request #462 from adrian17/lambda_parsing
Change lambda parsing to be closer to Python official grammar. Fixes #427
2019-02-13 20:44:55 +00:00
Adam
233242c3ad Merge pull request #429 from adrian17/master
Fix callable(), add tests.
2019-02-13 20:38:27 +00:00
Adrian Wielgosik
21299ecf3d Refactor arg_check macro 2019-02-13 21:05:23 +01:00
Adrian Wielgosik
7dfb0728fd Change lambda parsing to be closer to Python grammar. Fixes #427 2019-02-13 21:01:13 +01:00
janczer
b77165c5ad Fix fmt set.clear 2019-02-13 14:44:50 +01:00
janczer
d07b3dff98 Add clear method to set 2019-02-13 14:37:05 +01:00
Ryan Liddle
3d4fd5fc86 Merge pull request #456 from yuvipanda/os-name
Implement os.name
2019-02-13 19:35:32 +11:00
Ryan Liddle
c6c1e7f60e Merge pull request #453 from OddCoincidence/int-float-comparison
Fix int to float comparison
2019-02-13 19:31:00 +11:00
yuvipanda
252c3be5f8 Add newline to os_info test file 2019-02-13 00:01:06 -08:00
yuvipanda
9dc45fd728 Implement os.name 2019-02-12 23:51:36 -08:00
Windel Bouwman
392262d3f4 Merge pull request #454 from janczer/call_wrap_functions
Call wrap functions insted of magic
2019-02-13 07:05:26 +01:00
Windel Bouwman
db7a64fe5a Merge pull request #451 from adrian17/list_copy
Add list.copy()
2019-02-13 07:04:24 +01:00
Windel Bouwman
74c5d4dae1 Merge pull request #452 from matrizx/master
Replaced cluttered match statements with if let
2019-02-13 07:02:48 +01:00
Joey Hain
5fd912b13a Remove float comparisons from int.__eq__, add int.__ne__ 2019-02-12 21:56:25 -08:00
janczer
4959defff8 Call wrap functions insted of magic 2019-02-13 06:34:44 +01:00
Joey Hain
2041b7cef6 Fix int to float comparison 2019-02-12 18:44:03 -08:00
matrizx
c041c8cbc5 Replaced cluttered match statements with if let 2019-02-12 16:55:12 -08:00
Adrian Wielgosik
ecfc70ef99 Add list.copy() 2019-02-13 00:21:42 +01:00
silmeth
bd64869686 fix None kwargs to print in vm and in wasm_builtins 2019-02-12 23:17:17 +01:00
silmeth
a2ab4473a3 add tests of error handling for wrong types of print() kwargs 2019-02-12 22:33:54 +01:00
silmeth
3d17cc0aa1 copy print() kwargs handling over to wasm_builtins 2019-02-12 22:27:04 +01:00
silmeth
7b7aa13295 microoptimize print (lock stdout, borrow strings) 2019-02-12 22:25:46 +01:00
Adrian Wielgosik
a8f650b709 Fix callable(), add tests. 2019-02-12 19:26:10 +01:00
Windel Bouwman
e5af4caecf Merge pull request #424 from janczer/add_object_lt_le_gt_ge
Add object.{__lt__, __le__, __gt__, __gt__}
2019-02-12 19:21:07 +01:00
Windel Bouwman
de98ac696b Merge pull request #442 from OddCoincidence/float-parsing
Support float(<str>) and float(<bytes>)
2019-02-12 18:45:50 +01:00
janczer
9277e67b15 Add not_implemented to float.{__le__, __gt__, __ge__} 2019-02-12 18:32:26 +01:00
janczer
9601673044 Fix the reflections of methods lt, le, gt, ge 2019-02-12 18:20:04 +01:00
janczer
1ff1bcda6b Fix the call __gt__ 2019-02-12 17:56:11 +01:00
Windel Bouwman
17bde53ca3 Add end kwarg to print function. 2019-02-12 17:23:33 +01:00
Windel Bouwman
2645bfd47a Merge pull request #448 from ZapAnton/fix_clippy_warnings
Fixed several clippy warnings
2019-02-12 17:05:53 +01:00
Windel Bouwman
a75eea56ab Merge pull request #446 from RustPython/none_str
Add __repr__ and __new__ to NoneType.
2019-02-12 17:00:46 +01:00
janczer
0887b55da8 Add object.{__lt__, __le__, __gt__, __gt__} 2019-02-12 15:32:07 +01:00
ZapAnton
604883dc86 Fixed the len_zero clippy warning 2019-02-12 17:13:09 +03:00
ZapAnton
08d767b010 Fixed the unnecessary_mut_passed clippy warning 2019-02-12 17:12:11 +03:00
ZapAnton
e8467c3bfe Fixed the redundant_closure clippy warning 2019-02-12 17:10:53 +03:00
ZapAnton
a0f1f51863 Fixed the useless_asref clippy warnings 2019-02-12 17:09:52 +03:00
ZapAnton
ef65612008 Fixed the clone_double_ref clippy warning 2019-02-12 16:59:15 +03:00
ZapAnton
206ccc55fb Fixed the len_without_is_empty clippy warning 2019-02-12 16:49:34 +03:00
ZapAnton
38930984ec Fixed the redundant_pattern_matching clippy warning 2019-02-12 16:45:44 +03:00
ZapAnton
291dba6bb6 Fixed the toplevel_ref_arg clippy warning 2019-02-12 16:44:47 +03:00
ZapAnton
5fe373555f Fixed the match_bool clippy warning 2019-02-12 16:43:59 +03:00
ZapAnton
45b9ef9719 Fixed the op_ref clippy warnings 2019-02-12 16:42:53 +03:00
ZapAnton
050bf459b0 Fixed the into_iter_on_ref clippy warning 2019-02-12 16:40:08 +03:00
ZapAnton
9144109f7d Fixed the useless_vec clippy warning 2019-02-12 16:39:38 +03:00
ZapAnton
66569160fc Fixed the redundant_closure clippy warning 2019-02-12 16:38:15 +03:00
ZapAnton
8b6d0b3721 Fixed the op_ref clippy warning 2019-02-12 16:37:02 +03:00
ZapAnton
00cfa47f64 Fixed the should_implement_trait clippy warning 2019-02-12 16:35:28 +03:00
ZapAnton
606ddd2216 Fixed the needless_return clippy warnings 2019-02-12 16:30:03 +03:00
ZapAnton
0d1b85a8da Fixed the collapsible_if clippy warning 2019-02-12 16:28:49 +03:00
ZapAnton
d86ffc40f6 Fixed the redundant_field_names clippy warnings 2019-02-12 16:07:24 +03:00
Adam Kelly
a735bb3dfc Add __repr__ and __new__ to NoneType. 2019-02-12 10:09:13 +00:00
Adam Kelly
8a89e13a7e Add .co_consts to code class. 2019-02-12 09:47:02 +00:00
Adam Kelly
8cc2d5f091 Move implementation of CodeObject after Instructions. 2019-02-12 09:40:55 +00:00
Adam
8835b47d1f Merge pull request #444 from skinny121/object_format
Add object.__format__
2019-02-12 08:52:20 +00:00
ben
d14aeef2e5 Handle passing no format_spec into format() 2019-02-12 20:24:57 +13:00
ben
5c12367f59 Merge branch 'master' into object_format 2019-02-12 20:09:27 +13:00
ben
93e5634d39 Fixes #328, add object.__format__ 2019-02-12 20:06:50 +13:00
Windel Bouwman
9177252cf9 Merge pull request #259 from RustPython/list_insert
Implemented list.insert()
2019-02-12 06:10:20 +01:00
Windel Bouwman
d0d27babba Merge pull request #443 from OddCoincidence/fix-typo
Fix typo in VirtualMachine::_and
2019-02-12 06:06:31 +01:00
Joey Hain
beb75a4dd0 Fix typo in VirtualMachine::_and 2019-02-11 19:51:17 -08:00
Joey Hain
38c0ea06e5 Support float(<str>) and float(<bytes>) 2019-02-11 19:40:55 -08:00
Windel Bouwman
6f0ac744f2 Merge pull request #441 from RustPython/dont_call__eq__
Dont call  eq
2019-02-11 23:17:29 +01:00
Shing Lyu
d188f05ffc Fix errors introduced during rebasing 2019-02-11 22:59:08 +01:00
Shing Lyu
b265601c58 Use isize in list.insert instead of i64 2019-02-11 22:52:55 +01:00
Shing Lyu
3467db51d0 Simplify the number logic for list.insert() 2019-02-11 22:52:55 +01:00
Shing Lyu
c99cb0c366 Rustfmt fixes 2019-02-11 22:52:55 +01:00
Shing Lyu
8ded37d566 Raise OverflowError is the index for list.index() overflows 2019-02-11 22:52:27 +01:00
Shing Lyu
b101a52dd0 Added list.insert() 2019-02-11 22:50:10 +01:00
Shing Lyu
cc407ed90a Merge pull request #412 from veera83372/travis-clippy
added cargo clippy to travis
2019-02-11 22:44:58 +01:00
Windel Bouwman
cb59d76900 Merge pull request #439 from RustPython/move_unwrap_constant
Move unwrap_constant from Frame to PyContext.
2019-02-11 22:11:47 +01:00
Adam Kelly
67710d6e28 Don't call __eq__ directly.
Doing so creates a very confusing error when NotImplemented in returned.
2019-02-11 21:11:33 +00:00
Adam Kelly
50be99a0a1 Failing test case for in and index where types don't match. 2019-02-11 21:11:33 +00:00
Adam
23aa4a71ea Merge pull request #436 from Tom1380/master
Fix #390.
2019-02-11 21:09:32 +00:00
Adam Kelly
860edc6dfe Move unwrap_constant from Frame to PyContext. 2019-02-11 15:52:19 +00:00
Adam
89495e102a Merge pull request #418 from veera83372/format-exception
Fixing assert second argument formatting
2019-02-11 13:06:07 +00:00
Adam
1033f20e36 Merge pull request #430 from RustPython/dict5
Change to more usage of VirtualMachine in anticipation of proper dicts
2019-02-11 13:04:28 +00:00
Adam
ca51f2d10e Merge pull request #438 from ZapAnton/fix_clippy
Fixed several small clippy warnings
2019-02-11 13:03:07 +00:00
Tommaso Thea Cioni
7e1589d811 Minor fix. 2019-02-11 13:38:53 +01:00
Adam
45f45bf43a Merge pull request #433 from OddCoincidence/not-implemented
Use NotImplemented in binary operations
2019-02-11 12:37:22 +00:00
Tommaso Thea Cioni
c04f4219eb Removed the __code__ attribute from the builtin_function_or_method type. 2019-02-11 13:35:59 +01:00
ZapAnton
e51c75e1df Fixed or_fun_call clippy warnings 2019-02-11 15:29:19 +03:00
ZapAnton
56e2d4c495 Fixed into_iter_on_ref clippy warning 2019-02-11 15:24:51 +03:00
ZapAnton
c8d619c123 Fixed useless_let_if_seq clippy warnings 2019-02-11 15:24:13 +03:00
Tommaso Thea Cioni
cc56f318cb Merge branch 'master' of https://github.com/RustPython/RustPython 2019-02-11 13:21:41 +01:00
Adam
5c378d3bc5 Merge pull request #437 from rmliddle/develop
OS Tidy and Name fix
2019-02-11 12:17:40 +00:00
ZapAnton
d5b87558a2 Fixed map_clone clippy warnings 2019-02-11 15:09:53 +03:00
ZapAnton
1043543f16 Fixed cast_lossless clippy warnings 2019-02-11 15:02:00 +03:00
ZapAnton
b1a4aea9f3 Fixed explicit_counter_loop clippy warning 2019-02-11 14:59:22 +03:00
rmliddle
dd7437242c os rename 2019-02-11 21:41:47 +11:00
rmliddle
55a22c5a71 Fix module name in os 2019-02-11 21:40:00 +11:00
Tommaso Thea Cioni
8ac3c46de1 Fix RustPython#390. Now Rust functions have a builtin_function_or_method type, Python functions retain the function type. 2019-02-11 02:50:51 +01:00
Joey Hain
057a22529e Move delegation of __ne__ to __eq__ out of objobject 2019-02-10 15:46:12 -08:00
Joey Hain
a510aed86a Tests and fix objobject ne impl 2019-02-10 10:13:30 -08:00
Windel Bouwman
7102128654 Merge pull request #432 from HomerMcMillan/range-properties
Range properties
2019-02-10 18:21:44 +01:00
Joey Hain
dab4f7385f Use NotImplemented in binary operations 2019-02-10 09:19:06 -08:00
Homer McMillan
389fc3acd9 cargo fmt 2019-02-10 12:04:42 -05:00
Homer McMillan
9de733be19 Add range start/stop/step 2019-02-10 12:03:22 -05:00
Homer McMillan
10c2099374 Merge remote-tracking branch 'upstream/master' 2019-02-10 11:27:19 -05:00
Windel Bouwman
accfac8c41 Merge pull request #431 from janczer/add_str_le_ge
Fix the str.{__lt__, __gt__} and add the methods str.{__le__, __ge__}
2019-02-10 17:15:05 +01:00
janczer
aac1ce4e07 Fix the str.{__lt__, __gt__} and add the methods str.{__le__, __ge__} 2019-02-10 16:40:09 +01:00
Windel Bouwman
b1e07f64be Change to more usage of VirtualMachine in anticipation of proper dictionaries. 2019-02-10 15:39:33 +01:00
Windel Bouwman
05cd60bebc Merge pull request #415 from silmeth/fix-int-eq-float
fix int – float equality for big ints, inf and nan
2019-02-10 13:55:50 +01:00
silmeth
2182fa1bf5 rename old math tests (conflicting with math library imports) 2019-02-10 13:33:45 +01:00
Windel Bouwman
cf31805c2c Fix set test by add __hash__ method. 2019-02-10 13:30:22 +01:00
Windel Bouwman
68002f1a9e Fix build error of removed str method. 2019-02-10 13:00:54 +01:00
Windel Bouwman
9497ee89e8 Merge pull request #292 from mcon/sets-using-hashes
Items are now added to sets using proper __hash__ function calls.
2019-02-10 12:57:46 +01:00
Windel Bouwman
1cb59c5731 Merge pull request #394 from ZapAnton/iter_doc
iter type: Added __doc__
2019-02-10 12:28:09 +01:00
Windel Bouwman
2bab31b8e7 Merge pull request #387 from janczer/add_bytes_ge_gt_le_lt
Add bytes.{__ge__, __gt__, __le__, __lt__}
2019-02-10 12:27:01 +01:00
Windel Bouwman
03a2aad82d Merge pull request #410 from OddCoincidence/complex
Add complex.{__abs__, __eq__, __neg__}
2019-02-10 12:23:24 +01:00
veera venky
9bc9befee6 Added exception string when msg can't be converted to string 2019-02-10 16:43:21 +05:30
Windel Bouwman
c2db23db2b Merge pull request #417 from janczer/fix_lt_le_ge_gt_float
float.{__lt__, __le__, __ge__, __gt__} fix comparing with non float type
2019-02-10 12:10:58 +01:00
Windel Bouwman
fc38d55b59 Merge pull request #381 from nficca/implement-range-count
Implement range.count
2019-02-10 11:46:10 +01:00
Windel Bouwman
94db145ae8 Merge branch 'master' into complex 2019-02-10 11:41:39 +01:00
Windel Bouwman
e69605328b Merge pull request #426 from skinny121/recursive_repr
Fixed #191, fixes recursive repr() for the standard collections
2019-02-10 08:35:02 +01:00
Windel Bouwman
e98d5f11cc Merge pull request #393 from ZapAnton/filter_doc
filter type: Added __doc__
2019-02-10 08:24:50 +01:00
Ryan Liddle
7422d27201 Merge pull request #422 from HomerMcMillan/range-reversed
Fix range reversed #421
2019-02-10 15:08:34 +11:00
ben
5b637385ea Fixed #191, fixes recursive repr() for the standard collections 2019-02-10 13:22:03 +13:00
Homer McMillan
0611e765e2 Add extra test to builtin_range.py 2019-02-09 18:40:46 -05:00
Homer McMillan
58e05d28f6 Merge remote-tracking branch 'upstream/master' 2019-02-09 18:15:45 -05:00
Adam
d8afc6a722 Merge pull request #420 from Tom1380/master
Uncommented a line of code like a TODO said.
2019-02-09 22:36:50 +00:00
Matthew Constable
0322b937f3 Updated formatting 2019-02-09 21:58:01 +00:00
Matthew Constable
9271bfcb84 Moved from using BigInt in set hash to u64, which is guaranteed to be of constant size - u64 seems easier than usize as it's the same size across all platforms. 2019-02-09 21:57:26 +00:00
Nic Ficca
0cb661f3a2 Dry up objrange
- Use get_value in all appropriate spots
2019-02-09 16:54:14 -05:00
Nic Ficca
2e9892029a Add objrange::get_value
- Refactor range_count to use get_value and isinstance for pulling out the range and argument respectively
2019-02-09 16:49:44 -05:00
Matthew Constable
cca16ff597 Simplify calling __hash__ method 2019-02-09 21:38:11 +00:00
Nic Ficca
316e94bd42 Add tests 2019-02-09 16:28:04 -05:00
Nic Ficca
b7a4248837 Add range.count 2019-02-09 16:27:12 -05:00
Matthew Constable
9f3cc35e9c Allow sets to be initialized from literals. 2019-02-09 21:24:16 +00:00
Matthew Constable
c673384cc4 Merge branch 'master' into sets-using-hashes 2019-02-09 21:04:33 +00:00
Homer McMillan
ba9226219b cargo fmt 2019-02-09 15:54:17 -05:00
Homer McMillan
a4d13f9f50 Fix typo 2019-02-09 15:53:13 -05:00
Homer McMillan
4e02962289 Fix range reversed #421 2019-02-09 15:49:51 -05:00
ZapAnton
216e690ee0 filter type: Added __doc__ 2019-02-09 23:00:43 +03:00
Tommaso Thea Cioni
b9d773824c Uncommented a line of code like a TODO said. 2019-02-09 20:24:24 +01:00
Windel Bouwman
ecea7035b0 Merge branch 'master' into iter_doc 2019-02-09 19:37:17 +01:00
Windel Bouwman
ac37026010 Merge pull request #385 from OddCoincidence/reversed
Add reversed builtin and range.__reversed__
2019-02-09 19:32:44 +01:00
Windel Bouwman
56a36b7959 Merge pull request #395 from ZapAnton/map_doc
map type: Added __doc__
2019-02-09 19:31:32 +01:00
Joey Hain
d3d73bdc22 Disable broken test for now 2019-02-09 10:24:17 -08:00
janczer
454837f64b Fix fmt in objfloat 2019-02-09 19:16:04 +01:00
Tommaso Thea Cioni
8ffd4c5e56 Fixed #402. (#414)
Raise syntax error rather than panicking on expected closing bracket. 

* Fixed #402.
2019-02-09 18:10:40 +00:00
Windel Bouwman
7807dc3d2c Merge pull request #388 from veera83372/sys-doc
Added __doc__ for sys module
2019-02-09 18:59:45 +01:00
Windel Bouwman
b14dc20adc Merge branch 'master' into map_doc 2019-02-09 18:58:37 +01:00
veera venky
b5911ed796 Fixing assert second argument formatting 2019-02-09 22:17:01 +05:30
Joey Hain
22a430cdc5 Don't use magic methods directly 2019-02-09 08:20:04 -08:00
Joey Hain
969ddf2ea0 Merge remote-tracking branch 'upstream/master' into reversed 2019-02-09 08:13:03 -08:00
Joey Hain
09dc751869 Avoid using magic methods in tests where possible 2019-02-09 08:09:48 -08:00
janczer
8d1d6ce1ee float.{__lt__, __le__, __ge__, __gt__} fix comparing with non float type 2019-02-09 17:05:32 +01:00
janczer
607e1262d4 Fix the typo 2019-02-09 16:42:32 +01:00
Windel Bouwman
3c25c14311 Merge pull request #400 from palaviv/Add-set-funcs
Add set.{__eq__,__gt__,__ge__,__le__,__lt__,issubset,issuperset}
2019-02-09 16:31:05 +01:00
Windel Bouwman
601e4c9dc9 Merge pull request #416 from silmeth/zero-division
fix floordiv and divmod by zero for ints and floats
2019-02-09 16:29:52 +01:00
Windel Bouwman
95cb0178cd Merge pull request #405 from RustPython/code_object
Code object
2019-02-09 16:20:07 +01:00
silmeth
6c56c22f0f fix floordiv and divmod by zero for ints and floats 2019-02-09 15:15:54 +01:00
silmeth
d960ca3d5b fix int – float equality for big ints, inf and nan 2019-02-09 14:02:43 +01:00
Adam Kelly
5c5d27203a Support for all co_* that can implemented currently. 2019-02-09 12:22:51 +00:00
Adam Kelly
6539f07818 @generated comment added to Cargo.lock 2019-02-09 12:22:51 +00:00
Adam Kelly
769b889097 Source path should always be set, make it non-optional for code object. 2019-02-09 12:22:51 +00:00
Adam
a6d6f0fcaa Merge pull request #413 from ka7/spelling
Spelling fixes
2019-02-09 12:18:09 +00:00
Adam Kelly
1869a9f1ed Passing version of code.py tests. 2019-02-09 12:15:16 +00:00
Adam Kelly
8116dae65f Add some co_* methods to code objects. 2019-02-09 12:15:16 +00:00
Adam Kelly
7d08867419 Record first line number in code object. 2019-02-09 12:15:16 +00:00
Adam Kelly
7b2508a730 Start adding methods to code object. 2019-02-09 12:15:16 +00:00
Adam
8ad95c4a57 Merge pull request #326 from lausek/master
int type: rounding, index, trunc, int (#304)
2019-02-09 11:23:14 +00:00
Adam
b87fcdce34 Merge pull request #285 from orf/handle-missing-file
Improve test coverage of os.open/open
2019-02-09 11:20:11 +00:00
Adam
2ae9d88de4 Merge pull request #398 from ZapAnton/range_doc
range type: Added __doc__
2019-02-09 11:11:13 +00:00
klemens
b109ea954a Merge branch 'master' into spelling 2019-02-09 12:03:08 +01:00
Adam
c5b94a4d82 Merge pull request #408 from janczer/add_floats_div_mul
Add floats.{__truediv__, __mul__}
2019-02-09 11:03:01 +00:00
klemens
79a7e5e42b spelling fixes 2019-02-09 12:00:46 +01:00
veera venky
fa927c5028 added cargo clippy 2019-02-09 16:25:29 +05:30
Aviv Palivoda
2df9d799f5 Fix formatting errors 2019-02-09 10:18:05 +02:00
Windel Bouwman
3376808428 Merge pull request #409 from skinny121/slice
Add slice type
2019-02-09 08:31:55 +01:00
Windel Bouwman
587617d5e3 Add dict data type. (#380)
* Add dict data type.

* Fix formatting.

* Implement review comments.
2019-02-09 08:14:37 +01:00
Joey Hain
520f71f354 Add NotImplemented built-in constant 2019-02-08 19:24:08 -08:00
ben
7abf02180a implement slice negative step handling 2019-02-09 15:48:07 +13:00
Joey Hain
d66ca54a2d Add complex.{__eq__, __neg__} 2019-02-08 18:20:58 -08:00
Joey Hain
fc863aaba5 Add complex.__abs__ 2019-02-08 18:20:55 -08:00
ben
907dfb6770 Add slice type and use BigInts in slice payload. 2019-02-09 12:07:04 +13:00
janczer
ba19732fbb Fix the fmt error 2019-02-08 22:09:42 +01:00
janczer
47fc303e55 Rasi error when try compare bytes with another types 2019-02-08 22:06:57 +01:00
janczer
59706538f4 Fix typo and fix fmt errors 2019-02-08 21:56:07 +01:00
Windel Bouwman
f454bf36d1 Merge pull request #396 from ZapAnton/property_doc
property type: Added __doc__
2019-02-08 21:16:17 +01:00
Windel Bouwman
85475e4e30 Merge pull request #347 from silmeth/master
Fix Range’s len() + division and mod by 0
2019-02-08 21:04:31 +01:00
janczer
d4b82007df Add floats.{__truediv__, __mul__} 2019-02-08 20:34:33 +01:00
Windel Bouwman
869b91a27d Merge pull request #399 from ZapAnton/super_doc
super type: Added __doc__
2019-02-08 20:08:22 +01:00
Windel Bouwman
32bfcf36fd Merge pull request #384 from skinny121/iter_lazy_2
Add enumerate and zip types
2019-02-08 20:05:20 +01:00
Adam
c55593406c Merge pull request #392 from ZapAnton/complex_doc
complex type: Added __doc__
2019-02-08 18:31:26 +00:00
Adam
f5792f84d6 Merge pull request #391 from ZapAnton/byteaaray_doc
bytearray type: Added __doc__
2019-02-08 18:31:03 +00:00
Adam
9245a62296 Merge pull request #401 from ZapAnton/type_doc
type type: Added __doc__
2019-02-08 18:30:17 +00:00
Adam
891b79bbb6 Merge pull request #403 from ZapAnton/remove_doc_tests
tests: Removed tests for the __doc__
2019-02-08 18:29:29 +00:00
Adam
bf294a82e8 Merge pull request #404 from ZapAnton/fix_if_same_then_else
Fix the 'if_same_then_else' clippy warnings
2019-02-08 18:29:02 +00:00
Benedykt Jaworski
b9245309d5 Merge branch 'master' into master 2019-02-08 18:45:00 +01:00
ZapAnton
0e6fca0106 Fix the 'if_same_then_else' clippy warnings
Relevant clippy warning: https://rust-lang.github.io/rust-clippy/master/index.html#if_same_then_else
2019-02-08 20:04:30 +03:00
veera venky
cf2d07502b Removed strict testing for __doc__ string 2019-02-08 22:26:28 +05:30
ZapAnton
da68dfef78 tests: Removed tests for the __doc__ 2019-02-08 19:41:47 +03:00
ZapAnton
ae88389e10 type type: Added __doc__ 2019-02-08 19:36:10 +03:00
Aviv Palivoda
9ec2eef579 Add set.{issubset,issuperset} 2019-02-08 18:33:04 +02:00
ZapAnton
2b0f87b69f super type: Added __doc__ 2019-02-08 19:28:39 +03:00
Aviv Palivoda
2bc946b748 Add set.__lt__ 2019-02-08 18:27:37 +02:00
Aviv Palivoda
adee66168b Add set.__le__ 2019-02-08 18:25:33 +02:00
ZapAnton
a6d6f7721b range type: Added __doc__ 2019-02-08 19:17:08 +03:00
ZapAnton
a6beeac383 property type: Added __doc__ 2019-02-08 19:09:38 +03:00
Aviv Palivoda
1ee583ef61 Use set_compare_inner 2019-02-08 18:06:22 +02:00
ZapAnton
c05f7dc83a map type: Added __doc__ 2019-02-08 19:01:18 +03:00
ZapAnton
e6d638d43f iter type: Added __doc__ 2019-02-08 18:56:34 +03:00
Aviv Palivoda
358aa6b2c0 Add set.__gt__ 2019-02-08 17:50:36 +02:00
ZapAnton
031f062e72 complex type: Added __doc__ 2019-02-08 18:47:23 +03:00
ZapAnton
a180a4b6cb bytearray type: Added __doc__ 2019-02-08 18:43:27 +03:00
veera venky
61cbb49647 Added __doc__ for sys module 2019-02-08 21:08:30 +05:30
Aviv Palivoda
0c737ae8d2 Add set.__eq__ 2019-02-08 17:31:45 +02:00
Aviv Palivoda
6274c3fe8b Add set.__ge__ 2019-02-08 17:18:14 +02:00
Windel Bouwman
07fd61f55f Change instance and class to simplified dict type. (#379)
* Change instance and class to simplified dict type.

* Fix formatting.
2019-02-08 14:18:14 +00:00
janczer
83202d639f Add bytes.{__ge__, __gt__, __le__, __lt__} 2019-02-08 15:02:50 +01:00
Joey Hain
1ebacafb00 Add reversed builtin and range.__reversed__ 2019-02-08 00:19:14 -08:00
ben
e1284e34b0 Made filter_new private 2019-02-08 21:05:04 +13:00
ben
5896f049ef Add enumerate and zip types and made them lazy. 2019-02-08 20:57:16 +13:00
Windel Bouwman
a4b99253c9 Merge pull request #382 from OddCoincidence/range-bool-contains
Add range.{__bool__, __contains__}
2019-02-08 08:05:40 +01:00
Joey Hain
54bcb08518 Add range.{__bool__, __contains__}
- Also fix range.index for negative steps
2019-02-07 20:31:32 -08:00
Windel Bouwman
3dc2ab979d Merge pull request #378 from veera83372/tuple-methods
Added __doc__ atrribute for tuple
2019-02-07 21:09:18 +01:00
Windel Bouwman
385fb03d7a Merge pull request #327 from ZapAnton/float_doc
Float type: Added __doc__
2019-02-07 21:08:42 +01:00
veera venky
b85cf91a23 Added __doc__ atrribute for tuple 2019-02-07 23:47:47 +05:30
Windel Bouwman
3d2d04596c Merge pull request #343 from ZapAnton/fix_various_clippy
Fixed various small clippy warnings
2019-02-07 17:35:29 +01:00
Windel Bouwman
4e584efa57 Merge pull request #374 from ZapAnton/set_doc
(frozen)set type: Added __doc__
2019-02-07 17:29:07 +01:00
Windel Bouwman
c24a88c5ad Merge pull request #369 from ZapAnton/bytes_doc
bytes type: Added __doc__
2019-02-07 17:28:25 +01:00
Benedykt Jaworski
f823eb9403 Merge branch 'master' into master 2019-02-07 17:20:54 +01:00
Tom Forbes
6c18126382 Improve test coverage of os.open 2019-02-07 07:30:53 -07:00
Ryan Liddle
4d02a1e037 Merge pull request #376 from veera83372/tuple-index
Added index to tuple
2019-02-07 21:49:26 +11:00
veera venky
1479d6bc77 Added index to tuple 2019-02-07 14:56:14 +05:30
Windel Bouwman
d3158f3db5 Merge pull request #372 from RustPython/eliminate_repeated_to_bigint
Eliminate repeated to bigint
2019-02-07 06:22:58 +01:00
ZapAnton
694cbda03d (frozen)set type: Added __doc__ 2019-02-07 00:57:29 +03:00
Windel Bouwman
8f2c959143 Merge pull request #368 from ZapAnton/list_doc
list type: Added __doc__
2019-02-06 20:44:39 +01:00
Adam Kelly
df89c439d9 Fix accidentally broken test. 2019-02-06 17:55:01 +00:00
lausek
02d99758fe round() for int 2019-02-06 18:38:37 +01:00
Adam Kelly
fd344ec1e0 Remove unnecessary to_bigint().unwrap() everywhere. 2019-02-06 17:38:01 +00:00
Adam Kelly
aca0238379 Allow new_int to take anything with ToBigInt. 2019-02-06 17:36:22 +00:00
Adam Kelly
a83fd7c1af Add __code__ to functions. 2019-02-06 16:01:07 +00:00
Windel Bouwman
eb0da4f61c Merge pull request #366 from rmliddle/develop
Fixes build on Windows
2019-02-06 14:15:30 +01:00
ZapAnton
ca63f899d6 list type: Added __doc__ 2019-02-06 15:18:45 +03:00
ZapAnton
1992e02b76 bytes type: Added __doc__ 2019-02-06 15:16:41 +03:00
ZapAnton
2d7164df92 float type: Added __doc__ 2019-02-06 14:44:30 +03:00
rmliddle
f89dc0061b included all not unix in static pathbuf 2019-02-06 22:37:35 +11:00
rmliddle
51d5f9d3a4 changed String to PathBuf 2019-02-06 21:46:50 +11:00
ZapAnton
3464828499 Fixed various small clippy warnings 2019-02-06 13:24:24 +03:00
Windel Bouwman
03fb016415 Merge pull request #333 from ZapAnton/fix_useless_format
Fixed the 'useless_format' clippy warning
2019-02-06 11:16:21 +01:00
rmliddle
401f477fc8 Format main.rs 2019-02-06 21:01:55 +11:00
Ryan Liddle
9e53091c0f Merge branch 'implement-io' of https://github.com/rmliddle/RustPython into implement-io 2019-02-06 21:00:37 +11:00
Ryan Liddle
2f0647e847 factored out xdg to cfg functions to allow windows builds to succeed 2019-02-06 20:59:54 +11:00
Windel Bouwman
c21772c969 Merge pull request #365 from ZapAnton/int_rxor
int type: Added __rxor__
2019-02-06 10:55:55 +01:00
Windel Bouwman
62cad730d3 Merge pull request #364 from HomerMcMillan/string_is_methods
Fix string is* methods
2019-02-06 10:55:06 +01:00
Windel Bouwman
baa59ec2fc Merge branch 'master' into fix_useless_format 2019-02-06 10:50:07 +01:00
Windel Bouwman
2c693d9a2e Merge pull request #336 from ZapAnton/fix_redundant_field_names
Fixed the 'redundant_field_names' clippy warnings
2019-02-06 10:48:45 +01:00
Benedykt Jaworski
ff244df3eb Merge branch 'master' into master 2019-02-06 10:24:59 +01:00
silmeth
af0fdcb9e3 fix zero-division tests 2019-02-06 10:15:44 +01:00
ZapAnton
dfd0ea23c0 int type: Added tests for the __rxor__ 2019-02-06 12:08:26 +03:00
ZapAnton
b682eb939e int type: Added __rxor__ 2019-02-06 12:04:47 +03:00
Homer McMillan
00ef668022 String is* methods return false on empty string #363 2019-02-06 03:15:03 -05:00
Homer McMillan
94dc6ece64 Fix python tests that travis didn't like 2019-02-06 02:42:44 -05:00
Windel Bouwman
040a377d06 Merge branch 'master' into fix_redundant_field_names 2019-02-06 08:14:14 +01:00
Windel Bouwman
a26279111d Merge pull request #353 from OddCoincidence/range-index
Add range.index
2019-02-06 08:00:11 +01:00
Windel Bouwman
f13cb62393 Merge pull request #357 from veera83372/object-methods
Added __doc__ atrribute for object
2019-02-06 07:53:01 +01:00
Windel Bouwman
8a53547e2b Merge pull request #355 from NLincoln/compliant-complex-repr
repr() of complex numbers is compliant with cpython
2019-02-06 07:52:31 +01:00
Windel Bouwman
819e5a01e4 Merge pull request #354 from HomerMcMillan/bytes_iter
Add bytes.__iter__
2019-02-06 07:45:10 +01:00
Windel Bouwman
0a3f15ae22 Merge pull request #348 from skinny121/iter_lazy
Made filter and map lazy
2019-02-06 07:43:07 +01:00
Homer McMillan
0085470c83 Add tests for bytearray 2019-02-06 01:26:51 -05:00
Homer McMillan
1270aee628 Add is* methods to bytearray 2019-02-06 01:22:23 -05:00
veera venky
3de17b9083 Added __doc__ atrribute for object 2019-02-06 08:35:57 +05:30
coolreader18
9b6516e175 Allow closures to be passed from Python to JS if using a WASM VM 2019-02-05 21:04:24 -06:00
Nathan
12e6de0503 repr() of complex numbers is compliant with cpython 2019-02-05 20:59:41 -06:00
Homer McMillan
35a06bc428 Add bytes.__iter__ 2019-02-05 21:44:14 -05:00
Joey Hain
49a23a8483 remove misleading contains method 2019-02-05 16:26:12 -08:00
coolreader18
a24cd8368a Merge branch 'master' into wasm-vm-class 2019-02-05 17:53:21 -06:00
ben
6d494fb9ee Merge branch 'master' into iter_lazy 2019-02-06 12:46:16 +13:00
ben
6c8ec39882 Make map and filter into proper types 2019-02-06 12:45:14 +13:00
Windel Bouwman
aaf0eab530 Merge pull request #342 from ZapAnton/fix_collapsible_if
Fixed the 'collapsible_if' clippy warnings
2019-02-05 23:34:29 +01:00
Windel Bouwman
87ceed77ad Merge pull request #287 from makarchuk/float-conversion
Float Conversion for #211
2019-02-05 23:19:20 +01:00
ben
3a81fd1ef4 style: rustfmt 2019-02-06 11:15:07 +13:00
ben
6e99ad32db Added tests for when function in filter/map raises StopIteration 2019-02-06 11:12:25 +13:00
ben
f85bc13ded Fix misunderstanding about behaviour if filter function is None 2019-02-06 11:12:25 +13:00
ben
91fcd7782e Make map lazy and accept multiple iterables 2019-02-06 11:12:25 +13:00
ben
8cc6821c44 Make filter lazy 2019-02-06 11:12:25 +13:00
silmeth
77ae6621e9 add tests for range length, and for division by zero 2019-02-05 22:50:52 +01:00
silmeth
8621f3ff2b fix: register arithmetic errors in builtins module 2019-02-05 22:48:33 +01:00
Windel Bouwman
69e3571d0c Merge pull request #341 from ZapAnton/toplevel_ref_arg
Fixed the 'toplevel_ref_arg' clippy warning
2019-02-05 22:42:31 +01:00
Windel Bouwman
3fb0f32a87 Merge pull request #335 from ZapAnton/fix_ptr_arg
Fixed the 'ptr_arg' clippy warnings
2019-02-05 22:36:29 +01:00
Joey Hain
b0a2f6f87d Add range.index 2019-02-05 13:34:54 -08:00
Windel Bouwman
9d5a953c8a Merge pull request #337 from ZapAnton/fix_unneeded_field_pattern
Fixed the 'unneeded_field_pattern' clippy warnings
2019-02-05 22:34:31 +01:00
Windel Bouwman
276b51c4d5 Merge pull request #338 from stratusjerry/master
Spellcheck
2019-02-05 22:32:26 +01:00
Windel Bouwman
835a55777b Merge pull request #334 from ZapAnton/fix_len_zero
Fixed the 'len_zero' clippy warnings
2019-02-05 22:31:54 +01:00
Windel Bouwman
907ce8801f Merge pull request #339 from ZapAnton/fix_needless_return
Fixed the 'needless_return' clippy warnings
2019-02-05 22:30:32 +01:00
silmeth
30c8e477e4 style: rustfmt 2019-02-05 21:54:03 +01:00
silmeth
d96e0ecf40 make division and modulo by 0 throw ZeroDivisionError 2019-02-05 21:28:48 +01:00
silmeth
0a1eb4b91b make len(range) throw OverflowError on too big ints + impl __repr__ 2019-02-05 21:27:49 +01:00
ZapAnton
fb9fa27555 Fixed the 'redundant_field_names' clippy warnings
This replaces all the occurrences of the Struct {field : field}
with the Struct {field}.

Relevant clippy warning: https://rust-lang.github.io/rust-clippy/master/index.html#redundant_field_names
2019-02-05 21:56:16 +03:00
Timur
74b84d4be1 Merge branch 'float-conversion' of github.com:makarchuk/RustPython into float-conversion 2019-02-05 21:56:14 +03:00
Timur
4b2787ea1d Comment out math from tests due to Travis errors 2019-02-05 21:54:13 +03:00
silmeth
b43c511542 fix range len() for negative and non-divisible steps 2019-02-05 19:49:14 +01:00
ZapAnton
b0cbb23b43 Fixed the 'collapsible_if' clippy warnings
Relevant clippy warning: https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
2019-02-05 21:49:07 +03:00
ZapAnton
0d3b218237 Fixed the 'toplevel_ref_arg' clippy warning
This replaces all the occurrences of the
'let ref var = another_var' with the
'let var = &another_var'

Relevant clippy warning: https://rust-lang.github.io/rust-clippy/master/index.html#toplevel_ref_arg
2019-02-05 21:45:56 +03:00
ZapAnton
526ed98d93 Fixed the 'needless_return' clippy warnings
This replaces all the occurrences of the 'return var;' at
the end of the functions with the 'var'.

Relevant clippy warning: https://rust-lang.github.io/rust-clippy/master/index.html#needless_return
2019-02-05 21:39:38 +03:00
stratusjerry
7134885775 Spellcheck 2019-02-05 13:39:16 -05:00
ZapAnton
d445e3082a Fixed the 'unneeded_field_pattern' clippy warnings
This replaces all the occurrences of the Struct {field: _} with
the Struct { .. }.

Relevant clippy warning: https://rust-lang.github.io/rust-clippy/master/index.html#unneeded_field_pattern
2019-02-05 21:37:41 +03:00
ZapAnton
1a6840280b Fixed the 'ptr_arg' clippy warnings
This replaces all the occurrences of &<dynamic collection><T>
with the &[T].

Relevant clippy warning: https://rust-lang.github.io/rust-clippy/master/index.html#ptr_arg
2019-02-05 21:22:16 +03:00
ZapAnton
6fb91ddfed Fixed the 'len_zero' clippy warnings
This replaces all the occurrences of the <collection>.len() == 0
with the <collection>.is_empty() and the occurrences of the
<collection>.len() > 0 with the !<collection>.is_empty()

Relevant clippy warning: https://rust-lang.github.io/rust-clippy/master/index.html#len_zero
2019-02-05 20:54:49 +03:00
ZapAnton
57e2beef3a Fixed the 'useless_format' clippy warning
This replaces all the occurrences of the format!(<&str>) with the <&str>.to_string()

Relevant clippy warning: https://rust-lang.github.io/rust-clippy/master/index.html#useless_format
2019-02-05 20:48:50 +03:00
Windel Bouwman
7941480fca Merge pull request #269 from mrecachinas/add-int-doc
Add int.__doc__ (addresses #261)
2019-02-05 18:26:28 +01:00
Windel Bouwman
0f0ceeaa00 Merge pull request #332 from lausek/imports
raise ImportError in import list
2019-02-05 18:25:41 +01:00
Windel Bouwman
fa91cc36e8 Merge pull request #329 from ZapAnton/int_invert
int type: Added __invert__
2019-02-05 18:14:21 +01:00
Windel Bouwman
e481063ca6 Fixed duplicate os error. 2019-02-05 18:13:08 +01:00
Windel Bouwman
815dd0937a Merge pull request #309 from holygits/add-os-error
Add OSError
2019-02-05 17:59:14 +01:00
Windel Bouwman
676f60296d Merge pull request #330 from ichyo/string-len
Use the number of characters instead of bytes for str.__len__
2019-02-05 17:57:58 +01:00
Windel Bouwman
8e006274ed Merge pull request #325 from rmliddle/implement-io
Factored OS Module for Windows Support, Unsafe Handling of Raw FileHandles and Descriptors
2019-02-05 17:49:52 +01:00
Windel Bouwman
b710eedb04 Merge pull request #324 from veera83372/refactor-py
Refactored: whats_left_to_implement.py
2019-02-05 17:45:10 +01:00
lausek
f4af599167 added ImportError as builtin 2019-02-05 17:41:05 +01:00
Timur Makarchuk
c7e6935e1c Get rid of exp usages
Assuming `exp` function was missing for platform-dependant reasons, let's try to test it with `sin` instead
2019-02-05 19:21:31 +03:00
Adam
6ea784e78e Merge pull request #323 from vokar97/handle-index-overflow
Add error handling for objsequence and objstr index overflow (addresses #276)
2019-02-05 16:00:07 +00:00
Adam
aee5090bd2 Merge pull request #321 from HomerMcMillan/tuple_comparisons
Fix error messages in tuple/list comparisons
2019-02-05 15:54:54 +00:00
ichyo
d1b034e3b9 Avoid using \xhh for string 2019-02-05 23:54:39 +09:00
lausek
f8db0f1c94 raise ImportError in import list 2019-02-05 15:42:39 +01:00
ichyo
fc779c2e3a Use the number of characters instead of bytes for str.__len__ 2019-02-05 23:26:13 +09:00
lausek
3d07ecdd1c int type: trunc and index 2019-02-05 14:08:08 +01:00
ZapAnton
8c469a6466 int type: Added tests for the __invert__ 2019-02-05 15:25:07 +03:00
ZapAnton
5db2025dec int type: Added __invert__ 2019-02-05 15:20:17 +03:00
rmliddle
aa2dff4bd9 Format os.rs 2019-02-05 23:08:45 +11:00
rmliddle
86e94f587b Comment fix and use of i64 instead of i32 2019-02-05 22:47:33 +11:00
lausek
73ae085ed8 implemented rounding funcs for int (#304) 2019-02-05 12:47:30 +01:00
rmliddle
eca75b3611 Comment and formatted on windows rust_file call 2019-02-05 22:18:24 +11:00
Ryan Liddle
0daa03875c windows fixes for os module 2019-02-05 22:14:14 +11:00
veera venky
ea4059a18f Refactored: whats_left_to_implement.py 2019-02-05 16:04:01 +05:30
rmliddle
ca815baeaf Factored out unix dependency 2019-02-05 20:57:06 +11:00
Vladimir Karamyshev
ebbd3d9f22 Add error handling for objsequence and objstr index overflow 2019-02-05 10:17:43 +03:00
coolreader18
de3762cabf Add .run(); fix .addToScope(); add panic-catcher for debugging 2019-02-05 00:39:16 -06:00
Homer McMillan
7446a52c18 Fix error messages in tuple/list comparisons 2019-02-05 00:27:36 -05:00
Windel Bouwman
63c83086c7 Merge pull request #320 from HomerMcMillan/tuple_comparisons
Tuple comparisons
2019-02-05 06:24:30 +01:00
Windel Bouwman
ed53a353c2 Merge pull request #316 from OddCoincidence/range-use-bigint
Represent range with BigInts
2019-02-05 06:21:04 +01:00
Windel Bouwman
2be174050a Merge pull request #305 from veera83372/master
Adding int.__bool__ method
2019-02-05 06:19:26 +01:00
Windel Bouwman
aea929a284 Merge pull request #319 from holygits/fix-fileno
Revert 'file_no' -> 'fileno' attr naming
2019-02-05 06:18:30 +01:00
Homer McMillan
fb58ca3e6c Add comparison tests for tuple 2019-02-04 23:31:39 -05:00
Homer McMillan
696bf8e9a9 rustfmt 2019-02-04 23:27:45 -05:00
Homer McMillan
608a13eabb Add comparison operations for tuple 2019-02-04 23:26:16 -05:00
holygits
5cad1b0215 Revert 'file_no' -> 'fileno' attr naming 2019-02-05 16:39:22 +13:00
coolreader18
f7c91c7df0 Add add_to_scope() method for WASM VM 2019-02-04 20:36:19 -06:00
Joey Hain
9ac8e55695 Represent range with BigInts 2019-02-04 17:38:23 -08:00
coolreader18
3bec2260bb Rename VMStore 2019-02-04 18:58:53 -06:00
holygits
9a37825f7b Add OSError
Fix heirarchy or existing os errors
2019-02-05 10:29:36 +13:00
veera venky
d3fedecd61 Adding 'int.__bool__' method 2019-02-05 02:26:44 +05:30
Windel Bouwman
f4a78d4148 Merge pull request #307 from veera83372/object-methods
Added object expected methods to left to implement list
2019-02-04 21:49:19 +01:00
Windel Bouwman
b7b4a8a51b Merge branch 'master' into add-int-doc 2019-02-04 21:47:09 +01:00
Windel Bouwman
47d43a7fef Merge pull request #306 from HomerMcMillan/range-builtin
Add built in range type (addresses #294)
2019-02-04 21:46:07 +01:00
Windel Bouwman
1c07a2285d Merge pull request #268 from mrecachinas/add-bool-doc
Add bool.__doc__ (addresses #260)
2019-02-04 21:34:58 +01:00
HomerMcMillan
41d73c49a1 Merge branch 'master' into range-builtin 2019-02-04 15:14:43 -05:00
veera venky
c8f2515f4b Added object expected methods to left to implement list 2019-02-05 01:42:32 +05:30
Homer McMillan
64bd33e787 Add built in range type (addresses #294) 2019-02-04 15:08:13 -05:00
Michael Recachinas
9dded0cb7b Replace context.new_property with context.new_str for int.__doc__ 2019-02-04 19:46:58 +00:00
Michael Recachinas
804def1522 Replace context.new_property with context.new_str for bool.__doc__ 2019-02-04 19:37:24 +00:00
Timur
b25aab006e Add type conversion to functions calls in math 2019-02-04 22:22:18 +03:00
Windel Bouwman
2b22cd443e Implement clippy thoughts into rustpython_parser 2019-02-04 18:18:40 +01:00
Windel Bouwman
7096434f95 Implement some clippy tips 2019-02-04 17:17:54 +01:00
Windel Bouwman
55aa12b68f Merge pull request #299 from holygits/fix-unicode-handling
Handle unicode string slicing with graphemes
2019-02-04 13:48:41 +01:00
Windel Bouwman
b7f6db753f Merge branch 'master' into fix-unicode-handling 2019-02-04 08:39:21 +01:00
Windel Bouwman
4242b66992 Merge pull request #301 from mrnugget/remove_dereference
Remove unnecessary dereferences/references in compiler
2019-02-04 08:37:32 +01:00
Windel Bouwman
1e576b5baa Merge pull request #273 from skinny121/tuple_add
Add tuple.__add__
2019-02-04 08:27:41 +01:00
Thorsten Ball
0146e5f51c Remove unnecessary dereferences/references in compiler
It's not necessary to dereference a reference to then take a reference
again, at least not in these cases, so we can remove them.
2019-02-04 08:15:22 +01:00
Windel Bouwman
caac5a34d5 Merge branch 'master' into tuple_add 2019-02-04 08:05:07 +01:00
Windel Bouwman
44e9658f52 Merge pull request #297 from HomerMcMillan/issue_295
Fix panic on out of bounds negative index (addresses #295)
2019-02-04 07:48:17 +01:00
Windel Bouwman
235aa864f4 Merge pull request #296 from agude/int_conj
Add .conjugate() method to int type
2019-02-04 07:43:13 +01:00
Windel Bouwman
371f8f81dc Merge pull request #298 from idbentley/alphebetize_exceptions
Alphebetize exception related code
2019-02-04 07:42:42 +01:00
holygits
33a3ec8832 Handle unicode string slicing with graphemes 2019-02-04 15:40:30 +13:00
idbentley
f2db23bb35 correct order of errors. 2019-02-03 16:51:17 -05:00
Homer McMillan
055e577424 Fix panic on out of bounds negative index (addresses #295)
Also an out of bounds index now raises an IndexError rather than a ValueError
2019-02-03 16:38:04 -05:00
idbentley
19557e8344 Alphebetize exception related code 2019-02-03 16:36:25 -05:00
Alexander Gude
33523d492c Change int.conjugate() to return a new int
This results in the correct behavior (that is, matching CPython) for
both int and bool types.

Also adding a bool conjugate test.
2019-02-03 13:31:09 -08:00
Windel Bouwman
0f87d151a0 Merge pull request #289 from chaconnewu/198fix
Fix reverse method for calling div.
2019-02-03 21:27:59 +01:00
Windel Bouwman
7c6fdbacf1 Merge pull request #279 from HomerMcMillan/list-orderable-ops
Add list.{__lt__, __gt__, __le__, __ge__}
2019-02-03 21:25:35 +01:00
Alexander Gude
a95747f161 Add .conjugate() method to int type
Also add tests for for the int type, and a commented out one for the
bool type.
2019-02-03 11:18:23 -08:00
Matthew Constable
190b2a43d9 Fixed formatting 2019-02-03 18:34:35 +00:00
Matthew Constable
0beceefd0c Add a few tests for sets which reflect new changes. 2019-02-03 17:51:06 +00:00
Matthew Constable
da5046100b Able to create set from iterable. 2019-02-03 17:25:24 +00:00
Matthew Constable
b433b7fcf0 Implemented remove() method on set. 2019-02-03 17:01:32 +00:00
Homer McMillan
353d881bac Fix missing seq_mul import 2019-02-03 11:33:11 -05:00
HomerMcMillan
168e0e5471 Merge branch 'master' into list-orderable-ops 2019-02-03 11:17:09 -05:00
Matthew Constable
c022ac46e6 Refactored adding to set using hash into helper function. 2019-02-03 16:09:44 +00:00
Matthew Constable
6acb7eb006 Handle attempt to add non-hashable items to a set. 2019-02-03 15:46:13 +00:00
Matthew Constable
d5801162bd Sets use python __hash__ functions when items are added - need to re-implement set creation from iterable 2019-02-03 15:25:24 +00:00
Windel Bouwman
34c99b0c99 Merge pull request #278 from holygits/improve-fio-errs
Better error handling for file io
2019-02-03 16:03:41 +01:00
Yu Wu
38ee8aeed6 Fix reverse method for calling div. 2019-02-03 07:02:36 -08:00
Windel Bouwman
384ae474de Merge pull request #282 from orf/use-xdg
Use XDG paths to store Python history
2019-02-03 15:40:24 +01:00
Windel Bouwman
a7d011f9c7 Merge pull request #270 from ZapAnton/str_isdecimal
Added the isdecimal method to the 'str' class
2019-02-03 15:37:20 +01:00
Windel Bouwman
ac0ea87ead Merge pull request #271 from holygits/bitshift
Implement `__rshift__` and `__lshift__` for integer type
2019-02-03 15:35:50 +01:00
Windel Bouwman
00f86d1454 Merge pull request #288 from 11Takanori/fix-typo
Fix typo
2019-02-03 14:58:24 +01:00
Takanori Ishibashi
334d78704a distuingish -> distinguish 2019-02-03 21:41:04 +09:00
Windel Bouwman
3bc9232eeb Merge pull request #272 from ZapAnton/fix_readme_testing
README: Clarified the 'Testing' section
2019-02-03 12:27:56 +01:00
Windel Bouwman
cdcddcc6c6 Merge pull request #281 from chaconnewu/198
Use call_or_unsupported for operators.
2019-02-03 11:50:09 +01:00
Windel Bouwman
1d7149e131 Merge pull request #280 from HomerMcMillan/list-pop
Add list.pop
2019-02-03 11:49:01 +01:00
Tom Forbes
a72dbf1d0c Use XDG paths to store Python history 2019-02-03 10:07:50 +01:00
Windel Bouwman
38bf2dde3d Merge pull request #274 from skinny121/tuple_mul
Add tuple.__mul__
2019-02-03 08:05:20 +01:00
Windel Bouwman
37e9f98859 Merge pull request #277 from 0xflotus/patch-1
fixed small errors
2019-02-03 08:02:21 +01:00
Homer McMillan
7b27fbf369 Add list.pop
Also include IndexError in the __builtin__ module.
2019-02-03 00:49:52 -05:00
Yu Wu
561eb8ed4f Use call_or_unsupported for operators. 2019-02-02 21:47:28 -08:00
Homer McMillan
8852435a3d Run cargo fmt 2019-02-02 23:05:32 -05:00
Homer McMillan
2b74727783 Fix broken test 2019-02-02 22:41:34 -05:00
Homer McMillan
ea1a7bb395 Add list.{__lt__, __gt__, __le__, __ge__} 2019-02-02 22:04:26 -05:00
holygits
8854430651 Better error handling for file io
Add FileNotFoundError
Add PermissionError
Minor idomatic clean ups
2019-02-03 14:53:21 +13:00
0xflotus
167aefa829 Update builtins.md 2019-02-03 02:35:05 +01:00
0xflotus
dae5b146ff fixed converter 2019-02-03 02:30:58 +01:00
ben
8f9b733a77 Add tuple.__mul__ 2019-02-03 13:59:43 +13:00
holygits
e8d1e10226 Implement __rshift__ and __lshift__ for integer 2019-02-03 12:38:38 +13:00
ZapAnton
8558b84b16 README: Replaced the 'pipenv shell' and the 'pytest -v' commands with the single 'pipenv run pytest -v' command in the 'Testing' section 2019-02-03 02:19:59 +03:00
ZapAnton
b55150c7bd README: Added the 'pipenv install' command to the 'Testing' section 2019-02-03 02:15:57 +03:00
ZapAnton
23de5581bd Added tests for the isdecimal method 2019-02-03 02:05:57 +03:00
ZapAnton
46b939721f str: Added the isdecimal method 2019-02-03 01:51:47 +03:00
Michael Recachinas
e557ff290a Suppress warning and rename obj to _zelf in arg_check 2019-02-02 21:39:06 +00:00
Michael Recachinas
f0abcff53d Add int.__doc__ (addresses #261) 2019-02-02 21:37:49 +00:00
Michael Recachinas
e0b41d1386 Add bool.__doc__ (addresses #260) 2019-02-02 21:25:14 +00:00
ben
b13b4741ad Add tuple.__add__. Also stop rustfmt from trying to format generated parser. 2019-02-02 17:40:17 +13:00
coolreader18
f47864f0ac Return Ok(()) from destroy() 2019-01-31 16:33:11 -06:00
coolreader18
136a476cd8 Call assert_valid() in destroy() 2019-01-31 16:13:55 -06:00
coolreader18
b32b732abe Run cargo fmt 2019-01-30 14:35:00 -06:00
coolreader18
d0a4f9d7f5 Make destroy() method public 2019-01-30 12:40:08 -06:00
coolreader18
f064bcaf57 Add ids() function to VMStore and destroy() method to VirtualMachine 2019-01-30 12:33:32 -06:00
coolreader18
13b2f83084 Fix vms.get() 2019-01-30 12:30:56 -06:00
coolreader18
4020ee7d41 Add a bare-bones VirtualMachine class to the WASM library 2019-01-30 12:18:59 -06:00
Windel Bouwman
328f81a28e Merge pull request #266 from coolreader18/format-mk-module
Format module building in a more readable way
2019-01-30 18:09:17 +01:00
Windel Bouwman
892493e464 Rename PyObjectKind into PyObjectPayload 2019-01-30 18:06:27 +01:00
coolreader18
37b5669bed Fix syntax error 2019-01-30 10:13:55 -06:00
coolreader18
f193291471 Merge branch 'master' into format-mk-module 2019-01-30 10:09:47 -06:00
Windel Bouwman
31523fe4d7 Merge pull request #265 from rmliddle/implement-io
File-IO: IO Module and Open Builtin
2019-01-29 20:43:28 +01:00
rmliddle
deb0688a99 Changed buffer imp. to use type + removed ByteArray Kind 2019-01-29 18:40:40 +11:00
coolreader18
e9bfea834a Format module building in a more readable way 2019-01-28 23:02:43 -06:00
Windel Bouwman
d627230434 Merge pull request #263 from coolreader18/string-str
Remove unnecessary to_string conversions
2019-01-28 20:38:54 +01:00
Windel Bouwman
d365563010 Merge pull request #264 from coolreader18/fix-trim-warnings
Fix warnings from using trim_left and trim_right
2019-01-28 20:36:06 +01:00
rmliddle
0ee535e49a Removed append + create 2019-01-28 20:14:19 +11:00
rmliddle
3ce9972c9c removed os.O_NONBLOCK from snippet 2019-01-28 20:07:57 +11:00
rmliddle
507f7bdca9 Fix for os open (optional params not allowed) 2019-01-28 19:38:06 +11:00
rmliddle
c011db2819 fmt w/nightly 2019-01-28 19:21:27 +11:00
rmliddle
7b23d0e917 rust fmt 2019-01-28 18:54:50 +11:00
rmliddle
9a86bbd718 ByteArray Usage 2019-01-28 18:30:19 +11:00
coolreader18
989357fe81 Fix warnings from using trim_left and trim_right 2019-01-27 23:02:27 -06:00
coolreader18
5ecff1b37e Remove unnecessary to_string conversions 2019-01-27 21:45:21 -06:00
rmliddle
c2e73cc829 Test Snippets for buffered_read, open builtin 2019-01-23 19:16:03 +11:00
rmliddle
9efc68efcb Generalized Mode Handling 2019-01-22 21:59:10 +11:00
rmliddle
dda3d7ffb7 Bug fix for sequential Writes, New File Writes 2019-01-21 20:03:36 +11:00
rmliddle
3845e23881 -Logging length in FileIO write, +Bytes to String in TextIOBase 2019-01-19 14:13:12 +11:00
rmliddle
b54738978a Remaining IO open classes: TextBaseIO, TextWrapperIO 2019-01-17 21:20:31 +11:00
rmliddle
30165f6c8a open builtin 2019-01-16 20:16:56 +11:00
rmliddle
edc720e79f Buffered Objects for Open 2019-01-14 20:32:27 +11:00
rmliddle
2bbd4fd18f BufferedIOBase Read 2019-01-13 10:54:47 +11:00
Windel Bouwman
ade4c88d90 Merge pull request #256 from RustPython/fix-deployment-again
Fix the deploy condition for missing spaces around equals sign
2019-01-12 22:44:38 +01:00
Windel Bouwman
e41b9179f5 Merge pull request #254 from RustPython/list_index
Added list.index()
2019-01-12 10:25:42 +01:00
Shing Lyu
83f05c6448 Fix the deploy condition for missing spaces around equals sign 2019-01-10 22:09:33 +01:00
Shing Lyu
5e8eb8a001 Added list.index() 2019-01-10 22:01:42 +01:00
Windel Bouwman
ce36919fe3 Merge pull request #255 from adamchainz/patch-1
Update example
2019-01-10 20:27:51 +01:00
Adam Johnson
32a58f8897 Update example
Improve spelling, grammar, and HTML a bit on the example page.
2019-01-10 14:07:08 +00:00
Windel Bouwman
cab2e0d076 Merge pull request #250 from RustPython/fix-deploymnet
Limit the deployment only to the specific build job
2019-01-09 16:36:46 +01:00
rmliddle
5e1324fd23 os modes 2019-01-09 20:56:08 +11:00
Shing Lyu
7c8ebee43b Limit the deployment only to the specfic build job 2019-01-08 22:37:31 +01:00
rmliddle
9041129bb8 read_into on FileIO 2019-01-08 18:10:35 +11:00
rmliddle
6deb71d84f os.open impl 2019-01-08 12:14:43 +11:00
rmliddle
dc6238bb0c __offset__ workaround 2019-01-05 21:38:33 +11:00
rmliddle
b783657477 file_io_readinto implementation for fixed length buffer reads 2019-01-04 19:35:33 +11:00
rmliddle
15d0c39c81 fixes to bytearray len 2019-01-04 19:34:28 +11:00
Windel Bouwman
6d0a25fb1c Merge pull request #248 from coolreader18/dockerfile
Create dockerfiles for the rustpython binary and wasm demo
2019-01-03 19:26:38 +01:00
coolreader18
3e3d28fa1d Create dockerfiles for the rustpython binary and wasm demo 2019-01-02 18:57:27 -06:00
rmliddle
cbd8d7b171 len attributes on byte types 2019-01-03 08:16:04 +11:00
Windel Bouwman
a28b665396 Merge pull request #246 from rmliddle/bytes-representation
Bytes representation changed from hex to utf-8
2019-01-02 22:07:21 +01:00
rmliddle
3d6742a9e8 change to bytes repr 2019-01-02 21:25:48 +11:00
rmliddle
278e1a8298 method name change for fileio 2019-01-02 13:41:12 +11:00
rmliddle
08a9fd9819 memoryview object, FileIO Methods 2019-01-01 23:39:21 +11:00
Windel Bouwman
d508d130b6 Merge pull request #235 from xrmx/stringconstants
Implement most string module constants
2018-12-29 15:29:28 +01:00
Windel Bouwman
d425c26763 Merge pull request #245 from coolreader18/final-demo-improvements
Final demo improvements
2018-12-29 15:28:26 +01:00
coolreader18
231e3f2f16 Export PyEvalOptions in typescript defs 2018-12-28 21:57:41 -06:00
coolreader18
e65639f61a Remove yarn.lock 2018-12-28 21:43:13 -06:00
coolreader18
d7fdc5c177 Fix typescript hack 2018-12-28 14:42:43 -06:00
coolreader18
36997e12d9 Comment out WB's TS definitions using a hack 2018-12-28 14:35:45 -06:00
coolreader18
1d5df4130a Add doc comments and typescript custom section 2018-12-27 22:31:15 -06:00
coolreader18
b2772804f2 Add README and manifest fields for the WASM library 2018-12-27 21:06:59 -06:00
coolreader18
4cc7f5aa9c Merge #console and #code styles 2018-12-27 20:43:09 -06:00
coolreader18
1f02cc0fa3 Squash all demo commits onto one branch 2018-12-27 20:28:12 -06:00
Riccardo Magliocchetti
e4ca1655e9 Implement most string module constants
whitespace and thus printable are excluded because i haven't found
a way to make tests pass.
2018-12-27 23:48:11 +01:00
Windel Bouwman
4c5b5845bb Merge pull request #244 from coolreader18/boxed-rustfunc
Change RustPyFunc from a fn pointer to a Fn trait
2018-12-27 20:23:22 +01:00
AgentMacklin
79a3b13252 Implement most of the string methods. (#239)
* implemented more functions

* backup

* Improve demo site

* Formatting; move the `+ '\n'` hack to eval().

* Rename run_code() to run_from_textbox()

* Switch to using json.dumps for py_to_js()

* Clarify names of wasm builtins

* Remove dependency on num_bigint

* Allow injecting JS variables into python with eval_py()

eval_py(`return js_vars["a"]`, { a: 9 }) == 9

* dict() now should work properly

e.g.
``` dict(a=2, b=3) == {"a": 2, "b": 3} ```

* Add documentation for eval_py() and update error message handling

Also, switch from iterating over the values of js_injections and
serializing each of them individually to asserting it's an object and
then just stringifying the whole thing.

* Finish revamping `dict_new()`

* Add 'from x import *' syntax.

This is a separate opcode in CPython so I added it as such here.

* Add test for dicts

* added functions

* ran rustfmt and fixed isidentifier

* fixed zfill and make_title

* python3.6 doesn't contain isascii()
2018-12-27 20:22:04 +01:00
coolreader18
8303743aab Remove RustPyFunc trait, just use Fn(..) everywhere 2018-12-27 11:50:14 -06:00
coolreader18
09602a2ec6 Change RustPyFunc from a fn pointer to a Fn trait 2018-12-27 09:18:00 -06:00
Windel Bouwman
f325ef1499 Merge pull request #240 from coolreader18/json-error
Have the json ser/de functions throw an exception instead of panicking
2018-12-27 09:20:52 +01:00
Windel Bouwman
978e7eabe3 Merge pull request #241 from coolreader18/formatted-exceptions
Format exceptions nicely (no more RefCell { value: .. }!)
2018-12-27 09:14:35 +01:00
coolreader18
8fee5a8800 Run cargo fmt --all 2018-12-27 00:12:08 -06:00
coolreader18
396842ef9d Readd conflicting files 2018-12-27 00:04:20 -06:00
coolreader18
dfadd03f95 Remove (now outdated) previously conflicting files 2018-12-27 00:02:33 -06:00
coolreader18
ada92d33a3 Add conflicting files 2018-12-27 00:01:20 -06:00
coolreader18
2968982a8f Change README portion for compiling wasm 2018-12-26 23:51:28 -06:00
coolreader18
877206dc47 Switch from shell to npm scripts for demo using webpack and @wasm-tool/wasm-pack-plugin
Also change travis deploy to use new demo directory.
2018-12-26 23:34:51 -06:00
coolreader18
0ac0432a53 Run cargo fmt 2018-12-26 18:23:40 -06:00
coolreader18
80573b0544 Format PyObject's correctly and nicely 2018-12-26 18:09:49 -06:00
coolreader18
d1a584f0fd Don't allocate a new string for each new type for the ExceptionZoo 2018-12-26 14:19:19 -06:00
coolreader18
a77b7e0ce4 Have json.* throw an exception instead of panicking 2018-12-26 14:18:15 -06:00
coolreader18
c38796bb49 Add some documentation for functions on the demo site 2018-12-26 13:25:56 -06:00
coolreader18
94d6a91873 Fix js_to_py with JS undefined 2018-12-26 13:21:29 -06:00
coolreader18
e0959b9384 Implement error conversion for js_to_py 2018-12-26 11:21:45 -06:00
coolreader18
132930ec82 Allow passing closures from JS to python via vars 2018-12-26 01:59:15 -06:00
coolreader18
63b3f3e71b Fix blanket impl of RustPyFunc 2018-12-24 15:51:54 -06:00
coolreader18
d1d958516d Change the instances of Fn(..) -> PyResult to a RustPyFunc trait alias 2018-12-24 15:45:45 -06:00
coolreader18
ffcd40b435 Remove conflicting files 2018-12-24 15:35:50 -06:00
coolreader18
24507de3b1 Re-add conflicting files 2018-12-24 15:34:52 -06:00
coolreader18
ab23f2c940 Use str.format for the demo 2018-12-24 15:28:49 -06:00
coolreader18
840c5072fb Improve UX for demo 2018-12-24 15:28:49 -06:00
coolreader18
d54d2b1c03 Make scripts executable 2018-12-24 15:28:49 -06:00
coolreader18
2ea9dca40c Add example, change some stuff in the demo to align with example 2018-12-24 15:28:49 -06:00
coolreader18
ca30ebcf5d Genericize the wasm lib to not be specifically for the demo
This included changing RustObjectKind::RustFunction.function to be
a `Box<Fn()>` instead of a `fn()` to support closures.
2018-12-24 15:28:49 -06:00
coolreader18
4c32693c7b Switch to using one workspace, move profile to root Cargo.toml 2018-12-24 15:28:49 -06:00
Windel Bouwman
946df53077 Merge pull request #237 from johndaniels/add-star-import
Add 'from x import *' syntax.
2018-12-23 17:55:34 +01:00
Gitea
ac3da8b453 Add 'from x import *' syntax.
This is a separate opcode in CPython so I added it as such here.
2018-12-22 22:40:02 -05:00
Windel Bouwman
366f3e2b13 Merge pull request #236 from coolreader18/proper-dict
Make `dict()` work like it does in cpython
2018-12-22 16:05:31 +01:00
coolreader18
427ce4347e Add test for dicts 2018-12-22 00:04:13 -06:00
coolreader18
f1784236af Finish revamping dict_new() 2018-12-21 23:35:45 -06:00
Shing Lyu
71ba5019bf Merge pull request #230 from coolreader18/master
Improve wasm demo website
2018-12-21 16:22:34 +01:00
coolreader18
e77f223538 Add documentation for eval_py() and update error message handling
Also, switch from iterating over the values of js_injections and
serializing each of them individually to asserting it's an object and
then just stringifying the whole thing.
2018-12-18 19:03:04 -06:00
coolreader18
03c619f79e Rearrange website directory and change webpack config 2018-12-18 18:22:30 -06:00
coolreader18
bdc80dc75b dict() now should work properly
e.g.
``` dict(a=2, b=3) == {"a": 2, "b": 3} ```
2018-12-18 01:34:00 -06:00
Windel Bouwman
950dbd1a77 Use new_list when constructing multiplied list. 2018-12-17 12:14:29 +01:00
Windel Bouwman
bbe333d6c7 Merge pull request #233 from rossjones/232-impl-mul-for-list
Implements __mul__ for lists
2018-12-17 11:55:44 +01:00
Windel Bouwman
8aaadb16c0 Merge pull request #234 from johndaniels/indentation
Handle mixed spaces and tabs.
2018-12-17 11:55:20 +01:00
Windel Bouwman
1b13b0c4e2 Merge pull request #231 from johndaniels/format
Add format builtin and String formatting stuff.
2018-12-17 11:50:14 +01:00
Gitea
9468b657d2 Run cargo fmt. 2018-12-16 17:40:25 -05:00
Gitea
c74cd90d8e Handle mixed spaces and tabs.
This allows the parser to handle tabs and spaces. Currently it
requires that spaces come after any tabs, which is slightly more
strict than python3. It also requires that neighboring indentation
levels have either both more spaces and tabs or less spaces and
tabs so that tab size can't make perception of indentation
differ from what the parser interprets.

I didn't opt to implement PartialOrd on IndentationLevel because I
wasn't sure that the comparison logic would meet the logical
requirements for that trait. One could easily switch to having it
implement PartialOrd though. This would necessitate switching to
manually implementing PartialEq so that it's behavior 'matches'.
It's unclear from the docs what 'matches' exactly means so for
now I'm avoiding implementing the traits.
2018-12-16 17:11:37 -05:00
Gitea
95d4073dd8 Add newline to end of file.
The parser currently doesn't handle missing newline gracefully.
2018-12-16 16:21:40 -05:00
Gitea
a6288acd22 Cargo format. 2018-12-16 15:48:59 -05:00
Gitea
bbe4844f6c Fix snippet to not use tab.
We should add support for '\t', but that should probably be a separate ticket.
2018-12-16 15:43:07 -05:00
Ross Jones
ae2f7ed1cb Implements __mul__ for lists
Implements __mul__ for lists so that it is possible to do things like

```
s = [1, 2,] * 3
s == [1, 2, 1, 2, 1, 2]
```
2018-12-16 12:22:31 +00:00
Gitea
b726e675ff Add format builtin and String formatting stuff.
This includes everything needed to call str.format with integers
as positional and keyword parameters.
2018-12-15 19:46:09 -05:00
coolreader18
a796b134a5 Allow injecting JS variables into python with eval_py()
eval_py(`return js_vars["a"]`, { a: 9 }) == 9
2018-12-15 12:20:03 -06:00
coolreader18
e78a25132e Remove dependency on num_bigint 2018-12-15 11:38:08 -06:00
coolreader18
3be6fee737 Clarify names of wasm builtins 2018-12-15 11:36:53 -06:00
coolreader18
921efd4d14 Switch to using json.dumps for py_to_js() 2018-12-15 11:33:37 -06:00
coolreader18
2ae1df590e Rename run_code() to run_from_textbox() 2018-12-15 01:41:25 -06:00
coolreader18
f8cce25f69 Formatting; move the + '\n' hack to eval(). 2018-12-15 01:31:44 -06:00
coolreader18
b428f2e3b3 Improve demo site 2018-12-15 00:49:47 -06:00
Windel Bouwman
62c53d8e5d Try to make it simpler to switch dict storage types. 2018-12-13 20:38:09 +01:00
Windel Bouwman
521f664e16 Merge pull request #229 from AgentMacklin/master
Added some of the missing str methods
2018-12-13 20:31:45 +01:00
Austen LeBeau
7ac22d96d1 update and added more functions 2018-12-13 12:02:18 -06:00
Windel Bouwman
a29e882bc1 Store dict key as pyobject into hashmap. 2018-12-13 17:05:01 +01:00
Windel Bouwman
e657633e51 Move set_item to context struct. 2018-12-12 22:27:28 +01:00
Windel Bouwman
4095e0cad7 Modify location of set_attr so that we are able to create str python objects for the dictionary. 2018-12-12 22:06:19 +01:00
Windel Bouwman
31f50eda3d Merge pull request #226 from RustPython/demo-error
[WASM] Catch errors and show it in the standard output textarea
2018-12-12 20:01:31 +01:00
Windel Bouwman
0215830aaa Move set_attr and set_item to context. 2018-12-12 19:41:09 +01:00
Austen LeBeau
dd2b4e3c25 added isalnum, isalpha, isdigit, swapcase 2018-12-12 12:01:35 -06:00
Windel Bouwman
5c04ad8aae Make underlying dict type more hidden. 2018-12-12 15:13:40 +01:00
Austen LeBeau
07336fa984 initial fork commit 2018-12-11 22:44:56 -06:00
Shing Lyu
6021fca8cd [WASM] Print the Rust panic to the output textarea 2018-12-11 21:50:25 +01:00
Shing Lyu
fabc67985a Make the run button bigger so it doesn't overflow 2018-12-11 21:38:02 +01:00
Windel Bouwman
95092be36d Merge pull request #225 from RustPython/test-demo
Fixed the travis build for deploying the demo page
2018-12-11 20:22:13 +01:00
Shing Lyu
0159051e95 Updated README about WASM build 2018-12-10 23:13:54 +01:00
Shing Lyu
13a9922d93 Fix the demo page travis build 2018-12-10 23:07:15 +01:00
Windel Bouwman
b46fc938d4 Merge pull request #224 from RustPython/readme-demo
Update README, adding demo and instruction for how to update doc
2018-12-10 22:18:37 +01:00
Shing Lyu
160cfe6155 Added link to online demo in README 2018-12-10 21:58:43 +01:00
Windel Bouwman
8345acc402 Change rustfmt check to stable. 2018-12-10 21:33:23 +01:00
Shing Lyu
bb4454912e Added instruction on updating online doc and demo page 2018-12-10 20:45:12 +01:00
Windel Bouwman
69d21e0ebb Merge pull request #222 from RustPython/wasm-output-pure-rs
[WASM] Print STDOUT to textarea on the demo page
2018-12-09 22:13:00 +01:00
Shing Lyu
b2aa7ac2fb [WASM] Changed the demo to fibonacci calculation 2018-12-09 21:35:23 +01:00
Shing Lyu
3e231620cd [WASM] Print STDOUT to textarea in HTML 2018-12-09 21:35:23 +01:00
Windel Bouwman
f8f9fa7fd0 Merge pull request #217 from RustPython/travis-demo
CI build and deploy demo page on master branch
2018-12-07 10:15:50 +01:00
Shing Lyu
b5c1990267 CI build and deploy demo page on master branch 2018-12-06 20:35:53 +01:00
Windel Bouwman
351a61f2b3 Merge pull request #216 from RustPython/forkme
Added fork me on github ribbon to demo page
2018-12-05 11:30:58 +01:00
Windel Bouwman
34a60ce6a2 Merge pull request #218 from RustPython/stabledoc
Use stable rust to build documentation
2018-12-05 11:30:38 +01:00
Shing Lyu
41d5dc52eb Use stable rust to build documentation 2018-12-04 21:15:51 +01:00
Shing Lyu
71ea9b8f16 Added fork me on github ribbon to demo page 2018-12-04 20:58:00 +01:00
Windel Bouwman
fa89e8803c Merge pull request #214 from RustPython/online-demo
Created a demo page so user can try their code online
2018-12-04 09:12:07 +01:00
Windel Bouwman
30bb111b1a Merge pull request #208 from RustPython/travis-fix
Limit the gh-pages deployment step to only nightly build
2018-12-04 09:01:16 +01:00
Shing Lyu
8d78c67d0b Created a demo page so user can try their code online 2018-12-03 20:49:26 +01:00
Shing Lyu
5734fc29ca Merge pull request #203 from RustPython/consolelog
Mapping Python print to JavaScript console.log
2018-12-03 20:48:43 +01:00
Shing Lyu
03911d98d7 Limit the gh-pages deployment step to only nightly build 2018-12-03 20:03:05 +01:00
Shing Lyu
2c55c4793e [WASM] Mapping print to console.log 2018-12-03 19:51:48 +01:00
Windel Bouwman
8eacbcbc06 Add builtins to sys.modules. Add __float__ method to int class. 2018-11-26 22:31:40 +01:00
Windel Bouwman
f227ce0498 Add random module 2018-11-25 23:20:10 +01:00
Windel Bouwman
eb51007993 Merge pull request #206 from RustPython/travis-branch
Push website to the master branch to simplify website development
2018-11-25 22:18:14 +01:00
Windel Bouwman
1b4b157a2d Merge pull request #207 from yodalee/math-implementation-with-statrs
Math implementation with statrs
2018-11-25 22:05:41 +01:00
yodalee
68892fb4e2 fix rustfmt 2018-11-25 22:13:26 +08:00
yodalee
04548db1e0 add implementation of special math function
function include: erf, erfc, gamma, lgamma
use package statrs' implementation
2018-11-25 20:10:34 +08:00
Windel Bouwman
ee2fb20f96 Merge pull request #205 from RustPython/readme-update
Added link to documentation in README
2018-11-24 12:05:52 +01:00
Shing Lyu
de61b1c685 Push website to the master branch to simplify website development 2018-11-24 10:43:56 +01:00
Shing Lyu
51271e5000 Added link to documentation in README 2018-11-24 10:37:19 +01:00
Windel Bouwman
a8fb2f3754 Merge pull request #204 from RustPython/travis-doc
Auto build and deploy documentation to website repo
2018-11-23 18:32:44 +01:00
Shing Lyu
023e6119c4 Auto build and deploy documentation to website repo 2018-11-23 11:51:39 +01:00
Windel Bouwman
083eb977ad Merge pull request #202 from RustPython/cleanup
Removed unused wasm/src/main.rs file
2018-11-22 21:37:32 +01:00
Shing Lyu
c1ab263258 Removed unused wasm/src/main.rs file 2018-11-20 21:50:17 +01:00
Windel Bouwman
be462afaa4 Add method to list and tuple class. 2018-11-17 12:31:24 +01:00
Windel Bouwman
a17fb3f4d0 Merge pull request #197 from BojanKogoj/bojan/vm-call_or_unsupported
WIP: Added call_or_unsupported to vm.rs
2018-11-17 09:07:19 +01:00
Shing Lyu
cd3429ce4d Merge pull request #193 from RustPython/readme-typo
Fixed wasm-bindgen typo in README
2018-11-16 14:44:00 +01:00
Bojan
0da1f73777 Removed empty space 2018-11-16 07:49:12 +01:00
Bojan
d972b07195 Fixed method comment 2018-11-15 23:47:11 +01:00
Bojan
f9860d083e Moved and to use new method 2018-11-15 23:42:17 +01:00
Bojan
15c6328ecd Moved sub to use new method 2018-11-15 23:42:03 +01:00
Bojan
05d2faa227 Added call_or_unsupported to vm.rs
This is to prevent code duplication
2018-11-15 23:37:46 +01:00
Shing Lyu
bbdef3d8c8 Merge pull request #194 from RustPython/wasm-doc
Updated the wasm installation instruction
2018-11-15 16:57:07 +01:00
Shing Lyu
1a0677ab44 Updated the wasm installation instruction 2018-11-15 00:25:22 +01:00
Shing Lyu
2939e53717 Fixed wasm typos in README 2018-11-14 23:43:44 +01:00
201 changed files with 16882 additions and 4381 deletions

2
.dockerignore Normal file
View File

@@ -0,0 +1,2 @@
target
**/node_modules

4
.gitignore vendored
View File

@@ -1,8 +1,10 @@
/target /target
wasm/target
**/*.rs.bk **/*.rs.bk
**/*.bytecode **/*.bytecode
__pycache__ __pycache__
**/*.pytest_cache **/*.pytest_cache
.*sw* .*sw*
.repl_history.txt .repl_history.txt
.vscode
wasm-pack.log
.idea/

View File

@@ -1,4 +1,3 @@
language: rust language: rust
rust: rust:
@@ -7,60 +6,140 @@ rust:
- nightly - nightly
script: script:
- cargo build --verbose --all - cargo build --verbose --all
- cargo test --verbose --all - cargo test --verbose --all
env: env:
# This is used to only capture the regular nightly test in allow_failures # This is used to only capture the regular nightly test in allow_failures
- REGULAR_TEST=true - REGULAR_TEST=true
cache: cargo cache: cargo
matrix: matrix:
include: fast_finish: true
# To test the snippets, we use Travis' Python environment (because include:
# installing rust ourselves is a lot easier than installing Python) # To test the snippets, we use Travis' Python environment (because
- language: python # installing rust ourselves is a lot easier than installing Python)
python: 3.6 - language: python
cache: python: 3.6
pip: true cache:
# Because we're using the Python Travis environment, we can't use pip: true
# the built-in cargo cacher # Because we're using the Python Travis environment, we can't use
directories: # the built-in cargo cacher
- /home/travis/.cargo directories:
- target - /home/travis/.cargo
env: - target
- TRAVIS_RUST_VERSION=stable env:
- REGULAR_TEST=false - TRAVIS_RUST_VERSION=stable
script: tests/.travis-runner.sh - REGULAR_TEST=false
- language: python - CODE_COVERAGE=false
python: 3.6 script: tests/.travis-runner.sh
cache: - language: python
pip: true python: 3.6
# Because we're using the Python Travis environment, we can't use cache:
# the built-in cargo cacher pip: true
directories: # Because we're using the Python Travis environment, we can't use
- /home/travis/.cargo # the built-in cargo cacher
- target directories:
env: - /home/travis/.cargo
- TRAVIS_RUST_VERSION=beta - target
- REGULAR_TEST=false env:
script: tests/.travis-runner.sh - TRAVIS_RUST_VERSION=beta
- name: rustfmt - REGULAR_TEST=false
language: rust - CODE_COVERAGE=false
rust: nightly script: tests/.travis-runner.sh
cache: cargo - name: rustfmt
before_script: language: rust
- rustup component add rustfmt-preview rust: stable
script: cache: cargo
# Code references the generated python.rs, so put something in before_script:
# place to make `cargo fmt` happy. (We use `echo` rather than - rustup component add rustfmt-preview
# `touch` because rustfmt complains about the empty file touch script:
# creates.) # Code references the generated python.rs, so put something in
- echo > parser/src/python.rs # place to make `cargo fmt` happy. (We use `echo` rather than
- cargo fmt --all -- --check # `touch` because rustfmt complains about the empty file touch
env: # creates.)
- REGULAR_TEST=false - echo > parser/src/python.rs
allow_failures: - cargo fmt --all -- --check
- rust: nightly env:
env: REGULAR_TEST=true - REGULAR_TEST=false
- name: publish documentation
language: rust
rust: stable
cache: cargo
script:
- cargo doc --no-deps --all
if: branch = release
env:
- REGULAR_TEST=false
- DEPLOY_DOC=true
- name: WASM online demo
language: rust
rust: nightly
cache: cargo
install:
- nvm install node
# install wasm-pack
- curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
script:
- cd wasm/demo
- npm install
- npm run dist
if: branch = release
env:
- REGULAR_TEST=false
- DEPLOY_DEMO=true
- name: cargo-clippy
language: rust
rust: stable
cache: cargo
before_script:
- rustup component add clippy
script:
- cargo clippy
env:
- REGULAR_TEST=true
- name: Code Coverage
language: python
python: 3.6
cache:
pip: true
# Because we're using the Python Travis environment, we can't use
# the built-in cargo cacher
directories:
- /home/travis/.cargo
- target
script:
- tests/.travis-runner.sh
env:
- TRAVIS_RUST_VERSION=nightly
- REGULAR_TEST=false
- CODE_COVERAGE=true
allow_failures:
- rust: nightly
env: REGULAR_TEST=true
- name: cargo-clippy
deploy:
- provider: pages
repo: RustPython/website
target-branch: master
local-dir: target/doc
skip-cleanup: true
# Set in the settings page of your repository, as a secure variable
github-token: $WEBSITE_GITHUB_TOKEN
keep-history: true
on:
branch: release
condition: $DEPLOY_DOC = true
- provider: pages
repo: RustPython/demo
target-branch: master
local-dir: wasm/demo/dist
skip-cleanup: true
# Set in the settings page of your repository, as a secure variable
github-token: $WEBSITE_GITHUB_TOKEN
keep-history: true
on:
branch: release
condition: $DEPLOY_DEMO = true

405
Cargo.lock generated
View File

@@ -1,3 +1,5 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
[[package]] [[package]]
name = "aho-corasick" name = "aho-corasick"
version = "0.6.4" version = "0.6.4"
@@ -131,6 +133,15 @@ name = "byteorder"
version = "1.2.6" version = "1.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "caseless"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"regex 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-normalization 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]] [[package]]
name = "cc" name = "cc"
version = "1.0.25" version = "1.0.25"
@@ -155,6 +166,14 @@ dependencies = [
"vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]]
name = "cloudabi"
version = "0.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]] [[package]]
name = "constant_time_eq" name = "constant_time_eq"
version = "0.1.3" version = "0.1.3"
@@ -188,7 +207,7 @@ name = "docopt"
version = "0.8.3" version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"lazy_static 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"regex 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "regex 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -213,10 +232,22 @@ dependencies = [
"atty 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", "atty 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
"humantime 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "humantime 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
"regex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
"termcolor 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "termcolor 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]]
name = "env_logger"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"atty 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
"humantime 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
"regex 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
"termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]] [[package]]
name = "failure" name = "failure"
version = "0.1.2" version = "0.1.2"
@@ -261,6 +292,11 @@ name = "fuchsia-zircon-sys"
version = "0.3.3" version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "futures"
version = "0.1.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "generic-array" name = "generic-array"
version = "0.9.0" version = "0.9.0"
@@ -269,6 +305,14 @@ dependencies = [
"typenum 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "typenum 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]]
name = "heck"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"unicode-segmentation 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]] [[package]]
name = "humantime" name = "humantime"
version = "1.1.1" version = "1.1.1"
@@ -290,6 +334,14 @@ name = "itoa"
version = "0.4.2" version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "js-sys"
version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"wasm-bindgen 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]] [[package]]
name = "kernel32-sys" name = "kernel32-sys"
version = "0.2.2" version = "0.2.2"
@@ -352,9 +404,29 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "lazy_static" name = "lazy_static"
version = "1.0.1" version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "lexical"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cfg-if 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"lexical-core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "lexical-core"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cfg-if 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
"stackvector 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"static_assertions 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]] [[package]]
name = "libc" name = "libc"
version = "0.2.42" version = "0.2.42"
@@ -409,6 +481,14 @@ name = "nodrop"
version = "0.1.12" version = "0.1.12"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "nom"
version = "4.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"memchr 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]] [[package]]
name = "num-bigint" name = "num-bigint"
version = "0.2.1" version = "0.2.1"
@@ -434,6 +514,16 @@ dependencies = [
"num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]]
name = "num-rational"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"num-bigint 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"num-integer 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]] [[package]]
name = "num-traits" name = "num-traits"
version = "0.2.6" version = "0.2.6"
@@ -522,6 +612,31 @@ dependencies = [
"winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]]
name = "rand"
version = "0.5.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
"fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_core 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "rand_core"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "rand_core"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "redox_syscall" name = "redox_syscall"
version = "0.1.40" version = "0.1.40"
@@ -554,19 +669,19 @@ dependencies = [
"aho-corasick 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", "aho-corasick 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)",
"memchr 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "memchr 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"regex-syntax 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", "regex-syntax 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)",
"thread_local 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"utf8-ranges 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "utf8-ranges 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
name = "regex" name = "regex"
version = "1.0.0" version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"aho-corasick 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", "aho-corasick 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)",
"memchr 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "memchr 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"regex-syntax 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "regex-syntax 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"thread_local 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"utf8-ranges 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "utf8-ranges 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
@@ -596,9 +711,26 @@ name = "rustc-demangle"
version = "0.1.9" version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "rustc_version"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "rustc_version_runtime"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
"semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]] [[package]]
name = "rustpython" name = "rustpython"
version = "0.0.1" version = "0.0.1-pre-alpha.1"
dependencies = [ dependencies = [
"clap 2.31.2 (registry+https://github.com/rust-lang/crates.io-index)", "clap 2.31.2 (registry+https://github.com/rust-lang/crates.io-index)",
"env_logger 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -606,6 +738,7 @@ dependencies = [
"rustpython_parser 0.0.1", "rustpython_parser 0.0.1",
"rustpython_vm 0.1.0", "rustpython_vm 0.1.0",
"rustyline 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustyline 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"xdg 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
@@ -626,15 +759,39 @@ version = "0.1.0"
dependencies = [ dependencies = [
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"byteorder 1.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
"caseless 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"lexical 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
"num-bigint 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "num-bigint 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"num-complex 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "num-complex 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"num-integer 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)",
"num-rational 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
"regex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)",
"regex 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc_version_runtime 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"rustpython_parser 0.0.1", "rustpython_parser 0.0.1",
"serde 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)",
"statrs 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-segmentation 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "rustpython_wasm"
version = "0.1.0"
dependencies = [
"cfg-if 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)",
"js-sys 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
"rustpython_parser 0.0.1",
"rustpython_vm 0.1.0",
"wasm-bindgen 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)",
"wasm-bindgen-futures 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"web-sys 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
@@ -655,7 +812,7 @@ dependencies = [
[[package]] [[package]]
name = "ryu" name = "ryu"
version = "0.2.5" version = "0.2.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
@@ -663,6 +820,19 @@ name = "scoped_threadpool"
version = "0.1.9" version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "semver"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "semver-parser"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "serde" name = "serde"
version = "1.0.66" version = "1.0.66"
@@ -684,7 +854,7 @@ version = "1.0.26"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"itoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "itoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
"ryu 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
@@ -704,12 +874,38 @@ name = "siphasher"
version = "0.2.2" version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "sourcefile"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "stackvector"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "static_assertions"
version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "statrs"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]] [[package]]
name = "string_cache" name = "string_cache"
version = "0.7.3" version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"lazy_static 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"new_debug_unreachable 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "new_debug_unreachable 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"phf_shared 0.7.22 (registry+https://github.com/rust-lang/crates.io-index)", "phf_shared 0.7.22 (registry+https://github.com/rust-lang/crates.io-index)",
"precomputed-hash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "precomputed-hash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -755,6 +951,16 @@ dependencies = [
"unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]]
name = "syn"
version = "0.15.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]] [[package]]
name = "synstructure" name = "synstructure"
version = "0.9.0" version = "0.9.0"
@@ -783,6 +989,14 @@ dependencies = [
"wincolor 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "wincolor 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]]
name = "termcolor"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"wincolor 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]] [[package]]
name = "termion" name = "termion"
version = "1.5.1" version = "1.5.1"
@@ -803,11 +1017,10 @@ dependencies = [
[[package]] [[package]]
name = "thread_local" name = "thread_local"
version = "0.3.5" version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"lazy_static 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
@@ -820,6 +1033,11 @@ name = "ucd-util"
version = "0.1.1" version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "unicode-normalization"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "unicode-segmentation" name = "unicode-segmentation"
version = "1.2.1" version = "1.2.1"
@@ -863,6 +1081,99 @@ name = "void"
version = "1.0.2" version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "wasm-bindgen"
version = "0.2.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"wasm-bindgen-macro 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "wasm-bindgen-backend"
version = "0.2.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
"proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.15.23 (registry+https://github.com/rust-lang/crates.io-index)",
"wasm-bindgen-shared 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "wasm-bindgen-futures"
version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)",
"js-sys 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"wasm-bindgen 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "wasm-bindgen-macro"
version = "0.2.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"quote 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)",
"wasm-bindgen-macro-support 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "wasm-bindgen-macro-support"
version = "0.2.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.15.23 (registry+https://github.com/rust-lang/crates.io-index)",
"wasm-bindgen-backend 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)",
"wasm-bindgen-shared 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "wasm-bindgen-shared"
version = "0.2.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "wasm-bindgen-webidl"
version = "0.2.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"failure 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"heck 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
"proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.15.23 (registry+https://github.com/rust-lang/crates.io-index)",
"wasm-bindgen-backend 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)",
"weedle 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "web-sys"
version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"env_logger 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"failure 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"js-sys 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"sourcefile 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
"wasm-bindgen 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)",
"wasm-bindgen-webidl 0.2.23 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "weedle"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"nom 4.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]] [[package]]
name = "winapi" name = "winapi"
version = "0.2.8" version = "0.2.8"
@@ -887,6 +1198,14 @@ name = "winapi-i686-pc-windows-gnu"
version = "0.4.0" version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "winapi-util"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]] [[package]]
name = "winapi-x86_64-pc-windows-gnu" name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0" version = "0.4.0"
@@ -900,6 +1219,20 @@ dependencies = [
"winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]]
name = "wincolor"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "xdg"
version = "2.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[metadata] [metadata]
"checksum aho-corasick 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d6531d44de723825aa81398a6415283229725a00fa30713812ab9323faa82fc4" "checksum aho-corasick 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d6531d44de723825aa81398a6415283229725a00fa30713812ab9323faa82fc4"
"checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" "checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b"
@@ -918,9 +1251,11 @@ dependencies = [
"checksum block-buffer 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a076c298b9ecdb530ed9d967e74a6027d6a7478924520acddcddc24c1c8ab3ab" "checksum block-buffer 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a076c298b9ecdb530ed9d967e74a6027d6a7478924520acddcddc24c1c8ab3ab"
"checksum byte-tools 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "560c32574a12a89ecd91f5e742165893f86e3ab98d21f8ea548658eb9eef5f40" "checksum byte-tools 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "560c32574a12a89ecd91f5e742165893f86e3ab98d21f8ea548658eb9eef5f40"
"checksum byteorder 1.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "90492c5858dd7d2e78691cfb89f90d273a2800fc11d98f60786e5d87e2f83781" "checksum byteorder 1.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "90492c5858dd7d2e78691cfb89f90d273a2800fc11d98f60786e5d87e2f83781"
"checksum caseless 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "808dab3318747be122cb31d36de18d4d1c81277a76f8332a02b81a3d73463d7f"
"checksum cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)" = "f159dfd43363c4d08055a07703eb7a3406b0dac4d0584d96965a3262db3c9d16" "checksum cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)" = "f159dfd43363c4d08055a07703eb7a3406b0dac4d0584d96965a3262db3c9d16"
"checksum cfg-if 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "405216fd8fe65f718daa7102ea808a946b6ce40c742998fbfd3463645552de18" "checksum cfg-if 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "405216fd8fe65f718daa7102ea808a946b6ce40c742998fbfd3463645552de18"
"checksum clap 2.31.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f0f16b89cbb9ee36d87483dc939fe9f1e13c05898d56d7b230a0d4dff033a536" "checksum clap 2.31.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f0f16b89cbb9ee36d87483dc939fe9f1e13c05898d56d7b230a0d4dff033a536"
"checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f"
"checksum constant_time_eq 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8ff012e225ce166d4422e0e78419d901719760f62ae2b7969ca6b564d1b54a9e" "checksum constant_time_eq 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8ff012e225ce166d4422e0e78419d901719760f62ae2b7969ca6b564d1b54a9e"
"checksum diff 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "3c2b69f912779fbb121ceb775d74d51e915af17aaebc38d28a592843a2dd0a3a" "checksum diff 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "3c2b69f912779fbb121ceb775d74d51e915af17aaebc38d28a592843a2dd0a3a"
"checksum digest 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "00a49051fef47a72c9623101b19bd71924a45cca838826caae3eaa4d00772603" "checksum digest 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "00a49051fef47a72c9623101b19bd71924a45cca838826caae3eaa4d00772603"
@@ -929,21 +1264,27 @@ dependencies = [
"checksum either 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3be565ca5c557d7f59e7cfcf1844f9e3033650c929c6566f511e8005f205c1d0" "checksum either 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3be565ca5c557d7f59e7cfcf1844f9e3033650c929c6566f511e8005f205c1d0"
"checksum ena 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cabe5a5078ac8c506d3e4430763b1ba9b609b1286913e7d08e581d1c2de9b7e5" "checksum ena 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cabe5a5078ac8c506d3e4430763b1ba9b609b1286913e7d08e581d1c2de9b7e5"
"checksum env_logger 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)" = "0e6e40ebb0e66918a37b38c7acab4e10d299e0463fe2af5d29b9cc86710cfd2a" "checksum env_logger 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)" = "0e6e40ebb0e66918a37b38c7acab4e10d299e0463fe2af5d29b9cc86710cfd2a"
"checksum env_logger 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "afb070faf94c85d17d50ca44f6ad076bce18ae92f0037d350947240a36e9d42e"
"checksum failure 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7efb22686e4a466b1ec1a15c2898f91fa9cb340452496dca654032de20ff95b9" "checksum failure 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7efb22686e4a466b1ec1a15c2898f91fa9cb340452496dca654032de20ff95b9"
"checksum failure_derive 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "946d0e98a50d9831f5d589038d2ca7f8f455b1c21028c0db0e84116a12696426" "checksum failure_derive 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "946d0e98a50d9831f5d589038d2ca7f8f455b1c21028c0db0e84116a12696426"
"checksum fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" "checksum fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed"
"checksum fixedbitset 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "86d4de0081402f5e88cdac65c8dcdcc73118c1a7a465e2a05f0da05843a8ea33" "checksum fixedbitset 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "86d4de0081402f5e88cdac65c8dcdcc73118c1a7a465e2a05f0da05843a8ea33"
"checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" "checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82"
"checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" "checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7"
"checksum futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)" = "49e7653e374fe0d0c12de4250f0bdb60680b8c80eed558c5c7538eec9c89e21b"
"checksum generic-array 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ef25c5683767570c2bbd7deba372926a55eaae9982d7726ee2a1050239d45b9d" "checksum generic-array 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ef25c5683767570c2bbd7deba372926a55eaae9982d7726ee2a1050239d45b9d"
"checksum heck 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ea04fa3ead4e05e51a7c806fc07271fdbde4e246a6c6d1efd52e72230b771b82"
"checksum humantime 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0484fda3e7007f2a4a0d9c3a703ca38c71c54c55602ce4660c419fd32e188c9e" "checksum humantime 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0484fda3e7007f2a4a0d9c3a703ca38c71c54c55602ce4660c419fd32e188c9e"
"checksum itertools 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)" = "f58856976b776fedd95533137617a02fb25719f40e7d9b01c7043cd65474f450" "checksum itertools 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)" = "f58856976b776fedd95533137617a02fb25719f40e7d9b01c7043cd65474f450"
"checksum itoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5adb58558dcd1d786b5f0bd15f3226ee23486e24b7b58304b60f64dc68e62606" "checksum itoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5adb58558dcd1d786b5f0bd15f3226ee23486e24b7b58304b60f64dc68e62606"
"checksum js-sys 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "58cfec35fd4a94f3cf357d5cb7da71c71cd52720c2f2a7320090a8db5f06f655"
"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"
"checksum lalrpop 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ba451f7bd819b7afc99d4cf4bdcd5a4861e64955ba9680ac70df3a50625ad6cf" "checksum lalrpop 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ba451f7bd819b7afc99d4cf4bdcd5a4861e64955ba9680ac70df3a50625ad6cf"
"checksum lalrpop-snap 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)" = "60013fd6be14317d43f47658b1440956a9ca48a9ed0257e0e0a59aac13e43a1f" "checksum lalrpop-snap 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)" = "60013fd6be14317d43f47658b1440956a9ca48a9ed0257e0e0a59aac13e43a1f"
"checksum lalrpop-util 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)" = "60c6c48ba857cd700673ce88907cadcdd7e2cd7783ed02378537c5ffd4f6460c" "checksum lalrpop-util 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)" = "60c6c48ba857cd700673ce88907cadcdd7e2cd7783ed02378537c5ffd4f6460c"
"checksum lazy_static 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e6412c5e2ad9584b0b8e979393122026cdd6d2a80b933f890dcd694ddbe73739" "checksum lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a374c89b9db55895453a74c1e38861d9deec0b01b405a82516e9d5de4820dea1"
"checksum lexical 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e4fac65df7e751b57bb3a334c346239cb4ce2601907d698726ceeb82a54ba4ef"
"checksum lexical-core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "025babf624c0c2b4bed1373efd684d5d0b2eecd61138d26ec3eec77bf0f2e33d"
"checksum libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)" = "b685088df2b950fccadf07a7187c8ef846a959c142338a48f9dc0b94517eb5f1" "checksum libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)" = "b685088df2b950fccadf07a7187c8ef846a959c142338a48f9dc0b94517eb5f1"
"checksum log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b" "checksum log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b"
"checksum log 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6fddaa003a65722a7fb9e26b0ce95921fe4ba590542ced664d8ce2fa26f9f3ac" "checksum log 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6fddaa003a65722a7fb9e26b0ce95921fe4ba590542ced664d8ce2fa26f9f3ac"
@@ -951,9 +1292,11 @@ dependencies = [
"checksum new_debug_unreachable 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0cdc457076c78ab54d5e0d6fa7c47981757f1e34dc39ff92787f217dede586c4" "checksum new_debug_unreachable 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0cdc457076c78ab54d5e0d6fa7c47981757f1e34dc39ff92787f217dede586c4"
"checksum nix 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d37e713a259ff641624b6cb20e3b12b2952313ba36b6823c0f16e6cfd9e5de17" "checksum nix 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d37e713a259ff641624b6cb20e3b12b2952313ba36b6823c0f16e6cfd9e5de17"
"checksum nodrop 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "9a2228dca57108069a5262f2ed8bd2e82496d2e074a06d1ccc7ce1687b6ae0a2" "checksum nodrop 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "9a2228dca57108069a5262f2ed8bd2e82496d2e074a06d1ccc7ce1687b6ae0a2"
"checksum nom 4.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9c349f68f25f596b9f44cf0e7c69752a5c633b0550c3ff849518bfba0233774a"
"checksum num-bigint 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "10b8423ea72ec64751198856a853e07b37087cfc9b53a87ecb19bff67b6d1320" "checksum num-bigint 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "10b8423ea72ec64751198856a853e07b37087cfc9b53a87ecb19bff67b6d1320"
"checksum num-complex 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "107b9be86cd2481930688277b675b0114578227f034674726605b8a482d8baf8" "checksum num-complex 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "107b9be86cd2481930688277b675b0114578227f034674726605b8a482d8baf8"
"checksum num-integer 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)" = "e83d528d2677f0518c570baf2b7abdcf0cd2d248860b68507bdcb3e91d4c0cea" "checksum num-integer 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)" = "e83d528d2677f0518c570baf2b7abdcf0cd2d248860b68507bdcb3e91d4c0cea"
"checksum num-rational 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4e96f040177bb3da242b5b1ecf3f54b5d5af3efbbfb18608977a5d2767b22f10"
"checksum num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0b3a5d7cc97d6d30d8b9bc8fa19bf45349ffe46241e8816f50f62f6d6aaabee1" "checksum num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0b3a5d7cc97d6d30d8b9bc8fa19bf45349ffe46241e8816f50f62f6d6aaabee1"
"checksum ordermap 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "a86ed3f5f244b372d6b1a00b72ef7f8876d0bc6a78a4c9985c53614041512063" "checksum ordermap 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "a86ed3f5f244b372d6b1a00b72ef7f8876d0bc6a78a4c9985c53614041512063"
"checksum petgraph 0.4.13 (registry+https://github.com/rust-lang/crates.io-index)" = "9c3659d1ee90221741f65dd128d9998311b0e40c5d3c23a62445938214abce4f" "checksum petgraph 0.4.13 (registry+https://github.com/rust-lang/crates.io-index)" = "9c3659d1ee90221741f65dd128d9998311b0e40c5d3c23a62445938214abce4f"
@@ -966,37 +1309,51 @@ dependencies = [
"checksum quote 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9949cfe66888ffe1d53e6ec9d9f3b70714083854be20fd5e271b232a017401e8" "checksum quote 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9949cfe66888ffe1d53e6ec9d9f3b70714083854be20fd5e271b232a017401e8"
"checksum quote 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e44651a0dc4cdd99f71c83b561e221f714912d11af1a4dff0631f923d53af035" "checksum quote 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e44651a0dc4cdd99f71c83b561e221f714912d11af1a4dff0631f923d53af035"
"checksum rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "eba5f8cb59cc50ed56be8880a5c7b496bfd9bd26394e176bc67884094145c2c5" "checksum rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "eba5f8cb59cc50ed56be8880a5c7b496bfd9bd26394e176bc67884094145c2c5"
"checksum rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e464cd887e869cddcae8792a4ee31d23c7edd516700695608f5b98c67ee0131c"
"checksum rand_core 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1961a422c4d189dfb50ffa9320bf1f2a9bd54ecb92792fb9477f99a1045f3372"
"checksum rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0905b6b7079ec73b314d4c748701f6931eb79fd97c668caa3f1899b22b32c6db"
"checksum redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "c214e91d3ecf43e9a4e41e578973adeb14b474f2bee858742d127af75a0112b1" "checksum redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "c214e91d3ecf43e9a4e41e578973adeb14b474f2bee858742d127af75a0112b1"
"checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" "checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76"
"checksum redox_users 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "214a97e49be64fd2c86f568dd0cb2c757d2cc53de95b273b6ad0a1c908482f26" "checksum redox_users 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "214a97e49be64fd2c86f568dd0cb2c757d2cc53de95b273b6ad0a1c908482f26"
"checksum regex 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9329abc99e39129fcceabd24cf5d85b4671ef7c29c50e972bc5afe32438ec384" "checksum regex 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9329abc99e39129fcceabd24cf5d85b4671ef7c29c50e972bc5afe32438ec384"
"checksum regex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "75ecf88252dce580404a22444fc7d626c01815debba56a7f4f536772a5ff19d3" "checksum regex 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3d8c9f33201f46669484bacc312b00e7541bed6aaf296dffe2bb4e0ac6b8ce2a"
"checksum regex-syntax 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8e931c58b93d86f080c734bfd2bce7dd0079ae2331235818133c8be7f422e20e" "checksum regex-syntax 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8e931c58b93d86f080c734bfd2bce7dd0079ae2331235818133c8be7f422e20e"
"checksum regex-syntax 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7d707a4fa2637f2dca2ef9fd02225ec7661fe01a53623c1e6515b6916511f7a7" "checksum regex-syntax 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7d707a4fa2637f2dca2ef9fd02225ec7661fe01a53623c1e6515b6916511f7a7"
"checksum regex-syntax 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8f1ac0f60d675cc6cf13a20ec076568254472551051ad5dd050364d70671bf6b" "checksum regex-syntax 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8f1ac0f60d675cc6cf13a20ec076568254472551051ad5dd050364d70671bf6b"
"checksum rustc-demangle 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "bcfe5b13211b4d78e5c2cadfebd7769197d95c639c35a50057eb4c05de811395" "checksum rustc-demangle 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "bcfe5b13211b4d78e5c2cadfebd7769197d95c639c35a50057eb4c05de811395"
"checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
"checksum rustc_version_runtime 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6de8ecd7fad7731f306f69b6e10ec5a3178c61e464dcc06979427aa4cc891145"
"checksum rustyline 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6010155119d53aac4f5b987cb8f6ea913d0d64d9b237da36f8f96a90cb3f5385" "checksum rustyline 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6010155119d53aac4f5b987cb8f6ea913d0d64d9b237da36f8f96a90cb3f5385"
"checksum ryu 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e7c066b8e2923f05d4718a06d2622f189ff362bc642bfade6c6629f0440f3827" "checksum ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "eb9e9b8cde282a9fe6a42dd4681319bfb63f121b8a8ee9439c6f4107e58a46f7"
"checksum scoped_threadpool 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "1d51f5df5af43ab3f1360b429fa5e0152ac5ce8c0bd6485cae490332e96846a8" "checksum scoped_threadpool 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "1d51f5df5af43ab3f1360b429fa5e0152ac5ce8c0bd6485cae490332e96846a8"
"checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"
"checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
"checksum serde 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)" = "e9a2d9a9ac5120e0f768801ca2b58ad6eec929dc9d1d616c162f208869c2ce95" "checksum serde 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)" = "e9a2d9a9ac5120e0f768801ca2b58ad6eec929dc9d1d616c162f208869c2ce95"
"checksum serde_derive 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)" = "0a90213fa7e0f5eac3f7afe2d5ff6b088af515052cc7303bd68c7e3b91a3fb79" "checksum serde_derive 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)" = "0a90213fa7e0f5eac3f7afe2d5ff6b088af515052cc7303bd68c7e3b91a3fb79"
"checksum serde_json 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)" = "44dd2cfde475037451fa99b7e5df77aa3cfd1536575fa8e7a538ab36dcde49ae" "checksum serde_json 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)" = "44dd2cfde475037451fa99b7e5df77aa3cfd1536575fa8e7a538ab36dcde49ae"
"checksum sha2 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9eb6be24e4c23a84d7184280d2722f7f2731fcdd4a9d886efbfe4413e4847ea0" "checksum sha2 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9eb6be24e4c23a84d7184280d2722f7f2731fcdd4a9d886efbfe4413e4847ea0"
"checksum siphasher 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0df90a788073e8d0235a67e50441d47db7c8ad9debd91cbf43736a2a92d36537" "checksum siphasher 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0df90a788073e8d0235a67e50441d47db7c8ad9debd91cbf43736a2a92d36537"
"checksum sourcefile 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4bf77cb82ba8453b42b6ae1d692e4cdc92f9a47beaf89a847c8be83f4e328ad3"
"checksum stackvector 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c049c77bf85fbc036484c97b008276d539d9ebff9dfbde37b632ebcd5b8746b6"
"checksum static_assertions 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "c19be23126415861cb3a23e501d34a708f7f9b2183c5252d690941c2e69199d5"
"checksum statrs 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "10102ac8d55e35db2b3fafc26f81ba8647da2e15879ab686a67e6d19af2685e8"
"checksum string_cache 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "25d70109977172b127fe834e5449e5ab1740b9ba49fa18a2020f509174f25423" "checksum string_cache 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "25d70109977172b127fe834e5449e5ab1740b9ba49fa18a2020f509174f25423"
"checksum string_cache_codegen 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "35293b05cf1494e8ddd042a7df6756bf18d07f42d234f32e71dce8a7aabb0191" "checksum string_cache_codegen 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "35293b05cf1494e8ddd042a7df6756bf18d07f42d234f32e71dce8a7aabb0191"
"checksum string_cache_shared 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b1884d1bc09741d466d9b14e6d37ac89d6909cbcac41dd9ae982d4d063bbedfc" "checksum string_cache_shared 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b1884d1bc09741d466d9b14e6d37ac89d6909cbcac41dd9ae982d4d063bbedfc"
"checksum strsim 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b4d15c810519a91cf877e7e36e63fe068815c678181439f2f29e2562147c3694" "checksum strsim 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b4d15c810519a91cf877e7e36e63fe068815c678181439f2f29e2562147c3694"
"checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550" "checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550"
"checksum syn 0.14.9 (registry+https://github.com/rust-lang/crates.io-index)" = "261ae9ecaa397c42b960649561949d69311f08eeaea86a65696e6e46517cf741" "checksum syn 0.14.9 (registry+https://github.com/rust-lang/crates.io-index)" = "261ae9ecaa397c42b960649561949d69311f08eeaea86a65696e6e46517cf741"
"checksum syn 0.15.23 (registry+https://github.com/rust-lang/crates.io-index)" = "9545a6a093a3f0bd59adb472700acc08cad3776f860f16a897dfce8c88721cbc"
"checksum synstructure 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "85bb9b7550d063ea184027c9b8c20ac167cd36d3e06b3a40bceb9d746dc1a7b7" "checksum synstructure 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "85bb9b7550d063ea184027c9b8c20ac167cd36d3e06b3a40bceb9d746dc1a7b7"
"checksum term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "fa63644f74ce96fbeb9b794f66aff2a52d601cbd5e80f4b97123e3899f4570f1" "checksum term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "fa63644f74ce96fbeb9b794f66aff2a52d601cbd5e80f4b97123e3899f4570f1"
"checksum termcolor 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "adc4587ead41bf016f11af03e55a624c06568b5a19db4e90fde573d805074f83" "checksum termcolor 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "adc4587ead41bf016f11af03e55a624c06568b5a19db4e90fde573d805074f83"
"checksum termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4096add70612622289f2fdcdbd5086dc81c1e2675e6ae58d6c4f62a16c6d7f2f"
"checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096" "checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096"
"checksum textwrap 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c0b59b6b4b44d867f1370ef1bd91bfb262bf07bf0ae65c202ea2fbc16153b693" "checksum textwrap 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c0b59b6b4b44d867f1370ef1bd91bfb262bf07bf0ae65c202ea2fbc16153b693"
"checksum thread_local 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "279ef31c19ededf577bfd12dfae728040a21f635b06a24cd670ff510edd38963" "checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b"
"checksum typenum 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "612d636f949607bdf9b123b4a6f6d966dedf3ff669f7f045890d3a4a73948169" "checksum typenum 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "612d636f949607bdf9b123b4a6f6d966dedf3ff669f7f045890d3a4a73948169"
"checksum ucd-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fd2be2d6639d0f8fe6cdda291ad456e23629558d466e2789d2c3e9892bda285d" "checksum ucd-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fd2be2d6639d0f8fe6cdda291ad456e23629558d466e2789d2c3e9892bda285d"
"checksum unicode-normalization 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "6a0180bc61fc5a987082bfa111f4cc95c4caff7f9799f3e46df09163a937aa25"
"checksum unicode-segmentation 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "aa6024fc12ddfd1c6dbc14a80fa2324d4568849869b779f6bd37e5e4c03344d1" "checksum unicode-segmentation 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "aa6024fc12ddfd1c6dbc14a80fa2324d4568849869b779f6bd37e5e4c03344d1"
"checksum unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "882386231c45df4700b275c7ff55b6f3698780a650026380e72dabe76fa46526" "checksum unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "882386231c45df4700b275c7ff55b6f3698780a650026380e72dabe76fa46526"
"checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" "checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc"
@@ -1005,9 +1362,21 @@ dependencies = [
"checksum utf8parse 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8772a4ccbb4e89959023bc5b7cb8623a795caa7092d99f3aa9501b9484d4557d" "checksum utf8parse 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8772a4ccbb4e89959023bc5b7cb8623a795caa7092d99f3aa9501b9484d4557d"
"checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" "checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a"
"checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" "checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d"
"checksum wasm-bindgen 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)" = "91f95b8f30407b9ca0c2de157281d3828bbed1fc1f55bea6eb54f40c52ec75ec"
"checksum wasm-bindgen-backend 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)" = "ab7c242ebcb45bae45340986c48d1853eb2c1c52ff551f7724951b62a2c51429"
"checksum wasm-bindgen-futures 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "d1784e7401a90119b2a4e8ec9c8d37c3594c3e3bb9ba24533ee1969eebaf0485"
"checksum wasm-bindgen-macro 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)" = "6e353f83716dec9a3597b5719ef88cb6c9e461ec16528f38aa023d3224b4e569"
"checksum wasm-bindgen-macro-support 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)" = "3cc90b65fe69c3dd5a09684517dc79f42b847baa2d479c234d125e0a629d9b0a"
"checksum wasm-bindgen-shared 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)" = "a71a37df4f5845025f96f279d20bbe5b19cbcb77f5410a3a90c6c544d889a162"
"checksum wasm-bindgen-webidl 0.2.23 (registry+https://github.com/rust-lang/crates.io-index)" = "b064b8b2336b5a6bf5f31bc95fc1310842395df29877d910cb6f8f791070f319"
"checksum web-sys 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7d7c588c2e5a091bc4532c5a87032955f9133b644e868b54d08ead0185dcc5b9"
"checksum weedle 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "26a4c67f132386d965390b8a734d5d10adbcd30eb5cc74bd9229af8b83f10044"
"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" "checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a"
"checksum winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "773ef9dcc5f24b7d850d0ff101e542ff24c3b090a9768e03ff889fdef41f00fd" "checksum winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "773ef9dcc5f24b7d850d0ff101e542ff24c3b090a9768e03ff889fdef41f00fd"
"checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" "checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc"
"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" "checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
"checksum winapi-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "afc5508759c5bf4285e61feb862b6083c8480aec864fa17a81fdec6f69b461ab"
"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
"checksum wincolor 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "eeb06499a3a4d44302791052df005d5232b927ed1a9658146d842165c4de7767" "checksum wincolor 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "eeb06499a3a4d44302791052df005d5232b927ed1a9658146d842165c4de7767"
"checksum wincolor 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "561ed901ae465d6185fa7864d63fbd5720d0ef718366c9a4dc83cf6170d7e9ba"
"checksum xdg 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d089681aa106a86fade1b0128fb5daf07d5867a509ab036d99988dec80429a57"

View File

@@ -1,9 +1,11 @@
[package] [package]
name = "rustpython" name = "rustpython"
version = "0.0.1" version = "0.0.1-pre-alpha.1"
authors = ["Windel Bouwman", "Shing Lyu <shing.lyu@gmail.com>"] authors = ["Windel Bouwman", "Shing Lyu <shing.lyu@gmail.com>"]
edition = "2018"
[workspace] [workspace]
members = [".", "vm", "wasm/lib", "parser"]
[dependencies] [dependencies]
log="0.4.1" log="0.4.1"
@@ -12,3 +14,7 @@ clap = "2.31.2"
rustpython_parser = {path = "parser"} rustpython_parser = {path = "parser"}
rustpython_vm = {path = "vm"} rustpython_vm = {path = "vm"}
rustyline = "2.1.0" rustyline = "2.1.0"
xdg = "2.2.0"
[profile.release]
opt-level = "s"

9
Dockerfile.bin Normal file
View File

@@ -0,0 +1,9 @@
FROM rust:1.31-slim
WORKDIR /rustpython
COPY . .
RUN cargo build --release
CMD [ "/rustpython/target/release/rustpython" ]

19
Dockerfile.wasm Normal file
View File

@@ -0,0 +1,19 @@
FROM rust:1.31-slim
RUN apt-get update && apt-get install curl gnupg -y && \
curl -o- https://deb.nodesource.com/setup_10.x | bash && \
apt-get install nodejs -y && \
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh && \
npm i -g serve
WORKDIR /rustpython
COPY . .
RUN cd ./wasm/lib/ && \
cargo build --release && \
cd ../demo && \
npm install && \
npm run dist
CMD [ "serve", "/rustpython/wasm/demo/dist" ]

123
README.md
View File

@@ -1,13 +1,18 @@
# RustPython # RustPython
A Python-3 (CPython >= 3.5.0) Interpreter written in Rust :snake: :scream: :metal:.
A Python-3 (CPython >= 3.5.0) Interpreter written in Rust :snake: :scream: :metal:.
[![Build Status](https://travis-ci.org/RustPython/RustPython.svg?branch=master)](https://travis-ci.org/RustPython/RustPython) [![Build Status](https://travis-ci.org/RustPython/RustPython.svg?branch=master)](https://travis-ci.org/RustPython/RustPython)
[![Build Status](https://dev.azure.com/ryan0463/ryan/_apis/build/status/RustPython.RustPython?branchName=master)](https://dev.azure.com/ryan0463/ryan/_build/latest?definitionId=1&branchName=master)
[![codecov](https://codecov.io/gh/RustPython/RustPython/branch/master/graph/badge.svg)](https://codecov.io/gh/RustPython/RustPython)
[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT) [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)
[![Contributors](https://img.shields.io/github/contributors/RustPython/RustPython.svg)](https://github.com/RustPython/RustPython/graphs/contributors) [![Contributors](https://img.shields.io/github/contributors/RustPython/RustPython.svg)](https://github.com/RustPython/RustPython/graphs/contributors)
[![Gitter](https://badges.gitter.im/RustPython/Lobby.svg)](https://gitter.im/rustpython/Lobby) [![Gitter](https://badges.gitter.im/RustPython/Lobby.svg)](https://gitter.im/rustpython/Lobby)
# Usage # Usage
### Check out our [online demo](https://rustpython.github.io/demo/) running on WebAssembly.
To test RustPython, do the following: To test RustPython, do the following:
$ git clone https://github.com/RustPython/RustPython $ git clone https://github.com/RustPython/RustPython
@@ -22,6 +27,13 @@ Or use the interactive shell:
>>>>> 2+2 >>>>> 2+2
4 4
# Disclaimer
RustPython is in a development phase and should not be used in production or a fault intolerant setting.
Our current build supports only a subset of Python syntax.
Contribution is also more than welcome! See our contribution section for more information on this.
# Goals # Goals
@@ -30,35 +42,48 @@ Or use the interactive shell:
# Documentation # Documentation
Currently the project is in an early phase, and so is the documentation. Currently along with other areas of the project, documentation is still in an early phase.
You can generate documentation by running: You can read the [online documentation](https://rustpython.github.io/website/rustpython/index.html) for the latest code on master.
You can also generate documentation locally by running:
```shell ```shell
$ cargo doc $ cargo doc # Including documentation for all dependencies
$ cargo doc --no-deps --all # Excluding all dependencies
``` ```
Documentation HTML files can then be found in the `target/doc` directory. Documentation HTML files can then be found in the `target/doc` directory.
If you wish to update the online documentation, push directly to the `release` branch (or ask a maintainer to do so). This will trigger a Travis build that updates the documentation and WebAssembly demo page.
# Code organization # Code organization
- `parser`: python lexing, parsing and ast - `parser/src`: python lexing, parsing and ast
- `vm`: python virtual machine - `vm/src`: python virtual machine
- `builtins.rs`: Builtin functions
- `compile.rs`: the python compiler from ast to bytecode
- `obj`: python builtin types
- `src`: using the other subcrates to bring rustpython to life. - `src`: using the other subcrates to bring rustpython to life.
- `docs`: documentation (work in progress) - `docs`: documentation (work in progress)
- `py_code_object`: CPython bytecode to rustpython bytecode convertor (work in progress) - `py_code_object`: CPython bytecode to rustpython bytecode converter (work in progress)
- `wasm`: Binary crate and resources for WebAssembly build - `wasm`: Binary crate and resources for WebAssembly build
- `tests`: integration test snippets - `tests`: integration test snippets
# Contributing # Contributing
To start contributing, there are a lot of things that need to be done. Contributions are more than welcome, and in many cases we are happy to guide contributors through PRs or on gitter.
With that in mind, please note this project is maintained by volunteers, some of the best ways to get started are below:
Most tasks are listed in the [issue tracker](https://github.com/RustPython/RustPython/issues). Most tasks are listed in the [issue tracker](https://github.com/RustPython/RustPython/issues).
Another approach is to checkout the sourcecode: builtin functions and object methods are often the simplest Check issues labeled with `good first issue` if you wish to start coding.
and easiest way to contribute.
Another approach is to checkout the source code: builtin functions and object methods are often the simplest
and easiest way to contribute.
You can also simply run You can also simply run
`cargo run tests/snippets/todo.py` to assist in finding any `cargo run tests/snippets/whats_left_to_implement.py` to assist in finding any
unimplemented method. unimplemented method.
# Testing # Testing
@@ -68,11 +93,11 @@ To test rustpython, there is a collection of python snippets located in the
```shell ```shell
$ cd tests $ cd tests
$ pipenv shell $ pipenv install
$ pytest -v $ pipenv run pytest -v
``` ```
There also are some unittests, you can run those will cargo: There also are some unit tests, you can run those with cargo:
```shell ```shell
$ cargo test --all $ cargo test --all
@@ -102,8 +127,7 @@ At this stage RustPython only has preliminary support for web assembly. The inst
## Setup ## Setup
To get started, install [wasm-bingden](https://rustwasm.github.io/wasm-bindgen/whirlwind-tour/basic-usage.html) To get started, install [wasm-pack](https://rustwasm.github.io/wasm-pack/installer/) and `npm`. ([wasm-bindgen](https://rustwasm.github.io/wasm-bindgen/whirlwind-tour/basic-usage.html) should be installed by `wasm-pack`. if not, install it yourself)
and [wasm-webpack](https://rustwasm.github.io/wasm-pack/installer/). You will also need to have `npm` installed.
<!-- Using `rustup` add the compile target `wasm32-unknown-emscripten`. To do so you will need to have [rustup](https://rustup.rs/) installed. <!-- Using `rustup` add the compile target `wasm32-unknown-emscripten`. To do so you will need to have [rustup](https://rustup.rs/) installed.
@@ -121,55 +145,53 @@ cd emsdk-portable/
./emsdk activate sdk-incoming-64bit ./emsdk activate sdk-incoming-64bit
``` --> ``` -->
## Build ## Build
Move into the `wasm` directory. This contains a custom library crate optimized for wasm build of RustPython. Move into the `wasm` directory. This directory contains a library crate for interop
with python to rust to js and back in `wasm/lib`, the demo website found at
https://rustpython.github.io/demo in `wasm/demo`, and an example of how to use
the crate as a library in one's own JS app in `wasm/example`.
```bash ```sh
cd wasm cd wasm
``` ```
From here run the build. This can take several minutes depending on the machine. Go to the demo directory. This is the best way of seeing the changes made to either
the library or the JS demo, as the `rustpython_wasm` module is set to the global
JS variable `rp` on the website.
``` ```sh
wasm-pack build cd demo
``` ```
Upon successful build, cd in the the `/pkg` directory and run: Now, start the webpack development server. It'll compile the crate and then
the demo app. This will likely take a long time, both the wasm-pack portion and
the webpack portion (from after it says "Your crate has been correctly compiled"),
so be patient.
``` ```sh
npm link npm run dev
``` ```
Now move back out into the `/app` directory. The files here have been adapted from [wasm-pack-template](https://github.com/rustwasm/wasm-pack-template). You can now open the webpage on https://localhost:8080 and Python code in either
the text box or browser devtools with:
Finally, run:
```
npm install
```
and you will be able to run the files with:
```
webpack-dev-server
```
Open a browser console and see the output of rustpython_wasm. To verify this, modify the line in `app/index.js`
```js ```js
rp.run_code("print('Hello Python!')\n"); rp.pyEval(
`
print(js_vars['a'] * 9)
`,
{
vars: {
a: 9
}
}
);
``` ```
To the following: Alternatively, you can run `npm run build` to build the app once, without watching
for changes, or `npm run dist` to build the app in release mode, both for the
```js crate and webpack.
rp.run_code("assert(False)\n");
```
and you should observe: `Execution failed` in your console output, indicating that the execution of RustPython has failed.
# Code style # Code style
@@ -192,4 +214,3 @@ These are some useful links to related projects:
- https://github.com/ProgVal/pythonvm-rust - https://github.com/ProgVal/pythonvm-rust
- https://github.com/shinglyu/RustPython - https://github.com/shinglyu/RustPython
- https://github.com/windelbouwman/rspython - https://github.com/windelbouwman/rspython

56
azure-pipelines.yml Normal file
View File

@@ -0,0 +1,56 @@
trigger:
- master
jobs:
- job: 'Test'
pool:
vmImage: 'vs2017-win2016'
strategy:
matrix:
Python37:
python.version: '3.7'
maxParallel: 10
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '$(python.version)'
architecture: 'x64'
- script: |
"C:\Program Files\Git\mingw64\bin\curl.exe" -sSf -o rustup-init.exe https://win.rustup.rs/
.\rustup-init.exe -y
set PATH=%PATH%;%USERPROFILE%\.cargo\bin
rustc -V
cargo -V
displayName: 'Installing Rust'
- script: |
set PATH=%PATH%;%USERPROFILE%\.cargo\bin
cargo build --verbose --all
displayName: 'Build'
- script: |
set PATH=%PATH%;%USERPROFILE%\.cargo\bin
cargo test --verbose --all
displayName: 'Run tests'
- script: |
pip install pipenv
pushd tests
pipenv install
popd
displayName: 'Install pipenv and python packages'
- script: |
set PATH=%PATH%;%USERPROFILE%\.cargo\bin
cargo build --verbose --release
displayName: 'Build release'
- script: |
set PATH=%PATH%;%USERPROFILE%\.cargo\bin
pushd tests
pipenv run pytest
popd
displayName: 'Run snippet tests'

View File

@@ -1,6 +1,6 @@
Byterun Byterun
* Builtins are exposted to frame.f_builtins * Builtins are exposed to frame.f_builtins
* f_builtins is assigned during frame creation, * f_builtins is assigned during frame creation,
self.f_builtins = f_locals['__builtins__'] self.f_builtins = f_locals['__builtins__']
if hasattr(self.f_builtins, '__dict__'): if hasattr(self.f_builtins, '__dict__'):
@@ -21,10 +21,10 @@ TODO:
* Implement a new type NativeFunction * Implement a new type NativeFunction
* Wrap a function pointer in NativeFunction * Wrap a function pointer in NativeFunction
* Refactor the CALL_FUNCTION case so it can call both python function and native function * Refactor the CALL_FUNCTION case so it can call both python function and native function
* During frame creation, force push a nativefunction `print` into the namespace * During frame creation, force push a native function `print` into the namespace
* Modify LOAD_* so they can search for names in builtins * Modify LOAD_* so they can search for names in builtins
* Create a module type * Create a module type
* In VM initialization, load the builtins module into locals * In VM initialization, load the builtins module into locals
* During frame creation, create a field that conatins the builtins dict * During frame creation, create a field that contains the builtins dict

View File

@@ -3,6 +3,7 @@ name = "rustpython_parser"
version = "0.0.1" version = "0.0.1"
authors = [ "Shing Lyu", "Windel Bouwman" ] authors = [ "Shing Lyu", "Windel Bouwman" ]
build = "build.rs" build = "build.rs"
edition = "2018"
[build-dependencies] [build-dependencies]
lalrpop="0.15.1" lalrpop="0.15.1"

View File

@@ -1,4 +1,4 @@
extern crate lalrpop; use lalrpop;
fn main() { fn main() {
lalrpop::process_root().unwrap(); lalrpop::process_root().unwrap();

View File

@@ -65,9 +65,9 @@ pub enum Statement {
value: Expression, value: Expression,
}, },
AugAssign { AugAssign {
target: Expression, target: Box<Expression>,
op: Operator, op: Operator,
value: Expression, value: Box<Expression>,
}, },
Expression { Expression {
expression: Expression, expression: Expression,
@@ -122,6 +122,7 @@ pub enum Statement {
// docstring: String, // docstring: String,
body: Vec<LocatedStatement>, body: Vec<LocatedStatement>,
decorator_list: Vec<Expression>, decorator_list: Vec<Expression>,
returns: Option<Expression>,
}, },
} }
@@ -197,7 +198,7 @@ pub enum Expression {
elements: Vec<Expression>, elements: Vec<Expression>,
}, },
String { String {
value: String, value: StringGroup,
}, },
Bytes { Bytes {
value: Vec<u8>, value: Vec<u8>,
@@ -217,22 +218,74 @@ pub enum Expression {
True, True,
False, False,
None, None,
Ellipsis,
}
impl Expression {
/// Returns a short name for the node suitable for use in error messages.
pub fn name(&self) -> &'static str {
use self::Expression::*;
use self::StringGroup::*;
match self {
BoolOp { .. } | Binop { .. } | Unop { .. } => "operator",
Subscript { .. } => "subscript",
Yield { .. } | YieldFrom { .. } => "yield expression",
Compare { .. } => "comparison",
Attribute { .. } => "attribute",
Call { .. } => "function call",
Number { .. }
| String {
value: Constant { .. },
}
| Bytes { .. } => "literal",
List { .. } => "list",
Tuple { .. } => "tuple",
Dict { .. } => "dict display",
Set { .. } => "set display",
Comprehension { kind, .. } => match **kind {
ComprehensionKind::List { .. } => "list comprehension",
ComprehensionKind::Dict { .. } => "dict comprehension",
ComprehensionKind::Set { .. } => "set comprehension",
ComprehensionKind::GeneratorExpression { .. } => "generator expression",
},
Starred { .. } => "starred",
Slice { .. } => "slice",
String {
value: Joined { .. },
}
| String {
value: FormattedValue { .. },
} => "f-string expression",
Identifier { .. } => "named expression",
Lambda { .. } => "lambda",
IfExpression { .. } => "conditional expression",
True | False | None => "keyword",
Ellipsis => "ellipsis",
}
}
} }
/* /*
* In cpython this is called arguments, but we choose parameters to * In cpython this is called arguments, but we choose parameters to
* distuingish between function parameters and actual call arguments. * distinguish between function parameters and actual call arguments.
*/ */
#[derive(Debug, PartialEq, Default)] #[derive(Debug, PartialEq, Default)]
pub struct Parameters { pub struct Parameters {
pub args: Vec<String>, pub args: Vec<Parameter>,
pub kwonlyargs: Vec<String>, pub kwonlyargs: Vec<Parameter>,
pub vararg: Option<Option<String>>, // Optionally we handle optionally named '*args' or '*' pub vararg: Option<Option<Parameter>>, // Optionally we handle optionally named '*args' or '*'
pub kwarg: Option<Option<String>>, pub kwarg: Option<Option<Parameter>>,
pub defaults: Vec<Expression>, pub defaults: Vec<Expression>,
pub kw_defaults: Vec<Option<Expression>>, pub kw_defaults: Vec<Option<Expression>>,
} }
#[derive(Debug, PartialEq, Default)]
pub struct Parameter {
pub arg: String,
pub annotation: Option<Box<Expression>>,
}
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq)]
pub enum ComprehensionKind { pub enum ComprehensionKind {
GeneratorExpression { element: Expression }, GeneratorExpression { element: Expression },
@@ -312,3 +365,29 @@ pub enum Number {
Float { value: f64 }, Float { value: f64 },
Complex { real: f64, imag: f64 }, Complex { real: f64, imag: f64 },
} }
/// Transforms a value prior to formatting it.
#[derive(Copy, Clone, Debug, PartialEq)]
pub enum ConversionFlag {
/// Converts by calling `str(<value>)`.
Str,
/// Converts by calling `ascii(<value>)`.
Ascii,
/// Converts by calling `repr(<value>)`.
Repr,
}
#[derive(Debug, PartialEq)]
pub enum StringGroup {
Constant {
value: String,
},
FormattedValue {
value: Box<Expression>,
conversion: Option<ConversionFlag>,
spec: String,
},
Joined {
values: Vec<StringGroup>,
},
}

79
parser/src/error.rs Normal file
View File

@@ -0,0 +1,79 @@
//! Define internal parse error types
//! The goal is to provide a matching and a safe error API, maksing errors from LALR
extern crate lalrpop_util;
use self::lalrpop_util::ParseError as InnerError;
use crate::lexer::{LexicalError, Location};
use crate::token::Tok;
use std::error::Error;
use std::fmt;
// A token of type `Tok` was observed, with a span given by the two Location values
type TokSpan = (Location, Tok, Location);
/// Represents an error during parsing
#[derive(Debug, PartialEq)]
pub enum ParseError {
/// Parser encountered an unexpected end of input
EOF(Option<Location>),
/// Parser encountered an extra token
ExtraToken(TokSpan),
/// Parser encountered an invalid token
InvalidToken(Location),
/// Parser encountered an unexpected token
UnrecognizedToken(TokSpan, Vec<String>),
/// Maps to `User` type from `lalrpop-util`
Other,
}
/// Convert `lalrpop_util::ParseError` to our internal type
impl From<InnerError<Location, Tok, LexicalError>> for ParseError {
fn from(err: InnerError<Location, Tok, LexicalError>) -> Self {
match err {
// TODO: Are there cases where this isn't an EOF?
InnerError::InvalidToken { location } => ParseError::EOF(Some(location)),
InnerError::ExtraToken { token } => ParseError::ExtraToken(token),
// Inner field is a unit-like enum `LexicalError::StringError` with no useful info
InnerError::User { .. } => ParseError::Other,
InnerError::UnrecognizedToken { token, expected } => {
match token {
Some(tok) => ParseError::UnrecognizedToken(tok, expected),
// EOF was observed when it was unexpected
None => ParseError::EOF(None),
}
}
}
}
}
impl fmt::Display for ParseError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
ParseError::EOF(ref location) => {
if let Some(l) = location {
write!(f, "Got unexpected EOF at: {:?}", l)
} else {
write!(f, "Got unexpected EOF")
}
}
ParseError::ExtraToken(ref t_span) => {
write!(f, "Got extraneous token: {:?} at: {:?}", t_span.1, t_span.0)
}
ParseError::InvalidToken(ref location) => {
write!(f, "Got invalid token at: {:?}", location)
}
ParseError::UnrecognizedToken(ref t_span, _) => {
write!(f, "Got unexpected token: {:?} at {:?}", t_span.1, t_span.0)
}
// This is user defined, it probably means a more useful error should have been given upstream.
ParseError::Other => write!(f, "Got unsupported token(s)"),
}
}
}
impl Error for ParseError {
fn source(&self) -> Option<&(dyn Error + 'static)> {
None
}
}

234
parser/src/fstring.rs Normal file
View File

@@ -0,0 +1,234 @@
use std::iter;
use std::mem;
use std::str;
use lalrpop_util::ParseError as LalrpopError;
use crate::ast::{ConversionFlag, StringGroup};
use crate::lexer::{LexicalError, Location, Tok};
use crate::parser::parse_expression;
use self::FStringError::*;
use self::StringGroup::*;
// TODO: consolidate these with ParseError
#[derive(Debug, PartialEq)]
pub enum FStringError {
UnclosedLbrace,
UnopenedRbrace,
InvalidExpression,
InvalidConversionFlag,
EmptyExpression,
MismatchedDelimiter,
}
impl From<FStringError> for LalrpopError<Location, Tok, LexicalError> {
fn from(_err: FStringError) -> Self {
lalrpop_util::ParseError::User {
error: LexicalError::StringError,
}
}
}
struct FStringParser<'a> {
chars: iter::Peekable<str::Chars<'a>>,
}
impl<'a> FStringParser<'a> {
fn new(source: &'a str) -> Self {
Self {
chars: source.chars().peekable(),
}
}
fn parse_formatted_value(&mut self) -> Result<StringGroup, FStringError> {
let mut expression = String::new();
let mut spec = String::new();
let mut delims = Vec::new();
let mut conversion = None;
while let Some(ch) = self.chars.next() {
match ch {
'!' if delims.is_empty() => {
conversion = Some(match self.chars.next() {
Some('s') => ConversionFlag::Str,
Some('a') => ConversionFlag::Ascii,
Some('r') => ConversionFlag::Repr,
Some(_) => {
return Err(InvalidConversionFlag);
}
None => {
break;
}
})
}
':' if delims.is_empty() => {
while let Some(&next) = self.chars.peek() {
if next != '}' {
spec.push(next);
self.chars.next();
} else {
break;
}
}
}
'(' | '{' | '[' => {
expression.push(ch);
delims.push(ch);
}
')' => {
if delims.pop() != Some('(') {
return Err(MismatchedDelimiter);
}
expression.push(ch);
}
']' => {
if delims.pop() != Some('[') {
return Err(MismatchedDelimiter);
}
expression.push(ch);
}
'}' if !delims.is_empty() => {
if delims.pop() != Some('{') {
return Err(MismatchedDelimiter);
}
expression.push(ch);
}
'}' => {
if expression.is_empty() {
return Err(EmptyExpression);
}
return Ok(FormattedValue {
value: Box::new(
parse_expression(expression.trim()).map_err(|_| InvalidExpression)?,
),
conversion,
spec,
});
}
'"' | '\'' => {
expression.push(ch);
while let Some(next) = self.chars.next() {
expression.push(next);
if next == ch {
break;
}
}
}
_ => {
expression.push(ch);
}
}
}
Err(UnclosedLbrace)
}
fn parse(mut self) -> Result<StringGroup, FStringError> {
let mut content = String::new();
let mut values = vec![];
while let Some(ch) = self.chars.next() {
match ch {
'{' => {
if let Some('{') = self.chars.peek() {
self.chars.next();
content.push('{');
} else {
if !content.is_empty() {
values.push(Constant {
value: mem::replace(&mut content, String::new()),
});
}
values.push(self.parse_formatted_value()?);
}
}
'}' => {
if let Some('}') = self.chars.peek() {
self.chars.next();
content.push('}');
} else {
return Err(UnopenedRbrace);
}
}
_ => {
content.push(ch);
}
}
}
if !content.is_empty() {
values.push(Constant { value: content })
}
Ok(match values.len() {
0 => Constant {
value: String::new(),
},
1 => values.into_iter().next().unwrap(),
_ => Joined { values },
})
}
}
pub fn parse_fstring(source: &str) -> Result<StringGroup, FStringError> {
FStringParser::new(source).parse()
}
#[cfg(test)]
mod tests {
use crate::ast;
use super::*;
fn mk_ident(name: &str) -> ast::Expression {
ast::Expression::Identifier {
name: name.to_owned(),
}
}
#[test]
fn test_parse_fstring() {
let source = String::from("{a}{ b }{{foo}}");
let parse_ast = parse_fstring(&source).unwrap();
assert_eq!(
parse_ast,
Joined {
values: vec![
FormattedValue {
value: Box::new(mk_ident("a")),
conversion: None,
spec: String::new(),
},
FormattedValue {
value: Box::new(mk_ident("b")),
conversion: None,
spec: String::new(),
},
Constant {
value: "{foo}".to_owned()
}
]
}
);
}
#[test]
fn test_parse_empty_fstring() {
assert_eq!(
parse_fstring(""),
Ok(Constant {
value: String::new(),
}),
);
}
#[test]
fn test_parse_invalid_fstring() {
assert_eq!(parse_fstring("{"), Err(UnclosedLbrace));
assert_eq!(parse_fstring("}"), Err(UnopenedRbrace));
assert_eq!(parse_fstring("{class}"), Err(InvalidExpression));
}
}

View File

@@ -1,17 +1,50 @@
//! This module takes care of lexing python source text. This means source //! This module takes care of lexing python source text. This means source
//! code is translated into seperate tokens. //! code is translated into separate tokens.
pub use super::token::Tok; pub use super::token::Tok;
use num_bigint::BigInt; use num_bigint::BigInt;
use num_traits::Num; use num_traits::Num;
use std::cmp::Ordering;
use std::collections::HashMap; use std::collections::HashMap;
use std::str::FromStr; use std::str::FromStr;
#[derive(Clone, Copy, PartialEq, Debug)]
struct IndentationLevel {
tabs: usize,
spaces: usize,
}
impl IndentationLevel {
fn new() -> IndentationLevel {
IndentationLevel { tabs: 0, spaces: 0 }
}
fn compare_strict(&self, other: &IndentationLevel) -> Option<Ordering> {
// We only know for sure that we're smaller or bigger if tabs
// and spaces both differ in the same direction. Otherwise we're
// dependent on the size of tabs.
if self.tabs < other.tabs {
if self.spaces <= other.spaces {
Some(Ordering::Less)
} else {
None
}
} else if self.tabs > other.tabs {
if self.spaces >= other.spaces {
Some(Ordering::Greater)
} else {
None
}
} else {
Some(self.spaces.cmp(&other.spaces))
}
}
}
pub struct Lexer<T: Iterator<Item = char>> { pub struct Lexer<T: Iterator<Item = char>> {
chars: T, chars: T,
at_begin_of_line: bool, at_begin_of_line: bool,
nesting: usize, // Amount of parenthesis nesting: usize, // Amount of parenthesis
indentation_stack: Vec<usize>, indentation_stack: Vec<IndentationLevel>,
pending: Vec<Spanned<Tok>>, pending: Vec<Spanned<Tok>>,
chr0: Option<char>, chr0: Option<char>,
chr1: Option<char>, chr1: Option<char>,
@@ -21,6 +54,8 @@ pub struct Lexer<T: Iterator<Item = char>> {
#[derive(Debug)] #[derive(Debug)]
pub enum LexicalError { pub enum LexicalError {
StringError, StringError,
NestingError,
UnrecognizedToken { tok: char },
} }
#[derive(Clone, Debug, Default, PartialEq)] #[derive(Clone, Debug, Default, PartialEq)]
@@ -31,10 +66,7 @@ pub struct Location {
impl Location { impl Location {
pub fn new(row: usize, column: usize) -> Self { pub fn new(row: usize, column: usize) -> Self {
Location { Location { row, column }
row: row,
column: column,
}
} }
pub fn get_row(&self) -> usize { pub fn get_row(&self) -> usize {
@@ -93,8 +125,7 @@ pub type Spanned<Tok> = Result<(Location, Tok, Location), LexicalError>;
pub fn make_tokenizer<'a>(source: &'a str) -> impl Iterator<Item = Spanned<Tok>> + 'a { pub fn make_tokenizer<'a>(source: &'a str) -> impl Iterator<Item = Spanned<Tok>> + 'a {
let nlh = NewlineHandler::new(source.chars()); let nlh = NewlineHandler::new(source.chars());
let lch = LineContinationHandler::new(nlh); let lch = LineContinationHandler::new(nlh);
let lexer = Lexer::new(lch); Lexer::new(lch)
lexer
} }
// The newline handler is an iterator which collapses different newline // The newline handler is an iterator which collapses different newline
@@ -111,7 +142,7 @@ where
{ {
pub fn new(source: T) -> Self { pub fn new(source: T) -> Self {
let mut nlh = NewlineHandler { let mut nlh = NewlineHandler {
source: source, source,
chr0: None, chr0: None,
chr1: None, chr1: None,
}; };
@@ -167,7 +198,7 @@ where
{ {
pub fn new(source: T) -> Self { pub fn new(source: T) -> Self {
let mut nlh = LineContinationHandler { let mut nlh = LineContinationHandler {
source: source, source,
chr0: None, chr0: None,
chr1: None, chr1: None,
}; };
@@ -218,7 +249,7 @@ where
chars: input, chars: input,
at_begin_of_line: true, at_begin_of_line: true,
nesting: 0, nesting: 0,
indentation_stack: vec![0], indentation_stack: vec![IndentationLevel::new()],
pending: Vec::new(), pending: Vec::new(),
chr0: None, chr0: None,
location: Location::new(0, 0), location: Location::new(0, 0),
@@ -244,7 +275,6 @@ where
let mut saw_f = false; let mut saw_f = false;
loop { loop {
// Detect r"", f"", b"" and u"" // Detect r"", f"", b"" and u""
// TODO: handle f-strings
if !(saw_b || saw_u || saw_f) && (self.chr0 == Some('b') || self.chr0 == Some('B')) { if !(saw_b || saw_u || saw_f) && (self.chr0 == Some('b') || self.chr0 == Some('B')) {
saw_b = true; saw_b = true;
} else if !(saw_b || saw_r || saw_u || saw_f) } else if !(saw_b || saw_r || saw_u || saw_f)
@@ -280,7 +310,7 @@ where
if keywords.contains_key(&name) { if keywords.contains_key(&name) {
Ok((start_pos, keywords.remove(&name).unwrap(), end_pos)) Ok((start_pos, keywords.remove(&name).unwrap(), end_pos))
} else { } else {
Ok((start_pos, Tok::Name { name: name }, end_pos)) Ok((start_pos, Tok::Name { name }, end_pos))
} }
} }
@@ -325,7 +355,7 @@ where
let end_pos = self.get_pos(); let end_pos = self.get_pos();
let value = BigInt::from_str_radix(&value_text, radix).unwrap(); let value = BigInt::from_str_radix(&value_text, radix).unwrap();
Ok((start_pos, Tok::Int { value: value }, end_pos)) Ok((start_pos, Tok::Int { value }, end_pos))
} }
fn lex_normal_number(&mut self) -> Spanned<Tok> { fn lex_normal_number(&mut self) -> Spanned<Tok> {
@@ -377,7 +407,7 @@ where
)) ))
} else { } else {
let end_pos = self.get_pos(); let end_pos = self.get_pos();
Ok((start_pos, Tok::Float { value: value }, end_pos)) Ok((start_pos, Tok::Float { value }, end_pos))
} }
} else { } else {
// Parse trailing 'j': // Parse trailing 'j':
@@ -385,18 +415,11 @@ where
self.next_char(); self.next_char();
let end_pos = self.get_pos(); let end_pos = self.get_pos();
let imag = f64::from_str(&value_text).unwrap(); let imag = f64::from_str(&value_text).unwrap();
Ok(( Ok((start_pos, Tok::Complex { real: 0.0, imag }, end_pos))
start_pos,
Tok::Complex {
real: 0.0,
imag: imag,
},
end_pos,
))
} else { } else {
let end_pos = self.get_pos(); let end_pos = self.get_pos();
let value = value_text.parse::<BigInt>().unwrap(); let value = value_text.parse::<BigInt>().unwrap();
Ok((start_pos, Tok::Int { value: value }, end_pos)) Ok((start_pos, Tok::Int { value }, end_pos))
} }
} }
} }
@@ -406,9 +429,7 @@ where
self.next_char(); self.next_char();
loop { loop {
match self.chr0 { match self.chr0 {
Some('\n') => { Some('\n') => return,
return;
}
Some(_) => {} Some(_) => {}
None => return, None => return,
} }
@@ -421,7 +442,7 @@ where
is_bytes: bool, is_bytes: bool,
is_raw: bool, is_raw: bool,
_is_unicode: bool, _is_unicode: bool,
_is_fstring: bool, is_fstring: bool,
) -> Spanned<Tok> { ) -> Spanned<Tok> {
let quote_char = self.next_char().unwrap(); let quote_char = self.next_char().unwrap();
let mut string_content = String::new(); let mut string_content = String::new();
@@ -512,36 +533,37 @@ where
} else { } else {
Tok::String { Tok::String {
value: string_content, value: string_content,
is_fstring,
} }
}; };
return Ok((start_pos, tok, end_pos)); Ok((start_pos, tok, end_pos))
} }
fn is_char(&self) -> bool { fn is_char(&self) -> bool {
match self.chr0 { match self.chr0 {
Some('a'...'z') | Some('A'...'Z') | Some('_') | Some('0'...'9') => return true, Some('a'..='z') | Some('A'..='Z') | Some('_') | Some('0'..='9') => true,
_ => return false, _ => false,
} }
} }
fn is_number(&self, radix: u32) -> bool { fn is_number(&self, radix: u32) -> bool {
match radix { match radix {
2 => match self.chr0 { 2 => match self.chr0 {
Some('0'...'1') => return true, Some('0'..='1') => true,
_ => return false, _ => false,
}, },
8 => match self.chr0 { 8 => match self.chr0 {
Some('0'...'7') => return true, Some('0'..='7') => true,
_ => return false, _ => false,
}, },
10 => match self.chr0 { 10 => match self.chr0 {
Some('0'...'9') => return true, Some('0'..='9') => true,
_ => return false, _ => false,
}, },
16 => match self.chr0 { 16 => match self.chr0 {
Some('0'...'9') | Some('a'...'f') | Some('A'...'F') => return true, Some('0'..='9') | Some('a'..='f') | Some('A'..='F') => true,
_ => return false, _ => false,
}, },
x => unimplemented!("Radix not implemented: {}", x), x => unimplemented!("Radix not implemented: {}", x),
} }
@@ -576,12 +598,23 @@ where
self.at_begin_of_line = false; self.at_begin_of_line = false;
// Determine indentation: // Determine indentation:
let mut col: usize = 0; let mut spaces: usize = 0;
let mut tabs: usize = 0;
loop { loop {
match self.chr0 { match self.chr0 {
Some(' ') => { Some(' ') => {
self.next_char(); self.next_char();
col += 1; spaces += 1;
}
Some('\t') => {
if spaces != 0 {
// Don't allow tabs after spaces as part of indentation.
// This is technically stricter than python3 but spaces before
// tabs is even more insane than mixing spaces and tabs.
panic!("Tabs not allowed as part of indentation after spaces");
}
self.next_char();
tabs += 1;
} }
Some('#') => { Some('#') => {
self.lex_comment(); self.lex_comment();
@@ -601,41 +634,63 @@ where
} }
} }
let indentation_level = IndentationLevel { spaces, tabs };
if self.nesting == 0 { if self.nesting == 0 {
// Determine indent or dedent: // Determine indent or dedent:
let current_indentation = *self.indentation_stack.last().unwrap(); let current_indentation = *self.indentation_stack.last().unwrap();
if col == current_indentation { let ordering = indentation_level.compare_strict(&current_indentation);
// Same same match ordering {
} else if col > current_indentation { Some(Ordering::Equal) => {
// New indentation level: // Same same
self.indentation_stack.push(col); }
let tok_start = self.get_pos(); Some(Ordering::Greater) => {
let tok_end = tok_start.clone(); // New indentation level:
return Some(Ok((tok_start, Tok::Indent, tok_end))); self.indentation_stack.push(indentation_level);
} else if col < current_indentation {
// One or more dedentations
// Pop off other levels until col is found:
while col < *self.indentation_stack.last().unwrap() {
self.indentation_stack.pop().unwrap();
let tok_start = self.get_pos(); let tok_start = self.get_pos();
let tok_end = tok_start.clone(); let tok_end = tok_start.clone();
self.pending.push(Ok((tok_start, Tok::Dedent, tok_end))); return Some(Ok((tok_start, Tok::Indent, tok_end)));
} }
Some(Ordering::Less) => {
// One or more dedentations
// Pop off other levels until col is found:
if col != *self.indentation_stack.last().unwrap() { loop {
// TODO: handle wrong indentations let ordering = indentation_level
panic!("Non matching indentation levels!"); .compare_strict(self.indentation_stack.last().unwrap());
match ordering {
Some(Ordering::Less) => {
self.indentation_stack.pop();
let tok_start = self.get_pos();
let tok_end = tok_start.clone();
self.pending.push(Ok((tok_start, Tok::Dedent, tok_end)));
}
None => {
panic!("inconsistent use of tabs and spaces in indentation")
}
_ => {
break;
}
};
}
if indentation_level != *self.indentation_stack.last().unwrap() {
// TODO: handle wrong indentations
panic!("Non matching indentation levels!");
}
return Some(self.pending.remove(0));
} }
None => panic!("inconsistent use of tabs and spaces in indentation"),
return Some(self.pending.remove(0));
} }
} }
} }
match self.chr0 { match self.chr0 {
Some('0'...'9') => return Some(self.lex_number()), Some('0'..='9') => return Some(self.lex_number()),
Some('_') | Some('a'...'z') | Some('A'...'Z') => return Some(self.lex_identifier()), Some('_') | Some('a'..='z') | Some('A'..='Z') => {
return Some(self.lex_identifier());
}
Some('#') => { Some('#') => {
self.lex_comment(); self.lex_comment();
continue; continue;
@@ -664,16 +719,13 @@ where
Some('+') => { Some('+') => {
let tok_start = self.get_pos(); let tok_start = self.get_pos();
self.next_char(); self.next_char();
match self.chr0 { if let Some('=') = self.chr0 {
Some('=') => { self.next_char();
self.next_char(); let tok_end = self.get_pos();
let tok_end = self.get_pos(); return Some(Ok((tok_start, Tok::PlusEqual, tok_end)));
return Some(Ok((tok_start, Tok::PlusEqual, tok_end))); } else {
} let tok_end = self.get_pos();
_ => { return Some(Ok((tok_start, Tok::Plus, tok_end)));
let tok_end = self.get_pos();
return Some(Ok((tok_start, Tok::Plus, tok_end)));
}
} }
} }
Some('*') => { Some('*') => {
@@ -737,61 +789,49 @@ where
Some('%') => { Some('%') => {
let tok_start = self.get_pos(); let tok_start = self.get_pos();
self.next_char(); self.next_char();
match self.chr0 { if let Some('=') = self.chr0 {
Some('=') => { self.next_char();
self.next_char(); let tok_end = self.get_pos();
let tok_end = self.get_pos(); return Some(Ok((tok_start, Tok::PercentEqual, tok_end)));
return Some(Ok((tok_start, Tok::PercentEqual, tok_end))); } else {
} let tok_end = self.get_pos();
_ => { return Some(Ok((tok_start, Tok::Percent, tok_end)));
let tok_end = self.get_pos();
return Some(Ok((tok_start, Tok::Percent, tok_end)));
}
} }
} }
Some('|') => { Some('|') => {
let tok_start = self.get_pos(); let tok_start = self.get_pos();
self.next_char(); self.next_char();
match self.chr0 { if let Some('=') = self.chr0 {
Some('=') => { self.next_char();
self.next_char(); let tok_end = self.get_pos();
let tok_end = self.get_pos(); return Some(Ok((tok_start, Tok::VbarEqual, tok_end)));
return Some(Ok((tok_start, Tok::VbarEqual, tok_end))); } else {
} let tok_end = self.get_pos();
_ => { return Some(Ok((tok_start, Tok::Vbar, tok_end)));
let tok_end = self.get_pos();
return Some(Ok((tok_start, Tok::Vbar, tok_end)));
}
} }
} }
Some('^') => { Some('^') => {
let tok_start = self.get_pos(); let tok_start = self.get_pos();
self.next_char(); self.next_char();
match self.chr0 { if let Some('=') = self.chr0 {
Some('=') => { self.next_char();
self.next_char(); let tok_end = self.get_pos();
let tok_end = self.get_pos(); return Some(Ok((tok_start, Tok::CircumflexEqual, tok_end)));
return Some(Ok((tok_start, Tok::CircumflexEqual, tok_end))); } else {
} let tok_end = self.get_pos();
_ => { return Some(Ok((tok_start, Tok::CircumFlex, tok_end)));
let tok_end = self.get_pos();
return Some(Ok((tok_start, Tok::CircumFlex, tok_end)));
}
} }
} }
Some('&') => { Some('&') => {
let tok_start = self.get_pos(); let tok_start = self.get_pos();
self.next_char(); self.next_char();
match self.chr0 { if let Some('=') = self.chr0 {
Some('=') => { self.next_char();
self.next_char(); let tok_end = self.get_pos();
let tok_end = self.get_pos(); return Some(Ok((tok_start, Tok::AmperEqual, tok_end)));
return Some(Ok((tok_start, Tok::AmperEqual, tok_end))); } else {
} let tok_end = self.get_pos();
_ => { return Some(Ok((tok_start, Tok::Amper, tok_end)));
let tok_end = self.get_pos();
return Some(Ok((tok_start, Tok::Amper, tok_end)));
}
} }
} }
Some('-') => { Some('-') => {
@@ -817,16 +857,13 @@ where
Some('@') => { Some('@') => {
let tok_start = self.get_pos(); let tok_start = self.get_pos();
self.next_char(); self.next_char();
match self.chr0 { if let Some('=') = self.chr0 {
Some('=') => { self.next_char();
self.next_char(); let tok_end = self.get_pos();
let tok_end = self.get_pos(); return Some(Ok((tok_start, Tok::AtEqual, tok_end)));
return Some(Ok((tok_start, Tok::AtEqual, tok_end))); } else {
} let tok_end = self.get_pos();
_ => { return Some(Ok((tok_start, Tok::At, tok_end)));
let tok_end = self.get_pos();
return Some(Ok((tok_start, Tok::At, tok_end)));
}
} }
} }
Some('!') => { Some('!') => {
@@ -851,6 +888,9 @@ where
} }
Some(')') => { Some(')') => {
let result = self.eat_single_char(Tok::Rpar); let result = self.eat_single_char(Tok::Rpar);
if self.nesting == 0 {
return Some(Err(LexicalError::NestingError));
}
self.nesting -= 1; self.nesting -= 1;
return Some(result); return Some(result);
} }
@@ -861,6 +901,9 @@ where
} }
Some(']') => { Some(']') => {
let result = self.eat_single_char(Tok::Rsqb); let result = self.eat_single_char(Tok::Rsqb);
if self.nesting == 0 {
return Some(Err(LexicalError::NestingError));
}
self.nesting -= 1; self.nesting -= 1;
return Some(result); return Some(result);
} }
@@ -871,6 +914,9 @@ where
} }
Some('}') => { Some('}') => {
let result = self.eat_single_char(Tok::Rbrace); let result = self.eat_single_char(Tok::Rbrace);
if self.nesting == 0 {
return Some(Err(LexicalError::NestingError));
}
self.nesting -= 1; self.nesting -= 1;
return Some(result); return Some(result);
} }
@@ -947,8 +993,15 @@ where
Some('.') => { Some('.') => {
let tok_start = self.get_pos(); let tok_start = self.get_pos();
self.next_char(); self.next_char();
let tok_end = self.get_pos(); if let (Some('.'), Some('.')) = (&self.chr0, &self.chr1) {
return Some(Ok((tok_start, Tok::Dot, tok_end))); self.next_char();
self.next_char();
let tok_end = self.get_pos();
return Some(Ok((tok_start, Tok::Ellipsis, tok_end)));
} else {
let tok_end = self.get_pos();
return Some(Ok((tok_start, Tok::Dot, tok_end)));
}
} }
Some('\n') => { Some('\n') => {
let tok_start = self.get_pos(); let tok_start = self.get_pos();
@@ -972,7 +1025,7 @@ where
None => return None, None => return None,
_ => { _ => {
let c = self.next_char(); let c = self.next_char();
panic!("Not impl {:?}", c) return Some(Err(LexicalError::UnrecognizedToken { tok: c.unwrap() }));
} // Ignore all the rest.. } // Ignore all the rest..
} }
} }
@@ -1047,9 +1100,11 @@ mod tests {
vec![ vec![
Tok::String { Tok::String {
value: "\\\\".to_string(), value: "\\\\".to_string(),
is_fstring: false,
}, },
Tok::String { Tok::String {
value: "\\".to_string(), value: "\\".to_string(),
is_fstring: false,
} }
] ]
); );
@@ -1233,12 +1288,56 @@ mod tests {
} }
} }
macro_rules! test_double_dedent_with_tabs {
($($name:ident: $eol:expr,)*) => {
$(
#[test]
fn $name() {
let source = String::from(format!("def foo():{}\tif x:{}{}\t return 99{}{}", $eol, $eol, $eol, $eol, $eol));
let tokens = lex_source(&source);
assert_eq!(
tokens,
vec![
Tok::Def,
Tok::Name {
name: String::from("foo"),
},
Tok::Lpar,
Tok::Rpar,
Tok::Colon,
Tok::Newline,
Tok::Indent,
Tok::If,
Tok::Name {
name: String::from("x"),
},
Tok::Colon,
Tok::Newline,
Tok::Indent,
Tok::Return,
Tok::Int { value: BigInt::from(99) },
Tok::Newline,
Tok::Dedent,
Tok::Dedent,
]
);
}
)*
}
}
test_double_dedent_with_eol! { test_double_dedent_with_eol! {
test_double_dedent_windows_eol: WINDOWS_EOL, test_double_dedent_windows_eol: WINDOWS_EOL,
test_double_dedent_mac_eol: MAC_EOL, test_double_dedent_mac_eol: MAC_EOL,
test_double_dedent_unix_eol: UNIX_EOL, test_double_dedent_unix_eol: UNIX_EOL,
} }
test_double_dedent_with_tabs! {
test_double_dedent_tabs_windows_eol: WINDOWS_EOL,
test_double_dedent_tabs_mac_eol: MAC_EOL,
test_double_dedent_tabs_unix_eol: UNIX_EOL,
}
macro_rules! test_newline_in_brackets { macro_rules! test_newline_in_brackets {
($($name:ident: $eol:expr,)*) => { ($($name:ident: $eol:expr,)*) => {
$( $(
@@ -1297,21 +1396,27 @@ mod tests {
vec![ vec![
Tok::String { Tok::String {
value: String::from("double"), value: String::from("double"),
is_fstring: false,
}, },
Tok::String { Tok::String {
value: String::from("single"), value: String::from("single"),
is_fstring: false,
}, },
Tok::String { Tok::String {
value: String::from("can't"), value: String::from("can't"),
is_fstring: false,
}, },
Tok::String { Tok::String {
value: String::from("\\\""), value: String::from("\\\""),
is_fstring: false,
}, },
Tok::String { Tok::String {
value: String::from("\t\r\n"), value: String::from("\t\r\n"),
is_fstring: false,
}, },
Tok::String { Tok::String {
value: String::from("\\g"), value: String::from("\\g"),
is_fstring: false,
}, },
] ]
); );
@@ -1329,6 +1434,7 @@ mod tests {
vec![ vec![
Tok::String { Tok::String {
value: String::from("abcdef"), value: String::from("abcdef"),
is_fstring: false,
}, },
] ]
) )

View File

@@ -1,13 +1,11 @@
#[macro_use] #[macro_use]
extern crate log; extern crate log;
extern crate num_bigint;
extern crate num_traits;
pub mod ast; pub mod ast;
pub mod error;
mod fstring;
pub mod lexer; pub mod lexer;
pub mod parser; pub mod parser;
#[cfg_attr(rustfmt, rustfmt_skip)]
mod python; mod python;
pub mod token; pub mod token;
pub use self::parser::parse;

View File

@@ -1,30 +1,10 @@
extern crate lalrpop_util;
use std::error::Error;
use std::fs::File;
use std::io::Read;
use std::iter; use std::iter;
use std::path::Path;
use super::ast; use crate::ast;
use super::lexer; use crate::error::ParseError;
use super::python; use crate::lexer;
use super::token; use crate::python;
use crate::token;
pub fn read_file(filename: &Path) -> Result<String, String> {
info!("Loading file {:?}", filename);
match File::open(&filename) {
Ok(mut file) => {
let mut s = String::new();
match file.read_to_string(&mut s) {
Err(why) => Err(String::from("Reading file failed: ") + why.description()),
Ok(_) => Ok(s),
}
}
Err(why) => Err(String::from("Opening file failed: ") + why.description()),
}
}
/* /*
* Parse python code. * Parse python code.
@@ -32,13 +12,6 @@ pub fn read_file(filename: &Path) -> Result<String, String> {
* https://github.com/antlr/grammars-v4/tree/master/python3 * https://github.com/antlr/grammars-v4/tree/master/python3
*/ */
pub fn parse(filename: &Path) -> Result<ast::Program, String> {
info!("Parsing: {}", filename.display());
let txt = read_file(filename)?;
debug!("Read contents of file: {}", txt);
parse_program(&txt)
}
macro_rules! do_lalr_parsing { macro_rules! do_lalr_parsing {
($input: expr, $pat: ident, $tok: ident) => {{ ($input: expr, $pat: ident, $tok: ident) => {{
let lxr = lexer::make_tokenizer($input); let lxr = lexer::make_tokenizer($input);
@@ -46,7 +19,7 @@ macro_rules! do_lalr_parsing {
let tokenizer = iter::once(Ok(marker_token)).chain(lxr); let tokenizer = iter::once(Ok(marker_token)).chain(lxr);
match python::TopParser::new().parse(tokenizer) { match python::TopParser::new().parse(tokenizer) {
Err(why) => Err(format!("{:?}", why)), Err(err) => Err(ParseError::from(err)),
Ok(top) => { Ok(top) => {
if let ast::Top::$pat(x) = top { if let ast::Top::$pat(x) = top {
Ok(x) Ok(x)
@@ -58,11 +31,11 @@ macro_rules! do_lalr_parsing {
}}; }};
} }
pub fn parse_program(source: &str) -> Result<ast::Program, String> { pub fn parse_program(source: &str) -> Result<ast::Program, ParseError> {
do_lalr_parsing!(source, Program, StartProgram) do_lalr_parsing!(source, Program, StartProgram)
} }
pub fn parse_statement(source: &str) -> Result<ast::LocatedStatement, String> { pub fn parse_statement(source: &str) -> Result<ast::LocatedStatement, ParseError> {
do_lalr_parsing!(source, Statement, StartStatement) do_lalr_parsing!(source, Statement, StartStatement)
} }
@@ -88,7 +61,7 @@ pub fn parse_statement(source: &str) -> Result<ast::LocatedStatement, String> {
/// expr); /// expr);
/// ///
/// ``` /// ```
pub fn parse_expression(source: &str) -> Result<ast::Expression, String> { pub fn parse_expression(source: &str) -> Result<ast::Expression, ParseError> {
do_lalr_parsing!(source, Expression, StartExpression) do_lalr_parsing!(source, Expression, StartExpression)
} }
@@ -103,7 +76,6 @@ mod tests {
#[test] #[test]
fn test_parse_empty() { fn test_parse_empty() {
let parse_ast = parse_program(&String::from("\n")); let parse_ast = parse_program(&String::from("\n"));
assert_eq!(parse_ast, Ok(ast::Program { statements: vec![] })) assert_eq!(parse_ast, Ok(ast::Program { statements: vec![] }))
} }
@@ -122,7 +94,9 @@ mod tests {
name: String::from("print"), name: String::from("print"),
}), }),
args: vec![ast::Expression::String { args: vec![ast::Expression::String {
value: String::from("Hello world"), value: ast::StringGroup::Constant {
value: String::from("Hello world")
}
}], }],
keywords: vec![], keywords: vec![],
}, },
@@ -148,7 +122,9 @@ mod tests {
}), }),
args: vec![ args: vec![
ast::Expression::String { ast::Expression::String {
value: String::from("Hello world"), value: ast::StringGroup::Constant {
value: String::from("Hello world"),
}
}, },
ast::Expression::Number { ast::Expression::Number {
value: ast::Number::Integer { value: ast::Number::Integer {
@@ -179,7 +155,9 @@ mod tests {
name: String::from("my_func"), name: String::from("my_func"),
}), }),
args: vec![ast::Expression::String { args: vec![ast::Expression::String {
value: String::from("positional"), value: ast::StringGroup::Constant {
value: String::from("positional"),
}
}], }],
keywords: vec![ast::Keyword { keywords: vec![ast::Keyword {
name: Some("keyword".to_string()), name: Some("keyword".to_string()),
@@ -266,7 +244,16 @@ mod tests {
node: ast::Statement::Expression { node: ast::Statement::Expression {
expression: ast::Expression::Lambda { expression: ast::Expression::Lambda {
args: ast::Parameters { args: ast::Parameters {
args: vec![String::from("x"), String::from("y")], args: vec![
ast::Parameter {
arg: String::from("x"),
annotation: None,
},
ast::Parameter {
arg: String::from("y"),
annotation: None,
}
],
kwonlyargs: vec![], kwonlyargs: vec![],
vararg: None, vararg: None,
kwarg: None, kwarg: None,
@@ -328,7 +315,9 @@ mod tests {
#[test] #[test]
fn test_parse_class() { fn test_parse_class() {
let source = String::from("class Foo(A, B):\n def __init__(self):\n pass\n def method_with_default(self, arg='default'):\n pass\n"); let source = String::from(
"class Foo(A, B):\n def __init__(self):\n pass\n def method_with_default(self, arg='default'):\n pass\n",
);
assert_eq!( assert_eq!(
parse_statement(&source), parse_statement(&source),
Ok(ast::LocatedStatement { Ok(ast::LocatedStatement {
@@ -350,7 +339,10 @@ mod tests {
node: ast::Statement::FunctionDef { node: ast::Statement::FunctionDef {
name: String::from("__init__"), name: String::from("__init__"),
args: ast::Parameters { args: ast::Parameters {
args: vec![String::from("self")], args: vec![ast::Parameter {
arg: String::from("self"),
annotation: None,
}],
kwonlyargs: vec![], kwonlyargs: vec![],
vararg: None, vararg: None,
kwarg: None, kwarg: None,
@@ -362,6 +354,7 @@ mod tests {
node: ast::Statement::Pass, node: ast::Statement::Pass,
}], }],
decorator_list: vec![], decorator_list: vec![],
returns: None,
} }
}, },
ast::LocatedStatement { ast::LocatedStatement {
@@ -369,12 +362,23 @@ mod tests {
node: ast::Statement::FunctionDef { node: ast::Statement::FunctionDef {
name: String::from("method_with_default"), name: String::from("method_with_default"),
args: ast::Parameters { args: ast::Parameters {
args: vec![String::from("self"), String::from("arg"),], args: vec![
ast::Parameter {
arg: String::from("self"),
annotation: None,
},
ast::Parameter {
arg: String::from("arg"),
annotation: None,
}
],
kwonlyargs: vec![], kwonlyargs: vec![],
vararg: None, vararg: None,
kwarg: None, kwarg: None,
defaults: vec![ast::Expression::String { defaults: vec![ast::Expression::String {
value: "default".to_string() value: ast::StringGroup::Constant {
value: "default".to_string()
}
}], }],
kw_defaults: vec![], kw_defaults: vec![],
}, },
@@ -383,6 +387,7 @@ mod tests {
node: ast::Statement::Pass, node: ast::Statement::Pass,
}], }],
decorator_list: vec![], decorator_list: vec![],
returns: None,
} }
} }
], ],

View File

@@ -4,9 +4,12 @@
// See also: https://greentreesnakes.readthedocs.io/en/latest/nodes.html#keyword // See also: https://greentreesnakes.readthedocs.io/en/latest/nodes.html#keyword
#![allow(unknown_lints,clippy)] #![allow(unknown_lints,clippy)]
use super::ast;
use super::lexer;
use std::iter::FromIterator; use std::iter::FromIterator;
use crate::ast;
use crate::fstring::parse_fstring;
use crate::lexer;
use num_bigint::BigInt; use num_bigint::BigInt;
grammar; grammar;
@@ -105,7 +108,11 @@ ExpressionStatement: ast::LocatedStatement = {
let rhs = e2.into_iter().next().unwrap(); let rhs = e2.into_iter().next().unwrap();
ast::LocatedStatement { ast::LocatedStatement {
location: loc, location: loc,
node: ast::Statement::AugAssign { target: expr, op: op, value: rhs }, node: ast::Statement::AugAssign {
target: Box::new(expr),
op,
value: Box::new(rhs)
},
} }
}, },
}; };
@@ -439,7 +446,7 @@ WithItem: ast::WithItem = {
}; };
FuncDef: ast::LocatedStatement = { FuncDef: ast::LocatedStatement = {
<d:Decorator*> <loc:@L> "def" <i:Identifier> <a:Parameters> ":" <s:Suite> => { <d:Decorator*> <loc:@L> "def" <i:Identifier> <a:Parameters> <r:("->" Test)?> ":" <s:Suite> => {
ast::LocatedStatement { ast::LocatedStatement {
location: loc, location: loc,
node: ast::Statement::FunctionDef { node: ast::Statement::FunctionDef {
@@ -447,13 +454,14 @@ FuncDef: ast::LocatedStatement = {
args: a, args: a,
body: s, body: s,
decorator_list: d, decorator_list: d,
returns: r.map(|x| x.1),
} }
} }
}, },
}; };
Parameters: ast::Parameters = { Parameters: ast::Parameters = {
"(" <a: (TypedArgsList)?> ")" => { "(" <a: (TypedArgsList<TypedParameter>)?> ")" => {
match a { match a {
Some(a) => a, Some(a) => a,
None => Default::default(), None => Default::default(),
@@ -463,8 +471,10 @@ Parameters: ast::Parameters = {
// parameters are (String, None), kwargs are (String, Some(Test)) where Test is // parameters are (String, None), kwargs are (String, Some(Test)) where Test is
// the default // the default
TypedArgsList: ast::Parameters = { // Note that this is a macro which is used once for function defs, and
<param1:TypedParameters> <args2:("," ParameterListStarArgs)?> => { // once for lambda defs.
TypedArgsList<ArgType>: ast::Parameters = {
<param1:TypedParameters<ArgType>> <args2:("," ParameterListStarArgs<ArgType>)?> => {
let (names, default_elements) = param1; let (names, default_elements) = param1;
// Now gather rest of parameters: // Now gather rest of parameters:
@@ -482,7 +492,7 @@ TypedArgsList: ast::Parameters = {
kw_defaults: kw_defaults, kw_defaults: kw_defaults,
} }
}, },
<param1:TypedParameters> <kw:("," KwargParameter)> => { <param1:TypedParameters<ArgType>> <kw:("," KwargParameter<ArgType>)> => {
let (names, default_elements) = param1; let (names, default_elements) = param1;
// Now gather rest of parameters: // Now gather rest of parameters:
@@ -500,7 +510,7 @@ TypedArgsList: ast::Parameters = {
kw_defaults: kw_defaults, kw_defaults: kw_defaults,
} }
}, },
<params:ParameterListStarArgs> => { <params:ParameterListStarArgs<ArgType>> => {
let (vararg, kwonlyargs, kw_defaults, kwarg) = params; let (vararg, kwonlyargs, kw_defaults, kwarg) = params;
ast::Parameters { ast::Parameters {
args: vec![], args: vec![],
@@ -511,7 +521,7 @@ TypedArgsList: ast::Parameters = {
kw_defaults: kw_defaults, kw_defaults: kw_defaults,
} }
}, },
<kw:KwargParameter> => { <kw:KwargParameter<ArgType>> => {
ast::Parameters { ast::Parameters {
args: vec![], args: vec![],
kwonlyargs: vec![], kwonlyargs: vec![],
@@ -525,8 +535,8 @@ TypedArgsList: ast::Parameters = {
// Use inline here to make sure the "," is not creating an ambiguity. // Use inline here to make sure the "," is not creating an ambiguity.
#[inline] #[inline]
TypedParameters: (Vec<String>, Vec<ast::Expression>) = { TypedParameters<ArgType>: (Vec<ast::Parameter>, Vec<ast::Expression>) = {
<param1:TypedParameterDef> <param2:("," TypedParameterDef)*> => { <param1:TypedParameterDef<ArgType>> <param2:("," TypedParameterDef<ArgType>)*> => {
// Combine first parameters: // Combine first parameters:
let mut args = vec![param1]; let mut args = vec![param1];
args.extend(param2.into_iter().map(|x| x.1)); args.extend(param2.into_iter().map(|x| x.1));
@@ -535,7 +545,6 @@ TypedParameters: (Vec<String>, Vec<ast::Expression>) = {
let mut default_elements = vec![]; let mut default_elements = vec![];
for (name, default) in args.into_iter() { for (name, default) in args.into_iter() {
names.push(name.clone());
if let Some(default) = default { if let Some(default) = default {
default_elements.push(default); default_elements.push(default);
} else { } else {
@@ -544,28 +553,35 @@ TypedParameters: (Vec<String>, Vec<ast::Expression>) = {
// have defaults // have defaults
panic!( panic!(
"non-default argument follows default argument: {}", "non-default argument follows default argument: {}",
name &name.arg
); );
} }
} }
names.push(name);
} }
(names, default_elements) (names, default_elements)
} }
}; };
TypedParameterDef: (String, Option<ast::Expression>) = { TypedParameterDef<ArgType>: (ast::Parameter, Option<ast::Expression>) = {
<i:TypedParameter> => (i, None), <i:ArgType> => (i, None),
<i:TypedParameter> "=" <e:Test> => (i, Some(e)), <i:ArgType> "=" <e:Test> => (i, Some(e)),
}; };
// TODO: add type annotations here: UntypedParameter: ast::Parameter = {
TypedParameter: String = { <i:Identifier> => ast::Parameter { arg: i, annotation: None },
Identifier,
}; };
ParameterListStarArgs: (Option<Option<String>>, Vec<String>, Vec<Option<ast::Expression>>, Option<Option<String>>) = { TypedParameter: ast::Parameter = {
"*" <va:Identifier?> <kw:("," TypedParameterDef)*> <kwarg:("," KwargParameter)?> => { <arg:Identifier> <a:(":" Test)?>=> {
let annotation = a.map(|x| Box::new(x.1));
ast::Parameter { arg, annotation }
},
};
ParameterListStarArgs<ArgType>: (Option<Option<ast::Parameter>>, Vec<ast::Parameter>, Vec<Option<ast::Expression>>, Option<Option<ast::Parameter>>) = {
"*" <va:ArgType?> <kw:("," TypedParameterDef<ArgType>)*> <kwarg:("," KwargParameter<ArgType>)?> => {
// Extract keyword arguments: // Extract keyword arguments:
let mut kwonlyargs = vec![]; let mut kwonlyargs = vec![];
let mut kw_defaults = vec![]; let mut kw_defaults = vec![];
@@ -583,8 +599,8 @@ ParameterListStarArgs: (Option<Option<String>>, Vec<String>, Vec<Option<ast::Exp
} }
}; };
KwargParameter: Option<String> = { KwargParameter<ArgType>: Option<ast::Parameter> = {
"**" <kwarg:Identifier?> => { "**" <kwarg:ArgType?> => {
kwarg kwarg
} }
}; };
@@ -608,17 +624,26 @@ ClassDef: ast::LocatedStatement = {
}, },
}; };
Path: ast::Expression = {
<n:Identifier> => ast::Expression::Identifier { name: n },
<p:Path> "." <n:name> => {
ast::Expression::Attribute {
value: Box::new(p),
name: n,
}
},
};
// Decorators: // Decorators:
Decorator: ast::Expression = { Decorator: ast::Expression = {
"@" <n:DottedName> <a: ("(" ArgumentList ")")?> "\n" => { "@" <p:Path> <a: ("(" ArgumentList ")")?> "\n" => {
let name = ast::Expression::Identifier { name: n };
match a { match a {
Some((_, args, _)) => ast::Expression::Call { Some((_, args, _)) => ast::Expression::Call {
function: Box::new(name), function: Box::new(p),
args: args.0, args: args.0,
keywords: args.1, keywords: args.1,
}, },
None => name, None => p,
} }
}, },
}; };
@@ -659,7 +684,7 @@ Test: ast::Expression = {
}; };
LambdaDef: ast::Expression = { LambdaDef: ast::Expression = {
"lambda" <p:TypedArgsList?> ":" <b:Expression> => "lambda" <p:TypedArgsList<UntypedParameter>?> ":" <b:Test> =>
ast::Expression::Lambda { ast::Expression::Lambda {
args: p.unwrap_or(Default::default()), args: p.unwrap_or(Default::default()),
body:Box::new(b) body:Box::new(b)
@@ -785,7 +810,8 @@ SliceOp: ast::Expression = {
} }
Atom: ast::Expression = { Atom: ast::Expression = {
StringConstant, <s:StringGroup> => ast::Expression::String { value: s },
<b:Bytes> => ast::Expression::Bytes { value: b },
<n:Number> => ast::Expression::Number { value: n }, <n:Number> => ast::Expression::Number { value: n },
<i:Identifier> => ast::Expression::Identifier { name: i }, <i:Identifier> => ast::Expression::Identifier { name: i },
"[" <e:TestListComp?> "]" => { "[" <e:TestListComp?> "]" => {
@@ -822,6 +848,7 @@ Atom: ast::Expression = {
"True" => ast::Expression::True, "True" => ast::Expression::True,
"False" => ast::Expression::False, "False" => ast::Expression::False,
"None" => ast::Expression::None, "None" => ast::Expression::None,
"..." => ast::Expression::Ellipsis,
}; };
TestListComp: Vec<ast::Expression> = { TestListComp: Vec<ast::Expression> = {
@@ -988,14 +1015,28 @@ Number: ast::Number = {
<s:complex> => { ast::Number::Complex { real: s.0, imag: s.1 } }, <s:complex> => { ast::Number::Complex { real: s.0, imag: s.1 } },
}; };
StringConstant: ast::Expression = { StringGroup: ast::StringGroup = {
<s:string+> => { <s:string+> =>? {
let glued = s.join(""); let mut values = vec![];
ast::Expression::String { value: glued } for (value, is_fstring) in s {
values.push(if is_fstring {
parse_fstring(&value)?
} else {
ast::StringGroup::Constant { value }
})
}
Ok(if values.len() > 1 {
ast::StringGroup::Joined { values }
} else {
values.into_iter().next().unwrap()
})
}, },
};
Bytes: Vec<u8> = {
<s:bytes+> => { <s:bytes+> => {
let glued = s.into_iter().flatten().collect::<Vec<u8>>(); s.into_iter().flatten().collect::<Vec<u8>>()
ast::Expression::Bytes { value: glued }
}, },
}; };
@@ -1017,6 +1058,7 @@ extern {
"~" => lexer::Tok::Tilde, "~" => lexer::Tok::Tilde,
":" => lexer::Tok::Colon, ":" => lexer::Tok::Colon,
"." => lexer::Tok::Dot, "." => lexer::Tok::Dot,
"..." => lexer::Tok::Ellipsis,
"," => lexer::Tok::Comma, "," => lexer::Tok::Comma,
"*" => lexer::Tok::Star, "*" => lexer::Tok::Star,
"**" => lexer::Tok::DoubleStar, "**" => lexer::Tok::DoubleStar,
@@ -1055,6 +1097,7 @@ extern {
"<=" => lexer::Tok::LessEqual, "<=" => lexer::Tok::LessEqual,
">" => lexer::Tok::Greater, ">" => lexer::Tok::Greater,
">=" => lexer::Tok::GreaterEqual, ">=" => lexer::Tok::GreaterEqual,
"->" => lexer::Tok::Rarrow,
"and" => lexer::Tok::And, "and" => lexer::Tok::And,
"as" => lexer::Tok::As, "as" => lexer::Tok::As,
"assert" => lexer::Tok::Assert, "assert" => lexer::Tok::Assert,
@@ -1092,7 +1135,7 @@ extern {
int => lexer::Tok::Int { value: <BigInt> }, int => lexer::Tok::Int { value: <BigInt> },
float => lexer::Tok::Float { value: <f64> }, float => lexer::Tok::Float { value: <f64> },
complex => lexer::Tok::Complex { real: <f64>, imag: <f64> }, complex => lexer::Tok::Complex { real: <f64>, imag: <f64> },
string => lexer::Tok::String { value: <String> }, string => lexer::Tok::String { value: <String>, is_fstring: <bool> },
bytes => lexer::Tok::Bytes { value: <Vec<u8>> }, bytes => lexer::Tok::Bytes { value: <Vec<u8>> },
name => lexer::Tok::Name { name: <String> }, name => lexer::Tok::Name { name: <String> },
"\n" => lexer::Tok::Newline, "\n" => lexer::Tok::Newline,

View File

@@ -9,7 +9,7 @@ pub enum Tok {
Int { value: BigInt }, Int { value: BigInt },
Float { value: f64 }, Float { value: f64 },
Complex { real: f64, imag: f64 }, Complex { real: f64, imag: f64 },
String { value: String }, String { value: String, is_fstring: bool },
Bytes { value: Vec<u8> }, Bytes { value: Vec<u8> },
Newline, Newline,
Indent, Indent,

View File

@@ -2,6 +2,7 @@
name = "py_code_object" name = "py_code_object"
version = "0.1.0" version = "0.1.0"
authors = ["Shing Lyu <shing.lyu@gmail.com>"] authors = ["Shing Lyu <shing.lyu@gmail.com>"]
edition = "2018"
[dependencies] [dependencies]
log = "0.3" log = "0.3"

View File

@@ -2,6 +2,7 @@
name = "python_compiler" name = "python_compiler"
version = "0.1.0" version = "0.1.0"
authors = ["Shing Lyu <shing.lyu@gmail.com>"] authors = ["Shing Lyu <shing.lyu@gmail.com>"]
edition = "2018"
[dependencies] [dependencies]
cpython = { git = "https://github.com/dgrunwald/rust-cpython.git" } cpython = { git = "https://github.com/dgrunwald/rust-cpython.git" }

View File

@@ -56,7 +56,7 @@ impl VirtualMachine {
} }
} }
// Can we get rid of the code paramter? // Can we get rid of the code parameter?
fn make_frame(&self, code: PyCodeObject, callargs: HashMap<String, Rc<NativeType>>, globals: Option<HashMap<String, Rc<NativeType>>>) -> Frame { fn make_frame(&self, code: PyCodeObject, callargs: HashMap<String, Rc<NativeType>>, globals: Option<HashMap<String, Rc<NativeType>>>) -> Frame {
//populate the globals and locals //populate the globals and locals
@@ -345,7 +345,7 @@ impl VirtualMachine {
let exception = match argc { let exception = match argc {
1 => curr_frame.stack.pop().unwrap(), 1 => curr_frame.stack.pop().unwrap(),
0 | 2 | 3 => panic!("Not implemented!"), 0 | 2 | 3 => panic!("Not implemented!"),
_ => panic!("Invalid paramter for RAISE_VARARGS, must be between 0 to 3") _ => panic!("Invalid parameter for RAISE_VARARGS, must be between 0 to 3")
}; };
panic!("{:?}", exception); panic!("{:?}", exception);
} }

1
rustfmt.toml Normal file
View File

@@ -0,0 +1 @@
edition = "2018"

View File

@@ -1,4 +1,3 @@
//extern crate rustpython_parser;
#[macro_use] #[macro_use]
extern crate clap; extern crate clap;
extern crate env_logger; extern crate env_logger;
@@ -9,16 +8,19 @@ extern crate rustpython_vm;
extern crate rustyline; extern crate rustyline;
use clap::{App, Arg}; use clap::{App, Arg};
use rustpython_parser::parser; use rustpython_parser::error::ParseError;
use rustpython_vm::obj::objstr; use rustpython_vm::{
use rustpython_vm::print_exception; compile,
use rustpython_vm::pyobject::{AttributeProtocol, PyObjectRef, PyResult}; error::CompileError,
use rustpython_vm::VirtualMachine; frame::ScopeRef,
use rustpython_vm::{compile, import}; import,
use rustyline::error::ReadlineError; obj::objstr,
use rustyline::Editor; print_exception,
use std::path::Path; pyobject::{AttributeProtocol, PyResult},
use std::path::PathBuf; util, VirtualMachine,
};
use rustyline::{error::ReadlineError, Editor};
use std::path::{Path, PathBuf};
fn main() { fn main() {
env_logger::init(); env_logger::init();
@@ -60,7 +62,7 @@ fn main() {
// Figure out if a script was passed: // Figure out if a script was passed:
match matches.value_of("script") { match matches.value_of("script") {
None => run_shell(&mut vm), None => run_shell(&mut vm),
Some(filename) => run_script(&mut vm, &filename.to_string()), Some(filename) => run_script(&mut vm, filename),
} }
}; };
@@ -68,8 +70,17 @@ fn main() {
handle_exception(&mut vm, result); handle_exception(&mut vm, result);
} }
fn _run_string(vm: &mut VirtualMachine, source: &str, source_path: Option<String>) -> PyResult { fn _run_string(vm: &mut VirtualMachine, source: &str, source_path: String) -> PyResult {
let code_obj = compile::compile(vm, &source.to_string(), compile::Mode::Exec, source_path)?; let code_obj = compile::compile(
source,
&compile::Mode::Exec,
source_path,
vm.ctx.code_type(),
)
.map_err(|err| {
let syntax_error = vm.context().exceptions.syntax_error.clone();
vm.new_exception(syntax_error, err.to_string())
})?;
// trace!("Code object: {:?}", code_obj.borrow()); // trace!("Code object: {:?}", code_obj.borrow());
let builtins = vm.get_builtin_scope(); let builtins = vm.get_builtin_scope();
let vars = vm.context().new_scope(Some(builtins)); // Keep track of local variables let vars = vm.context().new_scope(Some(builtins)); // Keep track of local variables
@@ -77,12 +88,9 @@ fn _run_string(vm: &mut VirtualMachine, source: &str, source_path: Option<String
} }
fn handle_exception(vm: &mut VirtualMachine, result: PyResult) { fn handle_exception(vm: &mut VirtualMachine, result: PyResult) {
match result { if let Err(err) = result {
Ok(_value) => {} print_exception(vm, &err);
Err(err) => { std::process::exit(1);
print_exception(vm, &err);
std::process::exit(1);
}
} }
} }
@@ -90,8 +98,8 @@ fn run_command(vm: &mut VirtualMachine, mut source: String) -> PyResult {
debug!("Running command {}", source); debug!("Running command {}", source);
// This works around https://github.com/RustPython/RustPython/issues/17 // This works around https://github.com/RustPython/RustPython/issues/17
source.push_str("\n"); source.push('\n');
_run_string(vm, &source, None) _run_string(vm, &source, "<stdin>".to_string())
} }
fn run_module(vm: &mut VirtualMachine, module: &str) -> PyResult { fn run_module(vm: &mut VirtualMachine, module: &str) -> PyResult {
@@ -103,43 +111,53 @@ fn run_module(vm: &mut VirtualMachine, module: &str) -> PyResult {
fn run_script(vm: &mut VirtualMachine, script_file: &str) -> PyResult { fn run_script(vm: &mut VirtualMachine, script_file: &str) -> PyResult {
debug!("Running file {}", script_file); debug!("Running file {}", script_file);
// Parse an ast from it: // Parse an ast from it:
let filepath = Path::new(script_file); let file_path = Path::new(script_file);
match parser::read_file(filepath) { match util::read_file(file_path) {
Ok(source) => _run_string(vm, &source, Some(filepath.to_str().unwrap().to_string())), Ok(source) => _run_string(vm, &source, file_path.to_str().unwrap().to_string()),
Err(msg) => { Err(err) => {
error!("Parsing went horribly wrong: {}", msg); error!("Failed reading file: {:?}", err.kind());
std::process::exit(1); std::process::exit(1);
} }
} }
} }
fn shell_exec(vm: &mut VirtualMachine, source: &str, scope: PyObjectRef) -> bool { fn shell_exec(vm: &mut VirtualMachine, source: &str, scope: ScopeRef) -> Result<(), CompileError> {
match compile::compile(vm, &source.to_string(), compile::Mode::Single, None) { match compile::compile(
source,
&compile::Mode::Single,
"<stdin>".to_string(),
vm.ctx.code_type(),
) {
Ok(code) => { Ok(code) => {
match vm.run_code_obj(code, scope) { if let Err(err) = vm.run_code_obj(code, scope) {
Ok(_value) => {
// Printed already.
}
Err(err) => {
print_exception(vm, &err);
}
}
}
Err(err) => {
// Enum rather than special string here.
let name = vm.new_str("msg".to_string());
let msg = match vm.get_attribute(err.clone(), name) {
Ok(value) => objstr::get_value(&value),
Err(_) => panic!("Expected msg attribute on exception object!"),
};
if msg == "Unexpected end of input." {
return false;
} else {
print_exception(vm, &err); print_exception(vm, &err);
} }
Ok(())
} }
}; // Don't inject syntax errors for line continuation
true Err(err @ CompileError::Parse(ParseError::EOF(_))) => Err(err),
Err(err) => {
let syntax_error = vm.context().exceptions.syntax_error.clone();
let exc = vm.new_exception(syntax_error, format!("{}", err));
print_exception(vm, &exc);
Err(err)
}
}
}
#[cfg(not(unix))]
fn get_history_path() -> PathBuf {
PathBuf::from(".repl_history.txt")
}
#[cfg(unix)]
fn get_history_path() -> PathBuf {
//work around for windows dependent builds. The xdg crate is unix specific
//so access to the BaseDirectories struct breaks builds on python.
extern crate xdg;
let xdg_dirs = xdg::BaseDirectories::with_prefix("rustpython").unwrap();
xdg_dirs.place_cache_file("repl_history.txt").unwrap()
} }
fn run_shell(vm: &mut VirtualMachine) -> PyResult { fn run_shell(vm: &mut VirtualMachine) -> PyResult {
@@ -152,57 +170,34 @@ fn run_shell(vm: &mut VirtualMachine) -> PyResult {
// Read a single line: // Read a single line:
let mut input = String::new(); let mut input = String::new();
let mut rl = Editor::<()>::new(); let mut repl = Editor::<()>::new();
// TODO: Store the history in a proper XDG directory // Retrieve a `history_path_str` dependent on the OS
let repl_history_path = ".repl_history.txt"; let repl_history_path_str = &get_history_path();
if rl.load_history(repl_history_path).is_err() { if repl.load_history(repl_history_path_str).is_err() {
println!("No previous history."); println!("No previous history.");
} }
let ps1 = &objstr::get_value(&vm.sys_module.get_attr("ps1").unwrap());
let ps2 = &objstr::get_value(&vm.sys_module.get_attr("ps2").unwrap());
let mut prompt = ps1;
loop { loop {
// TODO: modules dont support getattr / setattr yet match repl.readline(prompt) {
//let prompt = match vm.get_attribute(vm.sys_module.clone(), "ps1") {
// Ok(value) => objstr::get_value(&value),
// Err(_) => ">>>>> ".to_string(),
//};
// We can customize the prompt:
let ps1 = objstr::get_value(&vm.sys_module.get_attr("ps1").unwrap());
let ps2 = objstr::get_value(&vm.sys_module.get_attr("ps2").unwrap());
match rl.readline(&ps1) {
Ok(line) => { Ok(line) => {
debug!("You entered {:?}", line);
input.push_str(&line); input.push_str(&line);
input.push_str("\n"); input.push_str("\n");
repl.add_history_entry(line.trim_end().as_ref());
debug!("You entered {:?}", input); match shell_exec(vm, &input, vars.clone()) {
if shell_exec(vm, &input, vars.clone()) { Err(CompileError::Parse(ParseError::EOF(_))) => {
// Line was complete. prompt = ps2;
rl.add_history_entry(input.trim_right().as_ref()); continue;
input = String::new(); }
} else { _ => {
loop { prompt = ps1;
// until an empty line is pressed AND the code is complete input = String::new();
//let prompt = match vm.get_attribute(vm.sys_module.clone(), "ps2") {
// Ok(value) => objstr::get_value(&value),
// Err(_) => "..... ".to_string(),
//};
match rl.readline(&ps2) {
Ok(line) => {
if line.len() == 0 {
if shell_exec(vm, &input, vars.clone()) {
rl.add_history_entry(input.trim_right().as_ref());
input = String::new();
break;
}
} else {
input.push_str(&line);
input.push_str("\n");
}
}
Err(msg) => panic!("Error: {:?}", msg),
}
} }
} }
} }
@@ -220,7 +215,7 @@ fn run_shell(vm: &mut VirtualMachine) -> PyResult {
} }
}; };
} }
rl.save_history(repl_history_path).unwrap(); repl.save_history(repl_history_path_str).unwrap();
Ok(vm.get_none()) Ok(vm.get_none())
} }

View File

@@ -10,7 +10,32 @@ pip install pipenv
(cd tests; pipenv install) (cd tests; pipenv install)
# Build outside of the test runner # Build outside of the test runner
cargo build --verbose --release if [ $CODE_COVERAGE = "true" ]
then
find . -name '*.gcda' -delete
export CARGO_INCREMENTAL=0
export RUSTFLAGS="-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Zno-landing-pads"
cargo build --verbose
else
cargo build --verbose --release
fi
# Run the tests # Run the tests
(cd tests; pipenv run pytest) (cd tests; pipenv run pytest)
if [ $CODE_COVERAGE = "true" ]
then
cargo test --verbose --all
zip -0 ccov.zip `find . \( -name "rustpython*.gc*" \) -print`
# Install grcov
curl -L https://github.com/mozilla/grcov/releases/download/v0.4.1/grcov-linux-x86_64.tar.bz2 | tar jxf -
./grcov ccov.zip -s . -t lcov --llvm --branch --ignore-not-existing --ignore-dir "/*" -p "x" > lcov.info
# Install codecov.io reporter
curl -s https://codecov.io/bash -o codecov.sh
bash codecov.sh -f lcov.info
fi

View File

@@ -44,7 +44,12 @@ assert int() == 0
a = complex(2, 4) a = complex(2, 4)
assert type(a) is complex assert type(a) is complex
assert type(a + a) is complex assert type(a + a) is complex
assert repr(a) == '(2+4j)'
a = 10j
assert repr(a) == '10j'
a = 1
assert a.conjugate() == a
a = 12345 a = 12345

View File

@@ -16,6 +16,9 @@ assert bool() == False
assert bool(1) == True assert bool(1) == True
assert bool({}) == False assert bool({}) == False
assert bool(NotImplemented) == True
assert bool(...) == True
if not 1: if not 1:
raise BaseException raise BaseException
@@ -46,3 +49,5 @@ assert True + True == 2
assert False * 7 == 0 assert False * 7 == 0
assert True > 0 assert True > 0
assert int(True) == 1 assert int(True) == 1
assert True.conjugate() == 1
assert isinstance(True.conjugate(), int)

View File

@@ -0,0 +1,26 @@
assert not callable(1)
def f(): pass
# TODO uncomment when callable types get unified __call__ (or equivalent)
#assert callable(f)
#assert callable(len)
#assert callable(lambda: 1)
assert callable(int)
class C:
def __init__(self):
# must be defined on class
self.__call__ = lambda self: 1
def f(self): pass
assert callable(C)
assert not callable(C())
#assert callable(C().f)
class C:
def __call__(self): pass
assert callable(C())
class C1(C): pass
assert callable(C1())
class C:
__call__ = 1
# CPython returns true here, but fails when actually calling it
assert callable(C())

View File

@@ -0,0 +1,46 @@
# __abs__
assert abs(complex(3, 4)) == 5
assert abs(complex(3, -4)) == 5
assert abs(complex(1.5, 2.5)) == 2.9154759474226504
# __eq__
assert complex(1, -1) == complex(1, -1)
assert complex(1, 0) == 1
assert 1 == complex(1, 0)
assert complex(1, 1) != 1
assert 1 != complex(1, 1)
assert complex(1, 0) == 1.0
assert 1.0 == complex(1, 0)
assert complex(1, 1) != 1.0
assert 1.0 != complex(1, 1)
assert complex(1, 0) != 1.5
assert not 1.0 != complex(1, 0)
assert bool(complex(1, 0))
assert complex(1, 2) != complex(1, 1)
assert complex(1, 2) != 'foo'
assert complex(1, 2).__eq__('foo') == NotImplemented
# __neg__
assert -complex(1, -1) == complex(-1, 1)
assert -complex(0, 0) == complex(0, 0)
# real
a = complex(3, 4)
b = 4j
assert a.real == 3
assert b.real == 0
# imag
assert a.imag == 4
assert b.imag == 4
# int and complex addition
assert 1 + 1j == complex(1, 1)
assert 1j + 1 == complex(1, 1)
assert (1j + 1) + 3 == complex(4, 1)
assert 3 + (1j + 1) == complex(4, 1)

View File

@@ -4,3 +4,7 @@ assert len({}) == 0
assert len({"a": "b"}) == 1 assert len({"a": "b"}) == 1
assert len({"a": "b", "b": 1}) == 2 assert len({"a": "b", "b": 1}) == 2
assert len({"a": "b", "b": 1, "a" + "b": 2*2}) == 3 assert len({"a": "b", "b": 1, "a" + "b": 2*2}) == 3
d = {}
d['a'] = d
assert repr(d) == "{'a': {...}}"

View File

@@ -0,0 +1,12 @@
class A:
def test():
pass
a = A()
assert "test" in dir(a)
import socket
assert "AF_INET" in dir(socket)

View File

@@ -1,3 +1,8 @@
from testutils import assert_raises
assert divmod(11, 3) == (3, 2) assert divmod(11, 3) == (3, 2)
assert divmod(8,11) == (0, 8) assert divmod(8,11) == (0, 8)
assert divmod(0.873, 0.252) == (3.0, 0.11699999999999999) assert divmod(0.873, 0.252) == (3.0, 0.11699999999999999)
assert_raises(ZeroDivisionError, lambda: divmod(5, 0), 'divmod by zero')
assert_raises(ZeroDivisionError, lambda: divmod(5.0, 0.0), 'divmod by zero')

View File

@@ -0,0 +1,22 @@
assert list(enumerate(['a', 'b', 'c'])) == [(0, 'a'), (1, 'b'), (2, 'c')]
assert type(enumerate([])) == enumerate
assert list(enumerate(['a', 'b', 'c'], -100)) == [(-100, 'a'), (-99, 'b'), (-98, 'c')]
assert list(enumerate(['a', 'b', 'c'], 2**200)) == [(2**200, 'a'), (2**200 + 1, 'b'), (2**200 + 2, 'c')]
# test infinite iterator
class Counter(object):
counter = 0
def __next__(self):
self.counter += 1
return self.counter
def __iter__(self):
return self
it = enumerate(Counter())
assert next(it) == (0, 1)
assert next(it) == (1, 2)

View File

@@ -0,0 +1,32 @@
assert list(filter(lambda x: ((x % 2) == 0), [0, 1, 2])) == [0, 2]
# None implies identity
assert list(filter(None, [0, 1, 2])) == [1, 2]
assert type(filter(None, [])) == filter
# test infinite iterator
class Counter(object):
counter = 0
def __next__(self):
self.counter += 1
return self.counter
def __iter__(self):
return self
it = filter(lambda x: ((x % 2) == 0), Counter())
assert next(it) == 2
assert next(it) == 4
def predicate(x):
if x == 0:
raise StopIteration()
return True
assert list(filter(predicate, [1, 2, 0, 4, 5])) == [1, 2]

View File

@@ -0,0 +1,9 @@
from testutils import assert_raises
assert format(5, "b") == "101"
assert_raises(TypeError, lambda: format(2, 3), 'format called with number')
assert format({}) == "{}"
assert_raises(TypeError, lambda: format({}, 'b'), 'format_spec not empty for dict')

View File

@@ -1,9 +1,6 @@
from testutils import assert_raises
assert hex(16) == '0x10' assert hex(16) == '0x10'
assert hex(-16) == '-0x10' assert hex(-16) == '-0x10'
try: assert_raises(TypeError, lambda: hex({}), 'ord() called with dict')
hex({})
except TypeError:
pass
else:
assert False, "TypeError not raised when ord() is called with a dict"

View File

@@ -0,0 +1,19 @@
a = 5
b = 6
loc = locals()
assert loc['a'] == 5
assert loc['b'] == 6
def f():
c = 4
a = 7
loc = locals()
assert loc['a'] == 4
assert loc['c'] == 7
assert not 'b' in loc

View File

@@ -0,0 +1,34 @@
a = list(map(str, [1, 2, 3]))
assert a == ['1', '2', '3']
b = list(map(lambda x, y: x + y, [1, 2, 4], [3, 5]))
assert b == [4, 7]
assert type(map(lambda x: x, [])) == map
# test infinite iterator
class Counter(object):
counter = 0
def __next__(self):
self.counter += 1
return self.counter
def __iter__(self):
return self
it = map(lambda x: x+1, Counter())
assert next(it) == 2
assert next(it) == 3
def mapping(x):
if x == 0:
raise StopIteration()
return x
assert list(map(mapping, [1, 2, 0, 4, 5])) == [1, 2]

View File

@@ -1,3 +1,5 @@
from testutils import assert_raises
# simple values # simple values
assert max(0, 0) == 0 assert max(0, 0) == 0
assert max(1, 0) == 1 assert max(1, 0) == 1
@@ -14,32 +16,17 @@ assert max({
}) == "b" }) == "b"
assert max([1, 2], default=0) == 2 assert max([1, 2], default=0) == 2
assert max([], default=0) == 0 assert max([], default=0) == 0
try: assert_raises(ValueError, lambda: max([]))
max([])
except ValueError:
pass
else:
assert False, "ValueError was not raised"
# key parameter # key parameter
assert max(1, 2, -3, key=abs) == -3 assert max(1, 2, -3, key=abs) == -3
assert max([1, 2, -3], key=abs) == -3 assert max([1, 2, -3], key=abs) == -3
# no argument # no argument
try: assert_raises(TypeError, lambda: max())
max()
except TypeError:
pass
else:
assert False, "TypeError was not raised"
# one non-iterable argument # one non-iterable argument
try: assert_raises(TypeError, lambda: max(1))
max(1)
except TypeError:
pass
else:
assert False, "TypeError was not raised"
# custom class # custom class
@@ -64,9 +51,4 @@ class MyNotComparable():
pass pass
try: assert_raises(TypeError, lambda: max(MyNotComparable(), MyNotComparable()))
max(MyNotComparable(), MyNotComparable())
except TypeError:
pass
else:
assert False, "TypeError was not raised"

View File

@@ -1,3 +1,5 @@
from testutils import assert_raises
# simple values # simple values
assert min(0, 0) == 0 assert min(0, 0) == 0
assert min(1, 0) == 0 assert min(1, 0) == 0
@@ -14,32 +16,18 @@ assert min({
}) == "a" }) == "a"
assert min([1, 2], default=0) == 1 assert min([1, 2], default=0) == 1
assert min([], default=0) == 0 assert min([], default=0) == 0
try:
min([]) assert_raises(ValueError, lambda: min([]))
except ValueError:
pass
else:
assert False, "ValueError was not raised"
# key parameter # key parameter
assert min(1, 2, -3, key=abs) == 1 assert min(1, 2, -3, key=abs) == 1
assert min([1, 2, -3], key=abs) == 1 assert min([1, 2, -3], key=abs) == 1
# no argument # no argument
try: assert_raises(TypeError, lambda: min())
min()
except TypeError:
pass
else:
assert False, "TypeError was not raised"
# one non-iterable argument # one non-iterable argument
try: assert_raises(TypeError, lambda: min(1))
min(1)
except TypeError:
pass
else:
assert False, "TypeError was not raised"
# custom class # custom class
@@ -64,9 +52,4 @@ class MyNotComparable():
pass pass
try: assert_raises(TypeError, lambda: min(MyNotComparable(), MyNotComparable()))
min(MyNotComparable(), MyNotComparable())
except TypeError:
pass
else:
assert False, "TypeError was not raised"

View File

@@ -0,0 +1,6 @@
from testutils import assert_raises
fd = open('README.md')
assert 'RustPython' in fd.read()
assert_raises(FileNotFoundError, lambda: open('DoesNotExist'))

View File

@@ -1,23 +1,9 @@
from testutils import assert_raises
assert ord("a") == 97 assert ord("a") == 97
assert ord("é") == 233 assert ord("é") == 233
assert ord("🤡") == 129313 assert ord("🤡") == 129313
try:
ord()
except TypeError:
pass
else:
assert False, "TypeError not raised when ord() is called with no argument"
try: assert_raises(TypeError, lambda: ord(), "ord() is called with no argument")
ord("") assert_raises(TypeError, lambda: ord(""), "ord() is called with an empty string")
except TypeError: assert_raises(TypeError, lambda: ord("ab"), "ord() is called with more than one character")
pass
else:
assert False, "TypeError not raised when ord() is called with an empty string"
try:
ord("ab")
except TypeError:
pass
else:
assert False, "TypeError not raised when ord() is called with more than one character"

View File

@@ -0,0 +1,52 @@
from testutils import assert_raises
assert range(2**63+1)[2**63] == 9223372036854775808
# len tests
assert len(range(10, 5)) == 0, 'Range with no elements should have length = 0'
assert len(range(10, 5, -2)) == 3, 'Expected length 3, for elements: 10, 8, 6'
assert len(range(5, 10, 2)) == 3, 'Expected length 3, for elements: 5, 7, 9'
# index tests
assert range(10).index(6) == 6
assert range(4, 10).index(6) == 2
assert range(4, 10, 2).index(6) == 1
assert range(10, 4, -2).index(8) == 1
assert_raises(ValueError, lambda: range(10).index(-1), 'out of bounds')
assert_raises(ValueError, lambda: range(10).index(10), 'out of bounds')
assert_raises(ValueError, lambda: range(4, 10, 2).index(5), 'out of step')
assert_raises(ValueError, lambda: range(10).index('foo'), 'not an int')
# count tests
assert range(10).count(2) == 1
assert range(10).count(11) == 0
assert range(10).count(-1) == 0
assert range(9, 12).count(10) == 1
assert range(4, 10, 2).count(4) == 1
assert range(4, 10, 2).count(7) == 0
assert range(10).count("foo") == 0
# __bool__
assert bool(range(1))
assert bool(range(1, 2))
assert not bool(range(0))
assert not bool(range(1, 1))
# __contains__
assert 6 in range(10)
assert 6 in range(4, 10)
assert 6 in range(4, 10, 2)
assert 10 in range(10, 4, -2)
assert 8 in range(10, 4, -2)
assert -1 not in range(10)
assert 9 not in range(10, 4, -2)
assert 4 not in range(10, 4, -2)
assert 'foo' not in range(10)
# __reversed__
assert list(reversed(range(5))) == [4, 3, 2, 1, 0]
assert list(reversed(range(5, 0, -1))) == [1, 2, 3, 4, 5]
assert list(reversed(range(1,10,5))) == [6, 1]

View File

@@ -0,0 +1 @@
assert list(reversed(range(5))) == [4, 3, 2, 1, 0]

View File

@@ -0,0 +1,73 @@
from testutils import assert_raises
a = []
assert a[:] == []
assert a[:2**100] == []
assert a[-2**100:] == []
assert a[::2**100] == []
assert a[10:20] == []
assert a[-20:-10] == []
b = [1, 2]
assert b[:] == [1, 2]
assert b[:2**100] == [1, 2]
assert b[-2**100:] == [1, 2]
assert b[2**100:] == []
assert b[::2**100] == [1]
assert b[-10:1] == [1]
assert b[0:0] == []
assert b[1:0] == []
assert_raises(ValueError, lambda: b[::0], 'zero step slice')
assert b[::-1] == [2, 1]
assert b[1::-1] == [2, 1]
assert b[0::-1] == [1]
assert b[0:-5:-1] == [1]
assert b[:0:-1] == [2]
assert b[5:0:-1] == [2]
c = list(range(10))
assert c[9:6:-3] == [9]
assert c[9::-3] == [9, 6, 3, 0]
assert c[9::-4] == [9, 5, 1]
assert c[8::-2**100] == [8]
assert c[7:7:-2] == []
assert c[7:8:-2] == []
d = "123456"
assert d[3::-1] == "4321"
assert d[4::-3] == "52"
slice_a = slice(5)
assert slice_a.start is None
assert slice_a.stop == 5
assert slice_a.step is None
slice_b = slice(1, 5)
assert slice_b.start == 1
assert slice_b.stop == 5
assert slice_b.step is None
slice_c = slice(1, 5, 2)
assert slice_c.start == 1
assert slice_c.stop == 5
assert slice_c.step == 2
class SubScript(object):
def __getitem__(self, item):
assert type(item) == slice
def __setitem__(self, key, value):
assert type(key) == slice
ss = SubScript()
_ = ss[:]
ss[:1] = 1

View File

@@ -0,0 +1,24 @@
assert list(zip(['a', 'b', 'c'], range(3), [9, 8, 7, 99])) == [('a', 0, 9), ('b', 1, 8), ('c', 2, 7)]
assert list(zip(['a', 'b', 'c'])) == [('a',), ('b',), ('c',)]
assert list(zip()) == []
assert list(zip(*zip(['a', 'b', 'c'], range(1, 4)))) == [('a', 'b', 'c'), (1, 2, 3)]
# test infinite iterator
class Counter(object):
def __init__(self, counter=0):
self.counter = counter
def __next__(self):
self.counter += 1
return self.counter
def __iter__(self):
return self
it = zip(Counter(), Counter(3))
assert next(it) == (1, 4)
assert next(it) == (2, 5)

View File

@@ -1,22 +1,12 @@
x = sum(map(int, ['1', '2', '3']))
a = list(map(str, [1, 2, 3]))
assert a == ['1', '2', '3']
x = sum(map(int, a))
assert x == 6 assert x == 6
assert callable(type) assert callable(type)
# TODO: # TODO:
# assert callable(callable) # assert callable(callable)
assert list(enumerate(['a', 'b', 'c'])) == [(0, 'a'), (1, 'b'), (2, 'c')]
assert type(frozenset) is type assert type(frozenset) is type
assert list(zip(['a', 'b', 'c'], range(3), [9, 8, 7, 99])) == [('a', 0, 9), ('b', 1, 8), ('c', 2, 7)]
assert list(filter(lambda x: ((x % 2) == 0), [0, 1, 2])) == [0, 2]
assert 3 == eval('1+2') assert 3 == eval('1+2')
code = compile('5+3', 'x.py', 'eval') code = compile('5+3', 'x.py', 'eval')

View File

@@ -0,0 +1,67 @@
#__getitem__ not implemented yet
#a = bytearray(b'abc')
#assert a[0] == b'a'
#assert a[1] == b'b'
assert len(bytearray([1,2,3])) == 3
assert bytearray(b'1a23').isalnum()
assert not bytearray(b'1%a23').isalnum()
assert bytearray(b'abc').isalpha()
assert not bytearray(b'abc1').isalpha()
# travis doesn't like this
#assert bytearray(b'xyz').isascii()
#assert not bytearray([128, 157, 32]).isascii()
assert bytearray(b'1234567890').isdigit()
assert not bytearray(b'12ab').isdigit()
l = bytearray(b'lower')
assert l.islower()
assert not l.isupper()
assert l.upper().isupper()
assert not bytearray(b'Super Friends').islower()
assert bytearray(b' \n\t').isspace()
assert not bytearray(b'\td\n').isspace()
b = bytearray(b'UPPER')
assert b.isupper()
assert not b.islower()
assert b.lower().islower()
assert not bytearray(b'tuPpEr').isupper()
assert bytearray(b'Is Title Case').istitle()
assert not bytearray(b'is Not title casE').istitle()
a = bytearray(b'abcd')
a.clear()
assert len(a) == 0
try:
bytearray([400])
except ValueError:
pass
else:
assert False
b = bytearray(b'test')
assert len(b) == 4
b.pop()
assert len(b) == 3
c = bytearray([123, 255, 111])
assert len(c) == 3
c.pop()
assert len(c) == 2
c.pop()
c.pop()
try:
c.pop()
except IndexError:
pass
else:
assert False

31
tests/snippets/code.py Normal file
View File

@@ -0,0 +1,31 @@
c1 = compile("1 + 1", "", 'eval')
code_class = type(c1)
def f(x, y, *args, power=1, **kwargs):
print("Constant String", 2, None, (2, 4))
assert code_class == type(c1)
z = x * y
return z ** power
c2 = f.__code__
# print(c2)
assert type(c2) == code_class
# print(dir(c2))
assert c2.co_argcount == 2
# assert c2.co_cellvars == ()
# assert isinstance(c2.co_code, bytes)
assert "Constant String" in c2.co_consts, c2.co_consts
print(c2.co_consts)
assert 2 in c2.co_consts, c2.co_consts
assert "code.py" in c2.co_filename
assert c2.co_firstlineno == 5, str(c2.co_firstlineno)
# assert isinstance(c2.co_flags, int) # 'OPTIMIZED, NEWLOCALS, NOFREE'
# assert c2.co_freevars == (), str(c2.co_freevars)
assert c2.co_kwonlyargcount == 1, (c2.co_kwonlyargcount)
# assert c2.co_lnotab == 0, c2.co_lnotab # b'\x00\x01' # Line number table
assert c2.co_name == 'f', c2.co_name
# assert c2.co_names == ('code_class', 'type', 'c1', 'AssertionError'), c2.co_names # , c2.co_names
# assert c2.co_nlocals == 4, c2.co_nlocals #
# assert c2.co_stacksize == 2, 'co_stacksize',
# assert c2.co_varnames == ('x', 'y', 'power', 'z'), c2.co_varnames

View File

@@ -0,0 +1,33 @@
# break from a nested for loop
def foo():
sum = 0
for i in range(10):
sum += i
for j in range(10):
sum += j
break
return sum
assert foo() == 45
# continue statement
def primes(limit):
"""Finds all the primes from 2 up to a given number using the Sieve of Eratosthenes."""
sieve = [False] * (limit + 1)
for i in range(2, limit + 1):
if sieve[i]:
continue
yield i
for j in range(2 * i, limit + 1, i):
sieve[j] = True
assert list(primes(1)) == []
assert list(primes(2)) == [2]
assert list(primes(10)) == [2, 3, 5, 7]
assert list(primes(13)) == [2, 3, 5, 7, 11, 13]

View File

@@ -14,3 +14,15 @@ c = add(10, 3)
assert c == 14 assert c == 14
def f(func): return lambda: 42
class A: pass
a = A()
a.a = A()
a.a.x = f
@a.a.x
def func():
pass
assert func() == 42

19
tests/snippets/dict.py Normal file
View File

@@ -0,0 +1,19 @@
def dict_eq(d1, d2):
return (all(k in d2 and d1[k] == d2[k] for k in d1)
and all(k in d1 and d1[k] == d2[k] for k in d2))
assert dict_eq(dict(a=2, b=3), {'a': 2, 'b': 3})
assert dict_eq(dict({'a': 2, 'b': 3}, b=4), {'a': 2, 'b': 4})
assert dict_eq(dict([('a', 2), ('b', 3)]), {'a': 2, 'b': 3})
a = {'g': 5}
b = {'a': a, 'd': 9}
c = dict(b)
c['d'] = 3
c['a']['g'] = 2
assert dict_eq(a, {'g': 2})
assert dict_eq(b, {'a': a, 'd': 9})
a.clear()
assert len(a) == 0

34
tests/snippets/dismod.py Normal file
View File

@@ -0,0 +1,34 @@
import dis
dis.dis(compile("5 + x + 5 or 2", "", "eval"))
print("\n")
dis.dis(compile("def f(x):\n return 1", "", "exec"))
print("\n")
dis.dis(compile("if a:\n 1 or 2\nelif x == 'hello':\n 3\nelse:\n 4", "", "exec"))
print("\n")
dis.dis(compile("f(x=1, y=2)", "", "eval"))
print("\n")
def f():
with g():
try:
for a in {1: 4, 2: 5}:
yield [True and False or True, []]
except Exception:
raise not ValueError({1 for i in [1,2,3]})
dis.dis(f)
class A(object):
def f():
x += 1
pass
def g():
for i in range(5):
if i:
continue
else:
break
print("A.f\n")
dis.dis(A.f)

View File

@@ -0,0 +1,11 @@
from testutils import assert_raises
assert_raises(ZeroDivisionError, lambda: 5 / 0)
assert_raises(ZeroDivisionError, lambda: 5 / -0.0)
assert_raises(ZeroDivisionError, lambda: 5 / (2-2))
assert_raises(ZeroDivisionError, lambda: 5 % 0)
assert_raises(ZeroDivisionError, lambda: 5 // 0)
assert_raises(ZeroDivisionError, lambda: 5.3 // (-0.0))
assert_raises(ZeroDivisionError, lambda: divmod(5, 0))
assert issubclass(ZeroDivisionError, ArithmeticError)

View File

@@ -0,0 +1,19 @@
from testutils import assert_raises
# 2.456984346552728
res = 10**500 / (4 * 10**499 + 7 * 10**497 + 3 * 10**494)
assert 2.456984 <= res <= 2.456985
# 95.23809523809524
res = 10**3000 / (10**2998 + 5 * 10**2996)
assert 95.238095 <= res <= 95.238096
assert 10**500 / (2*10**(500-308)) == 5e307
assert 10**500 / (10**(500-308)) == 1e308
assert_raises(OverflowError, lambda: 10**500 / (10**(500-309)), 'too big result')
# a bit more than f64::MAX = 1.7976931348623157e+308_f64
assert (2 * 10**308) / 2 == 1e308
# when dividing too big int by a float, the operation should fail
assert_raises(OverflowError, lambda: (2 * 10**308) / 2.0, 'division of big int by float')

View File

@@ -0,0 +1,8 @@
a = ...
b = ...
c = type(a)() # Test singleton behavior
assert a is b
assert b is c

View File

@@ -1,3 +1,7 @@
import math
from testutils import assert_raises
1 + 1.1 1 + 1.1
a = 1.2 a = 1.2
@@ -15,3 +19,90 @@ assert b >= a
assert c >= a assert c >= a
assert not a >= b assert not a >= b
assert a + b == 2.5
assert a - c == 0
assert a / c == 1
assert a < 5
assert a <= 5
try:
assert a < 'a'
except TypeError:
pass
try:
assert a <= 'a'
except TypeError:
pass
assert a > 1
assert a >= 1
try:
assert a > 'a'
except TypeError:
pass
try:
assert a >= 'a'
except TypeError:
pass
assert math.isnan(float('nan'))
assert math.isnan(float('NaN'))
assert math.isnan(float('+NaN'))
assert math.isnan(float('-NaN'))
assert math.isinf(float('inf'))
assert math.isinf(float('Inf'))
assert math.isinf(float('+Inf'))
assert math.isinf(float('-Inf'))
assert float('+Inf') > 0
assert float('-Inf') < 0
assert float('3.14') == 3.14
assert float('2.99e-23') == 2.99e-23
assert float(b'3.14') == 3.14
assert float(b'2.99e-23') == 2.99e-23
assert_raises(ValueError, lambda: float('foo'))
assert_raises(OverflowError, lambda: float(2**10000))
# check that magic methods are implemented for ints and floats
assert 1.0.__add__(1.0) == 2.0
assert 1.0.__radd__(1.0) == 2.0
assert 2.0.__sub__(1.0) == 1.0
assert 2.0.__rmul__(1.0) == 2.0
assert 1.0.__truediv__(2.0) == 0.5
assert 1.0.__rtruediv__(2.0) == 2.0
assert 1.0.__add__(1) == 2.0
assert 1.0.__radd__(1) == 2.0
assert 2.0.__sub__(1) == 1.0
assert 2.0.__rmul__(1) == 2.0
assert 1.0.__truediv__(2) == 0.5
assert 1.0.__rtruediv__(2) == 2.0
assert 2.0.__mul__(1) == 2.0
assert 2.0.__rsub__(1) == -1.0
assert (1.7).real == 1.7
assert (1.3).is_integer() == False
assert (1.0).is_integer() == True
assert (0.875).as_integer_ratio() == (7, 8)
assert (-0.875).as_integer_ratio() == (-7, 8)
assert (0.0).as_integer_ratio() == (0, 1)
assert (11.5).as_integer_ratio() == (23, 2)
assert (0.0).as_integer_ratio() == (0, 1)
assert (2.5).as_integer_ratio() == (5, 2)
assert (0.5).as_integer_ratio() == (1, 2)
assert (2.1).as_integer_ratio() == (4728779608739021, 2251799813685248)
assert (-2.1).as_integer_ratio() == (-4728779608739021, 2251799813685248)
assert (-2100.0).as_integer_ratio() == (-2100, 1)
assert (2.220446049250313e-16).as_integer_ratio() == (1, 4503599627370496)
assert (1.7976931348623157e+308).as_integer_ratio() == (179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368, 1)
assert (2.2250738585072014e-308).as_integer_ratio() == (1, 44942328371557897693232629769725618340449424473557664318357520289433168951375240783177119330601884005280028469967848339414697442203604155623211857659868531094441973356216371319075554900311523529863270738021251442209537670585615720368478277635206809290837627671146574559986811484619929076208839082406056034304)
assert_raises(OverflowError, float('inf').as_integer_ratio)
assert_raises(OverflowError, float('-inf').as_integer_ratio)
assert_raises(ValueError, float('nan').as_integer_ratio)

View File

@@ -0,0 +1,41 @@
foo = 'bar'
assert f"{''}" == ''
assert f"{f'{foo}'}" == 'bar'
assert f"foo{foo}" == 'foobar'
assert f"{foo}foo" == 'barfoo'
assert f"foo{foo}foo" == 'foobarfoo'
assert f"{{foo}}" == '{foo}'
assert f"{ {foo} }" == "{'bar'}"
assert f"{f'{{}}'}" == '{}' # don't include escaped braces in nested f-strings
assert f'{f"{{"}' == '{'
assert f'{f"}}"}' == '}'
assert f'{foo}' f"{foo}" 'foo' == 'barbarfoo'
assert f'{"!:"}' == '!:'
assert fr'x={4*10}\n' == 'x=40\\n'
assert f'{16:0>+#10x}' == '00000+0x10'
assert f"{{{(lambda x: f'hello, {x}')('world}')}" == '{hello, world}'
# Normally `!` cannot appear outside of delimiters in the expression but
# cpython makes an exception for `!=`, so we should too.
# assert f'{1 != 2}' == 'True'
# conversion flags
class Value:
def __format__(self, spec):
return "foo"
def __repr__(self):
return "bar"
def __str__(self):
return "baz"
v = Value()
assert f'{v}' == 'foo'
assert f'{v!r}' == 'bar'
assert f'{v!s}' == 'baz'

View File

@@ -1,21 +1,12 @@
from testutils import assert_raises
def no_args(): def no_args():
pass pass
no_args() no_args()
try: assert_raises(TypeError, lambda: no_args('one_arg'), '1 arg to no_args')
no_args('one_arg') assert_raises(TypeError, lambda: no_args(kw='should fail'), 'kwarg to no_args')
except TypeError:
pass
else:
assert False, 'no TypeError raised: 1 arg to no_args'
try:
no_args(kw='should fail')
except TypeError:
pass
else:
assert False, 'no TypeError raised: kwarg to no_args'
def one_arg(arg): def one_arg(arg):
@@ -24,40 +15,20 @@ def one_arg(arg):
one_arg('one_arg') one_arg('one_arg')
assert "arg" == one_arg(arg="arg") assert "arg" == one_arg(arg="arg")
try: assert_raises(TypeError, lambda: one_arg(), 'no args to one_arg')
one_arg() assert_raises(TypeError,
except TypeError: lambda: one_arg(wrong_arg='wont work'),
pass 'incorrect kwarg to one_arg')
else: assert_raises(TypeError,
assert False, 'no TypeError raised: no args to one_arg' lambda: one_arg('one_arg', 'two_arg'),
'two args to one_arg')
assert_raises(TypeError,
lambda: one_arg('one_arg', extra_arg='wont work'),
'no TypeError raised: extra kwarg to one_arg')
try: assert_raises(TypeError,
one_arg(wrong_arg='wont work') lambda: one_arg('one_arg', arg='duplicate'),
except TypeError: 'same pos and kwarg to one_arg')
pass
else:
assert False, 'no TypeError raised: incorrect kwarg to one_arg'
try:
one_arg('one_arg', 'two_arg')
except TypeError:
pass
else:
assert False, 'no TypeError raised: two args to one_arg'
try:
one_arg('one_arg', extra_arg='wont work')
except TypeError:
pass
else:
assert False, 'no TypeError raised: extra kwarg to one_arg'
try:
one_arg('one_arg', arg='duplicate')
except TypeError:
pass
else:
assert False, 'no TypeError raised: same pos and kwarg to one_arg'
def one_default_arg(arg="default"): def one_default_arg(arg="default"):
@@ -67,12 +38,9 @@ assert 'default' == one_default_arg()
assert 'arg' == one_default_arg('arg') assert 'arg' == one_default_arg('arg')
assert 'kwarg' == one_default_arg(arg='kwarg') assert 'kwarg' == one_default_arg(arg='kwarg')
try: assert_raises(TypeError,
one_default_arg('one_arg', 'two_arg') lambda: one_default_arg('one_arg', 'two_arg'),
except TypeError: 'two args to one_default_arg')
pass
else:
assert False, 'no TypeError raised: two args to one_default_arg'
def one_normal_one_default_arg(pos, arg="default"): def one_normal_one_default_arg(pos, arg="default"):
@@ -81,19 +49,13 @@ def one_normal_one_default_arg(pos, arg="default"):
assert ('arg', 'default') == one_normal_one_default_arg('arg') assert ('arg', 'default') == one_normal_one_default_arg('arg')
assert ('arg', 'arg2') == one_normal_one_default_arg('arg', 'arg2') assert ('arg', 'arg2') == one_normal_one_default_arg('arg', 'arg2')
try: assert_raises(TypeError,
one_normal_one_default_arg() lambda: one_normal_one_default_arg(),
except TypeError: 'no args to one_normal_one_default_arg')
pass
else:
assert False, 'no TypeError raised: no args to one_normal_one_default_arg'
try: assert_raises(TypeError,
one_normal_one_default_arg('one', 'two', 'three') lambda: one_normal_one_default_arg('one', 'two', 'three'),
except TypeError: 'three args to one_normal_one_default_arg')
pass
else:
assert False, 'no TypeError raised: three args to one_normal_one_default_arg'
def two_pos(a, b): def two_pos(a, b):

View File

@@ -5,4 +5,10 @@ assert b == 6
c = 2 + 4 if a > 5 else 'boe' c = 2 + 4 if a > 5 else 'boe'
assert c == 'boe' assert c == 'boe'
d = lambda x, y: x > y
assert d(5, 4)
e = lambda x: 1 if x else 0
assert e(True) == 1
assert e(False) == 0

View File

@@ -10,6 +10,7 @@ def test_function():
x = 17 x = 17
assert sys._getframe().f_locals is not locals_dict assert sys._getframe().f_locals is not locals_dict
assert sys._getframe().f_locals['x'] == 17 assert sys._getframe().f_locals['x'] == 17
assert sys._getframe(1).f_locals['foo'] == 'bar'
test_function() test_function()

View File

@@ -1,6 +1,7 @@
import import_target, import_target as aliased import import_target, import_target as aliased
from import_target import func, other_func from import_target import func, other_func
from import_target import func as aliased_func, other_func as aliased_other_func from import_target import func as aliased_func, other_func as aliased_other_func
from import_star import *
assert import_target.X == import_target.func() assert import_target.X == import_target.func()
assert import_target.X == func() assert import_target.X == func()
@@ -13,6 +14,14 @@ assert import_target.Y == aliased.Y
assert import_target.X == aliased_func() assert import_target.X == aliased_func()
assert import_target.Y == aliased_other_func() assert import_target.Y == aliased_other_func()
assert STAR_IMPORT == '123'
try:
from import_target import func, unknown_name
raise AssertionError('`unknown_name` does not cause an exception')
except ImportError:
pass
# TODO: Once we can determine current directory, use that to construct this # TODO: Once we can determine current directory, use that to construct this
# path: # path:
#import sys #import sys

View File

@@ -0,0 +1,3 @@
# This is used by import.py; the two should be modified in concert
STAR_IMPORT = '123'

View File

@@ -0,0 +1,11 @@
# WARNING! This file contains mixed tabs and spaces
# (because that's what it is testing)
def weird_indentation():
return_value = "hi"
if False:
return return_value
return "hi"
assert weird_indentation() == "hi"

View File

@@ -0,0 +1,26 @@
import sys
def expect_cannot_fit_index_error(s, index):
try:
s[index]
except IndexError:
pass
# TODO: Replace current except block with commented
# after solving https://github.com/RustPython/RustPython/issues/322
# except IndexError as error:
# assert str(error) == "cannot fit 'int' into an index-sized integer"
else:
assert False
MAX_INDEX = sys.maxsize + 1
MIN_INDEX = -(MAX_INDEX + 1)
test_str = "test"
expect_cannot_fit_index_error(test_str, MIN_INDEX)
expect_cannot_fit_index_error(test_str, MAX_INDEX)
test_list = [0, 1, 2, 3]
expect_cannot_fit_index_error(test_list, MIN_INDEX)
expect_cannot_fit_index_error(test_list, MAX_INDEX)

View File

@@ -0,0 +1,109 @@
class InPlace:
def __init__(self, val):
self.val = val
def __ipow__(self, other):
self.val **= other
return self
def __imul__(self, other):
self.val *= other
return self
def __imatmul__(self, other):
# I guess you could think of an int as a 1x1 matrix
self.val *= other
return self
def __itruediv__(self, other):
self.val /= other
return self
def __ifloordiv__(self, other):
self.val //= other
return self
def __imod__(self, other):
self.val %= other
return self
def __iadd__(self, other):
self.val += other
return self
def __isub__(self, other):
self.val -= other
return self
def __ilshift__(self, other):
self.val <<= other
return self
def __irshift__(self, other):
self.val >>= other
return self
def __iand__(self, other):
self.val &= other
return self
def __ixor__(self, other):
self.val ^= other
return self
def __ior__(self, other):
self.val |= other
return self
i = InPlace(2)
i **= 3
assert i.val == 8
i = InPlace(2)
i *= 2
assert i.val == 4
i = InPlace(2)
i @= 2
assert i.val == 4
i = InPlace(1)
i /= 2
assert i.val == 0.5
i = InPlace(1)
i //= 2
assert i.val == 0
i = InPlace(10)
i %= 3
assert i.val == 1
i = InPlace(1)
i += 1
assert i.val == 2
i = InPlace(2)
i -= 1
assert i.val == 1
i = InPlace(2)
i <<= 3
assert i.val == 16
i = InPlace(16)
i >>= 3
assert i.val == 2
i = InPlace(0b010101)
i &= 0b111000
assert i.val == 0b010000
i = InPlace(0b010101)
i ^= 0b111000
assert i.val == 0b101101
i = InPlace(0b010101)
i |= 0b111000
assert i.val == 0b111101

View File

@@ -0,0 +1,15 @@
# 10**308 cannot be represented exactly in f64, thus it is not equal to 1e308 float
assert not (10**308 == 1e308)
# but the 1e308 float can be converted to big int and then it still should be equal to itself
assert int(1e308) == 1e308
# and the equalities should be the same when operands switch sides
assert not (1e308 == 10**308)
assert 1e308 == int(1e308)
# floats that cannot be converted to big ints shouldnt crash the vm
import math
assert not (10**500 == math.inf)
assert not (math.inf == 10**500)
assert not (10**500 == math.nan)
assert not (math.nan == 10**500)

60
tests/snippets/ints.py Normal file
View File

@@ -0,0 +1,60 @@
from testutils import assert_raises
# int to int comparisons
assert 1 == 1
assert not 1 != 1
assert (1).__eq__(1)
assert not (1).__ne__(1)
# int to float comparisons
assert 1 == 1.0
assert not 1 != 1.0
assert not 1 > 1.0
assert not 1 < 1.0
assert 1 >= 1.0
assert 1 <= 1.0
# check for argument handling
assert int("101", base=2) == 5
# magic methods should only be implemented for other ints
assert (1).__eq__(1) == True
assert (1).__ne__(1) == False
assert (1).__gt__(1) == False
assert (1).__ge__(1) == True
assert (1).__lt__(1) == False
assert (1).__le__(1) == True
assert (1).__add__(1) == 2
assert (1).__radd__(1) == 2
assert (2).__sub__(1) == 1
assert (2).__rsub__(1) == -1
assert (2).__mul__(1) == 2
assert (2).__rmul__(1) == 2
assert (2).__truediv__(1) == 2.0
assert (2).__rtruediv__(1) == 0.5
# real/imag attributes
assert (1).real == 1
assert (1).imag == 0
assert_raises(OverflowError, lambda: 1 << 10 ** 100000)
assert (1).__eq__(1.0) == NotImplemented
assert (1).__ne__(1.0) == NotImplemented
assert (1).__gt__(1.0) == NotImplemented
assert (1).__ge__(1.0) == NotImplemented
assert (1).__lt__(1.0) == NotImplemented
assert (1).__le__(1.0) == NotImplemented
assert (1).__add__(1.0) == NotImplemented
assert (2).__sub__(1.0) == NotImplemented
assert (1).__radd__(1.0) == NotImplemented
assert (2).__rsub__(1.0) == NotImplemented
assert (2).__mul__(1.0) == NotImplemented
assert (2).__rmul__(1.0) == NotImplemented
assert (2).__truediv__(1.0) == NotImplemented
assert (2).__rtruediv__(1.0) == NotImplemented

View File

@@ -0,0 +1,54 @@
class Regular:
pass
assert isinstance(Regular(), Regular)
class MCNotInstanceOf(type):
def __instancecheck__(self, instance):
return False
class NotInstanceOf(metaclass=MCNotInstanceOf):
pass
class InheritedNotInstanceOf(NotInstanceOf):
pass
assert not isinstance(Regular(), NotInstanceOf)
assert not isinstance(1, NotInstanceOf)
# weird cpython behaviour if exact match then isinstance return true
assert isinstance(NotInstanceOf(), NotInstanceOf)
assert not NotInstanceOf.__instancecheck__(NotInstanceOf())
assert not isinstance(InheritedNotInstanceOf(), NotInstanceOf)
class MCAlwaysInstanceOf(type):
def __instancecheck__(self, instance):
return True
class AlwaysInstanceOf(metaclass=MCAlwaysInstanceOf):
pass
assert isinstance(AlwaysInstanceOf(), AlwaysInstanceOf)
assert isinstance(Regular(), AlwaysInstanceOf)
assert isinstance(1, AlwaysInstanceOf)
class MCReturnInt(type):
def __instancecheck__(self, instance):
return 3
class ReturnInt(metaclass=MCReturnInt):
pass
assert isinstance("a", ReturnInt) is True

View File

@@ -0,0 +1,63 @@
class A:
pass
class B(A):
pass
assert issubclass(A, A)
assert issubclass(B, A)
assert not issubclass(A, B)
class MCNotSubClass(type):
def __subclasscheck__(self, subclass):
return False
class NotSubClass(metaclass=MCNotSubClass):
pass
class InheritedNotSubClass(NotSubClass):
pass
assert not issubclass(A, NotSubClass)
assert not issubclass(NotSubClass, NotSubClass)
assert not issubclass(InheritedNotSubClass, NotSubClass)
assert not issubclass(NotSubClass, InheritedNotSubClass)
class MCAlwaysSubClass(type):
def __subclasscheck__(self, subclass):
return True
class AlwaysSubClass(metaclass=MCAlwaysSubClass):
pass
class InheritedAlwaysSubClass(AlwaysSubClass):
pass
assert issubclass(A, AlwaysSubClass)
assert issubclass(AlwaysSubClass, AlwaysSubClass)
assert issubclass(InheritedAlwaysSubClass, AlwaysSubClass)
assert issubclass(AlwaysSubClass, InheritedAlwaysSubClass)
class MCAVirtualSubClass(type):
def __subclasscheck__(self, subclass):
return subclass is A
class AVirtualSubClass(metaclass=MCAVirtualSubClass):
pass
assert issubclass(A, AVirtualSubClass)
assert not isinstance(B, AVirtualSubClass)

View File

@@ -31,8 +31,7 @@ assert '{}' == json.dumps({})
assert 1 == json.loads("1") assert 1 == json.loads("1")
assert -1 == json.loads("-1") assert -1 == json.loads("-1")
assert 1.0 == json.loads("1.0") assert 1.0 == json.loads("1.0")
# TODO: uncomment once negative floats are implemented assert -1.0 == json.loads("-1.0")
# assert -1.0 == json.loads("-1.0")
assert "str" == json.loads('"str"') assert "str" == json.loads('"str"')
assert True is json.loads('true') assert True is json.loads('true')
assert False is json.loads('false') assert False is json.loads('false')

View File

@@ -1,3 +1,5 @@
from testutils import assert_raises
x = [1, 2, 3] x = [1, 2, 3]
assert x[0] == 1 assert x[0] == 1
assert x[1] == 2 assert x[1] == 2
@@ -9,3 +11,148 @@ assert y == [2, 1, 2, 3]
y.extend(x) y.extend(x)
assert y == [2, 1, 2, 3, 1, 2, 3] assert y == [2, 1, 2, 3, 1, 2, 3]
assert x * 0 == [], "list __mul__ by 0 failed"
assert x * -1 == [], "list __mul__ by -1 failed"
assert x * 2 == [1, 2, 3, 1, 2, 3], "list __mul__ by 2 failed"
# index()
assert ['a', 'b', 'c'].index('b') == 1
assert [5, 6, 7].index(7) == 2
assert_raises(ValueError, lambda: ['a', 'b', 'c'].index('z'))
x = [[1,0,-3], 'a', 1]
y = [[3,2,1], 'z', 2]
assert x < y, "list __lt__ failed"
x = [5, 13, 31]
y = [1, 10, 29]
assert x > y, "list __gt__ failed"
assert [1,2,'a'].pop() == 'a', "list pop failed"
assert_raises(IndexError, lambda: [].pop())
recursive = []
recursive.append(recursive)
assert repr(recursive) == "[[...]]"
# insert()
x = ['a', 'b', 'c']
x.insert(0, 'z') # insert is in-place, no return value
assert x == ['z', 'a', 'b', 'c']
x = ['a', 'b', 'c']
x.insert(100, 'z')
assert x == ['a', 'b', 'c', 'z']
x = ['a', 'b', 'c']
x.insert(-1, 'z')
assert x == ['a', 'b', 'z', 'c']
x = ['a', 'b', 'c']
x.insert(-100, 'z')
assert x == ['z', 'a', 'b', 'c']
assert_raises(OverflowError, lambda: x.insert(100000000000000000000, 'z'))
x = [[], 2, {}]
y = x.copy()
assert x is not y
assert x == y
assert all(a is b for a, b in zip(x, y))
y.append(4)
assert x != y
a = [1, 2, 3]
assert len(a) == 3
a.remove(1)
assert len(a) == 2
assert not 1 in a
assert_raises(ValueError, lambda: a.remove(10), 'Remove not exist element')
foo = bar = [1]
foo += [2]
assert (foo, bar) == ([1, 2], [1, 2])
x = [1]
x.append(x)
assert x in x
assert x.index(x) == 1
assert x.count(x) == 1
x.remove(x)
assert x not in x
class Foo(object):
def __eq__(self, x):
return False
foo = Foo()
foo1 = Foo()
x = [1, foo, 2, foo, []]
assert x == x
assert foo in x
assert 2 in x
assert x.index(foo) == 1
assert x.count(foo) == 2
assert x.index(2) == 2
assert [] in x
assert x.index([]) == 4
assert foo1 not in x
x.remove(foo)
assert x.index(foo) == 2
assert x.count(foo) == 1
x = []
x.append(x)
assert x == x
a = [1, 2, 3]
b = [1, 2, 3]
c = [a, b]
a.append(c)
b.append(c)
assert a == b
assert [foo] == [foo]
for size in [1, 2, 3, 4, 5, 8, 10, 100, 1000]:
lst = list(range(size))
orig = lst[:]
lst.sort()
assert lst == orig
assert sorted(lst) == orig
assert_raises(ZeroDivisionError, lambda: sorted(lst, key=lambda x: 1/x))
lst.reverse()
assert sorted(lst) == orig
assert sorted(lst, reverse=True) == lst
assert sorted(lst, key=lambda x: -x) == lst
assert sorted(lst, key=lambda x: -x, reverse=True) == orig
assert sorted([(1, 2, 3), (0, 3, 6)]) == [(0, 3, 6), (1, 2, 3)]
assert sorted([(1, 2, 3), (0, 3, 6)], key=lambda x: x[0]) == [(0, 3, 6), (1, 2, 3)]
assert sorted([(1, 2, 3), (0, 3, 6)], key=lambda x: x[1]) == [(1, 2, 3), (0, 3, 6)]
assert sorted([(1, 2), (), (5,)], key=len) == [(), (5,), (1, 2)]
lst = [3, 1, 5, 2, 4]
class C:
def __init__(self, x): self.x = x
def __lt__(self, other): return self.x < other.x
lst.sort(key=C)
assert lst == [1, 2, 3, 4, 5]
lst = [3, 1, 5, 2, 4]
class C:
def __init__(self, x): self.x = x
def __gt__(self, other): return self.x > other.x
lst.sort(key=C)
assert lst == [1, 2, 3, 4, 5]
lst = [5, 1, 2, 3, 4]
def f(x):
lst.append(1)
return x
assert_raises(ValueError, lambda: lst.sort(key=f)) # "list modified during sort"
assert lst == [1, 2, 3, 4, 5]

View File

@@ -18,4 +18,12 @@ assert -a == -4
assert +a == 4 assert +a == 4
# import math # import math
# print(math.cos(1.2)) # assert(math.exp(2) == math.exp(2.0))
# assert(math.exp(True) == math.exp(1.0))
#
# class Conversible():
# def __float__(self):
# print("Converting to float now!")
# return 1.1111
#
# assert math.log(1.1111) == math.log(Conversible())

View File

@@ -1,3 +1,5 @@
from testutils import assert_raises
# test lists # test lists
assert 3 in [1, 2, 3] assert 3 in [1, 2, 3]
assert 3 not in [1, 2] assert 3 not in [1, 2]
@@ -13,6 +15,13 @@ assert "whatever" not in "foobar"
# TODO: uncomment this when bytes are implemented # TODO: uncomment this when bytes are implemented
# assert b"foo" in b"foobar" # assert b"foo" in b"foobar"
# assert b"whatever" not in b"foobar" # assert b"whatever" not in b"foobar"
assert b"1" < b"2"
assert b"1" <= b"2"
assert b"5" <= b"5"
assert b"4" > b"2"
assert not b"1" >= b"2"
assert b"10" >= b"10"
assert_raises(TypeError, lambda: bytes() > 2)
# test tuple # test tuple
assert 1 in (1, 2) assert 1 in (1, 2)
@@ -41,12 +50,7 @@ class MyNotContainingClass():
pass pass
try: assert_raises(TypeError, lambda: 1 in MyNotContainingClass())
1 in MyNotContainingClass()
except TypeError:
pass
else:
assert False, "TypeError not raised"
class MyContainingClass(): class MyContainingClass():

View File

@@ -14,3 +14,7 @@ assert none() is none()
assert none() is x assert none() is x
assert none() is none2() assert none() is none2()
assert str(None) == 'None'
assert repr(None) == 'None'
assert type(None)() is None

View File

@@ -2,9 +2,43 @@ x = 5
x.__init__(6) x.__init__(6)
assert x == 5 assert x == 5
class A(int): class A(int):
pass pass
x = A(7) x = A(7)
assert x == 7 assert x == 7
assert type(x) is A assert type(x) is A
assert int(2).__index__() == 2
assert int(2).__trunc__() == 2
assert int(2).__ceil__() == 2
assert int(2).__floor__() == 2
assert int(2).__round__() == 2
assert int(2).__round__(3) == 2
assert int(-2).__index__() == -2
assert int(-2).__trunc__() == -2
assert int(-2).__ceil__() == -2
assert int(-2).__floor__() == -2
assert int(-2).__round__() == -2
assert int(-2).__round__(3) == -2
assert round(10) == 10
assert round(10, 2) == 10
assert round(10, -1) == 10
assert int(2).__bool__() == True
assert int(0.5).__bool__() == False
assert int(-1).__bool__() == True
assert int(0).__invert__() == -1
assert int(-3).__invert__() == 2
assert int(4).__invert__() == -5
assert int(0).__rxor__(0) == 0
assert int(1).__rxor__(0) == 1
assert int(0).__rxor__(1) == 1
assert int(1).__rxor__(1) == 0
assert int(3).__rxor__(-3) == -2
assert int(3).__rxor__(4) == 7

15
tests/snippets/object.py Normal file
View File

@@ -0,0 +1,15 @@
class MyObject:
pass
assert not MyObject() == MyObject()
assert MyObject() != MyObject()
myobj = MyObject()
assert myobj == myobj
assert not myobj != myobj
assert MyObject().__eq__(MyObject()) == NotImplemented
assert MyObject().__ne__(MyObject()) == NotImplemented
assert MyObject().__lt__(MyObject()) == NotImplemented
assert MyObject().__le__(MyObject()) == NotImplemented
assert MyObject().__gt__(MyObject()) == NotImplemented
assert MyObject().__ge__(MyObject()) == NotImplemented

View File

@@ -0,0 +1,3 @@
import os
assert os.name == 'posix' or os.name == 'nt'

View File

@@ -1 +0,0 @@
print(2 + 3)

View File

@@ -0,0 +1,11 @@
from testutils import assert_raises
print(2 + 3)
assert_raises(TypeError, lambda: print('test', end=4), 'wrong type passed to end')
assert_raises(TypeError, lambda: print('test', sep=['a']), 'wrong type passed to sep')
try:
print('test', end=None, sep=None, flush=None)
except:
assert False, 'Expected None passed to end, sep, and flush to not raise errors'

146
tests/snippets/set.py Normal file
View File

@@ -0,0 +1,146 @@
from testutils import assert_raises, assertRaises
assert set([1,2]) == set([1,2])
assert not set([1,2,3]) == set([1,2])
assert set([1,2,3]) >= set([1,2])
assert set([1,2]) >= set([1,2])
assert not set([1,3]) >= set([1,2])
assert set([1,2,3]).issuperset(set([1,2]))
assert set([1,2]).issuperset(set([1,2]))
assert not set([1,3]).issuperset(set([1,2]))
assert set([1,2,3]) > set([1,2])
assert not set([1,2]) > set([1,2])
assert not set([1,3]) > set([1,2])
assert set([1,2]) <= set([1,2,3])
assert set([1,2]) <= set([1,2])
assert not set([1,3]) <= set([1,2])
assert set([1,2]).issubset(set([1,2,3]))
assert set([1,2]).issubset(set([1,2]))
assert not set([1,3]).issubset(set([1,2]))
assert set([1,2]) < set([1,2,3])
assert not set([1,2]) < set([1,2])
assert not set([1,3]) < set([1,2])
class Hashable(object):
def __init__(self, obj):
self.obj = obj
def __repr__(self):
return repr(self.obj)
def __hash__(self):
return id(self)
recursive = set()
recursive.add(Hashable(recursive))
assert repr(recursive) == "{set(...)}"
a = set([1, 2, 3])
assert len(a) == 3
a.clear()
assert len(a) == 0
assert set([1,2,3]).union(set([4,5])) == set([1,2,3,4,5])
assert set([1,2,3]).union(set([1,2,3,4,5])) == set([1,2,3,4,5])
assert set([1,2,3]) | set([4,5]) == set([1,2,3,4,5])
assert set([1,2,3]) | set([1,2,3,4,5]) == set([1,2,3,4,5])
assert set([1,2,3]).intersection(set([1,2])) == set([1,2])
assert set([1,2,3]).intersection(set([5,6])) == set([])
assert set([1,2,3]) & set([4,5]) == set([])
assert set([1,2,3]) & set([1,2,3,4,5]) == set([1,2,3])
assert set([1,2,3]).difference(set([1,2])) == set([3])
assert set([1,2,3]).difference(set([5,6])) == set([1,2,3])
assert set([1,2,3]) - set([4,5]) == set([1,2,3])
assert set([1,2,3]) - set([1,2,3,4,5]) == set([])
assert set([1,2,3]).symmetric_difference(set([1,2])) == set([3])
assert set([1,2,3]).symmetric_difference(set([5,6])) == set([1,2,3,5,6])
assert set([1,2,3]) ^ set([4,5]) == set([1,2,3,4,5])
assert set([1,2,3]) ^ set([1,2,3,4,5]) == set([4,5])
assert_raises(TypeError, lambda: set([[]]))
assert_raises(TypeError, lambda: set().add([]))
a = set([1, 2, 3])
assert a.discard(1) is None
assert not 1 in a
assert a.discard(42) is None
a = set([1,2,3])
b = a.copy()
assert len(a) == 3
assert len(b) == 3
b.clear()
assert len(a) == 3
assert len(b) == 0
a = set([1,2])
b = a.pop()
assert b in [1,2]
c = a.pop()
assert (c in [1,2] and c != b)
assert_raises(KeyError, lambda: a.pop())
a = set([1,2,3])
a.update([3,4,5])
assert a == set([1,2,3,4,5])
assert_raises(TypeError, lambda: a.update(1))
a = set([1,2,3])
b = set()
for e in a:
assert e == 1 or e == 2 or e == 3
b.add(e)
assert a == b
a = set([1,2,3])
a |= set([3,4,5])
assert a == set([1,2,3,4,5])
with assertRaises(TypeError):
a |= 1
a = set([1,2,3])
a.intersection_update([2,3,4,5])
assert a == set([2,3])
assert_raises(TypeError, lambda: a.intersection_update(1))
a = set([1,2,3])
a &= set([2,3,4,5])
assert a == set([2,3])
with assertRaises(TypeError):
a &= 1
a = set([1,2,3])
a.difference_update([3,4,5])
assert a == set([1,2])
assert_raises(TypeError, lambda: a.difference_update(1))
a = set([1,2,3])
a -= set([3,4,5])
assert a == set([1,2])
with assertRaises(TypeError):
a -= 1
a = set([1,2,3])
a.symmetric_difference_update([3,4,5])
assert a == set([1,2,4,5])
assert_raises(TypeError, lambda: a.difference_update(1))
a = set([1,2,3])
a ^= set([3,4,5])
assert a == set([1,2,4,5])
with assertRaises(TypeError):
a ^= 1

View File

@@ -0,0 +1,10 @@
from io import BufferedReader, FileIO
fi = FileIO('README.md')
bb = BufferedReader(fi)
result = bb.read()
assert len(result) <= 8*1024
assert len(result) >= 0
assert isinstance(result, bytes)

View File

@@ -0,0 +1,13 @@
import os
from testutils import assert_raises
assert os.open('README.md', 0) > 0
assert_raises(FileNotFoundError, lambda: os.open('DOES_NOT_EXIST', 0))
assert os.O_RDONLY == 0
assert os.O_WRONLY == 1
assert os.O_RDWR == 2

View File

@@ -0,0 +1,75 @@
import socket
from testutils import assertRaises
MESSAGE_A = b'aaaa'
MESSAGE_B= b'bbbbb'
# TCP
listener = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
listener.bind(("127.0.0.1", 0))
listener.listen(1)
connector = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
connector.connect(("127.0.0.1", listener.getsockname()[1]))
(connection, addr) = listener.accept()
assert addr == connector.getsockname()
connector.send(MESSAGE_A)
connection.send(MESSAGE_B)
recv_a = connection.recv(len(MESSAGE_A))
recv_b = connector.recv(len(MESSAGE_B))
assert recv_a == MESSAGE_A
assert recv_b == MESSAGE_B
connection.close()
connector.close()
listener.close()
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
with assertRaises(TypeError):
s.connect(("127.0.0.1", 8888, 8888))
with assertRaises(TypeError):
s.bind(("127.0.0.1", 8888, 8888))
with assertRaises(TypeError):
s.bind((888, 8888))
s.close()
# UDP
sock1 = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock1.bind(("127.0.0.1", 0))
sock2 = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock2.sendto(MESSAGE_A, sock1.getsockname())
(recv_a, addr1) = sock1.recvfrom(len(MESSAGE_A))
assert recv_a == MESSAGE_A
sock2.sendto(MESSAGE_B, sock1.getsockname())
(recv_b, addr2) = sock1.recvfrom(len(MESSAGE_B))
assert recv_b == MESSAGE_B
assert addr1[0] == addr2[0]
assert addr1[1] == addr2[1]
sock2.close()
sock3 = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock3.bind(("127.0.0.1", 0))
sock3.sendto(MESSAGE_A, sock1.getsockname())
(recv_a, addr) = sock1.recvfrom(len(MESSAGE_A))
assert recv_a == MESSAGE_A
assert addr == sock3.getsockname()
sock1.connect(("127.0.0.1", sock3.getsockname()[1]))
sock3.connect(("127.0.0.1", sock1.getsockname()[1]))
sock1.send(MESSAGE_A)
sock3.send(MESSAGE_B)
recv_a = sock3.recv(len(MESSAGE_A))
recv_b = sock1.recv(len(MESSAGE_B))
assert recv_a == MESSAGE_A
assert recv_b == MESSAGE_B
sock1.close()
sock3.close()

View File

@@ -8,6 +8,9 @@ assert "\n" == """
""" """
assert len(""" " \" """) == 5 assert len(""" " \" """) == 5
assert len("é") == 1
assert len("") == 2
assert len("") == 1
assert type("") is str assert type("") is str
assert type(b"") is bytes assert type(b"") is bytes
@@ -32,6 +35,15 @@ assert a.startswith('H')
assert not a.startswith('f') assert not a.startswith('f')
assert a.endswith('llo') assert a.endswith('llo')
assert not a.endswith('on') assert not a.endswith('on')
assert a.zfill(8) == '000Hallo'
assert a.isalnum()
assert not a.isdigit()
assert not a.isdecimal()
assert not a.isnumeric()
assert a.istitle()
assert a.isalpha()
b = ' hallo ' b = ' hallo '
assert b.strip() == 'hallo' assert b.strip() == 'hallo'
@@ -40,3 +52,36 @@ assert b.rstrip() == ' hallo'
c = 'hallo' c = 'hallo'
assert c.capitalize() == 'Hallo' assert c.capitalize() == 'Hallo'
assert c.center(11, '-') == '---hallo---'
# assert c.isascii()
assert c.index('a') == 1
assert c.rindex('l') == 3
assert c.find('h') == 0
assert c.rfind('x') == -1
assert c.islower()
assert c.title() == 'Hallo'
assert c.count('l') == 2
assert ' '.isspace()
assert 'hello\nhallo\nHallo'.splitlines() == ['hello', 'hallo', 'Hallo']
assert 'abc\t12345\txyz'.expandtabs() == 'abc 12345 xyz'
assert '-'.join(['1', '2', '3']) == '1-2-3'
assert 'HALLO'.isupper()
assert "hello, my name is".partition("my ") == ('hello, ', 'my ', 'name is')
assert "hello, my name is".rpartition("is") == ('hello, my name ', 'is', '')
assert not ''.isdecimal()
assert '123'.isdecimal()
assert not '\u00B2'.isdecimal()
# String Formatting
assert "{} {}".format(1,2) == "1 2"
assert "{0} {1}".format(2,3) == "2 3"
assert "--{:s>4}--".format(1) == "--sss1--"
assert "{keyword} {0}".format(1, keyword=2) == "2 1"
assert 'a' < 'b'
assert 'a' <= 'b'
assert 'a' <= 'a'
assert 'z' > 'b'
assert 'z' >= 'b'
assert 'a' >= 'a'

View File

@@ -0,0 +1,21 @@
from testutils import assert_raises
#
# Tests
#
assert 8 >> 3 == 1
assert 8 << 3 == 64
# Left shift raises type error
assert_raises(TypeError, lambda: 1 << 0.1)
assert_raises(TypeError, lambda: 1 << "abc")
# Right shift raises type error
assert_raises(TypeError, lambda: 1 >> 0.1)
assert_raises(TypeError, lambda: 1 >> "abc")
# Left shift raises value error on negative
assert_raises(ValueError, lambda: 1 << -1)
# Right shift raises value error on negative
assert_raises(ValueError, lambda: 1 >> -1)

View File

@@ -0,0 +1,42 @@
exec("def square(x):\n return x * x\n")
assert 16 == square(4)
d = {}
exec("def square(x):\n return x * x\n", {}, d)
assert 16 == d['square'](4)
exec("assert 2 == x", {}, {'x': 2})
exec("assert 2 == x", {'x': 2}, {})
exec("assert 4 == x", {'x': 2}, {'x': 4})
exec("assert max(1, 2) == 2", {}, {})
exec("assert max(1, 5, square(5)) == 25", None)
#
# These doesn't work yet:
#
# Local environment shouldn't replace global environment:
#
# exec("assert max(1, 5, square(5)) == 25", None, {})
#
# Closures aren't available if local scope is replaced:
#
# def g():
# seven = "seven"
# def f():
# try:
# exec("seven", None, {})
# except NameError:
# pass
# else:
# raise NameError("seven shouldn't be in scope")
# f()
# g()
try:
exec("", 1)
except TypeError:
pass
else:
raise TypeError("exec should fail unless globals is a dict or None")

View File

@@ -0,0 +1,20 @@
empty_set = set()
non_empty_set = set([1,2,3])
set_from_literal = {1,2,3}
assert 1 in non_empty_set
assert 4 not in non_empty_set
assert 1 in set_from_literal
assert 4 not in set_from_literal
# TODO: Assert that empty aruguments raises exception.
non_empty_set.add('a')
assert 'a' in non_empty_set
# TODO: Assert that empty arguments, or item not in set raises exception.
non_empty_set.remove(1)
assert 1 not in non_empty_set
# TODO: Assert that adding the same thing to a set once it's already there doesn't do anything.

View File

@@ -0,0 +1,13 @@
import string
assert string.ascii_letters == 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
assert string.ascii_lowercase == 'abcdefghijklmnopqrstuvwxyz'
assert string.ascii_uppercase == 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
assert string.digits == '0123456789'
assert string.hexdigits == '0123456789abcdefABCDEF'
assert string.octdigits == '01234567'
assert string.punctuation == '!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~'
# FIXME
#assert string.whitespace == ' \t\n\r\x0b\x0c', string.whitespace
#assert string.printable == '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~ \t\n\r\x0b\x0c'

View File

@@ -0,0 +1,36 @@
def assert_raises(exc_type, expr, msg=None):
"""
Helper function to assert `expr` raises an exception of type `exc_type`.
Args:
expr: Callable
exec_type: Exception
Returns:
None
Raises:
Assertion error on failure
"""
try:
expr()
except exc_type:
pass
else:
failmsg = '{!s} was not raised'.format(exc_type.__name__)
if msg is not None:
failmsg += ': {!s}'.format(msg)
assert False, failmsg
class assertRaises:
def __init__(self, expected):
self.expected = expected
def __enter__(self):
return self
def __exit__(self, exc_type, exc_val, exc_tb):
if exc_type is None:
failmsg = '{!s} was not raised'.format(self.expected.__name_)
assert False, failmsg
if not issubclass(exc_type, self.expected):
return False
return True

View File

@@ -8,6 +8,19 @@ except BaseException as ex:
# print(ex.__traceback__) # print(ex.__traceback__)
# print(type(ex.__traceback__)) # print(type(ex.__traceback__))
try:
raise ZeroDivisionError
except ZeroDivisionError as ex:
pass
class E(Exception):
def __init__(self):
asdf
try:
raise E
except NameError as ex:
pass
l = [] l = []
try: try:

View File

@@ -5,3 +5,32 @@ assert x[0] == 1
y = (1,) y = (1,)
assert y[0] == 1 assert y[0] == 1
assert x + y == (1, 2, 1)
assert x * 3 == (1, 2, 1, 2, 1, 2)
# assert 3 * x == (1, 2, 1, 2, 1, 2)
assert x * 0 == ()
assert x * -1 == () # integers less than zero treated as 0
assert y < x, "tuple __lt__ failed"
assert x > y, "tuple __gt__ failed"
b = (1,2,3)
assert b.index(2) == 1
recursive_list = []
recursive = (recursive_list,)
recursive_list.append(recursive)
assert repr(recursive) == "([(...)],)"
assert (None, "", 1).index(1) == 2
assert 1 in (None, "", 1)
class Foo(object):
def __eq__(self, x):
return False
foo = Foo()
assert (foo,) == (foo,)

View File

@@ -0,0 +1,7 @@
# See also: https://github.com/RustPython/RustPython/issues/587
def curry(foo: int) -> float:
return foo * 3.1415926 * 2
assert curry(2) > 10

View File

@@ -0,0 +1,33 @@
def test_slice_bounds(s):
# End out of range
assert s[0:100] == s
assert s[0:-100] == ''
# Start out of range
assert s[100:1] == ''
# Out of range both sides
# This is the behaviour in cpython
# assert s[-100:100] == s
def expect_index_error(s, index):
try:
s[index]
except IndexError:
pass
else:
assert False
unicode_str = "∀∂"
assert unicode_str[0] == ""
assert unicode_str[1] == ""
assert unicode_str[-1] == ""
test_slice_bounds(unicode_str)
expect_index_error(unicode_str, 100)
expect_index_error(unicode_str, -100)
ascii_str = "hello world"
test_slice_bounds(ascii_str)
assert ascii_str[0] == "h"
assert ascii_str[1] == "e"
assert ascii_str[-1] == "d"

View File

@@ -8,5 +8,6 @@ class X:
a = X() a = X()
b = ref(a) b = ref(a)
assert callable(b)
assert b() is a assert b() is a

View File

@@ -1,4 +1,7 @@
bool_expected_methods = [ expected_methods = []
# TODO: using tuple could have been better
expected_methods.append({'name': 'bool', 'methods': [
'__abs__', '__abs__',
'__add__', '__add__',
'__and__', '__and__',
@@ -69,9 +72,8 @@ bool_expected_methods = [
'numerator', 'numerator',
'real', 'real',
'to_bytes', 'to_bytes',
] ], 'type': bool})
expected_methods.append({'name': 'bytearray', 'type': bytearray, 'methods': [
bytearray_expected_methods = [
'__add__', '__add__',
'__alloc__', '__alloc__',
'__class__', '__class__',
@@ -157,9 +159,8 @@ bytearray_expected_methods = [
'translate', 'translate',
'upper', 'upper',
'zfill', 'zfill',
] ]})
expected_methods.append({'name': 'bytes', 'type': bytes, 'methods': [
bytes_expected_methods = [
'__add__', '__add__',
'__class__', '__class__',
'__contains__', '__contains__',
@@ -233,9 +234,8 @@ bytes_expected_methods = [
'translate', 'translate',
'upper', 'upper',
'zfill', 'zfill',
] ]})
expected_methods.append({'name': 'complex', 'type': complex, 'methods': [
complex_expected_methods = [
'__abs__', '__abs__',
'__add__', '__add__',
'__bool__', '__bool__',
@@ -285,9 +285,8 @@ complex_expected_methods = [
'conjugate', 'conjugate',
'imag', 'imag',
'real', 'real',
] ]})
expected_methods.append({'name': 'dict', 'type': dict, 'methods': [
dict_expected_methods = [
'__class__', '__class__',
'__contains__', '__contains__',
'__delattr__', '__delattr__',
@@ -328,9 +327,8 @@ dict_expected_methods = [
'setdefault', 'setdefault',
'update', 'update',
'values', 'values',
] ]})
expected_methods.append({'name': 'float','type':float,'methods':[
float_expected_methods = [
'__abs__', '__abs__',
'__add__', '__add__',
'__bool__', '__bool__',
@@ -388,9 +386,8 @@ float_expected_methods = [
'imag', 'imag',
'is_integer', 'is_integer',
'real', 'real',
] ]})
expected_methods.append({'name': 'frozenset','type':frozenset, 'methods': [
frozenset_expected_methods = [
'__and__', '__and__',
'__class__', '__class__',
'__contains__', '__contains__',
@@ -433,9 +430,8 @@ frozenset_expected_methods = [
'issuperset', 'issuperset',
'symmetric_difference', 'symmetric_difference',
'union', 'union',
] ]})
expected_methods.append({'name': 'int', 'type':int, 'methods': [
int_expected_methods = [
'__abs__', '__abs__',
'__add__', '__add__',
'__and__', '__and__',
@@ -506,9 +502,8 @@ int_expected_methods = [
'numerator', 'numerator',
'real', 'real',
'to_bytes', 'to_bytes',
] ]})
expected_methods.append({'name': 'iter','type':iter,'methods':[
iter_expected_methods = [
'__class__', '__class__',
'__delattr__', '__delattr__',
'__dir__', '__dir__',
@@ -536,9 +531,8 @@ iter_expected_methods = [
'__sizeof__', '__sizeof__',
'__str__', '__str__',
'__subclasshook__', '__subclasshook__',
] ]})
expected_methods.append({'name': 'list','type':list,'methods':[
list_expected_methods = [
'__add__', '__add__',
'__class__', '__class__',
'__contains__', '__contains__',
@@ -585,9 +579,8 @@ list_expected_methods = [
'remove', 'remove',
'reverse', 'reverse',
'sort', 'sort',
] ]})
expected_methods.append({'name': 'memoryview','type':memoryview,'methods':[
memoryview_expected_methods = [
'__class__', '__class__',
'__delattr__', '__delattr__',
'__delitem__', '__delitem__',
@@ -634,9 +627,8 @@ memoryview_expected_methods = [
'suboffsets', 'suboffsets',
'tobytes', 'tobytes',
'tolist', 'tolist',
] ]})
expected_methods.append({'name': 'range','type':range,'methods':[
range_expected_methods = [
'__bool__', '__bool__',
'__class__', '__class__',
'__contains__', '__contains__',
@@ -671,9 +663,8 @@ range_expected_methods = [
'start', 'start',
'step', 'step',
'stop', 'stop',
] ]})
expected_methods.append({'name': 'set','type':set,'methods':[
set_expected_methods = [
'__and__', '__and__',
'__class__', '__class__',
'__contains__', '__contains__',
@@ -729,9 +720,8 @@ set_expected_methods = [
'symmetric_difference_update', 'symmetric_difference_update',
'union', 'union',
'update', 'update',
] ]})
expected_methods.append({'name': 'string','type':str,'methods':[
string_expected_methods = [
'__add__', '__add__',
'__class__', '__class__',
'__contains__', '__contains__',
@@ -810,9 +800,8 @@ string_expected_methods = [
'translate', 'translate',
'upper', 'upper',
'zfill' 'zfill'
] ]})
expected_methods.append({'name': 'tuple','type':tuple, 'methods': [
tuple_expected_methods = [
'__add__', '__add__',
'__class__', '__class__',
'__contains__', '__contains__',
@@ -846,116 +835,42 @@ tuple_expected_methods = [
'__subclasshook__', '__subclasshook__',
'count', 'count',
'index', 'index',
] ]})
expected_methods.append({'name': 'object', 'type':object, 'methods':[
'__repr__',
'__hash__',
'__str__',
'__getattribute__',
'__setattr__',
'__delattr__',
'__lt__',
'__le__',
'__eq__',
'__ne__',
'__gt__',
'__ge__',
'__init__',
'__new__',
'__reduce_ex__',
'__reduce__',
'__subclasshook__',
'__init_subclass__',
'__format__',
'__sizeof__',
'__dir__',
'__class__',
'__doc__'
]})
not_implemented = [] not_implemented = []
for method in bool_expected_methods: for item in expected_methods:
try: for method in item['methods']:
if not hasattr(bool, method): try:
not_implemented.append(("bool", method)) if not hasattr(item['type'], method):
except NameError: not_implemented.append((item['name'], method))
not_implemented.append(("bool", method)) except NameError:
not_implemented.append((item['name'], method))
for method in bytearray_expected_methods:
try:
if not hasattr(bytearray(), method):
not_implemented.append(("bytearray", method))
except NameError:
not_implemented.append(("bytearray", method))
for method in bytes_expected_methods:
try:
if not hasattr(bytes, method):
not_implemented.append(("bytes", method))
except NameError:
not_implemented.append(("bytes", method))
for method in complex_expected_methods:
try:
if not hasattr(complex, method):
not_implemented.append(("complex", method))
except NameError:
not_implemented.append(("complex", method))
for method in dict_expected_methods:
try:
if not hasattr(dict, method):
not_implemented.append(("dict", method))
except NameError:
not_implemented.append(("dict", method))
for method in float_expected_methods:
try:
if not hasattr(float, method):
not_implemented.append(("float", method))
except NameError:
not_implemented.append(("float", method))
for method in frozenset_expected_methods:
# TODO: uncomment this when frozenset is implemented
# try:
# if not hasattr(frozenset, method):
# not_implemented.append(("frozenset", method))
# except NameError:
not_implemented.append(("frozenset", method))
for method in int_expected_methods:
try:
if not hasattr(int, method):
not_implemented.append(("int", method))
except NameError:
not_implemented.append(("int", method))
for method in iter_expected_methods:
try:
if not hasattr(iter([]), method):
not_implemented.append(("iter", method))
except NameError:
not_implemented.append(("iter", method))
for method in list_expected_methods:
try:
if not hasattr(list, method):
not_implemented.append(("list", method))
except NameError:
not_implemented.append(("list", method))
for method in memoryview_expected_methods:
# TODO: uncomment this when memoryview is implemented
# try:
# if not hasattr(memoryview, method):
# not_implemented.append(("memoryview", method))
# except NameError:
not_implemented.append(("memoryview", method))
for method in range_expected_methods:
try:
if not hasattr(range, method):
not_implemented.append(("range", method))
except NameError:
not_implemented.append(("range", method))
for method in set_expected_methods:
try:
if not hasattr(set, method):
not_implemented.append(("set", method))
except NameError:
not_implemented.append(("set", method))
for method in string_expected_methods:
try:
if not hasattr(str, method):
not_implemented.append(("string", method))
except NameError:
not_implemented.append(("string", method))
for method in tuple_expected_methods:
try:
if not hasattr(tuple, method):
not_implemented.append(("tuple", method))
except NameError:
not_implemented.append(("tuple", method))
for r in not_implemented: for r in not_implemented:
print(r[0], ".", r[1]) print(r[0], ".", r[1])

View File

@@ -77,8 +77,12 @@ def run_via_rustpython(filename, test_type):
log_level = 'info' if test_type == _TestType.benchmark else 'trace' log_level = 'info' if test_type == _TestType.benchmark else 'trace'
env['RUST_LOG'] = '{},cargo=error,jobserver=error'.format(log_level) env['RUST_LOG'] = '{},cargo=error,jobserver=error'.format(log_level)
env['RUST_BACKTRACE'] = '1' env['RUST_BACKTRACE'] = '1'
subprocess.check_call( if env.get('CODE_COVERAGE', 'false') == 'true':
['cargo', 'run', '--release', filename], env=env) subprocess.check_call(
['cargo', 'run', filename], env=env)
else:
subprocess.check_call(
['cargo', 'run', '--release', filename], env=env)
def create_test_function(cls, filename, method, test_type): def create_test_function(cls, filename, method, test_type):

View File

@@ -2,12 +2,16 @@
name = "rustpython_vm" name = "rustpython_vm"
version = "0.1.0" version = "0.1.0"
authors = ["Shing Lyu <shing.lyu@gmail.com>"] authors = ["Shing Lyu <shing.lyu@gmail.com>"]
edition = "2018"
[dependencies] [dependencies]
bitflags = "1.0.4" bitflags = "1.0.4"
num-complex = "0.2" num-complex = "0.2"
num-bigint = "0.2.1" num-bigint = "0.2.1"
num-traits = "0.2" num-traits = "0.2"
num-integer = "0.1.39"
num-rational = "0.2.1"
rand = "0.5"
log = "0.3" log = "0.3"
rustpython_parser = {path = "../parser"} rustpython_parser = {path = "../parser"}
serde = "1.0.66" serde = "1.0.66"
@@ -15,3 +19,9 @@ serde_derive = "1.0.66"
serde_json = "1.0.26" serde_json = "1.0.26"
byteorder = "1.2.6" byteorder = "1.2.6"
regex = "1" regex = "1"
rustc_version_runtime = "0.1.*"
statrs = "0.10.0"
caseless = "0.2.1"
unicode-segmentation = "1.2.1"
lazy_static = "^1.0.1"
lexical = "2.0.0"

Some files were not shown because too many files have changed in this diff Show More