[issue43620] os.path.join does not use os.sep as documentation claims

2021-03-25 Thread Fred Drake


Fred Drake  added the comment:

Just reviewed the documentation for both os.sep and os.path.join().

The os.sep docs do not suggest it can be set, and the reference in the 
os.path.join() description is silent regarding that, so can be read as Jared 
did.  I don't recall this coming up before, but... there's a lot I don't 
remember at this point.  --sigh--

Removing the reference to os.sep from the os.path.join() description would not 
be confusing, IMO.  Clearly, the ambiguity can bite.

I'd be open to a patch to remove the reference to os.sep from the 
os.path.join() docs.  Reopening, but removing 3.6 and 3.7 since they're in 
security-fix-only mode.

--
keywords: +easy
resolution: not a bug -> 
stage: resolved -> needs patch
status: closed -> open
versions:  -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



[issue40066] Enum: modify __repr__, __str__; update docs

2021-03-25 Thread Ethan Furman


Change by Ethan Furman :


--
components: +Library (Lib)
title: Enum._convert should change __repr__ and/or __str__ to use module name 
instead of class name -> Enum: modify __repr__, __str__; update docs

___
Python tracker 

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



[issue43629] fix _PyRun_SimpleFileObject create __main__ module and cache. Call this function multiple times, the attributes stored in the module dict will affect eachother.

2021-03-25 Thread junyixie


Change by junyixie :


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

___
Python tracker 

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



[issue43629] fix _PyRun_SimpleFileObject create __main__ module and cache. Call this function multiple times, the attributes stored in the module dict will affect eachother.

2021-03-25 Thread junyixie


New submission from junyixie :

fix _PyRun_SimpleFileObject create __main__ module and cache. Call this 
function multiple times, the attributes stored in the module dict will affect 
eachother.

create __main__ module, and cache it.

for example. 
if we run fileA, call _PyRun_SimpleFileObject will create __main__ module, 
fileA add some attribute in __main__ module dict.

now we run fileB. call _PyRun_SimpleFileObject will load cached __main__ 
module. now in __main__ module dict, we can get fileA's attribute.


dir(module), We got unexpected results
```
for name in dir(module):
...
```

in unittest, if we execute test, and don't exit. (unittest main.py 
TestProgram), set exit=False.
```
def __init__(self, module='__main__', defaultTest=None, argv=None,
testRunner=None, testLoader=loader.defaultTestLoader,
exit=True, verbosity=1, failfast=None, catchbreak=None,
buffer=None, warnings=None, *, tb_locals=False):
```

then when unittest load tests. if we use _PyRun_SimpleFileObject to run 
unittest, it will Repeated load test cases
```
for name in dir(module):
obj = getattr(module, name)
if isinstance(obj, type) and issubclass(obj, case.TestCase):
tests.append(self.loadTestsFromTestCase(obj))
```


```
int
_PyRun_SimpleFileObject(FILE *fp, PyObject *filename, int closeit,
PyCompilerFlags *flags)
{
PyObject *m, *d, *v;
int set_file_name = 0, ret = -1;

m = PyImport_AddModule("__main__");
if (m == NULL)
return -1;
Py_INCREF(m);
d = PyModule_GetDict(m);
```

--
components: C API
messages: 389538
nosy: JunyiXie
priority: normal
severity: normal
status: open
title: fix _PyRun_SimpleFileObject create __main__ module and cache. Call this 
function multiple times, the attributes stored in the module dict will affect 
eachother.
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



[issue40758] For 7.2.7. Code Examples, distinguish between the Tutorial and other documentation

2021-03-25 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

I would think this would go without saying.  The word "tutorial" means example 
driven instruction.  Previous to now, no one has ever reported confusion about 
this.

--
nosy: +rhettinger

___
Python tracker 

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



[issue43628] Incorrect argument errors for random.getstate()

2021-03-25 Thread Raymond Hettinger

Raymond Hettinger  added the comment:

Here's how to use getstate() and setstate():

>>> import random
>>> state = random.getstate()
>>> random.choices('ABCDE', k=8)
['E', 'A', 'B', 'B', 'A', 'A', 'E', 'D']
>>> # restore the previous state
>>> random.setstate(state)
>>> # now, replay the random selections
>>> random.choices('ABCDE', k=8)
['E', 'A', 'B', 'B', 'A', 'A', 'E', 'D']



> 1. Is the TypeError correct? This should be an inconsistent
> argument number error. There is nothing to do with Type. 

Yes, it is correct, but I agree that it is unintuitive.  It just happens to be 
the Python way to report an incorrect number of arguments as a TypeError.


> 2. Is the detailed error correct? Doc says random.getstate()
> takes 0 argument, the reported error says getstate() take 1
> positional argument. which is inconsistent. 

This is an artifact of how Python implements object orient programming.  No one 
really likes this, but at some level it can be viewed as being technically 
correct — methods prepend an instance argument before calling an underlying 
function which reports on the number of arguments that it sees.  Presumably, if 
there were a straight-forward way of improving the error message, it would have 
been done long ago.

> Besides, I pass one argument to random.getstate(), 
> but the reported error says 2 were given.

Don't pass any arguments into getstate().


> random.getstate() takes 0 argument and return 
> the current setting for the weekday to start each week.

This part doesn't make sense to me.  Why do you think it accepts or returns a 
weekday?

--
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



[issue43628] Incorrect argument errors for random.getstate()

2021-03-25 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
nosy: +mark.dickinson, rhettinger

___
Python tracker 

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



[issue43628] Incorrect argument errors for random.getstate()

2021-03-25 Thread Yang Feng

New submission from Yang Feng :

In documentation of random.getstate(), it says:
“random.getstate()
Return an object capturing the current internal state of the generator. This 
object can be passed to setstate() to restore the state.”

random.getstate() takes 0 argument and return the current setting for the 
weekday to start each week. However, when I give one argument to 
random.getstate(), the interpreter reports the following error:
--
>>> import random
>>> random.getstate(1)
Traceback (most recent call last):
File "", line 1, in 
TypeError: getstate() takes 1 positional argument but 2 were given
--

Here I have two doubts about the reported errors:
1. Is the TypeError correct? This should be an inconsistent argument number 
error. There is nothing to do with Type. 
2. Is the detailed error correct? Doc says random.getstate() takes 0 argument, 
the reported error says getstate() take 1 positional argument. which is 
inconsistent. Besides, I pass one argument to random.getstate(), but the 
reported error says 2 were given.


Environment: Python 3.10, Ubuntu 16.04

--
assignee: docs@python
components: Documentation
messages: 389535
nosy: CharlesFengY, docs@python
priority: normal
severity: normal
status: open
title: Incorrect argument errors for random.getstate()
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



[issue43624] Add underscore as a decimal separator for string formatting

2021-03-25 Thread Eric V. Smith


Eric V. Smith  added the comment:

If we do anything for float, we should do the same for decimal.Decimal.

--

___
Python tracker 

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



[issue43624] Add underscore as a decimal separator for string formatting

2021-03-25 Thread Eric V. Smith


Change by Eric V. Smith :


--
nosy: +eric.smith

___
Python tracker 

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



[issue39418] str.strip() should have a means of adding to the default behaviour

2021-03-25 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Marking this as closed because the issue doesn't seem to have gathered much 
interest.  If someone wants to move this forward, I recommend discussing it on 
python-ideas.

--
resolution:  -> rejected
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



[issue43620] os.path.join does not use os.sep as documentation claims

2021-03-25 Thread Jared Sutton


Jared Sutton  added the comment:

> Perhaps Jared was expecting that modifying os.sep would affect the functions 
> in os.path?

This is precisely what I thought, because the documentation makes it sound like 
that variable named os.sep is read and used as the path delimiter when 
constructing something with join(). In fact, that variable isn't read *at all* 
because the path separator is hard-coded in both posixpath.py and ntpath.py. 
Since os.sep isn't used, I see no reason why it should be referenced in the 
documentation at all.

I'm not trying to be pedantic here (though we nerds are famous for that :) ), 
but what I see here is a disagreement between what is documented and what 
actually exists in the implementation. Yes the *value* of os.sep happens to be 
the same as the one hard-coded into either ntpath or posixpath, but since that 
variable is not referenced in the implementation, its presence in the doc only 
serves to confuse people who take the documentation at face value and then get 
an unexpected result.

--

___
Python tracker 

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



[issue40758] For 7.2.7. Code Examples, distinguish between the Tutorial and other documentation

2021-03-25 Thread Irit Katriel


Change by Irit Katriel :


--
assignee:  -> docs@python
components: +Documentation
nosy: +docs@python
versions:  -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



[issue39418] str.strip() should have a means of adding to the default behaviour

2021-03-25 Thread Irit Katriel


Irit Katriel  added the comment:

In python 3.9 there is also str.removeprefix:
https://docs.python.org/3/library/stdtypes.html#str.removeprefix
which you can apply in a loop.

--
components: +Library (Lib)
nosy: +iritkatriel

___
Python tracker 

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



[issue38241] doc: Pickle with protocol=0 in python 3 does not produce a 'human-readable' format

2021-03-25 Thread Irit Katriel


Change by Irit Katriel :


--
assignee:  -> docs@python
components: +Documentation
nosy: +docs@python
title: Pickle with protocol=0 in python 3 does not produce a 'human-readable' 
format -> doc: Pickle with protocol=0 in python 3 does not produce a 
'human-readable' format
versions: +Python 3.10, Python 3.8, Python 3.9 -Python 3.7

___
Python tracker 

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



[issue21297] csv.skipinitialspace only skips spaces, not "whitespace" in general

2021-03-25 Thread Irit Katriel


Change by Irit Katriel :


--
versions: +Python 3.10, Python 3.8, Python 3.9 -Python 2.7, Python 3.4, Python 
3.5, Python 3.6

___
Python tracker 

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



[issue35816] csv.DictReader, skipinitialspace does not ignore tabs

2021-03-25 Thread Irit Katriel


Change by Irit Katriel :


--
components: +Library (Lib)
versions: +Python 3.10 -Python 3.5

___
Python tracker 

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



[issue43618] random.shuffle loses most of the elements

2021-03-25 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

As an immediate fix to your problem, replace this line:

random.shuffle(questions_element)

with:

questions = list(questions_element)
random.shuffle(questions)
questions_element[:] = questions

--

___
Python tracker 

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



[issue43624] Add underscore as a decimal separator for string formatting

2021-03-25 Thread Dominic Davis-Foster


Dominic Davis-Foster  added the comment:

ISO 8-1:2009 recommends groups of three digits either side of the decimal 
sign.

--
nosy: +domdfcoding

___
Python tracker 

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



[issue43627] What are the requirements for a test_sundry-testable script in Tools/scripts?

2021-03-25 Thread Skip Montanaro


Change by Skip Montanaro :


--
title: What are the requirements for a test_sunry-testable script in 
Tools/scripts? -> What are the requirements for a test_sundry-testable script 
in Tools/scripts?

___
Python tracker 

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



[issue43625] CSV has_headers heuristic could be improved

2021-03-25 Thread Skip Montanaro


Skip Montanaro  added the comment:

I assume the OP is referring to this sort of usage:

>>> sniffer = csv.Sniffer()
>>> raw = open("mixed.csv").read()
>>> sniffer.has_header(raw)
False

*sigh*

I really wish the Sniffer class had never been added to the CSV module. I can't 
recall who wrote it (the author is long gone). Though I am responsible for the 
initial commits, it wasn't me or the main authors of csvmodule.c. As far as I 
know, it never really worked well. I can't recall ever using it.

A simpler heuristic would be if the first row contains a bunch of strings and 
the second row contains a bunch of numbers, then the file has a header. That 
assumes that CSV files consist mostly of numeric data.

Looking at has_header, I see this:

for thisType in [int, float, complex]:

I think this particular problem would be solved if the order of those types 
were reversed. The attached diff suggests that as well. Note that the Sniffer 
class currently contains no test cases, so that the test I added failed before 
the change and passes after doesn't mean it doesn't break someone's mission 
critical Sniffer usage.

(Sorry, Raymond. My Github-foo is insufficient to allow me to fork, apply the 
diff and create a PR.)

--
keywords: +patch
Added file: https://bugs.python.org/file49915/csv.diff

___
Python tracker 

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



[issue40521] [subinterpreters] Make free lists and unicode caches per-interpreter

2021-03-25 Thread STINNER Victor


STINNER Victor  added the comment:

I reopen the issue to remind me that collections.deque() freelist is shared by 
all interpreters.

--
resolution: fixed -> 
status: closed -> open

___
Python tracker 

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



[issue43627] What are the requirements for a test_sunry-testable script in Tools/scripts?

2021-03-25 Thread Skip Montanaro


New submission from Skip Montanaro :

In my fork of python/cpython I recently created a simple script to help me with 
my work (I am messing around in the internals and sometimes get blindsided by 
opcode changes). I stuck the script in Tools/script which caused 
test_tools.test_sundry to hang. (I suspect it's because my script reads from 
sys.stdin, but I'm not certain. The old Unix pipeline ways die hard.)

Looking around to see how I could modify my script to make it acceptable to 
test_sundry, I saw nothing about requirements. I tossed it in the 
TestSundryScripts.other list and now that test completes. Still, it seems there 
should be a bit written about what it takes for a script to be amenable to the 
minimal testing test_sundry.py performs.

--
components: Tests
messages: 389526
nosy: skip.montanaro
priority: normal
severity: normal
status: open
title: What are the requirements for a test_sunry-testable script in 
Tools/scripts?
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



[issue40521] [subinterpreters] Make free lists and unicode caches per-interpreter

2021-03-25 Thread Raymond Hettinger


Raymond Hettinger  added the comment:


New changeset 3bb19873abd572879cc9a8810b1db9db1f704070 by Raymond Hettinger in 
branch 'master':
Revert "bpo-40521: Remove freelist from collections.deque() (GH-21073)" 
(GH-24944)
https://github.com/python/cpython/commit/3bb19873abd572879cc9a8810b1db9db1f704070


--

___
Python tracker 

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



[issue43625] CSV has_headers heuristic could be improved

2021-03-25 Thread Raymond Hettinger


Change by Raymond Hettinger :


--
nosy: +rhettinger

___
Python tracker 

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



[issue43625] CSV has_headers heuristic could be improved

2021-03-25 Thread Raymond Hettinger


Change by Raymond Hettinger :


--
nosy: +skip.montanaro

___
Python tracker 

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



[issue43511] tkinter with Tk 8.6.11 is slow on macOS

2021-03-25 Thread Christopher A. Chavez


Change by Christopher A. Chavez :


--
nosy: +chrstphrchvz

___
Python tracker 

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



[issue24605] segmentation fault at asciilib_split_char.lto_priv

2021-03-25 Thread STINNER Victor


Change by STINNER Victor :


--
resolution:  -> out of date
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



[issue24605] segmentation fault at asciilib_split_char.lto_priv

2021-03-25 Thread STINNER Victor


STINNER Victor  added the comment:

No activity for 6 years, the reporter didn't provide any way to reproduce the 
crash, I close the issue.

Note: Python 3.10 now dumps the list of third party C extensions on a fatal 
error, or when faulthandler handlers a crash ;-) Just enabled the Python 
Development Mode:
https://docs.python.org/dev/library/devmode.html

--
status: pending -> open

___
Python tracker 

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



[issue43609] ast.unparse-ing a FunctionType gives ambiguous result

2021-03-25 Thread midori


midori  added the comment:

@BTaskaya I've seen this in third party ides and type checker. For example they 
are referring to "Union[Callable[[], Union[int, str]], None]" as "() -> (int | 
str) | None" where there are parentheses around the returns.

--

___
Python tracker 

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



[issue43624] Add underscore as a decimal separator for string formatting

2021-03-25 Thread STINNER Victor


Change by STINNER Victor :


--
nosy: +vstinner

___
Python tracker 

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



[issue43626] SIGSEV in PyErr_SetObject

2021-03-25 Thread STINNER Victor


STINNER Victor  added the comment:

> What can be happening? How can I help to debug this?

Try to run your application in the Python Debug Mode: 
https://docs.python.org/dev/library/devmode.html

The best is if you can run your application with a Python built in debug mode.

Usually, it's a bug in a 3rd party C extension.

See also: https://pythondev.readthedocs.io/debug_tools.html

--
nosy: +vstinner

___
Python tracker 

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



[issue43620] os.path.join does not use os.sep as documentation claims

2021-03-25 Thread Eryk Sun


Eryk Sun  added the comment:

Fred, do you think this needs to be reopened to clarify that os.sep and 
os.altsep are not parameters for the ntpath and posixpath modules? 

I would have thought that the note at the top (path name conventions, etc) 
would be sufficient to let someone know that os.path is meant for working with 
paths on the current platform. Working with Windows paths in POSIX, and vice 
versa, is not simply a matter of replacing os.sep. For example:

>>> posixpath.join('C:/spam', '/eggs')
'/eggs'
>>> ntpath.join('C:/spam', '/eggs')
'C:/eggs'

--

___
Python tracker 

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



[issue43626] SIGSEV in PyErr_SetObject

2021-03-25 Thread Abraham Macias


New submission from Abraham Macias :

Hi, I'm dealing with random crashes when using pymongo in Python 3.7.3 in a 
Debian Buster.

This is the python backtrace:
(gdb) thread apply all py-bt

Thread 2 (Thread 0x7f9817d95700 (LWP 221)):
Traceback (most recent call first):
  File "/usr/local/lib/python3.7/dist-packages/gevent/_threading.py", line 80, 
in wait
waiter.acquire() # Block on the native lock
  File "/usr/local/lib/python3.7/dist-packages/gevent/_threading.py", line 162, 
in get
self._not_empty.wait()
  File "/usr/local/lib/python3.7/dist-packages/gevent/threadpool.py", line 270, 
in _worker
task = task_queue.get()
  File "/usr/local/lib/python3.7/dist-packages/gevent/threadpool.py", line 254, 
in __trampoline
g.switch()

Thread 1 (Thread 0x7f981fdfd740 (LWP 216)):
Traceback (most recent call first):
  
  File "/usr/local/lib/python3.7/dist-packages/bson/__init__.py", line 1089, in 
_decode_all_selective
return decode_all(data, codec_options)
  File "/usr/local/lib/python3.7/dist-packages/pymongo/message.py", line 1616, 
in unpack_response
self.payload_document, codec_options, user_fields)
  File "/usr/local/lib/python3.7/dist-packages/pymongo/cursor.py", line 1080, 
in _unpack_response
legacy_response)
  File "/usr/local/lib/python3.7/dist-packages/pymongo/server.py", line 131, in 
run_operation_with_response
user_fields=user_fields)
  File "/usr/local/lib/python3.7/dist-packages/pymongo/mongo_client.py", line 
1366, in _cmd
unpack_res)
  File "/usr/local/lib/python3.7/dist-packages/pymongo/mongo_client.py", line 
1471, in _retryable_read
return func(session, server, sock_info, slave_ok)
  File "/usr/local/lib/python3.7/dist-packages/pymongo/mongo_client.py", line 
1372, in _run_operation_with_response
exhaust=exhaust)
  File "/usr/local/lib/python3.7/dist-packages/pymongo/cursor.py", line 1001, 
in __send_message
address=self.__address)
  File "/usr/local/lib/python3.7/dist-packages/pymongo/cursor.py", line 1124, 
in _refresh
self.__send_message(q)
  File "/usr/local/lib/python3.7/dist-packages/pymongo/cursor.py", line 1207, 
in next
if len(self.__data) or self._refresh():
  File "/usr/local/lib/python3.7/dist-packages/pymongo/collection.py", line 
1319, in find_one
for result in cursor.limit(-1):
  File "/usr/local/lib/python3.7/dist-packages/gecoscc/userdb.py", line 119, in 
create_user
user = self.collection.find_one({'email': email})
  File 
"/usr/local/lib/python3.7/dist-packages/gecoscc/commands/create_adminuser.py", 
line 95, in command
{'is_superuser': self.options.is_superuser}
  File "/usr/local/lib/python3.7/dist-packages/gecoscc/management.py", line 90, 
in __call__
self.command()
  File "/usr/local/lib/python3.7/dist-packages/gecoscc/management.py", line 48, 
in main
command()
  File "/usr/local/bin/pmanage", line 10, in 
sys.exit(main())
(gdb) 

And this is the builtin-code backtrace:

