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


Groups > comp.lang.python > #50124

Re: UnpicklingError: NEWOBJ class argument isn't a type object

Path csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!newsfeed.eweka.nl!feeder3.eweka.nl!81.171.88.15.MISMATCH!eweka.nl!lightspeed.eweka.nl!194.134.4.91.MISMATCH!news2.euro.net!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.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'argument': 0.05; 'detect': 0.07; 'error:': 0.07; 'string': 0.09; 'executed': 0.09; 'parameter': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'python': 0.11; 'django': 0.11; 'achievement.': 0.16; 'bytecode': 0.16; 'expects': 0.16; 'files)': 0.16; 'means.': 0.16; 'operation.': 0.16; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-ipconnect.de': 0.16; 'sees': 0.16; 'sockets': 0.16; 'subject:class': 0.16; 'subject:object': 0.16; 'subject:type': 0.16; 'later': 0.20; 'header:User-Agent:1': 0.23; 'error': 0.23; '(such': 0.24; 'gets': 0.27; 'header:X-Complaints- To:1': 0.27; "i'm": 0.30; 'code': 0.31; 'extract': 0.31; 'motivation': 0.31; 'pickle': 0.31; 'writes:': 0.31; 'class': 0.32; 'probably': 0.32; 'cases': 0.33; 'maybe': 0.34; 'could': 0.34; 'something': 0.35; 'case,': 0.35; 'objects': 0.35; 'but': 0.35; 'charset:us-ascii': 0.36; 'hi,': 0.36; 'should': 0.36; 'effort': 0.37; 'to:addr:python-list': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'skip:u 10': 0.60; 'most': 0.60; 'here:': 0.62; 'received:217': 0.63; 'information': 0.63; 'such': 0.63; 'provide': 0.64; 'special': 0.74; 'abandon': 0.84; 'alongside': 0.84; 'itself?': 0.84; 'partial': 0.84
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From dieter <dieter@handshake.de>
Subject Re: UnpicklingError: NEWOBJ class argument isn't a type object
Date Mon, 08 Jul 2013 08:53:42 +0200
References <18dd6d34-5afa-4324-bd2f-f5561413b156@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
X-Gmane-NNTP-Posting-Host pd9e0a19b.dip0.t-ipconnect.de
User-Agent Gnus/5.1008 (Gnus v5.10.8) XEmacs/21.4.22 (linux)
Cancel-Lock sha1:xJ38ODBjEVW0s2EVfrkA++Ty7BM=
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.4366.1373266438.3114.python-list@python.org> (permalink)
Lines 45
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1373266438 news.xs4all.nl 15911 [2001:888:2000:d::a6]:38480
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:50124

Show key headers only | View raw


skunkwerk <skunkwerk@gmail.com> writes:

> Hi,
>   I'm using a custom pickler that replaces any un-pickleable objects (such as sockets or files) with a string representation of them, based on the code from Shane Hathaway here:
> http://stackoverflow.com/questions/4080688/python-pickling-a-dict-with-some-unpicklable-items
>
> It works most of the time, but when I try to unpickle a Django HttpResponse, I get the following error:
> UnpicklingError: NEWOBJ class argument isn't a type object
>
> I have no clue what the error actually means.

The pickling protocol uses a form of bytecode which is executed
during the unpickling to reconstruct the python objects based
on their state found in the pickle alongside the bytecode.

"NEWOBJ" is executed in response to such a bytecode operation.
It expects to get a type as a parameter but in your case,
it gets something else.


> If it pickles okay, why should it not be able to unpickle?  Any ideas?

It is by principle impossible for the pickler to garantee
that an unpickler will later succeed: the pickler does not know
which classes/types are available for the unpickler.

In your special case, the pickler could probably
detect that unpickling will fail - but when
an aim cannot be achieved completely this may provide
motivation to abandon it as a whole - and not put much effort
into a partial achievement.
I have seen many cases where pickling succeeded but
unpickling failed and in principle the pickler could have
already predicted the failure (under the assumption that
the unpickler sees the same classes/types as the pickler).


If it is important for you to get Django HttpResponses
successfully unpickled then you likely need to guide
their pickling process better.

Maybe (as an alternative), you can extract the relevant information
from the "HttpResponse" and pickle that instead of
the response itself?

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


Thread

UnpicklingError: NEWOBJ class argument isn't a type object skunkwerk <skunkwerk@gmail.com> - 2013-07-07 22:27 -0700
  Re: UnpicklingError: NEWOBJ class argument isn't a type object Chris Angelico <rosuav@gmail.com> - 2013-07-08 15:57 +1000
  Re: UnpicklingError: NEWOBJ class argument isn't a type object dieter <dieter@handshake.de> - 2013-07-08 08:53 +0200
  Re: UnpicklingError: NEWOBJ class argument isn't a type object Peter Otten <__peter__@web.de> - 2013-07-08 09:45 +0200
    Re: UnpicklingError: NEWOBJ class argument isn't a type object skunkwerk <skunkwerk@gmail.com> - 2013-07-08 16:38 -0700
      Re: UnpicklingError: NEWOBJ class argument isn't a type object Peter Otten <__peter__@web.de> - 2013-07-09 09:24 +0200

csiph-web