Path: csiph.com!4.us.feeder.erje.net!feeder.erje.net!2.eu.feeder.erje.net!news.roellig-ltd.de!open-news-network.org!weretis.net!feeder4.news.weretis.net!news.mixmin.net!aioe.org!bofh.it!news.nic.it!robomod From: Chris Lamb Newsgroups: linux.debian.maint.python Subject: Re: TypeError: ord() expected a character, but string of length 3 found (Was: Updated python-uncertainties) Date: Fri, 12 Oct 2018 13:50:01 +0200 Message-ID: References: X-Original-To: Andreas Tille , debian-python@lists.debian.org, David Paleino , Federico Ceratto X-Mailbox-Line: From debian-python-request@lists.debian.org Fri Oct 12 11:43:11 2018 Old-Return-Path: X-Amavis-Spam-Status: No, score=-7.7 tagged_above=-10000 required=5.3 tests=[BAYES_00=-2, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, LDO_WHITELIST=-5, RCVD_IN_DNSWL_LOW=-0.7] autolearn=ham autolearn_force=no X-Policyd-Weight: using cached result; rate:hard: -5 X-Greylist: delayed 626 seconds by postgrey-1.36 at bendel; Fri, 12 Oct 2018 11:42:56 UTC Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=elSEoskUB0h9MMHuHp2tCp7joY1YlIKqmP8LhiKCc oo=; b=jj5TESyvaSVZRcq53x6vj7MNybrS08PGjdKyYmNfrL/FhodVZHMJnXNHs ZYtREN7ebGBHlQVnhWNawBcZGr5VmRKdWC+1nFRWRY/djTGGrmmch2VWCeFOvvSh 17UeRFJOzD1oqlsLl/ijWkoQQtfBMHpQnaqD0IBh6xEr/mb1CpS7KeXdyA65R9FR kampUhks2jKHXUpiDdVCIoA9opLNnFSeeOSiKWgVSFmpMYRjsUKutAhDx410clXU vTLpyMOxlz1Eh9ycb6XjIxKVRH+qErOrbDPq9DBQtWDwD+KX7zcAgL3XLA/m47nj c2GSMOnnId5QNqpeDHwtr8gmKOp6A== X-Me-Sender: X-Me-Proxy: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" X-Mailer: MessagingEngine.com Webmail Interface - ajax-6804a824 X-Mailing-List: archive/latest/16411 List-ID: List-URL: List-Archive: https://lists.debian.org/msgid-search/1539343938.2065153.1539680744.792D0909@webmail.messagingengine.com Approved: robomod@news.nic.it Lines: 76 Organization: linux.* mail to news gateway Sender: robomod@news.nic.it X-Original-Cc: =?utf-8?Q?Picca=20Fr=C3=A9d=C3=A9ric-Emmanuel?= X-Original-Date: Fri, 12 Oct 2018 12:32:18 +0100 X-Original-Message-ID: <1539343938.2065153.1539680744.792D0909@webmail.messagingengine.com> X-Original-References: <20181011110643.hrxkvpfyzj4jjqeb@an3as.eu> <20181012061902.mf7vngqnwvxdge2s@an3as.eu> <20181012111533.4ym6loirbvnr2fnx@an3as.eu> Xref: csiph.com linux.debian.maint.python:10981 Andreas, > > File "/usr/lib/python2.7/dist-packages/uncertainties/core.py", line 9= 46, in > > ord(sup): normal for (normal, sup) in list(TO_SUPERSCRIPT.items())} Please always provide a minimal testcase, otherwise people have to do a lot of work simply to get where you are.. $ cat testcase.py # coding=3Dutf-8 TO_SUPERSCRIPT =3D { 0x2b: '=E2=81=BA', 0x2d: '=E2=81=BB', 0x30: '=E2=81=B0', 0x31: '=C2=B9', 0x32: '=C2=B2', 0x33: '=C2=B3', 0x34: '=E2=81=B4', 0x35: '=E2=81=B5', 0x36: '=E2=81=B6', 0x37: '=E2=81=B7', 0x38: '=E2=81=B8', 0x39: '=E2=81=B9' } #! Python 2.7+ can use a dictionary comprehension instead: FROM_SUPERSCRIPT =3D { ord(sup): normal for (normal, sup) in list(TO_SUPERSCRIPT.items())} $ python2 testcase.py=20=20 Traceback (most recent call last): File "testcase.py", line 18, in ord(sup): normal for (normal, sup) in list(TO_SUPERSCRIPT.items())} File "testcase.py", line 18, in ord(sup): normal for (normal, sup) in list(TO_SUPERSCRIPT.items())} TypeError: ord() expected a character, but string of length 3 found Under Python 2.x, list(TO_SUPERSCRIPT.items()) is: [(43, '\xe2\x81\xba'), (45, '\xe2\x81\xbb'), (48, '\xe2\x81\xb0'), [=E2=80=A6] ] ie. strings with a length of 3 whilst ord() takes a single char. These should therefore be probably defined as: TO_SUPERSCRIPT =3D { 0x2b: u'=E2=81=BA', 0x2d: u'=E2=81=BB', [=E2=80=A6] .. instead, but I haven't tested or confirmed or anythinged that; I'll leave it with you and upstream. I also couldn't help notice: Vcs-Browser: https://salsa.debian.org/debian/python-uncertainties Vcs-Git: https://salsa.debian.org/debian/python-uncertainties.git .. yet: Maintainer: Debian Python Modules Team Regards, --=20 ,''`. : :' : Chris Lamb `. `'` lamby@debian.org / chris-lamb.co.uk `-