[issue34357] situation where urllib3 works, but urllib does not work

2018-08-13 Thread Martin Panter


Change by Martin Panter :


--
superseder:  -> Cannot override 'connection: close' in urllib2 headers

___
Python tracker 

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



[issue34356] Add support for args and kwargs in logging.conf

2018-08-13 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

Adding Vinay for his thoughts on this. Also Python 3.4 and 3.5 are in security 
fixes only mode and can be removed.

Thanks

--
nosy: +vinay.sajip, xtreak

___
Python tracker 

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



[issue30400] Race condition in shutil.copyfile(): source file replaced file during copy

2018-08-13 Thread Preston Moore


Preston Moore  added the comment:

Hello everyone,

I've just updated my pull request to include an additional test so everything 
should be in shape testing wise.

Once I get confirmation that this strategy is acceptable and/or this PR is 
merged I will get to work addressing the other identified problem areas in a 
similar fashion.  There are a few more weeks before classes start back up for 
the fall semester so I should have available bandwidth to make good progress.

Thanks,
Preston

--

___
Python tracker 

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



[issue34390] arparse.ArgumentParser misparses list arguments followed by undefined arguments

2018-08-13 Thread paul j3


paul j3  added the comment:

Duplicate of

https://bugs.python.org/issue22909 [argparse] Using parse_known_args, unknown 
arg with space in value is interpreted as first positional arg (closed as 
duplicate)

https://bugs.python.org/issue22433 Argparse considers unknown optional 
arguments with spaces as a known positional argument

In 22433 I suggested a patch but worried about backward incompatibility.  

I propose closing this as a duplicate.

--

___
Python tracker 

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



[issue34390] arparse.ArgumentParser misparses list arguments followed by undefined arguments

2018-08-13 Thread paul j3


paul j3  added the comment:

Parsing is a two step process.  First the strings are passed through

def _parse_optional(self, arg_string):

which classifies them as 'O', an optional flag, or 'A', an argument.

- no prefix char => A
- the string is in the dictionary of option_strings (e.g. '--list-arg') => O
- one char => A
- has '=' and first part in option_strings => O
- test for abreviations
- negative number => O or A
- contains space => A
- else => unmatched O?

(read it for the details)

With your inputs, the pattern is:

['--list-arg', 'a', '--text-arg', 'hello world']
O A O? A

['--list-arg', 'a', '--text-arg=hello']
O A O?

['--list-arg', 'a', '--text-arg=hello world']
O A A

It's the space in the string marks it as an argument that can be added to the 
'--list-arg' list.

Unmatched optionals go on the 'extras' list.

---

In [25]: parser.parse_known_args(['--list-arg', 'a', '--text-arg', 'hello 
world'])
Out[25]: (Namespace(list_arg=['a']), ['--text-arg', 'hello world'])

In [26]: parser.parse_known_args(['--list-arg', 'a', '--text-arg=hello'])
Out[26]: (Namespace(list_arg=['a']), ['--text-arg=hello'])

In [32]: parser.parse_known_args(['--list-arg', 'a', '--text-arg=hello world'])
Out[32]: (Namespace(list_arg=['a', '--text-arg=hello world']), [])

---

So '--text-arg=hello world' is split into ['--text-arg', 'hello world'] only if 
'--text-arg' is an option_string.

Any ways, the behavior is explainable.  Whether the blank should have this 
priority might be debatable, but I suspect any changes will be rejected on the 
grounds of backward incompatibility.  

Your users still have the option of using:

--text-arg 'hello world'

It may be worth search the issues for an earlier discussion.

--
nosy: +paul.j3

___
Python tracker 

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



[issue34396] Certain methods that heap allocated subtypes inherit suffer a 50-80% performance penalty

2018-08-13 Thread Benjamin Peterson


Benjamin Peterson  added the comment:

Amusingly, this is because of an old hack to make directly calling 
somedict.__getitem__ fast: 
https://github.com/python/cpython/commit/8f5cdaa784f555149adf5e94fd2e989f99d6b1db

Reverting the dictobject.c changes of the commit, i.e., the following patch, 
fixes your example.

diff --git a/Objects/dictobject.c b/Objects/dictobject.c
index 413557d667..d85834977d 100644
--- a/Objects/dictobject.c
+++ b/Objects/dictobject.c
@@ -3032,8 +3032,6 @@ dict_sizeof(PyDictObject *mp, PyObject 
*Py_UNUSED(ignored))
 return PyLong_FromSsize_t(_PyDict_SizeOf(mp));
 }
 
-PyDoc_STRVAR(getitem__doc__, "x.__getitem__(y) <==> x[y]");
-
 PyDoc_STRVAR(sizeof__doc__,
 "D.__sizeof__() -> size of D in memory, in bytes");
 
@@ -3071,8 +3069,6 @@ PyDoc_STRVAR(values__doc__,
 
 static PyMethodDef mapp_methods[] = {
 DICT___CONTAINS___METHODDEF
-{"__getitem__", (PyCFunction)dict_subscript,METH_O | METH_COEXIST,
- getitem__doc__},
 {"__sizeof__",  (PyCFunction)dict_sizeof,   METH_NOARGS,
  sizeof__doc__},
 DICT_GET_METHODDEF

--
nosy: +benjamin.peterson

___
Python tracker 

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



[issue34270] Add names to asyncio tasks

2018-08-13 Thread Benjamin Peterson


Benjamin Peterson  added the comment:


New changeset aa4e4a40db531f7095513a4b0aa6510f18162a07 by Benjamin Peterson in 
branch 'master':
Make regular expressions in test_tasks.py raw strings. (GH-8759)
https://github.com/python/cpython/commit/aa4e4a40db531f7095513a4b0aa6510f18162a07


--
nosy: +benjamin.peterson

___
Python tracker 

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



[issue34270] Add names to asyncio tasks

2018-08-13 Thread Benjamin Peterson


Change by Benjamin Peterson :


--
pull_requests: +8235

___
Python tracker 

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



[issue34397] remove redundant overflow checks in tuple and list implementations

2018-08-13 Thread Raymond Hettinger


Change by Raymond Hettinger :


--
nosy: +mark.dickinson, serhiy.storchaka, tim.peters

___
Python tracker 

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



[issue34117] Rename "generator expressions" to "generator comprehensions"

2018-08-13 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Results from two Python courses:

* In terms of teaching gexexps, there was no net gain or loss.  When genexps 
are show side-by-side with list/dict/set comps the symmetric relationship was 
obvious regardless of terminology.

* In terms of being able to search StackOverflow, blog posts, and external 
resources, the new terminology made the resources unfindable.

* When using the new terminology, I did get questions that never came up 
before, "why don't the parentheses mean tuple-comprehension".

Based on those results, I recommend we keep the terminology the same as it is 
now.  The loss of searchability isn't worth it (there doesn't seem to be any 
upside) and it is concerning that a new category of confusion (list/tuple 
comprehension) seems to be arising from the change in terminology.

--

___
Python tracker 

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



[issue27186] add os.fspath()

2018-08-13 Thread Erik Janssens


Erik Janssens  added the comment:

thank you for the info ... I'll have a look at making the posix module easier 
to port ...

--

___
Python tracker 

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



[issue34394] Descriptors HowTo doesn't mention __set_name__

2018-08-13 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Thanks. I'm already working on this.

--
assignee: docs@python -> rhettinger
nosy: +rhettinger

___
Python tracker 

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



[issue34387] Deletion of attributes in dataclass is buggy

2018-08-13 Thread Brett Cannon


Brett Cannon  added the comment:

I agree with Eric that without concrete details I suspect everything is working 
as expected. E.g.

```python
class Foo:
   attr = -13

ins = Foo()
ins.attr = 42
print(ins.attr)
del ins.attr
print(ins.attr)
```

--
nosy: +brett.cannon
title: Deletion of attributes in dataclass is buggy! -> Deletion of attributes 
in dataclass is buggy

___
Python tracker 

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



[issue34395] memory leaks in error handling in csv and pickle modules

2018-08-13 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

Hi and thank you for the report. Could you elaborate a bit more on how/where 
the leak happens? This will help when reviewing the Pull Request. Thanks!

--
nosy: +pablogsal

___
Python tracker 

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



[issue34356] Add support for args and kwargs in logging.conf

2018-08-13 Thread Xavier Hardy


Change by Xavier Hardy :


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

___
Python tracker 

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



[issue34397] remove redundant overflow checks in tuple and list implementations

2018-08-13 Thread Sergey Fedoseev


New submission from Sergey Fedoseev :

Max size of list and tuples is limited by PY_SSIZE_T_MAX / sizeof(PyObject*), 
so the sum of any two list/tuples sizes always <= PY_SSIZE_T_MAX if 
sizeof(PyObject*) > 1, which seems true for all supported (existing?) platforms.
It means that overflow checks in app1, ins1, list_concat and tupleconcat are 
redundant and can be safely removed.

--
components: Interpreter Core
messages: 323491
nosy: sir-sigurd
priority: normal
severity: normal
status: open
title: remove redundant overflow checks in tuple and list implementations
type: enhancement
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



[issue34397] remove redundant overflow checks in tuple and list implementations

2018-08-13 Thread Sergey Fedoseev


Change by Sergey Fedoseev :


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

___
Python tracker 

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



[issue34396] Certain methods that heap allocated subtypes inherit suffer a 50-80% performance penalty

2018-08-13 Thread Dan Snider


New submission from Dan Snider :

The ones I know of are list.__getitem__, dict __contains__ & __getitem__, and 
(frozen)set.__contains__ but from what I can tell so far it seems like 
dict.__getitem__ takes the worst hit. For dicts, I've spent a few hours trying 
to figure out what's getting put into the heap type's mp_subscript slot to slow 
it down so drastically but I just can't figure it out. 

So I just forced `dict_subscript` into the heap type's mp_subscript slot to 
confirm the rather obvious impossibility of it breaking anything. Here's a 
"little" timeit script to demonstrate how horribly inefficient 
`dict.__getitem__` is when called on anything other than an extension type:

if __name__ == '__main__':

import timeit
from collections import OrderedDict as FastDictSub
from ctypes import *

class mappingmethods(Structure):
_fields_ = [
('mp_length', c_void_p),
('mp_subscript', PYFUNCTYPE(py_object,py_object,py_object)),
('mp_ass_subscript', c_void_p)]

class _type_object(Structure):
_fields_ = [('junk', (c_uint8*56)), # <- brevity
('tp_as_mapping', POINTER(mappingmethods))]
py_type = POINTER(_type_object)

class SlowDictSub(dict):
pass

assert SlowDictSub.__base__ is dict and FastDictSub.__base__ is dict
assert SlowDictSub.__getitem__ is dict.__getitem__
assert FastDictSub.__getitem__ is dict.__getitem__

mp = dict.fromkeys(range(15))
setup = 'from __main__ import mp, %s as Dict; d=Dict(mp)'
print(f'Comparing execution time of heap allocated dict subtype '
  f'versus PyODict_Type (who also inherits dict.__getitem__)...\n')
slown, slowt = timeit.Timer('d[10]', setup%'SlowDictSub').autorange()
print(f'avg. exec {slown/slowt:_.0f} SlowDictSub[x] statements per second')
fastn, fastt = timeit.Timer('d[10]', setup%'FastDictSub').autorange()
print(f'avg. exec {fastn/fastt:_.0f} OrderedDict[x] statements per second')
print()
print(f'SlowDictSub was {1/(fastt/slowt):.2f}x slower than OrderedDict... '
  f"Let's see what happens when we fix SlowDictSub's 'broken' "
  "mp_subscript slot:\n")
slow_tp = cast(id(SlowDictSub), py_type).contents
fast_tp = cast(id(FastDictSub), py_type).contents

slow_tp.tp_as_mapping.contents.mp_subscript = (
fast_tp.tp_as_mapping.contents.mp_subscript)
postn, postt = timeit.Timer('d[10]', setup%'SlowDictSub').autorange()
print(f'avg. exec {postn/postt:_.0f} SlowDictSub[x] after slot change')
print(f'which is now {1/(fastt/postt):.2}x the speed of dict_item')


Comparing execution time of heap allocated dict subtype versus PyODict_Type 
(who also inherits dict.__getitem__)...

avg. exec 6_220_709 SlowDictSub[x] statements per second
avg. exec 21_894_971 OrderedDict[x] statements per second

SlowDictSub was 3.52x slower than OrderedDict... Let's see what happens when we 
fix SlowDictSub's 'broken' mp_subscript slot:

avg. exec 21_665_595 SlowDictSub[x] after slot change
which is now 1.0x the speed of dict_item

--
components: Interpreter Core
messages: 323490
nosy: bup
priority: normal
severity: normal
status: open
title: Certain methods that heap allocated subtypes inherit suffer a 50-80% 
performance penalty
type: performance
versions: Python 3.7, Python 3.8

___
Python tracker 

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



[issue33262] Deprecate shlex.split(None) to read from stdin.

2018-08-13 Thread Niklas Rosenstein


Niklas Rosenstein  added the comment:

I've just run into this as well -- I thought it was a bug until I found this 
issue. I also think that this is anything from sane.

--
nosy: +n_rosenstein

___
Python tracker 

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



[issue34384] os.readlink does not accept pathlib.Path on Windows

2018-08-13 Thread Berker Peksag


Berker Peksag  added the comment:

Thanks for the suggestions! I've updated PR 8740. I will submit separate PRs to 
fix os.readlink() documentation in 3.6 and 3.7 branches.

--

___
Python tracker 

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



[issue34395] memory leaks in error handling in csv and pickle modules

2018-08-13 Thread Sergey Fedoseev


Change by Sergey Fedoseev :


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

___
Python tracker 

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



[issue34395] memory leaks in error handling in csv and pickle modules

2018-08-13 Thread Sergey Fedoseev


New submission from Sergey Fedoseev :

There are memory leaks in csv and pickle modules caused by incautious usage of 
PyMem_Resize().

See GitHub PR.

--
components: Extension Modules
messages: 323487
nosy: sir-sigurd
priority: normal
severity: normal
status: open
title: memory leaks in error handling in csv and pickle modules

___
Python tracker 

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



[issue34384] os.readlink does not accept pathlib.Path on Windows

2018-08-13 Thread Steve Dower


Steve Dower  added the comment:

Serhiy is exactly right, but to emphasise, the best way to do paths now is to 
use argument clinic with its path_t type. On Windows, .narrow is a flag that 
indicates whether you should PyUnicode_FSEncode() any results before returning 
them, and .wide is always initialized correctly.

Do not use any *A APIs - only *W from now on :)

--

___
Python tracker 

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



[issue19050] [Python 2, Windows] fflush called on pointer to potentially closed file

2018-08-13 Thread Mark Lawrence


Change by Mark Lawrence :


--
nosy:  -BreamoreBoy

___
Python tracker 

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



[issue19050] [Python 2, Windows] fflush called on pointer to potentially closed file

2018-08-13 Thread Steve Dower


Steve Dower  added the comment:

As this is a fail-fast and not an uncontrolled crash, I vote to close as 
wontfix.

This only applies to security-fix versions, and it is not exploitable.

--

___
Python tracker 

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



[issue34117] Rename "generator expressions" to "generator comprehensions"

2018-08-13 Thread Shiva Saxena


Shiva Saxena  added the comment:

I am interested to work on this issue. It would be my first contribution in 
cpython. Should I go ahead?

--
nosy: +GeekyShacklebolt

___
Python tracker 

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



[issue16038] ftplib: unlimited readline() from connection

2018-08-13 Thread Jeff Dafoe


Jeff Dafoe  added the comment:

I have a question about this old patch, as it just came down in a CentOS 6 
update. I think the patch is applied to the data channel in ASCII mode and not 
just the control channel. On the data channel in ASCII mode, there should be no 
assumption of maximum line length before EOL. I saw that your current value 
came from vsftpd's header file. I'm guessing if you look at the implementation, 
it's either only applied to the control channel or it's just used to set a 
single read size inside of a loop.  Examples of ASCII mode files that can 
exceed nearly any MAXLINE value without EOL are XML files or EDI files.

--
nosy: +Jeff Dafoe

___
Python tracker 

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



[issue17180] shutil copy* unsafe on POSIX - they preserve setuid/setgit bits

2018-08-13 Thread Jim Jewett


Jim Jewett  added the comment:

My current UI shows this as relevant *only* to 3.4 and 3.5.  If it really has 
been fixed in 3.6, and the fix can't be backported, I think the risk of 
breaking backup programs is enough to argue for doing nothing more than a doc 
change.  Anyone still using 3.4 (or even 3.5) *and* able to install from source 
is likely to be more upset by unexpected (and possibly silent) breakage of an 
existing process than new exploits of a 6 year old bug.  

That said, I'm probably the wrong person to verify which versions are affected, 
so consider this as only soft support for Release Manager to do so if this 
continues to languish.

--
nosy: +Jim.Jewett

___
Python tracker 

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



[issue15100] Race conditions in shutil.copy, shutil.copy2 and shutil.copyfile

2018-08-13 Thread Jim Jewett


Jim Jewett  added the comment:

(Note:  I am talking only about the disclosure issue; file corruption would 
ideally be fixed as far back as possible, though I would be somewhat 
sympathetic to a "nah, that ain't security, too late" argument.)

My current UI shows this as relevant to every release *except* 3.4 and 3.8.  If 
it is really 3.4 only, I think it should be closed -- anyone still using 3.4 
*and* able to install from source is likely to be more upset by unexpected (and 
possibly silent) breakage of an existing process than new exploits of a 6 year 
old bug.  

If it really does apply to 3.5-3.7, then it would be good to do the same fix in 
all (and to match 3.8, which presumably is also affected, and simply wasn't 
available to check when the Versions were last set).

If, for some reason, the *right* fix on 3.8 (or at least 3.7 or 3.6) doesn't 
apply to earlier 3.x versions, I suggest closing it as won't-fix on those older 
versions.

That said, I'm probably the wrong person to verify which versions are affected, 
so consider this as only soft support for Release Manager to do so if this 
continues to languish.

--

___
Python tracker 

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



[issue34357] situation where urllib3 works, but urllib does not work

2018-08-13 Thread David


David  added the comment:

martin.parter, it worked! Thanks so much, I was going nuts I also read the 
issue you pointed to, very interesting. Even if all servers should just work 
here, it does not seem to be the case in real life (I guess it's something easy 
to misconfigure) so I agree not setting "Connection: false" by default would 
make the standard lib more user friendly.

I guess I'll now talk to the maintainers of the upstream library and suggest 
the following:

* Reading this issue and the one you pointed to.
* Reviewing their server configuration.
* Migrating to http.client, specially if they don't make to fix the server 
configuration.

This can now be closed, thanks so much again <3

--
stage: test needed -> 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



[issue34394] Descriptors HowTo doesn't mention __set_name__

2018-08-13 Thread Semyon


New submission from Semyon :

There is a great HowTo document for descriptors 
https://github.com/python/cpython/blob/master/Doc/howto/descriptor.rst
But it doesn't even mention the __set_name__ method which was added in py3. And 
it lists the descriptor protocol without that method as if it is the full 
protocol. The only way to know about that method is to go to the link for any 
other method and then you'll see that there is a __set_name__.
I think the guide sholud be updated to include at least information about 
existence of __set_name__.

--
assignee: docs@python
components: Documentation
messages: 323479
nosy: MarSoft, docs@python
priority: normal
severity: normal
status: open
title: Descriptors HowTo doesn't mention __set_name__
versions: Python 3.4, Python 3.5, Python 3.6, Python 3.7, Python 3.8

___
Python tracker 

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



[issue34357] situation where urllib3 works, but urllib does not work

2018-08-13 Thread David


David  added the comment:

Hi Martin.

It's definitely something with my internet connection. Yesterday I temporarily 
changed the way I connect to the internet to use the mobile connection from my 
cell phone instead of my WiFi connection, and things started working.

I also debugged the headers being received and I did notice the "Connection: 
Close" header was the only relevant difference in the request when comparing it 
to the request sent by my browser when accessing that page directly. My next 
task was to investigate how to do what you just suggested... With my currently 
knowledge of python it would've taken me ages to figure out, so thanks so much!

Let me try your suggestions and report back! Thanks so much for your help! :)

