From: MRAB on
Victor Subervi wrote:
> Hi;
> I get this error:
>
> /var/www/html/angrynates.com/christians/cart/simplemail/mail.py
> <http://angrynates.com/christians/cart/simplemail/mail.py>
> 153 </head>
> 154 <body>'''
> 155 commitSale()
> 156 myMail()
> 157 print '''
> commitSale = <function commitSale>
> /var/www/html/angrynates.com/christians/cart/simplemail/mail.py
> <http://angrynates.com/christians/cart/simplemail/mail.py> in commitSale()
> 98 cursor.execute('select max(ID) from %sCustomerData;' % store)
> 99 custID = cursor.fetchone()[0]
> 100 customerData(store, tmpTable, custID, patientID)
> 101
> 102 def myMail():
> global customerData = <function customerData>, global store =
> 'products', tmpTable = 'tem12627568064', custID = 1, global patientID =
> 'None'
> /var/www/html/angrynates.com/christians/cart/customerData.py
> <http://angrynates.com/christians/cart/customerData.py> in
> customerData(store='products', tmpTable='tem12627568064', custID=1,
> patientID='None')
> 39 <body>
> 40 """
> 41 print """
> 42 print '<h1 align="center">%s Customer Data</h1>' %
> (store[0].upper() + store[1:])
> 43 cursor.execute('describe %sCustomerData' % store)
> store = 'products'
>
> ValueError: unsupported format character '(' (0x28) at index 54
> args = ("unsupported format character '(' (0x28) at index 54",)
>
> Apparently that character is a "file separator", which I presume is an
> invisible character. I tried retyping the area in question, but with no
> avail (threw same error). Please advise. Complete code follows.
>
Please provide the actual code (and, preferably, an easier-to-understand
traceback, like what CPython does!). What you supplied isn't runnable.
From: r0g on
MRAB wrote:
> Victor Subervi wrote:
>> Hi;
>> I get this error:
>>
>> /var/www/html/angrynates.com/christians/cart/simplemail/mail.py
>> <http://angrynates.com/christians/cart/simplemail/mail.py>
>> 153 </head>
>> 154 <body>'''
>> 155 commitSale()
>> 156 myMail()
>> 157 print '''
>> commitSale = <function commitSale>
>> /var/www/html/angrynates.com/christians/cart/simplemail/mail.py
>> <http://angrynates.com/christians/cart/simplemail/mail.py> in
>> commitSale()
>> 98 cursor.execute('select max(ID) from %sCustomerData;' % store)
>> 99 custID = cursor.fetchone()[0]
>> 100 customerData(store, tmpTable, custID, patientID)
>> 101
>> 102 def myMail():
>> global customerData = <function customerData>, global store =
>> 'products', tmpTable = 'tem12627568064', custID = 1, global patientID
>> = 'None'
>> /var/www/html/angrynates.com/christians/cart/customerData.py
>> <http://angrynates.com/christians/cart/customerData.py> in
>> customerData(store='products', tmpTable='tem12627568064', custID=1,
>> patientID='None')
>> 39 <body>
>> 40 """
>> 41 print """
>> 42 print '<h1 align="center">%s Customer Data</h1>' %
>> (store[0].upper() + store[1:])
>> 43 cursor.execute('describe %sCustomerData' % store)
>> store = 'products'
>>
>> ValueError: unsupported format character '(' (0x28) at index 54
>> args = ("unsupported format character '(' (0x28) at index 54",)
>>
>> Apparently that character is a "file separator", which I presume is an
>> invisible character. I tried retyping the area in question, but with
>> no avail (threw same error). Please advise. Complete code follows.
>>
> Please provide the actual code (and, preferably, an easier-to-understand
> traceback, like what CPython does!). What you supplied isn't runnable.



Oh and, it's probably not a good idea to post things that identify the
site you're working on, especially if you're fairly new to programming
and you're doing a shopping cart! Hackers have been known to trawl
google looking for mention of novice coders websites, giving them domain
names, internal paths, table names etc might well help them hack you!

Cheers & good luck,

Roger.
From: John Machin on
On Jan 7, 3:29 am, MRAB <pyt...(a)mrabarnett.plus.com> wrote:
> Victor Subervi wrote:

> > ValueError: unsupported format character '(' (0x28) at index 54
> >       args = ("unsupported format character '(' (0x28) at index 54",)
>
> > Apparently that character is a "file separator", which I presume is an
> > invisible character. I tried retyping the area in question, but with no
> > avail (threw same error). Please advise. Complete code follows.
>

OP is barking up the wrong tree. "file separator" has ordinal 28
DECIMAL. Correct tree contains '(' (left parenthesis, ordinal 0x28
(HEX)) as the error message says.
From: John Machin on
On Jan 7, 11:14 am, John Machin <sjmac...(a)lexicon.net> wrote:
> On Jan 7, 3:29 am, MRAB <pyt...(a)mrabarnett.plus.com> wrote:
>
> > Victor Subervi wrote:
> > > ValueError: unsupported format character '(' (0x28) at index 54
> > >       args = ("unsupported format character '(' (0x28) at index 54",)
>
> > > Apparently that character is a "file separator", which I presume is an
> > > invisible character. I tried retyping the area in question, but with no
> > > avail (threw same error). Please advise. Complete code follows.
>
> OP is barking up the wrong tree. "file separator" has ordinal 28
> DECIMAL. Correct tree contains '(' (left parenthesis, ordinal 0x28
> (HEX)) as the error message says.

It took a bit of mucking about to get an example of that error message
(without reading the Python source code):

|>>> anything = object()

\|>>> "foo%(" % anything
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: format requires a mapping

|>>> "foo%(" % {}
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: incomplete format key

|>>> "foo%2(" % anything
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: unsupported format character '(' (0x28) at index 5

FWIW, the OP's message subject is "TypeError" but the reported message
contains ValueError ... possibly indicative of code that first builds
a format string (incorrectly) and then uses it with error messages
that can vary from run to run depending on exactly what was stuffed
into the format string.

I note that in the code shown there are examples of building an SQL
query where the table name is concocted at runtime via the %
operator ... key phrases: "bad database design" (one table per
store!), "SQL injection attack"

A proper traceback would be very nice ... at this stage it's not
certain what was the line of source that triggers the exception.
From: Steve Holden on
John Machin wrote:
[...]
> I note that in the code shown there are examples of building an SQL
> query where the table name is concocted at runtime via the %
> operator ... key phrases: "bad database design" (one table per
> store!), "SQL injection attack"
>
I'm not trying to defend the code overall, but most databases won't let
you parameterize the table or column names, just the data values.

regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
PyCon is coming! Atlanta, Feb 2010 http://us.pycon.org/
Holden Web LLC http://www.holdenweb.com/
UPCOMING EVENTS: http://holdenweb.eventbrite.com/