Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AttributeError: 'NoneType' object has no attribute 'endswith'

I am currently working on a Python script that updates a web page. But running the main script generates this error:

<res status='-1'><error message="'NoneType' object has no attribute 'endswith'"><![CDATA[
Traceback (most recent call last):
  File "/path/to/file/ws_config.py", line XXXX, in Run
    tests = TestList().tests
  File "/path/to/file/ws_config.py", line XXXX, in __init__
    UpdateTestGroup(None),
  File "/path/to/file/ws_config.py", line XXXX, in __init__
    test = CT.CurlTest(settings),
  File "/path/to/file/config_tests.py", line XXXX, in __init__
    self.params.path = os.path.join('/', os.path.join(params.dir, params.file))
  File "/usr/lib/python2.6/posixpath.py", line 67, in join
    elif path == '' or path.endswith('/'):
AttributeError: 'NoneType' object has no attribute 'endswith'

I cannot past any code because is too long. What I am trying to understand is where the error lays or what part of the code is triggering the AttributeError. Can you please help me???

like image 971
mr.G Avatar asked Jul 21 '13 13:07

mr.G


1 Answers

The path in the elif is a None and None == '' returns False so the remain will be executed. And backwards, the params.dir is a None. You need to check your code where the params.dir generated to see how the None come.

like image 116
zhangyangyu Avatar answered Sep 29 '22 08:09

zhangyangyu