Commit Graph

331 Commits

Author SHA1 Message Date
Jeong YunWon
1848c45302 first cspell dict 2023-01-09 19:57:23 +09:00
Steve Shi
765933136c Implement Sqlite3 Module (#4260)
* add supporting for PyAtomic<PyObject>

* create sqlite module

* add dependency sqlite3-sys

* add module constants

* import sqlite3 from cpython

* adjust lib

* add module structure

* impl Connection.cursor

* add module exceptions

* impl lstrip_sql

* impl statement new

* wip cursor.execute

* wip cursor

* wip error to exception

* add SqliteRaw and SqliteStatementRaw

* impl statement parameters binding

* wip cursor.execute

* add test_sqlite

* impl closeable connection

* impl closeable cursor

* impl cursor.executemany

* impl cursor.executescript

* impl cursor.fetch*

* impl connection.backup

* stage 1

* add support connection.backup with progress

* fix backup deadlock

* support changable isolation_level

* impl converter

* impl adapter

* impl text_factory and blob

* impl create_function

* impl create_function 2

* fix empty statement

* impl blob support

* impl create_aggregate

* impl create_aggregate 2

* refactor create_*

* impl enable_callback_traceback

* impl create_collation

* refactor create_* with CallbackData

* fix text and blob use SQLITE_TRANSIENT

* fix str to SQLITE_TEXT

* impl thread check

* impl Connection Factory

* impl busy timeout

* shift sqlite3-sys -> libsqlite3-sys

* refactor CallbackData

* impl create_window_function

* refactor callback functions

* add module attr converters

* fix nullable isolation_level

* add module attr adapters

* fix nullable adapt proto

* impl set_authorizer

* impl trace_callback

* impl set_progress_handler

* impl cancellable sqlite function*

* impl attributes for Connection

* fix some failed tests

* impl Row

* impl Blob methods

* impl Blob subscript & ass_subscript

* pass tests

* rebase

* no sqlite for wasm

* use ThreadId instead u64

* no libsqlite3-sys for wasm

* fix into_cstring for all platform

* fixup

* rebase

* fix windows into_bytes

* disable sqlite for android

* fixup
2023-01-07 22:03:24 +02:00
Steve Shi
b6c9882e1a Fix bug in Sliceable and rename del_item* to delitem (#4333)
* fix bug in sliceable

* fixup
2023-01-01 17:28:42 +02:00
Moreal
d41f40879c Allow trailing bits while decoding base64 2022-12-28 05:19:06 +09:00
Jeong YunWon
31b89fc124 Merge pull request #4347 from qingshi163/refactor-number
Refactor Number Protocol &PyNumber -> PyNumber
2022-12-24 22:30:37 +09:00
Kangzhi Shi
f16a48df39 Refactor Number Protocol 2022-12-24 15:42:06 +09:00
Dimitris Fasarakis Hilliard
29eaab0abf Fix build error for ssl on android. 2022-12-18 11:45:40 +02:00
Jeong YunWon
d935fbc445 Fix nightly clippy warnings 2022-12-05 12:18:16 +09:00
Discord9
754b28c086 refactor: use Lazy for static 2022-11-24 12:17:07 +08:00
Jeong YunWon
499b34cee0 Apply let-else statements 2022-11-10 15:39:31 +09:00
Dimitris Fasarakis Hilliard
9d303a21d6 Fix errors from update to rust 1.65 2022-11-04 20:57:27 +02:00
Devon Hollowood
96bf177acc Respond to reviewer comments 2022-10-27 18:27:06 -07:00
Devon Hollowood
fa50056fce Apply suggestions from code review
Co-authored-by: Jeong YunWon <69878+youknowone@users.noreply.github.com>
2022-10-27 18:20:50 -07:00
Devon Hollowood
3739372d43 Implement more accurate hypot()
This uses the improved-accuracy hypotenuse algorithm from Borges 2019,
see https://arxiv.org/abs/1904.09481.
2022-10-26 23:44:13 -07:00
Devon Hollowood
4cfe1453e1 Accept reviewer suggestion
Co-authored-by: Jeong YunWon <69878+youknowone@users.noreply.github.com>
2022-10-25 10:49:09 -07:00
Devon Hollowood
82b4990224 Use improved log2() implementation for log10()
This also fixes a bug in the log2() implementation, where very large
negative integer arguments would not raise an exception (and instead
would turn into NaNs).
2022-10-24 18:46:49 -07:00
Devon Hollowood
893f86e9cf Respond to reviewer comments 2022-10-23 10:17:43 -07:00
Devon Hollowood
beeb0441ef Allow log2() to work on large integers 2022-10-22 14:55:14 -07:00
Jeong YunWon
6d140fb0e7 Merge pull request #4223 from youknowone/nightly-clippy
Fix nightly clippy warnings
2022-10-17 13:28:53 +09:00
Jeong YunWon
00dc025463 Merge pull request #4228 from gilteunchoi/remove-old-doc-remark
remove most of old __doc__ remarks
2022-10-17 11:59:51 +09:00
Steve Shi
2c5cacf9f2 Refactor Mapping Protocol (#4222) 2022-10-17 09:51:22 +09:00
gilteun
227034d36b remove most of old __doc__ remarks 2022-10-17 09:00:01 +09:00
Steve Shi
30aeb8bee5 Introduce PyAtomicRef and impl for PyObject.typ (#3828)
* introduce PyAtomicRef

* refactor PyObject.typ use PyAtomicRef

* add documents

* add swap_to_temporary_refs

* replace AtomicCell with PyAtomic

* fix name conflict
2022-10-15 21:53:12 +02:00
Jeong YunWon
d94f638784 Fix nightly clippy warnings 2022-10-16 02:38:50 +09:00
Jeong YunWon
185e0cb62d clippy is platform-dependent 2022-10-15 15:53:39 +09:00
Steve Shi
273ffd969c Optimize PyType Creation (#4209) 2022-10-11 15:05:52 +09:00
Steve Shi
186990f4f2 Refactor Sequence Protocol (#4137)
* Refactor Sequence Protocol

* rebase

* fixup

* fix inherit slots

* rebase

* fix io slot_init

* mark unsuccess test_xml_etree
2022-10-10 20:21:15 +02:00
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