[issue42005] profile/cProfile CLI should catch BrokenPipeError

2020-10-10 Thread Zhiming Wang


Change by Zhiming Wang :


--
keywords: +patch
pull_requests: +21617
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/22643

___
Python tracker 

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



[issue39828] json.tool should catch BrokenPipeError

2020-10-10 Thread Zhiming Wang


Change by Zhiming Wang :


--
nosy: +zmwangx
nosy_count: 5.0 -> 6.0
pull_requests: +21618
pull_request: https://github.com/python/cpython/pull/22643

___
Python tracker 

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



[issue42005] profile/cProfile CLI should catch BrokenPipeError

2020-10-10 Thread Zhiming Wang


New submission from Zhiming Wang :

Since profile/cProfile CLI interface prints a sorted list of stats, using head 
to limit output to the most relevant entries should be a fairly natural thing 
to do. Unfortunately, BrokenPipeError isn't caught, causing quite a bit of 
pollution to the output:

$ python3 -m cProfile -m http.server -h | head
usage: http.server [-h] [--cgi] [--bind ADDRESS] [--directory DIRECTORY]
   [port]

positional arguments:
  port  Specify alternate port [default: 8000]

optional arguments:
  -h, --helpshow this help message and exit
  --cgi Run as CGI Server
  --bind ADDRESS, -b ADDRESS
Traceback (most recent call last):
  File "/Users/zmwang/.pyenv/versions/3.9.0/lib/python3.9/runpy.py", line 197, 
in _run_module_as_main
return _run_code(code, main_globals, None,
  File "/Users/zmwang/.pyenv/versions/3.9.0/lib/python3.9/runpy.py", line 87, 
in _run_code
exec(code, run_globals)
  File "/Users/zmwang/.pyenv/versions/3.9.0/lib/python3.9/cProfile.py", line 
180, in 
main()
  File "/Users/zmwang/.pyenv/versions/3.9.0/lib/python3.9/cProfile.py", line 
173, in main
runctx(code, globs, None, options.outfile, options.sort)
  File "/Users/zmwang/.pyenv/versions/3.9.0/lib/python3.9/cProfile.py", line 
19, in runctx
return _pyprofile._Utils(Profile).runctx(statement, globals, locals,
  File "/Users/zmwang/.pyenv/versions/3.9.0/lib/python3.9/profile.py", line 66, 
in runctx
self._show(prof, filename, sort)
  File "/Users/zmwang/.pyenv/versions/3.9.0/lib/python3.9/profile.py", line 72, 
in _show
prof.print_stats(sort)
  File "/Users/zmwang/.pyenv/versions/3.9.0/lib/python3.9/cProfile.py", line 
42, in print_stats
pstats.Stats(self).strip_dirs().sort_stats(sort).print_stats()
  File "/Users/zmwang/.pyenv/versions/3.9.0/lib/python3.9/pstats.py", line 431, 
in print_stats
self.print_line(func)
  File "/Users/zmwang/.pyenv/versions/3.9.0/lib/python3.9/pstats.py", line 513, 
in print_line
print(f8(tt/nc), end=' ', file=self.stream)
BrokenPipeError: [Errno 32] Broken pipe
Exception ignored in: <_io.TextIOWrapper name='' mode='w' 
encoding='utf-8'>
BrokenPipeError: [Errno 32] Broken pipe

I think the exception should be caught in order to suppress this noise.

--
components: Library (Lib)
messages: 378421
nosy: zmwangx
priority: normal
severity: normal
status: open
title: profile/cProfile CLI should catch BrokenPipeError
type: behavior
versions: Python 3.10

___
Python tracker 

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



[issue42001] Deprecate `typing.io` Wrapper Namespace

2020-10-10 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
nosy: +gvanrossum, levkivskyi

___
Python tracker 

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



[issue41972] bytes.find consistently hangs in a particular scenario

2020-10-10 Thread Tim Peters


Tim Peters  added the comment:

Ya, the case for the diff is at best marginal. Note that while it may be 
theoretically provable that the extra test would make the worst cases slower, 
that's almost certainly not measurable. The extra test would almost never be 
executed in the worst cases: in those the last characters of the needle and 
haystack DO match, and we spend almost all the total time in the

for (j = 0; j < mlast; j++)

loop.  The extra test is only in the branch where the last characters _don't_ 
match.

In that branch, it's already certain that the last haystack character does not 
match the last needle character, so in a probabilistic sense, for "random" data 
that increases the odds that the last haystack character isn't in the needle at 
all. In which case the payoff is relatively large compared to the cost of the 
test (can skip len(needle) positions at once, instead of only 1).

I don't believe this can be out-thought. It would require timing on "typical" 
real-life searches. Which are likely impossible to obtain ;-)

Offhand do you know what the _best_ timing for two-way search is in a 
pattern-not-found case? The algorithm is too complicated for that to be 
apparent to me at a glance. As Fredrik said in the post of his I linked to, he 
was very keen to have an algorithm with best case sublinear time. For example, 
the one we have takes best-case not-found O(n/m) time (where n is the haystack 
length and m the needle length).  For example, searching for 'B' * 1_000_000 in 
'A' * 10_000_000 fails after just 9 character comparisons (well, not counting 
the million less 1 compares to initialize `skip` to the ultimately useless 0).

--

___
Python tracker 

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



[issue42003] After changing to list or tuple, will the original parameter change?

2020-10-10 Thread Steven D'Aprano


Steven D'Aprano  added the comment:

This is not a bug. In Python 2, zip() returns a list, so you can use it over 
and over again. But in Python 3, zip() returns an iterator, and you can only 
use iterators once. After you have used the iterator, it is exhausted and there 
is nothing left.

So the behaviour you see is expected and intentional.

--
nosy: +steven.daprano
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

___
Python tracker 

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



[issue42004] Allow uploading files with SimpleHTTPRequestHandler

2020-10-10 Thread Javier Ayres


New submission from Javier Ayres :

Hello. I'm a big fan of the http.server module to quickly serve some files in a 
local network with `python3 -m http.server`. I regularly needed to get some 
files from other people too, but getting everyone to install/run python3 was 
not such a simple task. Eventually I wrote a subclass of 
SimpleHTTPRequestHandler that added a form with a file input and accepted POST 
requests, so people could also upload files to my computer. I think this would 
be a fine addition to SimpleHTTPRequestHandler, so I'm attaching a potential 
patch that implements this and adds a new cli parameter so this feature is only 
enabled explicitly.

--
components: Library (Lib)
files: patch
messages: 378418
nosy: lufte
priority: normal
severity: normal
status: open
title: Allow uploading files with SimpleHTTPRequestHandler
type: enhancement
versions: Python 3.10
Added file: https://bugs.python.org/file49506/patch

___
Python tracker 

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



[issue42003] After changing to list or tuple, will the original parameter change?

2020-10-10 Thread foxpython_2020


New submission from foxpython_2020 :

c = dict(zip(['one', 'two', 'three'], [1, 2, 3]))
print("1:",c) # right: {'one': 1, 'two': 2, 'three': 3}

b= zip(['one', 'two', 'three'], [1, 2, 3])
a= list(b) #Because of this line of code, the result is different
print("2:",dict(b)) #wrong: {}

b= zip(['one', 'two', 'three'], [1, 2, 3])
a= tuple(b) #Because of this line of code, the result is different
print("2:",dict(b)) #wrong: {}

--
messages: 378417
nosy: foxpython_2020
priority: normal
severity: normal
status: open
title: After changing to list or tuple, will the original parameter change?

___
Python tracker 

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



[issue38605] [typing] PEP 563: Postponed evaluation of annotations: enable it by default in Python 3.10

2020-10-10 Thread Guido van Rossum


Guido van Rossum  added the comment:


New changeset 0ae216b11644b23511c6287a52e7d28aeb9f by Batuhan Taskaya in 
branch 'master':
bpo-38605: bump the magic number for 'annotations' future (#22630)
https://github.com/python/cpython/commit/0ae216b11644b23511c6287a52e7d28aeb9f


--

___
Python tracker 

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



[issue41991] Remove _PyObject_HasAttrId

2020-10-10 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed
versions:  -Python 3.8, Python 3.9

___
Python tracker 

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



[issue42002] Clean up initialization of the sys module

2020-10-10 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
keywords: +patch
pull_requests: +21616
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/22642

___
Python tracker 

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



[issue42002] Clean up initialization of the sys module

2020-10-10 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
nosy: +vstinner

___
Python tracker 

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



[issue42002] Clean up initialization of the sys module

2020-10-10 Thread Serhiy Storchaka


New submission from Serhiy Storchaka :

_PySys_InitCore() and _PySys_InitMain() in Python/sysmodule.c contains many 
invocations of macros for setting attributes of the sys module. The proposed PR 
changes these macros.

1. SET_SYS_FROM_STRING was renamed to just SET_SYS. It is much shorter and 
allow to write many invocations in one line. Also SET_SYS_FROM_STRING was not 
consistent with SET_SYS_FROM_WSTR.

2. Added new SET_SYS_FROM_STRING which sets attribute specified as C char 
string (similarly to SET_SYS_FROM_WSTR which sets attribute specified as C 
wchar_t string).

3. Added COPY_SYS_ATTR for making a copy of the attribute. It uses 
PyMapping_GetItemString() instead of PyDict_GetItemString() which silences all 
expressions.

4. Removed SET_SYS_FROM_STRING_BORROW. It no longer used, and it was used 
improperly.

5. SET_SYS_FROM_STRING_INT_RESULT replaced with SET_SYS.

6. All macros have been rewritten in term of SET_SYS that significantly 
simplifies the code.

All this makes the code clearer and makes errors handling more correct.

--
components: Interpreter Core
messages: 378415
nosy: serhiy.storchaka
priority: normal
severity: normal
status: open
title: Clean up initialization of the sys module
versions: Python 3.10

___
Python tracker 

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



[issue42001] Deprecate `typing.io` Wrapper Namespace

2020-10-10 Thread Sebastian Rittau


Sebastian Rittau  added the comment:

For reference, this came up in 
https://github.com/python/typeshed/issues/4639#issuecomment-706596656. 
`typing.io` has never been in typeshed and we decided not to include it. It 
looks as if it never gained any traction, especially since the types are 
available from `typing` directly.

--
nosy: +srittau

___
Python tracker 

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



[issue41986] Py_FileSystemDefaultEncodeErrors and Py_UTF8Mode are not available with limited API

2020-10-10 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

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



[issue41991] Remove _PyObject_HasAttrId

2020-10-10 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset 98c4433a81a4cd88c7438adbee1f2aa486188ca3 by Serhiy Storchaka in 
branch 'master':
bpo-41991: Remove _PyObject_HasAttrId (GH-22629)
https://github.com/python/cpython/commit/98c4433a81a4cd88c7438adbee1f2aa486188ca3


--

___
Python tracker 

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



[issue42001] Deprecate `typing.io` Wrapper Namespace

2020-10-10 Thread Kaushal Rohit


New submission from Kaushal Rohit :

The `typing` module has a wrapper namespace in it called `typing.io` which 
contain I/O stream types.

These types are now a part of the `typing` module itself.

While we are at it, should we also deprecate `typing.re`?

--
components: Library (Lib)
messages: 378412
nosy: rohitkg98
priority: normal
severity: normal
status: open
title: Deprecate `typing.io` Wrapper Namespace
type: behavior
versions: Python 3.10, Python 3.6, Python 3.7, Python 3.8, Python 3.9

___
Python tracker 

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



[issue42000] Small cleanups to AST-related code

2020-10-10 Thread Batuhan Taskaya


Change by Batuhan Taskaya :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

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



[issue42000] Small cleanups to AST-related code

2020-10-10 Thread miss-islington


New submission from miss-islington :


New changeset 02a1603f918b9862e164e4fd050c505b16bc9f57 by Batuhan Taskaya in 
branch 'master':
bpo-42000: Cleanup the AST related C-code (GH-22641)
https://github.com/python/cpython/commit/02a1603f918b9862e164e4fd050c505b16bc9f57


--
nosy: +miss-islington

___
Python tracker 

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



[issue42000] Small cleanups to AST-related code

2020-10-10 Thread Batuhan Taskaya


Change by Batuhan Taskaya :


--
keywords: +patch
pull_requests: +21614
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/22641

___
Python tracker 

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



[issue42000] Small cleanups to AST-related code

2020-10-10 Thread Batuhan Taskaya


Change by Batuhan Taskaya :


--
components: Interpreter Core
nosy: BTaskaya
priority: normal
severity: normal
status: open
title: Small cleanups to AST-related code
versions: Python 3.10

___
Python tracker 

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



[issue40213] contextlib.aclosing()

2020-10-10 Thread John Belmonte


Change by John Belmonte :


--
keywords: +patch
nosy: +jbelmonte
nosy_count: 9.0 -> 10.0
pull_requests: +21613
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/22640

___
Python tracker 

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



[issue38792] IDLE calltips may not properly close on KeyboardInterrupt

2020-10-10 Thread Terry J. Reedy


Change by Terry J. Reedy :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

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



[issue38077] IDLE leaking ARGV into globals() namespace

2020-10-10 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

Since I opened the followup issue, yes.  Thanks for noticing.

--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

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



[issue41999] imaplib Time2Internaldate crashing with time.struct_time supplied from datetime.timetuple()

2020-10-10 Thread sajicek


New submission from sajicek :

Hello
first of all, I couldn't find any issue related to this, so sorry if it has 
been solved before.

There seems to be an issue with IMAPLIB in all versions I've checked, when 
using the Time2Internaldate function with time.struct_time created by 
datetime.timetuple() extracted from an EmailMessage object (using the 
email.utils.parsedate_to_datetime function), and even when created with 
datetime.now() the function crashes the app with
"TypeError: unsupported type for timedelta seconds component: NoneType"
on line 1530 in current master on GH. (delta = timedelta(seconds=gmtoff))

Crash happens because the "date_time.tm_gmtoff" from which the gmtoff variable 
is constructed, seems to default to None in all instances of time.struct_time 
object created by datetime.timetuple(), which still passes the try, except 
clausule on 1520, because it's not an AttributeError. The time.localtime() 
metioned in the docs asigns the correct value into tm_gmtoff, but the 
datetime.timetuple() does not.


Possible solutions I've found:
1) inside Time2Internaldate: surround the delta with try and except - in except 
make the delta = 0
2) inside Time2Internaldate: check the gmtoff for None and if yes, then change 
it to 0
3) change the default of tm_gmtoff in timetuple from None to 0 (or to a current 
timezone offset)

or just say in the docs, that time.struct_time created this way (using the 
datetime.timetuple()) is unsupported

PS: when writing this issue, I've started thinking this might be a datetime lib 
issue too

--
components: Library (Lib)
messages: 378409
nosy: sajicek
priority: normal
severity: normal
status: open
title: imaplib Time2Internaldate crashing with time.struct_time supplied from 
datetime.timetuple()
type: behavior
versions: Python 3.10, Python 3.5, Python 3.6, Python 3.7, Python 3.8, Python 
3.9

___
Python tracker 

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



[issue41986] Py_FileSystemDefaultEncodeErrors and Py_UTF8Mode are not available with limited API

2020-10-10 Thread miss-islington


miss-islington  added the comment:


New changeset ebc5a6b59ece48b490987bdaa2af842c29f5b2f8 by Miss Skeleton (bot) 
in branch '3.9':
bpo-41986: Add Py_FileSystemDefaultEncodeErrors and Py_UTF8Mode back to limited 
API (GH-22621)
https://github.com/python/cpython/commit/ebc5a6b59ece48b490987bdaa2af842c29f5b2f8


--

___
Python tracker 

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



[issue41986] Py_FileSystemDefaultEncodeErrors and Py_UTF8Mode are not available with limited API

2020-10-10 Thread miss-islington


miss-islington  added the comment:


New changeset ff6870f199511f09304e9d3ee7e7d8ed3902ffd1 by Miss Skeleton (bot) 
in branch '3.8':
bpo-41986: Add Py_FileSystemDefaultEncodeErrors and Py_UTF8Mode back to limited 
API (GH-22621)
https://github.com/python/cpython/commit/ff6870f199511f09304e9d3ee7e7d8ed3902ffd1


--

___
Python tracker 

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



[issue38792] IDLE calltips may not properly close on KeyboardInterrupt

2020-10-10 Thread Irit Katriel


Irit Katriel  added the comment:

This seems complete, can it be closed?

--
nosy: +iritkatriel

___
Python tracker 

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



[issue41986] Py_FileSystemDefaultEncodeErrors and Py_UTF8Mode are not available with limited API

2020-10-10 Thread miss-islington


Change by miss-islington :


--
nosy: +miss-islington
nosy_count: 2.0 -> 3.0
pull_requests: +21611
pull_request: https://github.com/python/cpython/pull/22637

___
Python tracker 

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



[issue41986] Py_FileSystemDefaultEncodeErrors and Py_UTF8Mode are not available with limited API

2020-10-10 Thread miss-islington


Change by miss-islington :


--
pull_requests: +21612
pull_request: https://github.com/python/cpython/pull/22638

___
Python tracker 

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



[issue41986] Py_FileSystemDefaultEncodeErrors and Py_UTF8Mode are not available with limited API

2020-10-10 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset 637a09b0d6e3ad4e34e0b5e0fc82f5afeae6f74b by Serhiy Storchaka in 
branch 'master':
bpo-41986: Add Py_FileSystemDefaultEncodeErrors and Py_UTF8Mode back to limited 
API (GH-22621)
https://github.com/python/cpython/commit/637a09b0d6e3ad4e34e0b5e0fc82f5afeae6f74b


--

___
Python tracker 

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



[issue41986] Py_FileSystemDefaultEncodeErrors and Py_UTF8Mode are not available with limited API

2020-10-10 Thread STINNER Victor


STINNER Victor  added the comment:

Python 3.7 defines it in fileobject.h as:

#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x0306
PyAPI_DATA(const char *) Py_FileSystemDefaultEncodeErrors;
#endif

#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x0307
PyAPI_DATA(int) Py_UTF8Mode;
#endif


Python 3.8 defines them the same way, but in Include/cpython/fileobject.h:

#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x0306
PyAPI_DATA(const char *) Py_FileSystemDefaultEncodeErrors;
#endif

#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x0307
PyAPI_DATA(int) Py_UTF8Mode;
#endif


I am likely the one who moved these definitions. It was a mistake to move them 
inside Include/cpython/, since "Py_LIMITED_API+0 >= 0x0307" became useless: 
cpython/fileobject.h is only included if Py_LIMITED_API is not defined.

In Include/cpython/, it seems like only 2 definitions are defined the wrong 
way, Py_FileSystemDefaultEncodeErrors and Py_UTF8Mode.

--

___
Python tracker 

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



[issue41997] Docs Standard Library index page has incorrect version in title

2020-10-10 Thread Patrick Reader


[issue41998] JSON Encoder Injection Using Indent

2020-10-10 Thread Dustin Moriarty


Dustin Moriarty  added the comment:

Sounds good. If this is the design intent, then we can close the issue.

--
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

___
Python tracker 

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



[issue41986] Py_FileSystemDefaultEncodeErrors and Py_UTF8Mode are not available with limited API

2020-10-10 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

It solves the breaking of the C API. Py_FileSystemDefaultEncodeErrors and 
Py_UTF8Mode were not deprecated, they were just suddenly excluded from the 
limited API. And seems this change was not intentional, otherwise surrounding 
#ifdef/#endif (which currently do not have effect) would be not preserved.

--

___
Python tracker 

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



[issue32885] Tools/scripts/pathfix.py leaves bunch of ~ suffixed files around with no opt-out

2020-10-10 Thread Miro Hrončok

Change by Miro Hrončok :


--
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

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



[issue41998] JSON Encoder Injection Using Indent

2020-10-10 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

The code works as expected. I do not think there is a problem with the json 
module. If some application accepts user input and use it without validation to 
control the formatting of sensitive data, it is a vulnerability in this 
application, not in tools which it uses.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue38077] IDLE leaking ARGV into globals() namespace

2020-10-10 Thread Irit Katriel


Irit Katriel  added the comment:

This seems complete, can it be closed?

--
nosy: +iritkatriel

___
Python tracker 

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



[issue41986] Py_FileSystemDefaultEncodeErrors and Py_UTF8Mode are not available with limited API

2020-10-10 Thread STINNER Victor


STINNER Victor  added the comment:

I consider the global configuration variables as deprecated. I would prefer to 
slowly move towards PyConfig, since almost all Python functions now use 
PyInterpreterState.config.

The problem is that my idea to provide a stable ABI for PyConfig was rejected:
https://mail.python.org/archives/list/python-...@python.org/thread/C7Z2NA2DTM3DLOZCFQAK5A2WFYO3PHHX/#2JAJQA5OANFPXAJ3327RRPHPQLKVP2EW

Which problem are you trying to solve your PR 22621?

--

___
Python tracker 

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



[issue32793] smtplib: duplicated debug message

2020-10-10 Thread Irit Katriel


Irit Katriel  added the comment:

Does this need to be backported to 3.8/3.7?

--
nosy: +iritkatriel

___
Python tracker 

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



[issue37461] email.parser.Parser hang

2020-10-10 Thread Irit Katriel


Irit Katriel  added the comment:

This seems complete, can it be closed?

--
nosy: +iritkatriel

___
Python tracker 

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



[issue41998] JSON Encoder Injection Using Indent

2020-10-10 Thread Dustin Moriarty


New submission from Dustin Moriarty :

It is possible to inject data while encoding json when a string is passed to 
the indent argument. 

Here is an example of an injection attack.

```python
import json

data = {"a": "original data"}
indent = '"b": "injected data",\n'
json_string = json.dumps(data, indent=indent)
print(json_string)
```

Output:
```
{
"b": "injected data",
"a": "original data"
}
```

This is a vulnerability because it is common for CLI and web frameworks to use 
string as the default data type for arguments. The vulnerability is more likely 
to be realized for CLI applications where there is more likely to be a use case 
for exposing the indent parameter to external users in order to control the 
json output. While this could be prevented by the application using the json 
encoder, the potential attach vector is not obvious or clear to developers. I 
cannot see any use case for allowing strings to be passed as indent, so I 
propose that indent is cast to integer on __init__ of the encoder. I will 
submit a corresponding PR.

--
components: Library (Lib)
messages: 378395
nosy: DustinMoriarty
priority: normal
severity: normal
status: open
title: JSON Encoder Injection Using Indent
type: security
versions: Python 3.10, Python 3.5, Python 3.6, Python 3.7, Python 3.8, Python 
3.9

___
Python tracker 

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



[issue41997] Docs Standard Library index page has incorrect version in title

2020-10-10 Thread Patrick Reader


New submission from Patrick Reader :

The documentation page for the Standard Library, 
https://docs.python.org/3/library/, still says "Python 3.8.6 documentation" in 
the title. When visiting https://docs.python.org/3.9/library/ (emphasis on the 
3.9) explicitly, the correct title is shown. I suspect there are other pages 
like this, perhaps ones that have not been modified since Python 3.8.6? This is 
possibly in fact some sort of bug in Sphinx, but I don't think so.

--
assignee: docs@python
components: Documentation
messages: 378394
nosy: docs@python, pxeger
priority: normal
severity: normal
status: open
title: Docs Standard Library index page has incorrect version in title
versions: Python 3.9

___
Python tracker 

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



[issue41980] Argparse documentation is slightly misleading

2020-10-10 Thread Yannick Gingras


Yannick Gingras  added the comment:

Raymond, I would love to submit the PR if we reach a consensus on what the new 
message should be.  I'm a bit out of touch with how things work these days.  Is 
Github the best place to submit the PR?

Paul, very good digging!  Reading the coding and running a few examples, I 
understand that the ``prog`` of the subparser is always the name of the main 
program with the name of the subcommand *unless* a usage string is supplied, in 
which case it overrides prog.  I suspect that the intent is to favour the 
programmer supplied usage string and that copying the usage string in the prog 
of the subparser is an implementation detail.   I think we can reword the 
documentation to describe the expected behavior with more emphasis on the 
common cases.

--

___
Python tracker 

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



[issue32885] Tools/scripts/pathfix.py leaves bunch of ~ suffixed files around with no opt-out

2020-10-10 Thread Irit Katriel


Irit Katriel  added the comment:

Please change status to closed as well. Thanks.

--

___
Python tracker 

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



[issue32885] Tools/scripts/pathfix.py leaves bunch of ~ suffixed files around with no opt-out

2020-10-10 Thread Miro Hrončok

Change by Miro Hrončok :


--
resolution:  -> fixed

___
Python tracker 

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



[issue41995] five possible Null Pointer Dereference bugs.

2020-10-10 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
nosy: +p-ganssle

___
Python tracker 

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



[issue40064] py38: document xml.etree.cElementTree will be removed in 3.9

2020-10-10 Thread Emmanuel Arias


Emmanuel Arias  added the comment:

Hi, 

This ticket should be closed or updated.

see disussion https://bugs.python.org/issue36543

--
nosy: +eamanu

___
Python tracker 

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



[issue41995] five possible Null Pointer Dereference bugs.

2020-10-10 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
nosy: +vstinner
versions: +Python 3.10 -Python 3.5, 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



[issue41996] Should `make install` still install to /usr/bin/python3?

2020-10-10 Thread Eric V. Smith


Eric V. Smith  added the comment:

There's a PEP for this: PEP 394. If you want to change this, I suggest 
discussing it on the python-dev mailing list. If that leads to changes in the 
PEP, this issue can be re-opened.

Personally I don't see this change happening until there are no systems left 
that install python2 as /usr/bin/python. Which is unfortunate, but such is 
life. Myself, I have a shell alias for python that points to python3. That 
solves 95% of my problems.

--
nosy: +eric.smith
resolution:  -> postponed
stage:  -> resolved
status: open -> closed

___
Python tracker 

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



[issue27141] Fix collections.UserList shallow copy

2020-10-10 Thread Bar Harel


Change by Bar Harel :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

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



[issue41992] Unable to install lxml using pip in Python 3.9

2020-10-10 Thread Eric V. Smith


Eric V. Smith  added the comment:

Closing as third party.

--
nosy: +eric.smith
resolution:  -> third party
stage:  -> resolved
status: open -> closed

___
Python tracker 

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



[issue41996] Should `make install` still install to /usr/bin/python3?

2020-10-10 Thread Emmanuel Arias


Emmanuel Arias  added the comment:

Hi,

There're many people that still use py2, or both.
Also python2 (python) is incompatible with python3, so we cannot
call python == python3.

(There was some discussion on Debian, just if you want take a look
https://lists.debian.org/debian-python/2020/07/msg00042.html)

--
nosy: +eamanu

___
Python tracker 

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



[issue41996] Should `make install` still install to /usr/bin/python3?

2020-10-10 Thread Patrick Reader


New submission from Patrick Reader :

Since Python 2 is now finally gone, should the Python executable not be 
installed to simply `/usr/bin/python` rather than `/usr/bin/python3` when 
running `make install`?

--
components: Installation
messages: 378387
nosy: pxeger
priority: normal
severity: normal
status: open
title: Should `make install` still install to /usr/bin/python3?
type: enhancement

___
Python tracker 

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



[issue41992] Unable to install lxml using pip in Python 3.9

2020-10-10 Thread Jürgen Gmach

Jürgen Gmach  added the comment:

There is no Python 3.9 compatible package on PyPI yet ( 
https://pypi.org/project/lxml/#files ).

I guess you have to wait a bit more until there will be a new release.

Also, this is the cpython issue tracker. When you have problems with a specific 
package, it is best to seek help at their issue tracker. For lxml this would be 
https://launchpad.net/lxml

Actually, there is already an issue on their tracker about support for Python 
3.9
https://bugs.launchpad.net/lxml/+bug/1892261

I suggest to close this issue here.

--
nosy: +jugmac00

___
Python tracker 

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



[issue41995] five possible Null Pointer Dereference bugs.

2020-10-10 Thread Roundup Robot


Change by Roundup Robot :


--
keywords: +patch
nosy: +python-dev
nosy_count: 1.0 -> 2.0
pull_requests: +21610
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/22635

___
Python tracker 

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



[issue41995] five possible Null Pointer Dereference bugs.

2020-10-10 Thread brightest star


New submission from brightest star :

Hello everyone,

I have found five Null Pointer Dereference bugs in recent master branch.
Although it's impact could be slightly, i think it is better to fix it.

Bug 1:
In the file ; ./Modules/_tracemalloc.c:
static int
tracemalloc_copy_trace(_Py_hashtable_t *traces,
   const void *key, const void *value,
   void *user_data)
{
_Py_hashtable_t *traces2 = (_Py_hashtable_t *)user_data;

trace_t *trace = (trace_t *)value;

1201:trace_t *trace2 = raw_malloc(sizeof(trace_t));
1202:if (traces2 == NULL) {  <-
return -1;
}
1205:   *trace2 = *trace;
...
return 0;
}
At line 1201, we malloc a varible 'trace2' and then we should check whether the 
varible 'trace2' is NULL. But it checks 'traces2'(not 'trace2') in line 1202. 
The varible 'trace2' still could be NULL.I think it is a spelling mistake.

Bug 2 and 3:
In the file :Modules/_zoneinfo.c

static int
load_data(PyZoneInfo_ZoneInfo *self, PyObject *file_obj)
{
...
908: self->trans_list_utc =
PyMem_Malloc(self->num_transitions * sizeof(int64_t));
910:trans_idx = PyMem_Malloc(self->num_transitions * sizeof(Py_ssize_t));
...
}
Line 908 alloc a memory to 'self->trans_list_utc' and line 910 alloc a memory 
to 'trans_idx'. But the paramters passed to PyMem_Malloc are not fixed,it means 
that we possible could control the size to malloc. If we pass a big size to 
PyMem_Malloc, it will return NULL.
So,we should add some checks for 'self->trans_list_utc' and 'trans_idx',such as 
if (self->trans_list_utc == NULL) {
goto error;
}

Bug 4 and 5:
In the file :Modules/_zoneinfo.c

The problem same to bug 3 and 4.
line 991:self->_ttinfos = PyMem_Malloc(self->num_ttinfos * sizeof(_ttinfo));
line 1005:   self->trans_ttinfos =
PyMem_Calloc(self->num_transitions, sizeof(_ttinfo *));

We should add some checks below these lines.

--
components: Extension Modules
messages: 378385
nosy: brightest3379
priority: normal
severity: normal
status: open
title: five possible Null Pointer Dereference bugs.
type: behavior
versions: Python 3.5, Python 3.6, Python 3.7, Python 3.8, Python 3.9

___
Python tracker 

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



[issue41994] Refcount issues in import

2020-10-10 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
keywords: +patch
pull_requests: +21609
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/22632

___
Python tracker 

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



[issue41994] Refcount issues in import

2020-10-10 Thread Serhiy Storchaka


New submission from Serhiy Storchaka :

There is a reference leak in import_add_module(). PyDict_GetItemWithError() 
returns a borrowed reference, but PyObject_GetItem() return a non-borrowed 
reference. If sys.modules is not a dict, there is a reference leak. 
import_add_module() and several other function which return a borrowed 
reference should be made returning a non-borrowed reference, because there are 
no guaranties that general mapping keeps reference to value.

It is still not guarantee correctness of PyImport_AddModuleObject().

--
components: Interpreter Core
messages: 378384
nosy: brett.cannon, eric.snow, ncoghlan, serhiy.storchaka
priority: normal
severity: normal
status: open
title: Refcount issues in import
type: resource usage
versions: Python 3.10, Python 3.9

___
Python tracker 

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



[issue41993] Possible issues when remove not completely initialized module from sys.module

2020-10-10 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
keywords: +patch
pull_requests: +21608
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/22631

___
Python tracker 

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



[issue32885] Tools/scripts/pathfix.py leaves bunch of ~ suffixed files around with no opt-out

2020-10-10 Thread Irit Katriel


Irit Katriel  added the comment:

This seems complete, can it be closed?

--
nosy: +iritkatriel

___
Python tracker 

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



[issue41993] Possible issues when remove not completely initialized module from sys.module

2020-10-10 Thread Serhiy Storchaka


New submission from Serhiy Storchaka :

There are several issues in remove_module() in Python/import.c.

1. PyMapping_HasKey() is used to determine if the module was in sys.modules 
before removing it. But it can return 0 not only when the key is absent in the 
mapping, but also when some exceptions was raised during checking (including 
MemoryError, KeybordInterraption and RecursionError). The corresponding 
exception will be silenced and the module will be left in sys.modules.

2. If PyMapping_DelItem() fails, a RuntimeError is raised. It is chained with 
the exception raised in PyMapping_DelItem(), but the original exception, raised 
before calling remove_module() will be lost.

3. There is a possible race condition between PyMapping_HasKey() and 
PyMapping_DelItem().

--
components: Interpreter Core
messages: 378382
nosy: brett.cannon, eric.snow, ncoghlan, serhiy.storchaka
priority: normal
severity: normal
status: open
title: Possible issues when remove not completely initialized module from 
sys.module
type: behavior
versions: Python 3.10, Python 3.8, Python 3.9

___
Python tracker 

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



[issue26835] Add file-sealing ops to fcntl

2020-10-10 Thread Irit Katriel


Irit Katriel  added the comment:

This seems complete, can it be closed?

--
nosy: +iritkatriel

___
Python tracker 

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



[issue41756] Do not always use exceptions to return result from coroutine

2020-10-10 Thread Mark Shannon


Mark Shannon  added the comment:

Vladimir,
Thanks for adding PyIter_Send().

Don't forget to remove PyGen_Send() :)

--

___
Python tracker 

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



[issue36520] Email header folded incorrectly

2020-10-10 Thread Irit Katriel


Irit Katriel  added the comment:

This seems complete, can it be closed?

--
nosy: +iritkatriel

___
Python tracker 

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



[issue38605] [typing] PEP 563: Postponed evaluation of annotations: enable it by default in Python 3.10

2020-10-10 Thread Batuhan Taskaya


Change by Batuhan Taskaya :


--
pull_requests: +21607
pull_request: https://github.com/python/cpython/pull/22630

___
Python tracker 

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



[issue33972] AttributeError in email.message.iter_attachments()

2020-10-10 Thread Irit Katriel


Irit Katriel  added the comment:

This seems complete, can it be closed?

--
nosy: +iritkatriel

___
Python tracker 

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



[issue41992] Unable to install lxml using pip in Python 3.9

2020-10-10 Thread Aruna Gopalan


New submission from Aruna Gopalan :

Installed Python 3.9 from Python.org
Tried installing lxml package using the command
"pip install lxml"
It complains that it is unable to do so without libxml2 (which is not a python 
package). I do not have the same issue with 3.8.6.

--
components: Library (Lib)
messages: 378377
nosy: agopalan
priority: normal
severity: normal
status: open
title: Unable to install lxml using pip in Python 3.9
type: behavior
versions: Python 3.9

___
Python tracker 

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



[issue37840] bytearray_getitem() handles negative index incorrectly

2020-10-10 Thread Irit Katriel


Irit Katriel  added the comment:

This seems complete, can it be closed?

--
nosy: +iritkatriel

___
Python tracker 

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



[issue38110] Use fdwalk() within os.closerange() impl if available

2020-10-10 Thread Irit Katriel


Irit Katriel  added the comment:

This seems complete, can it be closed?

--
nosy: +iritkatriel

___
Python tracker 

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



[issue38605] [typing] PEP 563: Postponed evaluation of annotations: enable it by default in Python 3.10

2020-10-10 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

test_grammar and test_pydoc became failed on my machine until I removed all 
.pyc files. We need to bump the magic number for .pyc files.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue26067] test_shutil fails when gid name is missing

2020-10-10 Thread Irit Katriel


Irit Katriel  added the comment:

This seems complete, can it be closed?

--
nosy: +iritkatriel

___
Python tracker 

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



[issue41972] bytes.find consistently hangs in a particular scenario

2020-10-10 Thread Dennis Sweeney


Dennis Sweeney  added the comment:

I agree that skip could could do 1 better.

---

> I don't know whether it "should be" applied

I don't think I'm convinced: the second check fixes only the very specific case 
when s[len(p):].startswith(p).
Perturbations of reproducer.py are still very slow with the patch:

- pattern2 = b"B" * BIG
+ pattern2 = b"B" * (BIG + 10)

In fact, it's even slower than before due to the double-checking.

---

I'd be curious how something like Crochemore and Perrin's "two-way" algorithm 
would do (constant space, compares < 2n-m):

http://www-igm.univ-mlv.fr/~lecroq/string/node26.html#SECTION00260
https://en.wikipedia.org/wiki/Two-way_string-matching_algorithm

Apparently it's been used as glibc's memmem() since 2008. There, it 
additionally computes a table, but only for long needles where it really pays 
off:

https://code.woboq.org/userspace/glibc/string/str-two-way.h.html
https://code.woboq.org/userspace/glibc/string/memmem.c.html

Although there certainly seems to be a complexity rabbithole here that would be 
easy to over-do.
I might look more into this.

--

___
Python tracker 

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



[issue41991] Remove _PyObject_HasAttrId

2020-10-10 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

This function was kept after previous clean because all its usages was in the 
code which silences all exceptions in any case, so using _PyObject_HasAttrId 
did not do additional harm. But now it is used also in the new code in 
Objects/unionobject.c. It is safer to not only fix Objects/unionobject.c, but 
remove _PyObject_HasAttrId at all.

--
nosy: +pablogsal, vstinner

___
Python tracker 

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



[issue41991] Remove _PyObject_HasAttrId

2020-10-10 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
keywords: +patch
pull_requests: +21606
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/22629

___
Python tracker 

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



[issue41991] Remove _PyObject_HasAttrId

2020-10-10 Thread Serhiy Storchaka


New submission from Serhiy Storchaka :

_PyObject_HasAttrId() can return -1, 0 or 1. It returns -1 when cannot create a 
string (most likely due to MemoryError or UnicodeDecodeError), but returns 0 
and silences all exceptions raised when look up the attribute (including 
MemoryError, KeybordInterruptError and RecursionError). Silencing arbitrary 
exceptions is bad, and the interface of the function is inconsistent, so it is 
better to remove it and replace all 5 of its occurrences in 3 files with 
_PyObject_LookupAttrId(). It is private API, so we can do it without breaking 
user code.

--
components: Interpreter Core
messages: 378370
nosy: serhiy.storchaka
priority: normal
severity: normal
status: open
title: Remove _PyObject_HasAttrId
type: behavior
versions: Python 3.10, Python 3.8, Python 3.9

___
Python tracker 

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



[issue41980] Argparse documentation is slightly misleading

2020-10-10 Thread paul j3


paul j3  added the comment:

For ArgumentParser, prog is defined as:

prog - The name of the program (default: sys.argv[0])

The comment in the `add_subparsers` method is:

   # prog defaults to the usage message of this parser, skipping
   # optional arguments and with no "usage:" prefix

if kwargs.get('prog') is None:
formatter = self._get_formatter()
positionals = self._get_positional_actions()
groups = self._mutually_exclusive_groups
formatter.add_usage(self.usage, positionals, groups, '')
kwargs['prog'] = formatter.format_help().strip()

and this keyword is saved as the action `self._prog_prefix.

Later in `add_parser` this is amended with:

 kwargs['prog'] = '%s %s' % (self._prog_prefix, name)

The intent is to provide the string required to run a particular subparser 
(sub-command), the `prog` of the main, positionals, and the subcommand. (It 
doesn't handle all 'required' arguments correctly.) 

The programmer has three places where they can customize this 'prog'.

So the default 'prog' as the 'add_subarsers' level is indeed just the main 
'prog' plus 'positionals'.  The default 'prog' display with the subcommand 
usage add the subcommand's name.

It's a complicated sequence, but I think the description for the 
'add_subparsers' 'prog' is enough.

--

___
Python tracker 

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



[issue41990] venv module clashes with pip --user ... improve coordination.

2020-10-10 Thread Bernd Wechner


New submission from Bernd Wechner :

When developing Python software it is highly discouraged to install python 
modules globally (risking adverse impacts upon the underlying OS where if has 
Python dependencies).

Project by project this typically done with venvs (and the venv module)

User by user it is typically done with the --user option.

In fact to make impacting system libraries less likely a pip.conf file can be 
written that contains:

[install]
user = true

I suspect this is an increasingly common practice which means pip installs are 
on a local user profile not into system dirs. 

Alas when in a venv now, pip bombs with a detected conflict:

ERROR: Can not perform a '--user' install. User site-packages are not visible 
in this virtualenv.

This was explored with pip here:

https://github.com/pypa/pip/issues/8977

It turns out that pip can be made to function by overriding this setting in the 
venv. That is depositing a pip.conf in the vend dir that contains:

[install]
user = true

and all is good once more. In the activated venv pip now works again. 

This is at its core a coordination issue then between the venv module and pip 
and the point to fix it seems most likely to be in the venv module which, 
knowing that this conflict can exist can as a safety precaution simply always, 
or optionally, write a pip.conf into newly created venvs that disables the user 
options. Given pip won't work in a venv if that option is enabled and we know 
that up front.

Why fix it in the venv module? Because discovering the cause of this conflict 
was time consuming and disorienting, poor UX by any definition and it should 
ideally not arise or if it must have an easily discovered fix. 

This is a request to prevent it arising altogether in newly created venvs.

--
components: Library (Lib)
messages: 378368
nosy: bernd.wechner
priority: normal
severity: normal
status: open
title: venv module clashes with pip --user ... improve coordination.
type: behavior
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



[issue40814] Update typing module documentation based on PEP 585

2020-10-10 Thread Guido van Rossum

Guido van Rossum  added the comment:

Yes, let’s document __args__ and __origin__.

--

___
Python tracker 

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



[issue33431] Change description about doc in programming, faq.

2020-10-10 Thread lvhuiyang


lvhuiyang  added the comment:

I has forgotten why I abandon the PR.

Sorry I have no time to follow up the issue recently. Would you like go on if 
you are interest in the issue?

--
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

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