Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!cs.uu.nl!news.stack.nl!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: 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; 'mrab': 0.05; 'paths': 0.07; 'python3': 0.07; "'')": 0.09; 'bytes,': 0.09; 'filename': 0.09; 'filenames': 0.09; 'instances.': 0.09; 'received:151': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'strings.': 0.09; 'python': 0.11; 'bytearray': 0.16; 'emanuele': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'typeerror:': 0.16; "skip:' 30": 0.19; '>>>': 0.22; 'header:User- Agent:1': 0.23; 'error': 0.23; 'bytes': 0.24; 'unicode': 0.24; 'header:X-Complaints-To:1': 0.27; 'function': 0.29; 'skip:( 20': 0.30; '"",': 0.31; 'skip:7 10': 0.31; 'writes:': 0.31; 'file': 0.32; 'compatible': 0.32; 'open': 0.33; 'linux': 0.33; '(most': 0.33; 'subject:from': 0.34; 'subject: (': 0.35; 'should': 0.36; 'example,': 0.37; 'list': 0.37; 'expected': 0.38; 'to:addr:python- list': 0.38; 'that,': 0.38; 'recent': 0.39; 'to:addr:python.org': 0.39; 'skip:p 20': 0.39; 'received:org': 0.40; 'che': 0.60; 'more': 0.64; '8bit%:100': 0.72; 'quando': 0.84; '2013,': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Lele Gaifax Subject: Re: Changing filenames from Greeklish => Greek (subprocess complain) Date: Thu, 06 Jun 2013 22:25:15 +0200 Organization: Nautilus Entertainments References: <2c425f2b-99de-4453-964e-c585f2043f71@googlegroups.com> <306a22ea-fbf7-4097-af31-121a999957d6@googlegroups.com> <9c482ba0-23ac-4e66-a0e1-a18be9fd82d8@googlegroup> <06a19483-65df-4fcd-9430-b45a01c9dbab@googlegroups.com> <51aed313$0$11118$c3e8da3@news.astraweb.com> <4c19b71d-4de5-41ad-b6ae-fb133a6c331e@googlegroups.com> <2be143c4-77c6-4c84-ba1c-46b02bd503ff@googlegroups.com> <1465c96b-c33e-4d5b-894e-b184c031a185@googlegroups.com> <808b7897-8ed4-4e0e-8976-4a22ae7f24cd@googlegroups.com> <332812d7-71b3-4bbb-a846-09827a6df65d@googlegroups.com> <152c78f5-b777-44e2-a83d-a23ecf2f84a3@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Gmane-NNTP-Posting-Host: 151.62.123.251 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) Cancel-Lock: sha1:vO1BiW/qwiBq2PimC8PpPIcO5TU= X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 32 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1370550312 news.xs4all.nl 15985 [2001:888:2000:d::a6]:46184 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:47270 Νικόλαος Κούρας writes: > Now the error afetr fixithg that transformed to: > > [Thu Jun 06 22:13:49 2013] [error] [client 79.103.41.173] filename = fullpath.replace( '/home/nikos/public_html/data/apps/', '' ) > [Thu Jun 06 22:13:49 2013] [error] [client 79.103.41.173] TypeError: expected bytes, bytearray or buffer compatible object > > MRAB has told me that i need to open those paths and filenames as bytestreams and not as unicode strings. Yes, that way the function will return a list of bytes instances. Knowing that, consider the following example, that should ring a bell: $ python3 Python 3.3.2 (v3.3.2:d047928ae3f6, May 16 2013, 09:59:04) [GCC 4.7.2] on linux Type "help", "copyright", "credits" or "license" for more information. >>> path = b"some/path" >>> path.replace('some', '') Traceback (most recent call last): File "", line 1, in TypeError: expected bytes, bytearray or buffer compatible object >>> path.replace(b'some', b'') b'/path' >>> ciao, lele. -- nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia. lele@metapensiero.it | -- Fortunato Depero, 1929.