[issue42005] profile/cProfile CLI should catch BrokenPipeError

2020-10-10 Thread Zhiming Wang


Change by Zhiming Wang :


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

___
Python tracker 

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



[issue39828] json.tool should catch BrokenPipeError

2020-10-10 Thread Zhiming Wang


Change by Zhiming Wang :


--
nosy: +zmwangx
nosy_count: 5.0 -> 6.0
pull_requests: +21618
pull_request: https://github.com/python/cpython/pull/22643

___
Python tracker 

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



[issue42005] profile/cProfile CLI should catch BrokenPipeError

2020-10-10 Thread Zhiming Wang


New submission from Zhiming Wang :

Since profile/cProfile CLI interface prints a sorted list of stats, using head 
to limit output to the most relevant entries should be a fairly natural thing 
to do. Unfortunately, BrokenPipeError isn't caught, causing quite a bit of 
pollution to the output:

$ python3 -m cProfile -m http.server -h | head
usage: http.server [-h] [--cgi] [--bind ADDRESS] [--directory DIRECTORY]
   [port]

positional arguments:
  port  Specify alternate port [default: 8000]

optional arguments:
  -h, --helpshow this help message and exit
  --cgi Run as CGI Server
  --bind ADDRESS, -b ADDRESS
Traceback (most recent call last):
  File "/Users/zmwang/.pyenv/versions/3.9.0/lib/python3.9/runpy.py", line 197, 
