Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] [stdlib] Fix String.format() to use explicit byte indexing and not assume String.__getitem__ indexes directly to byte offset. #3296

Closed
martinvuyk opened this issue Jul 23, 2024 · 0 comments
Labels
bug Something isn't working mojo Issues that are related to mojo mojo-repo Tag all issues with this label

Comments

@martinvuyk
Copy link
Contributor

Bug description

Fix String.format() to use explicit byte indexing and not assume String.__getitem__ indexes directly to byte offset.

Python's String indexes by unicode codepoints (UTF-32) our String implementation currently uses UTF-8 and it's __getitem__ returns by byte offset. We need to be compliant with Python's indexing using unicode codepoints and String.format() needs to be fixed.

This is related to PR #3295 and issue #3246

@rd4com I saw it's code you commited, do you wanna take this or should I ?

Steps to reproduce

  • Include relevant code snippet or link to code that did not work as expected.
  • If applicable, add screenshots to help explain the problem.
  • If using the Playground, name the pre-existing notebook that failed and the steps that led to failure.
  • Include anything else that might help us debug the issue.

System information

- What OS did you do install Mojo on ?
- Provide version information for Mojo by pasting the output of `mojo -v`
- Provide Modular CLI version by pasting the output of `modular -v`
@martinvuyk martinvuyk added bug Something isn't working mojo-repo Tag all issues with this label labels Jul 23, 2024
modularbot added a commit that referenced this issue Oct 17, 2024
…tor for performance and readability, and prepare for full format spec support (#49225)

[External] [stdlib] Fix `String.format()` to use byte indexing, refactor
for performance and readability, and prepare for full format spec
support

Fix `String.format()` to use byte indexing, refactor for performance and
readability, and prepare for full format spec support.

Closes #3296.

ORIGINAL_AUTHOR=martinvuyk
<[email protected]>
PUBLIC_PR_LINK=#3539

Co-authored-by: martinvuyk <[email protected]>
Closes #3539
MODULAR_ORIG_COMMIT_REV_ID: 2d7ebae6f48b7d29866c089cffd084cb4405ac45
modularbot added a commit that referenced this issue Dec 17, 2024
…tor for performance and readability, and prepare for full format spec support (#49225)

[External] [stdlib] Fix `String.format()` to use byte indexing, refactor
for performance and readability, and prepare for full format spec
support

Fix `String.format()` to use byte indexing, refactor for performance and
readability, and prepare for full format spec support.

Closes #3296.

ORIGINAL_AUTHOR=martinvuyk
<[email protected]>
PUBLIC_PR_LINK=#3539

Co-authored-by: martinvuyk <[email protected]>
Closes #3539
MODULAR_ORIG_COMMIT_REV_ID: 2d7ebae6f48b7d29866c089cffd084cb4405ac45
@ematejska ematejska added mojo-playground mojo Issues that are related to mojo labels Feb 26, 2025 — with Linear
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working mojo Issues that are related to mojo mojo-repo Tag all issues with this label
Projects
None yet
Development

No branches or pull requests

2 participants