[issue33422] Fix and update string/byte literals in help()

2018-05-07 Thread Andrés Delfino

Andrés Delfino  added the comment:

I was exploring pydoc, saw the literals as available help "terms" on the 
sysmbols section, and tried reading the help for one of them.

I learnt about IDLE debugging to trace this bug :)

--

___
Python tracker 

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



[issue33422] Fix and update string/byte literals in help()

2018-05-06 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

Thank you for your contribution Andrés!

I just wondering how did you discover this bug?

--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed
type:  -> behavior
versions: +Python 2.7, Python 3.6, Python 3.7

___
Python tracker 

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



[issue33422] Fix and update string/byte literals in help()

2018-05-06 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:


New changeset c40eeeb5e69df12a5f46edc7ba82ec75c7d1b820 by Serhiy Storchaka 
(Andrés Delfino) in branch '2.7':
[2.7] bpo-33422: Fix quotation marks getting deleted when looking up 
byte/string literals on pydoc. (GH-6701) (GH-6712)
https://github.com/python/cpython/commit/c40eeeb5e69df12a5f46edc7ba82ec75c7d1b820


--

___
Python tracker 

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



[issue33422] Fix and update string/byte literals in help()

2018-05-05 Thread Andrés Delfino

Change by Andrés Delfino :


--
pull_requests: +6405

___
Python tracker 

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



[issue33422] Fix and update string/byte literals in help()

2018-05-05 Thread miss-islington

miss-islington  added the comment:


New changeset 0ba812b1bee65a6cad16f153a7f5074bc271e0e5 by Miss Islington (bot) 
in branch '3.6':
bpo-33422: Fix quotation marks getting deleted when looking up byte/string 
literals on pydoc. (GH-6701)
https://github.com/python/cpython/commit/0ba812b1bee65a6cad16f153a7f5074bc271e0e5


--

___
Python tracker 

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



[issue33422] Fix and update string/byte literals in help()

2018-05-05 Thread miss-islington

miss-islington  added the comment:


New changeset 351782b9927c610ff531100dbdcbbd19d91940a3 by Miss Islington (bot) 
in branch '3.7':
bpo-33422: Fix quotation marks getting deleted when looking up byte/string 
literals on pydoc. (GH-6701)
https://github.com/python/cpython/commit/351782b9927c610ff531100dbdcbbd19d91940a3


--
nosy: +miss-islington

___
Python tracker 

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



[issue33422] Fix and update string/byte literals in help()

2018-05-05 Thread miss-islington

Change by miss-islington :


--
pull_requests: +6403

___
Python tracker 

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



[issue33422] Fix and update string/byte literals in help()

2018-05-05 Thread miss-islington

Change by miss-islington :


--
pull_requests: +6402

___
Python tracker 

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



[issue33422] Fix and update string/byte literals in help()

2018-05-05 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:


New changeset b2043bbe6034b53f5ad337887f4741b74b70b00d by Serhiy Storchaka 
(Andrés Delfino) in branch 'master':
bpo-33422: Fix quotation marks getting deleted when looking up byte/string 
literals on pydoc. (GH-6701)
https://github.com/python/cpython/commit/b2043bbe6034b53f5ad337887f4741b74b70b00d


--

___
Python tracker 

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



[issue33422] Fix and update string/byte literals in help()

2018-05-04 Thread Andrés Delfino

Andrés Delfino  added the comment:

I have updated the PR. Now symbols show:

Here is a list of the punctuation symbols which Python assigns special meaning
to. Enter any symbol to get more help.

!=  +   <=  __
"   +=  <>  `
""" ,   ==  b"
%   -   >   b'
%=  -=  >=  f"
&   .   >>  f'
&=  ... >>= j
'   /   @   r"
''' //  J   r'
(   //= [   u"
)   /=  \   u'
*   :   ]   |
**  <   ^   |=
**= <<  ^=  ~
*=  <<= _   

I don't understand how topics.py gets autogenerated by Sphinx (by te way, it 
says it was generated on January 2018), so I'm having trouble with using a more 
specific topic for f'.

--

___
Python tracker 

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



[issue33422] Fix and update string/byte literals in help()

2018-05-04 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

Option 2 LGTM.

--

___
Python tracker 

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



[issue33422] Fix and update string/byte literals in help()

2018-05-04 Thread Andrés Delfino

Andrés Delfino  added the comment:

And what should symbols show in pydoc?

Should symbols show:

1. All legal combinations with ("'", '"') (48 possible combinations)
2. Only b/f/r/u with ("'", '"') (IMHO, this is the most reasonable option) 
3. Only b/f/r/u with ' or "

Depending on that, we can choose one of the options you mentioned.

--

___
Python tracker 

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



[issue33422] Fix and update string/byte literals in help()

2018-05-04 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

I don't think we need to support prefixes without quotes or with triple qoutes. 
'ur' is not valid prefix. Using simplified code from tokenize:

_strprefixes = [''.join(u) + q
for t in ('b', 'r', 'u', 'f', 'br', 'rb', 'fr', 'rf')
for u in itertools.product(*[(c, c.upper()) for c in t])
for q in ("'", '"')]

Or you can use tokenize._all_string_prefixes() directly:

_strprefixes = [p + q
for p in tokenize._all_string_prefixes()
for q in ("'", '"')]

But it may be simple to just convert the string to lower case before looking up 
in the symbols dict. Then

_strprefixes = [p + q
for p in ('b', 'r', 'u', 'f', 'br', 'rb', 'fr', 'rf')
for q in ("'", '"')]

--

___
Python tracker 

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



[issue33422] Fix and update string/byte literals in help()

2018-05-04 Thread Andrés Delfino

Andrés Delfino  added the comment:

To get the 144 combinations I used the logic in tokenize.py:

import re

def _combinations(*l):
return set(
x + y for x in l for y in l + ("",) if x.casefold() != y.casefold()
)

_strprefixes = (
_combinations('r', 'R', 'f', 'F') | _combinations('r', 'R', 'b', 'B') | 
{'u', 'U', 'ur', 'uR', 'Ur', 'UR'}
)

triple_quoted = (
{"'''", '"""'} | {f"{prefix}'''" for prefix in _strprefixes} | 
{f'{prefix}"""' for prefix in _strprefixes}
)
single_quoted = (
{"'", '"'} | {f"{prefix}'" for prefix in _strprefixes} | {f'{prefix}"' for 
prefix in _strprefixes}
)

all_combinations = _strprefixes | single_quoted | triple_quoted

print(' '.join(list(all_combinations)))

print(len(all_combinations))

--

___
Python tracker 

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



[issue33422] Fix and update string/byte literals in help()

2018-05-04 Thread Andrés Delfino

Andrés Delfino  added the comment:

Eric, I entered "r'" in the interactive prompt.

Serhiy, using the code in tokenize, I got a total of 144 combinations. For 
comparison, the list of symbols help() shows, after the proposed change, has 67 
items.

IMHO, we should compromise. Maybe just mentioning the letters? With no quoting 
character. I do know that this can be confusing, since J is shown as a letter 
but it's used as a suffix unlike b/f/r/u...

What do you think?

--

___
Python tracker 

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



[issue33422] Fix and update string/byte literals in help()

2018-05-04 Thread Eric V. Smith

Eric V. Smith  added the comment:

It's not clear to me what you're typing to get the output in the first message. 
Can you clarify? Is this at the interactive prompt?

--

___
Python tracker 

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



[issue33422] Fix and update string/byte literals in help()

2018-05-04 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

Interesting, I didn't know that pydoc supports this.

Specifying all possible prefixes is cumbersome and errorprone. The number of 
combinations grows exponentially with adding new letters. I suggest either to 
specify only lower-case variants and generate all variants with upper-case 
letters (as it done in the tokenize module) or always calls the lower() method 
when look up in the symbols dictionary.

It may be worth to add a special topic for f-strings.

--
nosy: +eric.smith, serhiy.storchaka

___
Python tracker 

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



[issue33422] Fix and update string/byte literals in help()

2018-05-03 Thread Andrés Delfino

Andrés Delfino  added the comment:

*While the list is still incomplete

--

___
Python tracker 

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



[issue33422] Fix and update string/byte literals in help()

2018-05-03 Thread Andrés Delfino

Change by Andrés Delfino :


--
keywords: +patch
pull_requests: +6393
stage:  -> patch review

___
Python tracker 

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



[issue33422] Fix and update string/byte literals in help()

2018-05-03 Thread Andrés Delfino

New submission from Andrés Delfino :

Right now, for string/byte literals help() shows, for example:

No Python documentation found for 'r'.
Use help() to get the interactive help utility.
Use help(str) for help on the str class.

PR fixes the quotation mark removal and updates the list with f and u literals, 
while also adding uppercase versions of all literals. While the list is install 
incomplete (e.g., fR and the others could be listed) I believe that's too much.

--
components: Library (Lib)
messages: 316148
nosy: adelfino
priority: normal
severity: normal
status: open
title: Fix and update string/byte literals in help()
versions: Python 3.8

___
Python tracker 

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