Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #71568
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.stack.nl!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.002 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; '(python': 0.07; "subject:' ": 0.07; 'string': 0.09; 'bytes.': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'resp': 0.09; 'expects': 0.16; 'ftplib': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'skip:` 40': 0.16; 'subject:object': 0.16; 'subject:python3': 0.16; 'typeerror:': 0.16; 'import': 0.22; 'header:User-Agent:1': 0.23; 'error': 0.23; 'skip:" 30': 0.26; 'header:X-Complaints-To:1': 0.27; 'host': 0.29; 'code': 0.31; 'writes:': 0.31; 'file': 0.32; 'run': 0.32; '(most': 0.33; 'could': 0.34; 'problem': 0.35; "can't": 0.35; 'something': 0.35; 'convert': 0.35; 'doing': 0.36; 'shows': 0.36; 'message- id:@gmail.com': 0.38; 'to:addr:python-list': 0.38; 'recent': 0.39; 'use.': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'subject:Can': 0.60; 'user,': 0.69; 'pardon': 0.84; 'received:89': 0.85 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Akira Li <4kir4.1i@gmail.com> |
| Subject | Re: python3; ftplib: TypeError: Can't convert 'bytes' object to str implicitly |
| Date | Wed, 14 May 2014 20:24:11 +0400 |
| References | <53735242.2010406@rece.vub.ac.be> |
| Mime-Version | 1.0 |
| Content-Type | text/plain |
| X-Gmane-NNTP-Posting-Host | 89.169.229.68 |
| User-Agent | Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) |
| Cancel-Lock | sha1:QZ13Ipz7Wxl51/0qA90LaqlB/Vo= |
| 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.10013.1400084668.18130.python-list@python.org> (permalink) |
| Lines | 37 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1400084668 news.xs4all.nl 2911 [2001:888:2000:d::a6]:41193 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:71568 |
Show key headers only | View raw
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.
--
akira
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: python3; ftplib: TypeError: Can't convert 'bytes' object to str implicitly Akira Li <4kir4.1i@gmail.com> - 2014-05-14 20:24 +0400
csiph-web