Core was generated by `/usr/bin/python3 /usr/local/bin/pmanage 
/opt/gecosccui/gecoscc.ini create_admin'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  PyErr_SetObject (exception=0x7ff9c0 <_PyExc_AttributeError.lto_priv.2311>, 
value=0x7f1ab49cb098) at ../Python/errors.c:101
101 Py_INCREF(exc_value);
[Current thread is 1 (Thread 0x7f1abc823740 (LWP 370))]
(gdb) bt
#0  PyErr_SetObject (exception=, value="type object 
'dict' has no attribute '_type_marker'") at ../Python/errors.c:101
#1  0x0052c23b in PyErr_FormatV (vargs=0x7ffedff77c40, 
format=, exception=) at 
../Python/errors.c:852
#2  PyErr_Format (exception=, format=) 
at ../Python/errors.c:852
#3  0x0058717d in type_getattro (type=, name=) at ../Objects/typeobject.c:3223
#4  0x0054baae in _PyObject_LookupAttr (result=, 
name=, v=) at ../Objects/object.c:949
#5  builtin_getattr (self=, args=, 
nargs=) at ../Python/bltinmodule.c:1121
#6  0x0053 in _PyMethodDef_RawFastCallKeywords (method=0x89d160 
, self=, args=0x1237208, 
nargs=, kwnames=)
at ../Objects/call.c:651
#7  0x005463e3 in _PyCFunction_FastCallKeywords (kwnames=0x0, nargs=3, 
args=0x1237208, func=) at ../Objects/call.c:730
#8  call_function (kwnames=0x0, oparg=3, pp_stack=) at 
../Python/ceval.c:4568
#9  _PyEval_EvalFrameDefault (f=, throwflag=) at 
../Python/ceval.c:3124
#10 0x005cd68c in PyEval_EvalFrameEx (throwflag=0, 
f=Frame 0x1237088, for file 
/usr/local/lib/python3.7/dist-packages/bson/codec_options.py, line 35, in 
_raw_document_class (document_class=)) at 
../Python/ceval.c:547
#11 function_code_fastcall (globals=, nargs=, 
args=, co=) at ../Objects/call.c:283
#12 _PyFunction_FastCallKeywords (func=, stack=, 
nargs=, kwnames=) at ../Objects/call.c:408
#13 0x0054207c in call_function (kwnames=0x0, oparg=, 
pp_stack=) at ../Python/ceval.c:4616
#14 _PyEval_EvalFrameDefault (f=, throwflag=) at 
../Python/ceval.c:3124
#15 0x0053f732 in PyEval_EvalFrameEx (throwflag=0, 
f=Frame 0x17882e8, for 

[issue43609] ast.unparse-ing a FunctionType gives ambiguous result

2021-03-25 Thread Batuhan Taskaya


Batuhan Taskaya  added the comment:

Hey @cleoold! Technically the second AST you gave is invalid (fun2), 
considering that the FunctionType is not an expression;

mod = Module(stmt* body, type_ignore* type_ignores)
| FunctionType(expr* argtypes, expr returns)

expr = BoolOp(boolop op, expr* values)
 | NamedExpr(expr target, expr value)
 | BinOp(expr left, operator op, expr right)

Though I am curious about use case. How did you come with the fun2's AST?

--
nosy: +BTaskaya -Batuhan Taskaya

___
Python tracker 

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



[issue43618] random.shuffle loses most of the elements

2021-03-25 Thread Stefan Behnel


Stefan Behnel  added the comment:

Yes, this is neither a bug in CPython (or its stdlib) nor in lxml. It's how 
things work. Don't use these two together.

--
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



[issue43624] Add underscore as a decimal separator for string formatting

2021-03-25 Thread Raymond Hettinger

Raymond Hettinger  added the comment:

Some brief research
===

""" in numbers four or more digits long, use commas to set off groups of three 
digits, counting leftward from the decimal point, in the standard American 
style. For long decimal numbers, do not use any digit-group separators to the 
right of the decimal point."""
— Google Style Guide https://developers.google.com/style/numbers

The CRC math handbook uses groups of five after the decimal point.
See §1.2.4 in 
http://dl.icdst.org/pdfs/files/2a2cbcfc89598fd83c315ce45c1ee663.pdf


NIST Guide for using SI units:  """The digits of numerical values having more 
than four digits on either side of the decimal marker are separated into groups 
of three using a thin, fixed space counting from both the left and right of the 
decimal marker. For example, 15 739.012 53 is highly preferred to 15739.01253. 
Commas are not used to separate digits into groups of three. (See Sec. 
10.5.3.)"""
— page vi in https://physics.nist.gov/cuu/pdf/sp811.pdf#10.5.2

StackExchange question on the topic:
https://math.stackexchange.com/questions/182775/convention-of-digit-grouping-after-decimal-point

The important reference, ISO 8:1 discusses this in section 7, "Printing 
rules", but the standard is not publicly available.

--

___
Python tracker 

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



[issue43616] random.shuffle() crashes with Unhandled exception

2021-03-25 Thread Stefan Behnel


Stefan Behnel  added the comment:

Almost certainly not a bug in CPython's stdlib.

Possibly something worth investigating in lxml, although, as stated in issue 
43618, random.shuffle() simply does not work on lxml.etree Elements.

--
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



[issue43625] CSV has_headers heuristic could be improved

2021-03-25 Thread ejacq


New submission from ejacq <0pyth...@jesuislibre.net>:

Here is an sample of CSV input:

"time","forces"
0,0
0.5,0.9

when calling has_header() from csv.py on this sample, it returns false.
Why? because 0 and 0.5 don't belong to the same type and thus the column is 
discarded by the heuristic.

I think the heuristic will better work if rather than just comparing number 
types, it would also consider casting the values in this order int -> float -> 
complex. If the values are similar then consider this upgraded type as the type 
of the column.

In the end, this file would be considered float columns with headers.

--
components: Library (Lib)
messages: 389515
nosy: ejacq
priority: normal
severity: normal
status: open
title: CSV has_headers heuristic could be improved
versions: Python 3.7

___
Python tracker 

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



[issue43620] os.path.join does not use os.sep as documentation claims

2021-03-25 Thread Fred Drake


Fred Drake  added the comment:

Perhaps Jared was expecting that modifying os.sep would affect the functions in 
os.path?

os.sep was never intended to be updated.

Using the specific *path modules to work with "foreign" paths has long been 
advocated as the way to do this.  It isn't a work-around.

--
nosy: +fdrake

___
Python tracker 

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



[issue37745] 3.8b3 - windows install gui/ inconsistent options

2021-03-25 Thread Dimitri Merejkowsky


Dimitri Merejkowsky  added the comment:

I know this is two years later so maybe this is not the best way to get 
answers, but Steve Dower said:

> We don't add Python to PATH by default (because it's bad), and people 
> couldn't find the option

Could someone clarify this for me? Because my experience as a Python teacher 
tells me the exact opposite.

For context, I've been teaching Python to absolute beginners (some of them do 
not even know how to *use* Windows to begin with).

I do tell them repeatedly to make sure to tick the "add python to Path", but 
every time, one of them forgot.

This gets even worse when the course is done remotely because I have to *tell* 
the students what to do through a screen-sharing app ...

Here's what I had to tell one of the students to do this morning.

Step 1: Tick "Display Hidden Items" in the Display option of the Windows File 
Explorer

Step 2: Go into c:\users\AppData

Step 3: Type `python.exe` in the search bar

Step 4: Copy/paste the full path 

Step 5: Open "Edit environment variables for my account"

Step 6: Click on "Edit environment variables"

Step 7: Click on Path

Step 8: Copy/paste the full path, without "python.exe"

Step 9: Copy/paste the full path, adding `\Scripts\` at the end

Step 10: restart cmd.exe


In insight, I wonder if I should have just told him to just re-run the 
installer and tick the box ...

Some notes: 

Fixing #14302 would help for step 9, which is nice.

I know very well that writing a Windows installer is far for trivial, but I'm 
ready to try and make a PR anyway. That being said, I understand there may be 
good reasons to *not* add python to PATH that I don't know about.

--
nosy: +Dimitri Merejkowsky

___
Python tracker 

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



[issue43624] Add underscore as a decimal separator for string formatting

2021-03-25 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

IIRC there is ISO recommending that after the decimal point, digits be arranged 
in groups of five.  I think is also how printed reference tables are typically 
formatted.

--
nosy: +mark.dickinson, rhettinger, serhiy.storchaka

___
Python tracker 

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



[issue24605] segmentation fault at asciilib_split_char.lto_priv

2021-03-25 Thread Irit Katriel


Irit Katriel  added the comment:

Is there anything we can do about this or should it be closed?

--
nosy: +iritkatriel
status: open -> pending

___
Python tracker 

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



[issue43618] random.shuffle loses most of the elements

2021-03-25 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Interestingly, this isn't an LXML bug.  It is a documented difference from how 
the standard library works:

https://lxml.de/tutorial.html#elements-are-lists

So, if you want use random.shuffle(), you need the standard library ElementTree 
instead of lxml.

This:

from lxml.etree import Element

root = Element('outer')
root.append(Element('zero'))
root.append(Element('one'))
root.append(Element('two'))
root[0] = root[1]
print([e.tag for e in root])

Produces:

   ['one', 'two']

--

___
Python tracker 

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



[issue43616] random.shuffle() crashes with Unhandled exception

2021-03-25 Thread Raymond Hettinger


Change by Raymond Hettinger :


--
nosy: +scoder -skrah

___
Python tracker 

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



[issue43618] random.shuffle loses most of the elements

2021-03-25 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

The standard library isn't at fault here.  Please file this an an LXML bug.

Reproducer:

from lxml.etree import Element

root = Element('outer')
root.append(Element('zero'))
root.append(Element('one'))
root.append(Element('two'))
print([e.tag for e in root])
root[1], root[0] = root[0], root[1]
print([e.tag for e in root])

This outputs:

   ['zero', 'one', 'two']
   ['one', 'two']

Replacing the import with:

   from xml.etree.ElementTree import Element

Gives the expected result:

   ['zero', 'one', 'two']
   ['one', 'zero', 'two']

--
nosy: +scoder -skrah

___
Python tracker 

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



[issue43624] Add underscore as a decimal separator for string formatting

2021-03-25 Thread Terry Davis


New submission from Terry Davis :

Proposal:
Enable this
>>> format(12_34_56.12_34_56, '_._f')
'123_456.123_456'

Where now only this is possible
>>> format(12_34_56.12_34_56, '_.f')
'123_456.123456'


Based on the discussion in the Ideas forum, three core devs support this 
addition.
https://discuss.python.org/t/add-underscore-as-a-thousandths-separator-for-string-formatting/7407

I'm willing to give this a try if someone points me to where to add tests and 
where the float formatting code is. This would be my first CPython contribution.

The feature freeze for 3.10 is 2021-05-03.
https://www.python.org/dev/peps/pep-0619/#id5

--
components: Interpreter Core
messages: 389508
nosy: Terry Davis
priority: normal
severity: normal
status: open
title: Add underscore as a decimal separator for string formatting
type: enhancement
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



[issue43416] Add README files in Include/cpython and Include/internal

2021-03-25 Thread STINNER Victor


Change by STINNER Victor :


--
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



[issue43416] Add README files in Include/cpython and Include/internal

2021-03-25 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 929c9039fe0468cb37e0811ddfb7b67c98353ea8 by Erlend Egeberg 
Aasland in branch 'master':
bpo-43416: Add Include/README.rst (GH-24884)
https://github.com/python/cpython/commit/929c9039fe0468cb37e0811ddfb7b67c98353ea8


--

___
Python tracker 

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



[issue43582] SSLContext.sni_callback docs inaccurately describe available handshake info

2021-03-25 Thread Andrew Dailey


Andrew Dailey  added the comment:

Okay, that makes sense. I appreciate the overview! What do you feel is the best 
way to "solve" this issue, then? Should the docs be updated to reflect the fact 
that ALPN info isn't available in the sni_callback? Or should some code be 
modified to make the docs correct (even though that'd have to be a bit hacky 
since the OpenSSL handshake callback order seems fairly set in stone).

I've got the contributor agreement signed and ready to go. I can formalize my 
ideas for revising the docs into a patch if that would make sense and be 
helpful.

--

___
Python tracker 

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



[issue33164] Blake 2 module update

2021-03-25 Thread Dong-hee Na


Change by Dong-hee Na :


--
nosy: +corona10

___
Python tracker 

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



[issue42136] [importlib] deprecate module_repr() methods

2021-03-25 Thread Brett Cannon


Change by Brett Cannon :


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

___
Python tracker 

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



[issue33164] Blake 2 module update

2021-03-25 Thread Christian Heimes


Change by Christian Heimes :


--
resolution: fixed -> 
stage: resolved -> needs patch
status: closed -> open
type:  -> behavior

___
Python tracker 

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



[issue43620] os.path.join does not use os.sep as documentation claims

2021-03-25 Thread Eryk Sun


Eryk Sun  added the comment:

> certainly you can see this is a doc bug, since the doc clearly 
> states that os.sep is utilized to join the elements of the path,
> when it clearly isn't; right?

os.path is ntpath in Windows, which uses backslash as the path separator, which 
is the same as os.sep in Windows. os.path is posixpath in POSIX, which uses 
slash as the path separator, which is the same as os.sep in POSIX.

--

___
Python tracker 

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



[issue33164] Blake 2 module update

2021-03-25 Thread STINNER Victor


STINNER Victor  added the comment:

> This reverted commit 5940c535b06805960d008bcafec7260dae74d9b9

Context of the memcpy/memove change: https://github.com/BLAKE2/BLAKE2/issues/32

--
nosy: +vstinner

___
Python tracker 

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



[issue43623] nouveauté 2021

2021-03-25 Thread STINNER Victor


Change by STINNER Victor :


--
Removed message: https://bugs.python.org/msg389503

___
Python tracker 

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



[issue43623] nouveauté 2021

2021-03-25 Thread STINNER Victor


Change by STINNER Victor :


--
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



[issue43623] nouveauté 2021

2021-03-25 Thread Emmanuel Miranda

New submission from Emmanuel Miranda :

Avec un nouveau cycle de release annuel la communauté Python ne cesse d’aller 
de l’avant hâte de voir ce qu’ils nous réservent pour 2021 après la version 
3.10 ! En espérant que les applicatifs suivent pour supporter

https://webscre.com/

--
components: Library (Lib)
messages: 389503
nosy: Yanis77
priority: normal
severity: normal
status: open
title: nouveauté 2021

___
Python tracker 

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



[issue33164] Blake 2 module update

2021-03-25 Thread Petr Viktorin


Petr Viktorin  added the comment:

This reverted commit 5940c535b06805960d008bcafec7260dae74d9b9

--
nosy: +petr.viktorin

___
Python tracker 

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



[issue43244] Move PyArena C API to the internal C API

2021-03-25 Thread STINNER Victor


STINNER Victor  added the comment:

In short, this issue is a follow-up of bpo-40939.

These C API removal are related to the final step of the PEP 617 "New PEG 
parser for CPython": removal of the PyParser C API.

* The PyParser C API produced "node*" objects, like 
PyParser_SimpleParseFile(FILE*) => node*. This C API was removed in Python 
3.10: bpo-40939 "Remove the old parser".

* The AST C API takes "node*" as input: PyAST_FromNode(node*) => mod_ty. I 
removed these APIs.

* symtable takes "mod_ty" as input.

* ASDL and PyArena API were only useful for the removed AST C APIs.

I searched for removed functions in the top PyPI 4000 projects, there is a 
single project on 4000: typed_ast. This typed_ast project is special, it copies 
directly code from CPython. Even after the C API removed, typed_ast can 
continue to use the internal C API, it only has to define the 
Py_BUILD_CORE_MODULE macro.

--

___
Python tracker 

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



[issue43620] os.path.join does not use os.sep as documentation claims

2021-03-25 Thread Jared Sutton


Jared Sutton  added the comment:

I can understand your suggestion to just utilize the posixpath library on 
Windows if needed. That's a reasonable work-around. But certainly you can see 
this is a doc bug, since the doc clearly states that os.sep is utilized to join 
the elements of the path, when it clearly isn't; right?

--
components:  -Library (Lib)

___
Python tracker 

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



[issue43622] TLS 1.3, client polling returns event without data

2021-03-25 Thread Christian Heimes


Christian Heimes  added the comment:

It looks like your code is treating a SSLSocket like an ordinary Kernel socket. 
SSLSocket are implemented in user space and behave differently. 
https://docs.python.org/3/library/ssl.html#ssl-nonblocking explains some of the 
aspects of non-blocking I/O for TLS connections. For non-blocking I/O it is 
generally easier to use sans-I/O approach and make use of MemoryBIO 
https://docs.python.org/3/library/ssl.html#memory-bio-support instead of 
SSLSocket.

3.6 and 3.7 only receive security updates and are out of scope anyway.

--

___
Python tracker 

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



[issue43622] TLS 1.3, client polling returns event without data

2021-03-25 Thread gchauvel


gchauvel  added the comment:

that's not the polling in itself,
it's: polling returning event + setblocking(False) + recv() which blocks

note: the behavior is present for python3.6

--

___
Python tracker 

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



[issue43622] TLS 1.3, client polling returns event without data

2021-03-25 Thread Christian Heimes


Christian Heimes  added the comment:

Could you please explain why you consider this a bug?

TLS 1.3 works differently than TLS 1.2. You must always assume that an 
application level read can result in a protocol level write operation and the 
other way around. This could happen with TLS 1.2, but it was less common to 
occur. With TLS 1.3 rekeying, client cert authentication with post handshake 
authentication, and sessions are most common examples.

--
versions:  -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



[issue43622] TLS 1.3, client polling returns event without data

2021-03-25 Thread gchauvel


New submission from gchauvel :

A simple test in test_ssl.py [1][2] with following context:
- client connects and listens to data without sending any first
- traces to make sure no data is written at test level from server or client
- TLSv1.3 is allowed or not using "context.options |= ssl.OP_NO_TLSv1_3"

produces this result:

TLSv1.2:
- no event on FD, no issue

TLSv1.3:
- event on FD without any write at test level
- recv() blocks, even with setblocking(False)

[1] master: 
https://github.com/g-chauvel/cpython/commit/8c95c4f67367ea43c508ea62a0cdbe120a3fed9b
[2] 3.6: 
https://github.com/g-chauvel/cpython/commit/7cd4b4ac22efea7c61a9f8f57b6f2315567f5742

--
assignee: christian.heimes
components: SSL
messages: 389496
nosy: christian.heimes, gchauvel
priority: normal
severity: normal
status: open
title: TLS 1.3, client polling returns event without data
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



[issue43613] gzip.compress and gzip.decompress are sub-optimally implemented.

2021-03-25 Thread Ruben Vorderman


Ruben Vorderman  added the comment:

I created bpo-43621 for the error issue. There should only be BadGzipFile. Once 
that is fixed, having only one error type will make it easier to implement some 
functions that are shared across the gzip.py codebase.

--

___
Python tracker 

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



[issue43621] gzip._GzipReader should only throw BadGzipFile errors

2021-03-25 Thread Ruben Vorderman


Change by Ruben Vorderman :


--
type:  -> behavior

___
Python tracker 

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



[issue43612] zlib.compress should have a wbits argument

2021-03-25 Thread Ruben Vorderman


Change by Ruben Vorderman :


--
components: +Extension Modules -Library (Lib)

___
Python tracker 

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



[issue43621] gzip._GzipReader should only throw BadGzipFile errors

2021-03-25 Thread Ruben Vorderman


New submission from Ruben Vorderman :

This is properly documented: 
https://docs.python.org/3/library/gzip.html#gzip.BadGzipFile . 

It now hrows EOFErrors when a stream is truncated. But this means that upstream 
both BadGzipFile and EOFError need to be catched in the exception handling when 
opening a gzip file for reading. When a gzip file is truncated it is also a 
"bad gzip file" in my opinion, so there is no reason to have an extra class of 
errors.
Also it throws zlib.error's when zlib craches for some reason. This means there 
is some corruption in the raw deflate block. Well that means it is a "bad gzip 
file" as well and the error message should reflect that. 

This won't break people's code. If they are already catching EOFError 
zlib.error and BadGzipFile it changes nothing. If they only catch BadGzipFile, 
they will have less annoying errors that pop through.

I can make the PR, but of course not without any feedback. I am curious what 
other people think.

--
components: Library (Lib)
messages: 389494
nosy: rhpvorderman
priority: normal
severity: normal
status: open
title: gzip._GzipReader should only throw BadGzipFile errors
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