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-144087: Add support for unicode MINUS SIGN in `int`, `float` and `complex` by johnslavik · Pull Request #144095 · python/cpython

Conversation

@johnslavik

@johnslavik johnslavik commented Jan 21, 2026 •
edited by bedevere-app Bot
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

I don't see a different approach to solving this that is equally or more optimal in terms of trade-offs. If there's any alternative approach that I've missed, please let me know.

  • Issue: Consider having int() support MINUS SIGN #144087

Sorry, something went wrong.

Uh oh!

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

jaraco reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@johnslavik
Add support for unicode MINUS SIGN in int, float and complex
8951088
@bedevere-app bedevere-app Bot mentioned this pull request Jan 21, 2026
Consider having int() support MINUS SIGN #144087
Open
@jaraco

jaraco commented Jan 24, 2026

Copy link
Copy Markdown
Member

LGTM. Needs tests and blurb. Maybe consider making the assignment a constant instead of a comment, though I don't feel strongly about it.

johnslavik reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

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

@johnslavik

johnslavik commented Jan 24, 2026 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member Author

LGTM. Needs tests and blurb.

Yep! Work in progress.

Thanks for chiming in :)

All reactions

Sorry, something went wrong.

Uh oh!

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

@skirpichev

skirpichev commented Jan 24, 2026

Copy link
Copy Markdown
Member

This also needs documentation. I would guess, it will take major part of the PR.

johnslavik reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

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

@picnixz

picnixz commented Jan 28, 2026

Copy link
Copy Markdown
Member

I don't see a different approach to solving this that is equally or more optimal in terms of trade-offs

How about only checking for the first non whitespace character? signs should not appear in the middle of a number unless they are in the e/E/p suffix I guess?

All reactions

Sorry, something went wrong.

Uh oh!

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

@skirpichev

skirpichev commented Jan 28, 2026

Copy link
Copy Markdown
Member

How about only checking for the first non whitespace character?

Hardly this optimizes something.

unless they are in the e/E/p suffix I guess?

Yes. _PyUnicode_TransformDecimalAndSpaceToASCII() used for floats and complexes (which gives another case of "sign in the middle") too.

picnixz reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

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

johnslavik added 22 commits February 14, 2026 00:39
@johnslavik
Add some test coverage
d3f7c80
Some tests are failing!
@johnslavik
Fix test
3fe1b82
@johnslavik
Add news entry
973e191
@johnslavik
Add C API test coverage (only test_long_fromunicodeobject)
2695c06
- `CAPIFloatTest.test_fromstring` doesn't test for minus signs
- I can't find `complex` C API tests
@johnslavik
Use :func: in news entry for better display
cf0324a
@johnslavik
Update int docs
3855919
@johnslavik
Update float docs
ae6cd6c
@johnslavik
Update complex docs
4a78b3a
@johnslavik
Simplify complex complex docs
f233ebd
@johnslavik
Fix formatting
03d24b2
@johnslavik
Update float syntax snippet
5ce17c9
@johnslavik
Update stdtypes reference
b4b9574
@johnslavik
Clarify complex docs
ff013f5
@johnslavik
Slightly changed "syntax" used in float production list
ca6eca0
@johnslavik
Fix alternative used in complex docs, I think it was incorrect
26dadc5
@johnslavik
Parenthesize consistently
6391d27
I think that reads better
@johnslavik
Parenthesize consistently vol. 2
f7c3fa7
@johnslavik
Empty commit to try to skip incremental lint
0d519f4
@johnslavik
Test NaNs properly
6c5994a
@johnslavik
Fix trailing whitespace (was confused)
0e7110c
@johnslavik
Parenthesize in news entry too
199a879
@johnslavik
Use .. versionchanged:: next
a9874e7
@johnslavik
johnslavik marked this pull request as ready for review February 21, 2026 10:46
@johnslavik

johnslavik commented Feb 21, 2026

Copy link
Copy Markdown
Member Author

This seems like something we could add to the "What's New" log. I'll do that.

All reactions

Sorry, something went wrong.

Uh oh!

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

@johnslavik
Add a *What's New* entry
53c7e97
@johnslavik
johnslavik requested a review from AA-Turner as a code owner February 21, 2026 12:25
johnslavik added 2 commits February 21, 2026 13:26
@johnslavik
Merge branch 'main' to fix conflicts
d349618
@johnslavik
Make versionchanged entry for float more fitting
8b4d9b1
@johnslavik
johnslavik requested a review from encukou February 25, 2026 11:17
@johnslavik
Add more tests
4df638d
@johnslavik
johnslavik requested review from picnixz and skirpichev March 2, 2026 00:01
@johnslavik

johnslavik commented Mar 2, 2026 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member Author

@picnixz, @skirpichev, I tagged you for reviews because I thought you may be interested now that it is ready :-)

I'm particularly unsure about whether I missed or added unnecessary tests, and whether the documentation changes are good.

