Daniel Sahlberg wrote on Sun, Mar 07, 2021 at 19:34:15 +0100:
> I'm attaching v4 where I blatantly stole Danielsh's script to read the hash
> file
> (
> http://mail-archives.apache.org/mod_mbox/subversion-dev/202102.mbox/%3c20210226173525.GA24828@tarpaulin.shahaf.local2%3e
> )

> +++ contrib/client-side/store-plaintext-password.py   (working copy)
> @@ -0,0 +1,184 @@
> +def _read_one_datum(fd, letter):
> +    """\
> +    Read a 'K <length>\\n<key>\\n' or 'V <length>\\n<value>\\n' block from
> +    an svn_hash_write2()-format FD.
> +
> +    LETTER identifies the first letter, as a bytes object.
> +    """
> +    assert letter in {b'K', b'V'}
> +    
> +    # Read the letter and the space
> +    if fd.read(1) != letter or fd.read(1) != b' ':
> +        raise ...

This line simply raises a TypeError that's unrelated to the
business-logic-level problem.  Make it more user-friendly?

I know I wrote that line, but I meant it as a placeholder.  (Compare
r1869139.)

> +    if line[-1:] != b'\n':

Aside: the colon here isn't redundant, as it would be if «line» were
a str:

    >>> type(b'foo'[-1])
    <class 'int'>
    >>> type(b'foo'[-1:])
    <class 'bytes'>

    >>> type('foo'[-1])
    <class 'str'>
    >>> type('foo'[-1:])
    <class 'str'>

Cheers,

Daniel

Reply via email to