--

___
Python tracker 

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



[issue34393] json.dumps - allow compression

2018-08-13 Thread liad


liad  added the comment:

The gzip module may work for saving file localy but for example:

This upload json to Google Storage:

import datalab.storage as storage
storage.Bucket('mybucket').item(path).write_to(json.dumps(response), 
'application/json')

Your won't work here unless I save the file locally and only then upload it... 
It's a bit of a problem when your files are  100 GBs+

I still think the json.dump() should support compression

--

___
Python tracker 

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



[issue34393] json.dumps - allow compression

2018-08-13 Thread rushter


rushter  added the comment:

You can use the gzip module.

with gzip.GzipFile('products.json', 'w') as outfile:
outfile.write(json.dumps(data, outfile, sort_keys=True))

--
nosy: +rushter

___
Python tracker 

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



[issue34393] json.dumps - allow compression

2018-08-13 Thread liad


New submission from liad :

The list of arguments of json.dump() can be seen here: 
https://docs.python.org/2/library/json.html

Notice that there is no way to make compression.

For example pandas allows you to do:
df.to_csv(path_or_buf=file_name, index=False, encoding='utf-8',
  compression='gzip',
  quoting=QUOTE_NONNUMERIC)

I want to be able to compress when I do:
with open('products.json', 'w') as outfile:
json.dump(data, outfile, sort_keys=True)


