Skip to content

[BUG] embed_pos_in_docstring and fast_getattr gives error on memoryview #6442

@user202729

Description

@user202729

Describe the bug

  1. Create setup.py

    from Cython.Build import cythonize
    import Cython.Compiler.Options
    Cython.Compiler.Options.embed_pos_in_docstring = True
    from setuptools import setup
    setup(
    	ext_modules=cythonize(
    		"a.pyx",
    		compiler_directives={'fast_getattr': True},
    		)
    	)
  2. Create a.pyx

    def f():
    	cdef int[:] b
    f()
  3. Run in shell

    rm a.c
    python setup.py build_ext --inplace
    python -c "import a"
  4. See

    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "a.pyx", line 1, in init a
    	def f():
    AttributeError: type object 'a.array' has no attribute '__getattr__'. Did you mean: '__setattr__'?

Expected behaviour

It runs without error

OS

Linux

Python version

3.12.6

Cython version

3.0.11

Additional context

Context: trying to use memoryview in SageMath sagemath/sage#38834

Actually fast_getattr is undocumented… but SageMath uses it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions