Re: f-string anomaly

2018-05-13 Thread Ken Kundert
Terry,
Thanks for your response.

I apologize about the double posting. I am well aware how doing so is
bad form. My double posting was unintentional; it occurred when my news
reader misbehaved.

What I did in my code was to put double braces inside the format_spec,
which the syntax specification in the f-string documentation does not
allow, and so it should be a syntax error. But it does not generate a
syntax error. So the question becomes, how does it interpret {{k}} and
{{v}} in the format spec. I was expecting it to treat the double braces
as escaped braces, and that is what the format method does. And by the
last sentence in the following paragraph, it seems like f-strings should
as well.

Top-level format specifiers may include nested replacement fields.
These nested fields may include their own conversion fields and
format specifiers, but may not include more deeply-nested
replacement fields. The format specifier mini-language is the same
as that used by the string .format() method.

> All names in the expression are resolved in the local namespace of the
> f string.  There are other differences.  Nesting can only be one level
> deep.

I tried adding k and v to the local namespace:

...
k = 6
v = 9
print(f'Email: {d:{{k}} {{v}}}')

I still got:

NameError: name 'k' is not defined

I don't know where it is looking for k, but it is not in the local
namespace.

And I don't think the comment on nesting applies. The format string does
not include nested references. Rather "{{k}} {{v}}" is meant to be
treated as a literal string that should de-escaped and passed to the
__format__ method, but no values should be interpolated. What the
__format__ method does with the format spec is not in anyway restricted
by the f string as long as __format__ returns a string.

The comment that the mini-language is the same between the format method
and the f string seems compelling to me. I think this is a bug. I think
the f-string syntax should be updated to explicitly allow escaped braces
in the format_spec, and the implementation of f-strings should be
updated to be consistent with the syntax specification, and with the
format method.

-Ken



On 05/13/2018 07:08 PM, Terry Reedy wrote:
> On 5/13/2018 3:22 PM, Ken Kundert wrote:
> 
> Please do not double post.
> 
>> I am seeing an unexpected difference between the behavior of the string
>> format method and f-strings.
> 
> Read
> https://docs.python.org/3/reference/lexical_analysis.html#formatted-string-literals
> carefully.
> 
>> Here is an example:
>>
>>  import sys, os
>>  from inform import error, os_error
>>
>>  class mydict(dict):
>>  def __format__(self, template):
>>  print('Template:', template)
>>  return ', '.join(template.format(v, k=k, v=v) for k, v in
>> self.items())
>>
>>
>>  d = mydict(bob='239-8402', ted='371-8567', carol='891-5810',
>> alice='552-2219')
>>
>>  print('Using format():')
>>  print('Email: {0:{{k}}: {{v}}}'.format(d))
>>  print()
>>  print('Using f-string:')
>>  print(f'Email: {d:{{k}} {{v}}}')
>>  print()
>>  print('Using f-string:')
>>  print(f'Email: {d:{{k}} {{v}}}', k=6, v=9)
>>
>>
>> It generates the following response:
>>
>>  Using format():
>>  Template: {k}: {v}
>>  Email: bob: 239-8402, ted: 371-8567, carol: 891-5810, alice:
>> 552-2219
>>
>>  Using f-string:
>>  Traceback (most recent call last):
>>  File "tryit", line 18, in 
>>  print(f'Email: {d:{{k}} {{v}}}')
>>  NameError: name 'k' is not defined
> 
> This is what I expected.
> 
>> Essentially I am using a format string as the template that indicates
>> how to format each member of a dictionary, {{k}} should interpolate the
>> key and {{v}} interpolates the value.  This format string is embedded
>> inside another format string, so the braces are doubled up so that they
>> will be ignored by the outer format string.
> 
> "The parts of the string outside curly braces are treated literally,
> except that any doubled curly braces '{{' or '}}' are replaced with the
> corresponding single curly brace. " note 'outside'
> 
>> This idea seems to work okay when using the format() method. You can see
>> I added a print statement inside __format__ that shows that the method
>> is being called.
>>
>> However, trying the same idea with f-strings results in a NameError.  It
>> appears that the escaping does not work when used within the template.
>> It appears the error occurs before __format__ is called (there is no
>> output from the print function).
>>
>> Does anybody know why the format() method would work in this case but
>> the f-string would not?
> 
> All names in the expression are resolved in the local namespace of the f
> string.  There are other differences.  Nesting can only be one level deep.
> 
>> Is this a bug in f-strings?
> 
> Not to me.
> 
> 

-- 
https://mail.python.org/mailman/listinfo/python-list


random.choices() Suggest that the code confirm that cum_weights sequence is in ascending order

2018-05-13 Thread Paul
Hi,
  I just learned how to use random.choices().  I initially misunderstood
the documentation for cum_weights as meaning that a cumulative sequence
would be *constructed from* the sequence which I supplied.  Consequently, I
specified 'cum_weights' with a sequence which wasn't in ascending order.  I
got back k results but I determined that they weren't correct (eg, certain
population values were never returned).

  Since the non-ascending sequence, which I had supplied, could not
possibly be valid input, why isn't this checked (and an error returned)?
 Returning incorrect results (which could be hard to spot as being
incorrect) is much more dangerous.  Also, checking that the list is in
ascending order need only be done once, and seems like it would be
inexpensive.

  Thanks,
  Paul
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue33479] Document tkinter and threads

2018-05-13 Thread Ivan Pozdeev

Ivan Pozdeev  added the comment:

I was composing a letter to python-dev with all I know of how tkinter works 
with regard to threads and Tcl, and the fixing plans so that we're all on the 
same page if you wish to participate.

I'm no longer sure if it belongs in the mailing list so see it in the 
attachment.

The plan I have for fixing the documentation is there towards the end.
It includes what you suggested but is more detailed. I'll recite it below:

---

* Document the current behaviour by rewriting 
https://docs.python.org/3/library/tkinter.html .

   Since I've recently learned Tkinter, I can say which critical information is 
missing and which existing one proved useless.

   Principles:

* include fundamental information critical to understand the module's 
behaviour
* concentrate on reference documentation for the module because it's more 
important to have than a user guide ( 
https://meta.serverfault.com/questions/8934/what-to-do-with-questions-when-the-answer-is-in-a-man-page#comment22241_8938
 )
* split off/drop anything unrelated to the above two

   Resulting scheme:

   0. Intro: +supported Tcl/Tk versions and the two flavors; the fact that 
Tkinter adds its own logic, and the Tkinter doc concentrates on that logic and 
refers to Tcl/Tk docs for details that are taken from there without changes.

   * Move external links section to be bottom.

   1. Architecture. "Unlike most other GUI toolkits, Tcl/Tk consists of a few 
