[issue34119] Able to name a variable as 'input'. This creates problem when using input() function.

2018-07-14 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

While "shadowing a builtin" was irritating in your case, it is an unavoidable 
part of how Python works and is in some cases considered a feature.  

FWIW, there is a workaround.  You can reference the real input() function 
directly in the __builtins__ namespace:

>>> input = 'x'
>>> __builtins__.input('Enter your name: ')
Enter your name: Becky
'Becky'
>>> input
'x'

Also, consider using tools like pylint and flake8 which give warnings in cases 
like this.

--
nosy: +rhettinger
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



[issue34119] Able to name a variable as 'input'. This creates problem when using input() function.

2018-07-14 Thread Kishore Aadada


New submission from Kishore Aadada :

When i used input as a variable name, there is no error provided. After that I 
am calling input() function to read data. In such case, below error is reported.

Python 3.6.3 (v3.6.3:2c5fed8, Oct  3 2017, 17:26:49) [MSC v.1900 32 bit 
(Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> input = "Test input"
>>> data = input("Please enter some input")
Traceback (most recent call last):
  File "", line 1, in 
data = input("Please enter some input")
TypeError: 'str' object is not callable
>>>

--
components: IO
files: inputError.png
messages: 321680
nosy: kishoreaadada
priority: normal
severity: normal
status: open
title: Able to name a variable as 'input'. This creates problem when using 
input() function.
type: behavior
versions: Python 3.6
Added file: https://bugs.python.org/file47692/inputError.png

___
Python tracker 

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



[issue29710] Incorrect representation caveat on bitwise operation docs

2018-07-14 Thread Nick Coghlan


Nick Coghlan  added the comment:

The restriction of the footnote to ``x & y``, ``x | y``, and ``x ^ y`` was 
going to come from the fact that only those rows in the table will reference 
the new note. However, it likely makes sense to repeat the relevant expressions 
in the footnote as well, since that makes it clearer what ``x`` and ``y`` refer 
to in the second sentence.

Latest proposal:

=
The results of ``x | y``,  ``x ^ y``, and ``x & y`` are calculated as though 
carried out in two's complement with an infinite number of sign bits. In 
practice, performing the calculation with at least one extra sign extension bit 
(a working bit-width of ``1 + max(x.bit_length(), y.bit_length()`` or more) is 
sufficient to get the expected result.
=

--

___
Python tracker 

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



[issue34118] Fix some class entries in 'Built-in Functions'

2018-07-14 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
title: Fix some class entries entries in 'Built-in Functions' -> Fix some class 
entries in 'Built-in Functions'

___
Python tracker 

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



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

2018-07-14 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

There are also few differences between comprehensions and generator 
expressions. The author of the patch should not just replace all occurrences of 
"generator expression" with "generator comprehension", but analyze all 
occurrences of the sole "comprehension" and replace it with "non-generator 
comprehension" if needed.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue29710] Incorrect representation caveat on bitwise operation docs

2018-07-14 Thread Tim Peters


Tim Peters  added the comment:

Nick, that seems a decent compromise.  "Infinite string of sign bits" is how 
Guido & I both thought of it when the semantics of longs were first defined, 
and others in this report apparently find it natural enough too.  It also 
applies to all 6 operations in the table as-is.

It appears that

a bit-width of ``1 + max(x.bit_length(), y.bit_length()``

only applies as-is to 3 (~ has only one operand, while the bit length of the 
RHS doesn't matter for << and >>).  Provided that's clarified, I'd only suggest 
inserting "at least" before "one extra sign extension bit" and after "a 
bit-width of".  That's a bridge between the "infinite" and 
"fixed-albeit-variable-width" views:  "plus 1" is the smallest approximation to 
infinity that works, but anything at least that large works too.

--

___
Python tracker 

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



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

2018-07-14 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Guido asked me to try this out on students.  I'll report back after next week's 
class.

--
nosy: +rhettinger

___
Python tracker 

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



[issue8525] Display exceptions' subclasses in help()

2018-07-14 Thread Rob Cliffe

Rob Cliffe  added the comment:

On 14/07/2018 13:44, Nick Coghlan wrote:
> Nick Coghlan  added the comment:
>
> Reviewing the builtins in 3.7, I get the following results for builtin 
> objects that have defined subclasses immediately after interpreter startup:
>
> =
 for name, obj in vars(builtins).items():
> .. if isinstance(obj, type) and name in str(obj):
> .. subclasses = type(obj).__subclasses__(obj)
> .. if subclasses:
> .. print(f"{obj}: {len(subclasses)}")
> ..
> : 1
> : 1
> : 1
> : 1
> : 132
> : 1
> : 16
> : 1
> : 4
> : 19
> : 2
> : 13
> : 3
> : 1
> : 1
> : 1
> : 3
> : 2
> : 3
> : 3
> : 1
> : 10
> : 4
> =
>
> So rather than special-casing exceptions or builtins in general, my 
> inclination would be to include a section that lists up to 4 subclasses 
> inline, and then adds a "... and NNN additional subclasses" trailing when 
> there are more than 4 (or when there are less than 4 subclasses with public 
> names, but additional private subclasses).
>
>
My 2 cents:
     To use Exceptions optimally (e.g. to make the errors you trap 
neither too specific nor too general), you often need to know (and 
understand) the relevant part of the Exception hierarchy.  In particular 
you may know the name of an Exception that covers a particular use case, 
but not the names of its subclasses, one of which might be more 
appropriate.  Exceptions are exceptional* in that the "issubclass" 
relationship is vital to the way that they work.  So it is USEFUL to 
know ALL subclasses of a given Exception class (not just 4; in practice 
there won't be more than a dozen or two).  I have found myself in just 
this position; in fact it impelled me to adding a "show subclasses" 
feature to help() in my then current version of 
Python 2.  (An alternative might be a handy way of showing the complete 
built-in Exception hierarchy.)

I question whether it is really useful to know all subclasses of ANY 
class, or whether YAGNI.  I think that, for non-Exception classes, 
typically when you look at a class you may want to know its inheritance 
(to understand its functionality better), but it is rare that you will 
want to know what subclasses it has, if any.  No doubt there are 
exceptions* (perhaps you monkey-patch a class and want to know what 
subclasses might be affected).
Regards
Rob Cliffe

* Pun not intended

--

___
Python tracker 

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



[issue34118] Fix some class entries entries in 'Built-in Functions'

2018-07-14 Thread Terry J. Reedy

New submission from Terry J. Reedy :

The Library Reference 'Built-in Functions' chapter includes build-in classes 
because classes are functions in the sense of being callable with arguments and 
returning objects.  A proposal to change the name to Built-in Functions and 
Classes was rejected (by Raymond, as I remember).
I suspect that 'Built-in Callables' has also been proposed.
  
Some of the current entries need one or both of two fixes. 

1. Most, but not all, of the classes are tagged with '*class*' before the class 
name.  Classes classmethod and staticmethed are instead tagged with '@' since 
they are mostly used as decorators, although property is tagged *class*.

Classes enumerate, filter, map, memoryview, range, reversed, tuple, and zip are 
untagged.  I think, to be consistent, that they should all get the *class* tag.

2. Nearly all entries fully describe the arguments and return values.  The 
exceptions are those for 6 collection classes. The first 3 have an abbreviated 
description of the result and a reference for further details on the 
relationship of input to result.

 class dict(iterable, **kwarg)
Create a new dictionary. The dict object is the dictionary class. See dict 
and Mapping Types — dict for documentation about this class.
For other containers see the built-in list, set, and tuple classes, as well 
as the collections module.

class frozenset([iterable])
Return a new frozenset object, optionally with elements taken from 
iterable. frozenset is a built-in class. See frozenset and Set Types — set, 
frozenset for documentation about this class.
For other containers see the built-in set, list, tuple, and dict classes, 
as well as the collections module.

class set([iterable])
Return a new set object, optionally with elements taken from iterable. set 
is a built-in class. See set and Set Types — set, frozenset for documentation 
about this class.
For other containers see the built-in frozenset, list, tuple, and dict 
classes, as well as the collections module.

The next 3 replace 'Return a ___' with 'Rather than being a function'.  (This 
is from Nick's patch 6 years ago.  
https://github.com/python/cpython/commit/83c0ae5de642145ec225d29e7b239aa410229539.)
  I object to this because it is wrong if one uses the broad definition of 
function used in the chapter title.  It is also wrong in the implication there 
is anything special about these classes in regard to being functions verses 
classess.  

class list([iterable])
Rather than being a function, list is actually a mutable sequence type, as 
documented in Lists and Sequence Types — list, tuple, range.

range(start, stop[, step])
Rather than being a function, range is actually an immutable sequence type, 
as documented in Ranges and Sequence Types — list, tuple, range.

tuple([iterable])
Rather than being a function, tuple is actually an immutable sequence type, 
as documented in Tuples and Sequence Types — list, tuple, range.

I propose that the 2nd 3 follow the model of the 1st 3, except that the final 
line should be: "For other collections see the built-in range, tuple, list, 
frozenset, set, and dict classes, as well as the collections module." (with 1 
of the 6 omitted as appropriate).  (Range represents a collection, but is not a 
container in the sense that the others are.)

--
assignee: docs@python
components: Documentation
messages: 321674
nosy: docs@python, ncoghlan, rhettinger, terry.reedy
priority: normal
severity: normal
stage: needs patch
status: open
title: Fix some class entries entries in 'Built-in Functions'
type: behavior
versions: Python 3.6, Python 3.7, Python 3.8

___
Python tracker 

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



[issue34060] regrtest: log "CPU usage" on Windows

2018-07-14 Thread Ammar Askar


Ammar Askar  added the comment:

Opened up a PR with a proof of concept to get feedback on if this approach is 
reasonable. 

Giampaolo, on your psutil issue you specifically said, "(possibly without using 
WMI)"

Is there any particular problem with using WMI?

--

___
Python tracker 

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



[issue34060] regrtest: log "CPU usage" on Windows

2018-07-14 Thread Ammar Askar


Ammar Askar  added the comment:

Thanks a lot for that link Jeremy, it was really helpful. After reading up on 
it, my take is that winapi is the most appropriate place for this, it is a non 
public api that's used in the stdlib.

I've used Windows APIs in a way that we don't need to manually start up a 
thread and call a calc_load function, instead using a callback invoked by 
windows. Internally this uses a thread pool, but it means we don't have to 
worry about managing the thread ourselves.

The load is stored as a global but the winapi module is already marked as "-1" 
indicating it has global state, so that shouldn't be a problem. 
https://docs.python.org/3/c-api/module.html#c.PyModuleDef.m_size

Like Jeremy noted, using WMI does add a 5mb overhead or so to the calling 
process. One more caveat is that the PdhAddEnglishCounterW function is only 
available in Vista+. I'm not sure if we still support Windows XP, but the 
alternative is to use PdhAddCounter, which breaks if the system language is not 
english because the counter paths are localized.

--

___
Python tracker 

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



[issue34060] regrtest: log "CPU usage" on Windows

2018-07-14 Thread Ammar Askar


Change by Ammar Askar :


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

___
Python tracker 

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



[issue34114] Build failing: use of undeclared identifier '_Py_END_SUPPRESS_IPH' & '_Py_BEGIN_SUPPRESS_IPH'

2018-07-14 Thread INADA Naoki


INADA Naoki  added the comment:

Sometime, you need to run `make distclean` or `git clean -fdx` to remove wrong 
caches.

--
nosy: +inada.naoki
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



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

2018-07-14 Thread Brett Cannon


New submission from Brett Cannon :

The idea came up on python-dev to tweak the names of generator expressions to 
"generator comprehensions" to align more with list|set|dict comprehensions. 
This would be strictly a doc change (for now). A reference to generator 
expressions should be left if nothing else than to point to the new name.

--
assignee: docs@python
components: Documentation
messages: 321670
nosy: brett.cannon, docs@python
priority: low
severity: normal
status: open
title: Rename "generator expressions" to "generator comprehensions"

___
Python tracker 

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



[issue34116] Move all bytes/bytearray/int/float/complex documentation to Built-in Types

2018-07-14 Thread Andrés Delfino

Andrés Delfino  added the comment:

See talk at: 
https://python.zulipchat.com/#narrow/stream/116633-documentation/subject/Gather.20all.20type.20documentation.20in.20stdtypes

--

___
Python tracker 

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



[issue34116] Move all bytes/bytearray/int/float/complex documentation to Built-in Types

2018-07-14 Thread Andrés Delfino

Change by Andrés Delfino :


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

___
Python tracker 

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



[issue34112] 3.7.0 build error with --enable-optimizations

2018-07-14 Thread Benjamin Peterson


Benjamin Peterson  added the comment:

--enable-optimizations

On Sat, Jul 14, 2018, at 12:31, Jayanth Koushik wrote:
> 
> Jayanth Koushik  added the comment:
> 
> Hi. Do you mean turning of `--enable-optimizations` or reducing GCC 
> optimization level (O3 etc)?
> 
> --
> 
> ___
> Python tracker 
> 
> ___

--

___
Python tracker 

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



[issue34116] Move all bytes/bytearray/int/float/complex documentation to Built-in Types

2018-07-14 Thread Andrés Delfino

New submission from Andrés Delfino :

Right now, bytearray, bytes, complex, float and int documentation is splitted 
into stdtypes.rst and functions.rst. I think stdtypes.rst should be the only 
source with all documentation, and functions.rst should just point out to 
stdtypes.rst. This would make it easier to get the complete picture of a given 
type without having to jump between pages. This is how the documentation of 
dict, frozenset, list, memoryview, range, set, str and tuple works.

I believe bool() is more useful in functions.rst, as it's really short.

--
assignee: docs@python
components: Documentation
messages: 321667
nosy: adelfino, docs@python
priority: normal
severity: normal
status: open
title: Move all bytes/bytearray/int/float/complex documentation to Built-in 
Types
type: enhancement
versions: Python 2.7, Python 3.6, Python 3.7, Python 3.8

___
Python tracker 

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



[issue34115] code.InteractiveConsole.interact() closes stdin

2018-07-14 Thread Yonatan Zunger


New submission from Yonatan Zunger :

code.InteractiveConsole.interact() closes stdin on exit, which can be very 
surprising to successive code, not least future calls to interact(). A simple 
repro with a workaround is:

import code
import io
import os
import sys

def run():
print(sys.stdin.buffer.raw)
dupstdin = os.dup(0)
try:
code.InteractiveConsole().interact()
except SystemExit:
pass
finally:
# Workaround: Without this line, the second call to run() will fail 
with a ValueError when
# it tries to call input().
sys.stdin = io.TextIOWrapper(
io.BufferedReader(io.FileIO(dupstdin, mode='rb', closefd=False)),
encoding='utf8')

run()
run()


- The exciting behavior appears to happen inside the exec() of a 'quit()' 
command, and I haven't searched it out further.
- That behavior inside exec() is likely there for a good reason, in which case 
the best fix is probably to just save and restore stdin in the code library.

--
components: Library (Lib)
messages: 321666
nosy: Yonatan Zunger
priority: normal
severity: normal
status: open
title: code.InteractiveConsole.interact() closes stdin
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



[issue34114] Build failing: use of undeclared identifier '_Py_END_SUPPRESS_IPH' & '_Py_BEGIN_SUPPRESS_IPH'

2018-07-14 Thread Sanyam Khurana


Sanyam Khurana  added the comment:

This is strange.

I cloned the repo again at some other location, and I can build it successfully.

In my older clone, however, it shows me this error, despite running a `make 
clean`.

Any idea on what is the problem here?

--
nosy: +vstinner
priority: high -> 
stage: needs patch -> 
type: compile error -> 
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



[issue29199] test_regrtest fails if PCBuild directory doesn't exist

2018-07-14 Thread ppperry


ppperry  added the comment:

To be precise, fixed as part of issue33352

--

___
Python tracker 

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



[issue29199] test_regrtest fails if PCBuild directory doesn't exist

2018-07-14 Thread ppperry


ppperry  added the comment:

This issue seems to have been fixed in 3.7

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



[issue34114] Build failing: use of undeclared identifier '_Py_END_SUPPRESS_IPH' & '_Py_BEGIN_SUPPRESS_IPH'

2018-07-14 Thread Sanyam Khurana


New submission from Sanyam Khurana :

The step for configuration works correctly and gives a makefile.

On running `./make` the following traceback is produced:

```
$ make  
   
---
Modules/Setup.dist is newer than Modules/Setup;
check to make sure you have all the updates you
need in your Modules/Setup file.
Usually, copying Modules/Setup.dist to Modules/Setup will work.
---
gcc -Wno-unused-result -Wsign-compare -g -O0 -Wall-std=c99 -Wextra 
-Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers 
-Wstrict-prototypes -Werror=implicit-function-declaration   -I. -I./Include 
-c ./Modules/posixmodule.c -o Modules/posixmodule.o
./Modules/posixmodule.c:1548:9: error: use of undeclared identifier 
'_Py_BEGIN_SUPPRESS_IPH'
_Py_BEGIN_SUPPRESS_IPH
^
./Modules/posixmodule.c:1550:9: error: use of undeclared identifier 
'_Py_END_SUPPRESS_IPH'
_Py_END_SUPPRESS_IPH
^
./Modules/posixmodule.c:4356:5: error: use of undeclared identifier 
'_Py_BEGIN_SUPPRESS_IPH'
_Py_BEGIN_SUPPRESS_IPH
^
./Modules/posixmodule.c:4364:5: error: expected expression
else
^
./Modules/posixmodule.c:4368:5: error: use of undeclared identifier 
'_Py_END_SUPPRESS_IPH'
_Py_END_SUPPRESS_IPH
^
./Modules/posixmodule.c:5075:5: error: use of undeclared identifier 
'_Py_BEGIN_SUPPRESS_IPH'
_Py_BEGIN_SUPPRESS_IPH
^
./Modules/posixmodule.c:5081:5: error: use of undeclared identifier 
'_Py_END_SUPPRESS_IPH'
_Py_END_SUPPRESS_IPH
^
./Modules/posixmodule.c:5146:5: error: use of undeclared identifier 
'_Py_BEGIN_SUPPRESS_IPH'
_Py_BEGIN_SUPPRESS_IPH
^
./Modules/posixmodule.c:5157:5: error: use of undeclared identifier 
'_Py_END_SUPPRESS_IPH'
_Py_END_SUPPRESS_IPH
^
./Modules/posixmodule.c:5376:5: error: use of undeclared identifier 
'_Py_BEGIN_SUPPRESS_IPH'
_Py_BEGIN_SUPPRESS_IPH
^
./Modules/posixmodule.c:5379:5: error: use of undeclared identifier 
'_Py_END_SUPPRESS_IPH'
_Py_END_SUPPRESS_IPH
^
./Modules/posixmodule.c:7996:5: error: use of undeclared identifier 
'_Py_BEGIN_SUPPRESS_IPH'
_Py_BEGIN_SUPPRESS_IPH
^
./Modules/posixmodule.c:8011:5: error: use of undeclared identifier 
'_Py_END_SUPPRESS_IPH'
_Py_END_SUPPRESS_IPH
^
./Modules/posixmodule.c:8048:5: error: use of undeclared identifier 
'_Py_BEGIN_SUPPRESS_IPH'
_Py_BEGIN_SUPPRESS_IPH
^
./Modules/posixmodule.c:8050:5: error: use of undeclared identifier 
'_Py_END_SUPPRESS_IPH'
_Py_END_SUPPRESS_IPH
^
./Modules/posixmodule.c:8074:5: error: use of undeclared identifier 
'_Py_BEGIN_SUPPRESS_IPH'
_Py_BEGIN_SUPPRESS_IPH
^
./Modules/posixmodule.c:8077:5: error: use of undeclared identifier 
'_Py_END_SUPPRESS_IPH'
_Py_END_SUPPRESS_IPH
^
./Modules/posixmodule.c:8265:5: error: use of undeclared identifier 
'_Py_BEGIN_SUPPRESS_IPH'
_Py_BEGIN_SUPPRESS_IPH
^
./Modules/posixmodule.c:8271:5: error: use of undeclared identifier 
'_Py_END_SUPPRESS_IPH'
_Py_END_SUPPRESS_IPH
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make: *** [Modules/posixmodule.o] Error 1
```

--
components: Interpreter Core
messages: 321662
nosy: CuriousLearner
priority: high
severity: normal
stage: needs patch
status: open
title: Build failing: use of undeclared identifier '_Py_END_SUPPRESS_IPH' & 
'_Py_BEGIN_SUPPRESS_IPH'
type: compile error
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



[issue34113] LLTRACE segv

2018-07-14 Thread Andrew Valencia


New submission from Andrew Valencia :

Build with -DLLTRACE, then:

>>> __lltrace__ = 1
>>> a = [1, 2, 3]
0: 100, 0
push 1
3: 100, 1
push 2
6: 100, 2
push 3
9: 103, 3
pop 3
pop 2
pop 1
push [1, 2, 3]
12: 90, 0
pop [1, 2, 3]
15: 100, 3
push None
18: 83
pop None

>>> a[0] = 1
0: 100, 0
push 1
3: 101, 0
push [1, 2, 3]
6: 100, 1
push 0
9: 60Program received signal SIGSEGV, Segmentation fault.
0x004535ae in internal_print (op=0x84002364, fp=0xb7f3bd60 <_IO_2_1_stdout_>,
flags=0, nesting=0) at Objects/object.c:293
293 if (op->ob_refcnt <= 0)
(gdb) bt
#0  0x004535ae in internal_print (op=0x84002364,
fp=0xb7f3bd60 <_IO_2_1_stdout_>, flags=0, nesting=0)
at Objects/object.c:293
#1  0x0045370a in PyObject_Print (op=0x84002364,
fp=0xb7f3bd60 <_IO_2_1_stdout_>, flags=0) at Objects/object.c:330
#2  0x004ada11 in prtrace (v=0x84002364, str=0x54b61d "stackadj")
at Python/ceval.c:3979
#3  0x004a505b in PyEval_EvalFrameEx (f=0xb7d11994, throwflag=0)
at Python/ceval.c:1919
#4  0x004ace97 in PyEval_EvalCodeEx (co=0xb7ce7bf0, globals=0xb7d7c714,
locals=0xb7d7c714, args=0x0, argcount=0, kws=0x0, kwcount=0, defs=0x0,
defcount=0, closure=0x0) at Python/ceval.c:3604
#5  0x004a0671 in PyEval_EvalCode (co=0xb7ce7bf0, globals=0xb7d7c714,
locals=0xb7d7c714) at Python/ceval.c:669
#6  0x004d26ab in run_mod (mod=0x646d78, filename=0x53ddfe "",
globals=0xb7d7c714, locals=0xb7d7c714, flags=0xb568, arena=0x5f2b10)
at Python/pythonrun.c:1385
#7  0x004d1106 in PyRun_InteractiveOneFlags (fp=0xb7f3b5a0 <_IO_2_1_stdin_>,
filename=0x53ddfe "", flags=0xb568) at Python/pythonrun.c:866
#8  0x004d0e72 in PyRun_InteractiveLoopFlags (fp=0xb7f3b5a0 <_IO_2_1_stdin_>,
filename=0x53ddfe "", flags=0xb568) at Python/pythonrun.c:786
#9  0x004d0d1a in PyRun_AnyFileExFlags (fp=0xb7f3b5a0 <_IO_2_1_stdin_>,
filename=0x53ddfe "", closeit=0, flags=0xb568)
at Python/pythonrun.c:755
#10 0x0041d798 in Py_Main (argc=1, argv=0xb694) at Modules/main.c:645
#11 0x0041c5eb in main (argc=1, argv=0xb694) at ./Modules/python.c:20

--
components: Interpreter Core
messages: 321661
nosy: vandyswa
priority: normal
severity: normal
status: open
title: LLTRACE segv
type: crash
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



[issue34060] regrtest: log "CPU usage" on Windows

2018-07-14 Thread Jeremy Kloth


Jeremy Kloth  added the comment:

Also prior conversation:

https://bugs.python.org/issue30263#msg296311

--
nosy: +jkloth

___
Python tracker 

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



[issue30618] readlink for pathlib paths

2018-07-14 Thread girts


Change by girts :


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

___
Python tracker 

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



[issue34112] 3.7.0 build error with --enable-optimizations

2018-07-14 Thread Jayanth Koushik


Jayanth Koushik  added the comment:

Hi. Do you mean turning of `--enable-optimizations` or reducing GCC 
optimization level (O3 etc)?

--

___
Python tracker 

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



[issue20353] Hanging bug with multiprocessing + sqlite3 + tkinter (OS X 10.9 only)

2018-07-14 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

#33111 claims that importing tkinter is enough to hang multiprocessing on MacOS 
up through 3.6.

--
components: +macOS
nosy: +ronaldoussoren, terry.reedy

___
Python tracker 

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



[issue34112] 3.7.0 build error with --enable-optimizations

2018-07-14 Thread Benjamin Peterson


Benjamin Peterson  added the comment:

It's look you're using a fairly old toolchain. I wouldn't reccomend using fancy 
modern compiler optimizations with GCC 4.

--
nosy: +benjamin.peterson

___
Python tracker 

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



[issue33111] Merely importing tkinter breaks parallel code (multiprocessing, sharedmem)

2018-07-14 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

On MacOS, 3.7.0 is compiled for and the installer loads tcl/tk 8.6.8.  The same 
is true for the 3.6.6 64-bit installer.  Do tkinter and multiprocessing work 
together better with these installations?

I want to consider using multiprocessing and pipes instead subprocess and 
socket for IDLE's user-code execution process, started from and communicating 
with the initial tkinter gui process.  idlelib.run, which runs in the execution 
process to communicae with the gui process and supervise running user code, 
imports tkinter.  Besides which, users have to be able to import tkinter in 
their programs.

--
nosy: +pitrou

___
Python tracker 

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



[issue34112] 3.7.0 build error with --enable-optimizations

2018-07-14 Thread Jayanth Koushik


New submission from Jayanth Koushik :

I'm trying to build 3.7.0 locally (not as superuser) on a server. I am able to 
successfully build without `--enable-optimizations` enabled, but the build 
fails with it enabled.

I have dependencies installed in custom locations as well, and this is my 
environment.

PREF=/scratch

export LC_ALL=C
export CC=gcc
export CXX=g++

export PATH=/opt/gcc/4.9.2/bin:$PREF/binutils/bin:/bin:/usr/bin

export 
LD_LIBRARY_PATH=/opt/gcc/4.9.2/lib64:/opt/gcc/4.9.2/lib:$PREF/bzip2/lib:$PREF/gdbm/lib:$PREF/libffi/lib64:$PREF/ncurses/lib:$PREF/openmpi/lib:$PREF/openssl/lib:$PREF/readline/lib:$PREF/sqlite/lib:$PREF/util-linux/lib:$PREF/xz/lib:$PREF/zlib/lib:/usr/lib64

export 
CPATH=/opt/gcc/4.9.2/include:$PREF/bzip2/include:$PREF/gdbm/include:$PREF/libffi/include:$PREF/ncurse
s/include:$PREF/openmpi/include:$PREF/openssl/include:$PREF/readline/include:$PREF/sqlite/include:$PREF/util
-linux/include:$PREF/xz/include:$PREF/zlib/include

I also have to update setup.py to point to the right locations for 
dependencies. This is the diff, and I've attached the full file.

46c46
< disabled_module_list = ["_tkinter", "_uuid"]
---
> disabled_module_list = []
544,567c544,545
< add_dir_to_list(self.compiler.library_dirs,
< '/scratch/readline/lib')
< add_dir_to_list(self.compiler.include_dirs,
< '/scratch/readline/include')
< add_dir_to_list(self.compiler.library_dirs,
< '/scratch/bzip2/lib')
< add_dir_to_list(self.compiler.include_dirs,
< '/scratch/bzip2/include')
< add_dir_to_list(self.compiler.library_dirs,
< '/scratch/ncurses/lib')
< add_dir_to_list(self.compiler.include_dirs,
< '/scratch/ncurses/include')
< add_dir_to_list(self.compiler.library_dirs,
< '/scratch/xz/lib')
< add_dir_to_list(self.compiler.include_dirs,
< '/scratch/xz/include')
< add_dir_to_list(self.compiler.library_dirs,
< '/scratch/gdbm/lib')
< add_dir_to_list(self.compiler.include_dirs,
< '/scratch/gdbm/include')
< add_dir_to_list(self.compiler.library_dirs,
< '/scratch/libffi/lib64')
< add_dir_to_list(self.compiler.include_dirs,
< '/scratch/libffi/include')
---
> add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib')
> add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
835,836c813,814
< #elif self.compiler.find_library_file(lib_dirs, 'ncursesw'):
< #curses_library = 'ncursesw'
---
> elif self.compiler.find_library_file(lib_dirs, 'ncursesw'):
> curses_library = 'ncursesw'
1152c1130,1136
< sqlite_inc_paths = [ '/scratch/sqlite/include' ]
---
> sqlite_inc_paths = [ '/usr/include',
>  '/usr/include/sqlite',
>  '/usr/include/sqlite3',
>  '/usr/local/include',
>  '/usr/local/include/sqlite',
>  '/usr/local/include/sqlite3',
>  ]
1195a1180
> os.path.join(sqlite_incdir, '..', 'lib64'),
1196a1182,1183
> os.path.join(sqlite_incdir, '..', '..', 'lib64'),
> os.path.join(sqlite_incdir, '..', '..', 'lib'),

