[issue35263] Add None handling for get_saved() in IDLE

2019-08-11 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

I suspect that this is related to #35379, where I added some preliminary 
analysis.

--

___
Python tracker 

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



[issue23220] IDLE: Document how Shell displays user code output

2019-08-11 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

The conclusion of this discussion was that we should insert control chars, in 
particular \b and \r, as are into tk.Text and document the (variable) result.  
Please describe your proposed new behavior, how it differs from the current 
behavior, and why you think it better.  I think that this should be a new issue.

--

___
Python tracker 

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



[issue37821] IDLE shell uses wrong namespace for completions

2019-08-11 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

I think the current behavior is intended.  The IDLE doc Completions subsection, 
written by Kurt Kaiser in help.text and copied to idle.rst in #5066, has this 
paragraph 

Completions are currently limited to those in the namespaces. Names in an 
Editor window which are not via __main__ and sys.modules will not be found.  
Run the module once with your imports to correct this situation. Note that IDLE 
itself places quite a few modules in sys.modules, so much can be found by 
default, e.g. the re module."

The second sentence is garbled but says that things in sys.modules *will* be 
found.  The fourth sentence points out that sys.modules has many things 
imported by IDLE, not by user code, so they can be found *without running one's 
code*.  The example is "import re...re." and re completions pop up.  I noted on 
#18766 that cleaning up run.py made this *feature* less useful.  It appears 
that this issue and your patch are about disable this intended feature.  I 
don't agree.

To put it another way, "If a shell exists, completion should use the namespace 
used for evaluating code in the shell." is not correct.  The intended behavior 
is to complete if at all possible.  #18766 is about expanding 'possible'.

To constantly maximize 'possible', one would run after every name-binding 
statement (an extreme version of the 3rd sentence above).  I sometimes come 
close to that, though more to catch typos  and rerun tests as I go.

You are correct that entering 're.DOTALL' by completion without also entering 
the required corresponding import results in a NameError when running the code 
.  But the same is true if one enters the same 're.DOTALL' by key.  Either way, 
one has entered the attribute where and when wanted; the NameError says "now go 
back up and add the import".

What is odd to me is that you seem happy using the more numerous non-user IDLE 
imports when there is no Shell.  That would mean that users would initially be 
better off killing the shell when starting to edit.  To me, the logic of 
restricting completions when there is a shell would mean no completions when 
there is not.

--

___
Python tracker 

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



Re: beginner question-very basic

2019-08-11 Thread Wildman via Python-list
On Sun, 11 Aug 2019 12:50:29 -0400, slefkowitz wrote:

> Just getting started with Python.
> 
> Downloaded 3.7.4 rom python.org
> 
> I wrote  program in Notepad, saved it with a ".py" extension.
> 
> What do I do next? How do I execute a program?

I am assuming you are using Windows since you posted with Outlook
and that the python executable is in your path.

Open a cmd window and enter:  python \path\to\program.py

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue37825] IDLE doc improvements

2019-08-11 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

The garble was in help.txt as copied into idle.rst in #5066.  I will have to 
figure out the meaning.

--

___
Python tracker 

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



[issue37825] IDLE doc improvements

2019-08-11 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

4. Completions subsection: fix this garbled sentence. "Names in an Editor 
window which are not via __main__ and sys.modules will not be found."  Check 
2.6 help.txt from whence it likely came.

--

___
Python tracker 

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



[issue34857] IDLE: SyntaxWarning not handled properly

2019-08-11 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Terry, thanks for the thorough analysis and explanation.

--

___
Python tracker 

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



[issue18766] IDLE: Autocomplete in editor doesn't work for un-imported modules

2019-08-11 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

The import-on-demand would be executed in the Shell's execution process 
namespace, so it works with the current implementation.  I said above that this 
puts names 'where they don't belong', but I feel a little differently now.  A 
variant idea might be to execute all imports as entered in the editor in the 
shell.

A pie-in-the-sky idea is to give each editor its own execution process and 
execute each line as entered, or something like that.  But I have put off 
researching what other editors do until we get what we have working better.

--

___
Python tracker 

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



[issue15248] Better explain "TypeError: 'tuple' object is not callable"

2019-08-11 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

IDLE's Shell has treated SyntaxWarnings as errors since 2001.  I don't know if 
any other IDE's do the same.  Raymond's example did not concern me, as I think 
not calling known non-callables is preferable.

But not executing literal-with-is code, such as "a = 1; a is 1" and "0 is ''" 
is wrong.  See msg349431 of #34857 for more discussion of these cases.

--

___
Python tracker 

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



beginner question-very basic

2019-08-11 Thread slefkowitz
Just getting started with Python.

Downloaded 3.7.4 rom python.org

I wrote  program in Notepad, saved it with a ".py" extension.

What do I do next? How do I execute a program?

 

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


[issue34857] IDLE: SyntaxWarning not handled properly

2019-08-11 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

Treating a SyntaxWarning as an error is intentional, since 2001 in a Kurt 
Kaiser patch.  IDLE's ModifiedInterpreter subclasses 
code.InteractiveInterpreter.  The subclass .runsource turns a SyntaxWarning 
into an error, before calling the superclass method, with

warnings.filterwarnings(action="error", category=SyntaxWarning)

As long as this is true, it should be documented.  It is included in #37825.

In interactive python (as opposed to IDLE), code is executed after a 
SyntaxWarning.  In the non-callable call examples, minimally "()()", "[]()", 
"1()", and "''()", the result is a traceback that repeats the warning message. 
I think the repetition is mostly noise and is better omitted. I don't know what 
SyntaxWarnings were present in 2001, but I presume that Kurt had the same 
impression, whatever it or they were.

The non-callable calls violate the 'ideal' Python grammar, which would have a 
production like "call = possible_callable '(', args, ')'.  Violations are 
caught by the compiler rather than the parser.  But they could plausibly be 
called a (subclass of) SyntaxError and execution avoided everywhere.

The situation is quite different with "literal is (not) something", where 
'literal' includes constant tuples.  The expression is valid, normally runs 
without exception, and should be executed. To me, this is not a syntax issue, 
so SyntaxWarning seems wrong.  But as long as is used for this situation, the 
conversion to error must cease.  (If I knew how, I would prefer to still not 
call known non-callables in Shell.)

There are two subcases with different reasons for pinging users.

1. The result is obvious ("0 is ''", "0 is ()") and unchanged when 'is' is 
replaced with '=='.  The advice is useless.  It should instead, it seems to me, 
be to use True or False.  I suspect that this case is rare.

2. The result using 'is' is implementation dependent ("0 is 0", "0 is a", "1000 
is 1000"). For production code, the advice to change 'is' to '==' is correct. 
For exploration of 'is' in a shell, which many beginners like to do, it likely 
is not, at least not immediately.
--

My initial messsage above is moot since compile("assert (0, 'bad')", '', 
'single') no longer emit a SyntaxWarning, and the new warnings do not show the 
same behavior, even for similarly legal code such as "0 is 0".

My second message, about when a SyntaxWarning for a file is displayed, is still 
relevant, and I agree that it is a higher priority than before.  

But it is more complex than reported above.  First, there are other warnings 
than SyntaxWarning, and we might decide to optionally enable them.  Second, Run 
Module does Check Module first.  If Check Module is selected directly, there is 
no restart line.  Third, there will be no restart line if there is a 
SyntaxError, or a Tabnanny but there might be prior warnings.  I think I know 
how to deal with all of the above.

Module SyntaxErrors and Tabnanny errors are displayed in a popup error box, 
with the cursor moved to the line and maybe column of the error.  Warnings 
could be put in a separate box unless there is a restart.  I would prefer to 
not shift focus to Shell unless and until a module is run.

--
priority: high -> normal

___
Python tracker 

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



[issue34857] IDLE: SyntaxWarning not handled properly

2019-08-11 Thread Terry J. Reedy


Change by Terry J. Reedy :


--
nosy: +taleinat

___
Python tracker 

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



[issue37812] Make implicit returns explicit in longobject.c (in CHECK_SMALL_INT)

2019-08-11 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

python-dev likely isn't the right place.  That is a forum for more mature ideas.

--

___
Python tracker 

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



[issue37812] Make implicit returns explicit in longobject.c (in CHECK_SMALL_INT)

2019-08-11 Thread Ma Lin


Ma Lin  added the comment:

I sent twice, but it doesn't appear in Python-Ideas list.
I will try to post to Python-Dev tomorrow.

--

___
Python tracker 

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



[issue37734] Registry keys for Windows Store package have wrong executable

2019-08-11 Thread Steve Dower


Steve Dower  added the comment:

Here's an example of someone hitting this issue: 
https://stackoverflow.com/q/56974927

--

___
Python tracker 

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



[issue37825] IDLE doc improvements

2019-08-11 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

Because the scope of SyntaxWarnings has been expanded to code that must be run, 
they should no longer be turned into errors, so this should not be added to the 
doc.  See #34857.

--

___
Python tracker 

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



[issue37826] Document PEP 3134 in tutorials/errors.rst

2019-08-11 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

This is a reasonable suggestion.

Would you like to submit a pull request?

--
nosy: +rhettinger

___
Python tracker 

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



[issue37812] Make implicit returns explicit in longobject.c (in CHECK_SMALL_INT)

2019-08-11 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Ma Lin:  Everything in Python is an object, nothing is native.  There is room 
to reconsider the implementation of integer objects, known internally as PyLong 
objects.  If you want to tease-out an alternative implementation, please do so 
on the python-ideas maillist.  Small integer operations (including) indexing 
used to be smaller and faster in Python 2.7, so there is likely some room for 
improvement on what we have now.

--

___
Python tracker 

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



[issue37807] Make hash() return a non-negative number

2019-08-11 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Withdrawing this issue and marking as closed.

Thanks for your thoughts on the subject.

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



[issue34632] Port importlib_metadata to Python 3.8

2019-08-11 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

> Following the same pattern that many standard Python objects 
> return (`open`, `map`, `filter`), the approach is less 
> constrained in that it can support arbitrarily large results.
> I wished to leave it to the caller to materialize a list if 
> that was needed and my assumption was that 90% of the use-cases
> would be iterating over the results once.

My recommendation is to return a concrete list.  Shifting the responsibility to 
the user makes the API less convenient, particularly if someone is running this 
at the interactive prompt and just wants to see the results.

We replaced the list version of map() with itertools.imap() for memory 
efficiency with potentially enormous or infinite inputs.  However, this came at 
a cost for usability.  In every single course where I present map() there is an 
immediate stumble over the need to wrap it in list() just to see the output.  
In general, we should save the iterators for cases where there is real value in 
lazy execution.  Otherwise, usability, inspectability, sliceability, and 
re-iterability wins.  (Just think of how awkward it would be if dir() or 
os.listdir() returned an iterator instead of a list.)

FWIW, the doc string for requires() is:

   Return a list of requirements for the indicated distribution


> Perhaps more appropriate would be 'distribution_name' or 'dist_name'.

I recommend 'distribution_name'.  It will normally be used as a positional 
parameter but the full name will show-up in the tool tips, providing guidance 
on how to use it.



When you get a chance, please look at 
https://github.com/python/cpython/pull/15204
where I'm presenting your creation to the world.

Overall, I think this was a nice addition to the standard library.  Thanks for 
your work :-)

--

___
Python tracker 

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



[issue37807] Make hash() return a non-negative number

2019-08-11 Thread Tim Peters


Tim Peters  added the comment:

I agree:  we "shouldn't have" documented anything about hash codes beyond the 
invariants needed to guarantee they work for their intended purpose, chiefly 
that x == y implies hash(x) == hash(y).

Which leads to your other question ;-)  That invariant is tricky to maintain 
across a pile of distinct but comparable numeric types!  Whatever we return for 
an int needs also to be what's returned for a float that happens to have the 
same value, and whatever we return for a float needs also to be what's returned 
for a fraction.Fraction with the same value, and so on.

So Python uses a single numeric hashing algorithm defined on mathematical 
rationals, described here:

https://docs.python.org/3.8/library/stdtypes.html#hashing-of-numeric-types

Presumably that's documented so that people defining their own numeric types 
have a clue about how to implement compatible hash codes.

Anyway, that algorithm uses a large fixed prime P (different on 32- and 64-bit 
boxes), and uses operations modulo P.  That's why the full bit width isn't 
used.  And not just any prime P, it picks one for which computing the remainder 
mod P is especially efficient.  2**61 - 1 is as good as it gets on 64 bit boxes.

I didn't pick this algorithm (I suspect Mark did), but I certainly approve of 
it.  It's clever and general enough to apply to any plausible subset-of-real 
numeric type short of the constructive reals (where equality isn't even 
theoretically decidable, so "x == y implies ..." can't get off the ground ;-) ).

--

___
Python tracker 

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



[issue34632] Port importlib_metadata to Python 3.8

2019-08-11 Thread Jason R. Coombs


Jason R. Coombs  added the comment:

> Is there a reason that requires() and files() return iterators instead of 
> lists?

I'm a huge fan of `itertools` and Python 3's move to prefer iterables over 
materialized lists, and I feel that forcing materialized results gives the 
caller less control over the results.

Following the same pattern that many standard Python objects return (`open`, 
`map`, `filter`), the approach is less constrained in that it can support 
arbitrarily large results. I wished to leave it to the caller to materialize a 
list if that was needed and my assumption was that 90% of the use-cases would 
be iterating over the results once.

> I also thought that the APIs accepted either a module or a package name,

Early on, I had hoped to have the API accept either the distribution package 
name or a Python package... and I even started creating a protocol for package 
vendors to provide a reference from their module or package back to the 
distribution package name. But I decided that approach was to invasive and 
unlikely to get widespread support, but also that it added little value.

What importlib really works with is distribution packages (also known as 
Projects in PyPI) and not Python packages... and it works at an earlier 
abstraction (often you want to know metadata about a package without importing 
it).

> Also consider changing the parameter from files(package) to 
> files(package_name).

I think at one point, the parameter name was distribution_name_or_package. We 
removed the acceptance of packages, but then renamed the parameter to 'package' 
for brevity. This parameter is used in many functions (files, requires, 
version, metadata, distribution). We'd want to change it in all of those. Once 
it becomes a parameter of the Distribution class (such as in 
Distribution.from_name), the 'distribution' is implied, so 'name' is clear 
enough. I do try to avoid long and multi-word parameters when possible. Perhaps 
more appropriate would be 'distribution_name' or 'dist_name'.

I'm leaning toward 'dist_name' right now. What do you think?

--

___
Python tracker 

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



[issue37812] Make implicit returns explicit in longobject.c (in CHECK_SMALL_INT)

2019-08-11 Thread Ma Lin


Ma Lin  added the comment:

How about using a hybrid implementation for `int`.

For example, on 64-bit platform, if (a integer >=-9223372036854775808 and 
<=9223372036854775807), use a native `signed long` to represent it.

People mostly use +-* operations, maybe using native int is faster, even 
including the cost of overflow checking.

If operation will overflow or other operation like **, we can transform native 
int to current form and run in current code path.

--
nosy: +Ma Lin

___
Python tracker 

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



[issue37807] Make hash() return a non-negative number

2019-08-11 Thread Raymond Hettinger

Raymond Hettinger  added the comment:

> What killer use case am I missing?

There's no killer use case. I just thought it weird that hte builtin hash() 
function ever returned a negative number.

> This is a change of documented behaviour that will affect 
> 3rd party libraries that provide numeric types, like NumPy
> and gmpy; it should not be done lightly.

Okay, I'm happy to drop this.  It was only a minor nuisance.

Am not sure at what point we ever guaranteed that hash() would return negative 
numbers, or any particular number.  That was probably a mistake.  I thought the 
guarantees were all higher level metamorphic invariants such as hash(x) == 
hash(y) when x == y and {type(x), type(y)} ⊂ {bool, int, float, Decimal, 
Fraction, complex}.

BTW, I'm not sure why the numeric hashes are not getting all 64 bits in to play:

from random import randrange, expovariate
from secrets import token_hex, token_bytes

for random_hash in [
lambda : hash(randrange(2**100)) % 2**64,
lambda : abs(hash(expovariate(1.0))) % 2**64,
lambda : hash(token_hex()) % 2**64,
lambda : hash(token_bytes()) % 2**64,
]:
print(max(random_hash().bit_length() for i in range(10_000)))

Outputs:

61
61
64
64

--

___
Python tracker 

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



[issue37812] Make implicit returns explicit in longobject.c (in CHECK_SMALL_INT)

2019-08-11 Thread Greg Price


Greg Price  added the comment:

> On the other hand, if it is tricky and requires something more than minor 
> surgery, that would be a hint that it isn't worth it.  There is some value in 
> code that is stable and known to be working just fine.

Definitely true!

I think this change turned out quite clean, though. Just sent, as GH-15216 -- 
please take a look.

--

___
Python tracker 

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



[issue37812] Make implicit returns explicit in longobject.c (in CHECK_SMALL_INT)

2019-08-11 Thread Greg Price


Change by Greg Price :


--
pull_requests: +14944
pull_request: https://github.com/python/cpython/pull/15216

___
Python tracker 

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



[issue34857] IDLE: SyntaxWarning not handled properly

2019-08-11 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

See: https://bugs.python.org/msg349375

Because new SyntaxWarnings were added in 3.8, I expect this problem to become 
more prevalent.  Hopefully, this gets fixed for the 3.8 release.

--
priority: normal -> high

___
Python tracker 

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



[issue34632] Port importlib_metadata to Python 3.8

2019-08-11 Thread Barry A. Warsaw


Barry A. Warsaw  added the comment:

@jaraco will be able to answer that better than me.  I actually thought those 
did return concrete lists.

I also thought that the APIs accepted either a module or a package name, but 
maybe I'm thinking about importlib.resources.  Again, @jaraco can clarify, but 
I think the problem is that there's no unambiguous mapping between packages and 
package names for metadata the way there is for resources.

--

___
Python tracker 

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



[issue34632] Port importlib_metadata to Python 3.8

2019-08-11 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Quick question:  Is there a reason that requires() and files() return iterators 
instead of lists?  ISTM that a list-based solution would be more usable than 
returning a starmap() object or somesuch.  I suspect almost every user would 
have to call list(files(package)) rather than files(package).  An iterator 
return type would only make sense if we need the values are produces lazily or 
if a known consumer required an iterator input.

Also consider changing the parameter from files(package) to 
files(package_name).  When I first tried-out this API, I typed:  "import 
requests; files(requests)" instead of "files('requests')".

Sorry to bring this up at a late stage, but the purpose of a beta release is to 
let other users try-out the API while there is still a chance to make 
adjustments.

--
nosy: +rhettinger
status: closed -> open

___
Python tracker 

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



[issue37812] Make implicit returns explicit in longobject.c (in CHECK_SMALL_INT)

2019-08-11 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

> I'll rework the explicit-return patch to send without this
> change. It'll be a little trickier but should be entirely doable.

An explicit return would be a nice improvement.

On the other hand, if it is tricky and requires something more than minor 
surgery, that would be a hint that it isn't worth it.  There is some value in 
code that is stable and known to be working just fine.  See: 
https://en.wikipedia.org/wiki/There_are_known_knowns

--

___
Python tracker 

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



[issue37819] as_integer_ratio() missing from fractions.Fraction()

2019-08-11 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Thanks.

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



[issue37819] as_integer_ratio() missing from fractions.Fraction()

2019-08-11 Thread Raymond Hettinger


Raymond Hettinger  added the comment:


New changeset 5ba1cb03939bd86d026db667580f590966b573ea by Raymond Hettinger 
(Miss Islington (bot)) in branch '3.8':
bpo-37819: Add Fraction.as_integer_ratio() (GH-15212) (GH-15215)
https://github.com/python/cpython/commit/5ba1cb03939bd86d026db667580f590966b573ea


--

___
Python tracker 

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



[issue37819] as_integer_ratio() missing from fractions.Fraction()

2019-08-11 Thread Raymond Hettinger


Raymond Hettinger  added the comment:


New changeset f03b4c8a48f62134799d368b78da35301af466a3 by Raymond Hettinger in 
branch 'master':
bpo-37819: Add Fraction.as_integer_ratio() (GH-15212)
https://github.com/python/cpython/commit/f03b4c8a48f62134799d368b78da35301af466a3


--

___
Python tracker 

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



[issue37819] as_integer_ratio() missing from fractions.Fraction()

2019-08-11 Thread miss-islington


Change by miss-islington :


--
pull_requests: +14943
pull_request: https://github.com/python/cpython/pull/15215

___
Python tracker 

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



[issue37822] Add math.as_integer_ratio()

2019-08-11 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Guido decided to stick with the current approach of adding as_integer_ratio() 
as needed to concrete classes.  It is an optional API for user classes that 
register as numbers.Rational().  

See https://bugs.python.org/msg349404

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



[issue32178] Some invalid email address groups cause an IndexError instead of a HeaderParseError

2019-08-11 Thread Abhilash Raj


Change by Abhilash Raj :


--
stage: patch review -> resolved
status: open -> closed
versions: +Python 3.7, Python 3.8, Python 3.9 -Python 3.4, Python 3.5, Python 
3.6

___
Python tracker 

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



[issue32178] Some invalid email address groups cause an IndexError instead of a HeaderParseError

2019-08-11 Thread miss-islington


miss-islington  added the comment:


New changeset dec231a73c2a463b29f19c4e8357602c10a68856 by Miss Islington (bot) 
in branch '3.7':
bpo-32178: Fix IndexError trying to parse 'To' header starting with ':'. 
(GH-15044)
https://github.com/python/cpython/commit/dec231a73c2a463b29f19c4e8357602c10a68856


--

___
Python tracker 

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



[issue32178] Some invalid email address groups cause an IndexError instead of a HeaderParseError

2019-08-11 Thread miss-islington


miss-islington  added the comment:


New changeset 9500bbe9372f6080decc49d2fd9365f0b927a0e2 by Miss Islington (bot) 
in branch '3.8':
bpo-32178: Fix IndexError trying to parse 'To' header starting with ':'. 
(GH-15044)
https://github.com/python/cpython/commit/9500bbe9372f6080decc49d2fd9365f0b927a0e2


--

___
Python tracker 

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



[issue32178] Some invalid email address groups cause an IndexError instead of a HeaderParseError

2019-08-11 Thread miss-islington


Change by miss-islington :


--
pull_requests: +14941
pull_request: https://github.com/python/cpython/pull/15213

___
Python tracker 

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



[issue32178] Some invalid email address groups cause an IndexError instead of a HeaderParseError

2019-08-11 Thread miss-islington


Change by miss-islington :


--
pull_requests: +14942
pull_request: https://github.com/python/cpython/pull/15214

___
Python tracker 

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



[issue32178] Some invalid email address groups cause an IndexError instead of a HeaderParseError

2019-08-11 Thread miss-islington


miss-islington  added the comment:


New changeset 09a1872a8007048dcdf825a476816c5e3498b8f8 by Miss Islington (bot) 
(Abhilash Raj) in branch 'master':
bpo-32178: Fix IndexError trying to parse 'To' header starting with ':'. 
(GH-15044)
https://github.com/python/cpython/commit/09a1872a8007048dcdf825a476816c5e3498b8f8


--
nosy: +miss-islington

___
Python tracker 

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



[issue37826] Document PEP 3134 in tutorials/errors.rst

2019-08-11 Thread Abhilash Raj


New submission from Abhilash Raj :

Looking at the docs, I couldn't find the `raise from` documentation anywhere in 
the Errors and Exceptions page (https://docs.python.org/3/tutorial/errors.html) 
page, which seems to be the landing page for Python Exceptions. 

I do see however that it is documented on the top page of 
https://docs.python.org/3/library/exceptions.html and raise statement's docs 
(https://docs.python.org/3/reference/simple_stmts.html#raise), both of which 
are pretty hard to discover. 

It would be nice to add the docs for `raise from` in the Errors and Exception 
page too.

--
assignee: docs@python
components: Documentation
messages: 349406
nosy: docs@python, maxking
priority: normal
severity: normal
status: open
title: Document PEP 3134 in tutorials/errors.rst

___
Python tracker 

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



[issue37808] Deprecate unbound super methods

2019-08-11 Thread Guido van Rossum


Guido van Rossum  added the comment:

I don't have time to review this, sorry.

--

___
Python tracker 

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



[issue37819] as_integer_ratio() missing from fractions.Fraction()

2019-08-11 Thread Guido van Rossum


Guido van Rossum  added the comment:

Let's continue on the current path -- add Fraction.as_integer_ratio().

Note that as_integer_ratio() is not part of the Numbers API, it is an optional 
protocol.

You can count me out for Jeroen's __ratio__ proposal.

--

___
Python tracker 

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



[issue37819] as_integer_ratio() missing from fractions.Fraction()

2019-08-11 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Guido, would you like to go forward with this?

IIRC, you had decided that adding as_integer_ratio() to all the relevant 
concrete classes was the way to go.  We already had the method on floats and 
Decimals, and then it was added bool and float, so Fraction is the only one 
missing.  I believe the goal was to get x.as_integer_ratio() to run without 
type testing on all concrete numeric types that could support it.

Serhiy is proposing to instead add a math.as_integer_ratio() function that 
would extract the components differently for different types (see issue 37822). 
If that had been our plan, then it was a mistake to add as_integer_ratio() to 
int and bool (as they already have numerator and denominator attributes). If 
you change you mind and want to go with 37822, we should probably rip-out the 
3.8 addition to int and bool.

Jeroen is proposing to down yet another path for this (see issue 28716). He 
wants to add a __ratio__ method to all the classes and access them with an 
operator.ratio() function.  He thinks this will help the SageMath package.

My recommendation is to stick with the original plan of adding the 
as_integer_ratio() to all the concrete types.  The only one left to be done is 
in the Fractions module.  That is pretty easy -- see PR 15212.

There is some question about whether to change numbers.Rational() but that 
discussion can be left for another day -- concrete classes are allowed to have 
extra methods that aren't in the abstract classes.   The abstract classes are 
harder to change because any existing user classes that had registered as 
Rational would instantly be non-compliant (though the fix is easy).

I would like to get this finished up for 3.8.  It doesn't make sense to me to 
have as_integer_ratio() for bool, int, float, and Decimal but to have omitted 
the most obvious case, Fraction.  That defeats the purpose of having parallel 
APIs.

--
nosy: +gvanrossum

___
Python tracker 

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



[issue37814] typing module: empty tuple syntax is undocumented

2019-08-11 Thread Guido van Rossum


Guido van Rossum  added the comment:

> What is better, Tuple[()] or Literal[()]?

In this context, Tuple[()] is better, as the discussion is about how to write 
the type of various tuples. Tuple[()] is just the edge case of the type of the 
empty tuple.

Josh, please sign the CLA and adjust the wording per my request in the PR.

--

___
Python tracker 

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



[issue37808] Deprecate unbound super methods

2019-08-11 Thread Guido van Rossum


Change by Guido van Rossum :


--
nosy: +gvanrossum

___
Python tracker 

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



[issue37819] as_integer_ratio() missing from fractions.Fraction()

2019-08-11 Thread Raymond Hettinger


Change by Raymond Hettinger :


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

___
Python tracker 

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



[issue34985] python finds test modules from the wrong directory during PGO build

2019-08-11 Thread Carol Willing


Carol Willing  added the comment:

When building from the gzipped source of 3.8.0b3, I am seeing similar crashes 
on Ubuntu 18.04.

Running ``make clean`` prior to ``configure`` and ``make`` seems to have 
resolved the issue. After this the regrtest was being found in the 3.8.0b3 
directory. I am no longer seeing core dumps.

I'm going to close this issue.

--
nosy: +willingc
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed
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



[issue37822] Add math.as_integer_ratio()

2019-08-11 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

-1 for having this spill into the math module.   We're already started down a 
different path; otherwise, there would have been no need to add the 
as_integer_ratio method to int/bool.  That was done so that 
x.as_integer_ratio() would work for all the concrete classes where it made 
sense.  Right now, the only concrete class that is missing the method is 
Fractions.  Adding it there is trivial and it doesn't garbage-up the math 
module with a pass-through function.

--

___
Python tracker 

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



[issue37819] as_integer_ratio() missing from fractions.Fraction()

2019-08-11 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

I think this can still go in for Fractions because it completes a feature that 
was already started (providing the method for the concrete types where it makes 
sense).

Altering numbers.py can be saved for the future.

--

___
Python tracker 

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



[issue37825] IDLE doc improvements

2019-08-11 Thread Terry J. Reedy


New submission from Terry J. Reedy :

1. Headings: Sections should be titlecased, subsections not.  This is 
especially needed now that they are not numbered.

2. Python Shell subsection. Revise 'paste', maybe move.  SyntaxWarnings are 
SyntaxErrors.  Explain Restart.

3. Any other pending changes I include.

--
assignee: terry.reedy
components: IDLE
messages: 349399
nosy: taleinat, terry.reedy
priority: normal
severity: normal
stage: needs patch
status: open
title: IDLE doc improvements
versions: Python 3.7, Python 3.8, Python 3.9

___
Python tracker 

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



[issue37819] as_integer_ratio() missing from fractions.Fraction()

2019-08-11 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

This will not solve the problem completely, because other rational numbers do 
not have as_integer_ratio().

But all rational numbers have the numerator and denominator properties. See 
issue37822 for more general solution.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue37824] IDLE: DeprecationWarning not handled properly

2019-08-11 Thread Serhiy Storchaka


New submission from Serhiy Storchaka :

DeprecationWarning at compile time is output multiple times to the stderr (on 
console from which IDLE was ran), but not to IDLE Shell window.

For example, when enter '\e':

$ ./python -m idlelib

Warning (from warnings module):
  File "", line 1
'\e'
DeprecationWarning: invalid escape sequence \e
>>> 
Warning (from warnings module):
  File "", line 1
'\e'
DeprecationWarning: invalid escape sequence \e
>>> 
Warning (from warnings module):
  File "", line 1
'\e'
DeprecationWarning: invalid escape sequence \e

And when close IDLE, additional output is printed in 3.8+:

>>> Exception ignored in: 
Traceback (most recent call last):
  File "/home/serhiy/py/cpython/Lib/idlelib/run.py", line 488, in close
  File "/home/serhiy/py/cpython/Lib/idlelib/pyshell.py", line 1019, in close
  File "/home/serhiy/py/cpython/Lib/idlelib/editor.py", line 1058, in close
  File "/home/serhiy/py/cpython/Lib/idlelib/outwin.py", line 94, in maybesave
  File "/home/serhiy/py/cpython/Lib/idlelib/editor.py", line 991, in get_saved
AttributeError: 'NoneType' object has no attribute 'get_saved'

--
assignee: terry.reedy
components: IDLE
messages: 349396
nosy: serhiy.storchaka, terry.reedy
priority: normal
severity: normal
status: open
title: IDLE: DeprecationWarning not handled properly
type: behavior
versions: Python 3.7, Python 3.8, Python 3.9

___
Python tracker 

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



[issue15248] Better explain "TypeError: 'tuple' object is not callable"

2019-08-11 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

This is not related to this particular warning, but to how IDLE handles 
SyntaxWarning. See issue34857.

--
assignee: terry.reedy -> 
components: +Interpreter Core -IDLE
status: open -> closed

___
Python tracker 

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



[issue34857] IDLE: SyntaxWarning not handled properly

2019-08-11 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
nosy: +rhettinger

___
Python tracker 

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



[issue34857] IDLE: SyntaxWarning not handled properly

2019-08-11 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

I cannot reproduce this behavior in 3.7+. `assert (0, 'bad')` does not have any 
effect. But in 3.6 it outputs a traceback to the stderr.

$ ./python -m idlelib
Exception in Tkinter callback
Traceback (most recent call last):
  File "/home/serhiy/py/cpython3.6/Lib/tkinter/__init__.py", line 1705, in 
__call__
return self.func(*args)
  File "/home/serhiy/py/cpython3.6/Lib/idlelib/multicall.py", line 176, in 
handler
r = l[i](event)
  File "/home/serhiy/py/cpython3.6/Lib/idlelib/pyshell.py", line 1205, in 
enter_callback
self.runit()
  File "/home/serhiy/py/cpython3.6/Lib/idlelib/pyshell.py", line 1246, in runit
self.interp.runsource(line)
  File "/home/serhiy/py/cpython3.6/Lib/idlelib/pyshell.py", line 684, in 
runsource
return InteractiveInterpreter.runsource(self, source, filename)
  File "/home/serhiy/py/cpython3.6/Lib/code.py", line 64, in runsource
code = self.compile(source, filename, symbol)
  File "/home/serhiy/py/cpython3.6/Lib/codeop.py", line 168, in __call__
return _maybe_compile(self.compiler, source, filename, symbol)
  File "/home/serhiy/py/cpython3.6/Lib/codeop.py", line 82, in _maybe_compile
code = compiler(source, filename, symbol)
  File "/home/serhiy/py/cpython3.6/Lib/codeop.py", line 133, in __call__
codeob = compile(source, filename, symbol, self.flags, 1)
SyntaxWarning: assertion is always true, perhaps remove parentheses?


But other syntax warnings are converted to errors in IDLE (reported by Raymond 
in https://bugs.python.org/issue15248#msg349375).

In the regular interactive interpreter:

>>> 0 is 0
:1: SyntaxWarning: "is" with a literal. Did you mean "=="?
True
>>> data = [
...  (1, 2, 3) # oops, missing comma!
...  (4, 5, 6)
...  ]
:2: SyntaxWarning: 'tuple' object is not callable; perhaps you missed a 
comma?
Traceback (most recent call last):
  File "", line 2, in 
TypeError: 'tuple' object is not callable

In IDLE:

>>> 0 is 0
SyntaxError: "is" with a literal. Did you mean "=="?
>>> data = [
 (1, 2, 3) # oops, missing comma!
 (4, 5, 6)
 ]

SyntaxError: 'tuple' object is not callable; perhaps you missed a comma?

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



[issue37823] Telnet documentation: fix the link to open()

2019-08-11 Thread Mariatta

New submission from Mariatta :

Bug in the Telnet docs: https://docs.python.org/3/library/telnetlib.html

In the section 
https://docs.python.org/3/library/telnetlib.html#telnetlib.Telnet the “open()” 
link should probably point to 
https://docs.python.org/3/library/telnetlib.html#telnetlib.Telnet.open but 
instead it points to https://docs.python.org/3/library/functions.html#open

This is newcomer friendly and I would prefer it be done by first time 
contributors.

Reported in docs mailing list: 
https://mail.python.org/pipermail/docs/2019-August/041817.html

--
assignee: docs@python
components: Documentation
keywords: easy, newcomer friendly
messages: 349393
nosy: Mariatta, docs@python
priority: normal
severity: normal
stage: needs patch
status: open
title: Telnet documentation: fix the link to open()
versions: Python 2.7, Python 3.7, Python 3.8, Python 3.9

___
Python tracker 

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



[issue23220] IDLE: Document how Shell displays user code output

2019-08-11 Thread Tal Einat


Tal Einat  added the comment:

See initial working implementation of handling \r and \b characters is the 
shell, PR GH-15211.

--
nosy: +taleinat

___
Python tracker 

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



[issue23220] IDLE: Document how Shell displays user code output

2019-08-11 Thread Tal Einat


Change by Tal Einat :


--
pull_requests: +14939
pull_request: https://github.com/python/cpython/pull/15211

___
Python tracker 

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



[issue37810] ndiff reports incorrect location when diff strings contain tabs

2019-08-11 Thread Anthony Sottile


Anthony Sottile  added the comment:

That's actually a good point, I don't think this should land in python3.7 since 
it changes outuput -- I'm removing that from the versions (though the bug does 
affect every version I have access to)

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



[issue37822] Add math.as_integer_ratio()

2019-08-11 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


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

___
Python tracker 

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



[issue37822] Add math.as_integer_ratio()

2019-08-11 Thread Serhiy Storchaka


New submission from Serhiy Storchaka :

There are two interfaces to represent a number as a ratio. The numbers.Rational 
interface has two properties: numerator and denominator. float and Decimal do 
not support this interface, but they provide method as_integer_ratio() which 
return a 2-tuple (numerator, denominator).

I propose to add math.as_integer_ratio() which unites both interfaces: uses the 
as_integer_ratio() method if it is defined, and uses the numerator and 
denominator properties otherwise. It will help in applications that work with 
exact numbers (e.g. modules fractions and statistics).

--
components: Library (Lib)
messages: 349390
nosy: mark.dickinson, rhettinger, serhiy.storchaka, stutzbach
priority: normal
severity: normal
status: open
title: Add math.as_integer_ratio()
type: enhancement
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



[issue37814] typing module: empty tuple syntax is undocumented

2019-08-11 Thread Josh Holland


Josh Holland  added the comment:

PEP 586 doesn't currently allow Literal to contain tuples, so Tuple[()] is the 
only option.

--

___
Python tracker 

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



[issue37814] typing module: empty tuple syntax is undocumented

2019-08-11 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

What is better, Tuple[()] or Literal[()]?

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue37814] typing module: empty tuple syntax is undocumented

2019-08-11 Thread Josh Holland


Change by Josh Holland :


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

___
Python tracker 

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



[issue37821] IDLE shell uses wrong namespace for completions

2019-08-11 Thread Tal Einat


Tal Einat  added the comment:

See fix in PR GH-15207.

--

___
Python tracker 

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



[issue37821] IDLE shell uses wrong namespace for completions

2019-08-11 Thread Tal Einat


Change by Tal Einat :


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

___
Python tracker 

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



[issue37820] Unnecessary URL scheme exists to allow 'URL: reading file in urllib

2019-08-11 Thread Abdullah


New submission from Abdullah :

I am not sure if this was reported before, fixed, or even how to report this. 
However this issue is similar to https://bugs.python.org/issue35907

# Vulnerability PoC
import urllib
print urllib.urlopen('URL:/etc/passwd').read()[:30]
the result is
##
# User Database
# 
# Note t

I have tested the PoC on my Mac python 2.7.

--
components: Library (Lib)
messages: 349385
nosy: Alyan
priority: normal
severity: normal
status: open
title: Unnecessary URL scheme exists to allow 'URL: reading file in urllib
type: security
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



[issue37821] IDLE shell uses wrong namespace for completions

2019-08-11 Thread Tal Einat


New submission from Tal Einat :

Currently, when running an IDLE shell with a sub-process, it will allow 
completing attributes of objects not actually in the shell's namespace. For 
example, typing "codecs." will bring up completions for the codecs module's 
attributes, despite that not having being imported. Further, if one uses the 
completion, this results in a NameError exception, since "codecs" isn't 
actually in the namespace.

AFAICT, the intended behavior is as follows:

* If a shell exists, completion should use the namespace used for evaluating 
code in the shell. (Note that this is slightly different when running a shell 
without a sub-process.)
* If no shell exists (only editor windows are open), completion should use the 
global namespace + sys.modules.

--
assignee: terry.reedy
components: IDLE
messages: 349386
nosy: taleinat, terry.reedy
priority: normal
severity: normal
status: open
title: IDLE shell uses wrong namespace for completions
type: behavior
versions: Python 3.7, Python 3.8, Python 3.9

___
Python tracker 

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



[issue18766] IDLE: Autocomplete in editor doesn't work for un-imported modules

2019-08-11 Thread Thrlwiti


Change by Thrlwiti :


--
nosy:  -THRlWiTi

___
Python tracker 

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



[issue18766] IDLE: Autocomplete in editor doesn't work for un-imported modules

2019-08-11 Thread Tal Einat


Tal Einat  added the comment:

I propose closing this as "wontfix", since this goes strongly against how 
completions currently work in IDLE (based on the namespace of the shell), and I 
don't think we're considering changing that.

--
nosy: +taleinat

___
Python tracker 

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



[issue26543] [EASY] imaplib noop Debug: bytes vs Unicode bug in debug mode

2019-08-11 Thread Sanyam Khurana


Change by Sanyam Khurana :


--
pull_requests: +14935
pull_request: https://github.com/python/cpython/pull/15206

___
Python tracker 

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



[issue37811] [FreeBSD, OSX] Socket module: incorrect usage of poll(2)

2019-08-11 Thread Kubilay Kocak


Kubilay Kocak  added the comment:

See Also: #31334

--

___
Python tracker 

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



[issue37811] [FreeBSD, OSX] Socket module: incorrect usage of poll(2)

2019-08-11 Thread Kubilay Kocak


Change by Kubilay Kocak :


--
nosy: +koobs

___
Python tracker 

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



[issue37811] [FreeBSD, OSX] Socket module: incorrect usage of poll(2)

2019-08-11 Thread hai shi


hai shi  added the comment:

I found an OS distinguishing behavior in 
https://github.com/python/cpython/blob/master/Modules/selectmodule.c#L603-L612

--
nosy: +shihai1991

___
Python tracker 

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



Re: NotADirectoryError: [Errno 20] Not a directory

2019-08-11 Thread Peter Otten
Youssef Abdelmohsen wrote:

> Note: Beginner
> 
> I'm trying to create an html parser that will go through a folder and all
> its subfolders and export all html files without any html tags, in file
> formats CSV and TXT with each html labeled with the title of the web page
> in a new CSV and TXT.
> 
> However I keep getting an error saying:
> 
> 
> 
> 
> *"Traceback (most recent call last):  File
> "/Users/username/Documents/htmlparser/parser10.py", line 59, in 
> for subentry in os.scandir(entry.path):NotADirectoryError: [Errno 20] Not
> a directory: '/Users/username/site/.DS_Store'"*
> 
> Here's what I've done so far (I have bolded line 59):

The error message says it: in the outer loop you encounter a *file* called 
".DS_Store" that doesn't match your regex. You then pass it to the inner 
loop, i. e. entry.path below is a file

> for subentry in os.scandir(entry.path):

However os.scandir expects a *directory* rather than a file.

To fix the immediate problem you can ensure that entry is a directory

if entry.is_dir():
for subentry in os.scandir(entry.path):
...

but wait a moment. I note that you copied the code to process the html file 
twice. This is bad practice as it's hard to keep the code in sync when you 
apply changes (you already have a bug because you refer to the `entry` 
variable of the outer loop in the inner loop, too).

Instead use a helper functions like

def is_html_file(filename):
return bool(re.match(...))

def process_html_file(filename):
...

The loops then become

for entry in os.scandir(site_directory):
if entry.is_dir():
for subentry in os.scandir(entry.path)
if subentry.is_dir():
for file in os.scandir(subentry.path)
if is_html_file(file.path):
process_html_file(file)
elif is_html_file(entry.path):
process_html_file(entry.path)

Hm, that still looks messy; there may be bugs. 

Do you really want to exclude the html files from the intermediate level? 

I'd suggest that instead you scan the whole tree. Enter os.walk():

for path, folders, files in os.walk(site_directory):
for name in files:
filename = os.path.join(path, name):
if is_html_file(filename):
process_html_file(filename)

While this doesn't do exactly the same thing it should be much clearer what 
it does ;)

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


