Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sphinx autoenum does not work with Sphinx 7.2+: UnboundLocalError: cannot access local variable 'membername' where it is not associated with a value #77

Open
adamtheturtle opened this issue Aug 21, 2023 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@adamtheturtle
Copy link
Contributor

Description

sphinx autoenum does not work with Sphinx 7.2+.

We get:

updating environment: [new config] 1 added, 0 changed, 0 removed
/Users/adam/.virtualenvs/enum_example/lib/python3.11/site-packages/enum_tools/autoenum.py:226: RemovedInSphinx80Warning: The tuple interface of ObjectMember is deprecated. Use (obj.__name__, obj.object) instead.
  if member[0] not in self.object.__members__.keys():

Exception occurred:
  File "/Users/adam/.virtualenvs/enum_example/lib/python3.11/site-packages/sphinx/ext/autodoc/__init__.py", line 779, in filter_members
    self.name, membername, member, exc, type='autodoc')
               ^^^^^^^^^^
UnboundLocalError: cannot access local variable 'membername' where it is not associated with a value
The full traceback has been saved in /var/folders/kd/d94l0l2j6vs_5f52qthyrtj80000gn/T/sphinx-err-040l0gvj.log, if you want to report the issue to the developers.

Steps to Reproduce

pip install the following:

enum-tools==0.10.0

# This will cause a failure.
# Change this to 7.1.2 or lower to avoid the error.
sphinx==7.2.2  

Create the following files:

conf.py :

extensions = ['sphinx.ext.autodoc', 'enum_tools.autoenum']

index.rst :

.. autoenum:: enum_tools.demo.People
    :members:

Run:

sphinx-build -M html . build

Actual result:

updating environment: [new config] 1 added, 0 changed, 0 removed
/Users/adam/.virtualenvs/enum_example/lib/python3.11/site-packages/enum_tools/autoenum.py:226: RemovedInSphinx80Warning: The tuple interface of ObjectMember is deprecated. Use (obj.__name__, obj.object) instead.
  if member[0] not in self.object.__members__.keys():

Exception occurred:
  File "/Users/adam/.virtualenvs/enum_example/lib/python3.11/site-packages/sphinx/ext/autodoc/__init__.py", line 779, in filter_members
    self.name, membername, member, exc, type='autodoc')
               ^^^^^^^^^^
UnboundLocalError: cannot access local variable 'membername' where it is not associated with a value
The full traceback has been saved in /var/folders/kd/d94l0l2j6vs_5f52qthyrtj80000gn/T/sphinx-err-040l0gvj.log, if you want to report the issue to the developers.

Expected result:

No error.

Reproduces how often:

Easily reproduced.

Version

  • Operating System: macOS
  • Python: 3.11.4
  • enum_tools: 0.10.0

Installation source

pip

@adamtheturtle
Copy link
Contributor Author

adamtheturtle commented Aug 21, 2023

My guess is that this is a combination of errors, and the particular UnboundLocalError from https://github.com/sphinx-doc/sphinx/blob/6183b6abee561fc71c88fc66416d31a8f8ca009f/sphinx/ext/autodoc/__init__.py#L775-L777 is a Sphinx error.

@adamtheturtle
Copy link
Contributor Author

Fix proposal for the Sphinx logging error: https://github.com/sphinx-doc/sphinx/pull/11628/files

sk1p added a commit to sk1p/LiberTEM that referenced this issue Aug 22, 2023
sk1p added a commit to LiberTEM/LiberTEM that referenced this issue Aug 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants