Commit Graph

304 Commits

Author SHA1 Message Date
Jeong YunWon
e002191a48 pyproperty -> pygetset
Though it actually create a getset descriptor,
we didn't change the name because its concept was a property for writers.
Now we have `pymember`, another property-like descriptor. So naming them under
same level would be less confusing instead of telling everybody
"it is a getset but we call it pyproperty"
2022-09-18 14:18:49 +09:00
Jeong YunWon
368e47cddb Merge pull request #4151 from jopemachine/add-cbrt
Add `math.cbrt` implemented in cpython 3.11
2022-09-12 13:55:56 +09:00
Gyubong
e0f491ea8c Fix edge case of math.pow(0.0, -inf), math.pow(-0.0, -inf) 2022-09-12 12:45:56 +09:00
Gyubong
96fc308c04 Add math.cbrt
Update math.rs
2022-09-12 12:39:53 +09:00
Gyubong
1933e5f56e Add math.exp2 2022-09-08 17:00:42 +09:00
Jeong YunWon
e400c60ed8 Remove _platform RustPython-only module 2022-09-03 23:27:13 +09:00
Richard Hozák
31fdb204d8 Allow fcntl functions to accept objects with fileno() function (#4144)
As specified in Python official documentation
(https://docs.python.org/3.10/library/fcntl.html)

> All functions in this module take a file descriptor fd as their first
> argument. This can be an integer file descriptor, such as returned by
> sys.stdin.fileno(), or an io.IOBase object, such as sys.stdin itself,
> which provides a fileno() that returns a genuine file descriptor.

And clarified more in fcntl.fcntl function:

> Perform the operation cmd on file descriptor fd (file objects
> providing a fileno() method are accepted as well).

All function in fcntl modules should accept either int fd or object with
fileno() function which returns int fd.

This was already implemented with for `fcntl.fcntl` function with
`io::Fildes` newtype helper which extracted either int fd or called
fileno() function, and it was also implemented with duplicated ad-hoc
code for `fcntl.ioctl`.

This commit replaces the ad-hoc implementation with `io::Fildes` and
adds it to missing functions: `fcntl.flock` and `fcntl.lockf`.

For more information that this is implemented in the same way as
CPython, you can check the corresponding CPython module:
https://github.com/python/cpython/blob/3.10/Modules/clinic/fcntlmodule.c.h

The functions are: `fcntl_fcntl`, `fcntl_ioctl`, `fcntl_flock` and
`fcntl_lockf`, all of these functions use
`_PyLong_FileDescriptor_Converter` which does the same thing as
RustPython's `io::Fildes`, meaning it either extracts the argument as
int fd or calls fileno() function on passed object that returns the int
fd.

Here is the implementation for `_PyLong_FileDescriptor_Converter`:
https://github.com/python/cpython/blob/3.10/Objects/fileobject.c#L227
which in turns calls `PyObject_AsFileDescriptor` which is located here
https://github.com/python/cpython/blob/3.10/Objects/fileobject.c#L180 in
the same file and we can see that it tries to convert it to int or call
fileno() function.

Note regarding the python unit tests `test_flock`,
`test_lockf_exclusive`, `test_lockf_shared`:

The tests no longer fail with `TypeError: 'BufferedRandom' object cannot
be interpreted as an integer` which makes `test_flock` pass the test,
but `test_lockf_exclusive` and `test_lockf_exclusive` still fail but not
on fcntl calls, they fail on `Process()` constructor with
`AttributeError: module 'os' has no attribute 'fork'` which seems
unrelated with this change.

This unrelated error was probably never detected as fcntl calls failed
earlier, before `Process()` could even be called.
2022-09-02 02:39:02 +09:00
tgsong827
d7cb77ecf2 update fcntl.ioctl's first arg can take other objects having fileno method not only Integer 2022-08-30 09:52:04 +09:00
Jeong YunWon
07e339a7fb Create vm::compiler to handle CompileError variations 2022-08-23 01:43:19 +09:00
Jeong YunWon
86118d5276 drop compiler dependencies from stdlib 2022-08-22 04:43:03 +09:00
Noa
ead2a392cc Update nix and rustyline 2022-08-18 20:02:17 -05:00
Noa
d146cdb7df Remove nullable_socket impl now that socket2::Socket has a niche 2022-08-18 20:01:56 -05:00
Jeong YunWon
27040c01b0 Fix nightly clippy 2022-08-16 09:02:42 +09:00
Jeong YunWon
50aa730aad Merge pull request #4058 from tgsong827/ssl-reason
Add 'library', 'reason' Attribute to ssl.SSLError
2022-08-15 21:29:26 +09:00
Jeong YunWon
bffb40fec6 Fix fcntl.ioctl to take non-negative request 2022-08-15 02:36:46 +09:00
TaeGit
93d411d50a Add 'library', 'reason' Attribute to ssl.SSLError 2022-08-14 04:52:31 +09:00
Jeong YunWon
33ab9497a3 Fix clippy warnings 2022-08-12 11:45:33 +09:00
Jeong YunWon
dae8c31d3a Fix a2b_base64 invalid bytes handling 2022-08-09 04:08:26 +09:00
Jeong YunWon
7b643da3ea add ssl.SSLContext.post_handshake_auth 2022-08-07 16:31:38 +09:00
hyerim
42290b103e Add: _uuid module (#3974) 2022-08-07 15:27:53 +09:00
Jeong YunWon
8dad7add5b Merge pull request #3816 from chang-57/binascii_qp
Add `binascii` `a2b_qp`
2022-08-07 06:22:21 +09:00
Lee Dogeon
02e05e489d Correct binascii.unhexlify error type (#4005)
* Correct `binascii.unhexlify` error type

* Unmark resolved tests
2022-08-07 06:21:35 +09:00
Jeong YunWon
1f13d11cf3 Fix magic number horror 2022-08-07 05:57:43 +09:00
Jeong YunWon
a02558b63a fix bug and styles not fixed yet 2022-08-07 05:57:21 +09:00
hachangmin6
33110aecfe add binascii a2b_qp
Signed-off-by: hachangmin6 <tom5757tom@pusan.ac.kr>
2022-08-07 04:33:15 +09:00
Jeong YunWon
8a307b89dd Merge pull request #2444 from verhovsky/add-bz2
add bz2 from CPython 3.10.5
2022-08-05 05:08:20 +09:00
Jeong YunWon
da9c98675b optional bz2 2022-08-05 04:00:51 +09:00
boris
7204ab7ea8 implement _bz2
Co-Authored-By: Jeong YunWon <jeong@youknowone.org>
2022-08-05 03:53:59 +09:00
Jeong YunWon
c073a611a1 Merge pull request #3598 from hwi-ya/timeout
Modify timeout print message
2022-08-05 02:09:40 +09:00
hwi-ya
53a74a1f2d Modify timeout print message
Co-Authored-By: Jeong YunWon <jeong@youknowone.org>
2022-08-05 01:25:53 +09:00
Jeong Yunwon
055c5cfb97 pyimpl -> pyclass 2022-08-05 01:18:10 +09:00
Sion Kang
bb52ed774e Feat: grp module (#3967) 2022-08-04 15:44:40 +09:00
Jeong YunWon
573b495def Fix iOS build 2022-07-28 08:49:00 +09:00
Jeong YunWon
e33a6a68ac Fix _posixsubprocess for updated subprocess 2022-07-25 04:10:59 +09:00
Jeong YunWon
370c4f7f60 PyObject::try_float 2022-07-24 15:05:30 +09:00
Jeong YunWon
2d1158b271 remove vm.try_index 2022-07-24 15:05:29 +09:00
Jeong YunWon
a05712fd9b no once cell 2022-07-24 15:05:12 +09:00
Jeong Yunwon
84f5aa93b0 Refactor repetive optional range pattern to OptionalRangeArgs 2022-07-22 03:11:38 +09:00
Daeun Lee
e6452d86d0 update array.index for optional range 2022-07-21 21:12:21 +09:00
siontama
2bf61aa60a Refactor: delete unnecessary clones 2022-07-16 17:40:40 +09:00
siontama
cdd937cebb Refactor: convert indent from tab to space 2022-07-16 17:20:13 +09:00
siontama
2417d3e813 Feat: impl PyArrayIter.setstate 2022-07-16 17:19:14 +09:00
Sion Kang
50aebefa4c Update stdlib/src/array.rs
Co-authored-by: Snowapril <sinjihng@gmail.com>
2022-07-16 16:53:52 +09:00
siontama
1a526aff47 Fix: Modify iter next to be implemented only internal 2022-07-16 16:42:00 +09:00
hyezzang
821f3e7aab fix position value to struct value 2022-07-13 18:04:17 +09:00
hyezzang
0f24b18312 Add arrayiter __reduce__
Co-authored-by: Yaminyam <siontama@gmail.com>
2022-07-13 18:04:06 +09:00
siontama
b190a0cbf3 refactor: change PyArrayIter name
* Change `PyArrayIter` struct to `PyArrayIterator`
2022-07-13 14:07:56 +09:00
Noa
4771ab6383 Switch then(|| foo) to then_some(foo) 2022-07-07 11:19:55 -04:00
Padraic Fanning
97db88560a Resolve ambiguous imports on Windows 2022-07-04 19:17:54 -04:00
Padraic Fanning
4e87250ba2 Fix compilation errors on macOS and Windows 2022-07-04 19:03:22 -04:00