Please add the ability to compress using json.dump()

--
messages: 323475
nosy: liad100
priority: normal
severity: normal
status: open
title: json.dumps - allow compression
type: enhancement
versions: Python 2.7

___
Python tracker 

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



[issue34392] Add sys.isinterned()

2018-08-13 Thread Christian Heimes


Christian Heimes  added the comment:

I'd prefer to have this as an internal API, either sys._isinterned() or as a 
helper method in testcapi.

--
nosy: +christian.heimes

___
Python tracker 

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



[issue34392] Add sys.isinterned()

2018-08-13 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


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

___
Python tracker 

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



[issue34392] Add sys.isinterned()

2018-08-13 Thread Serhiy Storchaka


New submission from Serhiy Storchaka :

I need to test whether the string is interned for Python implementations of 
marshal.dumps(). It is easy to do in C, and I suggest to expose this 
functionality to Python.

Currently you can test if the string is interned using the following function:

def isinterned(s):
return sys.intern(s) is s

But it has a side effect -- it interns a string if it is not equal to an 
already interned string.

--
components: Interpreter Core
messages: 323473
nosy: rhettinger, ronaldoussoren, serhiy.storchaka
priority: normal
severity: normal
status: open
title: Add sys.isinterned()
type: enhancement
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



[issue34391] test_ftplib is failing with TLS 1.3

2018-08-13 Thread Christian Heimes


New submission from Christian Heimes :

Related to #32947

Four ftplib tests are failing with OpenSSL 1.1.1-pre8 and TLS 1.3 enabled. All 
failing tests use a separate data connection and transfer data on the server. 
For store operations, the client never calls recv(). This breaks bidirectional 
shutdown. I assume there are session tickets stuck on the wire.

==
ERROR: test_storbinary (test.test_ftplib.TestTLS_FTPClassMixin)
--
Traceback (most recent call last):
  File "/home/heimes/dev/python/cpython/Lib/test/test_ftplib.py", line 591, in 
test_storbinary
self.client.storbinary('stor', f)
  File "/home/heimes/dev/python/cpython/Lib/ftplib.py", line 514, in storbinary
conn.unwrap()
  File "/home/heimes/dev/python/cpython/Lib/ssl.py", line 1091, in unwrap
s = self._sslobj.shutdown()
OSError: [Errno 0] Error

==
ERROR: test_storbinary_rest (test.test_ftplib.TestTLS_FTPClassMixin)
--
Traceback (most recent call last):
  File "/home/heimes/dev/python/cpython/Lib/test/test_ftplib.py", line 603, in 
test_storbinary_rest
self.client.storbinary('stor', f, rest=r)
  File "/home/heimes/dev/python/cpython/Lib/ftplib.py", line 514, in storbinary
conn.unwrap()
  File "/home/heimes/dev/python/cpython/Lib/ssl.py", line 1091, in unwrap
s = self._sslobj.shutdown()
OSError: [Errno 0] Error

==
ERROR: test_storlines (test.test_ftplib.TestTLS_FTPClassMixin)
--
Traceback (most recent call last):
  File "/home/heimes/dev/python/cpython/Lib/test/test_ftplib.py", line 608, in 
test_storlines
self.client.storlines('stor', f)
  File "/home/heimes/dev/python/cpython/Lib/ftplib.py", line 545, in storlines
conn.unwrap()
  File "/home/heimes/dev/python/cpython/Lib/ssl.py", line 1091, in unwrap
s = self._sslobj.shutdown()
OSError: [Errno 0] Error

==
ERROR: test_data_connection (test.test_ftplib.TestTLS_FTPClass)
--
Traceback (most recent call last):
  File "/home/heimes/dev/python/cpython/Lib/test/test_ftplib.py", line 889, in 
test_data_connection
self.assertEqual(self.client.voidresp(), "226 transfer complete")
  File "/home/heimes/dev/python/cpython/Lib/ftplib.py", line 251, in voidresp
resp = self.getresp()
  File "/home/heimes/dev/python/cpython/Lib/ftplib.py", line 236, in getresp
resp = self.getmultiline()
  File "/home/heimes/dev/python/cpython/Lib/ftplib.py", line 222, in 
getmultiline
line = self.getline()
  File "/home/heimes/dev/python/cpython/Lib/ftplib.py", line 204, in getline
line = self.file.readline(self.maxline + 1)
  File "/home/heimes/dev/python/cpython/Lib/socket.py", line 589, in readinto
return self._sock.recv_into(b)
socket.timeout: timed out

--
Ran 88 tests in 9.402s

FAILED (errors=4, skipped=1)

--
messages: 323472
nosy: christian.heimes
priority: normal
severity: normal
status: open
title: test_ftplib is failing with TLS 1.3

___
Python tracker 

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



[issue1529353] Squeezer - squeeze large output in the interpreter

2018-08-13 Thread Tal Einat


Tal Einat  added the comment:

I'm back to working on this.  I've made good progress: I'm nearly done with all 
of the changes suggested here and ready for another PR review.

I'd like some opinions on a few things:

1. Should the tooltip-related configuration options be removed?  There is one 
for whether to show tooltips for squeezed outputs and another to set the hover 
delay.  I feel that they add unnecessary complexity.

2. Should there be an option to entirely disable auto-squeezing?  Currently 
there is only a setting for the minimum number of lines, which can just be set 
very high.

3. Should we keep the events for squeezing the last output block and expanding 
the last squeezed output block?  ISTM the keyboard shortcuts would only be used 
by "power users", which aren't our main target.  Further, without keyboard 
shortcuts, I see no point for having these events at all, given that it is easy 
to achieve this otherwise.

4. Is it worth the effort to update the number of lines displayed for squeezed 
outputs when a shell window's width is changed?

--

___
Python tracker 

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



[issue34386] Expose a dictionary of interned strings in sys module

2018-08-13 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

I concur with Ronald. Using a dict instance is an implementation detail. 
CPython could use a dict, a set, a hashtable implementation from 
Modules/hashtable.c, or the HAMT implementation from Python/hamt.c. Other 
Python implementations can have other options.

--
nosy: +serhiy.storchaka
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



[issue30563] [Cygwin] multiprocessing module with pool object issue

2018-08-13 Thread Antoine Pitrou


Antoine Pitrou  added the comment:

> In fact, the Python package should probably be removed from Cygwin?

We don't maintain Cygwin nor Python on Cygwin here.  You should contact those 
people.

--

___
Python tracker 

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



[issue34386] Expose a dictionary of interned strings in sys module

2018-08-13 Thread Ronald Oussoren


Ronald Oussoren  added the comment:

IMHO we shouldn't expose the intern dictionary without there being a clear, and 
good enough, use case for doing so.  

Exposing the dictionary decreases implementation flexibility, and increases 
requirements on other implementations.  One example of the former: at least in 
theory the interning dictionary could be a set, but we couldn't make that 
change if the dictionary were exposed in the API.

With current information I'm -1 on exposing the dictionary, and -0 on doing 
that for debug builds only.

--

___
Python tracker 

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



[issue34357] situation where urllib3 works, but urllib does not work

2018-08-13 Thread Martin Panter

Martin Panter  added the comment:

I can’t get it to hang. Does your computer or Internet provider have a proxy or 
firewall that may be interfering?

Perhaps it is worth comparing the HTTP header fields being sent and received. 
You can enable debug messages to see the request sent, and print the response 
fields directly. Most important things to look for are the Content-Length and 
Transfer-Encoding (if any) fields in the response.

>>> import urllib.request
>>> url = "https://cinnamon-spices.linuxmint.com/json/applets.json;
>>> handler = urllib.request.HTTPSHandler(debuglevel=1)
>>> opener = urllib.request.build_opener(handler)
>>> resp = opener.open(url)
send: b'GET /json/applets.json HTTP/1.1\r\nAccept-Encoding: identity\r\nHost: 
cinnamon-spices.linuxmint.com\r\nUser-Agent: Python-urllib/3.6\r\nConnection: 
close\r\n\r\n'
reply: 'HTTP/1.1 200 OK\r\n'
header: Server header: Date header: Content-Type header: Content-Length header: 
Connection header: Last-Modified header: ETag header: X-Sucuri-Cache header: 
X-XSS-Protection header: X-Frame-Options header: X-Content-Type-Options header: 
X-Sucuri-ID header: Accept-Ranges $
>>> print(response.info())
Server: Sucuri/Cloudproxy
Date: Mon, 13 Aug 2018 07:18:11 GMT
Content-Type: application/json
Content-Length: 70576
Connection: close
Last-Modified: Mon, 13 Aug 2018 07:25:14 GMT
ETag: "113b0-5734bfe97145e"
X-Sucuri-Cache: HIT
X-XSS-Protection: 1; mode=block
X-Frame-Options: SAMEORIGIN
X-Content-Type-Options: nosniff
X-Sucuri-ID: 11014
Accept-Ranges: bytes


>>> data = resp.read()
>>> len(data)
70576

Another experiment would be to try “http.client” directly, which I understand 
is used by both the built-in “urllib.request” module, and “urllib3”:

from http.client import HTTPSConnection
conn = HTTPSConnection("cinnamon-spices.linuxmint.com")
headers = {  # Same header fields sent by “urllib.request”
"Accept-Encoding": "identity",
"Host": "cinnamon-spices.linuxmint.com",
"User-Agent": "Python-urllib/3.6",
"Connection": "close",
}
conn.request("GET", "/json/applets.json", headers=headers)
resp = conn.getresponse()
print(resp.msg)
data = resp.read()

Try removing the “Connection: close” field from the request. Occasionally this 
triggers bad server behaviour (see Issue 12849); maybe your server or proxy is 
affected.

--
nosy: +martin.panter
stage:  -> test needed
type:  -> behavior
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



[issue30563] [Cygwin] multiprocessing module with pool object issue

2018-08-13 Thread Niels Kristian Jensen


Niels Kristian Jensen  added the comment:

I ran the same test on Windows 10, works fine, but Windows Server 2012 bails 
out with no message, no abnormal exit code.

@Antoine Pitrou - if Cygwin and Python3 are non-compatible, I suggest that 
someone in the Python3 community writes a note about this, for reference.

In fact, the Python package should probably be removed from Cygwin?

--
nosy: +nkjensen

___
Python tracker 

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



[issue34384] os.readlink does not accept pathlib.Path on Windows

2018-08-13 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Currently the behavior doesn't match the documentation. Initially I thought 
that this can be solved by adding the support of path-like objects and 
backporting this up to 3.6. But os.readlink() on Windows doesn't not support 
also bytes paths, and never supported. This looks to me now more like a new 
feature. In 3.6 and 3.7 we can resolve this issue by just updating the 
documentation.

Bytes paths on Windows were deprecated before 3.6. Since implementing PEP 529, 
their should be supported on Windows if they are supported on other platforms. 
We shouldn't use an 8-bit API like CreateFileA, but instead decode bytes paths 
with UTF-8 and use a Unicode API (this should be implemented in 
path_converter()).

--

___
Python tracker 

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



[issue18597] On Windows sys.stdin.readline() doesn't handle Ctrl-C properly

2018-08-13 Thread Joshua Kinard


Joshua Kinard  added the comment:

I was able to modify eryksun's patch for Python-2.7.15, at least the bulk of 
it.  It looks like the '_PyOS_SigintEvent' function is new to the 3.x branch, 
and despite it being a fairly simple function, it's used in a few core Python 
modules.  So I'm not sure the difficulty of adding it for Python-2.7.  Is there 
an alternative function available in the 2.7 code that I can replace it with?

I also don't have a clue how anyone even builds Python-2.7 on Windows, because 
getting the required tools properly installed borders on the arcane (esp VS2008 
tools).  So testing it might be a bit difficult.  Is there a cheat sheet 
somewhere?

--
nosy: +kumba

___
Python tracker 

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