This is my build process.

mkdir build && cd build

LDFLAGS="-Wl,--rpath=$PREF/glibc/lib -Wl,--rpath=$PREF/bzip2/lib 
-Wl,--rpath=$PREF/gdbm/lib -Wl,--rpath=$PRE
F/ncurses/lib -Wl,--rpath=$PREF/openssl/lib -Wl,--rpath=$PREF/readline/lib 
-Wl,--rpath=$PREF/sqlite/lib -Wl,
--rpath=$PREF/xz/lib -Wl,--rpath=$PREF/zlib/lib -Wl,--rpath=$PREF/libffi/lib64 
-Wl,--rpath=$PREF/openmpi/lib
 -Wl,--rpath=$PREF/util-linux/lib 
-Wl,--dynamic-linker=$PREF/glibc/lib/ld-linux-x86-64.so.2" ../configure --
enable-shared --prefix=$PREF/python-latest --with-openssl=$PREF/openssl 
--enable-optimizations

make -j 8

And this is the error that I get. It's when rebuilding with optimizations.

Rebuilding with profile guided optimizations:
rm -f profile-clean-stamp
make build_all CFLAGS_NODIST=" -fprofile-use -fprofile-correction" LDFLAGS=""
make[1]: Entering directory `/scratch/src/Python-latest/build'
LD_LIBRARY_PATH=/scratch/src/Python-latest/build:/opt/gcc/4.9.2/lib64:/opt/gcc/4.9.2/lib:/scratch/bzip2/lib:/scratch/gdbm/lib:/scratch/libffi/lib64:/scratch/ncurses/lib:/scratch/openmpi/lib:/scratch/openssl/lib:/scratch/readline/lib:/scratch/sqlite/lib:/scratch/util-linux/lib:/scratch/xz/lib:/scratch/zlib/lib:/usr/lib64
 ./python -E -S -m sysconfig --generate-posix-vars ;\
if test $? -ne 0 ; then \
echo "generate-posix-vars failed" ; \

[issue33668] Wrong behavior of help function on module

2018-07-14 Thread Dong-hee Na


Dong-hee Na  added the comment:

I've checked both cases are now working on my patch.

--

___
Python tracker 

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



[issue33668] Wrong behavior of help function on module

2018-07-14 Thread Dong-hee Na


Dong-hee Na  added the comment:

This script works well on Python2 but not on Python3.
I've submitted a PR. Please take a look.

--
nosy: +corona10

___
Python tracker 

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



[issue33668] Wrong behavior of help function on module

2018-07-14 Thread Dong-hee Na


Change by Dong-hee Na :


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

___
Python tracker 

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



[issue29710] Incorrect representation caveat on bitwise operation docs

2018-07-14 Thread Nick Coghlan


Nick Coghlan  added the comment:

I think we have a fairly different notion of what clarity means here - I have 
no mental concept whatsoever of how to do two's complement arithmetic with an 
infinite number of sign bits (I learned most of what I know about two's 
complement by working with fixed point 16-bit and 32-bit microprocessors), so 
the infinite bits explanation provides me with very little useful insight, 
whereas I can readily cope with the notion of storing a single extra sign 
extension bit beyond the minimum required to hold the operands' two's 
complement representations.

That said, I do like the idea of using infinite precision arithmetic as the 
formal definition of the intended language semantics, which would lead to 
wording like the following:

=
Each bitwise operation has the same result as though carried out in two's 
complement with an infinite number of sign bits. In practice, performing the 
calculation with one extra sign extension bit (a bit-width of ``1 + 
max(x.bit_length(), y.bit_length()``) is sufficient to get the expected result.
=

--

___
Python tracker 

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



[issue8525] Display exceptions' subclasses in help()

2018-07-14 Thread Nick Coghlan


Nick Coghlan  added the comment:

Reviewing the builtins in 3.7, I get the following results for builtin objects 
that have defined subclasses immediately after interpreter startup:

=
>>> for name, obj in vars(builtins).items():
... if isinstance(obj, type) and name in str(obj):
... subclasses = type(obj).__subclasses__(obj)
... if subclasses:
... print(f"{obj}: {len(subclasses)}")
... 
: 1
: 1
: 1
: 1
: 132
: 1
: 16
: 1
: 4
: 19
: 2
: 13
: 3
: 1
: 1
: 1
: 3
: 2
: 3
: 3
: 1
: 10
: 4
=

So rather than special-casing exceptions or builtins in general, my inclination 
would be to include a section that lists up to 4 subclasses inline, and then 
adds a "... and NNN additional subclasses" trailing when there are more than 4 
(or when there are less than 4 subclasses with public names, but additional 
private subclasses).

So in a class like "int", for example, we'd see:

Currently imported subclasses:
bool

While in a class like OSError we'd see:

Currently imported subclasses:
BlockingIOError
ChildProcessError
ConnectionError
FileExistsError
... and 9 other subclasses

And in "help(object)" we'd see something like:

Currently imported subclasses:
async_generator
BaseException
builtin_function_or_method
bytearray
... and 215 other subclasses


The initial list of subclasses to show would be restricted to public builtins: 
`sorted((str(cls) for cls in object.__subclasses__() if not 
cls.__name__.startswith("_") and cls.__module__ == "builtins"), key=str.lower)`

If that gives less then four names, then the list of names would be expanded to 
subclasses with public names in public modules (i.e. neither __qualname__ nor 
__module__ starts with "_", neither of those contains "._", and qualname 
doesn't contain "..").

The full count of currently imported subclasses would ignore whether the 
subclass names were public or not.

--
nosy: +ncoghlan

___
Python tracker 

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



[issue34111] python-config breaks when symlinked to another location

2018-07-14 Thread tobik


New submission from tobik :

When symlinking python3.6-config to another location, it starts
outputting bogus paths.  It's convenient to symlink the system
python3.6-config to somewhere else in PATH to make sure the build
of an application with a hardcoded use of python3-config is using
the right Python version.  This is something that we would like to
do in FreeBSD Ports instead of having to patch build files.

It works fine with python2.7-config.  However when I try a similar
thing with python3.6-config it starts outputting bogus paths.  For
example

$ pwd
/home/tobias
$ python2.7-config --includes
-I/usr/local/include/python2.7 -I/usr/local/include/python2.7
$ ln -s /usr/local/bin/python2.7-config python2-config
$ ./python2-config --includes
-I/usr/local/include/python2.7 -I/usr/local/include/python2.7
$ python3.6-config --includes
-I/usr/local/include/python3.6m -I/usr/local/include/python3.6m
$ ln -s /usr/local/bin/python3.6-config python3-config
$ ./python3-config --includes
-I/home/include/python3.6m -I/home/include/python3.6m

It would be nice if this could just work.  This was on FreeBSD but
the same problem exists on e.g. Void Linux too.

The problem seems to be that the path to the original script is not
resolved properly when trying to determine the install prefix.
Adding realpath(1) to python-config seems to solve it.

--
files: patch-Misc__python-config.sh.in
messages: 321650
nosy: tobik
priority: normal
severity: normal
status: open
title: python-config breaks when symlinked to another location
type: behavior
versions: Python 3.4, Python 3.5, Python 3.6, Python 3.7
Added file: https://bugs.python.org/file47690/patch-Misc__python-config.sh.in

___
Python tracker 

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



[issue24618] Invalid read in PyCode_New

2018-07-14 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


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

___
Python tracker 

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



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

2018-07-14 Thread Giampaolo Rodola'


Giampaolo Rodola'  added the comment:

> For example, os.stat() accepts both a filename (string) or a file descriptor 
> (integer).

Interesting. I never realized that. Other functions involved in file copy are:

os.lchmod
os.chmod
os.listxattr
os.getxattr

I checked and it appears they all support fd args (this is not documented and 
it should). os.path.* all use os.stat() internally so they can easily be 
replaced. I wonder whether this can introduce any change in semantic though:

>>> import os
>>> os.stat('foobar')
Traceback (most recent call last):
  File "", line 1, in 
FileNotFoundError: [Errno 2] No such file or directory: 'foobar'
>>> os.stat(333)
Traceback (most recent call last):
  File "", line 1, in 
OSError: [Errno 9] Bad file descriptor: 333

Also wonder it this would play nice on Windows.

--

___
Python tracker 

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



[issue34060] regrtest: log "CPU usage" on Windows

2018-07-14 Thread Giampaolo Rodola'


Giampaolo Rodola'  added the comment:

There is an old ticket for this in psutil with some (possible useful) 
references in it: 
https://github.com/giampaolo/psutil/issues/604

--

___
Python tracker 

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



[issue34068] traceback.clear_frames(): Objects/typeobject.c:3086: _PyType_Lookup: Assertion `!PyErr_Occurred()' failed.

