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

gh-127555: Document that sys.tracebacklimit can be set to None#127556

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
srittau wants to merge6 commits intopython:main
base:main
Choose a base branch
Loading
fromsrittau:tracebacklimit-doc

Conversation

srittau
Copy link
Contributor

@srittausrittau commentedDec 3, 2024
edited by github-actionsbot
Loading

@bedevere-appbedevere-appbot added docsDocumentation in the Doc dir skip news labelsDec 3, 2024
@ZeroIntensityZeroIntensity added needs backport to 3.12only security fixes needs backport to 3.13bugs and security fixes labelsDec 3, 2024
Copy link
Member

@ZeroIntensityZeroIntensity left a comment

Choose a reason for hiding this comment

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

I don't think this is the intended behavior. The source is here:

if (limitv&&PyLong_Check(limitv)) {

Setting toany type that isn't an integer will result in this happening. To me, seeingsys.tracebacklimit = None looks like "no limit," not "default limit." I'm not sure we should document that.

@srittau
Copy link
ContributorAuthor

Considering that this behavior is explicitly called out in the NEWS entries for 3.6.4 and 3.7.0a3, it sounds deliberate to me.

@ZeroIntensity
Copy link
Member

If we really do wantNone as a special case, we should emit a warning (or possibly raise an exception) for other types. cc@serhiy-storchaka, who wrote the code.

@serhiy-storchaka
Copy link
Member

Please remember the issue wnd the changelog corresponding to that NEWS entry. I do no remember such issue.

I most likely did not invent that behavior, but simply fixed crashes or error handling in corner cases, or/and synchronized the C and the Python implementations. L9k also at the Python code.

@srittau
Copy link
ContributorAuthor

For reference, here is the original issue:#76130 and the PR:#4289. The PR introduced an explicit test forNone:

check(None,traceback)

@serhiy-storchaka
Copy link
Member

Thanks,@srittau. What does the corresponding Python code do? There should be a code usingtracebacklimit in thetraceback module.

@srittau
Copy link
ContributorAuthor

The only instance is this:

limit=getattr(sys,'tracebacklimit',None)

So,Noneis supported, but that might be incidental. The following code basically skips over any frame limiting iflimit isNone, although I'm not sure what that means exactly, as I'm not particular familiar with the traceback module.

@rruuaanng
Copy link
Contributor

The only instance is this:

limit=getattr(sys,'tracebacklimit',None)

So,Noneis supported, but that might be incidental. The following code basically skips over any frame limiting iflimit isNone, although I'm not sure what that means exactly, as I'm not particular familiar with the traceback module.

Can supportNone, and this is necessary, this's not a incidental. After thegetattr(sys, 'tracebacklimit', None) statement is executed, it always returns None, because the tracebacklimit attribute does not exist and it never appears insys module.

Running Release|x64 interpreter...Python 3.14.0a0 (heads/master-dirty:ff4e499, Nov 16 2024, 20:59:33) [MSC v.1941 64 bit (AMD64)] on win32Type "help", "copyright", "credits" or "license" for more information.>>> import sys>>> sys.tracebacklimitTraceback (most recent call last):  File "<python-input-1>", line 1, in <module>    sys.tracebacklimitAttributeError: module 'sys' has no attribute 'tracebacklimit'

(It's fix appears in another PR of mine.)

Copy link
Member

@ZeroIntensityZeroIntensity left a comment

Choose a reason for hiding this comment

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

Yeah, I manually checked locally, and settingtracebacklimit toNone does the same for the Python implementation (it still might be incidental, but it doesn't matter anyway). Anyways, intentional or not, this seems to be the proper behavior for both implementations of traceback, so this LGTM.

@iritkatriel
Copy link
Member

Thanks,@srittau. What does the corresponding Python code do? There should be a code usingtracebacklimit in thetraceback module.

@serhiy-storchaka we no longer have C and Python implementations of the traceback formatting logic. It's all in Python now.

@iritkatriel
Copy link
Member

Are there tests for setting it toNone?

@serhiy-storchaka
Copy link
Member

There is still C code in_PyTraceBack_Print().

There are tests for settingsys.tracebacklimit to None in test_sys. But the Python implementation in thetraceback module is not tested for this.

And it seems to me that settingsys.tracebacklimit to None has different effect on C and Python implementations.

@ZeroIntensity
Copy link
Member

I think it's vice-versa: we're testing the Python implementation, not the C-level_PyTraceBack_Print. Again though, they seem to do the same thing forNone, at least if my test was extensive enough.

@hugovkhugovk removed the needs backport to 3.12only security fixes labelApr 10, 2025
@serhiy-storchakaserhiy-storchaka added the needs backport to 3.14bugs and security fixes labelMay 8, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@serhiy-storchakaserhiy-storchakaserhiy-storchaka left review comments

@ZeroIntensityZeroIntensityZeroIntensity approved these changes

Assignees
No one assigned
Labels
awaiting core reviewdocsDocumentation in the Doc dirneeds backport to 3.13bugs and security fixesneeds backport to 3.14bugs and security fixesskip news
Projects
Status: Todo
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

6 participants
@srittau@ZeroIntensity@serhiy-storchaka@rruuaanng@iritkatriel@hugovk

[8]ページ先頭

©2009-2025 Movatter.jp