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


Groups > linux.debian.maint.python > #10981

Re: TypeError: ord() expected a character, but string of length 3 found (Was: Updated python-uncertainties)

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 <lamby@debian.org>
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 <wI477-F5-3@gated-at.bofh.it> (permalink)
References <wHH0T-3XO-67@gated-at.bofh.it> <wHYXL-6cv-1@gated-at.bofh.it> <wI3E5-vZ-11@gated-at.bofh.it>
X-Original-To Andreas Tille <andreas@an3as.eu>, debian-python@lists.debian.org, David Paleino <dapal@debian.org>, Federico Ceratto <federico.ceratto@gmail.com>
X-Mailbox-Line From debian-python-request@lists.debian.org Fri Oct 12 11:43:11 2018
Old-Return-Path <lamby@debian.org>
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 <xms:QobAW87yZPKOSZLpSGzkxzl6GLRRT-rwyGOmJMg8Cmy8qjObVL8bNw>
X-Me-Proxy <xmx:QobAW0f0WwvUzOxY0qoi8ZU0nqEbSRE6tkG3psgvqYvDfJTY3fM47g> <xmx:QobAWwraqwC901AVqg6mt28P16HhQ0Z4cSLsEqmCpdqFRAo7O62HmA> <xmx:QobAW9BQs66nuYir7Tr0VpPkxKj5S-YeyuX6o_oHHBJsw7Z9ObnhHw> <xmx:QobAWxdqpNlmQSoJwJ9nBDhuaXttyPDcSj_cg_gcNw92Qv16wjnrzw> <xmx:QobAW1t184ZHLM9YE3sII5kC3Zp-RaVgRiqtVzCQcWdnTap3NjJs5A> <xmx:QobAW5mTp3eMqhKiM-rdiQbUScbCBo10lrkG9ogQJW1WfYK7X2ICeg>
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 <debian-python@lists.debian.org> archive/latest/16411
List-ID <debian-python.lists.debian.org>
List-URL <https://lists.debian.org/debian-python/>
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 Picca Frédéric-Emmanuel <picca@debian.org>
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

Show key headers only | View raw


Andreas,


> >   File "/usr/lib/python2.7/dist-packages/uncertainties/core.py", line 946, in <dictcomp>
> >     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=utf-8
  TO_SUPERSCRIPT = {
      0x2b: '⁺',
      0x2d: '⁻',
      0x30: '⁰',
      0x31: '¹',
      0x32: '²',
      0x33: '³',
      0x34: '⁴',
      0x35: '⁵',
      0x36: '⁶',
      0x37: '⁷',
      0x38: '⁸',
      0x39: '⁹'
      }
  #! Python 2.7+ can use a dictionary comprehension instead:
  FROM_SUPERSCRIPT = {
      ord(sup): normal for (normal, sup) in list(TO_SUPERSCRIPT.items())}

  $ python2 testcase.py  
  Traceback (most recent call last):
    File "testcase.py", line 18, in <module>
      ord(sup): normal for (normal, sup) in list(TO_SUPERSCRIPT.items())}
    File "testcase.py", line 18, in <dictcomp>
      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'),
   […]
  ]

