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

Fix for AttributeError: 'NoneType' object has no attribute pos in #488

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

shyamsubbu
Copy link

@shyamsubbu shyamsubbu commented May 18, 2019

line 81 function emit_depend will throw AttributeError error when m is None
and we reference m.pos.ref

@coveralls
Copy link

Coverage Status

Coverage increased (+1.7%) to 37.379% when pulling 8a8214c on shyamsubbu:patch-1 into 8f5f1a7 on mbj4668:master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage increased (+1.7%) to 37.379% when pulling 8a8214c on shyamsubbu:patch-1 into 8f5f1a7 on mbj4668:master.

@shyamsubbu
Copy link
Author

@mbj4668
I faced this issue while compiling a package where m is None and the line 81 function emit_depend will throw AttributeError error for m.pos.ref.
So i added a check for m is None . Hope this is ok .

@mbj4668
Copy link
Owner

mbj4668 commented May 29, 2019

I don't think that this is the right fix. Note that you can pass --depend-ignore-module ModName to ignore some modules.
However, the code shouldn't crash; in this case it should probably give an error instead.
Do you have an example fot how to reproduce this?

@shyamsubbu
Copy link
Author

shyamsubbu commented Jul 5, 2019

Code is crashing as shown below. Like you mentioned even though i did not use "--depend-ignore-module "
pyang should not crash.

Traceback (most recent call last):
File "/auto/nso/tools/py3/bin/pyang", line 4, in
import('pkg_resources').run_script('pyang==1.7.8', 'pyang')
File "/auto/nso/tools/py3/lib/python3.6/site-packages/pkg_resources/init.py", line 658, in run_script
self.require(requires)[0].run_script(script_name, ns)
File "/auto/nso/tools/py3/lib/python3.6/site-packages/pkg_resources/init.py", line 1438, in run_script
exec(code, namespace, namespace)
File "/auto/nso/tools/py3/lib/python3.6/site-packages/pyang-1.7.8-py3.6.egg/EGG-INFO/scripts/pyang", line 489, in
run()
File "/auto/nso/tools/py3/lib/python3.6/site-packages/pyang-1.7.8-py3.6.egg/EGG-INFO/scripts/pyang", line 458, in run
emit_obj.emit(ctx, modules, fd)
File "/auto/nso/tools/py3/lib/python3.6/site-packages/pyang-1.7.8-py3.6.egg/pyang/plugins/depend.py", line 63, in emit
emit_depend(ctx, modules, fd)
File "/auto/nso/tools/py3/lib/python3.6/site-packages/pyang-1.7.8-py3.6.egg/pyang/plugins/depend.py", line 80, in emit_depend
filename = m.pos.ref
AttributeError: 'NoneType' object has no attribute 'pos'
make[1]: *** [../load-dir/ipaddress-allocator-oper.fxs] Error 1

ygorelik added a commit to ygorelik/pyang that referenced this pull request Jul 10, 2023
Fix for AttributeError: 'NoneType' object has no attribute. PR mbj4668#488
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.

3 participants