Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

ImproveInvalidTZPathWarning warning with a stacklevel #106233

Closed
Assignees
sobolevn
Labels
stdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error
@sobolevn

Description

@sobolevn

Given this code:

# ex.pyimportzoneinfoprint(zoneinfo.TZPATH)

And this command to run it:PYTHONTZPATH=ex.py ./python.exe ex.py

Output will be:

» PYTHONTZPATH=ex.py ./python.exe ex.py/Users/sobolev/Desktop/cpython/Lib/zoneinfo/_tzpath.py:44: InvalidTZPathWarning: Invalid paths specified in PYTHONTZPATH environment variable. Paths should be absolute but found the following relative paths:    ex.py  warnings.warn(()

Settingstacklevel

From1 to5:

/Users/sobolev/Desktop/cpython/Lib/zoneinfo/_tzpath.py:44: InvalidTZPathWarning: Invalid paths specified in PYTHONTZPATH environment variable. Paths should be absolute but found the following relative paths:    ex.py  warnings.warn(
/Users/sobolev/Desktop/cpython/Lib/zoneinfo/_tzpath.py:22: InvalidTZPathWarning: Invalid paths specified in PYTHONTZPATH environment variable. Paths should be absolute but found the following relative paths:    ex.py  base_tzpath = _parse_python_tzpath(env_var)
/Users/sobolev/Desktop/cpython/Lib/zoneinfo/_tzpath.py:176: InvalidTZPathWarning: Invalid paths specified in PYTHONTZPATH environment variable. Paths should be absolute but found the following relative paths:    ex.py  reset_tzpath()
/Users/sobolev/Desktop/cpython/Lib/zoneinfo/__init__.py:10: InvalidTZPathWarning: Invalid paths specified in PYTHONTZPATH environment variable. Paths should be absolute but found the following relative paths:    ex.py  from . import _tzpath
/Users/sobolev/Desktop/cpython/ex.py:1: InvalidTZPathWarning: Invalid paths specified in PYTHONTZPATH environment variable. Paths should be absolute but found the following relative paths:    ex.py  import zoneinfo

Looks like5 is the best in terms of being informative, where this warning comes from.
I will send a PR with the fix.

CC@pganssle

Linked PRs

Metadata

Metadata

Assignees

Labels

stdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp