Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #40865 > unrolled thread
| Started by | Νίκος Γκρ33κ <nikos.gr33k@gmail.com> |
|---|---|
| First post | 2013-03-08 08:35 -0800 |
| Last post | 2013-03-08 08:50 -0800 |
| Articles | 8 — 5 participants |
Back to article view | Back to comp.lang.python
I cant understand this error when i click a link on my website Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-08 08:35 -0800
Re: I cant understand this error when i click a link on my website Chris Angelico <rosuav@gmail.com> - 2013-03-09 03:46 +1100
Re: I cant understand this error when i click a link on my website Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-08 08:50 -0800
Re: I cant understand this error when i click a link on my website Sven <svenito@gmail.com> - 2013-03-08 17:04 +0000
Re: I cant understand this error when i click a link on my website info@cravendot.gr - 2013-03-08 11:16 -0800
Re: I cant understand this error when i click a link on my website info@cravendot.gr - 2013-03-08 11:16 -0800
Re: I cant understand this error when i click a link on my website MRAB <python@mrabarnett.plus.com> - 2013-03-08 17:24 +0000
Re: I cant understand this error when i click a link on my website Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-08 08:50 -0800
| From | Νίκος Γκρ33κ <nikos.gr33k@gmail.com> |
|---|---|
| Date | 2013-03-08 08:35 -0800 |
| Subject | I cant understand this error when i click a link on my website |
| Message-ID | <e72cf106-db58-45b4-bcb8-3e519b83e2bb@googlegroups.com> |
A problem occurred in a Python script. Here is the sequence of function calls leading up to the error, in the order they occurred.
/home/nikos/public_html/cgi-bin/metrites.py in ()
12
13 htmlpage = form.getvalue('htmlpage')
14 if re.search( r'(.html|.py)', htmlpage ):
15 htmlpage = htmlpage.replace( '/home/nikos/public_html/', '' )
16 else:
re = <module 're' from '/usr/lib64/python2.6/re.pyc'>, re.search = <function search>, htmlpage = ['/home/nikos/public_html/index.html', 'pelatologio.py']
/usr/lib64/python2.6/re.py in search(pattern='(.html|.py)', string=['/home/nikos/public_html/index.html', 'pelatologio.py'], flags=0)
140 """Scan through string looking for a match to the pattern, returning
141 a match object, or None if no match was found."""
142 return _compile(pattern, flags).search(string)
143
144 def sub(pattern, repl, string, count=0):
global _compile = <function _compile>, pattern = '(.html|.py)', flags = 0, ).search undefined, string = ['/home/nikos/public_html/index.html', 'pelatologio.py']
<type 'exceptions.TypeError'>: expected string or buffer
args = ('expected string or buffer',)
message = 'expected string or buffer'
==============================
The code worksmy webpoage appear when i http://superhost.gr but whne i click a link on it for exmaple the 1st imaeg shown i get this error, and in evry link too.
[toc] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2013-03-09 03:46 +1100 |
| Message-ID | <mailman.3088.1362761198.2939.python-list@python.org> |
| In reply to | #40865 |
On Sat, Mar 9, 2013 at 3:35 AM, Νίκος Γκρ33κ <nikos.gr33k@gmail.com> wrote: > 15 htmlpage = htmlpage.replace( '/home/nikos/public_html/', '' ) > re = <module 're' from '/usr/lib64/python2.6/re.pyc'>, re.search = <function search>, htmlpage = ['/home/nikos/public_html/index.html', 'pelatologio.py'] > <type 'exceptions.TypeError'>: expected string or buffer The regular expression functions expect a string (or a buffer), but you're passing it a list. Learning to read exception tracebacks is one of the important parts of becoming a competent programmer. ChrisA
[toc] | [prev] | [next] | [standalone]
| From | Νίκος Γκρ33κ <nikos.gr33k@gmail.com> |
|---|---|
| Date | 2013-03-08 08:50 -0800 |
| Message-ID | <fbaf3979-b0a3-4cf4-9eac-4c9c1300dc6f@googlegroups.com> |
| In reply to | #40869 |
Τη Παρασκευή, 8 Μαρτίου 2013 6:46:35 μ.μ. UTC+2, ο χρήστης Chris Angelico έγραψε: > On Sat, Mar 9, 2013 at 3:35 AM, Νίκος Γκρ33κ <nikos.gr33k@gmail.com> wrote: > > > 15 htmlpage = htmlpage.replace( '/home/nikos/public_html/', '' ) > > > re = <module 're' from '/usr/lib64/python2.6/re.pyc'>, re.search = <function search>, htmlpage = ['/home/nikos/public_html/index.html', 'pelatologio.py'] > > > <type 'exceptions.TypeError'>: expected string or buffer > > > > The regular expression functions expect a string (or a buffer), but > > you're passing it a list. > > > > Learning to read exception tracebacks is one of the important parts of > > becoming a competent programmer. > > > > ChrisA but that same exact code is executed withour errors when someone is http://superhost.gr the erro is produces when he is requesting a link from that page...
[toc] | [prev] | [next] | [standalone]
| From | Sven <svenito@gmail.com> |
|---|---|
| Date | 2013-03-08 17:04 +0000 |
| Message-ID | <mailman.3090.1362762272.2939.python-list@python.org> |
| In reply to | #40870 |
[Multipart message — attachments visible in raw view] — view raw
On 8 March 2013 16:50, Νίκος Γκρ33κ <nikos.gr33k@gmail.com> wrote: > > > but that same exact code is executed withour errors when someone is > http://superhost.gr > > the erro is produces when he is requesting a link from that page... > -- > But with different arguments. It's http://superhost.gr/?htmlpage=files.py http://superhost.gr/ and the arguments to your regex are coming up as "string=['/home/nikos/public_html/index.html', 'files.py']" which is clearly a list of strings. In the case of http://superhost.gr/ it's probably just a single string -- ./Sven
[toc] | [prev] | [next] | [standalone]
| From | info@cravendot.gr |
|---|---|
| Date | 2013-03-08 11:16 -0800 |
| Message-ID | <42390196-c6cd-42b2-95a1-f654b80c06df@googlegroups.com> |
| In reply to | #40873 |
Τη Παρασκευή, 8 Μαρτίου 2013 7:04:29 μ.μ. UTC+2, ο χρήστης sven έγραψε: > On 8 March 2013 16:50, Νίκος Γκρ33κ <nikos...@gmail.com> wrote: > > > > > > > > > but that same exact code is executed withour errors when someone is http://superhost.gr > > > > the erro is produces when he is requesting a link from that page... > > -- > > > > But with different arguments. It's http://superhost.gr/?htmlpage=files.py http://superhost.gr/ and the arguments to your regex are coming up as "string=['/home/nikos/public_html/index.html', 'files.py']" which is clearly a list of strings. > > In the case of http://superhost.gr/ it's probably just a single string > > -- > ./Sven Thanks i have fixed the problem just now after 3 hours!
[toc] | [prev] | [next] | [standalone]
| From | info@cravendot.gr |
|---|---|
| Date | 2013-03-08 11:16 -0800 |
| Message-ID | <mailman.3093.1362770212.2939.python-list@python.org> |
| In reply to | #40873 |
Τη Παρασκευή, 8 Μαρτίου 2013 7:04:29 μ.μ. UTC+2, ο χρήστης sven έγραψε: > On 8 March 2013 16:50, Νίκος Γκρ33κ <nikos...@gmail.com> wrote: > > > > > > > > > but that same exact code is executed withour errors when someone is http://superhost.gr > > > > the erro is produces when he is requesting a link from that page... > > -- > > > > But with different arguments. It's http://superhost.gr/?htmlpage=files.py http://superhost.gr/ and the arguments to your regex are coming up as "string=['/home/nikos/public_html/index.html', 'files.py']" which is clearly a list of strings. > > In the case of http://superhost.gr/ it's probably just a single string > > -- > ./Sven Thanks i have fixed the problem just now after 3 hours!
[toc] | [prev] | [next] | [standalone]
| From | MRAB <python@mrabarnett.plus.com> |
|---|---|
| Date | 2013-03-08 17:24 +0000 |
| Message-ID | <mailman.3092.1362763479.2939.python-list@python.org> |
| In reply to | #40870 |
On 08/03/2013 17:04, Sven wrote: > On 8 March 2013 16:50, Νίκος Γκρ33κ <nikos.gr33k@gmail.com > <mailto:nikos.gr33k@gmail.com>> wrote: > > > > but that same exact code is executed withour errors when someone is > http://superhost.gr > > the erro is produces when he is requesting a link from that page... > -- > > > But with different arguments. It's > http://superhost.gr/?htmlpage=files.py http://superhost.gr/ and the > arguments to your regex are coming up as > "string=['/home/nikos/public_html/index.html', 'files.py']" which is > clearly a list of strings. > In the case of http://superhost.gr/ it's probably just a single string > The documentation for getvalue says """If the submitted form data contains more than one field with the same name, the object retrieved by form[key] is not a FieldStorage or MiniFieldStorage instance but a list of such instances. Similarly, in this situation, form.getvalue(key) would return a list of strings.""" This suggests that the webpage may in fact have 2 fields with the name "htmlpage".
[toc] | [prev] | [next] | [standalone]
| From | Νίκος Γκρ33κ <nikos.gr33k@gmail.com> |
|---|---|
| Date | 2013-03-08 08:50 -0800 |
| Message-ID | <mailman.3089.1362761445.2939.python-list@python.org> |
| In reply to | #40869 |
Τη Παρασκευή, 8 Μαρτίου 2013 6:46:35 μ.μ. UTC+2, ο χρήστης Chris Angelico έγραψε: > On Sat, Mar 9, 2013 at 3:35 AM, Νίκος Γκρ33κ <nikos.gr33k@gmail.com> wrote: > > > 15 htmlpage = htmlpage.replace( '/home/nikos/public_html/', '' ) > > > re = <module 're' from '/usr/lib64/python2.6/re.pyc'>, re.search = <function search>, htmlpage = ['/home/nikos/public_html/index.html', 'pelatologio.py'] > > > <type 'exceptions.TypeError'>: expected string or buffer > > > > The regular expression functions expect a string (or a buffer), but > > you're passing it a list. > > > > Learning to read exception tracebacks is one of the important parts of > > becoming a competent programmer. > > > > ChrisA but that same exact code is executed withour errors when someone is http://superhost.gr the erro is produces when he is requesting a link from that page...
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web