[issue12671] urlopen returning empty string

2011-07-31 Thread Matthew Barnett

New submission from Matthew Barnett pyt...@mrabarnett.plus.com:

Someone over at StackOverflow had a problem with urlopen in Python 3.2.1:


http://stackoverflow.com/questions/6892573/problem-with-urlopen/6892843#6892843

This is the code:

from urllib.request import urlopen
f = 
urlopen('http://online.wsj.com/mdc/public/page/2_3020-tips.html?mod=topnav_2_3000')
page = f.read()
f.close()

With Python 3.1 and Python 3.2 it works OK, but with Python 3.2.1 the
read returns an empty string.

--
components: Library (Lib)
messages: 141481
nosy: mrabarnett
priority: normal
severity: normal
status: open
title: urlopen returning empty string
type: behavior
versions: Python 3.2

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12671
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12671] urlopen returning empty string

2011-07-31 Thread Matthew Barnett

Matthew Barnett pyt...@mrabarnett.plus.com added the comment:

Just been told this bug has already been reported as issue #12576.

--
resolution:  - duplicate

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12671
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12671] urlopen returning empty string

2011-07-31 Thread Matthew Barnett

Changes by Matthew Barnett pyt...@mrabarnett.plus.com:


--
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12671
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Returning a string

2009-01-06 Thread Kless
How is possible that I can print a variable, but when I use *return
var* it returns an empty string

http://paste.pocoo.org/show/97588/
--
http://mail.python.org/mailman/listinfo/python-list


Re: Returning a string

2009-01-06 Thread Simon Brunning
2009/1/3 Kless jonas@googlemail.com:
 How is possible that I can print a variable, but when I use *return
 var* it returns an empty string

What makes you think it's returning an empty string? You aren't doing
anything with the return value in line 26 of your example.

-- 
Cheers,
Simon B.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Returning a string

2009-01-03 Thread Diez B. Roggisch

Kless schrieb:

How is possible that I can print a variable, but when I use *return
var* it returns an empty string

http://paste.pocoo.org/show/97588/


I don't see anything that indicates that the returned object is the 
empty string. Simply because there is no code testing for that. And of 
course you don't show any debugging output, which doesn't help either.


Diez
--
http://mail.python.org/mailman/listinfo/python-list


Re: Returning a string

2009-01-03 Thread Kless
On 3 ene, 19:12, Diez B. Roggisch de...@nospam.web.de wrote:
 Kless schrieb:

  How is possible that I can print a variable, but when I use *return
  var* it returns an empty string

 http://paste.pocoo.org/show/97588/

 I don't see anything that indicates that the returned object is the
 empty string. Simply because there is no code testing for that. And of
 course you don't show any debugging output, which doesn't help either.

 Diez

Afghanistan
AF
Out[19]: u'AF'
AFG
Out[19]: u'AFG'
004
Out[19]: u'004'
--
http://mail.python.org/mailman/listinfo/python-list


Re: Returning a string

2009-01-03 Thread Simon Forman
On Jan 3, 11:20 am, Kless jonas@googlemail.com wrote:
 On 3 ene, 19:12, Diez B. Roggisch de...@nospam.web.de wrote:

  Kless schrieb:

   How is possible that I can print a variable, but when I use *return
   var* it returns an empty string

  http://paste.pocoo.org/show/97588/

  I don't see anything that indicates that the returned object is the
  empty string. Simply because there is no code testing for that. And of
  course you don't show any debugging output, which doesn't help either.

  Diez

 Afghanistan
 AF
 Out[19]: u'AF'
 AFG
 Out[19]: u'AFG'
 004
 Out[19]: u'004'

What?
--
http://mail.python.org/mailman/listinfo/python-list


Re: Returning a string

2009-01-03 Thread Kless
On 3 ene, 19:40, Simon Forman sajmik...@gmail.com wrote:
 On Jan 3, 11:20 am, Kless jonas@googlemail.com wrote:

  Afghanistan
  AF
  Out[19]: u'AF'
  AFG
  Out[19]: u'AFG'
  004
  Out[19]: u'004'

 What?

