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


Groups > comp.lang.python > #50127

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

From Peter Otten <__peter__@web.de>
Subject Re: UnpicklingError: NEWOBJ class argument isn't a type object
Date 2013-07-08 09:45 +0200
Organization None
References <18dd6d34-5afa-4324-bd2f-f5561413b156@googlegroups.com>
Newsgroups comp.lang.python
Message-ID <mailman.4367.1373269568.3114.python-list@python.org> (permalink)

Show all headers | View raw


skunkwerk wrote:

> 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.  If it pickles okay, why
> should it not be able to unpickle?  Any ideas?

A simple way to provoke the error is to rebind the name referring to the 
class of the pickled object:

>>> import cPickle
>>> class A(object): pass
... 
>>> p = cPickle.dumps(A(), -1)
>>> cPickle.loads(p)
<__main__.A object at 0x7fce7bb58c50>
>>> A = 42
>>> cPickle.loads(p)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
cPickle.UnpicklingError: NEWOBJ class argument isn't a type object

You may be doing something to that effect.

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