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 — bpo-39939: Add str.removeprefix and str.removesuffix by sweeneyde · Pull Request #18939 · python/cpython

Conversation

@sweeneyde

@sweeneyde sweeneyde commented Mar 11, 2020 •
edited by bedevere-bot
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

https://bugs.python.org/issue39939

Sorry, something went wrong.

Uh oh!

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

LodiAleardo, ibrahimsha23, janosh, srinivasreddy, and olehermanse reacted with thumbs up emoji pradyunsg, ryepesg, daniil-konovalenko, selurvedu, Akuli, guillaume-jcb, ThatXliner, jas-ho, orn688, ibrahimsha23, and 8 more reacted with hooray emoji
All reactions
  • 👍 5 reactions
  • 🎉 18 reactions
sweeneyde added 5 commits March 9, 2020 23:27
@sweeneyde
Add cutprefix and cutsuffix methods to str, bytes, and bytearray.
0addc43
@sweeneyde
pep 7: lining up argumenets
3adb9fa
@sweeneyde
Revert "pep 7: lining up argumenets"
a7a1bc8
This reverts commit 3adb9fa.
@sweeneyde
pep 7: line up arguemnts
fe18644
@sweeneyde
pep 7: line up arguemnts
ff8e3c6
@the-knights-who-say-ni the-knights-who-say-ni added the CLA signed label Mar 11, 2020
@bedevere-bot bedevere-bot added the awaiting review label Mar 11, 2020
blurb-it Bot and others added 3 commits March 11, 2020 19:17
@blurb-it
📜🤖 Added by blurb_it.
5339a46
@sweeneyde
add UserString methods
cc85978
@sweeneyde
Merge branch 'cut_affix' of https://github.com/sweeneyde/cpython into…
1442ffe
… cut_affix
@sweeneyde
sweeneyde requested a review from rhettinger as a code owner March 11, 2020 20:00
sweeneyde added 3 commits March 11, 2020 16:08
@sweeneyde
update count of objects in test_doctests
111b0f9
@sweeneyde
restore clinic output
8265e4d
@sweeneyde
update count of objects in test_doctests
7401b87
serhiy-storchaka
serhiy-storchaka reviewed Mar 11, 2020
View reviewed changes

@serhiy-storchaka serhiy-storchaka 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.

The code LGTM. But I am not sure about adding these method for bytearray.

Needed also updates of the documentation.

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread Objects/bytesobject.c Resolved

Uh oh!

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

@sweeneyde
return original when bytes.cut***fix does not find match
e550171
@sweeneyde

sweeneyde commented Mar 12, 2020

Copy link
Copy Markdown
Member Author

But I am not sure about adding these method for bytearray.

Currently the bytearray api is almost a strict superset of the bytes api:

>>> set(dir(bytes)) - set(dir(bytearray))
{'__getnewargs__'}

and I didn't want to break that.

Needed also updates of the documentation.

I will work on the docs tonight and tomorrow.

All reactions

Sorry, something went wrong.

Uh oh!

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

sweeneyde and others added 7 commits March 11, 2020 23:39
@sweeneyde
Document cutprefix and cutsuffix
0a5d0a9
@sweeneyde
fix doctest in docs
a126438
@sweeneyde
Add credit
fbc4a50
@sweeneyde
make the empty affix case fast
3783dc3
@sweeneyde
clarified: one affix at a time
428e733
@sweeneyde
ensure tuples are not allowed
5796757
@sweeneyde
Fix userstring type behavior
6fe9ac5
serhiy-storchaka
serhiy-storchaka reviewed Mar 12, 2020
View reviewed changes
Comment thread Lib/collections/__init__.py Resolved

Uh oh!

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

@serhiy-storchaka

serhiy-storchaka commented Mar 12, 2020

Copy link
Copy Markdown
Member

Thank you. All this LGTM, and I am impressed by the quality of code from a new contributor.

I do not press the "Approve" button only because I did not follow the discussion. You need an approve from a core developer more interested in this feature.

Please add also a What's New entry. And add your name in Misc/ACKS.

zware and musically-ut reacted with thumbs up emoji
All reactions
  • 👍 2 reactions

Sorry, something went wrong.

Uh oh!

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

sweeneyde added 2 commits March 12, 2020 03:47
@sweeneyde
WhatsNew and ACKS
13e8296
@sweeneyde
WhatsNew and ACKS
49fa220
serhiy-storchaka
serhiy-storchaka reviewed Mar 12, 2020
View reviewed changes
Comment thread Doc/whatsnew/3.9.rst Resolved

Uh oh!

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

@sweeneyde @serhiy-storchaka
fix spelling
550beca
Co-Authored-By: Serhiy Storchaka <[email protected]>
@sweeneyde
changed 'cut' to 'remove'
4c33b74
sweeneyde
sweeneyde commented Mar 25, 2020
View reviewed changes

@sweeneyde sweeneyde left a comment

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.

Change 'cut" --> "remove" in NEWS and whatsnew

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread Doc/whatsnew/3.9.rst Resolved

Uh oh!

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

Comment thread Misc/NEWS.d/next/Core and Builtins/2020-03-11-19-17-36.bpo-39939.NwCnAM.rst Resolved

Uh oh!

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

sweeneyde added 2 commits March 25, 2020 19:18
@sweeneyde
Change method names in whatsnew
4413e2e
@sweeneyde
Update Misc/NEWS.d/next/Core and Builtins/2020-03-11-19-17-36.bpo-399…
5dfa968
…39.NwCnAM.rst


Change method names in NEWS
@sweeneyde sweeneyde changed the title bpo-39939: Add str.cutprefix and str.cutsuffix bpo-39939: Add str.removeprefix and str.removesuffix Mar 25, 2020
@sweeneyde
new names in the whatsnew header
aa6eede
@sweeneyde sweeneyde mentioned this pull request Apr 9, 2020
Submission for SC consideration: PEP 616: String methods to remove prefixes and suffixes python/steering-council#23
Closed
sweeneyde and others added 3 commits April 9, 2020 15:35
@sweeneyde
Merge branch 'master' into cut_affix
d941711
@sweeneyde
add examples of differences between l/rstrip and removeaffix
f55836d
@sweeneyde
Merge branch 'cut_affix' of https://github.com/sweeneyde/cpython into…
8d0584a
… cut_affix
vstinner
vstinner reviewed Apr 22, 2020
View reviewed changes
Comment thread Doc/library/stdtypes.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/stdtypes.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/stdtypes.rst Resolved

Uh oh!

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

Comment thread Doc/whatsnew/3.9.rst Resolved

Uh oh!

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

Comment thread Doc/whatsnew/3.9.rst Resolved

Uh oh!

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

Comment thread Doc/whatsnew/3.9.rst Resolved

Uh oh!

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

Comment thread Misc/NEWS.d/next/Core and Builtins/2020-03-11-19-17-36.bpo-39939.NwCnAM.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.

sweeneyde added 2 commits April 22, 2020 04:15
@sweeneyde
apply changes from review
8b6267a
@sweeneyde
apply changes from review
61cd530
@sweeneyde

sweeneyde commented Apr 22, 2020

Copy link
Copy Markdown
Member Author

Does someone know how to make the docs escape the slice string[:len(string)-len(suffix)]? I'm having trouble with Sphinx thinking that :len is a special kind of role.

All reactions

Sorry, something went wrong.

Uh oh!

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

vstinner
vstinner reviewed Apr 22, 2020
View reviewed changes

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

Overall, I like the change. Here is my second review on the doc, which is IMO the most important part here ;-)

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread Doc/library/stdtypes.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/whatsnew/3.9.rst Resolved

Uh oh!

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

Comment thread Doc/whatsnew/3.9.rst Resolved

Uh oh!

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

Comment thread Doc/whatsnew/3.9.rst Resolved

Uh oh!

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

Comment thread Misc/NEWS.d/next/Core and Builtins/2020-03-11-19-17-36.bpo-39939.NwCnAM.rst Resolved

Uh oh!

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

Comment thread Objects/bytearrayobject.c Resolved

Uh oh!

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

Comment thread Objects/bytearrayobject.c Resolved

Uh oh!

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

Comment thread Objects/bytearrayobject.c Resolved

Uh oh!

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

@vstinner

vstinner commented Apr 22, 2020

Copy link
Copy Markdown
Member

Does someone know how to make the docs escape the slice string[:len(string)-len(suffix)]? I'm having trouble with Sphinx thinking that :len is a special kind of role.

Sadly, your documentation syntax is correct. It's a bug in the "make suspicious" target of Doc/Makefile:

Makefile:115: recipe for target 'suspicious' failed

We could try to fix "make suspicious". But first I suggest you to write string[:-len(suffix)] instead: it's the syntax used in the PEP 616 and it's correct. I'm not sure why you chose to explicit the string length. I expect that "make suspicious" will not complain on :- which doesn't look like a Sphinx markup.

All reactions

Sorry, something went wrong.

Uh oh!

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

sweeneyde added 3 commits April 22, 2020 14:51
@sweeneyde
more documentation tweaks
ffe72f1
@sweeneyde
clean up the NEWS entry
d8f5a99
@sweeneyde
mention arg type in docstrings
3df1f38
@vstinner
vstinner merged commit a81849b into python:master Apr 22, 2020
@bedevere-bot bedevere-bot removed the awaiting review label Apr 22, 2020
@vstinner

vstinner commented Apr 22, 2020

Copy link
Copy Markdown
Member

Congrats @sweeneyde, I merged your PR! Maybe the documentation could still be enhanced even more, but I think that it's now good enough for an alpha release ;-) I built the documentation locally to check if it is rendered correctly and it was the case. I didn't see any obvious Sphinx syntax issue.

sweeneyde and musically-ut reacted with hooray emoji
All reactions
  • 🎉 2 reactions

