Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #71572
| Path | csiph.com!usenet.pasdenom.info!gegeweb.org!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python@mrabarnett.plus.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'argument': 0.05; 'say,': 0.05; '(python': 0.07; 'failing': 0.07; 'paths': 0.07; 'python3': 0.07; "subject:' ": 0.07; 'string': 0.09; 'bytes.': 0.09; 'converted': 0.09; 'resp': 0.09; 'assume': 0.14; 'anyway': 0.14; '-999': 0.16; 'encoding.': 0.16; 'expects': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'ftplib': 0.16; 'message- id:@mrabarnett.plus.com': 0.16; 'received:192.168.1.4': 0.16; 'received:84.93': 0.16; 'received:84.93.230': 0.16; 'skip:` 40': 0.16; 'subject: \n ': 0.16; 'subject:object': 0.16; 'subject:python3': 0.16; 'timeout': 0.16; 'typeerror:': 0.16; 'wrote:': 0.18; '>>>': 0.22; 'code,': 0.22; 'import': 0.22; 'header:User-Agent:1': 0.23; 'error': 0.23; 'bytes': 0.24; 'skip:" 30': 0.26; 'header:In-Reply-To:1': 0.27; 'host': 0.29; 'generally': 0.29; 'network.': 0.30; 'especially': 0.30; 'code': 0.31; 'writes:': 0.31; 'allows': 0.31; 'file': 0.32; 'run': 0.32; 'another': 0.32; '(most': 0.33; 'could': 0.34; 'problem': 0.35; "can't": 0.35; 'something': 0.35; 'convert': 0.35; 'received:84': 0.35; 'but': 0.35; 'doing': 0.36; 'shows': 0.36; 'to:addr:python- list': 0.38; 'rather': 0.38; 'recent': 0.39; 'expect': 0.39; 'use.': 0.39; 'sure': 0.39; 'to:addr:python.org': 0.39; 'subject:Can': 0.60; 'default': 0.69; 'user,': 0.69; 'none!': 0.84; 'pardon': 0.84; 'studying': 0.84 |
| X-CM-Score | 0.00 |
| X-CNFS-Analysis | v=2.1 cv=CL+kXHbD c=1 sm=1 tr=0 a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=0Bzu9jTXAAAA:8 a=1oDRhzKAKukA:10 a=jNGeECpvY1YA:10 a=ihvODaAuJD4A:10 a=IkcTkHD0fZMA:10 a=EBOSESyhAAAA:8 a=RjDBoGWeGH4NffpLYewA:9 a=QEXdDO2ut3YA:10 |
| X-AUTH | mrabarnett:2500 |
| Date | Wed, 14 May 2014 19:38:15 +0100 |
| From | MRAB <python@mrabarnett.plus.com> |
| User-Agent | Mozilla/5.0 (Windows NT 6.3; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 |
| MIME-Version | 1.0 |
| To | python-list@python.org |
| Subject | Re: python3; ftplib: TypeError: Can't convert 'bytes' object to str implicitly |
| References | <53735242.2010406@rece.vub.ac.be> <87r43wfhw4.fsf@gmail.com> <5373B0A9.1090508@rece.vub.ac.be> |
| In-Reply-To | <5373B0A9.1090508@rece.vub.ac.be> |
| Content-Type | text/plain; charset=UTF-8; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.10017.1400092703.18130.python-list@python.org> (permalink) |
| Lines | 47 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1400092703 news.xs4all.nl 2975 [2001:888:2000:d::a6]:37995 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:71572 |
Show key headers only | View raw
On 2014-05-14 19:06, Antoon Pardon wrote:
> op 14-05-14 18:24, Akira Li schreef:
>> Antoon Pardon <antoon.pardon@rece.vub.ac.be> writes:
>>
>>> This is the code I run (python 3.3)
>>>
>>> host = ...
>>> user = ...
>>> passwd = ...
>>>
>>> from ftplib import FTP
>>>
>>> ftp = FTP(host, user, passwd)
>>> ftp.mkd(b'NewDir')
>>> ftp.rmd(b'NewDir')
>>>
>>> This is the traceback
>>>
>>> Traceback (most recent call last):
>>> File "ftp-problem", line 9, in <module>
>>> ftp.mkd(b'NewDir')
>>> File "/usr/lib/python3.3/ftplib.py", line 612, in mkd
>>> resp = self.voidcmd('MKD ' + dirname)
>>> TypeError: Can't convert 'bytes' object to str implicitly
>>>
>>> The problem is that I do something like this in a backup program.
>>> I don't know the locales that other people use. So I manipulate
>>> all file and directory names as bytes.
>>>
>>> Am I doing something wrong?
>>
>> The error message shows that ftplib expects a string here, not bytes.
>> You could use `ftp.mkd(some_bytes.decode(ftp.encoding))` as a
>> workaround.
>
> Sure but what I like to know: Can this be considered a failing of
> ftplib. Since python3 generally allows paths to be strings as
> well as bytes can't we expect the same of ftplib?
>
> Especially as I assume that path will be converted to bytes anyway
> in order to send it over the network.
>
From studying the code, I see that it uses the Latin-1 encoding.
On another note, I find it interesting that the default for the timeout
argument uses the 'magic' value -999 rather than, say, None!
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: python3; ftplib: TypeError: Can't convert 'bytes' object to str implicitly MRAB <python@mrabarnett.plus.com> - 2014-05-14 19:38 +0100
csiph-web