← 输入框|github.com|刷新
Skip to content

Bug in LPython 0.19.0 emulation mode: 'function' object has no attribute 'restype' #2222

Closed

Description

@certik

It works with LPython 0.18.4, but breaks with LPython 0.19.0:

  File "/root/mambaforge/envs/ch_emulation/share/lpython/lib/lpython/lpython.py", line 398, in __call__
    if self.cf.restype == ctypes.c_char_p:
AttributeError: 'function' object has no attribute 'restype'

I still need to create a minimal example.

Activity

  1. certik commented on Jul 30, 2023

    @certik
    ContributorAuthor

    This fixes it:

    diff --git a/src/runtime/lpython/lpython.py b/src/runtime/lpython/lpython.py
    index 2f0eee0b5..1f09e9abb 100644
    --- a/src/runtime/lpython/lpython.py
    +++ b/src/runtime/lpython/lpython.py
    @@ -371,6 +371,7 @@ class CTypes:
                 self.cf = self.library[self.name]
             else:
                 self.cf = CTypes.emulations[self.name]
    +            self.cf.restype = None
             argtypes = []
             for arg in self.args:
                 arg_type = self.annotations[arg]
  2. certik commented on Jul 30, 2023

    @certik
    ContributorAuthor

    This change was introduced in #2196.

  3. added a commit that references this issue on Jul 30, 2023
    9979cce
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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