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

Fixed recursion error when pyan.py is called in a directory with an __init__.py #2

Merged
merged 1 commit into from
Dec 12, 2016

Conversation

mao-liu
Copy link

@mao-liu mao-liu commented Dec 8, 2016

If running pyan.py in a directory which contains an __init__.py, a recursion error occurs inside get_module_name with get_module_name('') recursively calling itself.

e.g. for the following folder structure:

foo/
    __init__.py
    bar.py
__init__.py

with the following call in the root directory:
python pyan.py foo/*.py --dot

get_module_name then gets called with the following arguments:

get_module_name('foo/bar.py')
--> get_module_name('foo')        # 1. this step should return 'foo' rather than recurse
    --> get_module_name('')
        -->get_module_name('')    # 2. recursion error
            ...

Existing behaviour is 2. New behaviour is 1.

@davidfraser
Copy link
Owner

Thanks for catching this!

@davidfraser davidfraser merged commit ef9b5a8 into davidfraser:master Dec 12, 2016
@davidfraser
Copy link
Owner

After merging this, I noticed certain cases (such as a function in the __init__ file) where an empty string would be generated in the dotfile. We should really have test cases for this, but in the mean time it would be good to handle that a bit better. Would you be interested in working that out?

@mao-liu
Copy link
Author

mao-liu commented Dec 13, 2016 via email

@davidfraser
Copy link
Owner

I've pushed a fix, and a testcase (not a proper running unit test yet):

cd testcase
../pyan.py --dot *.py foo/*.py > x.dot

PatrickMassot added a commit to PatrickMassot/pyan that referenced this pull request Dec 18, 2016
Technologicat added a commit to Technologicat/pyan that referenced this pull request Nov 15, 2017
@Technologicat Technologicat mentioned this pull request Nov 16, 2017
davidfraser pushed a commit that referenced this pull request Feb 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants