Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

I am not an Economist. I am an honest man! -- Paul McCracken


devel / comp.lang.python / Re: pathlib.Path.is_file vs os.path.isfile difference

SubjectAuthor
o Re: pathlib.Path.is_file vs os.path.isfile differenceGrant Edwards

1
Re: pathlib.Path.is_file vs os.path.isfile difference

<mailman.68.1709925701.3452.python-list@python.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=29622&group=comp.lang.python#29622

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: grant.b.edwards@gmail.com (Grant Edwards)
Newsgroups: comp.lang.python
Subject: Re: pathlib.Path.is_file vs os.path.isfile difference
Date: Fri, 8 Mar 2024 14:21:39 -0500 (EST)
Lines: 33
Message-ID: <mailman.68.1709925701.3452.python-list@python.org>
References: 689.EURPRD10.PROD.OUTLOOK.COM>
<33cad416-6f2d-4e1e-9c86-227e30e220fd@tompassin.net>
<4TrwyW50knznVDr@mail.python.org>
X-Trace: news.uni-berlin.de azwjs7gZIQdahme7N0UjzgUX5Z7jhHV7VDo3JBKdH1tQ==
Cancel-Lock: sha1:nhAQnX//S5HIi6H8BVTDiwdEKtU= sha256:bn383XWKgJroB8mtT7pgMvKaMq+9lIEil/sSk25gwqA=
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.000
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'this:': 0.03; 'traceback':
0.04; '(most': 0.05; 'last):': 0.05; 'python.': 0.08; 'linux':
0.09; 'resemble': 0.09; 'import': 0.15; 'false.': 0.16;
'from:addr:grant.b.edwards': 0.16; 'from:name:grant edwards':
0.16; 'possible?': 0.16; 'subject:skip:o 10': 0.16;
'subject:skip:p 20': 0.16; 'wrote:': 0.16; 'python': 0.16; 'feb':
0.17; 'pm,': 0.19; 'to:addr:python-list': 0.20; 'returns': 0.22;
'version': 0.23; 'stuff': 0.25; 'old': 0.27; '>>>': 0.28; 'header
:User-Agent:1': 0.30; '"",': 0.32; 'python-list': 0.32; "i'm":
0.33; 'running': 0.34; 'from:addr:gmail.com': 0.35; 'file': 0.38;
'try': 0.40; 'skip:o 10': 0.61; 'message-id:invalid': 0.68;
'skip:f 30': 0.71; 'discovered': 0.80; 'replacing': 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: <4TrwyW50knznVDr@mail.python.org>
X-Mailman-Original-References: 689.EURPRD10.PROD.OUTLOOK.COM>
<33cad416-6f2d-4e1e-9c86-227e30e220fd@tompassin.net>
 by: Grant Edwards - Fri, 8 Mar 2024 19:21 UTC

On 2024-03-08, Thomas Passin via Python-list <python-list@python.org> wrote:
> On 3/8/2024 1:03 PM, Albert-Jan Roskam via Python-list wrote:
>> Hi,
>> I was replacing some os.path stuff with Pathlib and I discovered this:
>> Path(256 * "x").is_file() # OSError
>> os.path.isfile(256 * "x") # bool
>> Is this intended? Does pathlib try to resemble os.path as closely as
>> possible?
>
> You must have an very old version of Python. I'm running 3.12.2 and it
> returns False.

It throws OSError with Python 3.11.8 on Linux.

$ python
Python 3.11.8 (main, Feb 23 2024, 16:11:29) [GCC 13.2.1 20240113] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pathlib
>>> pathlib.Path(256 * "x").is_file()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.11/pathlib.py", line 1267, in is_file
return S_ISREG(self.stat().st_mode)
^^^^^^^^^^^
File "/usr/lib/python3.11/pathlib.py", line 1013, in stat
return os.stat(self, follow_symlinks=follow_symlinks)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
OSError: [Errno 36] File name too long: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
>>>
>>> import os
>>> os.path.isfile(256 * "x")
False

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor