Visitar URL original
Support tuple type also for memoryview shape arg by 24seconds · Pull Request #3465 · RustPython/RustPython · GitHub
The Wayback Machine - https://web.archive.org/web/20260616170849/https://github.com/RustPython/RustPython/pull/3465
Skip to content

Support tuple type also for memoryview shape arg#3465

Merged
youknowone merged 4 commits into
RustPython:mainfrom
24seconds:fix_test_base64
Nov 29, 2021
Merged

Support tuple type also for memoryview shape arg#3465
youknowone merged 4 commits into
RustPython:mainfrom
24seconds:fix_test_base64

Conversation

@24seconds

Copy link
Copy Markdown
Contributor

Description

This pr is to fix test_base64.py test failure. Turned out most of them are related to memoryview's cast function.

In the Cpython, cast function's argument shape seems to support list and tuple type.
https://github.com/python/cpython/blob/af9ee57b96cb872df6574e36027cc753417605f9/Objects/memoryobject.c#L1367-L1418

But RustPython currently supports list only.
So this pr did those below

  • Change CastArgs shape field type to OptionalArg<PyObjectRef>
  • Check shape type is one of list or tuple
  • convert shape properly

Because many test_base64.py tests are related to this problem, most of them are resolved after fix.

For the check, I ran these. If there is another thing that I should do, please give me guide 🙇

cargo check
cargo fmt
cargo clippy

@youknowone youknowone left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We usually use types to narrow down to specific types when it is possible. Could you update it using Either?

Comment thread vm/src/builtins/memory.rs Outdated
24seconds and others added 2 commits November 28, 2021 18:25
Co-authored-by: Jeong YunWon <69878+youknowone@users.noreply.github.com>
@24seconds 24seconds requested a review from youknowone November 28, 2021 09:38

@24seconds 24seconds left a comment •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

65d9e2f, NICE!

@youknowone youknowone left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work, thank you!

@youknowone youknowone merged commit 32a9b95 into RustPython:main Nov 29, 2021
@24seconds 24seconds deleted the fix_test_base64 branch November 29, 2021 07:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants