Skip to content

[BUG]: Misleading errors on duplicate enum key registration #5853

@ManuelSchneid3r

Description

@ManuelSchneid3r

Required prerequisites

What version (or hash if on master) of pybind11 are you using?

3.0.1

Problem description

I added duplicate enum keys by accident:

   py::native_enum<StandardIconType>(m, "StandardIconType", "enum.IntEnum")
        .value("TitleBarMenuButton", TitleBarMenuButton)
        .value("TitleBarMenuButton", TitleBarMenuButton)
        …

Now i get lots of warnings like:

15:36:31 [warn:albert.python] ImportError: initialization failed

At:
  /Users/manuel/Library/Application Support/albert/python/plugins/color/__init__.py(17): <module>
  <frozen importlib._bootstrap>(488): _call_with_frames_removed
  <frozen importlib._bootstrap_external>(1026): exec_module

15:36:31 [debg:albert] Plugin python.color unloaded. ImportError: initialization failed

At:
  /Users/manuel/Library/Application Support/albert/python/plugins/color/__init__.py(17): <module>
  <frozen importlib._bootstrap>(488): _call_with_frames_removed
  <frozen importlib._bootstrap_external>(1026): exec_module

15:36:32 [warn:albert.python] ImportError: generic_type: type "PluginInstance" is already registered!

At:
  /Users/manuel/Library/Application Support/albert/python/plugins/firefox/__init__.py(9): <module>
  <frozen importlib._bootstrap>(488): _call_with_frames_removed
  <frozen importlib._bootstrap_external>(1026): exec_module

15:36:32 [debg:albert] Plugin python.firefox unloaded. ImportError: generic_type: type "PluginInstance" is already registered!

At:
  /Users/manuel/Library/Application Support/albert/python/plugins/firefox/__init__.py(9): <module>
  <frozen importlib._bootstrap>(488): _call_with_frames_removed
  <frozen importlib._bootstrap_external>(1026): exec_module

15:36:32 [warn:albert.python] ImportError: generic_type: type "MatchConfig" is already registered!

At:
  /Users/manuel/Library/Application Support/albert/python/plugins/jetbrains_projects/__init__.py(43): <module>
  <frozen importlib._bootstrap>(488): _call_with_frames_removed
  <frozen importlib._bootstrap_external>(1026): exec_module

15:36:32 [debg:albert] Plugin python.jetbrains_projects unloaded. ImportError: generic_type: type "MatchConfig" is already registered!

At:
  /Users/manuel/Library/Application Support/albert/python/plugins/jetbrains_projects/__init__.py(43): <module>
  <frozen importlib._bootstrap>(488): _call_with_frames_removed
  <frozen importlib._bootstrap_external>(1026): exec_module

Basically for each import of the embedded module I get weird is already registered! errros for types that are not part of the actual problem. It took me quite a while to find the actual problem statement (the duplicate enum above).

I would be useful if the errord could indicate the actually duplicate registration of the enum key instead of random other symbols.

Reproducible example code

See above

Is this a regression? Put the last known working version here if it is.

Not a regression

Metadata

Metadata

Assignees

No one assigned

    Labels

    triageNew bug, unverified

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions