mmap extended slicing ignores the step; negative steps raise java.lang.IndexOutOfBoundsException

オープン
#1,367 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
64/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
java, python
領域
backend

調査の方向性

Start by running the three-line reproduction script on GraalPy and comparing it with CPython's output. The payload names no source files, so locate the mmap implementation by searching for the slice handling. CPython's test_mmap.MmapTests.test_extended_getslice is the target. Done when extended slices with positive and negative steps match bytearray and the negative-step case no longer raises a Java IndexOutOfBoundsException.

索引モデルが issue の本文から書いたものです。

説明

I found this while benchmarking the conformance of alternative Python implementations against CPython: the same standard library cases and selected CPython tests run on CPython, PyPy, GraalPy and RustPython.

Reading a mmap.mmap slice with a step other than 1 returns the contiguous bytes instead of every n-th byte. A negative step raises a Java IndexOutOfBoundsException that is not catchable as a Python exception. mmap objects are documented to behave like bytearray, and CPython's test_mmap.MmapTests.test_extended_getslice covers this; it fails on GraalPy.

Reproduction
import mmap

data = bytes(range(10))
region = mmap.mmap(-1, len(data))
region[:] = data
print(region[::2].hex(), data[::2].hex())
print(region[1:7:3].hex(), data[1:7:3].hex())
print(region[::-1].hex(), data[::-1].hex())

CPython 3.12.15:

0002040608 0002040608
0104 0104
09080706050403020100 09080706050403020100

GraalPy:

0001020304 0002040608
0102 0104
java.lang.IndexOutOfBoundsException

The length of the result is right; the step is not applied. Assigning to an extended slice (region[::2] = b"xyz") works.

Versions
  • GraalPy 25.2.4 Community (Python 3.12.8), Linux x86-64 and macOS aarch64 standalone builds
  • GraalPy 25.6.5 Community (Python 3.13.14), macOS aarch64 standalone build

This report was drafted with the help of AI. The reproductions were run on the GraalPy versions listed above, and on CPython 3.12.15 for the expected output.

主要言語
Python
スター
1.7k
フォーク
167
平均マージ
3日 11時間
マージ済み PR(30日)
68

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

oracle/graalpython のほかの issue

oracle/graalpython の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。