[issue44405] add program passed as string to dis module.

2022-03-18 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Neither of tokenize, ast or symtable modules support passing the source string 
as argument. If add this feature in the dis module, we will need to add it in 
all other modules with similar CLI. I do not think it is practical. You always 
can pass the source string via stdin. And you do not even need to pass 
/dev/stdin as argument, stdin is the default.

I usually use it with rlwrap. It allows to use some editing and history.

rlwrap ./python -m dis

I propose to close this issue and open a new issue for documenting the CLI of 
the dis module.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44405] add program passed as string to dis module.

2021-07-23 Thread Nick Coghlan


Nick Coghlan  added the comment:

I suspect the only reason the dis CLI isn't documented is because it's been 
around for so long (22 years!) that nobody previously noticed it was missing: 
https://github.com/python/cpython/commit/1fdae12c93246fcf4abbf882ba08df789070dfcc

Folks then either didn't know about it, or already knew how to use it.

Even the migration to use argparse was a code cleanup from a user that happened 
to be reading the module source code and noticed that it didn't already do so: 
https://bugs.python.org/issue18538

I can see value in supporting `-c` and `-m` options to dis to align with the 
main interpreter CLI.

--
nosy: +ncoghlan

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44405] add program passed as string to dis module.

2021-06-17 Thread Emmanuel Arias


Change by Emmanuel Arias :


--
nosy: +eamanu

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44405] add program passed as string to dis module.

2021-06-13 Thread Arjun


Change by Arjun :


--
pull_requests: +25302
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/26714

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44405] add program passed as string to dis module.

2021-06-13 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

I often use the command-line interface of dis, ast, and sometimes tokenize 
modules. They are mature enough and not only for self-testing. If they are not 
documented, we need to document them.

Since they read from stdin by default (no need to specify /dev/stdin or CON 
explicitly) I never needed the -c option. It would not be particularly useful 
in any case because Python code is usually multi-line.

BTW sometimes I want to implement GUI for these modules in IDLE.

--
nosy: +serhiy.storchaka

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44405] add program passed as string to dis module.

2021-06-12 Thread Steven D'Aprano


Change by Steven D'Aprano :


--
nosy: +steven.daprano
versions: +Python 3.11

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44405] add program passed as string to dis module.

2021-06-12 Thread Arjun


Arjun  added the comment:

> If _test were considered obsolete, it could be removed.

removing _test: 
https://github.com/CCLDArjun/cpython/commit/8b3b8ccef0ef693f8f4105fd1eb56e9386675301
 does not break dis tests.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44405] add program passed as string to dis module.

2021-06-12 Thread Arjun


Arjun  added the comment:

> If _test were considered obsolete, it could be removed.

Yup, originally it was added 2 decades ago (in 2000) originally as a test: 
1fdae12c932

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44405] add program passed as string to dis module.

2021-06-12 Thread Arjun


Arjun  added the comment:

Huh, that's actually weird that the "exisisting command line interface" (quotes 
because it was added as a test) isn't official. I've found it to be convinient 
as a newcomer to the cpython codebase. 

> What is unusual, I think, for a CLI test function is that it requires a 
> passed in argument

git blame shows the commit hash is 095668914c3, which is for bpo: 
https://bugs.python.org/issue18538 "python -m dis now uses argparse". The 
Misc/HISTORY file references the change in section "What's New in Python 3.4.0 
Alpha 3?"

Regardless of the cli being official, personally I think, it's a good feature 
to add. But also, maybe I should start a discussion in python-ideas about 
making it official?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44405] add program passed as string to dis module.

2021-06-12 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

What is unusual, I think, for a CLI test function is that it requires a passed 
in argument.  As a sanity-check test, 'python -m dis' could (should) 
disassemble itself.  Perhaps there once were some true tests that were moved to 
unittests.  (I started IDLE unittests by doing this with module test 
functions.)  If you know git, you could check the history and checkin messages.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44405] add program passed as string to dis module.

2021-06-12 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

I checked https://docs.python.org/3/library/dis.html and there is no mention of 
dis having a command-line interface.  This suggests that _test is likely 
present only for testing the module, not for using it.  This was common a 
couple of decades ago before we had unittests.  If _test were considered 
obsolete, it could be removed.

By suggesting that the command line interface by upgraded, I suspect that you 
are implicitly suggesting that it be considered 'official'.  If so, that 
'_test' should become '_main' (where the underscore leaves it out of __all__), 
and the CLI documented as in other modules with a CLI.  (I am not up on the 
details and policy around this issue.)

It may be appropriate to start a discussion of python-ideas.

--
nosy: +terry.reedy, yselivanov

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44405] add program passed as string to dis module.

2021-06-12 Thread Arjun


New submission from Arjun :

python dis module should have a program passed in as string.

Currently, you can do this:
$ echo "x = 6" | python -m dis /dev/stdin
  1   0 LOAD_CONST   0 (6)
  2 STORE_NAME   0 (x)
  4 LOAD_CONST   1 (None)
  6 RETURN_VALUE

would be convenient like this:
$ ./python.exe -m dis -c "x=6"
  1   0 LOAD_CONST   0 (6)
  2 STORE_NAME   0 (x)
  4 LOAD_CONST   1 (None)
  6 RETURN_VALUE

these changes seem to be working.

--
components: Library (Lib)
files: dis.patch
keywords: patch
messages: 395720
nosy: CCLDArjun
priority: normal
severity: normal
status: open
title: add program passed as string to dis module.
type: enhancement
Added file: https://bugs.python.org/file50107/dis.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com