in _run_module_as_main
return _run_code(code, main_globals, None,
  File "/Users/zmwang/.pyenv/versions/3.9.0/lib/python3.9/runpy.py", line 87, 
in _run_code
exec(code, run_globals)
  File "/Users/zmwang/.pyenv/versions/3.9.0/lib/python3.9/cProfile.py", line 
180, in 
main()
  File "/Users/zmwang/.pyenv/versions/3.9.0/lib/python3.9/cProfile.py", line 
173, in main
runctx(code, globs, None, options.outfile, options.sort)
  File "/Users/zmwang/.pyenv/versions/3.9.0/lib/python3.9/cProfile.py", line 
19, in runctx
return _pyprofile._Utils(Profile).runctx(statement, globals, locals,
  File "/Users/zmwang/.pyenv/versions/3.9.0/lib/python3.9/profile.py", line 66, 
in runctx
self._show(prof, filename, sort)
  File "/Users/zmwang/.pyenv/versions/3.9.0/lib/python3.9/profile.py", line 72, 
in _show
prof.print_stats(sort)
  File "/Users/zmwang/.pyenv/versions/3.9.0/lib/python3.9/cProfile.py", line 
42, in print_stats
pstats.Stats(self).strip_dirs().sort_stats(sort).print_stats()
  File "/Users/zmwang/.pyenv/versions/3.9.0/lib/python3.9/pstats.py", line 431, 
in print_stats
self.print_line(func)
  File "/Users/zmwang/.pyenv/versions/3.9.0/lib/python3.9/pstats.py", line 513, 
in print_line
print(f8(tt/nc), end=' ', file=self.stream)
BrokenPipeError: [Errno 32] Broken pipe
Exception ignored in: <_io.TextIOWrapper name='' mode='w' 
encoding='utf-8'>
BrokenPipeError: [Errno 32] Broken pipe

I think the exception should be caught in order to suppress this noise.

--
components: Library (Lib)
messages: 378421
nosy: zmwangx
priority: normal
severity: normal
status: open
title: profile/cProfile CLI should catch BrokenPipeError
type: behavior
versions: Python 3.10

___
Python tracker 

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



For Creatives and Developers Only

2020-10-10 Thread Joe Mayami
We are recruiting Developers, and Creatives to join our community into building 
personal portfolios, personal development skills, work on Open Source Projects, 
Devops, Collaboration, User Testing and Supports.

Community members include experts in product designs, python programming, data 
science, creative writers, graphics and designs, artificial intelligence and a 
lot more.

Link to join: https://chat.whatsapp.com/Geld8FNt4QCLGhYpA8DxkG
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python's carbon guilt

2020-10-10 Thread Terry Reedy

On 10/10/2020 11:58 AM, Peter Pearson wrote:

Python advocates might want to organize their thoughts on
this subject before their bosses spring the suggestion:

 From 
https://www.sciencemag.org/news/2020/10/we-re-part-problem-astronomers-confront-their-role-and-vulnerability-climate-change
 :

 . . . Astronomers should also abandon popular programming languages
 such as Python in favor of efficient compiled languages. Languages
 such as Fortran and C++, Zwart calculates, are more than 100 times
 more carbon efficient than Python because they require fewer
 operations.


Here is my reply to the "senior correspondent for astronomy..." who 
wrote the columm.

---

Dear Mr. Clery:

You report that Zwart of Leiden U says ...

"Astronomers should also abandon popular programming languages such as 
Python in favor of efficient compiled languages. Languages such as 
Fortran and C++, Zwart calculates, are more than 100 times more carbon 
efficient than Python because they require fewer operations."


Summary counter claim: the claim is phony.  As actually used by 
astronomers for computationally intensive tasks, Python is nearly if not 
as 'carbon efficient' -- because nearly all the computation is done with 
machine code compiled from C, Fortran, C++, or whatever.


(I am not an expert here, but am reporting to you a summary of what is 
generally known among experienced Python users.  I am leaving out 
numerous details.  Feel free to contact scientific Python experts for more.)


Here is how anti-Python, pro-OtherLanguage people come up with such 
misleading numbers as '100x slower'.  Confuse the issue by ascribing 
efficiency to languages rather than implementations.  Then compare a 
relatively efficient 'production' implementation of some algorithm in 
OtherLanguage to an computer inefficient (but human efficient) 
'development' implementation in Python that ignores how Python is being 
used in practice by scientific communities, such as the astronomy community.


Step 1: Create a file with couple of numerically intensive functions 
such as matrix_init and matrix_invert written in directly compiled 
OtherLanguage.  Add calls to matrix_init and matrix_invert.  Time one or 
more runs.


Step 2: Naively translate OtherLanguage directly into Python.  Don't 
allow imports. Time one or more runs with the CPython interpreter. 
Compare the OtherLanguage time to this worst case Python time.  Imply 
that users of Python are stupid enough to stop here for production 
usage.  I consider this a bit slanderous.


In practice, Python users inverting matrices, for instance, import the 
compiled numpy module, which among other things, wraps the standard 
Linpack package, which  uses machine-specific, assemble-coded, Basic 
Linear Algebra Subroutines (BLAS) when available.  In practice, I have 
read, the overhead of calling C libraries from Python instead of C is 
only a few percent.


The original and still main Python implementation, CPython, is written 
in C.  It interprets Python code, which is 'slow', but the Python code 
can include calls to fast, compiled, pre-written C functions.  CPython 
was designed from the beginning to be extended with other other modules 
and functions written in C. (Fortran extensions were included either 
immediately or soon after, but I don't know which.)  Some of these are 
included in the standard library, others from third-parties.


Since the release of Python 1.0 in 1992, real-world Python users, have 
been extending CPython when appropriate for production usage.  Indeed, 
numerical scientific computation was Python's first 'killer 
application'.  Now, most every open-source C library with significant 
usage has been wrapped.  There are at least hundreds. The current 
standard numerical package, numpy, is the third, and the needs of 
astronomers were among those that contributed to the design.


--
Terry Jan Reedy

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


[issue42001] Deprecate `typing.io` Wrapper Namespace

2020-10-10 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
nosy: +gvanrossum, levkivskyi

___
Python tracker 

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



Re: Truncation error

2020-10-10 Thread Grant Edwards
On 2020-10-10, Peter J. Holzer  wrote:
> On 2020-10-07 07:53:55 +0200, Marco Sulla wrote:
>> If you want to avoid float problems, you can use Decimal:
>
> Decimal doesn't avoid floating point problems, because it is a floating
> point format. For example:
> [...]

> >>> from decimal import *
> >>> a = Decimal(3)
> >>> a
> Decimal('3')
> >>> b = Decimal(1E50)
> >>> b
> Decimal('17629769841091887003294964970946560')
> [...]

There are two problems with your code:

 1. You meant Decimal('1e50').  What you typed creates a Decimal value
from the IEEE 64-bit floating point value closest to 1e50.

 2. You need to increase the context precision.  It defaults to 28,
and you're example needs it to be at least 51:

>>> getcontext().prec = 100
>>> a = Decimal(3)
>>> b = Decimal('1e50')
>>> c = Decimal(2)
>>> a + b - c - b
Decimal('1')
>>> b - b + a - c
Decimal('1')
>>> a + (b - b) - c
Decimal('1')
>>> a + b - b - c
Decimal('1')

Like other floating point systems, you still need to know what you're
doing if you want to get the "right" results.

--
Grant

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


Re: Python's carbon guilt

2020-10-10 Thread Tim Daneliuk
On 10/10/20 2:35 PM, Marco Sulla wrote:
> He should also calculate the carbon dioxide emitted by brains that
> works in C++ only. I omit other sources.
> 


yes, methane is an alleged greenhouse gas as well
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Trying to Download PygameZero

2020-10-10 Thread Terry Reedy

On 10/10/2020 11:11 AM, Mats Wichmann wrote:

On 10/10/20 12:22 AM, Tom Hedge via Python-list wrote:
I am in a 8 grade coding class at the moment and my teacher asked me to download a script 

... [on Windows according to file paths]... .


The problem is the pygame developers have not released a pygame for
Python 3.9 and you're using Python 3.9.


https://www.lfd.uci.edu/~gohlke/pythonlibs/ has wheels for pygame. 
('wheel' is the distribution format use by pypi.)  Download to you 
system and install with pip from that.


--
Terry Jan Reedy

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


[issue41972] bytes.find consistently hangs in a particular scenario

2020-10-10 Thread Tim Peters


Tim Peters  added the comment:

Ya, the case for the diff is at best marginal. Note that while it may be 
theoretically provable that the extra test would make the worst cases slower, 
that's almost certainly not measurable. The extra test would almost never be 
executed in the worst cases: in those the last characters of the needle and 
haystack DO match, and we spend almost all the total time in the

for (j = 0; j < mlast; j++)

loop.  The extra test is only in the branch where the last characters _don't_ 
match.

In that branch, it's already certain that the last haystack character does not 
match the last needle character, so in a probabilistic sense, for "random" data 
that increases the odds that the last haystack character isn't in the needle at 
all. In which case the payoff is relatively large compared to the cost of the 
test (can skip len(needle) positions at once, instead of only 1).

I don't believe this can be out-thought. It would require timing on "typical" 
real-life searches. Which are likely impossible to obtain ;-)

Offhand do you know what the _best_ timing for two-way search is in a 
pattern-not-found case? The algorithm is too complicated for that to be 
apparent to me at a glance. As Fredrik said in the post of his I linked to, he 
was very keen to have an algorithm with best case sublinear time. For example, 
the one we have takes best-case not-found O(n/m) time (where n is the haystack 
length and m the needle length).  For example, searching for 'B' * 1_000_000 in 
'A' * 10_000_000 fails after just 9 character comparisons (well, not counting 
the million less 1 compares to initialize `skip` to the ultimately useless 0).

--

___
Python tracker 

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



[issue42003] After changing to list or tuple, will the original parameter change?

2020-10-10 Thread Steven D'Aprano


Steven D'Aprano  added the comment:

This is not a bug. In Python 2, zip() returns a list, so you can use it over 
and over again. But in Python 3, zip() returns an iterator, and you can only 
use iterators once. After you have used the iterator, it is exhausted and there 
is nothing left.

So the behaviour you see is expected and intentional.

--
nosy: +steven.daprano
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

___
Python tracker 

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



Re: Problem saving datetime to file and reading it back for a calculation

2020-10-10 Thread Chris Angelico
On Sun, Oct 11, 2020 at 12:57 PM Cameron Simpson  wrote:
> Personally I strongly dislike using datetimes for computation or as the
> basis for time record keeping, essentially because of the timezone issue
> but also because the human calendar is a complex disaster of illfitting
> units (days in a year? variable; days in a month? variable; that table
> of days per unit? variable depending on your time in history).
>
> Instead, I always try to work in POSIX timestamps, an absolute number of
> seconds since midnight, 1 January 1970 GMT. You can always do arithmetic
> directly between these in seconds, then convert for presentation
> purposes whenever.
>

Absolutely agree, with the annoying exception of recurring events. If
a human says "this happens every Monday at 2pm", then the human
expects it to recur every Monday at 2pm, not every 604800 seconds. The
difference shows up when the conversion between UTC and local time
changes - most commonly when Daylight Saving Time starts or ends...

(And I guess if you care about leap seconds, then Unix time would be
inappropriate there too. But I rather doubt that most of us are
bothered by that.)

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


Re: Problem saving datetime to file and reading it back for a calculation

2020-10-10 Thread Cameron Simpson
On 10Oct2020 18:17, Steve  wrote:
>I would like to use the line:
>HoursDiff = int((d2-d1).total_seconds()/3600)
>to determine the difference in hours between two timedate entries.
>
>The variable d2 is from datetime.now()
>and d1 is read from a text file.
>
>I can save d2 to the file only if I convert it to string and, at a later
>date, it gets read back in as d1 as string.

That is the nature of text files.

>The variable d1 as string will
>not work in the HoursDiff statement.

Because it is a string.

Peter has described a way to transcribe a datetime in an arbitrary string 
format and back. Note that his example formats are "naive" - they don't know 
what you timezone is, and you want that if that ever varies (not just 
datetimes in contexts from different places, but also at different times of 
the year if you run different summer and winter times, particularly 
troublesome around the transition from one to the other).

>To me, it looks like a problem in formatting.
>How do I fix this?

Personally I strongly dislike using datetimes for computation or as the 
basis for time record keeping, essentially because of the timezone issue 
but also because the human calendar is a complex disaster of illfitting 
units (days in a year? variable; days in a month? variable; that table 
of days per unit? variable depending on your time in history).

Instead, I always try to work in POSIX timestamps, an absolute number of 
seconds since midnight, 1 January 1970 GMT. You can always do arithmetic 
directly between these in seconds, then convert for presentation 
purposes whenever.

Because you're now working in seconds directly, you go:

HoursDiff = int((t2-t1)/3600)

or:

HoursDiff = (t2-t1) // 3600

When you first collect your datetime, convert it to a POSIX timestamp 
immediately. If you're _starting_ from datetime.now(), do not do that! Just 
start with time.time() and no conversion is needed at all.

Just _present_ in datetime formats if you need to. DO NOT try to work 
with them as your basic type - they are a source of pitfalls.

As far as storing timestamps in a file, they're ints or floats; just 
write them out.

Cheers,
Cameron Simpson 
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue42004] Allow uploading files with SimpleHTTPRequestHandler

2020-10-10 Thread Javier Ayres


New submission from Javier Ayres :

Hello. I'm a big fan of the http.server module to quickly serve some files in a 
local network with `python3 -m http.server`. I regularly needed to get some 
files from other people too, but getting everyone to install/run python3 was 
not such a simple task. Eventually I wrote a subclass of 
SimpleHTTPRequestHandler that added a form with a file input and accepted POST 
requests, so people could also upload files to my computer. I think this would 
be a fine addition to SimpleHTTPRequestHandler, so I'm attaching a potential 
patch that implements this and adds a new cli parameter so this feature is only 
enabled explicitly.

--
components: Library (Lib)
files: patch
messages: 378418
nosy: lufte
priority: normal
severity: normal
status: open
title: Allow uploading files with SimpleHTTPRequestHandler
type: enhancement
versions: Python 3.10
Added file: https://bugs.python.org/file49506/patch

___
Python tracker 

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



Re: Problem saving datetime to file and reading it back for a calculation

2020-10-10 Thread Peter Pearson
On Sat, 10 Oct 2020 18:17:26 -0400, Steve  wrote:
> I would like to use the line:
> HoursDiff = int((d2-d1).total_seconds()/3600)
> to determine the difference in hours between two timedate entries.
>
> The variable d2 is from datetime.now()
> and d1 is read from a text file.
>
> I can save d2 to the file only if I convert it to string and, at a later
> date, it gets read back in as d1 as string.   The variable d1 as string will
> not work in the HoursDiff statement.
>
> To me, it looks like a problem in formatting.
> How do I fix this?

datetime.datetime.strftime and datetime.datetime.strptime ?

>>> t = datetime.datetime.now()
>>> t.strftime("%Y-%m-%d %H:%M:%S")
'2020-10-10 18:02:33'
>>> b = datetime.datetime.strptime("2020-09-09 12:34:56", "%Y-%m-%d %H:%M:%S")
>>> b.strftime("%Y-%m-%d %H:%M:%S")
'2020-09-09 12:34:56'
>>> 

-- 
To email me, substitute nowhere->runbox, invalid->com.
-- 
https://mail.python.org/mailman/listinfo/python-list


aiosnow

2020-10-10 Thread Robert Wikman
Happy to announce a project I've been working on for some time that's
finally in beta: aiosnow, a MIT licensed Python 3 client library for
interacting with an ITSM cloud service, providing something not too
dissimilar to a database ORM.

I'm sharing this here as the library makes use of Python asyncio, and other
cool features like:
- Asynchronous generators, context managers
- Query condition chaining using Python bitwise operators
- Model Schema system implemented using Marshmallow
- The aiohttp library for working with remote HTTP APIs

It was built with modularity in mind, and is meant to be forked, hacked and
consumed in other projects - commercial or otherwise.

What's in it for me?
I do this for fun, to learn, and to support the asyncio backend of another
project I'm working on, which uses this library at its core.

GitHub page:
https://github.com/rbw/aiosnow

Technical documentation:
https://aiosnow.readthedocs.io/en/latest

Big thanks to the code contributors and donors!

--
Robert Wikman
0xf6feb506ae5d3762
___
Python-announce-list mailing list -- python-announce-list@python.org
To unsubscribe send an email to python-announce-list-le...@python.org
https://mail.python.org/mailman3/lists/python-announce-list.python.org/
Member address: arch...@mail-archive.com


Guppy 3/Heapy 3.1.0

2020-10-10 Thread YiFei Zhu
I am happy to announce Guppy 3 3.1.0

Guppy 3 is a library and programming environment for Python,
currently providing in particular the Heapy subsystem, which supports
object and heap memory sizing, profiling and debugging. It also
includes a prototypical specification language, the Guppy
Specification Language (GSL), which can be used to formally specify
aspects of Python programs and generate tests and documentation from a
common source.

Guppy 3 is a fork of Guppy-PE, created by Sverker Nilsson for Python 2.

This is a major feature release. The main news in this release:

o Python 3.9 support, without subinterpreter support or inter-interpreter
  traversal.
o Added .byprod classifier via tracemalloc, and .prod to print tracemalloc
  traceback.
o Added .all to print all lines in a MorePrinter buffer.
o Added R_INSET relation for being contained by an unordered set.

License: MIT

The project homepage is on GitHub:

https://github.com/zhuyifei1999/guppy3

Enjoy,

YiFei Zhu
___
Python-announce-list mailing list -- python-announce-list@python.org
To unsubscribe send an email to python-announce-list-le...@python.org
https://mail.python.org/mailman3/lists/python-announce-list.python.org/
Member address: arch...@mail-archive.com


[issue42003] After changing to list or tuple, will the original parameter change?

2020-10-10 Thread foxpython_2020


New submission from foxpython_2020 :

c = dict(zip(['one', 'two', 'three'], [1, 2, 3]))
print("1:",c) # right: {'one': 1, 'two': 2, 'three': 3}

b= zip(['one', 'two', 'three'], [1, 2, 3])
a= list(b) #Because of this line of code, the result is different
print("2:",dict(b)) #wrong: {}

b= zip(['one', 'two', 'three'], [1, 2, 3])
a= tuple(b) #Because of this line of code, the result is different
print("2:",dict(b)) #wrong: {}

--
messages: 378417
nosy: foxpython_2020
priority: normal
severity: normal
status: open
title: After changing to list or tuple, will the original parameter change?

___
Python tracker 

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



Problem saving datetime to file and reading it back for a calculation

2020-10-10 Thread Steve
I would like to use the line:
HoursDiff = int((d2-d1).total_seconds()/3600)
to determine the difference in hours between two timedate entries.

The variable d2 is from datetime.now()
and d1 is read from a text file.

I can save d2 to the file only if I convert it to string and, at a later
date, it gets read back in as d1 as string.   The variable d1 as string will
not work in the HoursDiff statement.

To me, it looks like a problem in formatting.
How do I fix this?

Steve


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


[issue38605] [typing] PEP 563: Postponed evaluation of annotations: enable it by default in Python 3.10

2020-10-10 Thread Guido van Rossum


Guido van Rossum  added the comment:


New changeset 0ae216b11644b23511c6287a52e7d28aeb9f by Batuhan Taskaya in 
branch 'master':
bpo-38605: bump the magic number for 'annotations' future (#22630)
https://github.com/python/cpython/commit/0ae216b11644b23511c6287a52e7d28aeb9f


--

___
Python tracker 

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



RE: Python's carbon guilt

2020-10-10 Thread Avi Gross via Python-list
People have a tendency to go too far in their religious zeal, Peter.

We could go back to writing on chalkboards to do calculations then re-use
the chalk dust when erasing to write again.

Many computers do almost nothing 90+ percent of the time. Want to outlaw
those or force them to accept random jobs from the internet when relatively
idle?

But all kidding aside, anything used frequently and not changed often might
be a good candidate for an efficient solution that uses fewer resources. Yet
our computers, so far, have been in many ways getting cheaper and in many
cases use less electricity to do the same number of calculations. But there
are tradeoffs such as optimizing speed over memory use or other resources
that are external and thus slower. 

The ultimate carbon cost can sometimes be for  carbon-based organisms, most
of them suitable to be called human. When you measure how long it takes them
to develop applications and verify they have minimal bugs, you may notice
that some development environments seem to take lots more time than others
for common tasks. Interactive has huge advantages in many cases. Slowest
would be asking people to go back to writing in machine code, not very
portably.

The reality is that speed and other resource use do matter for anything run
often or that would take a very long time. Languages like python and R
acknowledge that and quite a few parts are now replaced by calls to
libraries in other language or C/C++ code. But often that is done only later
when the code is not going to be changed regularly.

I think there is a reality here. The costs of computing end sometimes of
power usage, often are dropping. The users like getting extra features and
underneath the covers, that often means lots of extra IF statements or other
checks, or loops that keep checking regularly to see if they need to do
anything.  If you program a GUI that allows the user to click or type in
many places at random, there can be lots of overhead even when done in a
compiled language. True speed and efficiency might require removing lots of
features entirely as too expensive. It may well be cheaper to do some
operations on matrices where every row/column is of the same object type but
there are very serious advantages to allowing a mixed type operation such as
a data.frame where each column is a hidden vector of some type or even at
times to allowing every cell/item to be of any object type. The overhead
rises in terms of storage and CPU time used but it allows higher levels of
abstraction and often the ability to write code with fewer lines that
handles many more conditions, sometimes invisibly. 

Consider how computing is being used and ask if a little more carbon
footprint there may reduce the carbon footprint elsewhere. Would you rather
have people spend years or months developing some app that can be used in a
way that reduces overall carbon dioxide production?

If your answer is that you can have it both ways, fine. But you may have
trouble hiring enough people willing to work under those constraints and you
may be told of lots of things they won't feel comfortable doing and it may
take longer and ...

A question. Are recent compiled languages that add features as small and
fast as earlier ones? For example, many older languages required a function
to take a fixed number of arguments in a fixed order and of exactly the
types mentioned when created. Some interpreted languages allow lots of
additional functionality, some of which could easily be provided such as
allowing named arguments in any order, or allowing additional optional
arguments or default values and so on. Much of this could be done in a
compiled way, but with additional compile time and even run-time cost. But
some features, by definition, must be at run time and especially for code
that modifies itself or creates new objects dynamically. IF you want some of
these new features, how would you supply them in a compiled way without
adding lots of the overhead you want to reduce? 

Carbon guilt should not be taken seriously as an immediate goal as compared
to an overall goal. If we make more people able to work from home or nearby
offices and avoid long commutes, does it matter if your remote work is much
more carbon friendly than the costs to travel and then still use other
energy there for lighting and more computers and ...




-Original Message-
From: Python-list  On
Behalf Of Peter Pearson
Sent: Saturday, October 10, 2020 11:58 AM
To: python-list@python.org
Subject: Python's carbon guilt

Python advocates might want to organize their thoughts on this subject
before their bosses spring the suggestion:

From
https://www.sciencemag.org/news/2020/10/we-re-part-problem-astronomers-confr
ont-their-role-and-vulnerability-climate-change :

. . . Astronomers should also abandon popular programming languages
such as Python in favor of efficient compiled languages. Languages
such as Fortran and C++, Zwart calculates, are 

[issue41991] Remove _PyObject_HasAttrId

2020-10-10 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


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



[issue42002] Clean up initialization of the sys module

2020-10-10 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


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

___
Python tracker 

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



[issue42002] Clean up initialization of the sys module

2020-10-10 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
nosy: +vstinner

___
Python tracker 

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



[issue42002] Clean up initialization of the sys module

2020-10-10 Thread Serhiy Storchaka


New submission from Serhiy Storchaka :

_PySys_InitCore() and _PySys_InitMain() in Python/sysmodule.c contains many 
invocations of macros for setting attributes of the sys module. The proposed PR 
changes these macros.

1. SET_SYS_FROM_STRING was renamed to just SET_SYS. It is much shorter and 
allow to write many invocations in one line. Also SET_SYS_FROM_STRING was not 
consistent with SET_SYS_FROM_WSTR.

2. Added new SET_SYS_FROM_STRING which sets attribute specified as C char 
string (similarly to SET_SYS_FROM_WSTR which sets attribute specified as C 
wchar_t string).

3. Added COPY_SYS_ATTR for making a copy of the attribute. It uses 
PyMapping_GetItemString() instead of PyDict_GetItemString() which silences all 
expressions.

4. Removed SET_SYS_FROM_STRING_BORROW. It no longer used, and it was used 
improperly.

5. SET_SYS_FROM_STRING_INT_RESULT replaced with SET_SYS.

6. All macros have been rewritten in term of SET_SYS that significantly 
simplifies the code.

All this makes the code clearer and makes errors handling more correct.

--
components: Interpreter Core
messages: 378415
nosy: serhiy.storchaka
priority: normal
severity: normal
status: open
title: Clean up initialization of the sys module
versions: Python 3.10

___
Python tracker 

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



[issue42001] Deprecate `typing.io` Wrapper Namespace

2020-10-10 Thread Sebastian Rittau


Sebastian Rittau  added the comment:

For reference, this came up in 
https://github.com/python/typeshed/issues/4639#issuecomment-706596656. 
`typing.io` has never been in typeshed and we decided not to include it. It 
looks as if it never gained any traction, especially since the types are 
available from `typing` directly.

--
nosy: +srittau

___
Python tracker 

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



Re: Python's carbon guilt

2020-10-10 Thread Marco Sulla
He should also calculate the carbon dioxide emitted by brains that
works in C++ only. I omit other sources.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue41986] Py_FileSystemDefaultEncodeErrors and Py_UTF8Mode are not available with limited API

2020-10-10 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


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



[issue41991] Remove _PyObject_HasAttrId

2020-10-10 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset 98c4433a81a4cd88c7438adbee1f2aa486188ca3 by Serhiy Storchaka in 
branch 'master':
bpo-41991: Remove _PyObject_HasAttrId (GH-22629)
https://github.com/python/cpython/commit/98c4433a81a4cd88c7438adbee1f2aa486188ca3


--

___
Python tracker 

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



[issue42001] Deprecate `typing.io` Wrapper Namespace

2020-10-10 Thread Kaushal Rohit


New submission from Kaushal Rohit :

The `typing` module has a wrapper namespace in it called `typing.io` which 
contain I/O stream types.

These types are now a part of the `typing` module itself.

While we are at it, should we also deprecate `typing.re`?

--
components: Library (Lib)
messages: 378412
nosy: rohitkg98
priority: normal
severity: normal
status: open
title: Deprecate `typing.io` Wrapper Namespace
type: behavior
versions: Python 3.10, Python 3.6, 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



Re: Python's carbon guilt

2020-10-10 Thread Chris Angelico
On Sun, Oct 11, 2020 at 3:01 AM Peter Pearson  wrote:
>
> Python advocates might want to organize their thoughts on
> this subject before their bosses spring the suggestion:
>
> From 
> https://www.sciencemag.org/news/2020/10/we-re-part-problem-astronomers-confront-their-role-and-vulnerability-climate-change
>  :
>
> . . . Astronomers should also abandon popular programming languages
> such as Python in favor of efficient compiled languages. Languages
> such as Fortran and C++, Zwart calculates, are more than 100 times
> more carbon efficient than Python because they require fewer
> operations.
>
>

Ahh, yes, a new way for people to worship the little tin god. How cute.

:)

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


[issue42000] Small cleanups to AST-related code

2020-10-10 Thread Batuhan Taskaya


Change by Batuhan Taskaya :


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



[issue42000] Small cleanups to AST-related code

2020-10-10 Thread miss-islington


New submission from miss-islington :


New changeset 02a1603f918b9862e164e4fd050c505b16bc9f57 by Batuhan Taskaya in 
branch 'master':
bpo-42000: Cleanup the AST related C-code (GH-22641)
https://github.com/python/cpython/commit/02a1603f918b9862e164e4fd050c505b16bc9f57


--
nosy: +miss-islington

___
Python tracker 

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



[issue42000] Small cleanups to AST-related code

2020-10-10 Thread Batuhan Taskaya


Change by Batuhan Taskaya :


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

___
Python tracker 

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



Re: Python's carbon guilt

2020-10-10 Thread Peter J. Holzer
On 2020-10-10 15:58:18 +, Peter Pearson wrote:
> Python advocates might want to organize their thoughts on
> this subject before their bosses spring the suggestion:
> 
> From 
> https://www.sciencemag.org/news/2020/10/we-re-part-problem-astronomers-confront-their-role-and-vulnerability-climate-change
>  :
> 
> . . . Astronomers should also abandon popular programming languages
> such as Python in favor of efficient compiled languages. Languages
> such as Fortran and C++, Zwart calculates, are more than 100 times
> more carbon efficient than Python because they require fewer
> operations.
> 

It would be interesting on which data he based these calculations. For
simple benchmarks of numerical code that's almost certainly true, but I
doubt anyone writes code intended to run on a supercomputer in plain
Python. Surely such programs would use numpy or other specialized
libraries which are already written in C or Fortran and may even use a
GPU if present? There is of course still some overhead, but it's much
smaller.

hp

-- 
   _  | Peter J. Holzer| Story must make more sense than reality.
|_|_) ||
| |   | h...@hjp.at |-- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |   challenge!"


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


Re: Truncation error

2020-10-10 Thread Meghna Karkera
Thanks, the problem was I solved a covariance matrix manually, but my
fellow mate using the covariance syntax. That's why there was difference in
Matlab and python results. But now when I use the covariance syntax in
python, matlab and python gives the same results.

On Sat, Oct 10, 2020, 21:37 Peter J. Holzer  wrote:

> On 2020-10-07 07:53:55 +0200, Marco Sulla wrote:
> > If you want to avoid float problems, you can use Decimal:
>
> Decimal doesn't avoid floating point problems, because it is a floating
> point format. For example:
>
> Python 3.8.5 (default, Jul 28 2020, 12:59:40)
> [GCC 9.3.0] on linux
> Type "help", "copyright", "credits" or "license" for more information.
> >>> from decimal import *
> >>> a = Decimal(3)
> >>> a
> Decimal('3')
> >>> b = Decimal(1E50)
> >>> b
> Decimal('17629769841091887003294964970946560')
> >>> c = Decimal(2)
> >>> a + b - c - b
> Decimal('8112996705035029053440')
> >>> b - b + a - c
> Decimal('1')
> >>> a + (b - b) - c
> Decimal('1')
> >>> a + b - b - c
> Decimal('8112996705035029053438')
> >>>
>
> Mathematically, all four expressions should have the result 1, but with
> floating point numbers they don't because intermediate results are
> rounded.
>
> For comparison, here are the results with float:
>
> >>> a + b - c - b
> 0.0
> >>> b - b + a - c
> 1.0
> >>> a + (b - b) - c
> 1.0
> >>> a + b - b - c
> -2.0
> >>>
>
> One could argue that these are at least closer to the truth, although I
> think that's just luck,
>
> Decimal does have two advantages over float:
>
> a) It's precision is configurable and even by default higher. So on
>average, the error is smaller (but still not zero).
>
> b) It uses decimal numbers like we learned in school. So it will make
>the same errors as we make when we use pencil and paper, which is
>less confusing to laypersons than the seemingly arbitrary errors from
>converting from decimal to binary and back.
>
>
> The disadvantages are of course higher memory consumption and lower
> speed. Also, I'm very confident that the engineers at Intel and AMD knew
> what they were doing when they designed the FP units of their
> processors. I'm slightly less confident about the authors of the Decimal
> module. And I'm much less confident that the average Python programmer
> can implement a matrix multiplication with Decimal which is as
> numerically stable as what Matlab or Pandas provide using IEEE-754
> arithmetic.
>
> hp
>
> PS: I recently read an interesting article on the Android calculator.
> That goes to extreme lengths to avoid unexpected rounding errors.
> It is also very slow, but still faster than a human can look, so it
> doesn't matter.
>
> --
>_  | Peter J. Holzer| Story must make more sense than reality.
> |_|_) ||
> | |   | h...@hjp.at |-- Charles Stross, "Creative writing
> __/   | http://www.hjp.at/ |   challenge!"
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Truncation error

2020-10-10 Thread Peter J. Holzer
On 2020-10-07 07:53:55 +0200, Marco Sulla wrote:
> If you want to avoid float problems, you can use Decimal:

Decimal doesn't avoid floating point problems, because it is a floating
point format. For example:

Python 3.8.5 (default, Jul 28 2020, 12:59:40)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from decimal import *
>>> a = Decimal(3)
>>> a
Decimal('3')
>>> b = Decimal(1E50)
>>> b
Decimal('17629769841091887003294964970946560')
>>> c = Decimal(2)
>>> a + b - c - b
Decimal('8112996705035029053440')
>>> b - b + a - c
Decimal('1')
>>> a + (b - b) - c
Decimal('1')
>>> a + b - b - c
Decimal('8112996705035029053438')
>>>

Mathematically, all four expressions should have the result 1, but with
floating point numbers they don't because intermediate results are
rounded.

For comparison, here are the results with float:

>>> a + b - c - b
0.0
>>> b - b + a - c
1.0
>>> a + (b - b) - c
1.0
>>> a + b - b - c
-2.0
>>>

One could argue that these are at least closer to the truth, although I
think that's just luck,

Decimal does have two advantages over float: 

a) It's precision is configurable and even by default higher. So on
   average, the error is smaller (but still not zero).

b) It uses decimal numbers like we learned in school. So it will make
   the same errors as we make when we use pencil and paper, which is
   less confusing to laypersons than the seemingly arbitrary errors from
   converting from decimal to binary and back.


The disadvantages are of course higher memory consumption and lower
speed. Also, I'm very confident that the engineers at Intel and AMD knew
what they were doing when they designed the FP units of their
processors. I'm slightly less confident about the authors of the Decimal
module. And I'm much less confident that the average Python programmer
can implement a matrix multiplication with Decimal which is as
numerically stable as what Matlab or Pandas provide using IEEE-754
arithmetic.

hp

PS: I recently read an interesting article on the Android calculator.
That goes to extreme lengths to avoid unexpected rounding errors.
It is also very slow, but still faster than a human can look, so it
doesn't matter.

-- 
   _  | Peter J. Holzer| Story must make more sense than reality.
|_|_) ||
| |   | h...@hjp.at |-- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |   challenge!"


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


Python's carbon guilt

2020-10-10 Thread Peter Pearson
Python advocates might want to organize their thoughts on
this subject before their bosses spring the suggestion:

>From 
>https://www.sciencemag.org/news/2020/10/we-re-part-problem-astronomers-confront-their-role-and-vulnerability-climate-change
> :

. . . Astronomers should also abandon popular programming languages
such as Python in favor of efficient compiled languages. Languages
such as Fortran and C++, Zwart calculates, are more than 100 times
more carbon efficient than Python because they require fewer
operations.


-- 
To email me, substitute nowhere->runbox, invalid->com.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue42000] Small cleanups to AST-related code

2020-10-10 Thread Batuhan Taskaya


Change by Batuhan Taskaya :


--
components: Interpreter Core
nosy: BTaskaya
priority: normal
severity: normal
status: open
title: Small cleanups to AST-related code
versions: Python 3.10

___
Python tracker 

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



[issue40213] contextlib.aclosing()

2020-10-10 Thread John Belmonte


Change by John Belmonte :


--
keywords: +patch
nosy: +jbelmonte
nosy_count: 9.0 -> 10.0
pull_requests: +21613
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/22640

___
Python tracker 

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



Re: Trying to Download PygameZero

2020-10-10 Thread Mats Wichmann
On 10/10/20 12:22 AM, Tom Hedge via Python-list wrote:
> I am in a 8 grade coding class at the moment and my teacher asked me to 
> download a script called pgzero. I can not seem to download pgzer or pygame 
> when i try it shoots me a error message:  ERROR: Command errored out with 
> exit status 1:     command: 'c:\program files\python39\python.exe' -c 'import 
> sys, setuptools, tokenize; sys.argv[0] = 
> '"'"'C:\\Users\\thedg\\AppData\\Local\\Temp\\pip-install-g9sb_mr0\\pygame\\setup.py'"'"';
>  
> __file__='"'"'C:\\Users\\thedg\\AppData\\Local\\Temp\\pip-install-g9sb_mr0\\pygame\\setup.py'"'"';f=getattr(tokenize,
>  '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', 
> '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' 
> egg_info --egg-base 
> 'C:\Users\thedg\AppData\Local\Temp\pip-pip-egg-info-rre7x6r3'         cwd: 
> C:\Users\thedg\AppData\Local\Temp\pip-install-g9sb_mr0\pygame\    Complete 
> output (17 lines):
> 
>     WARNING, No "Setup" File Exists, Running "buildconfig/config.py"    Using 
> WINDOWS configuration...
> 
>     Download prebuilts to "prebuilt_downloads" and copy to "./prebuilt-x64"? 
> [Y/n]Traceback (most recent call last):      File "", line 1, in 
>       File 
> "C:\Users\thedg\AppData\Local\Temp\pip-install-g9sb_mr0\pygame\setup.py", 
> line 194, in         buildconfig.config.main(AUTO_CONFIG)      File 
> "C:\Users\thedg\AppData\Local\Temp\pip-install-g9sb_mr0\pygame\buildconfig\config.py",
>  line 210, in main        deps = CFG.main(**kwds)      File 
> "C:\Users\thedg\AppData\Local\Temp\pip-install-g9sb_mr0\pygame\buildconfig\config_win.py",
>  line 576, in main        and download_win_prebuilt.ask(**download_kwargs):   
>    File 
> "C:\Users\thedg\AppData\Local\Temp\pip-install-g9sb_mr0\pygame\buildconfig\download_win_prebuilt.py",
>  line 302, in ask        reply = raw_input(    EOFError: EOF when reading a 
> line    ERROR: Command errored out 
> with exit status 1: python setup.py egg_info Check the logs for full command 
> output.
> 
> Please let me know ASAP how to fix this. Ive spent countless hours trying to 
> fix this, ive tried my changing my Path becasue thats what everyone told me. 
> I have also tried some other means to fix this and non have been sucsussful.
> Please Help me,
> 

The problem is the pygame developers have not released a pygame for
Python 3.9 and you're using Python 3.9.

You can check the availability here:

https://pypi.org/project/pygame/#files

Easiest answer is to stick with Python 3.8.6 for now.

Slightly longer:  all those daunting error messages are because pip
didn't find a wheel file matching your python version / operating system
/ architecture, and thus wants to instead download the source
distribution and build it (that's the pygame\\setup.py). And that fails,
as it normally does for Windows users.

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


[issue38792] IDLE calltips may not properly close on KeyboardInterrupt

2020-10-10 Thread Terry J. Reedy


Change by Terry J. Reedy :


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



[issue38077] IDLE leaking ARGV into globals() namespace

2020-10-10 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

Since I opened the followup issue, yes.  Thanks for noticing.

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



[issue41999] imaplib Time2Internaldate crashing with time.struct_time supplied from datetime.timetuple()

2020-10-10 Thread sajicek


New submission from sajicek :

Hello
first of all, I couldn't find any issue related to this, so sorry if it has 
been solved before.

There seems to be an issue with IMAPLIB in all versions I've checked, when 
using the Time2Internaldate function with time.struct_time created by 
datetime.timetuple() extracted from an EmailMessage object (using the 
email.utils.parsedate_to_datetime function), and even when created with 
datetime.now() the function crashes the app with
"TypeError: unsupported type for timedelta seconds component: NoneType"
on line 1530 in current master on GH. (delta = timedelta(seconds=gmtoff))

Crash happens because the "date_time.tm_gmtoff" from which the gmtoff variable 
is constructed, seems to default to None in all instances of time.struct_time 
object created by datetime.timetuple(), which still passes the try, except 
clausule on 1520, because it's not an AttributeError. The time.localtime() 
metioned in the docs asigns the correct value into tm_gmtoff, but the 
datetime.timetuple() does not.


Possible solutions I've found:
1) inside Time2Internaldate: surround the delta with try and except - in except 
make the delta = 0
2) inside Time2Internaldate: check the gmtoff for None and if yes, then change 
it to 0
3) change the default of tm_gmtoff in timetuple from None to 0 (or to a current 
timezone offset)

or just say in the docs, that time.struct_time created this way (using the 
datetime.timetuple()) is unsupported

PS: when writing this issue, I've started thinking this might be a datetime lib 
issue too

--
components: Library (Lib)
messages: 378409
nosy: sajicek
priority: normal
severity: normal
status: open
title: imaplib Time2Internaldate crashing with time.struct_time supplied from 
datetime.timetuple()
type: behavior
versions: Python 3.10, Python 3.5, Python 3.6, 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



[issue41986] Py_FileSystemDefaultEncodeErrors and Py_UTF8Mode are not available with limited API

2020-10-10 Thread miss-islington


miss-islington  added the comment:


New changeset ebc5a6b59ece48b490987bdaa2af842c29f5b2f8 by Miss Skeleton (bot) 
in branch '3.9':
bpo-41986: Add Py_FileSystemDefaultEncodeErrors and Py_UTF8Mode back to limited 
API (GH-22621)
https://github.com/python/cpython/commit/ebc5a6b59ece48b490987bdaa2af842c29f5b2f8


--

___
Python tracker 

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



[issue41986] Py_FileSystemDefaultEncodeErrors and Py_UTF8Mode are not available with limited API

2020-10-10 Thread miss-islington


miss-islington  added the comment:


New changeset ff6870f199511f09304e9d3ee7e7d8ed3902ffd1 by Miss Skeleton (bot) 
in branch '3.8':
bpo-41986: Add Py_FileSystemDefaultEncodeErrors and Py_UTF8Mode back to limited 
API (GH-22621)
https://github.com/python/cpython/commit/ff6870f199511f09304e9d3ee7e7d8ed3902ffd1


--

___
Python tracker 

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



[issue38792] IDLE calltips may not properly close on KeyboardInterrupt

2020-10-10 Thread Irit Katriel


Irit Katriel  added the comment:

This seems complete, can it be closed?

--
nosy: +iritkatriel

___
Python tracker 

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



[issue41986] Py_FileSystemDefaultEncodeErrors and Py_UTF8Mode are not available with limited API

2020-10-10 Thread miss-islington


Change by miss-islington :


--
nosy: +miss-islington
nosy_count: 2.0 -> 3.0
pull_requests: +21611
pull_request: https://github.com/python/cpython/pull/22637

___
Python tracker 

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



[issue41986] Py_FileSystemDefaultEncodeErrors and Py_UTF8Mode are not available with limited API

2020-10-10 Thread miss-islington


Change by miss-islington :


--
pull_requests: +21612
pull_request: https://github.com/python/cpython/pull/22638

___
Python tracker 

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



[issue41986] Py_FileSystemDefaultEncodeErrors and Py_UTF8Mode are not available with limited API

2020-10-10 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset 637a09b0d6e3ad4e34e0b5e0fc82f5afeae6f74b by Serhiy Storchaka in 
branch 'master':
bpo-41986: Add Py_FileSystemDefaultEncodeErrors and Py_UTF8Mode back to limited 
API (GH-22621)
https://github.com/python/cpython/commit/637a09b0d6e3ad4e34e0b5e0fc82f5afeae6f74b


--

___
Python tracker 

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



python

2020-10-10 Thread 수꿍이
import numpy as np
import matplotlib.pylab as plt
x = [1, -2 , 1]; h = [1 , 2 , -1 , 0 , 3 , 1];
nx = nx=[0,1,2]; nh =[0,1,2,3,4,5]
y = np.convolve(x ,h)
ny = np.arange(nx[0] + nh[0], nx[-1] + nx[-1]+1,nx[1]);
print(ny,y)
plt.subplot(1,1,1); plt.stem(y)
plt.subplot(1,1,1); plt.stem( ny, y)

