Skip to content

Conversation

yihong0618
Copy link
Contributor

@yihong0618 yihong0618 commented Aug 23, 2025

for mac if environ is valid and it will retrigger all of it

so I checked the code base in repr the os is from init
so make it in__init__ is better and can avoid

and that is not enough, we also need fix it the same way in

_can_colorize theme

cc @pablogsal

in my env it fixed the issue, and I wonder it maybe a litter faster

Signed-off-by: yihong0618 <zouzou0208@gmail.com>
@yihong0618
Copy link
Contributor Author

the news is the same so maybe we can ignore it?

Signed-off-by: yihong0618 <zouzou0208@gmail.com>
@picnixz picnixz changed the title [3.13] gh-128636: Fix crash in PyREPL when os.environ is overwritten with an invalid value for mac(GH-128653) gh-128636: Fix crash in PyREPL when os.environ is overwritten with an invalid value for mac Aug 23, 2025
@yihong0618
Copy link
Contributor Author

Why only 3.13?

only up to 3.13 new repr has this issue follow this patch title #129186

@picnixz
Copy link
Member

picnixz commented Aug 23, 2025

the news is the same so maybe we can ignore it?

No, because we have already shipped a few releases since then, so we need a fresh one.

@yihong0618
Copy link
Contributor Author

the news is the same so maybe we can ignore it?

No, because we have already shipped a few releases since then, so we need a fresh one.

learned that, thank you very much

@picnixz
Copy link
Member

picnixz commented Aug 23, 2025

only up to 3.13 new repr has this issue follow this patch title #129186

That's the backport. All PRs must first be done against main and we backport them when needed. We only use [3.x] when the fix is specific to the version.

@yihong0618
Copy link
Contributor Author

only up to 3.13 new repr has this issue follow this patch title #129186

That's the backport. All PRs must first be done against main and we backport them when needed. We only use [3.x] when the fix is specific to the version.

copy that, sorry for my wrong understand at first

Signed-off-by: yihong0618 <zouzou0208@gmail.com>
Copy link
Member

@picnixz picnixz left a comment

Choose a reason for hiding this comment

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

I'm not entirely sure but caching THEME() seems to go against the comment in THEME().

Signed-off-by: yihong0618 <zouzou0208@gmail.com>
@yihong0618
Copy link
Contributor Author

yihong0618 commented Aug 23, 2025

I'm not entirely sure but caching THEME() seems to go against the comment in THEME().

addressed thank you

and add tests

Signed-off-by: yihong0618 <zouzou0208@gmail.com>
Signed-off-by: yihong0618 <zouzou0208@gmail.com>
@yihong0618 yihong0618 requested a review from picnixz August 24, 2025 08:12
@bedevere-app
Copy link

bedevere-app bot commented Aug 24, 2025

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

Signed-off-by: yihong0618 <zouzou0208@gmail.com>
@@ -303,3 +303,15 @@ def test_getheightwidth_with_invalid_environ(self, _os_write):
self.assertIsInstance(console.getheightwidth(), tuple)
os.environ = []
self.assertIsInstance(console.getheightwidth(), tuple)

def test_mac_with_invalid_environ(self, _os_write):
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
def test_mac_with_invalid_environ(self, _os_write):
def test_is_mac_with_invalid_environ(self, _os_write):

@picnixz
Copy link
Member

picnixz commented Aug 24, 2025

The change with is_mac affects restore(). Please test this (if it's possible). Otherwise, the test might not be necessary. More generally, we should test the functions or methods that may call os.environ.* during the interactive session.

@yihong0618
Copy link
Contributor Author

The change with is_mac affects restore(). Please test this (if it's possible). Otherwise, the test might not be necessary. More generally, we should test the functions or methods that may call os.environ.* during the interactive session.

copy will try this way but seems not simple for testing let me try

Signed-off-by: yihong0618 <zouzou0208@gmail.com>
@yihong0618
Copy link
Contributor Author

The change with is_mac affects restore(). Please test this (if it's possible). Otherwise, the test might not be necessary. More generally, we should test the functions or methods that may call os.environ.* during the interactive session.

@picnixz try a better one, learned something from this, thank you again

without this patch(on main)

image

with this patch

image

Signed-off-by: yihong0618 <zouzou0208@gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
@yihong0618 yihong0618 requested a review from hugovk as a code owner August 24, 2025 13:49
@yihong0618
Copy link
Contributor Author

yihong0618 commented Aug 24, 2025

addressed and add co-author thanks for the kindly help

and FYI, the new way is better but not so simple.


tested about the theme change, the code is right, but already_colorize maybe can change to a better name

Signed-off-by: yihong0618 <zouzou0208@gmail.com>
Signed-off-by: yihong0618 <zouzou0208@gmail.com>
@yihong0618 yihong0618 requested a review from picnixz August 25, 2025 00:32
@ambv
Copy link
Contributor

ambv commented Aug 25, 2025

While I appreciate the willingness to fix this, I don't really like an argument to can_colorize that amounts to "please return True". It's bad form.

@yihong0618
Copy link
Contributor Author

agreed but the two can_color is already there one is function another is a boolean, Can we refactor theme? Or there's other way to fix this

@picnixz picnixz removed their request for review August 25, 2025 12:47
@picnixz picnixz dismissed their stale review August 25, 2025 12:48

I'm letting Łukasz shepherd this as I'm not a REPL expert

Signed-off-by: yihong0618 <zouzou0208@gmail.com>
@yihong0618
Copy link
Contributor Author

fixed thank you for the help

@yihong0618 yihong0618 requested a review from ambv August 25, 2025 13:49
Signed-off-by: yihong0618 <zouzou0208@gmail.com>
@yihong0618 yihong0618 requested a review from hugovk August 25, 2025 20:55
Sign up for free to 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.

4 participants