13

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???

1 Answer 1

7

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.

4
  • The problem is in the last but one entry: either params.dir or params.file is None, not the last entry since it points to posixpath.py stdlib module.
    – Maciej Gol
    Jul 21, 2013 at 13:43
  • So you are basically saying that either params.dir or params.file are returning a None?
    – mr.G
    Jul 21, 2013 at 14:12
  • Yes. params.dir is None. Jul 21, 2013 at 14:13
  • Thank you very much guys! I'll try to print out the value of params.dir and params.file and i'll let you know.
    – mr.G
    Jul 21, 2013 at 14:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.