Encodign issue in Python 3.3.1 (once again)

Michael Torrie torriem at gmail.com
Tue May 28 13:17:05 EDT 2013


On 05/28/2013 10:45 AM, Νίκος Γκρ33κ wrote:
> con = pymysql.connect( db = 'pelatologio', host = 'localhost', user = 'blabla', passwd = 'blabla', init_command='SET NAMES UTF8', charset = 'utf-8' )
> 
> produces this "God knows what" error traceback....

Hey at least your database code is now working.

>     /home/nikos/public_html/cgi-bin/metrites.py in ()
>     217                 template = htmldata + counter
>     218         elif page.endswith('.py'):
> =>  219                 htmldata = subprocess.check_output( '/home/nikos/public_html/cgi-bin/' + page )
>     220                 template = htmldata.decode('utf-8').replace( 'Content-type: text/html; charset=utf-8', '' ) + counter
>     221                 
> htmldata undefined, subprocess = <module 'subprocess' from '/opt/python3/lib/python3.3/subprocess.py'>, subprocess.check_output = <function check_output>, page = 'pelatologio.py'
>  /opt/python3/lib/python3.3/subprocess.py in check_output(timeout=None, *popenargs=('/home/nikos/public_html/cgi-bin/pelatologio.py',), **kwargs={})
>     584         retcode = process.poll()
>     585         if retcode:
> =>  586             raise CalledProcessError(retcode, process.args, output=output)
>     587     return output
>     588 
> global CalledProcessError = <class 'subprocess.CalledProcessError'>, retcode = 1, process = <subprocess.Popen object>, process.args = '/home/nikos/public_html/cgi-bin/pelatologio.py', output = b'<!--: spam\nContent-Type: text/html\n\n<body b...Type\' object has no attribute \'id\'\n\n-->\n\n'
> CalledProcessError: Command '/home/nikos/public_html/cgi-bin/pelatologio.py' returned non-zero exit status 1 
>       args = (1, '/home/nikos/public_html/cgi-bin/pelatologio.py') 
>       cmd = '/home/nikos/public_html/cgi-bin/pelatologio.py' 
>       output = b'<!--: spam\nContent-Type: text/html\n\n<body b...Type\' object has no attribute \'id\'\n\n-->\n\n' 
>       returncode = 1 
>       with_traceback = <built-in method with_traceback of CalledProcessError object>

Again the traceback is telling you where to look for the problem.  And
the problem is in your own script, pelatologio.py, though the line
number that's causing the problem is obscured.

Basically you want pelatologio.py to run and then you process the output
through a template, correct?

Well the traceback is telling you that pelatologio.py is erroring out.
In fact, subprocess is telling you that this process (your script) quit
with an error.  Though the line number in pelatologio.py is unknown (the
traceback is obscured by your html processing code in your template
processor), the error message itself is not.  Inside pelatologio.py
there is some object that you are trying to reference the "id" attribute
on it does not contain id.

So the problem is in pelatologio.py.  Double check your code there.  Try
to make a standalone test file you can run locally.



More information about the Python-list mailing list