Skip to content

bpo-32832: support override of ps1/ps2/output prefix for doctest parser#7141

Closed
skirpichev wants to merge 1 commit into
python:masterfrom
skirpichev:doctest-ipython-style
Closed

bpo-32832: support override of ps1/ps2/output prefix for doctest parser#7141
skirpichev wants to merge 1 commit into
python:masterfrom
skirpichev:doctest-ipython-style

Conversation

@skirpichev

@skirpichev skirpichev commented May 27, 2018

Copy link
Copy Markdown
Member

The Python stdlib allows override of sys.ps1/ps2 (to make IPython-like
dynamic prompts and so on). In the IPython - customized parser
class created to support doctests, written in such a style. This commit
adds optional arguments for DocTestParser.__init__() to support
same in the doctest module as well.

https://bugs.python.org/issue32832

The Python stdlib allows override of sys.ps1/ps2 (to make IPython-like
dynamic prompts and so on).  In the IPython - customized parser
class created to support doctests, written in such a style.  This commit
adds optional arguments for DocTestParser.__init__() to support
same in the doctest module as well.
@the-knights-who-say-ni

Copy link
Copy Markdown

Hello, and thanks for your contribution!

I'm a bot set up to make sure that the project can legally accept your contribution by verifying you have signed the PSF contributor agreement (CLA).

Unfortunately we couldn't find an account corresponding to your GitHub username on bugs.python.org (b.p.o) to verify you have signed the CLA (this might be simply due to a missing "GitHub Name" entry in your b.p.o account settings). This is necessary for legal reasons before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue.

When your account is ready, please add a comment in this pull request
and a Python core developer will remove the CLA not signed label
to make the bot check again.

Thanks again to your contribution and we look forward to looking at it!

@skirpichev

Copy link
Copy Markdown
Member Author

Github account name on b.p.o. was missed, added now. Sorry.

@brettcannon

Copy link
Copy Markdown
Member

@skirpichev bugs.python.org still says you have not signed the CLA.

@skirpichev

Copy link
Copy Markdown
Member Author

Sorry, probably forgot to confirm email last time. CLA was signed just now.

BTW, it seems bugs.python.org was banned in Russia.

@csabella

Copy link
Copy Markdown
Contributor

@skirpichev , thank you for the pull request, but as @tim-one was -1 on this change in the discussion on the bug tracker, I'm going to close this. If Tim changes his decision in the future, please feel free to re-open this. Any additional discussion should happen on the bug tracker first before re-opening. Thanks!

@csabella csabella closed this May 13, 2019
@skirpichev

Copy link
Copy Markdown
Member Author

Thank you, but I'm not planning to contribute anymore in cpython, it's apparently worthless.

@tim-one

tim-one commented May 13, 2019

Copy link
Copy Markdown
Member

@skirpichev, Python is a mature project now, with millions of users. The bar for making changes is correspondingly high. It can certainly still be done, but a strong case needs to be made. I left this on the bug tracker a year ago:

Something that might change my mind: find an author of a widely used alternative Python shell who says this change would allow them to remove their own doctest-PS1/PS2 customization code. That would be a real use case.

Since nothing more happened, there's still no real use case in sight, so I agree with @csabella closing this.

@skirpichev

Copy link
Copy Markdown
Member Author

find an author of a widely used alternative Python shell who says this change would allow them to remove their own doctest-PS1/PS2 customization code.

IPython. That example was provided from the beginning. Maybe this patch doesn't remove all doctest customization, but noticeable part of (I think, the IPDocTestParser class entirely).

@tim-one

tim-one commented May 13, 2019

Copy link
Copy Markdown
Member

But we discussed that on the bug tracker a year ago, and in the last message you left there, you agreed:

I admit, exactly this use case I can't provide right now.

I left the bug open, on the chance that you would try to find an author of a widely used alternative shell who could say the patch would be a real help to them. But that's the last we heard. Your comments at the time suggested you thought IPython should be rewritten in other ways instead:

IMHO, same effect should be possible by running doctest several times with different conventions.

But that's not for you (or me) to decide - that's up to the IPython maintainers. Did you ask them?

In the continued absence of at least one actual major potential user saying "yes, I want this!", there's really no case to be made for complicating long-stable code.

It's nothing personal. It's about costs-vs-benefits guesses.

@skirpichev

Copy link
Copy Markdown
Member Author

that's up to the IPython maintainers. Did you ask them?

Apparently, they think that fixing Python stdlib worthless as well. (The existence of IPython itself shows, that stdlib - sucks, CPython has no good built-in REPL capabilities.)

no case to be made for complicating long-stable code.

Given issues like https://bugs.python.org/issue26092, it seems I fail to have a mental model for stdlib maintenance.

I will consider patching pytest's doctest plugin.

It's nothing personal.

Sure, I didn't mean the opposite.

@skirpichev skirpichev deleted the doctest-ipython-style branch May 15, 2019 09:31
@tim-one

tim-one commented May 16, 2019

Copy link
Copy Markdown
Member

So I take it a straight answer to my question is "no, I didn't ask". Then that remains a problem: you can't sell an idea as "a solution" if you can't find real users with problems it would actually solve. "I like it better this other way" just isn't enough.

There's no point in repeating "worthless", unless you're just trying to blow off steam. It's pejorative and grossly overstated.

About BPO 8408, I hadn't seen it before. The resolution doesn't surprise me, despite that it seemed unprincipled. What you may not know: Noam Yorav-Raphael contributed substantial features to IDLE, and eventually started his own Python shell project (DreamPie - between IDLE and IPython in power). Because he was well-known, and because his patch actually solved a real problem his users were actually having in DreamPie, Georg wasn't inclined to push back, so applied his patch.

But I have no idea what "a right way" to solve that would have been. I wrote doctest 20 years ago, and never gave a thought to sys.displayhook. IDLE was the fanciest alternative shell in the world at that time, and it was an explicit non-goal of doctest's to cater to the IDLE shell'a weird mix of ">>> " and leading tabs.

I hadn't seen your BPO 26092 before either, but don't know what you expected from it. Open source is driven by people scratching their own itches, and in that report you didn't identify a specific problem or a specific solution. Hoping other people will drop what they're doing to think about it doesn't usually work 😉. No problem in trying that, but the python-ideas (or maybe python-dev if the idea is close to polished) mailing list is far more suitable for such stuff than the issue tracker.

@skirpichev

skirpichev commented May 16, 2019 via email

Copy link
Copy Markdown
Member Author

@tim-one

tim-one commented May 17, 2019

Copy link
Copy Markdown
Member

What's the relevance of Diofant? It appears to be a capable package for doing symbolic computation, but - unless it's very deeply buried in the docs - doesn't appear to make any attempt to supply its own shell.

If not, I'm left clueless as to what actual problem you're trying to solve.

I'll suggest a possibility: perhaps people writing doctests when using Diofant under IPython are frustrated that they "don't work" when they try to run them under plain-old-Python instead?

That I'd have sympathy for. A good solution to that might be to merge IPython's doctest parsing into the core standard library. Best I can tell, there are only a handful of Python shells out there (Python, IDLE, IPython, DreamPie, bpython, ptpython), and they all (except IDLE) use either Python's or IPython's shell conventions. IPython's doctest parser handles both, so covers the universe of real-world possibilities.

Then everything would "just work".

@skirpichev

skirpichev commented May 17, 2019 via email

Copy link
Copy Markdown
Member Author

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.

6 participants