All reactions

Sorry, something went wrong.

Uh oh!

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

@johnslavik
johnslavik requested a review from serhiy-storchaka March 2, 2026 00:03
johnslavik
johnslavik commented Mar 2, 2026
View reviewed changes
Comment thread Lib/test/test_int.py Resolved

Uh oh!

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

skirpichev
skirpichev approved these changes Mar 2, 2026
View reviewed changes

@skirpichev skirpichev 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, with minor nitpicks.

Maybe you can do docs more compact. See suggestions as an example.

Alternatively, omit just "(ASCII plus sign)" clarifications. There shouldn't be much confusion. Visual difference for '-' and '−' is less apparent.

Sorry, something went wrong.

Uh oh!

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

johnslavik and ambv reacted with rocket emoji
All reactions
  • 🚀 2 reactions
Comment thread Doc/library/functions.rst Resolved

Uh oh!

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

Comment thread Doc/library/functions.rst Resolved

Uh oh!

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

@bedevere-app bedevere-app Bot added awaiting core review and removed awaiting review labels Mar 2, 2026
encukou
encukou reviewed Mar 2, 2026
View reviewed changes
Comment thread Doc/library/functions.rst Resolved

Uh oh!

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

@johnslavik @encukou
Correct the grammar reference
f3dccd0
Co-authored-by: Petr Viktorin <[email protected]>
skirpichev
skirpichev reviewed Mar 2, 2026
View reviewed changes
Comment thread Doc/library/functions.rst Resolved

Uh oh!

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

@johnslavik @skirpichev
Keep character in grammar reference
9353f09
Co-authored-by: Sergey B Kirpichev <[email protected]>
@johnslavik
johnslavik requested a review from rhettinger March 12, 2026 14:20
@ambv @skirpichev
Adjust docs to not say "ASCII"
3c2e361
Co-authored-by: Sergey B Kirpichev <[email protected]>
skirpichev
skirpichev reviewed Mar 12, 2026
View reviewed changes

@skirpichev skirpichev 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.

Note also, that we have a separate parsing from string code in the fromhex() class method.

I don't see good reasons to reject new sign character here, if we are going to support in the float constructor.

Sorry, something went wrong.

Uh oh!

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

johnslavik reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
Comment thread Doc/library/functions.rst Resolved

Uh oh!

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

Comment thread Doc/library/functions.rst Resolved

Uh oh!

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

Comment thread Doc/library/functions.rst Resolved

Uh oh!

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

Comment thread Doc/library/stdtypes.rst Resolved

Uh oh!

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

Comment thread Doc/library/functions.rst Resolved

Uh oh!

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

Comment thread Lib/test/test_float.py
def test_float(self):
self.assertEqual(float(3.14), 3.14)
self.assertEqual(float(314), 314.0)
self.assertEqual(float(" 3.14 "), 3.14)

@skirpichev skirpichev Mar 12, 2026

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.

I think you can add here also tests for parsing floats in scientific notation, with exponent.

Sorry, something went wrong.

Uh oh!

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

johnslavik reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

@johnslavik johnslavik Mar 13, 2026

Copy link
Copy Markdown
Member Author

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.

Thanks, I'll address this on the weekend.

Sorry, something went wrong.

Uh oh!

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

All reactions
@johnslavik @skirpichev
Remove more mentions of other signs being ASCII from docs
301eb4b
Co-authored-by: Sergey B Kirpichev <[email protected]>
@johnslavik

johnslavik commented Mar 24, 2026

Copy link
Copy Markdown
Member Author

Please do not merge this. I need to collect more feedback on the idea.

All reactions

Sorry, something went wrong.

Uh oh!

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

@johnslavik johnslavik added the DO-NOT-MERGE label Mar 24, 2026
@github-actions

github-actions Bot commented May 5, 2026

Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

All reactions

Sorry, something went wrong.

Uh oh!

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

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label May 5, 2026
@johnslavik

johnslavik commented Jul 20, 2026

Copy link
Copy Markdown
Member Author

I'm not sure it is worth it. Feel free to pick this up if you want!

encukou reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

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

@johnslavik johnslavik closed this Jul 20, 2026
@johnslavik
johnslavik deleted the feat-handle-minus-sign branch July 21, 2026 01:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@encukou encukou encukou left review comments
@skirpichev skirpichev skirpichev approved these changes
@AA-Turner AA-Turner Awaiting requested review from AA-Turner AA-Turner is a code owner
@picnixz picnixz Awaiting requested review from picnixz
@serhiy-storchaka serhiy-storchaka Awaiting requested review from serhiy-storchaka
@rhettinger rhettinger Awaiting requested review from rhettinger

Uh oh!

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

Assignees

No one assigned

Labels

awaiting core review DO-NOT-MERGE stale Stale PR or inactive for long period of time.

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.

6 participants

@johnslavik @jaraco @skirpichev @picnixz @encukou @ambv
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.