[OT] Python Q: expected string, tuple found

jburtram jburtram at gmail.com
Thu Feb 20 22:15:17 EST 2014


The error says:
TypeError: sequence item 0:
which is 'header'
I would try to print out that value and see what's in there.  It may give you a better idea where to start. 

--joel

Sent via the Samsung GALAXY S®4, an AT&T 4G LTE smartphone

-------- Original message --------
From: "Greg Rundlett (freephile)" <greg at freephile.com> 
Date: 02/20/2014  17:25  (GMT-05:00) 
To: GNHLUG <gnhlug-discuss at mail.gnhlug.org> 
Subject: [OT] Python Q: expected string, tuple found 
 
I'm trying to run a python script called crucible.py (from Atlassian, for their Crucible product.)   While I'm waiting for their support, I wanted to ask here for help understanding python.

The script is supposed to setup a code review for a local subversion working copy, but it can't even login to the Crucible server.  Using the --debug flag, here is what I get:


grundlett at build-svr1:~/work/test/projects/web/trunk$ crucible.py -r test -d
Crucible server: http://atlassian-demo:8060
Crucible username: grundlett
Please enter your Crucible password: 
DEBUG:root:No authtoken, trying to get one
DEBUG:root:Trying to encode str as UTF-8
DEBUG:root:RestRequest: http://atlassian-demo:8060/rest-service/auth-v1/login - {'Content-Type': 'application/x-www-form-urlencoded', 'Authorization': '++SANITIZED++', 'Accept': 'application/json'} -  userName=grundlett&password=++SANITIZED++
DEBUG:root:Traceback (most recent call last):
  File "/home/grundlett/bin/crucible.py", line 493, in _request
    response = urllib2.build_opener(HTTPRedirectHandler()).open(request, data=payload, timeout=self.timeout).read()
  File "/usr/local/lib/python2.7/urllib2.py", line 391, in open
    response = self._open(req, data)
  File "/usr/local/lib/python2.7/urllib2.py", line 409, in _open
    '_open', req)
  File "/usr/local/lib/python2.7/urllib2.py", line 369, in _call_chain
    result = func(*args)
  File "/usr/local/lib/python2.7/urllib2.py", line 1173, in http_open
    return self.do_open(httplib.HTTPConnection, req)
  File "/usr/local/lib/python2.7/urllib2.py", line 1142, in do_open
    h.request(req.get_method(), req.get_selector(), req.data, headers)
  File "/usr/local/lib/python2.7/httplib.py", line 946, in request
    self._send_request(method, url, body, headers)
  File "/usr/local/lib/python2.7/httplib.py", line 986, in _send_request
    self.putheader(hdr, value)
  File "/usr/local/lib/python2.7/httplib.py", line 924, in putheader
    str = '%s: %s' % (header, '\r\n\t'.join(values))
TypeError: sequence item 0: expected string, tuple found

So, somewhere a tuple is not being converted to string.  Not sure if it's the headers, or extra payload since the log message is sanitized by the logger.  The script is http://pastebin.com/3zeYm2qC and line 493 is where the problem starts.  Any suggestions?

I think I could do something like 

values = ','.join(str(value_list)[1:-1])

but I'm not sure how, and I'm pretty sure that it's the code in crucible.py that is the problem, not in httplib.py

Greg Rundlett
http://eQuality-Tech.com
http://freephile.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.gnhlug.org/mailman/private/gnhlug-discuss/attachments/20140220/b0e23b0b/attachment.html 


More information about the gnhlug-discuss mailing list