Fredrik Lundh | 1 Dec 2000 07:39

TypeError: foo, bar

just stumbled upon yet another (high-profile) python newbie
confused a "TypeError: read-only character buffer, dictionary"
message.

how about changing "read-only character buffer" to "string
or read-only character buffer", and the "foo, bar" format to
"expected foo, found bar", so we get:

    "TypeError: expected string or read-only character
    buffer, found dictionary"

</F>

Tim Peters | 1 Dec 2000 07:58
Picon

RE: TypeError: foo, bar

[Fredrik Lundh]
> just stumbled upon yet another (high-profile) python newbie
> confused a "TypeError: read-only character buffer, dictionary"
> message.
>
> how about changing "read-only character buffer" to "string
> or read-only character buffer", and the "foo, bar" format to
> "expected foo, found bar", so we get:
> 
>     "TypeError: expected string or read-only character
>     buffer, found dictionary"

+0.  +1 if "found" is changed to "got".

"found"-implies-a-search-ly y'rs  - tim

Thomas Heller | 1 Dec 2000 09:10

Re: PEP 229 and 222

> > Beats me.  I'm not even sure if the Distutils offers a way to compile
> > a static Python binary.  (GPW: well, does it?)
> 
> It's in the CCompiler interface, but hasn't been exposed to the outside
> world.  (IOW, it's mainly a question of desiging the right setup
> script/command line interface: the implementation should be fairly
> straightforward, assuming the existing CCompiler classes do the right
> thing for generating binary executables.)
Distutils currently only supports build_*** commands for
C-libraries and Python extensions.

Shouldn't there also be build commands for shared libraries,
executable programs and static Python binaries?

Thomas

BTW: Distutils-sig seems pretty dead these days...

Ka-Ping Yee | 1 Dec 2000 11:23

Cryptic error messages

An attempt to use sockets for the first time yesterday left a
friend of mine bewildered:

    >>> import socket
    >>> s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    >>> s.connect('localhost:234')
    Traceback (most recent call last):
      File "<stdin>", line 1, in ?
    TypeError: 2-sequence, 13-sequence
    >>> 

"What the heck does '2-sequence, 13-sequence' mean?" he rightfully asked.

I see in getargs.c (line 275) that this type of message is documented:

    /* Convert a tuple argument.
    [...]
       If the argument is invalid:
    [...]
          *msgbuf contains an error message, whose format is:
             "<typename1>, <typename2>", where:
                <typename1> is the name of the expected type, and
                <typename2> is the name of the actual type,
             (so you can surround it by "expected ... found"),
          and msgbuf is returned.
    */

It's clear that the socketmodule is not prepending "expected" and
appending "found", as the author of converttuple intended.

(Continue reading)

Michael Hudson | 1 Dec 2000 12:20
Picon
Picon
Favicon

Re: Cryptic error messages

Ka-Ping Yee <ping <at> lfw.org> writes:

> An attempt to use sockets for the first time yesterday left a
> friend of mine bewildered:
> 
>     >>> import socket
>     >>> s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
>     >>> s.connect('localhost:234')
>     Traceback (most recent call last):
>       File "<stdin>", line 1, in ?
>     TypeError: 2-sequence, 13-sequence
>     >>> 
> 
> "What the heck does '2-sequence, 13-sequence' mean?" he rightfully asked.
> 

I'm not sure about the general case, but in this case you could do
something like:

http://sourceforge.net/patch/?func=detailpatch&patch_id=102599&group_id=5470

Now you get an error message like:

TypeError: getsockaddrarg: AF_INET address must be tuple, not string

Cheers,
M.

--

-- 
  I have gathered a posie of other men's flowers, and nothing but the
(Continue reading)

Guido van Rossum | 1 Dec 2000 14:02
Favicon

Re: TypeError: foo, bar

> just stumbled upon yet another (high-profile) python newbie
> confused a "TypeError: read-only character buffer, dictionary"
> message.
> 
> how about changing "read-only character buffer" to "string
> or read-only character buffer", and the "foo, bar" format to
> "expected foo, found bar", so we get:
> 
>     "TypeError: expected string or read-only character
>     buffer, found dictionary"

The first was easy, and I've done it.  The second one, for some
reason, is hard.  I forget why.  Sorry.

--Guido van Rossum (home page: http://www.python.org/~guido/)

Charles G Waldman | 1 Dec 2000 14:41
X-Face
Favicon

TypeError: foo, bar

Fredrik Lundh writes:

 > how about changing "read-only character buffer" to "string
 > or read-only character buffer", and the "foo, bar" format to
 > "expected foo, found bar", so we get:
 > 
 >     "TypeError: expected string or read-only character
 >     buffer, found dictionary"

+100.  Recently, I've been teaching Python to some beginners and they
find this message absolutely inscrutable.

Also agree with Tim about "found" vs. "got", but this is of secondary
importance.

Moshe Zadka | 1 Dec 2000 15:26
Picon
Picon
Favicon

[OT] Change of Address

I'm sorry to bother you all with this, but from time to time you might
need to reach my by e-mail...
30 days from now, this e-mail address will no longer be valid.
Please use anything <at> zadka.site.co.il to reach me.

Thank you for your time.
--
Moshe Zadka <moshez <at> zadka.site.co.il> -- 95855124
http://advogato.org/person/moshez

Greg Ward | 1 Dec 2000 16:14

Re: PEP 229 and 222

On 01 December 2000, Thomas Heller said:
> Distutils currently only supports build_*** commands for
> C-libraries and Python extensions.
> 
> Shouldn't there also be build commands for shared libraries,
> executable programs and static Python binaries?

Andrew and I talked about this a bit yesterday, and the proposed
interface is as follows:

    python setup.py build_ext --static

will compile all extensions in the current module distribution, but
instead of creating a .so (.pyd) file for each one, will create a new
python binary in build/bin.<plat>.

Issue to be resolved: what to call the new python binary, especially
when installing it (presumably we *don't* want to clobber the stock
binary, but supplement it with (eg.) "foopython").

Note that there is no provision for selectively building some extensions
as shared.  This means that Andrew's Distutil-ization of the standard
library will have to override the build_ext command and have some extra
way to select extensions for shared/static.  Neither of us considered
this a problem.

> BTW: Distutils-sig seems pretty dead these days...

Yeah, that's a combination of me playing on other things and python.net
email being dead for over a week.  I'll cc the sig on this and see if
(Continue reading)

Jeremy Hylton | 1 Dec 2000 20:27
Picon
Favicon

unit testing and Python regression test

There was recently some idle chatter in Guido's living room about
using a unit testing framework (like PyUnit) for the Python regression
test suite.  We're also writing tests for some DC projects, and need
to decide what framework to use.

Does anyone have opinions on test frameworks?  A quick web search
turned up PyUnit (pyunit.sourceforge.net) and a script by Tres Seaver
that allows implements xUnit-style unit tests.  Are there other tools
we should consider?

Is anyone else interested in migrating the current test suite to a new
framework?  I hope the new framework will allow us to improve the test
suite in a number of ways:

    - run an entire test suite to completion instead of stopping on
      the first failure

    - clearer reporting of what went wrong

    - better support for conditional tests, e.g. write a test for
      httplib that only runs if the network is up.  This is tied into
      better error reporting, since the current test suite could only
      report that httplib succeeded or failed.

Jeremy


Gmane