Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #4211
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!weretis.net!feeder1.news.weretis.net!news.solani.org!.POSTED!not-for-mail |
|---|---|
| From | Peter Otten <__peter__@web.de> |
| Newsgroups | comp.lang.python |
| Subject | Re: unpickling derived LogRecord in python 2.7 from python2.6 |
| Followup-To | comp.lang.python |
| Date | Thu, 28 Apr 2011 09:22:06 +0200 |
| Organization | None |
| Lines | 36 |
| Message-ID | <ipb4hd$9rf$1@solani.org> (permalink) |
| References | <dddb61de-6964-41c4-9f14-d9d1d5fdb2b7@cu4g2000vbb.googlegroups.com> <ip9gtg$s9p$1@solani.org> <bb7009bd-e93d-470e-9077-9fa12046dd7f@q20g2000vbx.googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset="ISO-8859-1" |
| Content-Transfer-Encoding | 7Bit |
| X-Trace | solani.org 1303975277 10095 eJwFwQEBACAIA7BKKvxgHC/SP4IbjJM3nKCj0czx9qHO6ldUPea9AhJjIcytSyOlHSp5zA8uCxGY (28 Apr 2011 07:21:17 GMT) |
| X-Complaints-To | abuse@news.solani.org |
| NNTP-Posting-Date | Thu, 28 Apr 2011 07:21:17 +0000 (UTC) |
| X-User-ID | eJwNy7EBwDAIA7CXQgyGnkNT8/8JzahBARpPOoMeEyNdR5fVYjvzxGpoyeXmoCMJ42eFo6qeG7Bz7GHud7/6ATHYFNk= |
| Cancel-Lock | sha1:ZhUr7FKKG47hLYVdDcunG7osKO4= |
| X-NNTP-Posting-Host | eJwNwoERACEIA7CVrBSUcVDL/iP8X+IWiLsYHvT+rRSPbtayps/5FIqukT3NsfoYinlQG/J8Zpt2vcgWKCGBB6ZuR2SND9R+GdA= |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:4211 |
Followups directed to: comp.lang.python
Show key headers only | View raw
Vinay Sajip wrote:
> On Apr 27, 5:41 pm, Peter Otten <__pete...@web.de> wrote:
>
>> The Problem is that as of Python 2.7logging.LogRecord has become a
>> newstyle class which is pickled/unpickled differently. I don't know if
>> there is an official way to do the conversion, but here's what I've
>> hacked up. The script can read pickles written with 2.6 in 2.7, but not
>> the other way round.
>> [code snipped]
>
> I don't know about "official", but another way of doing this is to
> pickle just the LogRecord's __dict__ and send that over the wire. The
> logging package contains a function makeLogRecord(d) where d is a
> dict.
You are right, my approach is too complicated and only needed when the OP
cannot modify the sending script -- which is unlikely.
> This is the approach used by the examples in the library documentation
> which pickle events for sending across a network:
>
> http://docs.python.org/howto/logging-cookbook.html#sending-and-receiving-
logging-events-across-a-network
>
> The built-in SocketHandler pickles the LogRecord's __dict__ rather
> than the LogRecord itself, precisely because of the improved
> interoperability over pickling the instance directly.
As a minimal change ensuring that the logging.LogRecord subclass used by the
OP is a newstyle class in 2.6 with
class LogRecord(logging.LogRecord, object):
#...
should work, too.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar
unpickling derived LogRecord in python 2.7 from python2.6 "ivdneut@gmail.com" <ivdneut@gmail.com> - 2011-04-27 06:56 -0700
Re: unpickling derived LogRecord in python 2.7 from python2.6 Peter Otten <__peter__@web.de> - 2011-04-27 18:41 +0200
Re: unpickling derived LogRecord in python 2.7 from python2.6 Vinay Sajip <vinay_sajip@yahoo.co.uk> - 2011-04-27 13:39 -0700
Re: unpickling derived LogRecord in python 2.7 from python2.6 Peter Otten <__peter__@web.de> - 2011-04-28 09:22 +0200
Re: unpickling derived LogRecord in python 2.7 from python2.6 "ivdneut@gmail.com" <ivdneut@gmail.com> - 2011-04-29 01:36 -0700
csiph-web