Skip to content

gh-122170: Fix interpreter exiting due to ValueError from os.stat for too long filename on Windows - #122175

Closed
devdanzin wants to merge 3 commits into
python:mainfrom
devdanzin:fix_valueerror_updatecache
Closed

gh-122170: Fix interpreter exiting due to ValueError from os.stat for too long filename on Windows#122175
devdanzin wants to merge 3 commits into
python:mainfrom
devdanzin:fix_valueerror_updatecache

Conversation

@devdanzin

@devdanzindevdanzin commented Jul 23, 2024

Copy link
Copy Markdown
Member

This PR fixes the interpreter exiting on Windows in 3.13.0b4 and main due to ValueError: stat: path too long for Windows being raised by os.stat() in updatecache() in linecache.py when trying to print a traceback with a too long filename.

@picnixzpicnixz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

checkcache is may also be subject to the same issue (it calls os.stat).

You can pick what I wrote here: 405a921

Comment threadLib/linecache.py
try:
stat = os.stat(fullname)
except OSError:
except (OSError, ValueError):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one should not be suppressed on Unix platforms.


@unittest.skipUnless(support.MS_WINDOWS, "Test only relevant in Windows.")
def test_filename_too_long(self):
self.assertEqual(linecache.updatecache("s" * 999999), [])

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also check checkcache (which I forgot on my branch).

@devdanzin

Copy link
Copy Markdown
MemberAuthor

Closing due to @picnixz's version being more complete and polished, thanks!

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@devdanzin@picnixz