Commit Graph

10030 Commits

Author SHA1 Message Date
Dean Li
de4c0363bd test: update support.wait_process from py3.10 2021-11-06 21:04:13 +08: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
d7f2e2e696 Merge pull request #3416 from deantvv/os-posix-spawn
os: fix posix_spawn exception
2021-11-06 18:53:29 +09: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
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
976ed1d5eb Merge pull request #3412 from DimitrisJim/random_seed
Allow any object as an argument for random.seed
2021-11-06 14:24:22 +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
Jeong YunWon
c5250e2fe9 Merge pull request #3413 from DimitrisJim/remove_old_code
Remove slot_new for longrange_iterator.
2021-11-05 13:28:04 +09: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
jfh
05c4fcf934 Allow any object as an argument for random.seed 2021-11-04 18:34:20 +02:00
jfh
aa00fe9c64 Mark failing tests in test_random. 2021-11-04 15:12:32 +02:00
jfh
950a2cfad3 Add test_random from CPython 3.8. 2021-11-04 14:56:09 +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
Jim Fasarakis-Hilliard
07a236f965 Merge pull request #3408 from coolreader18/fix-panic
Fix panic in debug mode
2021-11-03 21:57:53 +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
544fb5ffa6 Merge pull request #3407 from matthieugouel/fix_whats_left
fix `not_impl.py` path for black in `whats_left.sh`
2021-11-03 20:15:54 +02:00
matthieugouel
81a6927081 fix not_impl.py path for black 2021-11-03 17:57:48 +01: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
Jim Fasarakis-Hilliard
9d95ad248b Merge pull request #3396 from OddBloke/oddbloke/exception_module
correctly set __module__ and __name__ for builtin exceptions
2021-11-03 14:48:24 +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
42186caade extra_tests: test stdlib exception __module__/__name__ 2021-11-02 18:28:02 -04: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
Jim Fasarakis-Hilliard
0de92bdc45 Merge pull request #3403 from stvsmth/benches-readme-typo
Fix typo in benches readme.
2021-11-02 16:42:55 +02:00
stvsmth
ba6f855a66 Fix typo in benches readme.
Correct the file location of the index.html file.
2021-11-02 08:37:37 -06: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
1092f94a75 Merge pull request #3377 from fanninpm/fix-test-posixpath
Fix error and unexpected success in test_posixpath
2021-11-02 18:05:52 +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
a3723462ce Don't create an intermediate map for rustpython_stdlib::stdlib_inits 2021-11-01 22:37:32 -05:00
Noa
5b780e70e6 Skip panicking test 2021-11-01 20:43:46 -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
c5eba15370 test_format: run test_bytes_and_bytearray_format
All the errors have now been addressed.
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
Daniel Watkins
1ed3a6ca81 cformat.rs: emit correct "not all arguments" errors for byte formatting
Without this, the code would accept `b"eggs" % b"ham"` and `b"eggs" %
bytearray(b"ham")` because it would detect bytes and bytearray as
mappings (which _are_ permitted to have leftover, unprocessed
arguments).
2021-11-01 21:34:51 -04:00
Daniel Watkins
8594a656c7 cformat.rs: s/string/bytes/ in byte formatting error messages 2021-11-01 21:34:51 -04:00
Daniel Watkins
3e19da8331 cformat.rs: implement b'%a'/b'%r' correctly
Unlike strings, b'%a' and b'%r' are equivalent, and they match the '%a'
behaviour of strings, not '%r'.

Thanks to @youknowone for improving this implementation.
2021-11-01 21:34:51 -04:00
Daniel Watkins
dcc0973b03 cformat.rs: handle bytearrays when formatting b'%c' 2021-11-01 21:34:51 -04:00
Daniel Watkins
380653b6cb cformat.rs: implement %a correctly, using builtins::ascii
The repr() of Unicode strings is the Unicode string, so the previous
code was incorrect for that case (at least).
2021-11-01 21:34:51 -04:00