Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #24471

Re: Frustrating circular bytes issue

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!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.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'output': 0.05; 'string.': 0.05; 'executes': 0.09; 'lines:': 0.09; 'def': 0.11; 'read.': 0.13; 'file.read()': 0.16; 'from:addr:behnel.de': 0.16; 'from:addr:stefan_ml': 0.16; 'from:name:stefan behnel': 0.16; 'read()': 0.16; 'received:80.91': 0.16; 'received:80.91.229': 0.16; 'received:gmane.org': 0.16; 'received:list': 0.16; 'stepping': 0.16; 'subject:issue': 0.16; 'true:': 0.16; '(the': 0.17; 'file,': 0.18; 'stefan': 0.18; 'creates': 0.20; 'byte': 0.22; 'bytes': 0.22; 'string,': 0.22; 'tells': 0.22; 'unicode': 0.22; 'yield': 0.22; 'header:In-Reply-To:1': 0.23; 'print': 0.25; 'header:User-Agent:1': 0.26; 'statement': 0.27; 'header:X -Complaints-To:1': 0.28; 'object.': 0.29; 'regular': 0.31; 'skip:_ 10': 0.31; 'lines': 0.32; 'received:84': 0.32; 'running': 0.34; "can't": 0.34; 'problem.': 0.35; 'to:addr:python-list': 0.35; 'skip:d 20': 0.36; 'something': 0.36; 'test': 0.36; 'subject:: ': 0.37; 'to:addr:python.org': 0.39; 'received:org': 0.39; 'header:Received:5': 0.39; 'expression': 0.72; 'received:arcor- ip.net': 0.84; 'received:pools.arcor-ip.net': 0.84
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Stefan Behnel <stefan_ml@behnel.de>
Subject Re: Frustrating circular bytes issue
Date Tue, 26 Jun 2012 19:22:24 +0200
References <CAFB6qZuUYE5Mp_Td-=LiMagP4UM65WEPLLJ5t33__Sa_bOq2hg@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host dslb-084-056-033-191.pools.arcor-ip.net
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:12.0) Gecko/20120430 Thunderbird/12.0.1
In-Reply-To <CAFB6qZuUYE5Mp_Td-=LiMagP4UM65WEPLLJ5t33__Sa_bOq2hg@mail.gmail.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1521.1340731362.4697.python-list@python.org> (permalink)
Lines 34
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1340731362 news.xs4all.nl 6980 [2001:888:2000:d::a6]:58156
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:24471

Show key headers only | View raw


J, 26.06.2012 18:30:
> def _reader(self, file, size=4096, delimiter=r"\n{2,}"):
>         buffer_old = ""
>         while True:
>             buffer_new = file.read()
>             print(type(buffer_new))
>             if not buffer_new:
>                 break
>             lines = re.split(delimiter, buffer_old + buffer_new)

"delimiter" is a Unicode string, which makes the regular expression a
Unicode regex that can't work on a byte string.


>             buffer_old = lines.pop(-1)
> 
>             for line in lines:
>                 yield line
> 
>         yield buffer_old
> 
> 
> (the print statement is something I put in to verify the problem.
> 
> So stepping through this, when _reader executes, it executes read() on
> the opened filehandle.  Originally, it read in 4096 byte chunks, I
> removed that to test a theory.  It creates buffer_new with the output
> of the read.
> 
> Running type() on buffer_new tells me that it's a bytes object.

Stefan

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Frustrating circular bytes issue Stefan Behnel <stefan_ml@behnel.de> - 2012-06-26 19:22 +0200

csiph-web