That's the output got from ipython. As you can see, it prints
'Afghanistan' but it can not returns it. In change, the another
strings are returned.

Could it be because it isn't returning the value from the
recursivecall?
--
http://mail.python.org/mailman/listinfo/python-list


Re: Returning a string

2009-01-03 Thread Diez B. Roggisch

Kless schrieb:

On 3 ene, 19:12, Diez B. Roggisch de...@nospam.web.de wrote:

Kless schrieb:


How is possible that I can print a variable, but when I use *return
var* it returns an empty string
http://paste.pocoo.org/show/97588/

I don't see anything that indicates that the returned object is the
empty string. Simply because there is no code testing for that. And of
course you don't show any debugging output, which doesn't help either.

Diez


Afghanistan
AF
Out[19]: u'AF'
AFG
Out[19]: u'AFG'
004
Out[19]: u'004'


What is that? IPython? And I don't see no empty string here. *What* I 
see is the way python's interactive prompt puts out strings, like this:


 unicode(foo)
u'foo'

Do you mean by any chance that you don't understand why print prints 
foo, but the prompt shows ufoo? That is because the prompt invokes


repr(o)

to print out an object:

 print repr(unicode(foo))
u'foo'

Which means that the output includes quotes and the u-prefix in case 
of an unicode object to help the user to see what the current object 
looks like.


Diez

--
http://mail.python.org/mailman/listinfo/python-list


Re: Returning a string

2009-01-03 Thread Diez B. Roggisch

Kless schrieb:

On 3 ene, 19:40, Simon Forman sajmik...@gmail.com wrote:

On Jan 3, 11:20 am, Kless jonas@googlemail.com wrote:


Afghanistan
AF
Out[19]: u'AF'
AFG
Out[19]: u'AFG'
004
Out[19]: u'004'

What?


That's the output got from ipython. As you can see, it prints
'Afghanistan' but it can not returns it. In change, the another
strings are returned.

Could it be because it isn't returning the value from the
recursivecall?


Yep, I guess that's the problem. You need to do

if cell_tag:
   return clean_tags(cell_tag)


Diez
--
http://mail.python.org/mailman/listinfo/python-list


Re: Returning a string

2009-01-03 Thread Marc 'BlackJack' Rintsch
On Sat, 03 Jan 2009 11:46:10 -0800, Kless wrote:

 On 3 ene, 19:40, Simon Forman sajmik...@gmail.com wrote:
 On Jan 3, 11:20 am, Kless jonas@googlemail.com wrote:

  Afghanistan
  AF
  Out[19]: u'AF'
  AFG
  Out[19]: u'AFG'
  004
  Out[19]: u'004'

 What?
 
 That's the output got from ipython. As you can see, it prints
 'Afghanistan' but it can not returns it. In change, the another strings
 are returned.

Maybe you should show the *input* too…

Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list


Re: Returning a string

2009-01-03 Thread Kless
On 3 ene, 19:51, Diez B. Roggisch de...@nospam.web.de wrote:
 Kless schrieb:



  On 3 ene, 19:40, Simon Forman sajmik...@gmail.com wrote:
  On Jan 3, 11:20 am, Kless jonas@googlemail.com wrote:

  Afghanistan
  AF
  Out[19]: u'AF'
  AFG
  Out[19]: u'AFG'
  004
  Out[19]: u'004'
  What?

  That's the output got from ipython. As you can see, it prints
  'Afghanistan' but it can not returns it. In change, the another
  strings are returned.

  Could it be because it isn't returning the value from the
  recursivecall?

 Yep, I guess that's the problem. You need to do

 if cell_tag:
     return clean_tags(cell_tag)

 Diez

Thank you very much. It works now.
--
http://mail.python.org/mailman/listinfo/python-list