[issue38981] better name for re.error Exception class.

2019-12-08 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

I am not sure about the new name. "re" is an abbreviation, so if include it in 
the exception name it should be "RE". I am not sure what name is better: 
RECompileError, REParseError, RESyntaxError, REError, CompileError, ParseError, 
SyntaxError or Error.

json raises JSONDecodeError, ElementTree raises ParseError, other xml modules 
raise ExpatError, csv raises Error, configparser raises subclasses of Error.

Many modules (at least 18: aifc, binhex, concurrent.futures, configparser, 
copy, cvs, ftplib, locale, mailbox, shutil, sqlite, sunau, test.support, uu, 
wave, webbrowser, xdrlib, xmlrpc.client) have an exception named just Error for 
module-specific errors.

--

___
Python tracker 

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



Decorator as a class and Descriptor __get__ working? - cookbook, 9.9, pg 349

2019-12-08 Thread Veek M
I did not follow the grok bit..
He's creating a Descriptor within class 'Spam' by doing 
@Profiled 
def bar()
because Profiled replaces 'bar' with it's instance that contains __get__

which means I have to do s.grok = 20 to trigger it? Which would imply,
s.__get__(instance, instance, value) NOT whatever he's done..  ? How is 
he passing Spam to 'grok'? It should be (self=decorator-instance, Spam-
instance-s and value) being passed to __get__

(for those who don't have the book, he's switched to 'grok' instead of 
'bar')


>>> s = Spam()
>>> def grok(self, x):
... pass
...
>>> grok.__get__(s, Spam)

class Spam:
@Profiled
def bar(self, x):
print(self, x)

import types
from functools import wraps
class Profiled:
def __init__(self, func):
wraps(func)(self)
self.ncalls = 0
  
def __call__(self, *args, **kwargs):
self.ncalls += 1
return self.__wrapped__(*args, **kwargs)

def __get__(self, instance, cls):
if instance is None:
return self
else:
return types.MethodType(self, instance)
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue38669] patch.object should raise another error when first argument is a str

2019-12-08 Thread Chris Withers


Change by Chris Withers :


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



[issue38669] patch.object should raise another error when first argument is a str

2019-12-08 Thread Chris Withers


Chris Withers  added the comment:


New changeset 41973c99fdfdc78315e819661e279bdcc2f058b1 by Chris Withers (Miss 
Islington (bot)) in branch '3.7':
bpo-38669: patch.object now raises a helpful error (GH17511)
https://github.com/python/cpython/commit/41973c99fdfdc78315e819661e279bdcc2f058b1


--

___
Python tracker 

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



[issue38669] patch.object should raise another error when first argument is a str

2019-12-08 Thread Chris Withers


Chris Withers  added the comment:


New changeset 4594565b56e9c99d2d3fb7549041bbca5ecba8e2 by Chris Withers (Miss 
Islington (bot)) in branch '3.8':
bpo-38669: patch.object now raises a helpful error (GH17510)
https://github.com/python/cpython/commit/4594565b56e9c99d2d3fb7549041bbca5ecba8e2


--

___
Python tracker 

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



[issue38993] cProfile behaviour issue with decorator and math.factorial() lib.

2019-12-08 Thread AVicennA


AVicennA  added the comment:

In short, here are different behaviours in increasing steps of values, which 
are (based on my researching) giving incorrect results in relation to each 
other.

Given example:

import functools
import cProfile

def decor(func):
@functools.wraps(func)
def wraps(*args, **kwargs):
return func(*args, **kwargs)
return wraps

@decor
def count(g_val):
if g_val < 1:
print("End")
else:
count(g_val - 1)

cProfile.run('count(VALUE)')


Below I wrote results by given values...

1) VALUE = 50

End 

   
 106 function calls (6 primitive calls) in 0.000 seconds

   


   
   Ordered by: standard name

   


   
   ncalls  tottime  percall  cumtime  percall filename:lineno(function) 

   
10.0000.0000.0000.000 :1()  

   
 51/10.0000.0000.0000.000 main.py:10(count) 

   
 51/10.0000.0000.0000.000 main.py:5(wraps)  

   
10.0000.0000.0000.000 {built-in method exec}

   
10.0000.0000.0000.000 {built-in method print}   

   
10.0000.0000.0000.000 {method 'disable' of 
'_lsprof.Profiler' objects}


2) VALUE = 45   
End 

   
 96 function calls (6 primitive calls) in 0.062 seconds 

   


   
   Ordered by: standard name

   


   
   ncalls  tottime  percall  cumtime  percall filename:lineno(function) 

   
10.0000.0000.0620.062 :1()  

   
 46/10.0000.0000.0610.061 main.py:10(count) 

   
 46/10.0000.0000.0620.062 main.py:5(wraps)  

   
10.0000.0000.0620.062 {built-in method exec}

   
10.0610.0610.0610.061 {built-in method print}   

   
10.0000.0000.0000.000 {method 'disable' of 
'_lsprof.Profiler' objects}


3) VALUE = 26   
End 


[issue38673] REPL shows continuation prompt (...) when comment or space entered

2019-12-08 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

I would prefer that.  I think treating '\n' and ' \n' differently is a bit of a 
bug.  And the fix pretty well matches code/codeop behavior.  I have so far not 
imagined how it could break code.But you could let Ned Deily decide, before 
the next rc, if you want.

I am neutral on 2.7.

--
versions:  -Python 3.5, Python 3.6

___
Python tracker 

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



[issue38673] REPL shows continuation prompt (...) when comment or space entered

2019-12-08 Thread Guido van Rossum


Guido van Rossum  added the comment:

So 3.8.1 got backported by Miss Islington. Do we want this in earlier releases?

--

___
Python tracker 

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



[issue38673] REPL shows continuation prompt (...) when comment or space entered

2019-12-08 Thread miss-islington


miss-islington  added the comment:


New changeset 184a3812b81e2f7d4bc6453bf7ceabe8ac590202 by Miss Islington (bot) 
in branch '3.8':
bpo-38673: dont switch to ps2 if the line starts with comment or whitespace 
(GH-17421)
https://github.com/python/cpython/commit/184a3812b81e2f7d4bc6453bf7ceabe8ac590202


--

___
Python tracker 

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



[issue38673] REPL shows continuation prompt (...) when comment or space entered

2019-12-08 Thread miss-islington


Change by miss-islington :


--
pull_requests: +16993
pull_request: https://github.com/python/cpython/pull/17516

___
Python tracker 

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



[issue38673] REPL shows continuation prompt (...) when comment or space entered

2019-12-08 Thread Guido van Rossum


Guido van Rossum  added the comment:

I'd like to backport this to 3.8.1 at least. Are people interested in getting 
it backported to earlier versions?

--

___
Python tracker 

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



[issue38673] REPL shows continuation prompt (...) when comment or space entered

2019-12-08 Thread miss-islington

miss-islington  added the comment:


New changeset 109fc2792a490ee5cd8a423e17d415fbdedec5c8 by Miss Islington (bot) 
(Batuhan Taşkaya) in branch 'master':
bpo-38673: dont switch to ps2 if the line starts with comment or whitespace 
(GH-17421)
https://github.com/python/cpython/commit/109fc2792a490ee5cd8a423e17d415fbdedec5c8


--
nosy: +miss-islington

___
Python tracker 

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



[issue13501] Make libedit support more generic; port readline / libedit to FreeBSD

2019-12-08 Thread Gregory P. Smith


Change by Gregory P. Smith :


--
versions: +Python 3.9 -Python 2.7, Python 3.4, Python 3.5, Python 3.6, Python 
3.7

___
Python tracker 

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



[issue30458] [security][CVE-2019-9740][CVE-2019-9947] HTTP Header Injection (follow-up of CVE-2016-5699)

2019-12-08 Thread Gregory P. Smith


Gregory P. Smith  added the comment:

i believe new work will be done via the new issue.  marking this closed.  if 
there is something not covered by issue38576 that remains, please open a new 
issue for it.  new discussion on this long issue is easy to get lost in.

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



[issue38576] CVE-2019-18348: CRLF injection via the host part of the url passed to urlopen()

2019-12-08 Thread Gregory P. Smith


Change by Gregory P. Smith :


--
priority: normal -> high

___
Python tracker 

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



Re: python 2 to 3 converter

2019-12-08 Thread jfong
Greg Ewing於 2019年12月9日星期一 UTC+8上午6時18分32秒寫道:
> On 8/12/19 9:30 pm, songbird wrote:
> >wouldn't it make more sense to just go back and fix the
> > converter program than to have to manually convert all this
> > python2 code?
> 
> Anything that isn't already fixed by 2to3 is probably
> somewhere between very difficult and impossible to fix
> using an automated process. It sounds like an interesting
> project, but be aware that it's probably an AI-complete
> problem.
> 
> -- 
> Greg

Even string is hard to be handled by the AI:-)

Quoted from https://portingguide.readthedocs.io/en/latest/strings.html
" ... This means that you need to go through the entire codebase, and decide 
which value is what type. Unfortunately, this process generally cannot be 
automated."

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


[issue38698] While parsing email message id: UnboundLocalError

2019-12-08 Thread Abhilash Raj


Abhilash Raj  added the comment:

Closing this as fixed.

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



[issue38708] parse_message_id in email module is very buggy / crashy

2019-12-08 Thread Abhilash Raj


Abhilash Raj  added the comment:

Closing this as fixed.

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



[issue38708] parse_message_id in email module is very buggy / crashy

2019-12-08 Thread miss-islington


miss-islington  added the comment:


New changeset 2abd3a8f580e6c7b1ce88b2ae9f9a783f4aea5d3 by Miss Islington (bot) 
in branch '3.8':
bpo-38708: email: Fix a potential IndexError when parsing Message-ID (GH-17504)
https://github.com/python/cpython/commit/2abd3a8f580e6c7b1ce88b2ae9f9a783f4aea5d3


--
nosy: +miss-islington

___
Python tracker 

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



[issue38698] While parsing email message id: UnboundLocalError

2019-12-08 Thread miss-islington


miss-islington  added the comment:


New changeset f66f4a09d0b6817fe6a86a567fd506aa223f1563 by Miss Islington (bot) 
in branch '3.8':
bpo-38698: Add a new InvalidMessageID token to email header parser. (GH-17503)
https://github.com/python/cpython/commit/f66f4a09d0b6817fe6a86a567fd506aa223f1563


--

___
Python tracker 

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



[issue38708] parse_message_id in email module is very buggy / crashy

2019-12-08 Thread miss-islington


Change by miss-islington :


--
pull_requests: +16992
pull_request: https://github.com/python/cpython/pull/17515

___
Python tracker 

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



[issue38708] parse_message_id in email module is very buggy / crashy

2019-12-08 Thread Abhilash Raj


Abhilash Raj  added the comment:


New changeset 3ae4ea1931361dd2743e464790e739d9285501bf by Abhilash Raj in 
branch 'master':
bpo-38708: email: Fix a potential IndexError when parsing Message-ID (GH-17504)
https://github.com/python/cpython/commit/3ae4ea1931361dd2743e464790e739d9285501bf


--

___
Python tracker 

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



[issue38698] While parsing email message id: UnboundLocalError

2019-12-08 Thread Abhilash Raj


Abhilash Raj  added the comment:


New changeset 68157da8b42b26408af5d157d2dba4fcf29c6320 by Abhilash Raj in 
branch 'master':
bpo-38698: Add a new InvalidMessageID token to email header parser. (GH-17503)
https://github.com/python/cpython/commit/68157da8b42b26408af5d157d2dba4fcf29c6320


--

___
Python tracker 

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



[issue38698] While parsing email message id: UnboundLocalError

2019-12-08 Thread miss-islington


Change by miss-islington :


--
pull_requests: +16991
pull_request: https://github.com/python/cpython/pull/17514

___
Python tracker 

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



[issue16397] UserString doesn't combine nicely with strings

2019-12-08 Thread Phillip Schanely


Change by Phillip Schanely :


--
nosy: +pschanely

___
Python tracker 

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



[issue38998] dict.setdefault (setdefault of dictionary)

2019-12-08 Thread da-dada


da-dada  added the comment:

my use case is different (I do a loop), but what I expected from the docs (just 
for fun!)

class Ddefault:

def __init__(self):
vars(self).setdefault('default', self.set_default() if not 'default' in 
vars(self) else self.default)
vars(self).setdefault('default', self.set_default() if not 'default' in 
vars(self) else self.default)
print(vars(self))

def set_default(self):
print(vars(self))
return 'default'

if __name__ == "__main__":
Ddefault()

may be the coding diverted from the docs after the fixing of issue 13521 and no 
one dares correcting..
anyway, I will probably keep my old coding (performance, if there is any)

--

___
Python tracker 

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



[issue38993] cProfile behaviour issue with decorator and math.factorial() lib.

2019-12-08 Thread Mark Dickinson


Mark Dickinson  added the comment:

@AVicennA Can you clarify exactly which part of the output you find surprising, 
and why, and what result you expected instead? It's a little hard to tell which 
details in your message we're supposed to be looking at.

--
nosy: +mark.dickinson

___
Python tracker 

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



Re: Aw: Re: stuck on time

2019-12-08 Thread RobH

On 08/12/2019 22:06, Greg Ewing wrote:

On 9/12/19 7:47 am, RobH wrote:
I wanted it to work as is, like it did for the author, without 
changing anything.


So why should I now start to learn how python works.


There are many, many reasons a piece of code could work in one
environment but not another. Figuring out why requires actual
understanding, not just copy-pasting. Part of that involves
gaining at least a basic knowledge of the language you're using.

You can't expect folks here to do all your work for you. We're
trying to help, but we can't debug your code and/or system
remotely, because we don't know everything about it. We can
offer advice, but ultimately you're the one who has to work
it out.

If you don't think the project is worth that much effort,
that's up to you. But you asked for help, and we're doing our
best to give it.



Yes, fair comment that, and I do appreciate the people who do try to help.

Thank you to those.
--
https://mail.python.org/mailman/listinfo/python-list


[issue38594] importlib.metadata documentation deficiencies

2019-12-08 Thread Jason R. Coombs


Jason R. Coombs  added the comment:

Please have a look at 
https://gitlab.com/python-devs/importlib_metadata/merge_requests/104/diffs, 
which attempts to clarify the documentation to indicate how one would implement 
a custom finder. If you have a prototype implementation, I'd be happy to have a 
look.

The use-case you present is exactly the type of use-case this project wishes to 
enable, so I'm grateful that you're working on it and I'd like to do what I can 
to support the effort.

--

___
Python tracker 

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



[issue38987] 3.8.0 on GNU/Linux fails to find shared library

2019-12-08 Thread Christian Heimes


Christian Heimes  added the comment:

Did you update the ld.so cache with ldconfig?

--
nosy: +christian.heimes

___
Python tracker 

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



[issue38901] Add a CLI flag to venv to use the pwd basename as the prompt

2019-12-08 Thread Brett Cannon


Brett Cannon  added the comment:

If it were `.` would we then always check if the prompt was a folder and then 
use the folder's name in that case? Or would it only apply to `.`?

As for `__curdir__`, it could work, but I don't know how easy would that be to 
remember or explain to new users compared to `.`?

My vote is to support `.` and make the rule that if you specify a folder it 
will use the basename automatically.

--

___
Python tracker 

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



Re: Python3 - How do I import a class from another file

2019-12-08 Thread Greg Ewing

On 9/12/19 6:28 am, R.Wieser wrote:



Are you sure there's a difference between classes and functions here?


Yes, quite sure.


And we're even more sure that there isn't. :-) Try it with
a test module containing a class definition, a function
definition and some top-level code that does something
noticeable. You'll find that *any* form of import executes
all the top-level code.

--
Greg

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


[issue38594] importlib.metadata documentation deficiencies

2019-12-08 Thread Jason R. Coombs


Jason R. Coombs  added the comment:

Good suggestions. Thanks for taking the time to articulate in such a friendly 
way the shortcomings you encountered. I'm happy to help.

In [this ticket](https://gitlab.com/python-devs/importlib_metadata/issues/105), 
I've mirrored this ticket in the backport project, where I can iterate much 
faster.

I'll provide brief answers to some of your questions/concerns here and then 
work out the wording for the documentation (and code changes) necessary to 
communicate that effectively.

> The reference to `load_metadata()` is the only occurrence of the string 
> `load_metadata` in the CPython and importlib_metadata code bases. I therefore 
> believe the documentation in both CPython and the importlib_metadata 
> standalone package are wrong because they are referring to a method that is 
> never implemented nor called.

That's right. The documentation is wrong. It should say to implement a 
`Distribution` subclass (especially its abstract methods). Nothing more should 
be necessary.

> I see that certain APIs return Path-like objects (which I will need to 
> implement)

Are you sure about that? The only code I see in the `Distribution` class that 
references a `Path` object is `.at()`, a static method that we decided to add 
to the `Distribution` class even though it would be more appropriate in the 
`PathDistribution` class in order to make that method readily available to 
projects that wished to construct the Path-based distribution objects from a 
file system (or zipfile) path. I'm pretty sure everything else in the 
Distribution class relies on the two abstract methods. If you disregard `at` 
(and I recommend you do) and focus on implementing the abstract methods, I 
think things will work. Let me know if you find otherwise.

> why the Context is optional and how Context could be used?

The interface is intentionally vague in order not to be too prescriptive, 
because as you point out, name or path may not be relevant in some contexts. 
It's meant to narrow the scope of any search.

So if a path is present, that means the query is looking in a specific 
'sys.path' entry. And if the name is present, that means it's looking for a 
distribution having a specific name. But basically, you can solicit any 
properties you like. You could expect a `size='max(100)'` parameter and only 
return distributions smaller than 100 (for whatever interpretation of `size` 
you wish to implement. Your DistributionFinder should do its best to honor 
whatever context might be relevant to the Distributions you provide.

Does PyOxidizer interact with `sys.path` at all? If not, it can disregard 
`Context.path`.

--

___
Python tracker 

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



[issue38998] dict.setdefault (setdefault of dictionary)

2019-12-08 Thread Rémi Lapeyre

Rémi Lapeyre  added the comment:

The documentation is correct, in Python argument are computed before the
call to a function, not when they are used. You can try other functions
than dict.setdefault() and see that the behaviour is always the same.

Le dim. 8 déc. 2019 à 22:47, da-dada  a écrit :

>
> da-dada  added the comment:
>
> I have no problem of making my programme run properly (asking first if in
> dict etc), but I just read the docu of dict.setdefault
>
> setdefault(key[, default])
> If key is in the dictionary, return its value. If not, insert key with a
> value of default and return default. default defaults to None.
>
> and it clearly reads if the key is.. return its value, with a full stop;
> so either the docu is wrong (but proposes exactly the needed shortcut) or
> python is as it is: come in & find out
>
> --
>
> ___
> Python tracker 
> 
> ___
>

--

___
Python tracker 

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



Re: Aw: Re: stuck on time

2019-12-08 Thread DL Neil via Python-list

It's a lot like the misuse of the word "theory".


You mean to say that in theory there is no difference between theory and 
practice, but in practice there is?


--
Regards =dn
--
https://mail.python.org/mailman/listinfo/python-list


Re: ModuleNotFoundError: No module named 'email.mime'; 'email' is not a package

2019-12-08 Thread DL Neil via Python-list

On 9/12/19 8:13 AM, b...@bbhoyer.com wrote:

Just registered
Thanks


Hi @bob, welcome to the gang...



  I am a beginner in Python, been working on class material from Mosh

...


  from email.mime.multipart import MIMEMultipart

...


  Here is the error message:
  Traceback (most recent call last):
    File "c:\Users\Owner\Desktop\HelloWorld\[5]email.py", line 1, in 

  from email.mime.multipart import MIMEMultipart
    File "c:\Users\Owner\Desktop\HelloWorld\[6]email.py", line 1, in 

  from email.mime.multipart import MIMEMultipart
  ModuleNotFoundError: No module named 'email.mime'; 'email' is not a 
package
  I have spent some time trying to figure out resolve ...
  Can you help me with this pistol of a problem …



("pistol"? ...he says, manfully-struggling with the temptation to 
suggest that you "make love not war"...)



Let's look at the information given (in the "stack trace":

<>>


On line 1, the code requests that a module named/addressed as 
"email.mime.multipart" be located ("found"), and an object 
("MIMEMultipart") be imported (etc, etc).


So, when executing line 1, Python was unable to find the specified 
module (let's over-simplify and use the word: "file").



Libraries from the Python Standard Library are not included in the basic 
"python" download, and have to be added/separately downloaded, when 
needed. I suspect this is the problem (but may not be)!



Sadly, I am not a user of MS-Win, so am loath to try to help much more, 
for fear of leading you along the wrong track.  Herewith some self-study 
which should put your boots (back) on the ground...



WebRefs: installing packages
This is more readable: 
https://protechguides.com/how-to-install-python-library/
This is from 'the book of words': 
https://packaging.python.org/tutorials/installing-packages/


NB I understand that "pip" is installed on MS-Win as part of python, so 
you don't need to worry about that/can quickly check. If your course has 
not taken you through "virtual environments" then feel free to ignore 
such, for now.

--
Regards =dn
--
https://mail.python.org/mailman/listinfo/python-list


Re: Aw: Re: stuck on time

2019-12-08 Thread MRAB

On 2019-12-08 20:34, Michael Torrie wrote:

On 12/8/19 11:47 AM, RobH wrote:

Err, excuse me, I was not attempting to hack into someone else's code.
As the code is in the public domain, I wanted it to work as is, like it 
did for the author, without changing anything.


No worries, you're totally fine.  The word "hack" means something
different.  To hack means to work on, learn, modify, etc.  It's a
positive word in this context.  I was hacking on python code myself
yesterday.

The word for breaking into a system or program is/was "crack", like in 
"safe-cracking". In common parlance, however, people have picked up the 
word "hack" instead, which, as Michael says, means something else.


It's a lot like the misuse of the word "theory".

[snip]
--
https://mail.python.org/mailman/listinfo/python-list


Re: ModuleNotFoundError: No module named 'email.mime'; 'email' is not a package

2019-12-08 Thread MRAB

On 2019-12-08 19:13, b...@bbhoyer.com wrote:

Just registered
Thanks

   Original Message 
  Subject: ModuleNotFoundError: No module named 'email.mime'; 'email' is
  not a package
  From: <[1]b...@bbhoyer.com>
  Date: Sun, December 08, 2019 11:14 am
  To: [2]python-list@python.org

  Hello Python Team,
  I am a beginner in Python, been working on class material from Mosh
  youtube 6 hrs., Mosh 12 hr paid course; Python Cash Course by Eric
  Matthes  … most of the time everything works just fine or a little
  adjustment for updated versions.
  I am running Python 3.8.0
  In example, Mosh 12 hr course, he did an exercise on sending email from
  within Python, so here is the code :
  from email.mime.multipart import MIMEMultipart
  from email.mime.text import MIMEText
  import smtplib
  message = MIMEMultipart()
  message["from"] = "Bob Hoyer = Python"
  message["to"] = "[3]b...@bbhoyer.com"
  message["subject"] = "This is a test using Python"
  message.attach(MIMEText("Body"))
  # godaddy recommended SMTP_SSL, host name & port #
  with smtplib.SMTP(host="smtpout.secureserver.net", port=465) as smtp:
  smtp.ehlo()
  # godaddy recommended removing ...
  # smtp.starttls()
  smtp.login("[4]em...@email.com", "password")  #email login &
  password blanked out for this msg
  smtp.send_message(message)
  print("Sent ...")
  smtp.close()
  Here is the error message:
  Traceback (most recent call last):
    File "c:\Users\Owner\Desktop\HelloWorld\[5]email.py", line 1, in 

  from email.mime.multipart import MIMEMultipart
    File "c:\Users\Owner\Desktop\HelloWorld\[6]email.py", line 1, in 

  from email.mime.multipart import MIMEMultipart
  ModuleNotFoundError: No module named 'email.mime'; 'email' is not a 
package
  I have spent some time trying to figure out resolve ...
  Can you help me with this pistol of a problem …
  Bob Hoyer


[snip]
I notice you have files called "[5]email.py" and "[6]email.py". Do you 
also have one called "email.py"?


If so, then what's happening is that Python is finding that one before 
the one in the stdlib.

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


Re: python 2 to 3 converter

2019-12-08 Thread Greg Ewing

On 8/12/19 9:30 pm, songbird wrote:

   wouldn't it make more sense to just go back and fix the
converter program than to have to manually convert all this
python2 code?


Anything that isn't already fixed by 2to3 is probably
somewhere between very difficult and impossible to fix
using an automated process. It sounds like an interesting
project, but be aware that it's probably an AI-complete
problem.

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


Re: stuck on time

2019-12-08 Thread Greg Ewing

On 9/12/19 7:46 am, Dennis Lee Bieber wrote:

Minecraftia appears to be a monospaced font meant to look like the
character set of old 8-bit gaming systems from the 80s.


From the name, it's probably mean to resemble the font in
Minecraft. As used in the game it's not actually monospaced, but
it is designed for very low resolution, so it's probably a
reasonable choice for use on a small display.

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


Re: Aw: Re: stuck on time

2019-12-08 Thread Greg Ewing

On 9/12/19 7:47 am, RobH wrote:
I wanted it to work as is, like it 
did for the author, without changing anything.


So why should I now start to learn how python works.


There are many, many reasons a piece of code could work in one
environment but not another. Figuring out why requires actual
understanding, not just copy-pasting. Part of that involves
gaining at least a basic knowledge of the language you're using.

You can't expect folks here to do all your work for you. We're
trying to help, but we can't debug your code and/or system
remotely, because we don't know everything about it. We can
offer advice, but ultimately you're the one who has to work
it out.

If you don't think the project is worth that much effort,
that's up to you. But you asked for help, and we're doing our
best to give it.

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


[issue38998] dict.setdefault (setdefault of dictionary)

2019-12-08 Thread da-dada


da-dada  added the comment:

I have no problem of making my programme run properly (asking first if in dict 
etc), but I just read the docu of dict.setdefault

setdefault(key[, default]) 
If key is in the dictionary, return its value. If not, insert key with a value 
of default and return default. default defaults to None.

and it clearly reads if the key is.. return its value, with a full stop;
so either the docu is wrong (but proposes exactly the needed shortcut) or 
python is as it is: come in & find out

--

___
Python tracker 

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



[issue38993] cProfile behaviour issue with decorator and math.factorial() lib.

2019-12-08 Thread AVicennA


AVicennA  added the comment:

Hello, I use decorators in my Python project. I tested project with 
cProfile(profiling). Then,
I decide did test with some decorator code fragments. Some results were 
surprising:

import functools
import cProfile

def decor(func):
@functools.wraps(func)
def wraps(*args, **kwargs):
return func(*args, **kwargs)
return wraps

@decor
def count(g_val):
if g_val < 1:
print("End")
else:
count(g_val - 1)
 
cProfile.run('count(102)')

OS names: Windows, Linux  -  x64
Python versions: 3.6.8, 3.4.3  -  x64

# cProfile using into the .py file
python dec_profile.py

End
 210 function calls (6 primitive calls) in 0.000 seconds

   Ordered by: standard name

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
10.0000.0000.0000.000 :1()
103/10.0000.0000.0000.000 timeer.py:10(count)
103/10.0000.0000.0000.000 timeer.py:5(wraps)
10.0000.0000.0000.000 {built-in method builtins.exec}
10.0000.0000.0000.000 {built-in method builtins.print}
10.0000.0000.0000.000 {method 'disable' of 
'_lsprof.Profiler' objects}

# Instead of 102 used ---> 82, 22, 33, 72 and etc. also gave me strange results 
like in 102. 
This behaviour can be changing sometimes, but usually give an incorrect results.

import functools
import cProfile

def decor(func):
@functools.wraps(func)
def wraps(*args, **kwargs):
return func(*args, **kwargs)
return wraps

@decor
def count(g_val):
if g_val < 1:
print("End")
else:
count(g_val - 1)
 
count(102)

# cProfile using via command line
python -m cProfile dec_profile.py

End
 539 function calls (334 primitive calls) in 0.002 seconds

   Ordered by: standard name

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
10.0000.0000.0000.000 :103(release)
10.0000.0000.0000.000 :143(__init__)
10.0000.0000.0000.000 :147(__enter__)
10.0000.0000.0000.000 :151(__exit__)
10.0000.0000.0000.000 :157(_get_module_lock)
10.0000.0000.0000.000 :176(cb)
10.0000.0000.0000.000 :211(_call_with_frames_removed)
   260.0000.0000.0000.000 :222(_verbose_message)
10.0000.0000.0000.000 :307(__init__)
10.0000.0000.0000.000 :311(__enter__)
10.0000.0000.0000.000 :318(__exit__)
40.0000.0000.0000.000 :321()
10.0000.0000.0000.000 :35(_new_module)
10.0000.0000.0000.000 :369(__init__)
20.0000.0000.0000.000 :403(cached)
10.0000.0000.0000.000 :416(parent)
10.0000.0000.0000.000 :424(has_location)
10.0000.0000.0000.000 :504(_init_module_attrs)
10.0000.0000.0000.000 :564(module_from_spec)
10.0000.0000.0000.000 :58(__init__)
10.0000.0000.0000.000 :651(_load_unlocked)
10.0000.0000.0000.000 :707(find_spec)
10.0000.0000.0000.000 :78(acquire)
10.0000.0000.0000.000 :780(find_spec)
30.0000.0000.0000.000 :843(__enter__)
30.0000.0000.0000.000 :847(__exit__)
10.0000.0000.0010.001 :870(_find_spec)
10.0000.0000.0010.001 :936(_find_and_load_unlocked)
10.0000.0000.0010.001 :966(_find_and_load)
60.0000.0000.0000.000 :1080(_path_importer_cache)
10.0000.0000.0010.001 :1117(_get_spec)
10.0000.0000.0010.001 :1149(find_spec)
10.0000.0000.0000.000 :1228(_get_spec)
50.0000.0000.0010.000 :1233(find_spec)
20.0000.0000.0000.000 :263(cache_from_source)
10.0000.0000.0000.000 :361(_get_cached)
50.0000.0000.0000.000 :37(_relax_case)
10.0000.0000.0000.000 :393(_check_name_wrapper)
10.0000.0000.0000.000 :430(_validate_bytecode_header)
10.0000.0000.0000.000 :485(_compile_bytecode)
20.0000.0000.0000.000 :52(_r_long)
10.0000.0000.0000.000 :524(spec_from_file_location)
   250.0000.0000.0000.000 :57(_path_join)
   250.0000.0000.0000.000 :59()
20.0000.0000.0000.000 :63(_path_split)
10.0000.0000.0000.000 :669(create_module)
10.0000.0000.0000.000 :672(exec_module)
10.0000.000

[issue38997] test__xxsubinterpreters test_atexit test_capi test_threading are leaking references

2019-12-08 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

Thanks for the fix, Victor!

--

___
Python tracker 

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



Re: Python3 - How do I import a class from another file

2019-12-08 Thread DL Neil via Python-list

On 9/12/19 7:29 AM, R.Wieser wrote:
...


Note that in all cases when you import a module (either by import the_file
or from the_file importe whatever) you actually import ALL of it


So much for my assumption only the class itself would be loaded - and a
wrench into my idea to have a number of classes in a "library" file.


There are three separate ideas which may be confusing:
1 we can 'load' a single class from a module, and
2 we can have 'library files' ("modules") which contains more than one 
importable-object

3 when a module is imported, parts of it are/may be executed at import-time

...


Update: While testing a bit more it turned out that, in the testcode, my
creating an instance with the same name as the class is to blame (who again
said that it isn't a good idea to use confusing names ?).  The moment I
changed the name of the instance everything works as expected.


and then there are the concepts of "scope" and "namespace".


Some of this you will know. (Hopefully) some will be 'new':


import moduleNM

- imports the entire contents of the module and executes what can be. 
This means that functions and classes are defined, and any executable 
code in the 'mainline', eg print( "Hello World" ); will be run.
- from that time you may then refer to the objects detailed within the 
module, eg


a = moduleNM.ClassA()

- note how the module has become part of the program, but occupies a 
separate "namespace"



from moduleNM import ClassA

- changes things so that you may now refer to ClassA without mention of 
the moduleNM, ie brings the name "ClassA" into the current namespace

- causes confusion if there is already a ClassA in the current namespace!


from moduleNM import ClassA as ClassA2

- also obviates the need to mention moduleNM/adds to the current namespace
- allows use of both ClassA-s - the 'local' ClassA as "ClassA", as well 
as providing an alias ("ClassA2") to the ClassA defined in moduleNM



import moduleNM as aliasNM; is also available!


WebRefs:
A comfortably readable expansion of the above: 
https://www.digitalocean.com/community/tutorials/how-to-import-modules-in-python-3
Python's view of (import-able) modules: 
https://docs.python.org/3/tutorial/modules.html
Other questions answered: 
https://docs.python.org/3/faq/programming.html?highlight=import, eg 
what-are-the-best-practices-for-using-import-in-a-module
The importlib library which under-pins "import": 
https://docs.python.org/3/reference/import.html
The full-fat range of import-possibilities: 
https://docs.python.org/3/library/modules.html--

Regards =dn
--
https://mail.python.org/mailman/listinfo/python-list


RE: ModuleNotFoundError: No module named 'email.mime'; 'email' is not a package

2019-12-08 Thread bob
   Just registered 
   Thanks

  Original Message 
 Subject: ModuleNotFoundError: No module named 'email.mime'; 'email' is
 not a package
 From: <[1]b...@bbhoyer.com>
 Date: Sun, December 08, 2019 11:14 am
 To: [2]python-list@python.org

 Hello Python Team, 
 I am a beginner in Python, been working on class material from Mosh
 youtube 6 hrs., Mosh 12 hr paid course; Python Cash Course by Eric
 Matthes  … most of the time everything works just fine or a little
 adjustment for updated versions.
 I am running Python 3.8.0 
 In example, Mosh 12 hr course, he did an exercise on sending email from
 within Python, so here is the code :
 from email.mime.multipart import MIMEMultipart
 from email.mime.text import MIMEText
 import smtplib
 message = MIMEMultipart()
 message["from"] = "Bob Hoyer = Python"
 message["to"] = "[3]b...@bbhoyer.com"
 message["subject"] = "This is a test using Python"
 message.attach(MIMEText("Body"))
 # godaddy recommended SMTP_SSL, host name & port #
 with smtplib.SMTP(host="smtpout.secureserver.net", port=465) as smtp:
 smtp.ehlo()
 # godaddy recommended removing ...
 # smtp.starttls()
 smtp.login("[4]em...@email.com", "password")  #email login &
 password blanked out for this msg
 smtp.send_message(message)
 print("Sent ...")
 smtp.close()
 Here is the error message: 
 Traceback (most recent call last):
   File "c:\Users\Owner\Desktop\HelloWorld\[5]email.py", line 1, in 
 from email.mime.multipart import MIMEMultipart
   File "c:\Users\Owner\Desktop\HelloWorld\[6]email.py", line 1, in 
 from email.mime.multipart import MIMEMultipart
 ModuleNotFoundError: No module named 'email.mime'; 'email' is not a package
 I have spent some time trying to figure out resolve ...
 Can you help me with this pistol of a problem … 
 Bob Hoyer

References

   Visible links
   1. mailto:b...@bbhoyer.com
   2. mailto:python-list@python.org
   3. mailto:b...@bbhoyer.com
   4. mailto:em...@email.com
   5. http://email.py/
   6. http://email.py/
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue39001] possible problem with 64-bit mingw DECREF

2019-12-08 Thread Dave Lawrence


New submission from Dave Lawrence :

I am calling a python method from C using the attached code.

The Site.py file is:

import os

def find_site():
path = os.path.abspath(".")
return path

Cross compiled to Windows from Linux using mxe.cc and python 2.7.17
On 32-bit this runs as expected:

module = 028BC710
result = 0283D6B0
Found Site at \\wsl$\Ubuntu\home\dl
result = 0283D6B0 decref
module = 028BC710 decref

Site = \\wsl$\Ubuntu\home\dl
but crashes on 64-bit, failing to DECREF result:

module = 02750408
result = 00E62EF0
Found Site at \\wsl$\Ubuntu\home\dl
result = 00E62EF0 decref

In both cases the libpython was made using the .dll copied from the target 
Windows machine and pexports and dlltool to create the .a

 if the return value of the python is return "C:/Test/Path" it works. if you 
add test2 = test and return test2 it fails. if you say test2 = "".join(c for c 
in path) and return test2 it fails. if you set path2 = "C:/Test/Path and return 
test2 it works

using Py_REFCNT [in the C code] shows a value of 2 for a return "c:/test" but a 
value of 1 a return test

--
components: Library (Lib), Windows
files: py.cc
messages: 358033
nosy: Dave Lawrence, paul.moore, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: possible problem with 64-bit mingw DECREF
type: crash
versions: Python 2.7
Added file: https://bugs.python.org/file48767/py.cc

___
Python tracker 

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



[issue38997] test__xxsubinterpreters test_atexit test_capi test_threading are leaking references

2019-12-08 Thread STINNER Victor


Change by STINNER Victor :


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

___
Python tracker 

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



[issue38997] test__xxsubinterpreters test_atexit test_capi test_threading are leaking references

2019-12-08 Thread STINNER Victor


STINNER Victor  added the comment:

I validated that my commit 080ee5a88406fb68aaab741145cd5d2a7c5f2ad6 fixed the 
leaks, so I closed PR 17509 and I close this issue. Thanks for the bug report 
Pablo! I was also awaiting Refleak buildbot results!

$ ./python -m test -R 3:3 -j0  test__xxsubinterpreters test_atexit test_capi 
test_threading
(...)
All 4 tests OK.

Total duration: 1 min 4 sec
Tests result: SUCCESS

--

___
Python tracker 

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



[issue38992] testFsum failure caused by constant folding of a float expression

2019-12-08 Thread Mark Dickinson


Mark Dickinson  added the comment:

@xdegaye Please could you test whether the PR GH-17513 fixes the issue for you?

--

___
Python tracker 

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



[issue38997] test__xxsubinterpreters test_atexit test_capi test_threading are leaking references

2019-12-08 Thread STINNER Victor


STINNER Victor  added the comment:

This reference leak is not new :-) It exists since at least Python 2.7. Extract 
of Python 2.7, Python/pythonrun.c:

sysmod = _PySys_Init();
if (sysmod == NULL)
Py_FatalError("Py_Initialize: can't initialize sys");
interp->sysdict = PyModule_GetDict(sysmod);

There is a missing Py_DECREF(sysmod). It was the same bug here, except that the 
code was deeply refactored in the meanwhile. I fixed the reference leak in 
commit 080ee5a88406fb68aaab741145cd5d2a7c5f2ad6.

Next question: why did the buildbot turn red? Well, at Python exit, there are 
like 18k references which are never decremented at Python exit:

$ ./python -X showrefcount -c pass
[18562 refs, 6494 blocks]

Previously, the subinterpreter sys module somehow shared references with the 
main interpreter. With my latest changes, the subinterpreter better isolates 
its own sys module from the main interpreter, and so the very old bug suddenyl 
is "releaved".

Getting subinterpreter "right" requires to fix all these very old bugs, one by 
one...

--

___
Python tracker 

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



[issue38992] testFsum failure caused by constant folding of a float expression

2019-12-08 Thread Mark Dickinson


Change by Mark Dickinson :


--
keywords: +patch
pull_requests: +16990
stage: needs patch -> patch review
pull_request: https://github.com/python/cpython/pull/17513

___
Python tracker 

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



[issue38858] new_interpreter() should reuse more Py_InitializeFromConfig() code

2019-12-08 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 080ee5a88406fb68aaab741145cd5d2a7c5f2ad6 by Victor Stinner in 
branch 'master':
bpo-38858: Fix ref leak in pycore_interp_init() (GH-17512)
https://github.com/python/cpython/commit/080ee5a88406fb68aaab741145cd5d2a7c5f2ad6


--

___
Python tracker 

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



[issue38997] test__xxsubinterpreters test_atexit test_capi test_threading are leaking references

2019-12-08 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 080ee5a88406fb68aaab741145cd5d2a7c5f2ad6 by Victor Stinner in 
branch 'master':
bpo-38858: Fix ref leak in pycore_interp_init() (GH-17512)
https://github.com/python/cpython/commit/080ee5a88406fb68aaab741145cd5d2a7c5f2ad6


--

___
Python tracker 

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



[issue39000] Range causing unstable output(Windows64)

2019-12-08 Thread Mark Dickinson


Mark Dickinson  added the comment:

This has nothing to do with range. The source of indeterminacy is this line in 
your code:

for amp_id in amp_programs.keys():

In Python 3.5, the ordering of `amp_programs.keys()` could differ from run to 
run. (With Python 3.6 and later, that won't happen.)

If you want a deterministic result in Python 3.5, you could for example replace 
that line with:

for amp_id in sorted(amp_programs):

Closing here; this isn't a Python bug.

--
nosy: +mark.dickinson
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



Re: Regarding problem in python 3.8.0 installation

2019-12-08 Thread Terry Reedy

On 12/8/2019 1:08 PM, alok singh wrote:


My system is windows 7 SP1 32-bit . after installing python in my
system,when i try to launch it using command prompt then a message is
shown. I am attaching a screenshot of the following.


Screenshots are not allowed.  Copy and paste from CommandPrompt.


--
Terry Jan Reedy

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


Re: Aw: Re: stuck on time

2019-12-08 Thread Michael Torrie
On 12/8/19 11:47 AM, RobH wrote:
> Err, excuse me, I was not attempting to hack into someone else's code.
> As the code is in the public domain, I wanted it to work as is, like it 
> did for the author, without changing anything.

No worries, you're totally fine.  The word "hack" means something
different.  To hack means to work on, learn, modify, etc.  It's a
positive word in this context.  I was hacking on python code myself
yesterday.

> So why should I now start to learn how python works.

Well if you learn how Python works, then a lot of what you are trying to
do will become easier and make more sense.  For example, knowing how
Python works will tell you why your print_time() function returns
nothing (hint, the code you posted does not show a "return" statement,
hence the function will not return anything).

> If the code doesn't work for me after a fair trial, I'll move on to 
> something else.

I can sense that you are frustrated, and I can also sense frustration on
the part of those trying to assist you. I hope you will give it a fair
trial as the entire endeavor, and Python in particular, can be really
fun once you grasp it!

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


[issue38994] Implement __class_getitem__ for PathLike

2019-12-08 Thread Andrew Svetlov


Change by Andrew Svetlov :


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



[issue38994] Implement __class_getitem__ for PathLike

2019-12-08 Thread miss-islington

miss-islington  added the comment:


New changeset 526606baf76e7a5309bb00f3bfaefa861a2014ba by Miss Islington (bot) 
(Batuhan Taşkaya) in branch 'master':
bpo-38994: Implement __class_getitem__ for PathLike (GH-17498)
https://github.com/python/cpython/commit/526606baf76e7a5309bb00f3bfaefa861a2014ba


--
nosy: +miss-islington

___
Python tracker 

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



[issue38992] testFsum failure caused by constant folding of a float expression

2019-12-08 Thread Mark Dickinson


Mark Dickinson  added the comment:

Note that the exact values of `1.7**i` don't matter here - some sloppiness in 
the `pow` results should not cause a test failure. The key point is that under 
fairly mild assumptions about IEEE 754 conformance, the subtractions 
`1.7**(i+1) - 1.7**i` are always performed exactly, thanks to Sterbenz's lemma.

--

___
Python tracker 

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



[issue38992] testFsum failure caused by constant folding of a float expression

2019-12-08 Thread Mark Dickinson


Mark Dickinson  added the comment:

So if I'm understanding correctly, the cause of the issue is that the value 
`1.7**(i+1)` computed in the last iteration (i=999) of the list comprehension 
doesn't exactly match the `-1.7**1000` value, because the former is computed at 
runtime using the libm's pow, while the latter is constant-folded and likely 
uses something more accurate than `pow`.

I think it should be easy to rewrite the test so that it precomputes the powers 
of `1.7`, and then makes sure to use those computed values (i.e., so that we're 
only computing `1.7**1000` once rather than twice, eliminating the possibility 
of getting different results).

--

___
Python tracker 

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



[issue38858] new_interpreter() should reuse more Py_InitializeFromConfig() code

2019-12-08 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +16988
pull_request: https://github.com/python/cpython/pull/17512

___
Python tracker 

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



[issue38997] test__xxsubinterpreters test_atexit test_capi test_threading are leaking references

2019-12-08 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +16989
pull_request: https://github.com/python/cpython/pull/17512

___
Python tracker 

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



[issue38669] patch.object should raise another error when first argument is a str

2019-12-08 Thread miss-islington


Change by miss-islington :


--
pull_requests: +16987
pull_request: https://github.com/python/cpython/pull/17511

___
Python tracker 

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



[issue38669] patch.object should raise another error when first argument is a str

2019-12-08 Thread miss-islington


Change by miss-islington :


--
pull_requests: +16986
pull_request: https://github.com/python/cpython/pull/17510

___
Python tracker 

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



[issue38669] patch.object should raise another error when first argument is a str

2019-12-08 Thread Chris Withers


Chris Withers  added the comment:


New changeset cd90a52983db34896a6335a572d55bdda274778f by Chris Withers (Elena 
Oat) in branch 'master':
bpo-38669: patch.object now raises a helpful error (GH17034)
https://github.com/python/cpython/commit/cd90a52983db34896a6335a572d55bdda274778f


--

___
Python tracker 

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



[issue39000] Range causing unstable output(Windows64)

2019-12-08 Thread Sean Moss


New submission from Sean Moss :

I was doing this year's Advent of Code and found that the following program 
produces unstable output when run using the given file as input:
"""
from itertools import permutations
import gc

def runProgram(amp_input, program, counter):
while program[counter] != 99:
# print('*' * 99)
instruction = str(program[counter])
opcode = instruction[-2:]
value1 = program[counter + 1]
# print('2:{}'.format(counter))
try:
if opcode in ['01', '02', '1', '2', '5', '05', '6', '06', '7', 
'07', '8', '08']:
value1 = program[counter + 1]
value2 = program[counter + 2]
param_modes = instruction[::-1][2:]
# print('{} {} {} {}'.format(instruction, value1, value2, 
value3))
param_modes += '0' * (3 - len(param_modes))
# print(param_modes)
if param_modes[0] == '0':
value1 = program[value1]
if param_modes[1] == '0':
value2 = program[value2]
# print('{} {} {} {}'.format(instruction, value1, value2, 
value3))
if opcode in ['01', '02', '1', '2', '7', '07', '8', '08']:
value3 = program[counter + 3]
if opcode.endswith('1'):
program[value3] = value1 + value2
elif opcode.endswith('2'):
program[value3] = value1 * value2
elif opcode in ['7', '07']:
program[value3] = 1 if value1 < value2 else 0
elif opcode in ['8', '08']:
program[value3] = 1 if value1 == value2 else 0
counter += 4
elif opcode in ['5', '05']:
if value1 != 0:
counter = value2
else:
counter += 3
elif opcode in ['6', '06']:
if value1 == 0:
counter = value2
else:
counter += 3
elif opcode in ['03', '3']:
program[value1] = amp_input.pop(0)
counter += 2
elif opcode in ['4', '04']:
# print('{} {}'.format(instruction, value1))
if instruction != '104':
value1 = program[value1]
# print('Output value: {}'.format(value1))
counter += 2
return value1, counter
else:
print("Something broke at {}".format(counter))
print("program state {}".format(program))
print(instruction)
return False
except Exception as e:
print("Out of bounds at {}".format(counter))
print("program state {}".format(program))
print(instruction)
print(e)
print(len(program))
return
return program, True

outputs = []
max_output = 0
# initial_program = list(map(int, open('input7.txt').read().split(',')))
amp_ids = ['A', 'B', 'C', 'D', 'E']
permutation = [5, 6, 7, 8, 9]
# for permutation in permutations([5, 6, 7, 8, 9]):
amp_programs = {amp_id: [list(map(int, 
open('input7.txt').read().split(',')))[:], 0] for amp_id in ['A', 'B', 'C', 
'D', 'E']}
loops = 0
prev_output = 0
for x in range(0, 5):
gc.collect()
new_output, outer_counter = runProgram([permutation[x], prev_output], 
amp_programs[amp_ids[x]][0], amp_programs[amp_ids[x]][1])
if outer_counter is not True:
prev_output = new_output
amp_programs[amp_ids[x]][1] = outer_counter
# print(new_output)
while amp_programs['E'][1] is not True:
gc.collect()
for amp_id in amp_programs.keys():
amp = amp_programs[amp_id]
# print(prev_output)
# print('1:{}'.format(amp[1]))
new_output, outer_counter = runProgram([prev_output], amp[0], amp[1])
if outer_counter is not True:
prev_output = new_output
amp[1] = outer_counter
# print('{}, {}'.format(amp[1], outer_counter))
# outputs.append(prev_output)
# print(prev_output)
outputs.append(prev_output)
# if prev_output > max_output:
# max_output = prev_output

print(max(outputs))
# print(outputs)
"""
However when this program is run on the same input it produces stable input:
"""
from itertools import permutations

def runProgram(amp_input, program, counter):
while program[counter] != 99:
# print('*' * 99)
instruction = str(program[counter])
opcode = instruction[-2:]
value1 = program[counter + 1]
# print('2:{}'.format(counter))
try:
if opcode in ['01', '02', '1', '2', '5', '05', '6', '06', '7', 
'07', '8', '08']:
value1 = program[counter + 1]
value2 = program[counter + 2]
param_modes = 

Re: Aw: Re: stuck on time

2019-12-08 Thread DL Neil via Python-list

On 9/12/19 7:47 AM, RobH wrote:

On 08/12/2019 16:49, Dennis Lee Bieber wrote:

On Sun, 8 Dec 2019 09:44:54 +, RobH  declaimed the
following:

def print_time():
  current_time = time.strftime("%I:%M")

...


I don't know if that is the correct way as I am just using the code from
the project I am trying to do


This is showing a severe lack of understanding in how Python itself
operates, leading me to recommend rereading a Python tutorial book before
attempting to hack into some one else's code.


+1
(in other words, agreement with others who have suggested that your 
knowledge of Python and/or programming, is insufficient to cope with the 
project you've set yourself)




Err, excuse me, I was not attempting to hack into someone else's code.
As the code is in the public domain, I wanted it to work as is, like it 
did for the author, without changing anything.


Please don't be upset. There are multiple understandings of the words 
"hack" and "hacker". Whereas most 'computer people' take the word "hack" 
to mean exactly what you are doing (and "crack" to refer to illegal 
access or ill-intent); the sad state of journalism (and Hollywood) has 
resulted in a confusion of the two.


Within the Python community, the word "hack" is used freely and without 
rancour, and includes both the permitted use of someone else's code, as 
you describe; and improving said code, as per @wlfraed's detailed 
analysis of the code-base's short-comings, a few hours ago.




So why should I now start to learn how python works.


Only you can answer this: is the effort required to bend the code to 
your will, worth the pleasure or utility the result will bring?


Alternatively, look at how much time *volunteers* have thought 
worth-while investing in helping you! (kudos @Karsten)



There is a safety issue here too. What if the original author had wicked 
intent, and the code actually performs to your disadvantage. How would 
you know? The only way is to inspect the code - reading it for example.



Following-on from the "hacking" comment, if the original author offered 
it to you/the world, and uploaded this code to some public repo(sitory), 
(s)he will also be happy for you/others to correct and improve.


Added to the observation that the code is missing parentheses, it would 
seem that (this version of) the code would never work. Now that you have 
discovered this, the conventions of "open source" are that you will 
propose, or better still, supply a fix...



If the code doesn't work for me after a fair trial, I'll move on to 
something else.


Frankly, given @wlfraed's extensive analysis of the code, I'd be 
wondering about its utility too - but again, your assessment is the only 
one that counts.


(If I am confusing two recent list-threads, I apologise)
If you are going to be experimenting with IoT and/or SBCs, the sad 
reality is that it is not an area which has had time to 'collect' a body 
of mature software. Accordingly, lots of the code made 'available' for 
use will be in a fairly rough (or "early") stage. Thus, the greater 
*your* skill-set, the more likely will be success - same as for any 
hobby/work-project! Also, IIRC you are also short-cutting by using a 
Pi-Zero (designed for application and roll-out) rather than a board 
designed for experimentation - but I'm guessing, so again, please don't 
take offense.

--
Regards =dn
--
https://mail.python.org/mailman/listinfo/python-list


Re: Python3 - How do I import a class from another file

2019-12-08 Thread Terry Reedy

On 12/8/2019 1:29 PM, R.Wieser wrote:



from the_file import ClassName


from somemod import name

has the same effect as

import somemod
name = somemod.name
del somemod

which is to import a particular 'name' linked to a particular python 
object into the namespace where the import is executed. 
sys.modules['somemod'] will become or continue to be the module 
resulting from executing the 'somemod' code.



Note that in all cases when you import a module (either by import the_file
or from the_file importe whatever) you actually import ALL of it


The entire module is executed the first time it is imported.


So much for my assumption only the class itself would be loaded - and a
wrench into my idea to have a number of classes in a "library" file.


Not really.  The resulting global objects do not normally take enough 
space to worry about on normal modern desktops.  It is normal for a 
module to only use a subset, possibly just one, of the objects in an 
imported module.  For instance, itertools has 18 public classes but 
almost no importer uses all of them.



if __name__ == '__main__':
 # not run when imported
 print("Hello world!")


Thanks for that.  It means I do not have to block-quote the testcode every
time - which I'm certain I will forget now-and-again ...


Standard for in-file test is

def test(): 

if __name__ == '__main__':
test()


Question: what is, in python, the convention in naming classes ?


The PEP 8 convention (except for basic builtin data structures like int, 
str, list, tuple, set, and dict) is TitleCase.  Follow or not as you wish.



Pre- or postfix it with "class" ?


No


--
Terry Jan Reedy

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


Re: Python3 - How do I import a class from another file

2019-12-08 Thread R.Wieser
Dennis,

> Common practice is that the class is capitalized. Instances
>are lowercase.

Thanks.

Regards,
Rudy Wieser


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


[issue38998] dict.setdefault (setdefault of dictionary)

2019-12-08 Thread Eric V. Smith


Eric V. Smith  added the comment:

Right. If you want the value only calculated once, then just call it once.

You might be interested in collections.defaultdict, which takes a factory 
function, and only calls it as needed.

--
nosy: +eric.smith
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



[issue38996] introduction of default values for collection.namedtuple

2019-12-08 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


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



[issue38999] Python launcher on Windows does not detect active venv

2019-12-08 Thread Alexandros Karypidis


Alexandros Karypidis  added the comment:

As confirmed by debug information when setting PYLAUNCH_DEBUG=1, the shebang 
seems to be ignored when using '#!//usr/bin/env python3' but works fine when 
using '#!//usr/bin/env python'.

This is with '#!//usr/bin/env python' (proper):

(.venv) PS C:\pytest> .\script.py
launcher build: 32bit
launcher executable: Console
File 'C:\Users\karypid\AppData\Local\py.ini' non-existent
File 'C:\WINDOWS\py.ini' non-existent
Called with command line: "C:\pytest\script.py"
maybe_handle_shebang: read 167 bytes
maybe_handle_shebang: BOM not found, using UTF-8
parse_shebang: found command: python
searching PATH for python executable
Python on path: C:\pytest\.venv\Scripts\python.exe
...


This is with '#!//usr/bin/env python3' (wrong):

(.venv) PS C:\pytest> .\script.py
launcher build: 32bit
launcher executable: Console
File 'C:\Users\karypid\AppData\Local\py.ini' non-existent
File 'C:\WINDOWS\py.ini' non-existent
Called with command line: "C:\pytest\script.py"
maybe_handle_shebang: read 168 bytes
maybe_handle_shebang: BOM not found, using UTF-8
parse_shebang: found command: python3
locating Pythons in 64bit registry
locate_pythons_for_key: unable to open PythonCore key in HKCU
...


As you can see in the second case even though it regognises the python3 
command, it makes no attempt to find it in the path.

Note that it appears that Windows installations only carry 'python.exe' and do 
not have a 'python3.exe' (neither in the native installation folder, nor in the 
virtual environment folder) so searching on the path would only 'work' if the 
user has copied python.exe to python3.exe in their \Scripts folder. (I 
actually tried that and it did not work).

A proper solution would probably need to search for 'python.exe' even for the 
'#!//usr/bin/env python3' shebang to detect if a virtual environment is 
present, possibly even confirming that the virtual environment is of the 
appropriate version.

--

___
Python tracker 

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



Regarding problem in python 3.8.0 installation

2019-12-08 Thread alok singh
Sir,

My system is windows 7 SP1 32-bit . after installing python in my
system,when i try to launch it using command prompt then a message is
shown. I am attaching a screenshot of the following.
kindly look seriously into my problem and tell me the solution..

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


[issue38998] dict.setdefault (setdefault of dictionary)

2019-12-08 Thread Rémi Lapeyre

Rémi Lapeyre  added the comment:

>
>
> def __init__(self):
> vars(self).setdefault('default', self.set_default())
> vars(self).setdefault('default', self.set_default())
>

This code is equivalent to

def __init__(self):
x = self.set_default()
vars(self).setdefault('default', x)

x = self.set_default()
vars(self).setdefault('default', x)

>
because the argument is evaluated before the call to setdefault() so you
can't optimise anything here.

--
nosy: +remi.lapeyre

___
Python tracker 

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



Re: Aw: Re: stuck on time

2019-12-08 Thread RobH

On 08/12/2019 16:49, Dennis Lee Bieber wrote:

On Sun, 8 Dec 2019 09:44:54 +, RobH  declaimed the
following:


def print_time():
  current_time = time.strftime("%I:%M")

returns nothing.


So what did you expect it to do?

All that does is define a function (binding the name "print_time" to a
compiled function object), and that function itself returns nothing IF
invoked (you haven't invoked it). (Presuming time has been imported, the
function will bind the name "current_time" to a string representation of
the current time... and then throws away "current_time" when the function
falls off the end and returns to the caller.)


I don't know if that is the correct way as I am just using the code from
the project I am trying to do


This is showing a severe lack of understanding in how Python itself
operates, leading me to recommend rereading a Python tutorial book before
attempting to hack into some one else's code.




Err, excuse me, I was not attempting to hack into someone else's code.
As the code is in the public domain, I wanted it to work as is, like it 
did for the author, without changing anything.


So why should I now start to learn how python works.

If the code doesn't work for me after a fair trial, I'll move on to 
something else.

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


[issue38998] dict.setdefault (setdefault of dictionary)

2019-12-08 Thread da-dada


New submission from da-dada :

from the docu I expected at the second call just a return of value and not a 
second calculation: there is room for improvement, as Elon Musk would say..

class Ddefault:

def __init__(self):
vars(self).setdefault('default', self.set_default())
vars(self).setdefault('default', self.set_default())

def set_default(self):
print(vars(self))
return 'default'

if __name__ == "__main__":
Ddefault()

--
messages: 358016
nosy: da-dada
priority: normal
severity: normal
status: open
title: dict.setdefault (setdefault of dictionary)
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



[issue38999] Python launcher on Windows does not detect active venv

2019-12-08 Thread Alexandros Karypidis


Alexandros Karypidis  added the comment:

Forgot the simple script:

#!/usr/bin/env python3

import os, sys, platform

print('EXECUTABLE: ' + sys.executable)
print('PREFIX: ' + sys.prefix)
print('BASE PREFIX: ' + sys.base_prefix)

--

___
Python tracker 

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



[issue38999] Python launcher on Windows does not detect active venv

2019-12-08 Thread Alexandros Karypidis


New submission from Alexandros Karypidis :

When you activate a venv on Windows and use a shebang with a major verion 
qualifier, the python launcer does not properly detect that a venv is active 
and uses the system installation instead.

The incorrect behavior is documented in this SO question where another user has 
confirmed and suggested it is a bug: 
https://stackoverflow.com/questions/59238326

Steps to reproduce (needs script.py attached below):

1. Install Python 3.7 on Windows 10 (64 bit)
2. Run script.py you should see:
PS C:\pytest> .\script.py
EXECUTABLE: C:\Program Files\Python37\python.exe
PREFIX: C:\Program Files\Python37
BASE PREFIX: C:\Program Files\Python37

3. Create and activate a virtual environment with:
PS C:\pytest> python -m venv .venv
PS C:\pytest> . .\.venv\Scripts\Activate.ps1

4. Run script.py you should see it ignore the active virtual environment:
(.venv) PS C:\pytest> .\script.py
EXECUTABLE: C:\Program Files\Python37\python.exe
PREFIX: C:\Program Files\Python37
BASE PREFIX: C:\Program Files\Python37

I am using Windows 10 64-bit, update 1903 and Python 3.7.5-64

--
components: Windows
messages: 358017
nosy: Alexandros Karypidis, paul.moore, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: Python launcher on Windows does not detect active venv
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



Re: Python3 - How do I import a class from another file

2019-12-08 Thread R.Wieser
Peter,

>> "from file import function" works, but fails when I try to do the same
>> with a class.
>
> Are you sure? It should behave the same for any name in the module.

I am.

At least, that is what the error said: "cannot import 'classname' from 
'filename' "

But as it turns out the problem is not the importing, but that my importing 
of the class also caused my testcode (instanciating the class, calling it 
and deleting the instance afterwards) to run.

... in which I created an instance with the same name as the class. 
Changing the instances name made the error go away (probably something to do 
with the "del instance" in the testcode).

> It's all or nothing, you cannot cherry-pick specific classes or functions.

Shucks.

> You can however protect part of the code with
> 'if __name__ == "__main__": ...':

Thanks.  (Python" also mentioned the above two).

Regards,
Rudy Wieser


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


Re: Python3 - How do I import a class from another file

2019-12-08 Thread R.Wieser
Python,

> from the_file import ClassName
>
> should work. I guess that your class name is not "class" right?

You guessed that right. :-)   Not a good idea to pick confusing names like
that, especially when you do something the first time.

> Note that in all cases when you import a module (either by import the_file
> or from the_file importe whatever) you actually import ALL of it

So much for my assumption only the class itself would be loaded - and a
wrench into my idea to have a number of classes in a "library" file.

And it turns out its also the cause of my problem: The displayed error told
me that it could not import the class from the file, but when I block-quoted
the testcode (instanciating the class, calling it and deleting the instance
afterwards) it all worked as it should.   No idea why though.

> if __name__ == '__main__':
> # not run when imported
> print("Hello world!")

Thanks for that.  It means I do not have to block-quote the testcode every
time - which I'm certain I will forget now-and-again ...

Update: While testing a bit more it turned out that, in the testcode, my 
creating an instance with the same name as the class is to blame (who again 
said that it isn't a good idea to use confusing names ?).  The moment I 
changed the name of the instance everything works as expected.

Question: what is, in python, the convention in naming classes ?   Pre- or 
postfix it with "class" ?  Something else ?

Regards,
Rudy Wieser



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


Re: Python3 - How do I import a class from another file

2019-12-08 Thread R.Wieser
Chris,

> Are you sure there's a difference between classes and functions here?

Yes, quite sure.

If not my attempt to load a class he same way as a function would have 
worked.  Which it doesn't.

> Try "from file import function" and see if it runs commands at
> the root of the file.

What function ?   The imported file doesn't contain any.

Regards,
Rudy Wieser


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


Re: python 2 to 3 converter

2019-12-08 Thread songbird
Chris Angelico wrote:
> On Sun, Dec 8, 2019 at 7:36 PM songbird  wrote:
>>   this would be a heck of a lot of fun.
>
> Then go ahead and do it.

  i know you're just being flip here and that's fine
with me.  that said, i'd love to!  how big is PyPI? 
(huge)  will it fit on an SSD?  (no)  my local machine 
and pipeline isn't big enough to crunch it (too bad).
etc.

  i'm going to have fun here so you can ignore this if
you'd like.

  my name for the new archive is called OctoPyPIE.  :)

  uploads to OPPIE are parsed from the start to be python3
compatible only.  if it is not compatible then the code is
quarantined with a message which says "fix it and try 
again, we no longer accept incompatible code."

  the quarantined python2 code will be used for background
processing (to see what is most broken) but it is never
distributed further.  it is just indexed, dependencies 
checked, noting which ones are most frequently used and
that information kept to help focus the broader effort of
conversion.  i think we should call the quarantine area
ISENGUARD and the programs for chewing it up called ENT.  
code that eventually may get a fixer so that it could be 
promoted back to OPPIE without any manual intervention 
would be done by ELROND.  code which is impossible to ever 
be manually converted would be left and perhaps would 
eventually end up in MORDOR after being transported by 
the RINGWRAITH.

  dev null is of course MTDOOM.

  those who come to the table of OPPIE only eat the 
freshest pie.  HOBBITS like only the best.

  thus is finished the 2nd AGE.


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


[issue38996] introduction of default values for collection.namedtuple

2019-12-08 Thread Eric V. Smith


Eric V. Smith  added the comment:

Agreed on closing this issue.

--

___
Python tracker 

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



[issue38996] introduction of default values for collection.namedtuple

2019-12-08 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Here's the status of the various ways to do it:

1) In 3.7, collections.namedtuple() added the *defaults* parameter and the 
*_field_defaults* attribute.

2) In 3.6.1, typing.NamedTuple added support for default values.

3) In older versions of Python, it was always possible to directly attach 
default values:

>>> from collections import namedtuple
>>> Point = namedtuple('Point', ('x', 'y'))
>>> Point.__new__.__defaults__ = (10, )
>>> Point(5)
Point(x=5, y=10)

Given that we can't introduce new features to old versions of Python, it looks 
like this can be closed as "out-of-date".

--

___
Python tracker 

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



[issue33880] namedtuple should use NFKD to find duplicate members

2019-12-08 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Marking as closed for the reasons listed above.

Other thoughts:
* In the class form with types.NamedTuple, no error is raised.
* In the function form with collections.namedtuple, the various
  TypeErrors and ValueErrors are just courtesy checks
  intended to provide slightly nicer error messages when possible.
  It wasn't the goal to upstage all possible syntax errors.

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



[issue35805] email package folds msg-id identifiers using RFC2047 encoded words where it must not

2019-12-08 Thread Abhilash Raj


Abhilash Raj  added the comment:

Closing this since it has been fixed in Python 3.8.

--
resolution:  -> fixed
stage: needs patch -> resolved
status: open -> closed
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



Re: Python3 - How do I import a class from another file

2019-12-08 Thread Peter Otten
R.Wieser wrote:

> Hello all,
> 
> Using Python3 I would like to import a specific class from another file
> (in the same folder), and have trouble doing so.
> 
> "from file import function" works, but fails when I try to do the same
> with a class.

Are you sure? It should behave the same for any name in the module.
 
> "import file
> x = file.class"
> 
> works, but also executes commands that are in the root of the file. And
> ofcourse loads all of the file, not just the class that I'm after ...
> 
> In other words, what is the syntaxt I should use ?

The body of a module that is imported is always executed -- that's how the 
classes and functions (and everything else) in the module are created.
It's all or nothing, you cannot cherry-pick specific classes or functions.

You can however protect part of the code with 
'if __name__ == "__main__": ...':


print("this will always be executed")
if __name__ == "__main__":
   print("this will only be executed when you run")
   print("the module directly as a script")


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


Re: Python3 - How do I import a class from another file

2019-12-08 Thread Python

R.Wieser wrote:

Hello all,

Using Python3 I would like to import a specific class from another file (in
the same folder), and have trouble doing so.

"from file import function" works, but fails when I try to do the same with
a class.

"import file
x = file.class"

works, but also executes commands that are in the root of the file. And
ofcourse loads all of the file, not just the class that I'm after ...


from the_file import ClassName

should work. I guess that your class name is not "class" right?

Note that in all cases when you import a module (either by
import the_file or from the_file importe whatever) you actually
import ALL of it (even if you don't see ALL names your name
space). If you do not want part of a module to be executed when
it is imported (any ways) but only when the file is executed
as a script (i.e. python3 the_file.py or ./the_file.py) then
you can test the name __name__ : it is a string "__main__"
when it is executed and the module name when imported :

if __name__ == '__main__':
# not run when imported
print("Hello world!")

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


[issue38242] Revert the new asyncio Streams API

2019-12-08 Thread Andrew Svetlov


Change by Andrew Svetlov :


--
resolution:  -> fixed
stage: commit 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



Re: Python3 - How do I import a class from another file

2019-12-08 Thread Chris Angelico
On Mon, Dec 9, 2019 at 3:31 AM R.Wieser  wrote:
>
> Hello all,
>
> Using Python3 I would like to import a specific class from another file (in
> the same folder), and have trouble doing so.
>
> "from file import function" works, but fails when I try to do the same with
> a class.
>
> "import file
> x = file.class"
>
> works, but also executes commands that are in the root of the file. And
> ofcourse loads all of the file, not just the class that I'm after ...
>
> In other words, what is the syntaxt I should use ?
>

Are you sure there's a difference between classes and functions here?
Try "from file import function" and see if it runs commands at the
root of the file.

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


Re: Aw: Re: Re: Re: stuck on time

2019-12-08 Thread Ethan Furman

On 12/08/2019 06:32 AM, Python wrote:


Well... Maybe it's time to admit, Rob, that programming is not
your thing.


Rob, my apologies.  Whoever this person is, they are not "Python", and their 
behavior will not be tolerated.

"Python", if you don't want to help then remain silent.  If you don't want to 
be frustrated, stop reading the thread.
Rude behavior will not be tolerated.  Consider this your one warning.

--
~Ethan~
Python List Moderator
--
https://mail.python.org/mailman/listinfo/python-list


[issue30064] BaseSelectorEventLoop.sock_{recv, sendall}() don't remove their callbacks when canceled

2019-12-08 Thread Andrew Svetlov


Andrew Svetlov  added the comment:

Not sure if failed uvloop tests are correct.
The scenario is like the following:
1. Suppose we have an unblocking socket connected to peer.
2. Create a task for reading data: 
  task = asyncio.create_task(loop.sock_read(sock, 1))
 Note, the task is not started yet.
3. Just after it, cancel the task without waiting for the actual cancellation
  task.cancel()
4. Finally, read from the socket again:
  data = await loop.sock_read(sock, 1)

If I put context switch (await asyncio.sleep(0)) between 3) and 4) *or* replace 
direct sock_read() call in 4) with creation a task (data = await 
asyncio.create_task(loop.sock_read(sock, 1))) the cancellation of former read 
is performed and test passes.

I very doubt if any sane code is organizing like this test: start delayed 
reading, cancel it and read again.

The worse, neither previous not current sock_read() implementation doesn't 
prevent the concurrent reading which basically delivers data in an 
unpredictable order. Honestly, I'm not sure if we need to provide the 
concurrency guarantee for such low-level functions.  The code built on top of 
these low-level primitives should handle the cuncurrent access problem IMHO.

--

___
Python tracker 

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



Python3 - How do I import a class from another file

2019-12-08 Thread R.Wieser
Hello all,

Using Python3 I would like to import a specific class from another file (in 
the same folder), and have trouble doing so.

"from file import function" works, but fails when I try to do the same with 
a class.

"import file
x = file.class"

works, but also executes commands that are in the root of the file. And 
ofcourse loads all of the file, not just the class that I'm after ...

In other words, what is the syntaxt I should use ?

Regards,
Rudy Wieser


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


Re: stuck on time

2019-12-08 Thread duncan smith
On 07/12/2019 17:48, RobH wrote:
> I am trying to do this project on a pi zero:
> 
> http://frederickvandenbosch.be/?p=1365
> 
> After overcoming a few errors, I now have the display working and the
> start of the code showing on the display, that being the time.
> 
> It doesn't move on to the next part of the code ie, no rectangle drawn
> def display_time():
> # Collect current time and date
> if(time_format):
>     current_time = time.strftime("%I:%M")<<< stays at this line
> else:
>     current_time = time.strftime("%H:%M")
>    
> current_date = time.strftime("%d/%m/%Y")
> 
> # Clear image buffer by drawing a black filled box
> draw.rectangle((0,0,width,height), outline=0, fill=0
> 
> In the original code you can see that the author used the
> Minecraftia.ttf font, but I had to download the Minecraftia-Regular.ttf
> font. The link the author gave took me to that.
> 
> The Minecraft-Regular.ttf font produced errors when the code was run,
> saying at the end of the error that it cannot open resource.
> 
> I then used the NotoSerif-Regular.ttf font which let the code start
> without error, but as above it is stuck at the time.

One thing you certainly need to do is add a closing brace to the last line.

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


[issue38992] testFsum failure caused by constant folding of a float expression

2019-12-08 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


--
nosy: +pablogsal

___
Python tracker 

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



[issue38993] cProfile behaviour issue with decorator and math.factorial() lib.

2019-12-08 Thread Pablo Galindo Salgado


New submission from Pablo Galindo Salgado :

Please, could you write a description to this issue here instead of the 
attached file?

--
nosy: +pablogsal

___
Python tracker 

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



[issue38997] test__xxsubinterpreters test_atexit test_capi test_threading are leaking references

2019-12-08 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

I will try to work on an alternative fix meanwhile, but I need to search for 
what exactly is leaking first.

--

___
Python tracker 

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



[issue38997] test__xxsubinterpreters test_atexit test_capi test_threading are leaking references

2019-12-08 Thread Pablo Galindo Salgado


New submission from Pablo Galindo Salgado :

Similar to https://bugs.python.org/issue38962, test__xxsubinterpreters 
test_atexit test_capi test_threading are leaking references. Example:

https://buildbot.python.org/all/#/builders/158/builds/10
https://buildbot.python.org/all/#/builders/16/builds/11
https://buildbot.python.org/all/#/builders/157/builds/11

test__xxsubinterpreters test_atexit test_capi test_threading
== Tests result: FAILURE then FAILURE ==
386 tests OK.
10 slowest tests:
- test_multiprocessing_spawn: 26 min 23 sec
- test_mailbox: 23 min 17 sec
- test_asyncio: 20 min 25 sec
- test_venv: 14 min 54 sec
- test_concurrent_futures: 13 min 35 sec
- test_zipfile: 11 min 10 sec
- test_regrtest: 9 min 34 sec
- test_distutils: 9 min 19 sec
- test_compileall: 9 min 9 sec
- test_lib2to3: 5 min 52 sec
4 tests failed:
test__xxsubinterpreters test_atexit test_capi test_threading

--
assignee: pablogsal
components: Tests
messages: 358006
nosy: pablogsal, vstinner
priority: normal
severity: normal
status: open
title: test__xxsubinterpreters test_atexit test_capi test_threading are leaking 
references
type: behavior
versions: Python 3.9

___
Python tracker 

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



Re: Aw: Re: Re: Re: Re: stuck on time

2019-12-08 Thread RobH

On 08/12/2019 14:26, Karsten Hilbert wrote:

Like this?
  >>>print_time()
Traceback (most recent call last)
File "stdin>", line 1, in 
File "stdin>", line 2, in print_time
File "stdin>", line 2, in print_time
File "stdin>", line 2, in print_time
[Previous line  repeated 996 more times]
RecursionError: maximum recursion depth excedded.


Sort of, yes, but since you meanwhile redeclared the function:

def print_time():
print_time()

to be recursive and then you ran that recursive function
it recursed until it ran out of resources.

However,


Running the code in a shell , it is displaying the time and now also the  date .


That would prove that the code itself is not
the reason why it hangs where you think it
hangs.

I suggest sprinkling print statements about the initial code
and see what it prints to the console to find out where
(and whether) it actually hangs.

Karsten



Ok, when I do:
>>>def print_time():
   print_time()

It hangs.

the code I linked to apparently works for the author and also for some 
others, but not for me. Admittedly they are using the Minecraftia.ttf 
font which gives me the IOError which posted about above this one.
I am presently using the NotoSerif-Regular.ttf font, and I only think 
that that is why nothing else happens.


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


  1   2   >