Commit Graph

96 Commits

Author SHA1 Message Date
Jeong Yunwon
6357a1acbe clean up imports and useless allow attributes 2022-04-15 23:58:20 +09:00
Padraic Fanning
29048b105e Fix needless_late_init Clippy warning 2022-02-25 19:33:52 -05:00
Noa
1188369956 Fix clippy warnings with 1.58 & convert some format strings to capture-args 2022-01-13 23:53:25 -06:00
Noa
af7ec416f9 Prevent edge case race condition, hopefully 2021-11-15 16:08:47 -06:00
Noa
8c7def00ec Address review 2021-11-15 16:08:47 -06:00
Noa
1da239ac08 Fix clippy 2021-11-15 16:08:47 -06:00
Noa
c6871166d1 Make WeakListInner a sidetable 2021-11-15 16:08:47 -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
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
Noa
358ce09b5c Run cargo upgrade 2021-10-30 19:42:35 -05:00
Noa
09e9ea91e7 TryFrom, TryInto, FromIterator are in prelude now 2021-10-21 17:04:19 -05:00
snowapril
6339390629 Implement keyword suggestion routine
`suggestions.rs` is almost porting of implementation of
[this](https://github.com/python/cpython/pull/16856) and
[this](https://github.com/python/cpython/pull/25397).

Signed-off-by: snowapril <sinjihng@gmail.com>
2021-10-20 10:19:42 +09:00
Noa
27540e1d35 Add unparse feature to ast 2021-10-17 21:55:27 -05:00
Jeong YunWon
a42d547a3f new_{utf8_str, ascii_literal} -> new_str again 2021-10-11 21:28:14 +09:00
snowapril
945d330b9c impl fmt::Display for BorrowedValue<str>
Signed-off-by: snowapril <sinjihng@gmail.com>
2021-10-10 15:38:45 +09:00
Jeong YunWon
2eb6c6826e Merge pull request #3046 from fanninpm/latin-1-encoding
Implement latin_1 in Rust
2021-10-01 21:38:38 +09:00
Jeong YunWon
44f7bc468a vm::utils::ascii! -> common::ascii! 2021-09-28 15:47:54 +09:00
Padraic Fanning
a100178fb4 Account for 0x80..=0xff range in memory 2021-09-24 19:44:59 -04:00
Padraic Fanning
7d322b728c Simplify latin_1 decode function 2021-09-23 23:52:15 -04:00
Padraic Fanning
0f889ce92b Implement latin_1 in Rust
This implementation is patterned off of the ascii codec.
2021-09-23 21:34:33 -04:00
Noa
20b86b2060 Implement ascii codec in Rust 2021-09-22 16:35:50 -05:00
Noa
d5272c9310 Merge pull request #3105 from youknowone/wchar-t
extract wchar_t definition to rustpython-common
2021-09-21 20:14:19 -05:00
Jeong YunWon
2952f6e7c6 extract wchar_t definition to rustpython-common 2021-09-22 03:30:41 +09:00
Codemonk-adi
a07d3432c1 Redid the commit cause I messed up 2021-09-21 21:58:51 +05:30
jfh
166e69e731 Use associated constants instead of module constants. 2021-09-11 16:29:06 +03:00
Tony Jinwoo Ahn
6e1c9c68b6 Fix range of "invalid start byte" for UTF-8
Signed-off-by: Tony Jinwoo Ahn <tony.jinwoo.ahn@gmail.com>
2021-09-04 21:09:52 +09:00
Noah
4de16f6955 Remove derive_more dep 2021-07-31 10:49:39 -05:00
jfh
2666e88d44 Allow specific instance of while let. 2021-07-29 23:35:16 +03:00
Jeong YunWon
ff4efd0f60 Fix unnessessary borrow 2021-07-30 02:32:16 +09:00
Noah
c5f11a7ef4 Merge pull request #2586 from RustPython/coolreader18/hash-neg1-to-neg2
Make PyStr.hash an AtomicI64
2021-05-22 12:31:49 -05:00
Noah
7172616881 Add AtomicBool and AtomicPtr for common::atomic 2021-05-22 10:40:47 -05:00
Noah
c1ae29e971 Fancy args structs for codec functions 2021-05-21 17:38:50 -05:00
Noah
d1a4812d3f Implement _codecs.utf_8_decode in rust 2021-05-20 20:36:04 -05:00
Noah
ab3537f9c9 Make PyStr.hash a AtomicI64 2021-05-20 18:41:13 -05:00
Noah
213c0d6bfe Turn hash() results of -1 into -2 2021-05-20 18:39:09 -05:00
Noah
27ee7e12bf Remove BorrowValue fully 2021-05-20 17:23:37 -05:00
Noah
c0f1da8d8f Make _codecs a native module 2021-05-18 23:43:13 -05:00
Noah
295613ecfe Fix tests 2021-05-13 20:05:17 -05:00
Noah
80e5c984f4 Implement TextIOWrapper.readline correctly 2021-05-13 19:46:17 -05:00
Noah
8d5588df67 Merge pull request #2532 from Pluriscient/documentation/common-start
Documentation of VM & Bytecode
2021-04-18 15:12:29 -05:00
Pluriscient
7881fb8547 Remove floating comment ufrexp 2021-04-15 14:56:39 +02:00
Eric van der Toorn
e1763fcb9d 'float' 2021-03-26 21:58:34 +01:00
Noah
1fff67db2c Correct float rounding algorithm 2021-03-25 08:06:58 -05:00
Noah
bdc01f0370 Fix bug for downgrading cell locks 2021-03-14 12:49:59 -05:00
Mark Umnus
6d663f4157 Fix formatting of decimal powers below 1 million
The previous implementation truncated even 10.0 to 1, because it cut away any
combination of trailing 0's and .'s.
2021-02-01 01:25:58 +01:00
Noah
8f536b986d Use boxvec for frame.stack 2020-12-21 18:48:56 -06:00
Noah
1ca5ca74dc Add common::BoxVec 2020-12-21 18:47:59 -06:00
Noah
5a56dd1a77 repr() functions with their names 2020-12-17 16:29:44 -06:00
Noah
f48e547981 Merge pull request #2316 from ChJR/feature/format_float
Unify float formatting
2020-11-21 17:40:46 -06:00