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

properties method failed when no props defined #89

Open
agefflot opened this issue Jul 4, 2017 · 2 comments · May be fixed by #178
Open

properties method failed when no props defined #89

agefflot opened this issue Jul 4, 2017 · 2 comments · May be fixed by #178

Comments

@agefflot
Copy link

agefflot commented Jul 4, 2017

Ask for properties on an element taht does ot have properties defined raise an AttributeError NoneType as no attribute findall

svn\common.py", line 197, in properties
for p in target_elem.findall('property')]
AttributeError: 'NoneType' object has no attribute 'findall'

Need to robustify I think

@keestux
Copy link

keestux commented Jun 14, 2019

What's the status of this?

@keestux
Copy link

keestux commented Jun 14, 2019

Perhaps a simple change like this?

diff --git a/svn/common.py b/svn/common.py
index e3dcda6..e6f7c76 100644
--- a/svn/common.py
+++ b/svn/common.py
@@ -157,8 +157,11 @@ class CommonClient(svn.common_base.CommonBase):
         # query the proper list of this path
         root = xml.etree.ElementTree.fromstring(result)
         target_elem = root.find('target')
-        property_names = [p.attrib["name"]
-                          for p in target_elem.findall('property')]
+        if target_elem is not None:
+            property_names = [p.attrib["name"]
+                              for p in target_elem.findall('property')]
+        else:
+            property_names = []
 
         # now query the content of each propery
         property_dict = {}

idbrii added a commit to idbrii/PySvn that referenced this issue Apr 29, 2021
Fix dsoprea#89: properties method failed when no props defined

When a file has no properties, the xml doesn't contain 'target' and
target_elem is None. To conform to the documentation for properties,
return an empty dict (instead of None).

Test for both no properties and mime type property (writing a binary
file in the simplest way I can find).
idbrii added a commit to idbrii/PySvn that referenced this issue Apr 29, 2021
Fix dsoprea#89: properties method failed when no props defined

When a file has no properties, the xml doesn't contain 'target' and
target_elem is None. To conform to the documentation for properties,
return an empty dict (instead of None).

Test for both no properties and mime type property (writing a binary
file in the simplest way I can find).
@idbrii idbrii linked a pull request Apr 29, 2021 that will close this issue
idbrii added a commit to idbrii/PySvn that referenced this issue Apr 30, 2021
Fix dsoprea#89: properties method failed when no props defined

When a file has no properties, the xml doesn't contain 'target' and
target_elem is None. To conform to the documentation for properties,
return an empty dict (instead of None).

Test for both no properties and mime type property (writing a binary
file in the simplest way I can find that works in py2 and py3).
idbrii added a commit to idbrii/PySvn that referenced this issue Apr 30, 2021
Fix dsoprea#89: properties method failed when no props defined

When a file has no properties, the xml doesn't contain 'target' and
target_elem is None. To conform to the documentation for properties,
return an empty dict (instead of None).

Test for both no properties and mime type property (writing a binary
file in the simplest way I can find that works in py2 and py3).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants