Skip to content

ctypes.CDLL on Linux creates a "main program" object when passed an empty string #99874

@ghost

Description

Bug report

ctypes.CDLL throws an exception when it can't find a library in the path pointed at by its name argument; however, if name is an empty string a dummy object is created:

>>> import ctypes
>>> ctypes.CDLL('')
<CDLL '', handle 7fb30d2d3190 at 0x7fb30c2caa60>

I don't think this is correct, since that dummy object will break things when trying to use it later on.

Your environment

  • CPython versions tested on: 3.8.10, 3.10.8
  • Operating system and architecture: Ubuntu 20.04.5 LTS for x86_64

This doesn't happen on Windows with Python 3.10.7; there I see an exception being thrown for the empty string.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions