Package: libpython3.7-stdlib
Version: 3.7.3-2+deb10u1
Severity: minor
File: /usr/lib/python3.7/pathlib.py

I expected pathlib glob() to behave like sh glob.
I shot myself in the foot because of an unexpected difference.
Please document this difference to protect other sysadmins.

    bash5$ ls
    bash5$ touch f
    bash5$ mkdir d

    bash5$ ls -d *
    d  f
    bash5$ ls -d */
    d/

    bash5$ dash -c 'ls -d *'
    d  f
    bash5$ dash -c 'ls -d */'
    d/

    bash5$ python3.7 -c 'import pathlib; 
print(list(pathlib.Path(".").glob("*")))'
    [PosixPath('d'), PosixPath('f')]
    bash5$ python3.7 -c 'import pathlib; 
print(list(pathlib.Path(".").glob("*/")))'
    [PosixPath('d'), PosixPath('f')]

I'm thinking something simple like this in Doc/library/pathlib.rst:

    Note that (unlike sh and bash) a pattern with a trailing slash will still 
match regular files.

PS: I guess this also applies to Doc/library/glob.rst as well?
I avoid glob.glob() because it had no way to separate the "static" part from 
the "pattern" part.
e.g. glob.glob(args.path + '/*.deb') is not safe.  pathlib fixes that, yay!


-- System Information:
Debian Release: 10.3
  APT prefers stable
  APT policy: (990, 'stable'), (500, 'stable-updates'), (500, 
'proposed-updates'), (500, 'unstable'), (1, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 5.4.0-0.bpo.2-amd64 (SMP w/2 CPU cores)
Kernel taint flags: TAINT_OOT_MODULE, TAINT_UNSIGNED_MODULE
Locale: LANG=en_AU.UTF-8, LC_CTYPE=en_AU.UTF-8 (charmap=UTF-8), 
LANGUAGE=en_AU.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages libpython3.7-stdlib:amd64 depends on:
ii  libbz2-1.0            1.0.6-9.2~deb10u1
ii  libc6                 2.29-9
ii  libdb5.3              5.3.28+dfsg1-0.5
ii  libffi6               3.2.1-9
ii  liblzma5              5.2.4-1
ii  libmpdec2             2.4.2-2
ii  libncursesw6          6.1+20181013-2+deb10u2
ii  libpython3.7-minimal  3.7.3-2+deb10u1
ii  libreadline7          7.0-5
ii  libsqlite3-0          3.31.1-1
ii  libtinfo6             6.1+20181013-2+deb10u2
ii  libuuid1              2.33.1-0.1
ii  mime-support          3.62

libpython3.7-stdlib:amd64 recommends no packages.

libpython3.7-stdlib:amd64 suggests no packages.

-- no debconf information

Reply via email to