2018-07-14 Thread Zackery Spytz


Change by Zackery Spytz :


--
nosy: +ZackerySpytz
versions: +Python 3.6, Python 3.7

___
Python tracker 

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



[issue34060] regrtest: log "CPU usage" on Windows

2018-07-14 Thread Ammar Askar


Ammar Askar  added the comment:

Taking a shot at this, should take a day or so.

--

___
Python tracker 

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



[issue34068] traceback.clear_frames(): Objects/typeobject.c:3086: _PyType_Lookup: Assertion `!PyErr_Occurred()' failed.

2018-07-14 Thread Zackery Spytz


Change by Zackery Spytz :


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

___
Python tracker 

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



[issue34060] regrtest: log "CPU usage" on Windows

2018-07-14 Thread Ammar Askar


Ammar Askar  added the comment:

Annoyingly, it looks like Windows does not provide an API that gives an average 
value. There is a counter exposed called "System \ Processor Queue Length" 
which does what the equivalent of unix's load

https://blogs.technet.microsoft.com/askperf/2008/01/15/an-overview-of-processor-bottlenecks/

But we're gonna have to average it ourselves if we want this information.

--
nosy: +ammar2

___
Python tracker 

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



[issue34087] int(s), float(s) and others may cause segmentation fault

2018-07-14 Thread INADA Naoki


INADA Naoki  added the comment:


New changeset b2f8aa0c998d331ab2b4c701756a6427c0e91d48 by INADA Naoki in branch 
'3.6':
bpo-34087: Backport tests for int/float/complex (GH-8274)
https://github.com/python/cpython/commit/b2f8aa0c998d331ab2b4c701756a6427c0e91d48


--

___
Python tracker 

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



[issue18295] Possible integer overflow in PyCode_New()

2018-07-14 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Since 3.7 the number of arguments no longer limited by 255 (see issue12844 and 
issue18896).

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

___
Python tracker 

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



[issue34060] regrtest: log "CPU usage" on Windows

2018-07-14 Thread Giampaolo Rodola'


Change by Giampaolo Rodola' :


--
nosy: +giampaolo.rodola

___
Python tracker 

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