ValueError: x and y must have same first dimension, but have shapes (5,) and 
(8,)
-whan can i do?? please comment please ㅠㅠ
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue41986] Py_FileSystemDefaultEncodeErrors and Py_UTF8Mode are not available with limited API

2020-10-10 Thread STINNER Victor


STINNER Victor  added the comment:

Python 3.7 defines it in fileobject.h as:

#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x0306
PyAPI_DATA(const char *) Py_FileSystemDefaultEncodeErrors;
#endif

#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x0307
PyAPI_DATA(int) Py_UTF8Mode;
#endif


Python 3.8 defines them the same way, but in Include/cpython/fileobject.h:

#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x0306
PyAPI_DATA(const char *) Py_FileSystemDefaultEncodeErrors;
#endif

#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x0307
PyAPI_DATA(int) Py_UTF8Mode;
#endif


I am likely the one who moved these definitions. It was a mistake to move them 
inside Include/cpython/, since "Py_LIMITED_API+0 >= 0x0307" became useless: 
cpython/fileobject.h is only included if Py_LIMITED_API is not defined.

In Include/cpython/, it seems like only 2 definitions are defined the wrong 
way, Py_FileSystemDefaultEncodeErrors and Py_UTF8Mode.

--

___
Python tracker 

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



[issue41997] Docs Standard Library index page has incorrect version in title

2020-10-10 Thread Patrick Reader


Trying to Download PygameZero

2020-10-10 Thread Tom Hedge via Python-list
I am in a 8 grade coding class at the moment and my teacher asked me to 
download a script called pgzero. I can not seem to download pgzer or pygame 
when i try it shoots me a error message:  ERROR: Command errored out with exit 
status 1:     command: 'c:\program files\python39\python.exe' -c 'import sys, 
setuptools, tokenize; sys.argv[0] = 
'"'"'C:\\Users\\thedg\\AppData\\Local\\Temp\\pip-install-g9sb_mr0\\pygame\\setup.py'"'"';
 
__file__='"'"'C:\\Users\\thedg\\AppData\\Local\\Temp\\pip-install-g9sb_mr0\\pygame\\setup.py'"'"';f=getattr(tokenize,
 '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', 
'"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info 
--egg-base 'C:\Users\thedg\AppData\Local\Temp\pip-pip-egg-info-rre7x6r3'        
 cwd: C:\Users\thedg\AppData\Local\Temp\pip-install-g9sb_mr0\pygame\    
Complete output (17 lines):

    WARNING, No "Setup" File Exists, Running "buildconfig/config.py"    Using 
WINDOWS configuration...

    Download prebuilts to "prebuilt_downloads" and copy to "./prebuilt-x64"? 
[Y/n]Traceback (most recent call last):      File "", line 1, in 
      File 
"C:\Users\thedg\AppData\Local\Temp\pip-install-g9sb_mr0\pygame\setup.py", line 
194, in         buildconfig.config.main(AUTO_CONFIG)      File 
"C:\Users\thedg\AppData\Local\Temp\pip-install-g9sb_mr0\pygame\buildconfig\config.py",
 line 210, in main        deps = CFG.main(**kwds)      File 
"C:\Users\thedg\AppData\Local\Temp\pip-install-g9sb_mr0\pygame\buildconfig\config_win.py",
 line 576, in main        and download_win_prebuilt.ask(**download_kwargs):     
 File 
"C:\Users\thedg\AppData\Local\Temp\pip-install-g9sb_mr0\pygame\buildconfig\download_win_prebuilt.py",
 line 302, in ask        reply = raw_input(    EOFError: EOF when reading a 
line    ERROR: Command errored out with 
exit status 1: python setup.py egg_info Check the logs for full command output.

Please let me know ASAP how to fix this. Ive spent countless hours trying to 
fix this, ive tried my changing my Path becasue thats what everyone told me. I 
have also tried some other means to fix this and non have been sucsussful.
Please Help me,

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


[issue41998] JSON Encoder Injection Using Indent

2020-10-10 Thread Dustin Moriarty


Dustin Moriarty  added the comment:

Sounds good. If this is the design intent, then we can close the issue.

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



[issue41986] Py_FileSystemDefaultEncodeErrors and Py_UTF8Mode are not available with limited API

2020-10-10 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

It solves the breaking of the C API. Py_FileSystemDefaultEncodeErrors and 
Py_UTF8Mode were not deprecated, they were just suddenly excluded from the 
limited API. And seems this change was not intentional, otherwise surrounding 
#ifdef/#endif (which currently do not have effect) would be not preserved.

--

___
Python tracker 

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



[issue32885] Tools/scripts/pathfix.py leaves bunch of ~ suffixed files around with no opt-out

2020-10-10 Thread Miro Hrončok

Change by Miro Hrončok :


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



[issue41998] JSON Encoder Injection Using Indent

2020-10-10 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

The code works as expected. I do not think there is a problem with the json 
module. If some application accepts user input and use it without validation to 
control the formatting of sensitive data, it is a vulnerability in this 
application, not in tools which it uses.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue38077] IDLE leaking ARGV into globals() namespace

2020-10-10 Thread Irit Katriel


Irit Katriel  added the comment:

This seems complete, can it be closed?

--
nosy: +iritkatriel

___
Python tracker 

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



[issue41986] Py_FileSystemDefaultEncodeErrors and Py_UTF8Mode are not available with limited API

2020-10-10 Thread STINNER Victor


STINNER Victor  added the comment:

I consider the global configuration variables as deprecated. I would prefer to 
slowly move towards PyConfig, since almost all Python functions now use 
PyInterpreterState.config.

The problem is that my idea to provide a stable ABI for PyConfig was rejected:
https://mail.python.org/archives/list/python-...@python.org/thread/C7Z2NA2DTM3DLOZCFQAK5A2WFYO3PHHX/#2JAJQA5OANFPXAJ3327RRPHPQLKVP2EW

Which problem are you trying to solve your PR 22621?

--

___
Python tracker 

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



[issue32793] smtplib: duplicated debug message

2020-10-10 Thread Irit Katriel


Irit Katriel  added the comment:

Does this need to be backported to 3.8/3.7?

--
nosy: +iritkatriel

___
Python tracker 

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



[issue37461] email.parser.Parser hang

2020-10-10 Thread Irit Katriel


Irit Katriel  added the comment:

This seems complete, can it be closed?

--
nosy: +iritkatriel

___
Python tracker 

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



[issue41998] JSON Encoder Injection Using Indent

2020-10-10 Thread Dustin Moriarty


New submission from Dustin Moriarty :

It is possible to inject data while encoding json when a string is passed to 
the indent argument. 

Here is an example of an injection attack.

```python
import json

data = {"a": "original data"}
indent = '"b": "injected data",\n'
json_string = json.dumps(data, indent=indent)
print(json_string)
```

Output:
```
{
"b": "injected data",
"a": "original data"
}
```

This is a vulnerability because it is common for CLI and web frameworks to use 
string as the default data type for arguments. The vulnerability is more likely 
to be realized for CLI applications where there is more likely to be a use case 
for exposing the indent parameter to external users in order to control the 
json output. While this could be prevented by the application using the json 
encoder, the potential attach vector is not obvious or clear to developers. I 
cannot see any use case for allowing strings to be passed as indent, so I 
propose that indent is cast to integer on __init__ of the encoder. I will 
submit a corresponding PR.

--
components: Library (Lib)
messages: 378395
nosy: DustinMoriarty
priority: normal
severity: normal
status: open
title: JSON Encoder Injection Using Indent
type: security
versions: Python 3.10, Python 3.5, Python 3.6, 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



[issue41997] Docs Standard Library index page has incorrect version in title

2020-10-10 Thread Patrick Reader


New submission from Patrick Reader :

The documentation page for the Standard Library, 
https://docs.python.org/3/library/, still says "Python 3.8.6 documentation" in 
the title. When visiting https://docs.python.org/3.9/library/ (emphasis on the 
3.9) explicitly, the correct title is shown. I suspect there are other pages 
like this, perhaps ones that have not been modified since Python 3.8.6? This is 
possibly in fact some sort of bug in Sphinx, but I don't think so.

--
assignee: docs@python
components: Documentation
messages: 378394
nosy: docs@python, pxeger
priority: normal
severity: normal
status: open
title: Docs Standard Library index page has incorrect version in title
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



[issue41980] Argparse documentation is slightly misleading

2020-10-10 Thread Yannick Gingras


Yannick Gingras  added the comment:

Raymond, I would love to submit the PR if we reach a consensus on what the new 
message should be.  I'm a bit out of touch with how things work these days.  Is 
Github the best place to submit the PR?

Paul, very good digging!  Reading the coding and running a few examples, I 
understand that the ``prog`` of the subparser is always the name of the main 
program with the name of the subcommand *unless* a usage string is supplied, in 
which case it overrides prog.  I suspect that the intent is to favour the 
programmer supplied usage string and that copying the usage string in the prog 
of the subparser is an implementation detail.   I think we can reword the 
documentation to describe the expected behavior with more emphasis on the 
common cases.

--

___
Python tracker 

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



[issue32885] Tools/scripts/pathfix.py leaves bunch of ~ suffixed files around with no opt-out

2020-10-10 Thread Irit Katriel


Irit Katriel  added the comment:

Please change status to closed as well. Thanks.

--

___
Python tracker 

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



[issue32885] Tools/scripts/pathfix.py leaves bunch of ~ suffixed files around with no opt-out

2020-10-10 Thread Miro Hrončok

Change by Miro Hrončok :


--
resolution:  -> fixed

___
Python tracker 

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



[issue41995] five possible Null Pointer Dereference bugs.

2020-10-10 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
nosy: +p-ganssle

___
Python tracker 

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



[issue40064] py38: document xml.etree.cElementTree will be removed in 3.9

2020-10-10 Thread Emmanuel Arias


Emmanuel Arias  added the comment:

Hi, 

This ticket should be closed or updated.

see disussion https://bugs.python.org/issue36543

--
nosy: +eamanu

___
Python tracker 

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



[issue41995] five possible Null Pointer Dereference bugs.

2020-10-10 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
nosy: +vstinner
versions: +Python 3.10 -Python 3.5, Python 3.6, Python 3.7

___
Python tracker 

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



[issue41996] Should `make install` still install to /usr/bin/python3?

2020-10-10 Thread Eric V. Smith


Eric V. Smith  added the comment:

There's a PEP for this: PEP 394. If you want to change this, I suggest 
discussing it on the python-dev mailing list. If that leads to changes in the 
PEP, this issue can be re-opened.

Personally I don't see this change happening until there are no systems left 
that install python2 as /usr/bin/python. Which is unfortunate, but such is 
life. Myself, I have a shell alias for python that points to python3. That 
solves 95% of my problems.

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



[issue27141] Fix collections.UserList shallow copy

2020-10-10 Thread Bar Harel


Change by Bar Harel :


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



[issue41992] Unable to install lxml using pip in Python 3.9

2020-10-10 Thread Eric V. Smith


Eric V. Smith  added the comment:

Closing as third party.

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



[issue41996] Should `make install` still install to /usr/bin/python3?

2020-10-10 Thread Emmanuel Arias


Emmanuel Arias  added the comment:

Hi,

There're many people that still use py2, or both.
Also python2 (python) is incompatible with python3, so we cannot
call python == python3.

(There was some discussion on Debian, just if you want take a look
https://lists.debian.org/debian-python/2020/07/msg00042.html)

--
nosy: +eamanu

___
Python tracker 

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



[issue41996] Should `make install` still install to /usr/bin/python3?

2020-10-10 Thread Patrick Reader


New submission from Patrick Reader :

Since Python 2 is now finally gone, should the Python executable not be 
installed to simply `/usr/bin/python` rather than `/usr/bin/python3` when 
running `make install`?

--
components: Installation
messages: 378387
nosy: pxeger
priority: normal
severity: normal
status: open
title: Should `make install` still install to /usr/bin/python3?
type: enhancement

___
Python tracker 

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



[issue41992] Unable to install lxml using pip in Python 3.9

2020-10-10 Thread Jürgen Gmach

Jürgen Gmach  added the comment:

There is no Python 3.9 compatible package on PyPI yet ( 
https://pypi.org/project/lxml/#files ).

I guess you have to wait a bit more until there will be a new release.

Also, this is the cpython issue tracker. When you have problems with a specific 
package, it is best to seek help at their issue tracker. For lxml this would be 
https://launchpad.net/lxml

Actually, there is already an issue on their tracker about support for Python 
3.9
https://bugs.launchpad.net/lxml/+bug/1892261

I suggest to close this issue here.

--
nosy: +jugmac00

___
Python tracker 

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



[issue41995] five possible Null Pointer Dereference bugs.

2020-10-10 Thread Roundup Robot


Change by Roundup Robot :


--
keywords: +patch
nosy: +python-dev
nosy_count: 1.0 -> 2.0
pull_requests: +21610
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/22635

___
Python tracker 

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



[issue41995] five possible Null Pointer Dereference bugs.

2020-10-10 Thread brightest star


New submission from brightest star :

Hello everyone,

I have found five Null Pointer Dereference bugs in recent master branch.
Although it's impact could be slightly, i think it is better to fix it.

Bug 1:
In the file ; ./Modules/_tracemalloc.c:
static int
tracemalloc_copy_trace(_Py_hashtable_t *traces,
   const void *key, const void *value,
   void *user_data)
{
_Py_hashtable_t *traces2 = (_Py_hashtable_t *)user_data;

trace_t *trace = (trace_t *)value;

1201:trace_t *trace2 = raw_malloc(sizeof(trace_t));
1202:if (traces2 == NULL) {  <-
return -1;
}
1205:   *trace2 = *trace;
...
return 0;
}
At line 1201, we malloc a varible 'trace2' and then we should check whether the 
varible 'trace2' is NULL. But it checks 'traces2'(not 'trace2') in line 1202. 
The varible 'trace2' still could be NULL.I think it is a spelling mistake.

Bug 2 and 3:
In the file :Modules/_zoneinfo.c

static int
load_data(PyZoneInfo_ZoneInfo *self, PyObject *file_obj)
{
...
908: self->trans_list_utc =
PyMem_Malloc(self->num_transitions * sizeof(int64_t));
910:trans_idx = PyMem_Malloc(self->num_transitions * sizeof(Py_ssize_t));
...
}
Line 908 alloc a memory to 'self->trans_list_utc' and line 910 alloc a memory 
to 'trans_idx'. But the paramters passed to PyMem_Malloc are not fixed,it means 
that we possible could control the size to malloc. If we pass a big size to 
PyMem_Malloc, it will return NULL.
So,we should add some checks for 'self->trans_list_utc' and 'trans_idx',such as 
if (self->trans_list_utc == NULL) {
goto error;
}

Bug 4 and 5:
In the file :Modules/_zoneinfo.c

The problem same to bug 3 and 4.
line 991:self->_ttinfos = PyMem_Malloc(self->num_ttinfos * sizeof(_ttinfo));
line 1005:   self->trans_ttinfos =
PyMem_Calloc(self->num_transitions, sizeof(_ttinfo *));

We should add some checks below these lines.

--
components: Extension Modules
messages: 378385
nosy: brightest3379
priority: normal
severity: normal
status: open
title: five possible Null Pointer Dereference bugs.
type: behavior
versions: Python 3.5, Python 3.6, 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



[issue41994] Refcount issues in import

2020-10-10 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


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

___
Python tracker 

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



[issue41994] Refcount issues in import

2020-10-10 Thread Serhiy Storchaka


New submission from Serhiy Storchaka :

There is a reference leak in import_add_module(). PyDict_GetItemWithError() 
returns a borrowed reference, but PyObject_GetItem() return a non-borrowed 
reference. If sys.modules is not a dict, there is a reference leak. 
import_add_module() and several other function which return a borrowed 
reference should be made returning a non-borrowed reference, because there are 
no guaranties that general mapping keeps reference to value.

It is still not guarantee correctness of PyImport_AddModuleObject().

--
components: Interpreter Core
messages: 378384
nosy: brett.cannon, eric.snow, ncoghlan, serhiy.storchaka
priority: normal
severity: normal
status: open
title: Refcount issues in import
type: resource usage
versions: Python 3.10, Python 3.9

___
Python tracker 

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



[issue41993] Possible issues when remove not completely initialized module from sys.module

2020-10-10 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


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

___
Python tracker 

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



[issue32885] Tools/scripts/pathfix.py leaves bunch of ~ suffixed files around with no opt-out

2020-10-10 Thread Irit Katriel


Irit Katriel  added the comment:

This seems complete, can it be closed?

--
nosy: +iritkatriel

___
Python tracker 

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



[issue41993] Possible issues when remove not completely initialized module from sys.module

2020-10-10 Thread Serhiy Storchaka


New submission from Serhiy Storchaka :

There are several issues in remove_module() in Python/import.c.

1. PyMapping_HasKey() is used to determine if the module was in sys.modules 
before removing it. But it can return 0 not only when the key is absent in the 
mapping, but also when some exceptions was raised during checking (including 
MemoryError, KeybordInterraption and RecursionError). The corresponding 
exception will be silenced and the module will be left in sys.modules.

2. If PyMapping_DelItem() fails, a RuntimeError is raised. It is chained with 
the exception raised in PyMapping_DelItem(), but the original exception, raised 
before calling remove_module() will be lost.

3. There is a possible race condition between PyMapping_HasKey() and 
PyMapping_DelItem().

--
components: Interpreter Core
messages: 378382
nosy: brett.cannon, eric.snow, ncoghlan, serhiy.storchaka
priority: normal
severity: normal
status: open
title: Possible issues when remove not completely initialized module from 
sys.module
type: behavior
versions: Python 3.10, 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



[issue26835] Add file-sealing ops to fcntl

2020-10-10 Thread Irit Katriel


Irit Katriel  added the comment:

This seems complete, can it be closed?

--
nosy: +iritkatriel

___
Python tracker 

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



[issue41756] Do not always use exceptions to return result from coroutine

2020-10-10 Thread Mark Shannon


Mark Shannon  added the comment:

Vladimir,
Thanks for adding PyIter_Send().

Don't forget to remove PyGen_Send() :)

--

___
Python tracker 

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



[issue36520] Email header folded incorrectly

2020-10-10 Thread Irit Katriel


Irit Katriel  added the comment:

This seems complete, can it be closed?

--
nosy: +iritkatriel

___
Python tracker 

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



[issue38605] [typing] PEP 563: Postponed evaluation of annotations: enable it by default in Python 3.10

2020-10-10 Thread Batuhan Taskaya


Change by Batuhan Taskaya :


--
pull_requests: +21607
pull_request: https://github.com/python/cpython/pull/22630

___
Python tracker 

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



[issue33972] AttributeError in email.message.iter_attachments()

2020-10-10 Thread Irit Katriel


Irit Katriel  added the comment:

This seems complete, can it be closed?

--
nosy: +iritkatriel

___
Python tracker 

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



[issue41992] Unable to install lxml using pip in Python 3.9

2020-10-10 Thread Aruna Gopalan


New submission from Aruna Gopalan :

Installed Python 3.9 from Python.org
Tried installing lxml package using the command
"pip install lxml"
It complains that it is unable to do so without libxml2 (which is not a python 
package). I do not have the same issue with 3.8.6.

--
components: Library (Lib)
messages: 378377
nosy: agopalan
priority: normal
severity: normal
status: open
title: Unable to install lxml using pip in Python 3.9
type: behavior
versions: Python 3.9

___
Python tracker 

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



[issue37840] bytearray_getitem() handles negative index incorrectly

2020-10-10 Thread Irit Katriel


Irit Katriel  added the comment:

This seems complete, can it be closed?

--
nosy: +iritkatriel

___
Python tracker 

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



[issue38110] Use fdwalk() within os.closerange() impl if available

2020-10-10 Thread Irit Katriel


Irit Katriel  added the comment:

This seems complete, can it be closed?

--
nosy: +iritkatriel

___
Python tracker 

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



[issue38605] [typing] PEP 563: Postponed evaluation of annotations: enable it by default in Python 3.10

2020-10-10 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

test_grammar and test_pydoc became failed on my machine until I removed all 
.pyc files. We need to bump the magic number for .pyc files.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue26067] test_shutil fails when gid name is missing

2020-10-10 Thread Irit Katriel


Irit Katriel  added the comment:

This seems complete, can it be closed?

--
nosy: +iritkatriel

___
Python tracker 

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



[issue41972] bytes.find consistently hangs in a particular scenario

2020-10-10 Thread Dennis Sweeney


Dennis Sweeney  added the comment:

I agree that skip could could do 1 better.

---

> I don't know whether it "should be" applied

I don't think I'm convinced: the second check fixes only the very specific case 
when s[len(p):].startswith(p).
Perturbations of reproducer.py are still very slow with the patch:

- pattern2 = b"B" * BIG
+ pattern2 = b"B" * (BIG + 10)

In fact, it's even slower than before due to the double-checking.

---

I'd be curious how something like Crochemore and Perrin's "two-way" algorithm 
would do (constant space, compares < 2n-m):

http://www-igm.univ-mlv.fr/~lecroq/string/node26.html#SECTION00260
https://en.wikipedia.org/wiki/Two-way_string-matching_algorithm

Apparently it's been used as glibc's memmem() since 2008. There, it 
additionally computes a table, but only for long needles where it really pays 
off:

https://code.woboq.org/userspace/glibc/string/str-two-way.h.html
https://code.woboq.org/userspace/glibc/string/memmem.c.html

Although there certainly seems to be a complexity rabbithole here that would be 
easy to over-do.
I might look more into this.

--

___
Python tracker 

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



Re: file to bits text and text containing bits to file

2020-10-10 Thread Harshit Sharma
On Saturday, October 10, 2020 at 1:43:09 AM UTC+5:30, dn wrote:
> On 09/10/2020 19:27, Harshit Sharma wrote: 
> > I want to read bits data of all file of any extention in 0s and 1s. And 
> > also want to do back means means construct file from bits text data how to 
> > do that tell with proof please. I am on a work of something like new sloot 
> > method but here I stuck.help everything else is done.
> Which (Python) tool(s) are you currently using? 
> What (Python) research have you done? 
> -- 
> Regards =dn
I have got solution to that using bitstring module.
I will tell to the world when program will get ready my blueprint of program is 
fully ready but I don't know coding very much so it will take time. it may take 
 3 or 4 months to code because I have to search on net everything how to do 
this or that in code. Or take help in social media. I also have to manage my 
studies side by side. Is there anyone who will code the program for me and make 
me owner for free or whatever I can make that but slowly.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue41991] Remove _PyObject_HasAttrId

2020-10-10 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

This function was kept after previous clean because all its usages was in the 
code which silences all exceptions in any case, so using _PyObject_HasAttrId 
did not do additional harm. But now it is used also in the new code in 
Objects/unionobject.c. It is safer to not only fix Objects/unionobject.c, but 
remove _PyObject_HasAttrId at all.

--
nosy: +pablogsal, vstinner

___
Python tracker 

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



[issue41991] Remove _PyObject_HasAttrId

2020-10-10 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


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

___
Python tracker 

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



[issue41991] Remove _PyObject_HasAttrId

2020-10-10 Thread Serhiy Storchaka


New submission from Serhiy Storchaka :

_PyObject_HasAttrId() can return -1, 0 or 1. It returns -1 when cannot create a 
string (most likely due to MemoryError or UnicodeDecodeError), but returns 0 
and silences all exceptions raised when look up the attribute (including 
MemoryError, KeybordInterruptError and RecursionError). Silencing arbitrary 
exceptions is bad, and the interface of the function is inconsistent, so it is 
better to remove it and replace all 5 of its occurrences in 3 files with 
_PyObject_LookupAttrId(). It is private API, so we can do it without breaking 
user code.

--
components: Interpreter Core
messages: 378370
nosy: serhiy.storchaka
priority: normal
severity: normal
status: open
title: Remove _PyObject_HasAttrId
type: behavior
versions: Python 3.10, 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



[issue41980] Argparse documentation is slightly misleading

2020-10-10 Thread paul j3


paul j3  added the comment:

For ArgumentParser, prog is defined as:

prog - The name of the program (default: sys.argv[0])

The comment in the `add_subparsers` method is:

   # prog defaults to the usage message of this parser, skipping
   # optional arguments and with no "usage:" prefix

if kwargs.get('prog') is None:
formatter = self._get_formatter()
positionals = self._get_positional_actions()
groups = self._mutually_exclusive_groups
formatter.add_usage(self.usage, positionals, groups, '')
kwargs['prog'] = formatter.format_help().strip()

and this keyword is saved as the action `self._prog_prefix.

Later in `add_parser` this is amended with:

 kwargs['prog'] = '%s %s' % (self._prog_prefix, name)

The intent is to provide the string required to run a particular subparser 
(sub-command), the `prog` of the main, positionals, and the subcommand. (It 
doesn't handle all 'required' arguments correctly.) 

The programmer has three places where they can customize this 'prog'.

So the default 'prog' as the 'add_subarsers' level is indeed just the main 
'prog' plus 'positionals'.  The default 'prog' display with the subcommand 
usage add the subcommand's name.

It's a complicated sequence, but I think the description for the 
'add_subparsers' 'prog' is enough.

--

___
Python tracker 

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



[issue41990] venv module clashes with pip --user ... improve coordination.

2020-10-10 Thread Bernd Wechner


New submission from Bernd Wechner :

When developing Python software it is highly discouraged to install python 
modules globally (risking adverse impacts upon the underlying OS where if has 
Python dependencies).

Project by project this typically done with venvs (and the venv module)

User by user it is typically done with the --user option.

In fact to make impacting system libraries less likely a pip.conf file can be 
written that contains:

[install]
user = true

I suspect this is an increasingly common practice which means pip installs are 
on a local user profile not into system dirs. 

Alas when in a venv now, pip bombs with a detected conflict:

ERROR: Can not perform a '--user' install. User site-packages are not visible 
in this virtualenv.

This was explored with pip here:

https://github.com/pypa/pip/issues/8977

It turns out that pip can be made to function by overriding this setting in the 
venv. That is depositing a pip.conf in the vend dir that contains:

[install]
user = true

and all is good once more. In the activated venv pip now works again. 

This is at its core a coordination issue then between the venv module and pip 
and the point to fix it seems most likely to be in the venv module which, 
knowing that this conflict can exist can as a safety precaution simply always, 
or optionally, write a pip.conf into newly created venvs that disables the user 
options. Given pip won't work in a venv if that option is enabled and we know 
that up front.

Why fix it in the venv module? Because discovering the cause of this conflict 
was time consuming and disorienting, poor UX by any definition and it should 
ideally not arise or if it must have an easily discovered fix. 

This is a request to prevent it arising altogether in newly created venvs.

--
components: Library (Lib)
messages: 378368
nosy: bernd.wechner
priority: normal
severity: normal
status: open
title: venv module clashes with pip --user ... improve coordination.
type: behavior
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



  1   2   >