separate modules with a clear distinction between them, and this is 
non-transparect to the user:..." Base on 
https://docs.python.org/3/library/tkinter.html#how-tk-and-tkinter-are-related , 
but focus on what implements what rather than what _calls_ what; drop Xlib 
entry (transparent implementation detail, not required for understanding).

   2. Threading model. The above-described general idea and user-visible 
limitations what can be called where and when. (the letter has details that 
this refers to, too long to recite)

   3. References for `tkinter`, `tkinter.Tk()`, `_tkinter.Tkapp` (public 
interface only -- `call()` at least). Mention which functions cannot be called 
from other threads. Do not mention the two issue33257 bugs.

   * Move widget reference to another page.
   * Drop Python-Tcl mappings unless the reference sections need them as 
supplemental reference.
   * Drop tutorial: too primitive to be useful. Move tutorials to another page 
like https://docs.python.org/3/library/logging.html does.
   * Drop https://docs.python.org/3/library/tk.html -- proved hard to find. 
Make https://docs.python.org/3/library/tkinter.html the head page instead.

* Discuss which of the described behaviour is as intended and which is a bug. 
Proceed with fixing.

--
assignee:  -> docs@python
components: +Documentation
nosy: +Ivan.Pozdeev, docs@python
Added file: https://bugs.python.org/file47586/[Python-Dev] Tkinter threading 
model description and fix plan.eml

___
Python tracker 

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



[issue33490] pthread auto-detection can use AX_PTHREAD

2018-05-13 Thread Eitan Adler

New submission from Eitan Adler :

There is a ton of logic in configure.ac to detect pthreads support. There is a 
standard macro to use instead: 
https://www.gnu.org/software/autoconf-archive/ax_pthread.html#ax_pthread 

In order to simplify our pthread logic we should make use of the standard macro 
instead of writing our own code.

--
components: Build
messages: 316491
nosy: eitan.adler
priority: normal
severity: normal
status: open
title: pthread auto-detection can use AX_PTHREAD
type: enhancement

___
Python tracker 

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



[issue33490] pthread auto-detection can use AX_PTHREAD

2018-05-13 Thread Eitan Adler

Change by Eitan Adler :


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

___
Python tracker 

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



[issue33477] Document that compile(code, 'exec') has different behavior in 3.7+

2018-05-13 Thread INADA Naoki

INADA Naoki  added the comment:

ref #32911

And it's documented already.
https://docs.python.org/3.7/whatsnew/3.7.html#changes-in-the-python-api

--
nosy: +inada.naoki

___
Python tracker 

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



[issue20104] expose posix_spawn(p)

2018-05-13 Thread STINNER Victor

STINNER Victor  added the comment:

For Python 3.7, I discussed with Pablo and he seems to be ok to remove the 
function from Python 3.7, to get more time to polish the API in the master 
branch (future Python 3.8).

Can someone please write a PR to remove the function from the 3.7 branch?

