Skip to content

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

Open
shyamsubbu wants to merge 1 commit intombj4668:masterfrom
shyamsubbu:patch-1
Open

Fix for AttributeError: 'NoneType' object has no attribute pos in#488
shyamsubbu wants to merge 1 commit intombj4668:masterfrom
shyamsubbu:patch-1

Conversation

@shyamsubbu
Copy link
Copy Markdown

@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
Copy Markdown

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
Copy Markdown

Coverage Status

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

@shyamsubbu
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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