Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #42997
| Path | csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed2.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; 'dynamically': 0.07; 'linux,': 0.07; 'none,': 0.07; '[],': 0.09; 'false,': 0.09; 'obj': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:files': 0.09; 'subject:module': 0.09; 'url:github': 0.09; 'windows,': 0.09; '{},': 0.09; 'subject:Help': 0.11; 'python': 0.11; 'windows': 0.15; "'rb')": 0.16; 'attaching': 0.16; 'broken.': 0.16; 'received:80.91.229.3': 0.16; 'received:dip.t-dialin.net': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-dialin.net': 0.16; 'reproduce': 0.16; 'wrote:': 0.18; 'library': 0.18; 'working.': 0.19; '>>>': 0.22; 'example': 0.22; 'import': 0.22; 'print': 0.22; 'creating': 0.23; 'header :User-Agent:1': 0.23; 'either.': 0.24; 'script.': 0.24; 'source': 0.25; 'header:X-Complaints-To:1': 0.27; 'mode': 0.30; 'statement': 0.30; 'code': 0.31; "skip:' 10": 0.31; 'file:': 0.31; 'linux.': 0.31; 'object.': 0.31; 'pickle': 0.31; "skip:' 40": 0.31; 'file': 0.32; 'know.': 0.32; 'run': 0.32; 'linux': 0.33; 'actual': 0.34; "i'd": 0.34; 'but': 0.35; 'add': 0.35; 'version': 0.36; 'raising': 0.36; 'hi,': 0.36; 'two': 0.37; 'being': 0.38; 'skip:o 20': 0.38; 'skip:[ 10': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'subject:" ': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'ensure': 0.60; 'read': 0.60; 'skip:c 50': 0.60; 'tell': 0.60; 'hope': 0.61; 'complete': 0.62; 'more': 0.64; 'different': 0.65; 'jul': 0.74; 'happening?': 0.84; 'observed': 0.84; 'otten': 0.84; 'url:master': 0.84; '2013': 0.98 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Peter Otten <__peter__@web.de> |
| Subject | Re: Help: pickle module unable to load "rb" mode files in linux |
| Date | Sun, 07 Apr 2013 14:51:31 +0200 |
| Organization | None |
| References | <CAArdDCqpMq=VNJTfpXY3CR5vRetma9HYO_6DnmLSry_bQ5wSkg@mail.gmail.com> <kjestm$64o$1@ger.gmane.org> <CAArdDCp7Haeu6B_JZizmai8qiUnQ0dhukihNZ+WrJ7aWm=tvTg@mail.gmail.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset="ISO-8859-1" |
| Content-Transfer-Encoding | 7Bit |
| X-Gmane-NNTP-Posting-Host | p5084a0e0.dip.t-dialin.net |
| User-Agent | KNode/4.7.3 |
| 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 | <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.240.1365339024.3114.python-list@python.org> (permalink) |
| Lines | 71 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1365339024 news.xs4all.nl 6910 [2001:888:2000:d::a6]:55289 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:42997 |
Show key headers only | View raw
Surya Kasturi wrote:
> I am attaching the file which has to be read.. please take a look into it.
> The actual source code can be observed at
>
https://github.com/scipy/SciPyCentral/blob/master/scipy_central/rest_comments/views.py#L235
>
>
> when we use "rb" mode in windows, its working. but its not working in
> linux system (particularly CentOS)
>
>
>
> On Tue, Apr 2, 2013 at 8:50 PM, Peter Otten <__peter__@web.de> wrote:
>
>> Surya Kasturi wrote:
>>
>> > Hi, hope you can help me on it..
>> >
>> > with open(pickle_f, 'r') as fhand:
>> > obj = pickle.load(fhand)
>> >
>> >
>> > This works on linux but not in windows until I use "rb" mode while
>> > creating file object. Surprisingly, the "rb" mode is not working on
>> > Linux.. raising EOFError.
>> >
>> > Why is this happening?
>>
>> I don't know.
>>
>> Please give a complete self-contained example that uses "wb" to write the
>> file and "rb" to read it, and that fails on Linux. Don't forget to tell
>> us the version of Python you used to run that script.
I am using Linux, but I cannot reproduce an EOFError with the attached file:
Python 2.7.2+ (default, Jul 20 2012, 22:15:08)
[GCC 4.6.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pickle
>>> with open("index.fpickle", "rb") as f:
... obj = pickle.load(f)
...
>>> obj
{'body': u'<p>yahoo</p>\n', 'prev': None, 'display_toc': False, 'title':
u'<no title>', 'sourcename': 'index.txt', 'customsidebar': None,
'current_page_name': 'index', 'next': None, 'rellinks': [('genindex',
u'General Index', 'I', u'index')], 'meta': {}, 'parents': [], 'toc': u'<ul
class="simple">\n</ul>\n', 'sidebars': None, 'metatags': ''}
As the data has only built-in types it cannot be a library thing either.
Given that the file's location is determined dynamically
[views.py]
call_sphinx_to_compile(settings.SPC['comment_compile_dir'])
pickle_f = ''.join([settings.SPC['comment_compile_dir'], os.sep,
'_build', os.sep, 'pickle', os.sep,
'index.fpickle'])
with open(pickle_f, 'rb') as fhand:
obj = pickle.load(fhand)
I'd add a
print pickle_f
statement just before the with-statement to ensure that you don't have two
different pickle files, one of them being empty or otherwise broken.
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Help: pickle module unable to load "rb" mode files in linux Peter Otten <__peter__@web.de> - 2013-04-07 14:51 +0200
csiph-web