[issue4608] urllib.request.urlopen does not return an iterable object
Stefan Schwarzer added the comment: It turned out that although the addinfourl instance had the `__iter__` attribute in `addbase.__init__` correctly assigned, `__iter__` wasn't found by the `iter` builtin. It seems that `iter` always tries to use the `__iter__` method of the _class_ and doesn't look at the instance. Riccardo Attilio Galli and I made the attached patch. The patch also fixes a corresponding `TypeError` for "file://" URLs, not just "ftp://"; URLs. -- nosy: +sschwarzer Added file: http://bugs.python.org/file22474/issue4608.diff ___ Python tracker <http://bugs.python.org/issue4608> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1067702] urllib fails with multiple ftp transfers
Stefan Schwarzer added the comment: I was able to get some error output with the code of the OP. However, I only saw the "opposite" message, such as: Retrieval of 'ftp://ftp.gnome.org/pub/debian/dists/stable/main/source/Sources.bz2' failed with error: [Errno ftp error] 200 Switching to Binary mode. I had to change the used FTP server and path because I had problems connecting to that server. Even with the guidelines by the OP, I could trigger the bug only occasionally. I converted the script to be executable with manual intervention (see attachment). Still, sometimes both files are also successfully downloaded in the second iteration (i. e. the "outer" iteration which downloads both files). These results are from a test with Python 2.6.6. I plan to continue testing with the tip of the Python 2.7 branch. -- nosy: +sschwarzer title: urllib fails with multiple ftps -> urllib fails with multiple ftp transfers Added file: http://bugs.python.org/file22484/urllibftpbug-non-interactive.py ___ Python tracker <http://bugs.python.org/issue1067702> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1067702] urllib fails with multiple ftp transfers
Stefan Schwarzer added the comment: > I converted the script to be executable with manual intervention (see > attachment). This should have been "without manual intervention". :) -- ___ Python tracker <http://bugs.python.org/issue1067702> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1067702] urllib fails with multiple ftp transfers
Stefan Schwarzer added the comment: I can confirm the bug for the Python 2.7 tip (changeset b11e7bc76d07) after using the script urllibftpbug-non-interactive.py. -- ___ Python tracker <http://bugs.python.org/issue1067702> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1067702] urllib fails with multiple ftp transfers
Stefan Schwarzer added the comment: After running the adapted test script three times for Python 3 tip (changeset c5b0585624ef), I didn't get an error message / exception. -- Added file: http://bugs.python.org/file22485/urllibftpbug-non-interactive-py3.py ___ Python tracker <http://bugs.python.org/issue1067702> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1067702] urllib fails with multiple ftp transfers
Stefan Schwarzer added the comment: The traceback and its context for the exception raised in Python 2.7 is: ... ### 99 % ### 99 % 100 % Done retrieving 'ftp://ftp.gnome.org/pub/debian/dists/stable/main/source/Sources.bz2'; read 4539023 bytes Start retrieving 'ftp://ftp.gnome.org/pub/debian/dists/stable/main/source/Sources.bz2' Start retrieving 'ftp://ftp.gnome.org/pub/debian/dists/stable/main/source/Sources.bz2' Retrieval of 'ftp://ftp.gnome.org/pub/debian/dists/stable/main/source/Sources.bz2' failed with error: [Errno ftp error] 200 Switching to Binary mode. Traceback (most recent call last): File "urllibftpbug-non-interactive.py", line 62, in _getTask self._fromFile = urllib.urlopen(self.fromURL) File "/home/schwa/sd/python/cpython/Lib/urllib.py", line 84, in urlopen return opener.open(url) File "/home/schwa/sd/python/cpython/Lib/urllib.py", line 205, in open return getattr(self, name)(url) File "/home/schwa/sd/python/cpython/Lib/urllib.py", line 548, in open_ftp (fp, retrlen) = self.ftpcache[key].retrfile(file, type) File "/home/schwa/sd/python/cpython/Lib/urllib.py", line 886, in retrfile conn = self.ftp.ntransfercmd(cmd) File "/home/schwa/sd/python/cpython/Lib/ftplib.py", line 326, in ntransfercmd host, port = self.makepasv() File "/home/schwa/sd/python/cpython/Lib/ftplib.py", line 304, in makepasv host, port = parse227(self.sendcmd('PASV')) File "/home/schwa/sd/python/cpython/Lib/ftplib.py", line 790, in parse227 raise error_reply, resp IOError: [Errno ftp error] 200 Switching to Binary mode. Total bytes: 4539023 0 % 0 % 0 % ... I printed the traceback by adding traceback.print_exc() at the end of the _getTask method: except Exception, e: self._cleanup(e) traceback.print_exc() -- ___ Python tracker <http://bugs.python.org/issue1067702> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1067702] urllib fails with multiple ftp transfers
Stefan Schwarzer added the comment: Hi Senthil, I don't yet understand what was going on before it resulted in the traceback. I also don't understand _why_ the patch fixes _this_ bug. (That's not to say it doesn't, but I think it's not obvious either. :-) ) Were you able to reproduce the exception with my attached script before you did the change? Here in the hotel I have a much faster internet connection than I had yesterday at the sprint (where lots of people shared the uplink), and now I can't reproduce the exception after running the test script three times, even _without_ having your change applied. -- ___ Python tracker <http://bugs.python.org/issue1067702> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21333] Document recommended exception for objects that shouldn't be pickled
New submission from Stefan Schwarzer: I recently was confused whether to raise a `PicklingError` or `TypeError` in `__getstate__` if objects of my class can't and shouldn't be pickled. [1] Terry Reedy advised I should use `TypeError`. [2] I wonder if the `pickle` module documention should explicitly recommend using `TypeError` if a class wants to say that its objects can't be pickled. What do you think? [1] https://mail.python.org/pipermail/python-list/2014-April/670987.html [2] https://mail.python.org/pipermail/python-list/2014-April/671002.html -- assignee: docs@python components: Documentation messages: 217054 nosy: docs@python, sschwarzer priority: normal severity: normal status: open title: Document recommended exception for objects that shouldn't be pickled type: enhancement versions: Python 3.5 ___ Python tracker <http://bugs.python.org/issue21333> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com