[issue37819] as_integer_ratio() missing from fractions.Fraction()

2019-08-11 Thread Stefan Behnel


Stefan Behnel  added the comment:

FWIW, makes total sense to me to have it there. Question is more if we can 
still get it into Py3.8, since it's a new feature for fractions.

--
nosy: +lukasz.langa, scoder

___
Python tracker 

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



[issue37496] Support annotations in signature strings.

2019-08-11 Thread hai shi


Change by hai shi :


--
nosy: +shihai1991

___
Python tracker 

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



[issue15248] Better explain "TypeError: 'tuple' object is not callable"

2019-08-11 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

I think it would be better to open a separate issue for IDLE.

--

___
Python tracker 

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



[issue37812] Make implicit returns explicit in longobject.c (in CHECK_SMALL_INT)

2019-08-11 Thread Greg Price


Greg Price  added the comment:

> Sometimes for testing we turn it off in order to identify identity test
bugs.

Interesting! Well, if the option is useful for testing, that's certainly a
good reason to keep it.

> Also, eveonline was controlling this to save memory.

Also interesting. I feel like there must be something about their setup
that I'm not imagining, because this is a pretty tiny amount of memory (9
kB) on the scale of a typical Python server process in my experience.

Or do you mean they were increasing the numbers? One thought I had looking
at this was actually that it would be interesting to do some measurements
and try to pick new (default) values for these parameters - it looks like
they're the same today as in 1993, and it's likely that with all that's
changed in typical hardware since then (plus the switch from Python ints +
longs to only what we used to call longs), the optimum values today are
different from the optimum in 1993. And certainly one of the effects of
this optimization when its hit rate is good is reducing memory consumption
- you have only one 17 instead of however many you make.

I'll rework the explicit-return patch to send without this change. It'll be
a little trickier but should be entirely doable.

On Sat, Aug 10, 2019, 23:19 Raymond Hettinger 
wrote:

>
> Raymond Hettinger  added the comment:
>
> P.S.  Making the returns explicit is a reasonable change to make, but the
> core #ifdef logic should remain.
>
> --
>
> ___
> Python tracker 
> 
> ___
>

--

___
Python tracker 

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



[issue37819] as_integer_ratio() missing from fractions.Fraction()

2019-08-11 Thread Sanyam Khurana


Change by Sanyam Khurana :


--
nosy: +CuriousLearner

___
Python tracker 

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



[issue37819] as_integer_ratio() missing from fractions.Fraction()

2019-08-11 Thread Raymond Hettinger


New submission from Raymond Hettinger :

When working on Whatsnew3.8, I noticed that as_integer_ratio() had been added 
to ints and bools, was already present in floats and Decimals, but was missing 
from Fractions.  

IIRC, the goal was to make all of these have as a similar API so that 
x.as_integer_ratio() would work for all types that could support it (not 
complex numbers).

--
components: Library (Lib)
keywords: easy
messages: 349378
nosy: lisroach, mark.dickinson, rhettinger
priority: high
severity: normal
status: open
title: as_integer_ratio() missing from fractions.Fraction()
type: enhancement
versions: Python 3.8, Python 3.9

___
Python tracker 

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



[issue37812] Make implicit returns explicit in longobject.c (in CHECK_SMALL_INT)

2019-08-11 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

P.S.  Making the returns explicit is a reasonable change to make, but the core 
#ifdef logic should remain.

--

___
Python tracker 

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



[issue37812] Make implicit returns explicit in longobject.c (in CHECK_SMALL_INT)

2019-08-11 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Thanks for the contribution Greg.  I understand your reasoning but am going to 
decline PR 15203.  Though the feature is not experimentnal, it is something we 
want be able to modify, shut-off, or extend at build time.  Sometimes for 
testing we turn it off in order to identify identity test bugs.  Also, 
eveonline was controlling this to save memory.

--
assignee:  -> rhettinger
nosy: +rhettinger

___
Python tracker 

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



[issue16837] Number ABC can be instantiated

2019-08-11 Thread Raymond Hettinger


Change by Raymond Hettinger :


--
resolution:  -> wont fix
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



[issue15248] Better explain "TypeError: 'tuple' object is not callable"

2019-08-11 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

This isn't interacting well with IDLE.


--- Works fine at the regular interactive prompt ---

$ python3.8
Python 3.8.0b3 (v3.8.0b3:4336222407, Jul 29 2019, 09:46:03)
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> data = [
...  (1, 2, 3) # oops, missing comma!
...  (4, 5, 6)
...  ]
:2: SyntaxWarning: 'tuple' object is not callable; perhaps you missed a 
comma?
Traceback (most recent call last):
  File "", line 2, in 



--- Behaves differently in the IDLE Shell---

Python 3.8.0b3 (v3.8.0b3:4336222407, Jul 29 2019, 09:46:03) 
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license()" for more information.
>>> data = [
 (1, 2, 3) # oops, missing comma!
 (4, 5, 6)
 ]
SyntaxError: 'tuple' object is not callable; perhaps you missed a comma?

--
assignee: docs@python -> terry.reedy
components: +IDLE -Documentation
nosy: +rhettinger
status: closed -> open

___
Python tracker 

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