Deutsch English Français Italiano |
<mailman.75.1709941192.3452.python-list@python.org> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!fu-berlin.de!uni-berlin.de!not-for-mail From: Grant Edwards <grant.b.edwards@gmail.com> Newsgroups: comp.lang.python Subject: Re: pathlib.Path.is_file vs os.path.isfile difference Date: Fri, 8 Mar 2024 18:39:51 -0500 (EST) Lines: 31 Message-ID: <mailman.75.1709941192.3452.python-list@python.org> References: =?utf-8?q?=3CDB9PR10MB6689728A4E7F95E99F80B9F283272=40DB9PR10MB6?= =?utf-8?q?689=2EEURPRD10=2EPROD=2EOUTLOOK=2ECOM=3E?= <f2d7a7bc-af39-408d-9614-13d32f8cf0b4@tompassin.net> <4Ts2hR1hWnznTq9@mail.python.org> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Trace: news.uni-berlin.de QCAaGOdFBW882jkqj6jbXgTeTPSwpJ0Fph1u9qoB5tZQ== Cancel-Lock: sha1:LOD9ztSAuAu856MGqP3Ftx4+50Y= sha256:Axyg8YMQCr/kInLr8zo6c4SniQJnbWqs+A9uv++jT5A= Return-Path: <grant.b.edwards@gmail.com> X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org Authentication-Results: mail.python.org; dkim=none reason="no signature"; dkim-adsp=none (unprotected policy); dkim-atps=neutral X-Spam-Status: OK 0.012 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'linux,': 0.07; 'underlying': 0.07; 'linux': 0.09; '"real"': 0.16; '3.8.': 0.16; 'another.': 0.16; 'exceeded': 0.16; 'filenames': 0.16; 'filesystem': 0.16; 'filesystems': 0.16; 'from:addr:grant.b.edwards': 0.16; 'from:name:grant edwards': 0.16; 'legacy': 0.16; 'limits.': 0.16; 'subject:skip:o 10': 0.16; 'subject:skip:p 20': 0.16; 'windows.': 0.16; 'wrote:': 0.16; 'python': 0.16; 'libraries': 0.19; 'to:addr:python-list': 0.20; 'ran': 0.22; 'url:wiki': 0.23; 'behavior': 0.26; 'header:User- Agent:1': 0.30; 'python-list': 0.32; 'there': 0.33; 'path': 0.33; 'from:addr:gmail.com': 0.35; 'errors': 0.36; 'posts': 0.36; 'file': 0.38; 'lower': 0.62; 'true': 0.63; 'back': 0.67; 'message- id:invalid': 0.68; 'url:wikipedia': 0.70; 'vary': 0.76; 'returned': 0.81; 'points': 0.84; '(such': 0.84; 'pointing': 0.84; 'remotely': 0.91 User-Agent: slrn/1.0.3 (Linux) X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.39 Precedence: list List-Id: General discussion list for the Python programming language <python-list.python.org> List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> List-Archive: <https://mail.python.org/pipermail/python-list/> List-Post: <mailto:python-list@python.org> List-Help: <mailto:python-list-request@python.org?subject=help> List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> X-Mailman-Original-Message-ID: <4Ts2hR1hWnznTq9@mail.python.org> X-Mailman-Original-References: =?utf-8?q?=3CDB9PR10MB6689728A4E7F95E99F80B9F283272=40DB9PR10MB6?= =?utf-8?q?689=2EEURPRD10=2EPROD=2EOUTLOOK=2ECOM=3E?= <f2d7a7bc-af39-408d-9614-13d32f8cf0b4@tompassin.net> Bytes: 4269 On 2024-03-08, Thomas Passin via Python-list <python-list@python.org> wrote: > >> Hi, I tested this with Python 3.8. Good to know that this was fixed! > > We just learned a few posts back that it might be specific to Linux; I > ran it on Windows. On Linux, the limit is imposed by the filesystem. Most of the "real" filesystems on Linux have a 255 character limit, a few support 256, and some of the legacy filesystems have lower limits. Reiser4 is the only one that's even remotely common which supports more than 256 -- according to https://en.wikipedia.org/wiki/Comparison_of_file_systems#Limits it supports filenames up to 3976 bytes long. NB: The behavior when the limit is exceeded might also vary from one filesystem to another. In any case, the pathlib docs for is_file() are explicit: any errors from the underlying OS and libraries will be propogated. There is nothing to fix. https://docs.python.org/3/library/pathlib.html#pathlib.Path.is_file Path.is_file() Return True if the path points to a regular file (or a symbolic link pointing to a regular file), False if it points to another kind of file. False is also returned if the path doesn’t exist or is a broken symlink; other errors (such as permission errors) are propagated.