Sorry, something went wrong.

Uh oh!

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

@bedevere-bot

bedevere-bot commented Apr 22, 2020

Copy link
Copy Markdown

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot AMD64 Fedora Stable LTO + PGO 3.x has failed when building commit a81849b.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/all/#builders/64/builds/656) and take a look at the build logs.
  4. Check if the failure is related to this commit (a81849b) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/all/#builders/64/builds/656

Failed tests:

  • test_concurrent_futures

Failed subtests:

  • test_killed_child - test.test_concurrent_futures.ProcessPoolSpawnProcessPoolExecutorTest

Summary of the results of the build (if available):

== Tests result: FAILURE then FAILURE ==

406 tests OK.

10 slowest tests:

  • test_concurrent_futures: 2 min 39 sec
  • test_multiprocessing_spawn: 1 min 43 sec
  • test_mailbox: 1 min 22 sec
  • test_nntplib: 1 min 21 sec
  • test_multiprocessing_forkserver: 1 min 15 sec
  • test_shelve: 1 min 3 sec
  • test_multiprocessing_fork: 1 min 3 sec
  • test_largefile: 51.6 sec
  • test_asyncio: 48.8 sec
  • test_signal: 47.1 sec

1 test failed:
test_concurrent_futures

14 tests skipped:
test_devpoll test_gdb test_ioctl test_kqueue test_msilib
test_ossaudiodev test_startfile test_tix test_tk test_ttk_guionly
test_winconsoleio test_winreg test_winsound test_zipfile64

1 re-run test:
test_concurrent_futures

Total duration: 5 min 46 sec

Click to see traceback logs
Traceback (most recent call last):
  File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-x86_64.lto-pgo/build/Lib/test/test_concurrent_futures.py", line 130, in tearDown
    self.executor.shutdown(wait=True)
  File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-x86_64.lto-pgo/build/Lib/concurrent/futures/process.py", line 724, in shutdown
    self._executor_manager_thread_wakeup.wakeup()
  File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-x86_64.lto-pgo/build/Lib/concurrent/futures/process.py", line 80, in wakeup
    self._writer.send_bytes(b"")
  File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-x86_64.lto-pgo/build/Lib/multiprocessing/connection.py", line 205, in send_bytes
    self._send_bytes(m[offset:offset + size])
  File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-x86_64.lto-pgo/build/Lib/multiprocessing/connection.py", line 416, in _send_bytes
    self._send(header + buf)
  File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-x86_64.lto-pgo/build/Lib/multiprocessing/connection.py", line 373, in _send
    n = write(self._handle, buf)
OSError: [Errno 9] Bad file descriptor
All reactions

Sorry, something went wrong.

Uh oh!

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

elazarg
elazarg reviewed May 28, 2020
View reviewed changes
Comment thread Doc/whatsnew/3.9.rst
to easily remove an unneeded prefix or a suffix from a string. Corresponding
``bytes``, ``bytearray``, and ``collections.UserString`` methods have also been
added. See :pep:`616` for a full description. (Contributed by Dennis Sweeney in
:issue:`18939`.)

@elazarg elazarg May 28, 2020

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 is not 18939, which is about "Venv docs regarding original python install". Shouldn't this be 39939?

Sorry, something went wrong.

Uh oh!

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

All reactions

@vstinner vstinner May 28, 2020

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.

Right, it's a typo error: @sweeneyde: can you please propose a PR to fix the typo?

Sorry, something went wrong.

Uh oh!

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

All reactions

@vstinner vstinner May 28, 2020

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.

Or @elazarg: Do you want to propose a PR to fix the typo?

Sorry, something went wrong.

Uh oh!

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

All reactions

@elazarg elazarg May 28, 2020

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.

Sure. I thought it might be overkill :)

Sorry, something went wrong.

Uh oh!

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

All reactions

@sweeneyde sweeneyde May 28, 2020

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.

Oops -- It looks like that's the GitHub PR number rather than the bpo number. I can't make a PR tonight so feel free to change it. If not, I can fix it tomorrow.

Sorry, something went wrong.

Uh oh!

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

All reactions

@elazarg elazarg May 28, 2020

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.

Done.

Sorry, something went wrong.

Uh oh!

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

All reactions
@elazarg elazarg mentioned this pull request May 28, 2020
bpo-39939: Fix typo in docs: removeprefix is issue 39939 #20473
Merged
@sweeneyde
sweeneyde deleted the cut_affix branch January 25, 2022 23:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@vstinner vstinner vstinner left review comments
@serhiy-storchaka serhiy-storchaka serhiy-storchaka left review comments
@tirkarthi tirkarthi tirkarthi left review comments
@rhettinger rhettinger Awaiting requested review from rhettinger
+1 more reviewer
@elazarg elazarg elazarg left review comments
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

None yet

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.

7 participants

@sweeneyde @serhiy-storchaka @vstinner @bedevere-bot @tirkarthi @elazarg @the-knights-who-say-ni
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.