Noa
f9d9a1e15e
Implement weakref._remove_dead_weakref
2021-11-15 16:08:47 -06:00
Noa
ec0a658d20
Implement weakref.getweakrefs
2021-11-15 16:08:47 -06:00
Noa
c6871166d1
Make WeakListInner a sidetable
2021-11-15 16:08:47 -06:00
Noa
0b7c0fab61
Add miri test for dropping objects
2021-11-15 16:08:47 -06:00
Noa
86edc72c7e
Fix miri UB
2021-11-15 16:08:46 -06:00
Noa
65cde9a0d6
Optimize size of WeakRefList
...
The outer struct is only 1 word now, and inside the box it's a byte for
the mutex (which gets padded to a word) + a word for the linked list (we
don't use the tail) + a word for the pointer to the object.
2021-11-15 16:08:46 -06:00
Noa
e42a3ca48e
Big overhaul part 1 - replace PyRc with manual RefCount + WeakRefList
2021-11-15 16:08:45 -06:00
Jeong YunWon
e7fa32c687
Merge pull request #3402 from Snowapril/refactor_exceptions
...
Refactor duplicated codes in exception creations
2021-11-16 02:45:30 +09:00
Steve Shi
742ea0c4fa
Reimpl Buffer Protocol and memoryview support ndarray with shape, stride and suboffset ( #3340 )
...
* Fix buffer protocol and memoryview
* Fix io and array the right way to use buffer protocol
* fix rebase
* fix memoryview and introduce VecBuffer
* fix deadlock
* fix memoryview avoid double release buffer
* impl ndim buffer support
* first implement nd array for buffer and memoryview
* fix slice adjust_indices
* fix adjust_indices introduct SaturatedSliceIterator
* fix memoryview cmp
* fix adjust_indices positive_order
* fix bug mark passed test
* fix clippy
* fix set_item_slice deadlock, optimize buffer
* Delete @test_113974_tmp
* Remove vec_buffer_type
* rusty names
* impl memoryview multi index
* add comments
Co-authored-by: Jeong YunWon <jeong@youknowone.org >
2021-11-13 07:17:11 +02:00
snowapril
ab1693e131
Replace new_class to new_exception_type
...
Replace `new_class` method call for module-level exceptions to newly
added `new_exception_type`
Signed-off-by: snowapril <sinjihng@gmail.com >
2021-11-12 21:40:26 +09:00
snowapril
59582ed295
Add new_exception_type for module-level exception
...
At previous, `vm.ctx.new_class` did role for adding exception in
module-level.
This commit add `new_exception_type` for doing that part of role.
As cpython implementation, if no bases is given, pass `exception_type`
by default
Signed-off-by: snowapril <sinjihng@gmail.com >
2021-11-12 21:40:26 +09:00
snowapril
5e8d3bcacb
Remove duplicated static_cell! stmts in each modules
...
Signed-off-by: snowapril <sinjihng@gmail.com >
2021-11-12 21:40:26 +09:00
joohongpark
5ceb2be86e
fixed set.{__ror__, __sub__} operator to behave according to type
2021-11-11 16:11:48 +09:00
Noa
96a9d55a62
Merge pull request #3399 from RustPython/custom-signals
...
Allow sending custom signals to a vm
2021-11-10 14:25:06 -06:00
Jeong YunWon
31f619510f
Merge pull request #3425 from deantvv/os-getrandom
...
os: implement getrandom
2021-11-10 00:52:29 +09:00
Dean Li
b6f266d3b8
os: implement getrandom
2021-11-09 11:33:51 +00:00
jfh
f4030ab1f6
Enable settime for macos.
2021-11-08 18:28:02 +02:00
Jeong YunWon
b80cec7798
Merge pull request #3423 from deantvv/os-waitstatus-to-exitcode
...
os: implement `os.waitstatus_to_exitcode`
2021-11-07 00:00:28 +09:00
Jeong YunWon
820a67cb7e
Merge pull request #3417 from moreal/as-mapping-str
...
Implement `AsMapping` for `PyStr`
2021-11-06 22:36:02 +09:00
Dean Li
a762ce5426
os: implement waitstatus_to_exitcode
2021-11-06 21:04:13 +08:00
Jim Fasarakis-Hilliard
625886f339
Merge pull request #3420 from zetwhite/pos_only_arg
...
fix error message for checking number of positional arguments
2021-11-06 12:10:57 +02:00
Jeong YunWon
98e3d26906
Use PyPathLike::into_cstring
2021-11-06 17:17:00 +09:00
zetwhite
0523a57195
fix error message for checking number of positional arguments
2021-11-06 17:00:20 +09:00
Moreal
276608233e
Implement AsMapping for PyStr
2021-11-06 15:46:41 +09:00
Dean Li
04821ce730
os: fix posix_spawn exception
2021-11-06 14:40:54 +08:00
Jeong YunWon
40fd9c2683
Merge pull request #3406 from DimitrisJim/clean_time
...
Clean up monotonic/perf_counter invocations.
2021-11-06 14:26:21 +09:00
Jeong YunWon
8933c7bd1e
Merge pull request #3414 from DimitrisJim/operator_classes_cleanup
...
Clean up slots in operator.
2021-11-06 14:22:55 +09:00
Jim Fasarakis-Hilliard
2c2656dc7a
Raise value error on large precision values for float, int __format__ ( #3415 )
2021-11-05 21:15:49 +02:00
Daniel Watkins
14b4f0092f
cformat.rs: fix remaining test_format.test_common_format failures ( #3405 )
...
* cformat.rs: refactor fill_string to take fill_with_precision
This allows it to be used with both self.min_field_width and
self.precision, which is necessary for padding out %ds with precision.
* cformat.rs: zero-pad %d entries using precision
This matches CPython's behaviour.
* cformat.rs: don't left-adjust when filling with precision
That will always be prepending 0s to %d arguments, the LEFT_ADJUST flag
will be used by a later call to `fill_string` with the 0-filled string
as the `string` param.
* floats: handle alternate form of general formatting
* cformat.rs: convert width/precision to i32
In CPython, width can be isize but precision can only be i32. Our
implementation currently assumes the same type for both: as CPython's
tests assert on overflows for precision, but not for width, we use that
size for both.
* test_format: run test_common_format
Except for the line which raises an OverflowError in CPython, because
overflows in Rust (and therefore RustPython) abort the process
immediately.
* test_types: don't expect test_float_to_string to fail
Its string formatting usage now works as expected.
2021-11-05 12:06:58 +02:00
jfh
a3daca0108
Clean up slots in operator.
2021-11-04 22:29:10 +02:00
jfh
a8a3cae61f
Remove slot_new for longrange_iterator.
2021-11-04 18:45:50 +02:00
Jeong YunWon
2309e59a72
Merge pull request #3404 from DimitrisJim/genericalias_no_kwargs
...
Disallow kwargs from genericalias `__new__`.
2021-11-04 19:16:36 +09:00
Jeong YunWon
95bb1a1ffb
Merge pull request #3409 from DimitrisJim/check_wasi
...
Add wasi check to ci.
2021-11-04 16:01:16 +09:00
jfh
25c7d82a86
Add wasi check to ci.
2021-11-04 01:21:24 +02:00
Noa
2c70bf26c3
Move the cfg(debug_assertions) inside the quote!}
2021-11-03 13:29:52 -05:00
Noa
f01a7b17c4
Upgrade nix
2021-11-03 13:28:41 -05:00
Jim Fasarakis-Hilliard
b69cfafad8
Merge pull request #3398 from deantvv/os-error-str-2
...
os: implement os-error-str according to CPython
2021-11-03 16:53:49 +02:00
jfh
cc3708816f
Clean up monotonic/perf_counter invocations.
2021-11-03 13:43:07 +02:00
jfh
ffd7e8cdb7
Disallow kwargs from genericalias new.
2021-11-03 13:35:28 +02:00
Dean Li
db212d80ff
os: implement os-error-str according to CPython
...
As was: "FileNotFoundError: [Errno 2] No such file or directory (os
error 2)"
To be: "FileNotFoundError: [Errno 2] No such file or directory (os
error 2): 'filename' -> 'filename2'"
Reference CPython implementation
```
if (self->filename) {
if (self->filename2) {
return PyUnicode_FromFormat("[Errno %S] %S: %R -> %R",
OR_NONE(self->myerrno),
OR_NONE(self->strerror),
self->filename,
self->filename2);
} else {
return PyUnicode_FromFormat("[Errno %S] %S: %R",
OR_NONE(self->myerrno),
OR_NONE(self->strerror),
self->filename);
}
}
if (self->myerrno && self->strerror)
return PyUnicode_FromFormat("[Errno %S] %S",
self->myerrno, self->strerror);
```
2021-11-03 17:30:28 +08:00
Daniel Watkins
9dce9bf0b9
correctly set __module__ and __name__ for builtin exceptions
...
In CPython's PyErr_NewException[0], the dotted "module.name" passed in is
split on that dot: the content before the dot is set as __module__ in
the created exception class, and the content after it is set as
__name__.
This commit mirrors that behaviour, by introducing a `module` argument
to `PyContext.new_class`: if Some("module_name") is passed, it will be
set as `__module__`. All exception-creating uses of `new_class` are
updated to pass in their module and class names separately.
[0] https://github.com/python/cpython/blob/main/Python/errors.c#L1082-L1087
2021-11-02 18:28:02 -04:00
Jim Fasarakis-Hilliard
612e943c6c
Merge pull request #3394 from Snowapril/fix-ga-param-chaining
...
Fix `GenericAlias` parameter chaining
2021-11-02 23:37:38 +02:00
Jeong YunWon
93ef12e553
Merge pull request #3401 from coolreader18/stdlib-arrayiter
...
Don't create an intermediate map for rustpython_stdlib::stdlib_inits
2021-11-02 18:12:28 +09:00
Jeong YunWon
d78347e7ea
Merge pull request #3390 from OddBloke/oddbloke/format
...
cformat.rs: fixes to get two test_format.py tests passing
2021-11-02 18:10:08 +09:00
Jeong YunWon
7b99d13f60
Merge pull request #3050 from RustPython/upd-deps
...
Run cargo update + upgrade
2021-11-02 17:58:02 +09:00
Noa
a4a1a154e2
Allow sending custom signals to a vm
2021-11-01 22:42:29 -05:00
Noa
a3723462ce
Don't create an intermediate map for rustpython_stdlib::stdlib_inits
2021-11-01 22:37:32 -05:00
Noa
401789dbf1
Tidy up signals atomics and such
2021-11-01 21:44:04 -05:00
Daniel Watkins
655bfbc6cf
cformat.rs: align exception text with CPython
...
test_format.py doesn't _fail_ if the text is different, but it does emit
a warning: this fixes those warnings.
2021-11-01 21:34:51 -04:00
Daniel Watkins
4d2747e4b8
cformat.rs: reject %c args > 255 when byte formatting
...
This matches CPython's behaviour. Thanks to @DimitrisJim for the
improved implementation here.
2021-11-01 21:34:51 -04:00