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

cython 0.29 produces invalid __path__, breaking nose #2662

Open
jbaum-cmcrc opened this Issue Oct 16, 2018 · 4 comments

Comments

Projects
None yet
3 participants
@jbaum-cmcrc

jbaum-cmcrc commented Oct 16, 2018

Cython 0.29 produces invalid __path__ module attributes, breaking nosetests (and possibly other tools).

According to the Python reference, "__path__ must be an iterable of strings, but it may be empty" (Python language reference, section 5.4.5).

  • In cython 0.29, the __path__ attribute on a compiled module is None, which is not an iterable.
  • In cython 0.28.5, there is no __path__ attribute on a compiled module.

Expected behaviour: Compiled modules have a valid __path__ attribute (or omit it altogether).

Impact on nosetests:

  • When collecting tests to run, nose checks the __path__ attribute on each module; if it exists, nose attempts to iterate over it in order to find submodules to test. (If the attribute doesn't exist, nose skips the iteration.)
  • In cython 0.29, nose attempts to iterate the invalid __path__ attribute, giving a "'NoneType' object is not iterable" error.
  • In cython 0.28.5, there is no __path__ attribute on a compiled module, so nose skips the iteration and proceeds without error; the new behaviour is therefore a regression as far as projects using nosetests are concerned.
  • Error message given by nose when testing a module compiled by Cython 0.29:
      File ".../lib/python3.6/site-packages/nose/loader.py", line 343, in loadTestsFromModule
        for module_path in module_paths:
    TypeError: 'NoneType' object is not iterable
    

@jbaum-cmcrc jbaum-cmcrc changed the title from cython 0.29 produces invalid `__path__`, breaking nose to cython 0.29 produces invalid __path__, breaking nose Oct 16, 2018

@hmaarrfk hmaarrfk referenced this issue Oct 16, 2018

Closed

lookfor is broken with cython == 0.29.0 #3475

0 of 1 task complete
@hmaarrfk

This comment has been minimized.

hmaarrfk commented Oct 17, 2018

It seems that this line of code

for var_name in ['__builtins__', '__name__', '__file__', '__doc__', '__path__',

was recently added and affects __path__

@jbaum-cmcrc

This comment has been minimized.

jbaum-cmcrc commented Oct 17, 2018

That seems like it should be an easy fix to initialise this one to () instead of None, which would make it valid (and acceptable to nose), though not informative.

@hmaarrfk

This comment has been minimized.

hmaarrfk commented Oct 17, 2018

Yeah, but i would like to hear something from a Cython developer. They will probably want a test to ensure it doesn't keep breaking things in the future.

@robertwb

This comment has been minimized.

Contributor

robertwb commented Oct 18, 2018

Yes, we should be setting this to something valid, if anything at all. (It should probably typically be omitted.) And, yes, we'd want tests with any fix :).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment