Repository navigation
Fix crash in ConanFileHandler and support list attributes (fixes #5495) - #5496
Open
muskan-creates352 wants to merge 1 commit into
Open
muskan-creates352 wants to merge 1 commit into
muskan-creates352 wants to merge 1 commit into
Conversation
…tcode-org#5495) - In ConanFileHandler._parse, safely check for any base matching ConanFile, supporting module-qualified bases like conan.ConanFile (Conan 2.0). - Safely handle empty files and files without a ConanFile class, avoiding AttributeError: 'NoneType' object has no attribute '_fields'. - Do not yield None from ConanFileHandler.parse. - Support ast.List for requires, topics, and license attributes in ConanFileParser.visit_Assign. - Handle requires entries without a slash delimiter in get_dependencies. - Add unit tests for qualified base, non-ConanFile files, list dependencies, and delimiterless requirements. Signed-off-by: Muskan Kumari <er.muskan09@gmail.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary of Changes
Fixes #5495
This PR addresses multiple issues in
src/packagedcode/conan.py:Avoid crash on module-qualified base or non-ConanFile classes:
ConanFileHandler._parse, searchnode.basesfor any base that is eitherast.Name(id="ConanFile")orast.Attribute(attr="ConanFile"), adding support forconan.ConanFile(standard in Conan 2.0).ConanFile(e.g., empty file, non-recipe Python script), safely returnNoneinstead of callingparser.visit(None)which previously raisedAttributeError: 'NoneType' object has no attribute '_fields'.Prevent yielding
None:ConanFileHandler.parse, only yield when_parse()returns a validPackageDataobject instead of unconditionally yielding[None].Support
ast.Listfor list-based attributes:ConanFileParser.visit_Assign, allow(ast.Tuple, ast.List)so thatrequires = ["..."],topics = ["..."], andlicense = ["..."]are properly extracted rather than silently dropped.Handle delimiterless
requiresentries:get_dependencies, handle requirement entries that do not contain/(e.g.,requires = ["package_name"]), preventingValueError: not enough values to unpack.Unit Tests:
tests/packagedcode/test_conan.pycovering module-qualified bases (conan.ConanFile), non-ConanFile/empty files, list-based dependencies, topics, license, and delimiterless requirements.Sign-off
Signed-off-by: Muskan Kumari er.muskan09@gmail.com