Commit Graph

7213 Commits

Author SHA1 Message Date
Daniel Chiquito
bf461cdebc Use CPython hash algorithm for frozenset
The original hash algorithm just XOR'd all the hashes of the elements of
the set, which is problematic. The CPython algorithm is required to pass
the tests.

- Replace `PyFrozenSet::hash` with CPython's algorithm
- Remove unused `hash_iter_unorded` functions
- Add `frozenset` benchmark
- Enable tests
- Lower performance expectations on effectiveness test
- Adjust `slot::hash_wrapper` so that it doesn't rehash the computed
  hash value in the process of converting PyInt to PyHash.
2024-02-09 21:02:40 -05:00
Daniel Chiquito
43d7c71a68 Fix integer rounding
The [docs](https://docs.python.org/3/library/functions.html#round)
specify that calling `round` with a negative precision removes
significant digits, so that `round(12345, -2) == 12300`. The
implementation was simply returning the original integer.

Additionally, `round(a, b)` is implemented as `(a / 10^b) * 10^b`, using
half-even rounding during the division.
2024-02-07 14:19:17 -05:00
Alin-Ioan Alexandru
3eda1cf3b4 Deprecation warning fix for __complex__ (#5152) 2024-01-25 14:54:06 +09:00
kenny the :/
aaae566231 Raise error on power with negative number (#5143) 2024-01-12 21:16:53 +09:00
NakanoMiku
28f0fa48a4 Fix abc error messages (#5140)
Co-authored-by: Jeong, YunWon <jeong@youknowone.org>
2024-01-11 17:48:56 +09:00
Noa
602015fca1 Update nix and socket2 2024-01-09 20:53:58 +09:00
Evan Rittenhouse
1ab133dae8 None.__ne__(None) should be NotImplemented (#5124) 2024-01-08 15:03:57 +09:00
Jeong, YunWon
7236109d75 Merge pull request #5144 from youknowone/clippy
Fix 1.75 clippy warnings
2023-12-30 13:16:10 +09:00
Jeong YunWon
506c8a633e Fix redox and nightly 2023-12-30 12:53:57 +09:00
Jeong YunWon
a309cb5d2c Fix 1.75 clippy warnings 2023-12-30 11:48:40 +09:00
Jeong, YunWon
4729ca3af0 Drop winapi from rustpython-vm 2023-12-28 23:44:47 +09:00
Jeong, YunWon
cccfb08835 replace winbase winnt to windows-sys 2023-12-28 22:40:49 +09:00
Jeong, YunWon
d01909a524 replace handleapi to windows-sys 2023-12-28 22:28:49 +09:00
Jeong, YunWon
ee128eac7c replace errorhandling to windows-sys 2023-12-28 22:28:33 +09:00
Jeong, YunWon
6df9732965 replace wincon to windows-sys 2023-12-28 22:28:33 +09:00
Jeong, YunWon
8a84a479f1 remove processthreadsapi 2023-12-28 22:28:33 +09:00
Jeong, YunWon
7513017e21 replace sysinfoapi to windows-sys 2023-12-28 22:28:33 +09:00
ChenyG
dc4f6994fb Support slice hash (#5123)
* make slice object hashable

* Update test_slice.py from CPython v3.12

* remove TODO

* remove outdated tests
2023-11-25 13:11:17 +09:00
Noa
068249196f Use new 1.74 features (#5118) 2023-11-17 13:01:05 +09:00
Noa
87cf891e50 Make PyMethodDef construction const (#5117)
* Make PyMethodDef construction const

* Remove iter_chain![]

Obsolete since arrays now impl IntoIterator
2023-11-15 12:52:47 +09:00
Jeong, YunWon
af884cb284 First step for Python 3.12 support (#5078)
* Mark 3.12

* Update importlib from Python 3.12.0

* Update test_importlib from Python3.12

* Mark failings tests from importlib

* Update test.support from Python3.12

* Fix unsupported parser feature

* mark failing test

* Update functools from Python 3.12

* manual type annotation

* slice behavior changed in 3.12

* empty unittest.main returns non-zero

* test_decimal from CPython 3.12

* Mark failing tests

* Update test_unicode from CPython 3.12

* Update test_functools from Python 3.12

* Update enum from Python 3.12

* enum

* Doc format changed

* Update test_module from CPython

---------

Co-authored-by: CPython developers <>
2023-10-22 19:19:05 -07:00
Jeong, YunWon
a75f26b922 Fake PEP-0695 with empty __type_params__ (#5098) 2023-10-22 18:01:06 -07:00
Dan Näsman
03576615e4 fix type_check (#5097) 2023-10-19 18:03:34 -07:00
Dan Näsman
0e72ba8819 implement PyObject_Type and PyObject_TypeCheck (#5091) 2023-10-17 16:22:10 -07:00
Dan Näsman
4e6172b99d Add object protocol correspoinding to PyObject_GetAIter (#5090) 2023-10-16 10:39:29 -07:00
Amuthan Mannar
9241e2e5d5 [VM] Object pickling implementation for product object (python itertools) (#5089)
* Implemented __reduce__, __setstate__ in product object
2023-10-12 20:12:33 +09:00
Dan Näsman
830389f62c implement dir for ByObjectRef (#5088) 2023-10-09 15:16:38 +09:00
Jeong, YunWon
4a61eba58e rustpython_vm::windows 2023-10-07 03:02:56 +09:00
Jeong, YunWon
58df09b492 GetLastError 2023-10-07 03:02:56 +09:00
Yaminyam
6313e4c9fb windows-sys attrs
Copied from https://github.com/RustPython/RustPython/pull/4086
2023-10-07 03:02:56 +09:00
Jeong, YunWon
0f3a9311e0 port winbase 2023-10-07 03:02:19 +09:00
Jeong, YunWon
987d50c092 port to windows-rs (#5080)
* Fix OpenSSL in windows CI

* bump windows-rs

* prepare windows-sys 0.48

* CloseHandle

* DuplicateHandle

* CreatePipe

* GetFileType

* GetExitCodeProcess

* TerminateProcess

* GetStdHandle

* GetCurrentProcess

* DeleteProcThreadAttributeList

* WaitForSingleObject

* CreateProcessW

* InitializeProcThreadAttributeList

* UpdateProcThreadAttribute

* clean up helpers
2023-10-07 03:01:42 +09:00
Jeong, YunWon
4135da42ac Fix clippy (#5083)
* Fix clippy

* Fix nightly clippy
2023-10-06 03:17:03 +09:00
Jeong, YunWon
d975c51b96 implement more warnings (#5077) 2023-10-04 23:42:37 +09:00
Reid00
b864e5da1f feat: Implement _imp._frozen_module_names (#5062) 2023-09-03 21:33:42 +09:00
Jeong, YunWon
77939d2ca5 Update platform from CPython 3.11.5 (#5060)
* Update platform and test from CPython 3.11.5

* sys.dllhandle (=0)

* Unmark fixed test of test_sysconfig

---------

Co-authored-by: CPython Developers <>
2023-09-01 13:55:28 +09:00
Reid00
3900a086b8 update imp.py from CPython 3.11 (#5054) 2023-08-31 17:44:31 +09:00
Jeong, YunWon
64c66e00d6 Fix encodings related error messages to be less confusing (#5049)
* Move cwd setup to interpreter code

* rework import encodings failure message

* try import_encodings only when `path_list` is set

* std::mem::take instead of drain(..).collect()

* Add empty path_list warnings to import_encodings

* Prepend current working directory when !safe_path

Co-authored-by: fanninpm <fanninpm@miamioh.edu>
2023-08-30 21:45:36 +09:00
Jeong, YunWon
4ba2892168 Better tips for Interpreter & InterpreterConfig (#5047)
Co-authored-by: fanninpm <fanninpm@miamioh.edu>
2023-08-30 20:00:07 +09:00
Jeong, YunWon
aee68d20bb Fix freeze-stdlib + Interpreter::without_stdlib (#5051)
* Fix pylib invalidation config

* Fix Interpreter::without_stdlib with frozen-stdlib feature
2023-08-30 19:50:20 +09:00
Junho Lee
d4be55c2ea Add command line parameter -P (#4611)
* Add command line parameter -P

* Modify the value of safe_path to be set

---------

Co-authored-by: Jeong YunWon <jeong@youknowone.org>
2023-08-30 19:32:27 +09:00
Jeong, YunWon
93d731cc4b Merge pull request #5029 from LucaSforza/main
added __reduce__ method for itertools.permutations
2023-08-27 03:19:37 +09:00
LucaSforza
94029386ae added __reduce__ method for itertools.permutations 2023-08-27 02:13:44 +09:00
Dan Nasman
5f6059ef73 fix formatting 2023-08-27 02:12:27 +09:00
Dan Nasman
ba8d7b541f change conditional expression 2023-08-27 02:12:27 +09:00
Dan Nasman
b1238ab4eb change import_encodings error message 2023-08-27 02:12:27 +09:00
Jeong, YunWon
d4d362a9ca Update to Rust 1.72.0 2023-08-27 00:38:10 +09:00
Zanie Blue
bdb0c8f645 Add parser support for PEP 695 (#5026)
* Add generated content for PEP 695 ASDL

* Bump RustPython/Parser to 704eb40108

* Add stubs for type aliases and parameters
2023-07-20 13:54:07 +09:00
Bobby Palmer
a58ede99f2 add int_max_str_digits input from command line (#5021)
* added int_max_str_digits to settings struct

* changed vm init to use the value from settings

* added error handling and set the settings default to -1 which sets the value to 4300
2023-07-06 01:24:11 +09:00
Dan Näsman
1cdc5d3294 Add get_int_max_str_digits and set_int_max_str_digits in sys. (#5014)
---------

Co-authored-by: DimitrisJim <d.f.hilliard@gmail.com>
2023-06-17 23:46:22 +03:00