ie. strings with a length of 3 whilst ord() takes a single char. These
should therefore be probably defined as:

  TO_SUPERSCRIPT = {
      0x2b: u'⁺',
      0x2d: u'⁻',
  […]

.. 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 <python-modules-team@lists.alioth.debian.org>


Regards,

-- 
      ,''`.
     : :'  :     Chris Lamb
     `. `'`      lamby@debian.org / chris-lamb.co.uk
       `-

Back to linux.debian.maint.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Re: Updated python-uncertainties Andreas Tille <andreas@an3as.eu> - 2018-10-12 08:20 +0200
  TypeError: ord() expected a character, but string of length 3 found  (Was: Updated python-uncertainties) Andreas Tille <andreas@an3as.eu> - 2018-10-12 13:20 +0200
    Re: TypeError: ord() expected a character,  but string of length 3 found (Was: Updated python-uncertainties) Chris Lamb <lamby@debian.org> - 2018-10-12 13:50 +0200
      Re: TypeError: ord() expected a character, but string of length 3  found (Was: Updated python-uncertainties) Andreas Tille <tille@debian.org> - 2018-10-12 14:50 +0200
        Re: TypeError: ord() expected a character, but string of length 3  found (Was: Updated python-uncertainties) Andreas Tille <tille@debian.org> - 2018-10-12 16:20 +0200
          Re: TypeError: ord() expected a character,  but string of length 3 found (Was: Updated python-uncertainties) Chris Lamb <lamby@debian.org> - 2018-10-12 16:40 +0200
          RE:TypeError: ord() expected a character, but string of length 3  found (Was: Updated python-uncertainties) PICCA Frederic-Emmanuel <frederic-emmanuel.picca@synchrotron-soleil.fr> - 2018-10-12 17:10 +0200
            RE:TypeError: ord() expected a character, but string of length 3  found (Was: Updated python-uncertainties) PICCA Frederic-Emmanuel <frederic-emmanuel.picca@synchrotron-soleil.fr> - 2018-10-12 17:40 +0200
              Re: TypeError: ord() expected a character, but string of length 3  found (Was: Updated python-uncertainties) Piotr Ożarowski <piotr@debian.org> - 2018-10-12 18:20 +0200
                RE:TypeError: ord() expected a character, but string of length 3  found (Was: Updated python-uncertainties) PICCA Frederic-Emmanuel <frederic-emmanuel.picca@synchrotron-soleil.fr> - 2018-10-12 18:40 +0200
                RE:TypeError: ord() expected a character, but string of length 3  found (Was: Updated python-uncertainties) PICCA Frederic-Emmanuel <frederic-emmanuel.picca@synchrotron-soleil.fr> - 2018-10-13 11:10 +0200
                RE:TypeError: ord() expected a character, but string of length 3  found (Was: Updated python-uncertainties) PICCA Frederic-Emmanuel <frederic-emmanuel.picca@synchrotron-soleil.fr> - 2018-10-13 11:50 +0200
                RE:TypeError: ord() expected a character, but string of length 3  found (Was: Updated python-uncertainties) PICCA Frederic-Emmanuel <frederic-emmanuel.picca@synchrotron-soleil.fr> - 2018-10-13 14:00 +0200
                Re: TypeError: ord() expected a character, but string of length 3  found (Was: Updated python-uncertainties) Andreas Tille <andreas@an3as.eu> - 2018-10-15 11:40 +0200
                RE:TypeError: ord() expected a character, but string of length 3  found (Was: Updated python-uncertainties) PICCA Frederic-Emmanuel <frederic-emmanuel.picca@synchrotron-soleil.fr> - 2018-10-15 12:00 +0200
                Re: TypeError: ord() expected a character, but string of length 3  found (Was: Updated python-uncertainties) Karsten Hilbert <Karsten.Hilbert@gmx.net> - 2018-10-15 12:10 +0200
                Re: TypeError: ord() expected a character, but string of length 3  found (Was: Updated python-uncertainties) Andreas Tille <andreas@an3as.eu> - 2018-10-15 13:20 +0200
                RE:TypeError: ord() expected a character, but string of length 3  found (Was: Updated python-uncertainties) PICCA Frederic-Emmanuel <frederic-emmanuel.picca@synchrotron-soleil.fr> - 2018-10-15 14:10 +0200
                RE:TypeError: ord() expected a character, but string of length 3  found (Was: Updated python-uncertainties) PICCA Frederic-Emmanuel <frederic-emmanuel.picca@synchrotron-soleil.fr> - 2018-10-15 21:20 +0200
                Re: TypeError: ord() expected a character,  but string of length 3 found (Was: Updated python-uncertainties) Chris Lamb <lamby@debian.org> - 2018-10-15 22:10 +0200
                RE:TypeError: ord() expected a character, but string of length 3  found (Was: Updated python-uncertainties) PICCA Frederic-Emmanuel <frederic-emmanuel.picca@synchrotron-soleil.fr> - 2018-10-15 21:10 +0200
                Re: TypeError: ord() expected a character, but string of length 3  found (Was: Updated python-uncertainties) Andreas Tille <andreas@an3as.eu> - 2018-10-16 09:10 +0200
                Re: TypeError: ord() expected a character, but string of length 3  found (Was: Updated python-uncertainties) Dmitry Shachnev <mitya57@debian.org> - 2018-10-17 16:40 +0200
                Re: TypeError: ord() expected a character, but string of length 3  found (Was: Updated python-uncertainties) Andreas Tille <tille@debian.org> - 2018-10-17 19:50 +0200

csiph-web