Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: 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; 'syntax': 0.04; 'mrab': 0.05; 'json': 0.07; 'parser': 0.07; 'strict': 0.07; 'string': 0.09; 'decodes': 0.09; 'fashion.': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'spec': 0.09; 'subject:using': 0.09; 'subset': 0.09; 'python': 0.11; 'jan': 0.12; 'escapes': 0.16; 'former,': 0.16; 'json:': 0.16; 'latter,': 0.16; 'pairs': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'skip:j 30': 0.16; 'surrogate': 0.16; 'sat,': 0.16; 'wrote:': 0.18; 'properly': 0.19; "python's": 0.19; 'value.': 0.19; '>>>': 0.22; 'header:User-Agent:1': 0.23; 'bytes': 0.24; 'unicode': 0.24; 'question': 0.24; "i've": 0.25; 'define': 0.26; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'am,': 0.29; 'characters': 0.30; 'primarily': 0.30; "skip:' 10": 0.31; 'sep': 0.31; 'probably': 0.32; 'compatible': 0.32; 'another': 0.32; 'guess': 0.33; 'but': 0.35; 'skip:j 20': 0.36; 'being': 0.38; 'represent': 0.38; 'to:addr:python-list': 0.38; 'issue': 0.38; 'pm,': 0.38; 'does': 0.39; 'received:71': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'most': 0.60; 'new': 0.61; 'simply': 0.61; 'guarantee': 0.63; 'therefore,': 0.64; 'more': 0.64; 'guaranteed': 0.75; "'true'": 0.84; '(ie': 0.84; "it'd": 0.84; 'received:fios.verizon.net': 0.84; 'hand,': 0.93 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: Storing instances using jsonpickle Date: Sat, 06 Sep 2014 14:27:45 -0400 References: <46e782a5-b087-4f95-aadb-26e233bf5419@googlegroups.com> <5407A69B.3030707@mrabarnett.plus.com> <5409ED0B.2030902@mrabarnett.plus.com> <540B3701.5020007@mrabarnett.plus.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: pool-71-175-90-87.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 In-Reply-To: <540B3701.5020007@mrabarnett.plus.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 51 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1410028089 news.xs4all.nl 2935 [2001:888:2000:d::a6]:40770 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:77662 On 9/6/2014 12:32 PM, MRAB wrote: > On 2014-09-06 01:20, Chris Angelico wrote: >> On Sat, Sep 6, 2014 at 3:04 AM, MRAB >> wrote: >>> JSON has 'true' and 'false'. >>> >>> Python has 'True' and 'False'. >>> >>> Therefore, if you want it to be able to drop it into Python's REPL, >>> it won't be compatible with JSON anyway! (Well, not unless you >>> define 'true' and 'false' first.) >> >> This is a new spec, so I guess the question is whether it's >> primarily "JSON with some more features" or "subset of Python syntax >> in the same way that JSON is a subset of JS". If it's the former, >> then yes, it'd use "true" and "false", and you'd have to define them; >> but if the latter, the spec would simply use "True" and "False". But >> being able to guarantee that JSON decodes correctly with this parser >> (ie make it a guaranteed superset of JSON) would be of value. >> > I've found that there's another issue with JSON: string escapes include > \u, but not \U: > > >>> json.dumps('\U0010FFFF') > '"\\udbff\\udfff"' > > Yes, it uses surrogate escapes! Because Javascript does. It does roundtrip properly (3.4.1) >>> json.loads('"\\udbff\\udfff"') '\U0010ffff' > Also: > > >>> json.dumps('\uDBFF\uDFFF') > '"\\udbff\\udfff"' > > so it won't round-trip. > > On the other hand, you probably won't be using pairs of surrogate > escapes in Python 3.3. The surrogate codepoints are not unicode characters and as I remember from reading the standard, would not be allowed in a strict utf-32 implementation. 3.3+ uses them, when requested, to represent undecodable bytes in a non-standard fashion. and for other occasional practical reasons that most of us can ignore. -- Terry Jan Reedy