Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unexisting con.json file: misreport the exists, and fail writing #109458

Closed
yantaozhao opened this issue Sep 15, 2023 · 6 comments
Closed

unexisting con.json file: misreport the exists, and fail writing #109458

yantaozhao opened this issue Sep 15, 2023 · 6 comments
Labels
type-bug An unexpected behavior, bug, or error

Comments

@yantaozhao
Copy link

yantaozhao commented Sep 15, 2023

Bug report

Bug description:

For name 'con.json', (indeed the suffix doesn't matter. for all matching pattern of con.* like con.txt, con.qwert, etc):

  • Python will always return True when run exists() check on name 'con.json', even though file not exists actually!
  • Writing content to the 'con.json' file will fail, and content is redirected to console.

image

CPython versions tested on:

3.9, 3.10, 3.11 ,release by conda

Operating systems tested on:

Windows 10

@yantaozhao yantaozhao added the type-bug An unexpected behavior, bug, or error label Sep 15, 2023
@yantaozhao yantaozhao changed the title misreport the exists of unexisting con.json file unexisting con.json file: misreport the exists, and fail writing Sep 15, 2023
@SouSingh
Copy link

hello @yantaozhao con.json I tried to run it on my device it says it doesn't exist
Screenshot (105)

@yantaozhao
Copy link
Author

yantaozhao commented Sep 15, 2023

hello @yantaozhao con.json I tried to run it on my device it says it doesn't exist Screenshot (105)

Hi @SouSingh , thanks for your work.

From the snapshot, it looks like your python release is from python.org, is it? And what's the system, Windown10 or 11?

@SouSingh
Copy link

Hi @yantaozhao I using Python 3.10.2 and the Device is Windows 11

@yantaozhao
Copy link
Author

it seems that the bug exists on Windows10

@aisk
Copy link
Member

aisk commented Sep 18, 2023

I can't reproduce the issue on Windows 11 with con.json, but with the filename con I've got your problem. However, con is a reserved name in Windows, even if it have any prefixes. The MS's document said:

Do not use the following reserved names for the name of a file:

CON, PRN, AUX, NUL, COM0, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9, LPT0, LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, and LPT9. Also avoid these names followed immediately by an extension; for example, NUL.txt and NUL.tar.gz are both equivalent to NUL. For more information, see Namespaces.

I doubt this is not a Python related issue but a Windows issue, and in any case, I think you should not use the reserved file name on Windows.

@yantaozhao
Copy link
Author

I can't reproduce the issue on Windows 11 with con.json, but with the filename con I've got your problem. However, con is a reserved name in Windows, even if it have any prefixes. The MS's document said:

Do not use the following reserved names for the name of a file:
CON, PRN, AUX, NUL, COM0, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9, LPT0, LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, and LPT9. Also avoid these names followed immediately by an extension; for example, NUL.txt and NUL.tar.gz are both equivalent to NUL. For more information, see Namespaces.

I doubt this is not a Python related issue but a Windows issue, and in any case, I think you should not use the reserved file name on Windows.

correct answer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

3 participants