I dislike the idea of applying a significant change on 3.7 to change the API 
between a beta and a rc release. IMHO it's too late, and we might find some API 
bugs. I would prefer to get more feedback on the API before setting it in stone 
(once a 3.x.0 version is released, it's really hard to change the API).

--
priority: deferred blocker -> release blocker

___
Python tracker 

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



Re: pylint/pyreverse with Python3

2018-05-13 Thread Terry Reedy

On 5/13/2018 1:01 PM, Rich Shepard wrote:

   Installed here is pylint-1.7.1 and python-3.6.5. When I try to run
pyreverse (and pylint) on python3 source code it fails because it finds 
only

the python-2.7 site-package and not the python-3.6 site-package.



   If you have learned how to run pylint/pyreverse on python3 code please
share your knowledge with me.


You have to install a package in /site-packages for each version you 
want to run it with.


Then you have to make sure you run the version you intend to run.


--
Terry Jan Reedy


--
https://mail.python.org/mailman/listinfo/python-list


Re: f-string anomaly

2018-05-13 Thread Terry Reedy

On 5/13/2018 3:22 PM, Ken Kundert wrote:

Please do not double post.


I am seeing an unexpected difference between the behavior of the string
format method and f-strings.


Read 
https://docs.python.org/3/reference/lexical_analysis.html#formatted-string-literals 
carefully.



Here is an example:

 import sys, os
 from inform import error, os_error

 class mydict(dict):
 def __format__(self, template):
 print('Template:', template)
 return ', '.join(template.format(v, k=k, v=v) for k, v in
self.items())


 d = mydict(bob='239-8402', ted='371-8567', carol='891-5810',
alice='552-2219')

 print('Using format():')
 print('Email: {0:{{k}}: {{v}}}'.format(d))
 print()
 print('Using f-string:')
 print(f'Email: {d:{{k}} {{v}}}')
 print()
 print('Using f-string:')
 print(f'Email: {d:{{k}} {{v}}}', k=6, v=9)


It generates the following response:

 Using format():
 Template: {k}: {v}
 Email: bob: 239-8402, ted: 371-8567, carol: 891-5810, alice: 552-2219

 Using f-string:
 Traceback (most recent call last):
 File "tryit", line 18, in 
 print(f'Email: {d:{{k}} {{v}}}')
 NameError: name 'k' is not defined


This is what I expected.


Essentially I am using a format string as the template that indicates
how to format each member of a dictionary, {{k}} should interpolate the
key and {{v}} interpolates the value.  This format string is embedded
inside another format string, so the braces are doubled up so that they
will be ignored by the outer format string.


"The parts of the string outside curly braces are treated literally, 
except that any doubled curly braces '{{' or '}}' are replaced with the 
corresponding single curly brace. " note 'outside'



This idea seems to work okay when using the format() method. You can see
I added a print statement inside __format__ that shows that the method
is being called.

However, trying the same idea with f-strings results in a NameError.  It
appears that the escaping does not work when used within the template.
It appears the error occurs before __format__ is called (there is no
output from the print function).

Does anybody know why the format() method would work in this case but
the f-string would not?


All names in the expression are resolved in the local namespace of the f 
string.  There are other differences.  Nesting can only be one level deep.



Is this a bug in f-strings?


Not to me.


--
Terry Jan Reedy

--
https://mail.python.org/mailman/listinfo/python-list


[issue33488] github pull request template does not satisfy markdownlint

2018-05-13 Thread Benjamin Peterson

Benjamin Peterson  added the comment:


New changeset f1ee4a2e52d98698ec2c0a0e8acb6cd3bbc9bf1f by Benjamin Peterson in 
branch '3.7':
[3.7] bpo-33488: Satisfy markdownlint for the pull request template. (GH-6786)
https://github.com/python/cpython/commit/f1ee4a2e52d98698ec2c0a0e8acb6cd3bbc9bf1f


--

___
Python tracker 

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



[issue33489] Newer externals for windows do not always trigger rebuild

2018-05-13 Thread Terry J. Reedy

New submission from Terry J. Reedy :

I added a new 2.7 worktree, with 2.7 checked out to track origin (my github 
fork).  I built Python with tcl/tk 8.5.15.  Whoops, my fork had 2.7 at 2.7.13+. 
 Fetch upstream, merge upstream/2.7, and rebuild.  I noticed that tcl/tk 8.5.19 
was downloaded.  But IDLE subsequently reported that tk was still at 8.5.15.  I 
renamed the 8.5.15 and the compiled tcltk directories, built again, and tcltk 
was recompiled to 8.5.19.  It seems that when new tcl/tk externals are 
downloaded, the compiled tcltk should be deleted.

If I understand, this part of the output says that there was no recompile of 
tcl/tk.

  _hashlib.vcxproj -> f:\dev\27\PCBuild\_hashlib_d.pyd
  _tkinter.c
 Creating library f:\dev\27\PCBuild\_tkinter_d.lib and object 
f:\dev\27\PCBuild\_tkinter_d.e
  xp
  _tkinter.vcxproj -> f:\dev\27\PCBuild\_tkinter_d.pyd
  _bsddb.c

My installed 2.7.15 also has tcl/tk at 8.5.15.  If tcl/tk was upgraded before 
this recent release, the upgrade did not take effect.  

When tcl/tk has been upgraded during 3.x alpha/beta periods, tcl/tk seems to 
have been recompiled when it should be.

The upstream update also caused the following updates:
Fetching bsddb-4.7.25.0...
Fetching openssl-1.0.2o...
Fetching sqlite-3.14.2.0...

There were new compiles to build
f:\dev\27\PCBuild\_sqlite3_d.pyd
f:\dev\27\PCBuild\ssleay_d.lib
f:\dev\27\PCBuild\_bsddb_d.pyd
so I presume these are ok and I can just delete the old directories.

--
components: Build, Windows
messages: 316487
nosy: paul.moore, steve.dower, terry.reedy, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: Newer externals for windows do not always trigger rebuild
type: behavior
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



[issue33488] github pull request template does not satisfy markdownlint

2018-05-13 Thread Benjamin Peterson

Change by Benjamin Peterson :


--
pull_requests: +6474

___
Python tracker 

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



[issue33488] github pull request template does not satisfy markdownlint

2018-05-13 Thread Benjamin Peterson

Change by Benjamin Peterson :


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



[issue33488] github pull request template does not satisfy markdownlint

2018-05-13 Thread Benjamin Peterson

Benjamin Peterson  added the comment:


New changeset 5cd22cf2097a6dd20cf97858d54564a3be87 by Benjamin Peterson 
(Eitan Adler) in branch 'master':
bpo-33488: Satisfy markdownlint for the pull request template. (GH-6786)
https://github.com/python/cpython/commit/5cd22cf2097a6dd20cf97858d54564a3be87


--
nosy: +benjamin.peterson

___
Python tracker 

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



[issue31500] IDLE: Tiny font on HiDPI display

2018-05-13 Thread Terry J. Reedy

Terry J. Reedy  added the comment:

Does IDLE now work on your HiDPI screen without the patch? or does it not work 
even with the patch?  

I just got a 2.7 worktree working with Python built.  2.7.15+ comes with 8.5.19 
instead of 8.5.15.  IDLE runs as I expect and windows look normal, as with 3.x, 
both before and after the patch.  

If calling fix_scaling ever causes anyone a problem on some particular 
combination of OS, Python, and Tk versions, they could neutralize it by adding 
the following after the current definition.

def fix_scaling: pass

--

___
Python tracker 

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



[issue33488] github pull request template does not satisfy markdownlint

2018-05-13 Thread Eitan Adler

Change by Eitan Adler :


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

___
Python tracker 

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



[issue33488] github pull request template does not satisfy markdownlint

2018-05-13 Thread Eitan Adler

New submission from Eitan Adler :

markdownlint is, as the name implies, a tool for linting markdown files.

The current template has the following lint warnings:

```
./.github/PULL_REQUEST_TEMPLATE.md:8: MD031 Fenced code blocks should be 
surrounded by blank lines
./.github/PULL_REQUEST_TEMPLATE.md:10: MD031 Fenced code blocks should be 
surrounded by blank lines
./.github/PULL_REQUEST_TEMPLATE.md:19: MD031 Fenced code blocks should be 
surrounded by blank lines
./.github/PULL_REQUEST_TEMPLATE.md:21: MD031 Fenced code blocks should be 
surrounded by blank lines
```

These should be fixed

--
assignee: docs@python
components: Documentation
messages: 316484
nosy: docs@python, eitan.adler
priority: normal
severity: normal
status: open
title: github pull request template does not satisfy markdownlint
type: enhancement

___
Python tracker 

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



f-string anomaly

2018-05-13 Thread Ken Kundert
I am seeing an unexpected difference between the behavior of the string
format method and f-strings in Python3.6.

Here is an example:

import sys, os
from inform import error, os_error

class mydict(dict):
def __format__(self, template):
print('Template:', template)
return ', '.join(template.format(v, k=k, v=v) for k, v in
self.items())


d = mydict(bob='239-8402', ted='371-8567', carol='891-5810',
alice='552-2219')

print('Using format():')
print('Email: {0:{{k}}: {{v}}}'.format(d))
print()
print('Using f-string:')
print(f'Email: {d:{{k}} {{v}}}')
print()
print('Using f-string:')
print(f'Email: {d:{{k}} {{v}}}', k=6, v=9)


It generates the following response:

Using format():
Template: {k}: {v}
Email: bob: 239-8402, ted: 371-8567, carol: 891-5810, alice: 552-2219

Using f-string:
Traceback (most recent call last):
File "tryit", line 18, in 
print(f'Email: {d:{{k}} {{v}}}')
NameError: name 'k' is not defined

Essentially I am using a format string as the template that indicates
how to format each member of a dictionary, {{k}} should interpolate the
key and {{v}} interpolates the value.  This format string is embedded
inside another format string, so the braces are doubled up so that they
will be ignored by the outer format string.

This idea seems to work okay when using the format() method. You can see
I added a print statement inside __format__ that shows that the method
is being called.

However, trying the same idea with f-strings results in a NameError.  It
appears that the escaping does not work when used within the template.
It appears the error occurs before __format__ is called (there is no
output from the print function).

Does anybody know why the format() method would work in this case but
the f-string would not?

Is this a but in f-strings?

-Ken
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: object types, mutable or not?

2018-05-13 Thread Richard Damon
On 5/13/18 4:02 PM, Mike McClain wrote:
> I'm new to Python and OOP.
> Python  en 2.7.14 Documentation  The Python Language Reference
> 3. Data model
> 3.1. Objects, values and types
> An object's type is also unchangeable. [1]
> [1] It is possible in some cases to change an object's type,
> under certain controlled conditions.
>
> It appears to me as if an object's type is totally mutable and
> solely dependant on assignment.
>
 obj = 'a1b2'
 obj
> 'a1b2'
 type (obj)
> 
 obj = list(obj)
 obj
> ['a', '1', 'b', '2']
 type (obj)
> 
 obj = dict( zip(obj[0::2],obj[1::2]) )
 type (obj)
> 
 obj
> {'a': '1', 'b': '2'}
>
> At what level does my understanding break down?
>
> Thanks,
> Mike
> --
> One reason experience is such a good teacher
> is that she doesn't allow dropouts.

The first this is obj is NOT 'the object', but is instead a reference
that 'points' to an object.

When you said

obj = 'a1b2'

a string object with the value a1b2 was created, and obj was pointed to it.

when you then said

obj = list(obj)

then a new object, a list, was created based on the value of the object
that obj was pointing to (the string 'a1b2') and then obj was set to
point to that new object, and the old string object became unreferenced
and will at some point be cleaned up (if between the two assignment you
did a obj2 = obj, then obj2 would continue to point to that original
string object).

Note that this says that after you assigned obj to the dict, if you then
assigned obj2 = obj and then did an operation that changed the value
stored in the dict (like using a mutating member function that adds a
member to the dict), obj2 would see the changes, because they both refer
to the same fundamental object.

-- 
Richard Damon

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: object types, mutable or not?

2018-05-13 Thread MRAB

On 2018-05-13 21:02, Mike McClain wrote:

I'm new to Python and OOP.
Python  en 2.7.14 Documentation  The Python Language Reference
3. Data model
3.1. Objects, values and types
An object's type is also unchangeable. [1]
[1] It is possible in some cases to change an object's type,
 under certain controlled conditions.

It appears to me as if an object's type is totally mutable and
solely dependant on assignment.


obj = 'a1b2'
obj

'a1b2'

type (obj)




obj = list(obj)
obj

['a', '1', 'b', '2']

type (obj)




obj = dict( zip(obj[0::2],obj[1::2]) )
type (obj)



obj

{'a': '1', 'b': '2'}

At what level does my understanding break down?

You're not mutating an object, you're creating new objects and then 
binding them to the same name.


The name 'obj' refers to a string, then a list, etc.

BTW, you should be using Python 3 unless you really need Python 2. 
Python 2.7 is the last in the Python 2 line, and it'll not longer be 
supported after 2020.

--
https://mail.python.org/mailman/listinfo/python-list


Re: object types, mutable or not?

2018-05-13 Thread Peter J. Holzer
On 2018-05-13 13:02:01 -0700, Mike McClain wrote:
> I'm new to Python and OOP.
> Python  en 2.7.14 Documentation  The Python Language Reference

Python 2 is near end-of-life. If you are new to Python you should use
Python 3 (unless you have to maintain legacy software written in Python
2).

> 3. Data model
> 3.1. Objects, values and types
> An object's type is also unchangeable. [1]
> [1] It is possible in some cases to change an object's type,
> under certain controlled conditions.
> 
> It appears to me as if an object's type is totally mutable and
> solely dependant on assignment.
> 
> >>> obj = 'a1b2'
> >>> obj
> 'a1b2'
> >>> type (obj)
> 
> >>>
> >>> obj = list(obj)
> >>> obj
> ['a', '1', 'b', '2']
> >>> type (obj)
> 
> >>>
> >>> obj = dict( zip(obj[0::2],obj[1::2]) )
> >>> type (obj)
> 
> >>> obj
> {'a': '1', 'b': '2'}
> 
> At what level does my understanding break down?

At the point where you assume that the variable “obj” always contains
the same objects. This is not the case. In fact, variables in Python
never “contain” anything, they are only “bound to” objects (or in other
words, they refer to, or point to objects).


> >>> obj = 'a1b2'

Here an object of type “str” and value 'a1b2' is created. 
> >>> obj
> 'a1b2'
> >>> type (obj)
> 
> >>>
> >>> obj = list(obj)

Here a new object of type list is created. The variable “obj” is bound
to this new object. The old str object isn't needed anymore and
destroyed.

> >>> obj
> ['a', '1', 'b', '2']
> >>> type (obj)
> 
> >>>
> >>> obj = dict( zip(obj[0::2],obj[1::2]) )

And here you create another new object (this time a dict) and bind the
variable to this new obj. Again, the old object isn't needed any more
and destroyed.

There is a good talk about this topic by Ned Batchelder on Youtube:
https://www.youtube.com/embed/_AEJHKGk9ns

25 minutes well spent.

hp

-- 
   _  | Peter J. Holzer| we build much bigger, better disasters now
|_|_) || because we have much more sophisticated
| |   | h...@hjp.at | management tools.
__/   | http://www.hjp.at/ | -- Ross Anderson 


signature.asc
Description: PGP signature
-- 
https://mail.python.org/mailman/listinfo/python-list


object types, mutable or not?

2018-05-13 Thread Mike McClain
I'm new to Python and OOP.
Python  en 2.7.14 Documentation  The Python Language Reference
3. Data model
3.1. Objects, values and types
An object's type is also unchangeable. [1]
[1] It is possible in some cases to change an object's type,
under certain controlled conditions.

It appears to me as if an object's type is totally mutable and
solely dependant on assignment.

>>> obj = 'a1b2'
>>> obj
'a1b2'
>>> type (obj)

>>>
>>> obj = list(obj)
>>> obj
['a', '1', 'b', '2']
>>> type (obj)

>>>
>>> obj = dict( zip(obj[0::2],obj[1::2]) )
>>> type (obj)

>>> obj
{'a': '1', 'b': '2'}

At what level does my understanding break down?

Thanks,
Mike
--
One reason experience is such a good teacher
is that she doesn't allow dropouts.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Leading 0's syntax error in datetime.date module (Python 3.6)

2018-05-13 Thread Peter J. Holzer
On 2018-05-11 12:32:24 +0100, bartc wrote:
> I tried it in Python 3 (0o100.5 - I find that prefix fiddly to type actually
> as I have to stop and think), and it seems to be illegal.

You could also read the docs.


> Based floating point literals may be unusual, but bear in mind that in
> decimal, some values may not be represented exactly (eg 0.1). I believe that
> in base 2, 4, 8 or 16, any floating point literal can be represented
> exactly, at least up the precision available.

Which is why C has hexadecimal floating point literals.

(And of course "any" is only correct if the internal representation is
binary - in general you don't unexpected rounding errors if the base of
the internal representation and the base of the literal match, and you
do get unexpected rounding errors if they don't)

hp

-- 
   _  | Peter J. Holzer| we build much bigger, better disasters now
|_|_) || because we have much more sophisticated
| |   | h...@hjp.at | management tools.
__/   | http://www.hjp.at/ | -- Ross Anderson 


signature.asc
Description: PGP signature
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue33480] Improvement suggestions for urllib.parse.urlparser

2018-05-13 Thread R. David Murray

R. David Murray  added the comment:

These are actually reasonable requests, and in fact have been brought up before 
and implemented:

>>> x = 
>>> urlparse('http://me:myp...@example.com:800/foo;key1=value1?key2=value2#key3=value3#key4=value4')
>>> x
ParseResult(scheme='http', netloc='me:myp...@example.com:800', path='/foo', 
params='key1=value1', query='key2=value2', fragment='key3=value3#key4=value4')
>>> x.hostname
'example.com'
>>> x.port
800
>>> x.username
'me'
>>> x.password
'mypass'
>>> x._asdict()
OrderedDict([('scheme', 'http'), ('netloc', 'me:myp...@example.com:800'), 
('path', '/foo'), ('params', 'key1=value1'), ('query', 'key2=value2'), 
('fragment', 'key3=value3#key4=value4')])


Now, what this doesn't get you is the "extra" fields that are not part of the 
base tuple.  The base tuple has the members it does for backward compatibility. 
 So, the thing to discuss on python-ideas would be an API for namedtuple that 
gets you the extra fields.

None versus the empty string is not something that can happen, for backward 
compatibility reasons, even if there was agreement that it was better.

I'm not entirely sure why dict(x) is not supported (but I suspect it is because 
x is "a tuple", again for backward compatibility reasons), so you might search 
the archives to find out why for sure, if you  are curious.

--
nosy: +r.david.murray
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



[issue33487] BZ2File(buffering=None) does not emit deprecation warning, deprecation version not documented.

2018-05-13 Thread Matthias Bussonnier

Change by Matthias Bussonnier :


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

___
Python tracker 

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



[issue33487] BZ2File(buffering=None) does not emit deprecation warning, deprecation version not documented.

2018-05-13 Thread Matthias Bussonnier

New submission from Matthias Bussonnier :

BZ2File(buffering=None) should emit a deprecation warning as the argument is 
deprecated.

The deprecation message and documentation should say since when it is 
deprecated. (AFAICT since 3.3)

--
messages: 316482
nosy: mbussonn
priority: normal
severity: normal
status: open
title: BZ2File(buffering=None) does not emit deprecation warning, deprecation 
version not documented.

___
Python tracker 

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



[issue33453] from __future__ import annotations breaks dataclasses ClassVar and InitVar handling

2018-05-13 Thread Eric V. Smith

Eric V. Smith  added the comment:

There have been comments on the PR, but I'd like to focus the higher level 
issue back here. Specifically, see my comment 
https://github.com/python/cpython/pull/6768#discussion_r187813919

To summarize: I still think string inspections are the best we can do.

I'm going to try to organize a meeting with Guido, Ivan, and Łukasz at the 
sprints on Monday.

--

___
Python tracker 

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



[issue33274] minidom removeAttributeNode returns None

2018-05-13 Thread Fred L. Drake, Jr.

Fred L. Drake, Jr.  added the comment:

While I've no strong objection to updating to follow the specification, I also 
don't see any real value here.  The current minidom implementation has been 
considered sufficient for many years now (if you consider the DOM desirable at 
all), so the lack of conformance with the W3C spec doesn't seem significant in 
practice.

--
nosy: +fdrake

___
Python tracker 

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



[issue33461] json.loads(encoding=) does not emit deprecation warning.

2018-05-13 Thread Matthias Bussonnier

Matthias Bussonnier  added the comment:

I've opened https://github.com/python/cpython/pull/6784 as an alternative that 
removes it. I was worried to remove it so close to 3.7.

--

___
Python tracker 

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



[issue33461] json.loads(encoding=) does not emit deprecation warning.

2018-05-13 Thread Matthias Bussonnier

Change by Matthias Bussonnier :


--
pull_requests: +6471

___
Python tracker 

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



[issue33480] Improvement suggestions for urllib.parse.urlparser

2018-05-13 Thread Ivan Pozdeev

Ivan Pozdeev  added the comment:

Such drastic changes of uncertain usefulness are best discussed at python-ideas 
first.

What you're really asking for seems to be to parse all "levels" at the same 
time.
Try to think of a use case that would make that help anything practical and 
bring that to the list.
I fail to see any use case 'cuz you never need query parameters and things like 
username/port at the same time.


All else that you suggest is either already being done (username/port parsing, 
read the docs) or likewise has no use cases I can think of where it would make 
things more convenient than they already are (dict emulation, None).

--
nosy: +Ivan.Pozdeev

___
Python tracker 

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



f-string anomaly

2018-05-13 Thread Ken Kundert
I am seeing an unexpected difference between the behavior of the string
format method and f-strings.

Here is an example:

import sys, os
from inform import error, os_error

class mydict(dict):
def __format__(self, template):
print('Template:', template)
return ', '.join(template.format(v, k=k, v=v) for k, v in
self.items())


d = mydict(bob='239-8402', ted='371-8567', carol='891-5810',
alice='552-2219')

print('Using format():')
print('Email: {0:{{k}}: {{v}}}'.format(d))
print()
print('Using f-string:')
print(f'Email: {d:{{k}} {{v}}}')
print()
print('Using f-string:')
print(f'Email: {d:{{k}} {{v}}}', k=6, v=9)


It generates the following response:

Using format():
Template: {k}: {v}
Email: bob: 239-8402, ted: 371-8567, carol: 891-5810, alice: 552-2219

Using f-string:
Traceback (most recent call last):
File "tryit", line 18, in 
print(f'Email: {d:{{k}} {{v}}}')
NameError: name 'k' is not defined

Essentially I am using a format string as the template that indicates
how to format each member of a dictionary, {{k}} should interpolate the
key and {{v}} interpolates the value.  This format string is embedded
inside another format string, so the braces are doubled up so that they
will be ignored by the outer format string.

This idea seems to work okay when using the format() method. You can see
I added a print statement inside __format__ that shows that the method
is being called.

However, trying the same idea with f-strings results in a NameError.  It
appears that the escaping does not work when used within the template.
It appears the error occurs before __format__ is called (there is no
output from the print function).

Does anybody know why the format() method would work in this case but
the f-string would not?

Is this a bug in f-strings?

-Ken
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue33486] regen autotools related files

2018-05-13 Thread Eitan Adler

Change by Eitan Adler :


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

___
Python tracker 

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



[issue33486] regen autotools related files

2018-05-13 Thread Eitan Adler

New submission from Eitan Adler :

There are few if any functional changes, but this is helpful when making other 
changes to the build system.

--
components: Build
messages: 316477
nosy: eitan.adler
priority: normal
severity: normal
status: open
title: regen autotools related files
type: enhancement

___
Python tracker 

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



[issue33484] build system runs when it merely link

2018-05-13 Thread Eitan Adler

Eitan Adler  added the comment:

I believe I have removed the regen step from all my patches. I will separately 
upgrade the generated files (particularly since it is only a minor version 
bump).

--

___
Python tracker 

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



[issue33484] build system runs when it merely link

2018-05-13 Thread R. David Murray

R. David Murray  added the comment:

Yes, we are one of those projects that wants it to be possible to build python 
without having the tools that generate build artifacts.  You will note that we 
also check in build artifacts that are produced by our own python scripts, to 
avoid the problem of trying to build python when you don't yet have a python.

Please use the same version of autotools as were used to generate the current 
files.  Upgrading autotools is done in a separate PR that only does the upgrade 
(and I don't know how we decide when to do that...)

Actually, you could just generate the PR with the changes to the source files, 
not the build artifacte, for the initial review.

--

___
Python tracker 

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



[issue33485] autoconf target does not behave correctly

2018-05-13 Thread Eitan Adler

Change by Eitan Adler :


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

___
Python tracker 

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



[issue33484] build system runs when it merely link

2018-05-13 Thread Eitan Adler

Eitan Adler  added the comment:

The unrelated changes are likely due to the "regen" step. I am using newer 
tools than previously used. It is unclear to me why we include generated files 
in the repository. Some projects prefer this to avoid the need to have 
autotools installed on the build machine.

With regard to "some cases where we really do have to *run* the code to prove 
the function" you will notice that this is not a complete search and replace: I 
manually looked through the various uses of AC_RUN_IFELSE and only changed the 
ones that I thought should be changed. If someone has more knowledge of more 
arcane platforms and disagrees with my assessment, I will happily revert those 
changes.

--

___
Python tracker 

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



[issue33485] autoconf target does not

2018-05-13 Thread Eitan Adler

New submission from Eitan Adler :

The current "autoconf" target is suboptimal in a few ways:
- it does not use a quoted srcdir
- it uses autoheader and autoconf instead of autoreconf
- it does act sanely if 'cd' fails.

--
components: Build
messages: 316472
nosy: eitan.adler
priority: normal
severity: normal
status: open
title: autoconf target does not
type: behavior

___
Python tracker 

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



[issue33485] autoconf target does not behave correctly

2018-05-13 Thread Eitan Adler

Change by Eitan Adler :


--
title: autoconf target does not -> autoconf target does not behave correctly

___
Python tracker 

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



[issue33484] build system runs when it merely link

2018-05-13 Thread R. David Murray

R. David Murray  added the comment:

Thanks for wanting to improve Python.

Your PR seems to contain quite a few changes that aren't obviously related to 
your topic.

As for the topic, I know there are at least some cases where we really do have 
to *run* the code to prove the function is supported by the platform.  That is, 
there are platforms that define the function but it doesn't actually work.  I 
don't know if that applies to the things you are changing, and it will require 
input from people with more knowledge of the build system than I to confirm 
that your changes are a good idea.

--
nosy: +r.david.murray

___
Python tracker 

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



[issue33484] build system runs when it merely link

2018-05-13 Thread Eitan Adler

Change by Eitan Adler :


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

___
Python tracker 

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



[issue33484] build system runs when it merely link

2018-05-13 Thread Eitan Adler

New submission from Eitan Adler :

The build system attempts to run certain test code when it can actually just 
link the code. This is a minor performance optimization but is really a 
semantic correctness issue.

--
components: Build
messages: 316471
nosy: eitan.adler
priority: normal
severity: normal
status: open
title: build system runs when it merely link

___
Python tracker 

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



[issue28055] pyhash's siphash24 assumes alignment of the data pointer

2018-05-13 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

Indeed the memcpy() approach is the common idiom in such situations, and sounds 
like the right thing.

--

___
Python tracker 

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



[issue33483] build system requires explicit compiler, but should discover it

2018-05-13 Thread Eitan Adler

Change by Eitan Adler :


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

___
Python tracker 

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



[issue28055] pyhash's siphash24 assumes alignment of the data pointer

2018-05-13 Thread Stefan Krah

Stefan Krah  added the comment:

MSVC optimizes memcpy() to an assignment, sometimes too well (pgo): 
https://bugs.python.org/issue15993

But that is fixed long ago, so I also think that the memcpy() approach is best.

--

___
Python tracker 

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



[issue33483] build system requires explicit compiler, but should discover it

2018-05-13 Thread Eitan Adler

New submission from Eitan Adler :

configure.ac requires explicit configuration for finding the preferred 
compiler. This results in a non-native way of configuring the system, and does 
not actually work on most platforms.

Expected behavior:

CC is used to discover the C compiler; CPP, LD, CXX, etc. are used to discover 
their appropriate tools

Actual: 
--without-gcc or --with-icc must be explicitly passed

--
components: Build
messages: 316468
nosy: eitan.adler
priority: normal
severity: normal
status: open
title: build system requires explicit compiler, but should discover it
type: compile error

___
Python tracker 

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



pylint/pyreverse with Python3

2018-05-13 Thread Rich Shepard

  Installed here is pylint-1.7.1 and python-3.6.5. When I try to run
pyreverse (and pylint) on python3 source code it fails because it finds only
the python-2.7 site-package and not the python-3.6 site-package.

  If you have learned how to run pylint/pyreverse on python3 code please
share your knowledge with me.

Rich
--
https://mail.python.org/mailman/listinfo/python-list


[issue22269] Resolve distutils option conflicts with priorities

2018-05-13 Thread Nicholas Chammas

Change by Nicholas Chammas :


--
nosy: +nchammas

___
Python tracker 

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



[issue27632] build on AIX fails when builddir != srcdir, more than bad path to ld_so_aix

2018-05-13 Thread Michael Felt

Michael Felt  added the comment:

Wishing I could edit a post...

root@x066:[/data/prj/python]find ./python3-3.4.8 git/python3-3.4.8 -name 
ld_so_aix
./python3-3.4.8/Modules/ld_so_aix

--

___
Python tracker 

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



[issue27632] build on AIX fails when builddir != srcdir, more than bad path to ld_so_aix

2018-05-13 Thread Michael Felt

Michael Felt  added the comment:

OOT builds are working for Python2.7, Python3-3.5, Python3-3.6 (and later I 
expect) but not for Python3-3.4(.8)

unable to execute '../git/python3-3.4.8/Modules/ld_so_aix': No such file or 
directory

while building OOT
root@x066:[/data/prj/python]ls -ld ./python3-3.4.8 git/python3-3.4.8
drwxr-sr-x   12 root 1954   4096 May 13 16:07 ./python3-3.4.8
drwxrwsr-x   16 199  1954   4096 May 13 15:37 git/python3-3.4.8

Sigh. So close!

--
versions: +Python 3.4

___
Python tracker 

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



[issue33482] codecs.StreamRecoder.writelines is broken

2018-05-13 Thread Jelle Zijlstra

Change by Jelle Zijlstra :


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

___
Python tracker 

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



[issue33482] codecs.StreamRecoder.writelines is broken

2018-05-13 Thread Jelle Zijlstra

New submission from Jelle Zijlstra :

codecs.StreamRecoder.writelines is implemented as:

def writelines(self, list):

data = ''.join(list)
data, bytesdecoded = self.decode(data, self.errors)
return self.writer.write(data)

It can't take a list of bytes because then the ''.join throws an error, and it 
can't take a list of str because self.decode takes bytes.

It looks like bytes are intended (self.write takes bytes), so I'll submit a 
simple PR to fix this.

--
messages: 316465
nosy: Jelle Zijlstra
priority: normal
severity: normal
status: open
title: codecs.StreamRecoder.writelines is broken
versions: 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



[issue33464] AIX and "specialized downloads" links

2018-05-13 Thread Michael Felt

Michael Felt  added the comment:

Took me a while to get this 'posted' properly.

- please see https://github.com/python/pythondotorg/issues/1156

My apologies for the noise.

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



Re: seeking deeper (language theory) reason behind Python design choice

2018-05-13 Thread Chris Angelico
On Sun, May 13, 2018 at 9:05 PM, Steven D'Aprano
 wrote:
> On Sat, 12 May 2018 21:42:13 -0500, Python wrote:
>
>> Responding to this further would essentially just require me to
>> reiterate what I already wrote--I won't do that.  I'll simply maintain
>> that in my rather lenghty experience, this mistake has actually been
>> rather rare and has to my knowledge *never* caused a support issue
>> requiring a bug fix to production code in projects I've been associated
>> with.  It's a useful construction whose detriment has, IMO, been
>> completely overblown.
>
> I already linked to the attempt to install a backdoor in the Linux kernel
> with this, but even for accidental errors, thirty seconds on the CVE
> database finds at least one real-world example:
>
> https://www.cvedetails.com/cve/CVE-2009-4633/
>
>
> I expect that these days it will be rare, since most C compilers would
> default to warning about it if you run with warnings enabled.
>

That assumes that you regularly run with warnings enabled. While that
might seem like a no-brainer, unfortunately it isn't. With the number
of C compilers out there, it's hard to make sure your code compiles
cleanly with -Wall on every one of them; and if there's a spew of
warnings, one more isn't going to be noticed. So for a large codebase,
it's entirely possible that it WON'T regularly be compiled with
warnings enabled.

Warnings certainly help, but they're not a complete solution.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue28055] pyhash's siphash24 assumes alignment of the data pointer

2018-05-13 Thread miss-islington

miss-islington  added the comment:


New changeset 0d17e60b33aca1a4d151a8a2bd6eaa331f0ec658 by Miss Islington (bot) 
in branch '3.6':
bpo-28055: Fix unaligned accesses in siphash24(). (GH-6123)
https://github.com/python/cpython/commit/0d17e60b33aca1a4d151a8a2bd6eaa331f0ec658


--

___
Python tracker 

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



[issue33481] configparser.write() does not save comments.

2018-05-13 Thread R. David Murray

Change by R. David Murray :


--
nosy: +lukasz.langa

___
Python tracker 

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



[issue33478] PEP 8 CapWords reference wrong?

2018-05-13 Thread R. David Murray

R. David Murray  added the comment:

In PEP 8 'CapWords" does not refer to the capwords function, as is fairly clear 
from context.  A big clues is that it is not spelled 'capwords', and case 
matters in python function names :)  I can understand your getting confused, 
but that sentence is trying to list the various names give to this style of 
naming, and "CapWords" is one of those names, so I don't know that we should 
delete it.

--
nosy: +r.david.murray
status: open -> closed

___
Python tracker 

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



[issue28055] pyhash's siphash24 assumes alignment of the data pointer

2018-05-13 Thread miss-islington

miss-islington  added the comment:


New changeset 8ed545f6de37efdadbcf71c45bb8136b8cb9619d by Miss Islington (bot) 
in branch '3.7':
bpo-28055: Fix unaligned accesses in siphash24(). (GH-6123)
https://github.com/python/cpython/commit/8ed545f6de37efdadbcf71c45bb8136b8cb9619d


--
nosy: +miss-islington

___
Python tracker 

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



[issue33478] PEP 8 CapWords reference wrong?

2018-05-13 Thread Amit Saha

Amit Saha  added the comment:

Thanks for the reply.  I think I was not clear - the behavior of 
string.capitalize() is correct as per documentation. But the PEP8 referring to 
CapWords as cap words case is the bit I am not clear about, since `Capwords` 
back when you call `string.capwords('CapWords') and not `CapWords`.

(Just reopening so that it doesn't get lost)

--
status: closed -> open

___
Python tracker 

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



Re: seeking deeper (language theory) reason behind Python design choice

2018-05-13 Thread Steven D'Aprano
On Sat, 12 May 2018 21:42:13 -0500, Python wrote:

> Responding to this further would essentially just require me to
> reiterate what I already wrote--I won't do that.  I'll simply maintain
> that in my rather lenghty experience, this mistake has actually been
> rather rare and has to my knowledge *never* caused a support issue
> requiring a bug fix to production code in projects I've been associated
> with.  It's a useful construction whose detriment has, IMO, been
> completely overblown.

I already linked to the attempt to install a backdoor in the Linux kernel 
with this, but even for accidental errors, thirty seconds on the CVE 
database finds at least one real-world example:

https://www.cvedetails.com/cve/CVE-2009-4633/


I expect that these days it will be rare, since most C compilers would 
default to warning about it if you run with warnings enabled.


-- 
Steve

-- 
https://mail.python.org/mailman/listinfo/python-list


[issue28055] pyhash's siphash24 assumes alignment of the data pointer

2018-05-13 Thread miss-islington

Change by miss-islington :


--
pull_requests: +6464

___
Python tracker 

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



[issue28055] pyhash's siphash24 assumes alignment of the data pointer

2018-05-13 Thread miss-islington

Change by miss-islington :


--
pull_requests: +6463

___
Python tracker 

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



[issue28055] pyhash's siphash24 assumes alignment of the data pointer

2018-05-13 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:


New changeset 1e2ec8a996daec65d8d5a3d43b66a9909c6d0653 by Serhiy Storchaka 
(Rolf Eike Beer) in branch 'master':
bpo-28055: Fix unaligned accesses in siphash24(). (GH-6123)
https://github.com/python/cpython/commit/1e2ec8a996daec65d8d5a3d43b66a9909c6d0653


--

___
Python tracker 

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



[issue33474] Support immutability per-field in dataclasses

2018-05-13 Thread Eric V. Smith

Eric V. Smith  added the comment:

Can you explain your use case for this?

Also, how do you envision this working with the existing frozen, hashing, and 
equality behavior? There are a lot of interactions there, and we'd want to do 
something that makes sense holistically, and isn't likely to cause trouble for 
casual users.

I haven't checked, but does attrs do anything like this? It might make sense to 
try out the idea there, first.

--

___
Python tracker 

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



[issue33481] configparser.write() does not save comments.

2018-05-13 Thread David James Peters

New submission from David James Peters :

The ConfigParser().write() does not save the comments; this makes using 
comments harder because it requires a separate demo ini file the user must be 
able to locate and read from without learning anything from the INI file they 
are using. Not Good. Pls make configparser save the comments or guide me to 
what I can do to fully support comments in my app. I am still reading the 
configparser documentation but it says its heavily customizable. Saving and 
loading comments is a must for my ini files.

--
components: Extension Modules
messages: 316457
nosy: pebaudhi
priority: normal
severity: normal
status: open
title: configparser.write() does not save comments.
type: behavior
versions: Python 3.6

___
Python tracker 

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



[issue33471] string format with 'n' failling with french locales

2018-05-13 Thread David Vasseur

David Vasseur  added the comment:

>>> locale.localeconv()
{'int_curr_symbol': 'EUR ', 'currency_symbol': '€', 'mon_decimal_point': ',', 
'mon_thousands_sep': '\u202f', 'mon_grouping': [3, 0], 'positive_sign': '', 
'negative_sign': '-', 'int_frac_digits': 2, 'frac_digits': 2, 'p_cs_precedes': 
0, 'p_sep_by_space': 1, 'n_cs_precedes': 0, 'n_sep_by_space': 1, 'p_sign_posn': 
1, 'n_sign_posn': 1, 'decimal_point': ',', 'thousands_sep': '\u202f', 
'grouping': [3, 0]}

--

___
Python tracker 

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



[issue31500] IDLE: Tiny font on HiDPI display

2018-05-13 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

Something was changed on my computer (I upgraded the OS twice since creating 
this issue), and now I don't see any difference between patched and unpatched 
2.7. Terry, could you please test whether there are any visible effects on 
Windows?

--

___
Python tracker 

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



[issue33480] Improvement suggestions for urllib.parse.urlparser

2018-05-13 Thread brent s.

New submission from brent s. :

Currently, a parsed urlparse() object looks (roughly) like this:

urlparse('http://example.com/foo;key1=value1?key2=value2#key3=value3#key4=value4')

returns:

ParseResult(scheme='http', netloc='example.com', path='/foo', 
params='key1=value1', query='key2=value2', fragment='key3=value3#key4=value4')

However, I recommend a couple things:

0.) that ParseResult objects support dict emulation. e.g. one can run:

dict(parseresult_obj)

and get (using the example string above (corrected classification for 
RFC2986 compliance and common usage):

{'fragment': [('key4', 'value4')],
 'netloc': 'foo.tld',
 'params': [('key2', 'value2')],
 'path': '/foo',
 'query': [('key3', 'value3')],
 'scheme': 'http'}

Obviously, fragment, params, and query could instead be serialized into a 
nested dict. I'm not sure which is more preferred in the pythonic sense.

1.) Better RFC3986 compliance.
Per RFC3986 § 3 (https://tools.ietf.org/html/rfc3986#section-3), the URL 
can be further split into separate components. For instance, while considered 
deprecated, should "userinfo" (e.g. "http://user:password@...;) be parsed? At 
the very least, the port should be parsed out to a separate component from the 
netloc (or userinfo parsed out separate from netloc) - this will assist in 
parsing host:port combinations in netlocs that contain both userinfo and a 
specified port (and allow the port to be given as an int type, thus more easily 
used in e.g. the socket lib).

2.) If a component is not present, I suggest it be a None object instead of an 
empty string.
e.g.:

urlparse('http://example.com/foo')

Would return:

ParseResult(scheme='http', netloc='example.com', path='/foo', 
params=None, query=None, fragment=None)

instead of

ParseResult(scheme='http', netloc='example.com', path='/foo', 
params='', query='', fragment='')

--
components: Library (Lib)
messages: 316454
nosy: bsaner
priority: normal
severity: normal
status: open
title: Improvement suggestions for urllib.parse.urlparser
type: enhancement

___
Python tracker 

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



[issue33478] PEP 8 CapWords reference wrong?

2018-05-13 Thread Berker Peksag

Berker Peksag  added the comment:

'CapWord' is a single word so string.capwords() works as documented:

Split the argument into words using str.split(), capitalize each word
using str.capitalize(), and join the capitalized words using str.join().

https://docs.python.org/3/library/string.html#string.capwords

You can also see this in the REPL:

>>> "CapWord".split()
['CapWord']
>>> _[0].capitalize()  # '_' is a shortcut for the latest command
'Capword'

--
nosy: +berker.peksag
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