GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-140544: fix build for including `pycore_pystate.h` when `HAVE_THREAD_LOCAL` is not defined by kumaraditya303 · Pull Request #140623 · python/cpython

Conversation

@kumaraditya303

@kumaraditya303 kumaraditya303 commented Oct 26, 2025 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor
  • Issue: Store current interpreter as a thread local variable #140544

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@kumaraditya303
fix build for mypyc
c82449d
@bedevere-app bedevere-app Bot mentioned this pull request Oct 26, 2025
Store current interpreter as a thread local variable #140544
Closed
@kumaraditya303 kumaraditya303 mentioned this pull request Oct 26, 2025
gh-140544: store pointer to interpreter state as a thread local for fast access #140573
Merged
@kumaraditya303

kumaraditya303 commented Oct 26, 2025

Copy link
Copy Markdown
Contributor Author

cc @cdce8p

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@kumaraditya303 kumaraditya303 added the skip news label Oct 26, 2025
cdce8p
cdce8p approved these changes Oct 26, 2025
View reviewed changes

@cdce8p cdce8p left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

This fixes the issue. Thanks @kumaraditya303!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-app bedevere-app Bot added the awaiting core review label Oct 26, 2025
@kumaraditya303
kumaraditya303 marked this pull request as ready for review October 26, 2025 14:05
@kumaraditya303
kumaraditya303 requested review from ZeroIntensity and ericsnowcurrently as code owners October 26, 2025 14:05
ZeroIntensity
ZeroIntensity reviewed Oct 26, 2025
View reviewed changes
Comment thread Include/internal/pycore_pystate.h Resolved

Uh oh!

There was an error while loading. Please reload this page.

@kumaraditya303
remove HAVE_THREAD_LOCAL
34a2688
@kumaraditya303
kumaraditya303 requested a review from ZeroIntensity October 27, 2025 19:41
ZeroIntensity
ZeroIntensity approved these changes Oct 27, 2025
View reviewed changes

@ZeroIntensity ZeroIntensity left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

LGTM, thanks.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting core review labels Oct 27, 2025
@kumaraditya303
kumaraditya303 merged commit f5394c2 into python:main Oct 27, 2025
4 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the awaiting merge label Oct 27, 2025
@kumaraditya303
kumaraditya303 deleted the tls branch October 27, 2025 20:10
@cdce8p

cdce8p commented Oct 27, 2025

Copy link
Copy Markdown
Contributor

Unfortunately it seems the last change broke it again.

/.../cpython/Include/internal/pycore_pystate.h:93:8: error: unknown type name '_Py_thread_local'
extern _Py_thread_local PyThreadState *_Py_tss_tstate;

/.../cpython/Include/internal/pycore_pystate.h:93:38: error: expected ';' after top level declarator
extern _Py_thread_local PyThreadState *_Py_tss_tstate;
                                     ^
                                     ;

It looks like _Py_thread_local only works for defined(HAVE_THREAD_LOCAL). So 34a2688 should probably be reverted.

cpython/Include/pyport.h

Lines 516 to 528 in f5394c2

# define HAVE_THREAD_LOCAL 1
# ifdef thread_local
# define _Py_thread_local thread_local
# elif __STDC_VERSION__ >= 201112L && !defined(__STDC_NO_THREADS__)
# define _Py_thread_local _Thread_local
# elif defined(_MSC_VER) /* AKA NT_THREADS */
# define _Py_thread_local __declspec(thread)
# elif defined(__GNUC__) /* includes clang */
# define _Py_thread_local __thread
# else
// fall back to the PyThread_tss_*() API, or ignore.
# undef HAVE_THREAD_LOCAL
# endif

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ZeroIntensity

ZeroIntensity commented Oct 27, 2025

Copy link
Copy Markdown
Member

No, this is all just HAVE_THREAD_LOCAL being messy. We should remove that all throughout the codebase and assume that thread locals are always available. mypyc will get some speedups from using the thread local directly. I'll put up a PR.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@cdce8p

cdce8p commented Oct 27, 2025

Copy link
Copy Markdown
Contributor

Sounds good. Happy to test it, just let me know.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@cdce8p cdce8p mentioned this pull request Oct 27, 2025
gh-140544: Always assume that thread locals are available #140690
Merged
StanFromIreland pushed a commit to StanFromIreland/cpython that referenced this pull request Dec 6, 2025
@kumaraditya303 @StanFromIreland
pythongh-140544: fix build for including pycore_pystate.h when `HAV…
6aad774
…E_THREAD_LOCAL` is not defined (python#140623)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@ZeroIntensity ZeroIntensity ZeroIntensity approved these changes
@ericsnowcurrently ericsnowcurrently Awaiting requested review from ericsnowcurrently ericsnowcurrently is a code owner
+1 more reviewer
@cdce8p cdce8p cdce8p approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

skip news

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@kumaraditya303 @cdce8p @ZeroIntensity
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.