Re: Why the list creates in two different ways? Does it cause by the mutability of its elements? Where the Python document explains it?

2021-06-15 Thread Chris Angelico
On Wed, Jun 16, 2021 at 12:44 PM Avi Gross via Python-list
 wrote:
>
> Greg,
>
> My point was not to ASK what python does as much as to ask why it matters to
> anyone which way it does it. Using less space at absolutely no real expense
> is generally a plus. Having a compiler work too hard, or even ask the code
> to work too hard, is often  a minus.
>
> If I initialized the tuples by calling f(5) and g(5) and so on, the compiler
> might not even be easily able to figure out that they all return the same
> thing. So should it make a run-time addition to the code so that after
> calculating the second, it should look around and if it matches the first,
> combine them? Again, I have seen languages where the implementation is to
> have exactly one copy of each unique string of characters. That can be
> useful but if it is done by creating some data structure and searching
> through it even when we have millions of unique strings, ...

"some data structure" being, in all probability, a hashtable, so that
searching through it is fast :)

Python lets you do this via sys.intern(), and CPython automatically
does it for any strings that look like identifiers.

Your analyses are both correct; but the compiler is generally allowed
to work hard, because its work can be dumped out into a file for next
time. Consider this code:

def make_adder(n):
def adder(values):
return [v + n for v in values]
return adder

This has four distinct code blocks (module, make_adder, adder, and the
list comp), all of which are represented as immutable code objects,
and can be saved into the .pyc file. If the compiler has to do extra
work, that's fine! And in fact, it does a LOT of constant folding and
other optimizations, based on what it can know about immediately.

Everything else (constructing function objects, constructing lists,
etc) is done at run time, although sometimes it's worth considering
"function definition time" as a separate phase of execution (since, in
many Python modules, that all happens at the very start of execution).
Optimizations done at that point are potentially more expensive, since
they might be done multiple times - imagine calling make_adder in a
loop. But since the code object can be used as-is, it's no trouble to
keep all the optimizations :)

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


Re: Behaviour of pop() for dictionaries

2021-06-15 Thread dn via Python-list
On 15/06/2021 21.37, BlindAnagram wrote:
> On 15/06/2021 00:11, dn wrote:
>> On 15/06/2021 09.18, BlindAnagram wrote:
>>> On 14/06/2021 20:43, Chris Angelico wrote:
 On Tue, Jun 15, 2021 at 5:41 AM BlindAnagram
>> ...
> I think the difference here is that I know I am going to have to look at
> the documentation for dequeue when I want to use it. For lists, sets and
> dictionaries, I don't expect to look at the documentation and pop()
> seemed a good bet for what I wanted to do.

"What I expect" (aka 'dim/dusty recollection' or 'gut feel') is a good
way to learn - match it with the Python REPL and a couple of experiments
to 'prove' your expectation/recollection. Thereafter there is a far
greater likelihood of "learning" - and remembering-correctly 'next time'...

The other worthy technique in this field is "deliberate learning". Thus,
spending some time studying the docs for the built-ins' functionality
(and experimentation) to obviate the need to look-up that level of
documentation.

Contrary to the learning-practices of 'our day', these days there is a
far lower reliance on memory, in favor of rapid-access to reference
data, eg the Python docs and REPL's help(), etc. Accordingly, the 'bits'
that we might think of as 'minimum knowledge' may be seen as somewhat
"arbitrary".
(actually it is called Curriculum Design, but given that there is no
single application-area for Python there is no single curriculum either)

No matter: we are completely correct, no question - and what would
'they' know anyway?


PS we were also subject to the idea that intelligence/ability was
largely genetic and thus only available in a fixed quantity - either one
is 'good' at something, or not (full stop). These days we know ourselves
(brains) to be more "plastic", and that with sufficient motivation and
effort we can learn 'new stuff', regardless of whether we were 'good at
it' yesterday!


>> I don't know if you are ComSc student or not, but there isn't even
>> consistency at the theoretical level. I first arrived at the concept of
>> "queuing" and "dequeuing" (NB the latter is not the same as the Python
>> Collections module "deque" library) whilst studying Queue Theory in
>> Operations Research. At about the same time, my ComSc studies took me
>> into "stacks".
> 
> My student days are well over (about 60 years over).

Someone with an even longer beard than mine! We could compare walking
sticks...

Oh wait, aren't we talking about Python.

I'm amazed at how stuff from 'history' is recyclable and becomes
applicable to whichever is described as 'today'. Even 'new' things in
computing!

There's always something new to adapt, if not learn...


...

> Yes, but we can still seek consistency where it is possible

Trouble is, there are different ways of looking at 'stuff', and thus
different dimensions of "consistent".

Thus, dict methods try to be consistent to the way a dict behaves.
Whereas being 'consistent' with other collections: sets, lists, strings,
etc; comes second. Oops if not OOPs!


>> Having entered the queue-of-life a long time ago, and shuffling ever
>> closer to 'the end of the line', this memory-challenged 'silver-surfer'
>> prefers to reserve pop() for straightforward stacks and lists, which
>> implies quite enough inconsistency, without trying to convolute my mind
>> to pop()-ing dicts, sets (or 'worse'!).

I still haven't recalled a single occasion when I've used set.pop() or
dict.pop(). Was that because I didn't recall their availability at the
right time, or does my mind simply not see that 'consistency' yours
recognises?
(not that it matters particularly)


>> That said, whether I actually use dict.pop() or not, these 'features'
>> which are consistent in name but not necessarily in arguments or
>> effects, contribute to Python's great flexibility and power! Thank
>> goodness for help() and the Python docs...
> 
> I don't like 'pop's at all since it meant that a valve had exploded on
> the Ferranti Pegasus that was my first encounter with computers.

That does pre-date the prehistoric computers I managed to play-with!

There's apparently one in LON's Science Museum. Don't know if it was
there when I last visited (c.15 years ago) - I do recall their Babbage
implementations and an analog computer (looked like some torture rack)
similar to one that my father used way, way, way-back. Similarly,
considering it/another similar exhibit and talking with our friends
about the 'joys' of using paper tape (and its talent for wrapping itself
around anything and everything, except where you wanted it) and those of
(assembler) programming delays in order to store data on rotating
mag-drums.

Those were the days!
(or maybe not)
-- 
Regards,
=dn
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue43945] [Enum] standardize format() behavior

2021-06-15 Thread Ethan Furman


Change by Ethan Furman :


--
pull_requests: +25337
pull_request: https://github.com/python/cpython/pull/26752

___
Python tracker 

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



[issue44431] Add command-line functionality to uuid module

2021-06-15 Thread Eric Phenix


Change by Eric Phenix :


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

___
Python tracker 

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



[issue44431] Add command-line functionality to uuid module

2021-06-15 Thread Eric Phenix


New submission from Eric Phenix :

Suggested functionality:

> python -m uuid
> b9aa5a06-e2cd-4c26-b26b-1590f01ea996

--
messages: 395906
nosy: ephenix
priority: normal
severity: normal
status: open
title: Add command-line functionality to uuid module
type: enhancement
versions: Python 3.11

___
Python tracker 

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



[issue44429] Tkinter Flow Geometry Manager

2021-06-15 Thread Zachary Ware


Zachary Ware  added the comment:

Hi Gary.

This sounds interesting.  However, Tkinter generally tries to be a pretty thin 
wrapper around Tcl/Tk; is there something like this already in Tk that could be 
used instead, or existing discussion to add such to Tk?  We certainly would not 
want to wind up in the situation of conflicting with Tcl/Tk if they later add 
something in the same vein :)

Also, the ship has long sailed for adding this to 3.9; 3.11 is the earliest 
this could happen at this point; I've adjusted the issue metadata accordingly.

--
nosy: +gpolo, serhiy.storchaka, zach.ware
type:  -> enhancement
versions: +Python 3.11 -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: Why the list creates in two different ways? Does it cause by the mutability of its elements? Where the Python document explains it?

2021-06-15 Thread Avi Gross via Python-list
Greg,

My point was not to ASK what python does as much as to ask why it matters to
anyone which way it does it. Using less space at absolutely no real expense
is generally a plus. Having a compiler work too hard, or even ask the code
to work too hard, is often  a minus.

If I initialized the tuples by calling f(5) and g(5) and so on, the compiler
might not even be easily able to figure out that they all return the same
thing. So should it make a run-time addition to the code so that after
calculating the second, it should look around and if it matches the first,
combine them? Again, I have seen languages where the implementation is to
have exactly one copy of each unique string of characters. That can be
useful but if it is done by creating some data structure and searching
through it even when we have millions of unique strings, ...

Heck, one excellent reason to use "constants" in your code (i.e. something
immutable) is to allow such optimizations. In some programs, garbage
collection is very active as things get copied and modified and parts
released. So it can be worth some effort to mark some items as
copy-on-change as they are often abandoned without changes. The common
paradigm I often see is you bring in a structure like a data.frame with
dozens of columns and then make a new variable containing a subset, perhaps
in a different order and perhaps then then add another column made by some
calculation like it being equal to the items in the column called "distance"
divided by the column entries called "time" to make a speed column. You
might graph the result and then make other such structures and graphs all
without doing anything but reading some columns.

If you then decided to just take a subset of the rows, or update even a
single item in one column, sure, you then take a copy but only of the
vectors that changed. 

Does python need something like this. I doubt it. Languages with such lazy
features can do very powerful things but then need even more operators to
force certain evaluations to be done in certain ways that leave other parts
unevaluated. R, for amusement, has an operator called !! (named bang bang)
for some such purposes and another operator !!! (obviously called The Big
Bang) for others. But it has radical differences in philosophy as compared
to something like python and each has a role and places it is easier to
write some kinds of programs than others.

The original question here was why there are different results. I think the
answer to my question is that it does not matter for most purposes. I can
think of one that MAYBE does.

If an application has some kind of ceiling, such as calculating how much
memory is left before deciding if a mail message is too big to send, and it
sometimes runs on machines with different amounts of such resources, you can
end up with a message being shunted along the way towards the destination
(we are talking ages ago) and suddenly hitting a machine where it is tossed
into junkmail as too big. So if your compiler/interpreter is one that allows
you to use less memory in circumstances like we are discussing, you may not
get what you think. Imagine a program that every time it creates a data
structure, adds some measure like sizeof() the new item and halts if the
size reached a gigabyte or perhaps charges extra because you used more of a
resource. The programmer choosing the list versus tuple alternative, would
get different behavior in such a hypothetical scenario. 


-Original Message-
From: Python-list  On
Behalf Of Greg Ewing
Sent: Tuesday, June 15, 2021 9:00 PM
To: python-list@python.org
Subject: Re: Why the list creates in two different ways? Does it cause by
the mutability of its elements? Where the Python document explains it?

On 16/06/21 12:15 pm, Avi Gross wrote:
> May I ask if there are any PRACTICAL differences if multiple immutable 
> tuples share the same address or not?

Only if some piece of code relies on the identity of tuples by using 'is' or
id() on them.

There's rarely any need to write code like that, though.
Normally you should compare tuples using '==', not 'is'.

Exceptions to this usually involve something like cacheing where identity is
only used for optimisation purposes, and the end result doesn't depend in
it.

> I mean if I use a tuple in a set or as the key in a dictionary and a 
> second one comes along, will it result in two entries one time and 
> only one the other time?

Dicts and sets compare keys by equality, not identity, so there is no
problem here.

 >>> a = 1
 >>> b = 2
 >>> t1 = (a, b)
 >>> t2 = (a, b)
 >>> t1 is t2
False
 >>> d = {}
 >>> d[t1] = 'spam'
 >>> t2 in d
True
 >>> s = set()
 >>> s.add(t1)
 >>> t2 in s
True

> Some languages I use often have a lazy evaluation where things are not 
> even copied when doing some things and only copied if absolutely 
> needed

 > So by that argument, you could have the copies of the list also be the  >
same at first and since they are mutable, they might 

[issue43945] [Enum] standardize format() behavior

2021-06-15 Thread Ethan Furman


Ethan Furman  added the comment:

Thinking about this some more I am partially reversing course.  The idea behind 
`IntEnum` and `IntFlag` is to be, as close as possible, drop-in replacements 
for existing integer-based constants.  If the format() of those two change then 
they become much less attractive.

So it won't.  Instead, any user-mixed enumerations will get the new behavior:

class Grades(int, Enum):
A = 5
F = 0

will emit a DeprecationWarning now, and in 3.12 `format(Grades.A)` will product 
'A' instead of '5'.

--

___
Python tracker 

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



[issue44342] enum with inherited type won't pickle

2021-06-15 Thread Ethan Furman


Ethan Furman  added the comment:


New changeset 41c2a4a727d3d559632598759433e0ec1bf594f5 by Ethan Furman in 
branch '3.10':
[3.10] bpo-44342: [Enum] improve test, add andrei kulakov to ACKS (GH-26726)
https://github.com/python/cpython/commit/41c2a4a727d3d559632598759433e0ec1bf594f5


--

___
Python tracker 

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



[issue44342] enum with inherited type won't pickle

2021-06-15 Thread Ethan Furman


Ethan Furman  added the comment:


New changeset 741b8ae1cfc507902eb57e20f003487af13e40c0 by Ethan Furman in 
branch 'main':
bpo-44342: [Enum] sync current docs to 3.10 (GH-26750)
https://github.com/python/cpython/commit/741b8ae1cfc507902eb57e20f003487af13e40c0


--

___
Python tracker 

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



Re: Why the list creates in two different ways? Does it cause by the mutability of its elements? Where the Python document explains it?

2021-06-15 Thread Greg Ewing

On 16/06/21 12:15 pm, Avi Gross wrote:

May I ask if there are any PRACTICAL differences if multiple immutable
tuples share the same address or not?


Only if some piece of code relies on the identity of tuples
by using 'is' or id() on them.

There's rarely any need to write code like that, though.
Normally you should compare tuples using '==', not 'is'.

Exceptions to this usually involve something like cacheing
where identity is only used for optimisation purposes,
and the end result doesn't depend in it.


I mean if I use a tuple in a set or as the key in a dictionary and a second
one comes along, will it result in two entries one time and only one the
other time?


Dicts and sets compare keys by equality, not identity, so
there is no problem here.

>>> a = 1
>>> b = 2
>>> t1 = (a, b)
>>> t2 = (a, b)
>>> t1 is t2
False
>>> d = {}
>>> d[t1] = 'spam'
>>> t2 in d
True
>>> s = set()
>>> s.add(t1)
>>> t2 in s
True


Some languages I use often have a lazy evaluation where things are not even
copied when doing some things and only copied if absolutely needed


> So by that argument, you could have the copies of the list also be the
> same at first and since they are mutable, they might diverge later

Python is not one of those languages, though, and it won't do things
like that. (At least not on its own -- you can certainly implement
such a lazily-copied data structure if you want.)


Now if you really still want true copies, what ways might fool a compiler?


I've shown one way above that works in CPython, but a smarter
implementation might notice that t1 and t2 will always be equal
and merge them.


NoDup = [(5, 2), (6-1, 6/3), (12%7, 1/1 + 1/1)]


CPython merges the last two of these, but not the first:

>>> NoDup = [(5, 2), (6-1, 6/3), (12%7, 1/1 + 1/1)]
>>> [id(x) for x in NoDup]
[4387029696, 4386827968, 4386827968]

The reason is that '/' does float division in Python 3. If you
use int division instead, they all get merged:

>>> NoDup = [(5, 2), (6-1, 6//3), (12%7, 1//1 + 1//1)]
>>> [id(x) for x in NoDup]
[4387030272, 4387030272, 4387030272]

So you need to be tricker than that to fool it!

The bottom line is, don't write code that depends on the identities
of immutable objects.

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


[issue44425] 'dirty' added to sys.version on Linux and Mac source builds depending on git version

2021-06-15 Thread Ned Deily


Change by Ned Deily :


--
nosy: +ned.deily

___
Python tracker 

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



Re: Why the list creates in two different ways? Does it cause by the mutability of its elements? Where the Python document explains it?

2021-06-15 Thread Chris Angelico
On Wed, Jun 16, 2021 at 10:17 AM Avi Gross via Python-list
 wrote:
>
> May I ask if there are any PRACTICAL differences if multiple immutable
> tuples share the same address or not?

No, there aren't. It's nothing more than an (optional) optimization.
This is true of every immutable type, including strings (both text and
byte), numbers (int, float, etc), and less obvious ones like code
objects. (Though not function objects. They're mutable.)

> I mean if I use a tuple in a set or as the key in a dictionary and a second
> one comes along, will it result in two entries one time and only one the
> other time?

Nope; dictionaries use the *value*, so even if you have two distinct
tuples with the same value, they will be considered equal.

> Some languages I use often have a lazy evaluation where things are not even
> copied when doing some things and only copied if absolutely needed as in
> when you make a change.  So you can create say a data.frame then make
> another from it with some columns added and removed and the storage used
> does not change much, but add or remove one or two, and suddenly entire
> large amounts get copied.
>
> So by that argument, you could have the copies of the list also be the same
> at first and since they are mutable, they might diverge later or not but
> tuples would never change so why not share if the compiler or interpreter
> was set to use less space when possible.

Hmm. Copy-on-write is permissible but wouldn't be worthwhile in most
cases. But I'm sure there are situations where it would be worth it.

> Now if you really still want true copies, what ways might fool a compiler?
>
> NoDup = [(5, 2), (6-1, 6/3), (12%7, 1/1 + 1/1)]
>

Note that these would all compare equal, but they are NOT
indistinguishable. The first one has a pair of integers, the other two
have an int and a float. But with the two that *are*
indistinguishable, CPython 3.10 folds them together and has two
references to the same tuple.

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


RE: Why the list creates in two different ways? Does it cause by the mutability of its elements? Where the Python document explains it?

2021-06-15 Thread Avi Gross via Python-list
May I ask if there are any PRACTICAL differences if multiple immutable
tuples share the same address or not?

I mean if I use a tuple in a set or as the key in a dictionary and a second
one comes along, will it result in two entries one time and only one the
other time?

Some languages I use often have a lazy evaluation where things are not even
copied when doing some things and only copied if absolutely needed as in
when you make a change.  So you can create say a data.frame then make
another from it with some columns added and removed and the storage used
does not change much, but add or remove one or two, and suddenly entire
large amounts get copied. 

So by that argument, you could have the copies of the list also be the same
at first and since they are mutable, they might diverge later or not but
tuples would never change so why not share if the compiler or interpreter
was set to use less space when possible.

Now if you really still want true copies, what ways might fool a compiler?

NoDup = [(5, 2), (6-1, 6/3), (12%7, 1/1 + 1/1)]


-Original Message-
From: Python-list  On
Behalf Of Greg Ewing
Sent: Tuesday, June 15, 2021 7:11 PM
To: python-list@python.org
Subject: Re: Why the list creates in two different ways? Does it cause by
the mutability of its elements? Where the Python document explains it?

On 15/06/21 7:32 pm, Jach Feng wrote:
> But usually the list creation is not in simple way:-) for example:
 a = [1,2]
 m = [a for i in range(3)]
 m
> [[1, 2], [1, 2], [1, 2]]
 id(m[0]) == id(m[1]) == id(m[2])
> True

The first line is only executed once, so you just get one list object [1,
2]. You then refer to that object three times when you build the outer list.

To get three different [1, 2] lists you would need something like this:

m = [[1,2] for i in range(3)]

This executes the [1, 2] expression 3 times. Because lists are mutable, you
can be sure that this will give you 3 distinct list objects.

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

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


[issue44342] enum with inherited type won't pickle

2021-06-15 Thread Ethan Furman


Change by Ethan Furman :


--
pull_requests: +25335
pull_request: https://github.com/python/cpython/pull/26750

___
Python tracker 

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



Re: Php vs Python gui (tkinter...) for small remote database app

2021-06-15 Thread Menno Holscher

Op 15-06-2021 om 19:14 schreef Grant Edwards:

On 2021-06-15, Menno Holscher  wrote:


There is no difference regarding security concerns.


I find that hard to believe given the long list of CVEs I've just had
to sort through for even fairly recent versions of PHP. I just can't
belive that Python has anywhere close to that many secruity issues.

An excellent example. The "concerns" here are "Is this platform safe?" 
and "Does the supplier/community react promptly to security problems?". 
In case of PHP indeed the safety of the platform is a worry, however, 
apparently if there is a problem, action is taken.


How does the Tkinter/TCL/TK software or the PyQt/Qt do in that respect? 
Just looking at the number of CVEs, is that enough? What if one of these 
stacks has few, but long outstanding security problems? Would that be 
better or worse than the situation for PHP?


As an aside, I do not know the amount of CVEs PHP nor Python is 
receiving. When I search the NIST CVE database for the word Python I get 
43 hits for the last 3 months. None of those are against the language or 
the CPython interpreter and only 1 against a Standard Library package or 
module (urllib3). A lot of the others are for web frameworks and 
extensions for those, as well as Tensorflow. So as you argue, it seems 
Python does really well as a secure development platform.

--
Met vriendelijke groet / Kind regards

Menno Hölscher


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


Re: Why the list creates in two different ways? Does it cause by the mutability of its elements? Where the Python document explains it?

2021-06-15 Thread Greg Ewing

On 15/06/21 7:32 pm, Jach Feng wrote:

But usually the list creation is not in simple way:-) for example:

a = [1,2]
m = [a for i in range(3)]
m

[[1, 2], [1, 2], [1, 2]]

id(m[0]) == id(m[1]) == id(m[2])

True


The first line is only executed once, so you just get one
list object [1, 2]. You then refer to that object three times
when you build the outer list.

To get three different [1, 2] lists you would need something
like this:

m = [[1,2] for i in range(3)]

This executes the [1, 2] expression 3 times. Because lists are
mutable, you can be sure that this will give you 3 distinct
list objects.

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


Re: optimization of rule-based model on discrete variables

2021-06-15 Thread Greg Ewing

On 15/06/21 10:07 pm, Elena wrote:

After the optimization, I will use f just to predict new Xi.


So you're going to use f backwards?

I don't see how that will work. Where are you going to
find a new yi to feed into the inverse of f?

I think I don't understand what role g plays in all of
this. If the ultimate goal is to find a better mixture,
you need some kind of figure of merit for an individual
mixture. But you don't have that, you only have this
thing g that somehow depends on all of your mixtures
at once.

I'm still not seeing the big picture.

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


[issue43693] Logically merge cell and locals array. They are already contiguous in memory

2021-06-15 Thread Guido van Rossum


Change by Guido van Rossum :


--
pull_requests: +25334
pull_request: https://github.com/python/cpython/pull/26749

___
Python tracker 

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



[issue44430] [sqlite3] refactor threading tests

2021-06-15 Thread Erlend E. Aasland


Change by Erlend E. Aasland :


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

___
Python tracker 

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



[issue44430] [sqlite3] refactor threading tests

2021-06-15 Thread Erlend E. Aasland


New submission from Erlend E. Aasland :

The threading tests (ThreadTests) in Lib/sqlite3/test/dbapi.py has a lot of 
code duplication, and none of the test methods use the 
test.support.threading_helper.reap_threads helper. Also, some branches are not 
covered by this test class. Suggesting the following:

1. Rewrite ThreadTests with a _run_test() helper method that does the heavy 
lifting
2. Add test.support.threading_helper.reap_threads to _run_test()
3. Use _run_test() in all threading tests
4. Add test case for sqlite3.Connection.set_trace_callback
5. Add test case for sqlite3.Connection.create_collation

--
assignee: erlendaasland
components: Tests
messages: 395901
nosy: erlendaasland, pablogsal
priority: low
severity: normal
status: open
title: [sqlite3] refactor threading tests
type: enhancement
versions: Python 3.11

___
Python tracker 

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



[issue44429] Tkinter Flow Geometry Manager

2021-06-15 Thread Gary Davenport


New submission from Gary Davenport :

Hi there.  I love Python and Tkinter.  I know that there are geometry managers 
pack, place, and grid.  I think there should be a flow type management 
available, like what is done in Java or html/css.  This is more important as 
responsive GUI design is needed with different screen sizes.

I initially addressed this by inheriting from the Frame in tkinter to a 
'FlowFrame' object and anything in that Frame would have flow geometry.

But this is a little awkward because the syntax is widget.pack() or 
widget.grid(), etc, so the method is linked to the widget.

So I altered the tkinter __init__.py  wrapper to add the .flow method so you 
can use widget.flow() syntax.

The flow geometry manager uses the grid managers methods.

The changes are straight-forward and I have 3 related projects on github:

1) https://github.com/garydavenport73/tkinterFlow - 
there are only 2 versions so history will demonstrate the relatively simple 
changes.

2) https://github.com/garydavenport73/FlowFrame -
a related project, FlowFrame object

3) https://github.com/garydavenport73/cpython
the formal changes to the most recent

https://github.com/python/cpython/blob/3.9/Lib/tkinter/__init__.py file.

--
components: Tkinter
hgrepos: 405
messages: 395900
nosy: Gary73
priority: normal
severity: normal
status: open
title: Tkinter Flow Geometry Manager
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



[issue43693] Logically merge cell and locals array. They are already contiguous in memory

2021-06-15 Thread Eric Snow


Eric Snow  added the comment:


New changeset ac38a9f2dfbba95f5d4338eb11a0221d38ef9328 by Eric Snow in branch 
'main':
bpo-43693: Eliminate unused "fast locals". (gh-26587)
https://github.com/python/cpython/commit/ac38a9f2dfbba95f5d4338eb11a0221d38ef9328


--

___
Python tracker 

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



[issue8772] sysconfig: _get_default_scheme can be made public?

2021-06-15 Thread Irit Katriel


Change by Irit Katriel :


--
versions: +Python 3.11 -Python 3.2

___
Python tracker 

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



[issue44342] enum with inherited type won't pickle

2021-06-15 Thread Ethan Furman


Change by Ethan Furman :


--
pull_requests: +25332
pull_request: https://github.com/python/cpython/pull/26747

___
Python tracker 

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



[issue44342] enum with inherited type won't pickle

2021-06-15 Thread Ethan Furman


Ethan Furman  added the comment:


New changeset 0f99324f61d5a2edd8729be5eed6f172c892af24 by Miss Islington (bot) 
in branch '3.10':
bpo-44342: [Enum] fix data type search (GH-26667)
https://github.com/python/cpython/commit/0f99324f61d5a2edd8729be5eed6f172c892af24


--

___
Python tracker 

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



[issue12458] Tracebacks should contain the first line of continuation lines

2021-06-15 Thread Edward Yang


Edward Yang  added the comment:

Supposing I like the old behavior (line number of the end of the statement), is 
there any way to recover that line number from the traceback after this change?

--
nosy: +ezyang

___
Python tracker 

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



[issue44428] _ProactorBasePipeTransport.abort() after _ProactorBasePipeTransport.close() does not cancel writes

2021-06-15 Thread Thomas Grainger


New submission from Thomas Grainger :

demo program:

import asyncio
import socket
import threading

async def amain():
family = socket.AddressFamily.AF_INET
sock = socket.socket(family, socket.SOCK_STREAM)
sock.settimeout(1)
sock.bind(('localhost', 0))
sock.listen()
host, port = sock.getsockname()[:2]

event = threading.Event()

def serve():
client, _ = sock.accept()
with client:
client.recv(1)
event.wait()

t = threading.Thread(target=serve, daemon=True)
t.start()

reader, writer = await asyncio.open_connection(host=host, port=port)
try:
while True:
writer.write(b"\x00" * 4096 * 682 * 2)
await asyncio.wait_for(writer.drain(), 2)
print("wrote")
except asyncio.TimeoutError:
print("timed out")

writer.close()
await asyncio.sleep(0)
writer.transport.abort()
print("waiting close")
await writer.wait_closed()  # never finishes on ProactorEventLoop
print("closed")
event.set()
t.join()

asyncio.run(amain())

it looks like it was fixed for the selector eventloop in 
https://github.com/python/cpython/commit/2546a177650264205e8a52b6836bc5b8c48bf085

but not for the proactor 
https://github.com/python/cpython/blame/8fe57aacc7bf9d9af84803b69dbb1d66597934c6/Lib/asyncio/proactor_events.py#L140

--
components: asyncio
messages: 395896
nosy: asvetlov, graingert, yselivanov
priority: normal
severity: normal
status: open
title: _ProactorBasePipeTransport.abort() after 
_ProactorBasePipeTransport.close() does not cancel writes
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



[issue44342] enum with inherited type won't pickle

2021-06-15 Thread miss-islington


Change by miss-islington :


--
pull_requests: +25331
pull_request: https://github.com/python/cpython/pull/26746

___
Python tracker 

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



[issue29153] Test test.test_asynchat.TestAsynchat / test.test_asynchat.TestAsynchat_WithPoll fail test_close_when_done

2021-06-15 Thread Irit Katriel


Irit Katriel  added the comment:

asynchat is deprecated since version 3.6 so there won't be any more development 
related to it.

--
nosy: +iritkatriel
resolution:  -> out of date
stage:  -> resolved
status: open -> closed

___
Python tracker 

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



[issue42064] Convert sqlite3 to multi-phase initialisation (PEP 489)

2021-06-15 Thread Erlend E. Aasland


Change by Erlend E. Aasland :


--
pull_requests: +25330
pull_request: https://github.com/python/cpython/pull/26745

___
Python tracker 

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



[issue43475] Worst-case behaviour of hash collision with float NaN

2021-06-15 Thread Mark Dickinson


Mark Dickinson  added the comment:


New changeset 8d0b2ca493e236fcad8709a622c1ac8ad29c372d by Mark Dickinson in 
branch '3.10':
[3.10] bpo-43475: Add what's new entry for NaN hash changes (GH-26725) 
(GH-26743)
https://github.com/python/cpython/commit/8d0b2ca493e236fcad8709a622c1ac8ad29c372d


--

___
Python tracker 

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



[issue44426] Docs fail to build with Sphinx 4 due to Invalid C declaration

2021-06-15 Thread Mark Dickinson


Change by Mark Dickinson :


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

___
Python tracker 

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



[issue43475] Worst-case behaviour of hash collision with float NaN

2021-06-15 Thread Mark Dickinson


Change by Mark Dickinson :


--
pull_requests: +25328
pull_request: https://github.com/python/cpython/pull/26743

___
Python tracker 

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



[issue4277] asynchat's handle_error inconsistency

2021-06-15 Thread Irit Katriel


Irit Katriel  added the comment:

asynchat has been deprecated for a long time, it's unlikely we will do anything 
with it now.

--
nosy: +iritkatriel
resolution:  -> out of date
stage: test needed -> 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



[issue43475] Worst-case behaviour of hash collision with float NaN

2021-06-15 Thread Mark Dickinson


Mark Dickinson  added the comment:


New changeset 1d10bf0bb9409a406c56b0de8870df998637fd0f by Mark Dickinson in 
branch 'main':
bpo-43475: Add what's new entry for NaN hash changes (GH-26725)
https://github.com/python/cpython/commit/1d10bf0bb9409a406c56b0de8870df998637fd0f


--

___
Python tracker 

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



[issue16663] Poor documentation for METH_KEYWORDS

2021-06-15 Thread Irit Katriel


Irit Katriel  added the comment:

This part of the documentation was reworded in issue28805, making this issue 
out of date.

--
nosy: +iritkatriel
resolution:  -> duplicate
stage:  -> resolved
status: open -> closed
superseder:  -> Add documentation for METH_FASTCALL and _PyObject_FastCall*()

___
Python tracker 

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



[issue44037] Broad performance regression from 3.10a7 to 3.10b2 with python.org macOS binaries

2021-06-15 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

The problem is still present in Python 3.10b2.

--
title: Broad performance regression from 3.10a7 to 3.10b1 with python.org macOS 
binaries -> Broad performance regression from 3.10a7 to 3.10b2 with python.org 
macOS binaries

___
Python tracker 

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



[issue44426] Docs fail to build with Sphinx 4 due to Invalid C declaration

2021-06-15 Thread Mark Dickinson


Mark Dickinson  added the comment:

As a test, gcc and clang both seem happy to treat this as valid C.  I think 
Sphinx is wrong to reject this.

mdickinson@mirzakhani Desktop % cat test.c
typedef struct {
double real;
double imag;
} Py_complex;

Py_complex _Py_c_neg(Py_complex complex);
mdickinson@mirzakhani Desktop % gcc -Wall -Wextra -std=c17 -c test.c
mdickinson@mirzakhani Desktop % clang -Wall -Wextra -std=c17 -c test.c
mdickinson@mirzakhani Desktop %

--

___
Python tracker 

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



[issue44426] Docs fail to build with Sphinx 4 due to Invalid C declaration

2021-06-15 Thread Mark Dickinson


Mark Dickinson  added the comment:

Hmm. It's probably not the best name, and we can certainly change it.

But I'm a bit confused by the error message: `complex` isn't a keyword in 
either C or C++, so I'm not sure why Sphinx thinks it is.

--
nosy: +mark.dickinson

___
Python tracker 

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



[issue44310] Document that lru_cache uses hard references

2021-06-15 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

See PR 26731 for a draft FAQ entry.  Let me know what you think.

--

___
Python tracker 

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



[issue27607] Importing the main module twice leads to two incompatible instances

2021-06-15 Thread Irit Katriel


Change by Irit Katriel :


--
versions: +Python 3.11 -Python 3.6

___
Python tracker 

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



Re: Help with Python circular error

2021-06-15 Thread Chris Angelico
On Wed, Jun 16, 2021 at 3:17 AM MRAB  wrote:
>
> On 2021-06-15 17:49, Chris Angelico wrote:
> > On Wed, Jun 16, 2021 at 2:45 AM Arak Rachael  
> > wrote:
> >>
> >> Hi to everyone,
> >>
> >> I am having a problem with this error, I created a package and uploaded it 
> >> to Test PyPi, but I can not get it to work, can someone help me please?
> >>
> >> https://test.pypi.org/manage/project/videotesting/releases/'
> >>
> >> The error:
> >>
> >> /home/user/anaconda3/envs/testing/bin/python 
> >> /home/user/devel/python.assignments/topgis-viz/topgis-test.py
> >> Traceback (most recent call last):
> >>   File "/home/user/devel/python.assignments/topgis-viz/topgis-test.py", 
> >> line 10, in 
> >> from videotesting import downsample_and_save_npz
> >>   File 
> >> "/home/user/anaconda3/envs/testing/lib/python3.8/site-packages/videotesting/__init__.py",
> >>  line 7, in 
> >> from videotesting import extract_video
> >> ImportError: cannot import name 'extract_video' from partially initialized 
> >> module 'videotesting' (most likely due to a circular import) 
> >> (/home/user/anaconda3/envs/testing/lib/python3.8/site-packages/videotesting/__init__.py)
> >>
> >
> > Hard to diagnose without the source code, but I'm thinking that your
> > __init__.py is probably trying to import from elsewhere in the
> > package? If so, try "from . import extract_video" instead.
> >
> Well, the traceback says that videotesting/__init__.py has:
>  from videotesting import extract_video
>
> so it is trying to import from itself during initialisation.

Yes, but what we can't tell is what the intention is. It could be
trying to import from its own package (in which case my suggestion
would be correct), or it could be trying to import from something
completely different (in which case the solution is to rename
something to avoid the conflict). Or it could be something else
entirely.

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


[issue29126] Fix comments about _PyThreadState_Current

2021-06-15 Thread Irit Katriel


Irit Katriel  added the comment:

These comments have been removed in the meantime, here:
https://github.com/python/cpython/commit/59d3dce69b0a4f6ee17578ae68037cc7ae90936f

--
nosy: +iritkatriel
resolution:  -> out of date
stage:  -> resolved
status: open -> closed

___
Python tracker 

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



Re: Php vs Python gui (tkinter...) for small remote database app

2021-06-15 Thread Grant Edwards
On 2021-06-15, Menno Holscher  wrote:

> There is no difference regarding security concerns.

I find that hard to believe given the long list of CVEs I've just had
to sort through for even fairly recent versions of PHP. I just can't
belive that Python has anywhere close to that many secruity issues.

-- 
Grant Edwards   grant.b.edwardsYow! I'd like some JUNK
  at   FOOD ... and then I want to
  gmail.combe ALONE --

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


Re: Help with Python circular error

2021-06-15 Thread MRAB

On 2021-06-15 17:49, Chris Angelico wrote:

On Wed, Jun 16, 2021 at 2:45 AM Arak Rachael  wrote:


Hi to everyone,

I am having a problem with this error, I created a package and uploaded it to 
Test PyPi, but I can not get it to work, can someone help me please?

https://test.pypi.org/manage/project/videotesting/releases/'

The error:

/home/user/anaconda3/envs/testing/bin/python 
/home/user/devel/python.assignments/topgis-viz/topgis-test.py
Traceback (most recent call last):
  File "/home/user/devel/python.assignments/topgis-viz/topgis-test.py", line 10, in 

from videotesting import downsample_and_save_npz
  File 
"/home/user/anaconda3/envs/testing/lib/python3.8/site-packages/videotesting/__init__.py",
 line 7, in 
from videotesting import extract_video
ImportError: cannot import name 'extract_video' from partially initialized 
module 'videotesting' (most likely due to a circular import) 
(/home/user/anaconda3/envs/testing/lib/python3.8/site-packages/videotesting/__init__.py)



Hard to diagnose without the source code, but I'm thinking that your
__init__.py is probably trying to import from elsewhere in the
package? If so, try "from . import extract_video" instead.


Well, the traceback says that videotesting/__init__.py has:
from videotesting import extract_video

so it is trying to import from itself during initialisation.
--
https://mail.python.org/mailman/listinfo/python-list


Re: Where did the message go?

2021-06-15 Thread dn via Python-list
On 16/06/2021 04.47, Chris Angelico wrote:
> On Wed, Jun 16, 2021 at 2:41 AM Grimble  wrote:
>> Thanks for reminding me of the  log files. I've worked out that the
>> message on machine H (for haydn, which shows my preferred music genre)
>> was bouncing because haydn.. was not a registered subdomain with
>> my ISP, whereas bach.. was registered. Sorted now.
>>
> 
> I like your naming convention :)

He's playing your tune!
-- 
Regards,
=dn
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue23035] python -c: Line causing exception not shown for exceptions other than SyntaxErrors

2021-06-15 Thread Irit Katriel


Change by Irit Katriel :


--
type:  -> enhancement
versions: +Python 3.11 -Python 3.5

___
Python tracker 

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



Re: Help with Python circular error

2021-06-15 Thread Chris Angelico
On Wed, Jun 16, 2021 at 2:45 AM Arak Rachael  wrote:
>
> Hi to everyone,
>
> I am having a problem with this error, I created a package and uploaded it to 
> Test PyPi, but I can not get it to work, can someone help me please?
>
> https://test.pypi.org/manage/project/videotesting/releases/'
>
> The error:
>
> /home/user/anaconda3/envs/testing/bin/python 
> /home/user/devel/python.assignments/topgis-viz/topgis-test.py
> Traceback (most recent call last):
>   File "/home/user/devel/python.assignments/topgis-viz/topgis-test.py", line 
> 10, in 
> from videotesting import downsample_and_save_npz
>   File 
> "/home/user/anaconda3/envs/testing/lib/python3.8/site-packages/videotesting/__init__.py",
>  line 7, in 
> from videotesting import extract_video
> ImportError: cannot import name 'extract_video' from partially initialized 
> module 'videotesting' (most likely due to a circular import) 
> (/home/user/anaconda3/envs/testing/lib/python3.8/site-packages/videotesting/__init__.py)
>

Hard to diagnose without the source code, but I'm thinking that your
__init__.py is probably trying to import from elsewhere in the
package? If so, try "from . import extract_video" instead.

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


Re: Why the list creates in two different ways? Does it cause by the mutability of its elements? Where the Python document explains it?

2021-06-15 Thread MRAB

On 2021-06-15 17:18, Dieter Maurer wrote:

Chris Angelico wrote at 2021-6-15 19:08 +1000:

On Tue, Jun 15, 2021 at 6:32 PM Dieter Maurer  wrote:


Chris Angelico wrote at 2021-6-15 05:35 +1000:
>On Tue, Jun 15, 2021 at 5:12 AM Jach Feng  wrote:
>>
>> >>> n = [(1,2) for i in range(3)]
>> >>> n
>> [(1, 2), (1, 2), (1, 2)]
>> >>> id(n[0]) == id(n[1])  == id(n[2])
>> True
>
>This is three tuples. Tuples are immutable and you get three
>references to the same thing.

In addition: object identity (as revealed by `id(...)`) is
an implementation detail. Do not rely on it!


Hmm, not always. In this case, object identity isn't guaranteed -
every literal could give you a unique object - but in other cases,
object identity is a language guarantee. For instance:


As far as I know, there are no guarantees are the language level.
There are some (partially documented) implementation details
for CPython (which is just one possible implementation).

There is a language guarantee that every object has an identity that's 
given by 'id' and that 'x is y' is equivalent to 'id(x) == id(y)'. In 
CPython it happens to be the address of the object, but that's an 
implementation detail.

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


[issue44422] threading.enumerate(): reentrant call during a GC collection hangs

2021-06-15 Thread STINNER Victor


STINNER Victor  added the comment:

Oh, I reopen the issue for PR 26741.

--
resolution: fixed -> 
status: closed -> open

___
Python tracker 

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



[issue44422] threading.enumerate(): reentrant call during a GC collection hangs

2021-06-15 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +25327
pull_request: https://github.com/python/cpython/pull/26741

___
Python tracker 

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



[issue44422] threading.enumerate(): reentrant call during a GC collection hangs

2021-06-15 Thread STINNER Victor


STINNER Victor  added the comment:

Ok, the deadlock on reentrant call to threading.enumerate() is now fixed in 
3.9, 3.10 and main (future 3.11) branches. I close the issue. Thanks for the 
reviews, as usual :-)

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



[issue44422] threading.enumerate(): reentrant call during a GC collection hangs

2021-06-15 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 8fe57aacc7bf9d9af84803b69dbb1d66597934c6 by Miss Islington (bot) 
in branch '3.9':
bpo-44422: Fix threading.enumerate() reentrant call (GH-26727) (GH-26738)
https://github.com/python/cpython/commit/8fe57aacc7bf9d9af84803b69dbb1d66597934c6


--

___
Python tracker 

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



Re: Where did the message go?

2021-06-15 Thread Chris Angelico
On Wed, Jun 16, 2021 at 2:41 AM Grimble  wrote:
> Thanks for reminding me of the  log files. I've worked out that the
> message on machine H (for haydn, which shows my preferred music genre)
> was bouncing because haydn.. was not a registered subdomain with
> my ISP, whereas bach.. was registered. Sorted now.
>

I like your naming convention :)

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


Re: Why the list creates in two different ways? Does it cause by the mutability of its elements? Where the Python document explains it?

2021-06-15 Thread Chris Angelico
On Wed, Jun 16, 2021 at 2:18 AM Dieter Maurer  wrote:
>
> Chris Angelico wrote at 2021-6-15 19:08 +1000:
> >On Tue, Jun 15, 2021 at 6:32 PM Dieter Maurer  wrote:
> >>
> >> Chris Angelico wrote at 2021-6-15 05:35 +1000:
> >> >On Tue, Jun 15, 2021 at 5:12 AM Jach Feng  wrote:
> >> >>
> >> >> >>> n = [(1,2) for i in range(3)]
> >> >> >>> n
> >> >> [(1, 2), (1, 2), (1, 2)]
> >> >> >>> id(n[0]) == id(n[1])  == id(n[2])
> >> >> True
> >> >
> >> >This is three tuples. Tuples are immutable and you get three
> >> >references to the same thing.
> >>
> >> In addition: object identity (as revealed by `id(...)`) is
> >> an implementation detail. Do not rely on it!
> >
> >Hmm, not always. In this case, object identity isn't guaranteed -
> >every literal could give you a unique object - but in other cases,
> >object identity is a language guarantee. For instance:
>
> As far as I know, there are no guarantees are the language level.
> There are some (partially documented) implementation details
> for CPython (which is just one possible implementation).

Yes there are - plenty of them :) The example I gave is a language
guarantee. Object identity is maintained in various places, and MUST
be; in fact, I've heard tell that PyPy actually has to do some
shenanigans to ensure that identities can be tracked across certain
types of optimizations (where the object mightn't actually exist
temporarily).

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


Help with Python circular error

2021-06-15 Thread Arak Rachael
Hi to everyone,

I am having a problem with this error, I created a package and uploaded it to 
Test PyPi, but I can not get it to work, can someone help me please?

https://test.pypi.org/manage/project/videotesting/releases/'

The error:

/home/user/anaconda3/envs/testing/bin/python 
/home/user/devel/python.assignments/topgis-viz/topgis-test.py
Traceback (most recent call last):
  File "/home/user/devel/python.assignments/topgis-viz/topgis-test.py", line 
10, in 
from videotesting import downsample_and_save_npz
  File 
"/home/user/anaconda3/envs/testing/lib/python3.8/site-packages/videotesting/__init__.py",
 line 7, in 
from videotesting import extract_video
ImportError: cannot import name 'extract_video' from partially initialized 
module 'videotesting' (most likely due to a circular import) 
(/home/user/anaconda3/envs/testing/lib/python3.8/site-packages/videotesting/__init__.py)


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


Re: Where did the message go?

2021-06-15 Thread Grimble

On 14/06/2021 20:58, dn wrote:

On 15/06/2021 01.00, Grimble wrote:

I have two machines running Mageia 8 and Python 2.8.9, They use the same
Python script to maintain a list of changed packages from dnf update and
dnf install. In addition the script sends a short email message to my
main email address. The problem is: the message from machine B arrives,
the message from machine H does not.
The part of the script that sends the message is:
    with open('email.txt') as fmail:
     msg = EmailMessage()
     msg.set_content(fmail.read())

     msg['Subject'] = 'System update'
     msg['From'] = sysname
     msg['To'] = 'gra...@.' (details removed to protect the
innocent)

     # Send the message via our own SMTP server.
     s = smtplib.SMTP('localhost')
     s.set_debuglevel(True)
     s.send_message(msg)
     s.quit()

The last lines of s.set_debuglevel are
reply: retcode (250); Msg: b'2.0.0 Ok: queued as B57B42C042F'
data: (250, b'2.0.0 Ok: queued as B57B42C042F')
send: 'quit\r\n'
reply: b'221 2.0.0 Bye\r\n'
reply: retcode (221); Msg: b'2.0.0 Bye'

The SMTP part of the system is working (hence this message).
The message from machine B correctly interprets "sysname" as
sysn...@sysname.. i.e a valid addr4ess.

Where do I look now, please?


That's machine B, but the issue is with machine H.
Have you compared the contents of the two machines' /var/log/maillog?

Thanks for reminding me of the  log files. I've worked out that the 
message on machine H (for haydn, which shows my preferred music genre) 
was bouncing because haydn.. was not a registered subdomain with 
my ISP, whereas bach.. was registered. Sorted now.


--
Grimble
Registered Linux User #450547
Machine 'Bach' running Plasma 5.20.4 on 5.10.43-desktop-1.mga8 kernel.
Mageia release 8 (Official) for x86_64
--
https://mail.python.org/mailman/listinfo/python-list


Re: optimization of rule-based model on discrete variables

2021-06-15 Thread Elena via Python-list
Il Tue, 15 Jun 2021 01:53:09 +, Martin Di Paola ha scritto:

> From what I'm understanding it is an "optimization problem" like the
> ones that you find in "linear programming".
> 
> But in your case the variables are not Real (they are Integers) and the
> function to minimize g() is not linear.
> 
> You could try/explore CVXPY (https://www.cvxpy.org/) which it's a solver
> for different kinds of "convex programming". I don't have experience
> with it however.
> 
> The other weapon in my arsenal would be Z3
> (https://theory.stanford.edu/~nikolaj/programmingz3.html) which it's a
> SMT/SAT solver with a built-in extension for optimization problems.
> 
> I've more experience with this so here is a "draft" of what you may be
> looking for.
> 
> 
> from z3 import Integers, Optimize, And, If
> 
> # create a Python array X with 3 Z3 Integer variables named x0, x1, x2 X
> = Integers('x0 x1 x2')
> Y = Integers('y0 y1')
> 
> # create the solver solver = Optimize()
> 
> # add some restrictions like lower and upper bounds for x in X:
>solver.add(And(0 <= x, x <= 2)) # each x is between 0 and 2
> for y in Y:
>solver.add(And(0 <= y, y <= 2))
> 
> def f(X):
># Conditional expression can be modeled too with "If"
># These are *not* evaluated like a normal Python "if" but # modeled
>as a whole. It'll be the solver which will "run it"
>return If(
>  And(x[0] == 0, x[1] == 0),  # the condition Y[0] == 0,  # Y[0] will
>  *must* be 0 *if* the condition holds Y[0] == 2   # Y[0] will *must*
>  be 2 *if* the condition doesn't hold )
> 
> solver.add(f(X))
> 
> # let's define the function to optimize g = Y[0]**2 solver.maximize(g)
> 
> # check if we have a solution solver.check() # this should return 'sat'
> 
> # get one of the many optimum solutions solver.model()
> 
> 
> I would recommend you to write a very tiny problem with 2 or 3 variables
> and a very simple f() and g() functions, make it work (manually and with
> Z3) and only then build a more complex program.
> 
> You may find useful (or not) these two posts that I wrote a month ago
> about Z3. These are not tutorials, just personal experience with a
> concrete example.
> 
> Combine Real, Integer and Bool variables:
> https://book-of-gehn.github.io/articles/2021/05/02/Planning-Space-
Missions.html
> 
> Lookup Tables (this may be useful for programming a f() "variable"
> function where the code of f() (the decision tree) is set by Z3 and not
> by you such f() leads to the optimum of g())
> https://book-of-gehn.github.io/articles/2021/05/26/Casting-Broadcasting-
LUT-and-Bitwise-Ops.html
> 
> 
> Happy hacking.
> Martin.
> 
> 

Interesting, I completely didn't know about this Z3 tool, I'll try to go  
into that.
Thank you for hint.
BTW the first two links I think are broken.

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


Re: optimization of rule-based model on discrete variables

2021-06-15 Thread Elena via Python-list
Il Tue, 15 Jun 2021 10:40:05 +1200, Greg Ewing ha scritto:

> On 15/06/21 12:51 am, Elena wrote:
> Hmmm, so the problem breaks down into two parts:
> (1) find a vector Y that minimises g (2) find a set of rules that will
> allow you to predict each component of Y from its corresponding X values
> 
> Is that right?

Correct, the split can be an interesting approach.

> 
> I ztill don't really understand. What are you going to do with this
> function f once you have it?
> 
> I would have thought the idea was that if someone gives you a new
> mixture X[n+1] you can use f to predict how well it will work.
> But that will just give you a y[n+1], and it's not clear what to do with
> that. Do you append it to Y and feed an n+1 component vector into g?
> 
> I think I still need more information about the underlying problem
> before I can help you much.

After the optimization, I will use f just to predict new Xi.

Thanks

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


Re: Php vs Python gui (tkinter...) for small remote database app

2021-06-15 Thread Menno Holscher

Op 14-06-2021 om 21:17 schreef Pascal B via Python-list:

Hi,
I would like to know if for a small app for instance that requires a connection 
to a remote server database if php is more suitable than Python mainly 
regarding security.
Php requires one port for http and one port for the connection to the database open. If using Python with a tkinter gui, I understand a small app can connect to a database so only one port to the database would need to be accessed/open listening to connection. So I would need to worry less 
about security if using Python over Php for something small, like a small 
python app that I give over to users.


Am I missing something in this assertion?


There is no difference regarding security concerns.

In the case of a PHP (or any web app for that matter) you indeed have to 
worry about the security of the connection to the browser. But, e.g. the 
access to the database is only in one place, on the server. If you use a 
Tkinter application, each user will have the access to the database at 
his/her own machine, causing other worries than connection security. The 
attack vector may be different, but the worries are no less or more in 
one of the solutions.


First investigate what you need to be afraid of/worried about, do not 
make a decision on a simple criterion like the number of connections.


--
Met vriendelijke groet / Kind regards

Menno Hölscher


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


Re: Behaviour of pop() for dictionaries

2021-06-15 Thread BlindAnagram

On 15/06/2021 00:11, dn wrote:

On 15/06/2021 09.18, BlindAnagram wrote:

On 14/06/2021 20:43, Chris Angelico wrote:

On Tue, Jun 15, 2021 at 5:41 AM BlindAnagram

...


No it isn't hard to use popitem() but it evidently proved hard for me to
remember that it was there.


If that's a problem, you're going to love using deques with their
'popping from the left' and 'popping from the right' concepts!


I think the difference here is that I know I am going to have to look at 
the documentation for dequeue when I want to use it. For lists, sets and 
dictionaries, I don't expect to look at the documentation and pop() 
seemed a good bet for what I wanted to do.



I don't know if you are ComSc student or not, but there isn't even
consistency at the theoretical level. I first arrived at the concept of
"queuing" and "dequeuing" (NB the latter is not the same as the Python
Collections module "deque" library) whilst studying Queue Theory in
Operations Research. At about the same time, my ComSc studies took me
into "stacks".


My student days are well over (about 60 years over).


Queues are known as FIFO constructs - "first-in, first-out".
Stacks are somewhat the opposite: LIFO - "last-in, first-out".

The "pop" operation was defined as taking the "next" item from the queue
or the "last" item from a stack (the opposite of "push"). However,
between queue and stack, the term "next" refers to opposite ends of the
(implementing in Python) list!

In fact, coming from a Burroughs mainframe, which ran on "stack
architecture" (cf IBM's multiplicity of "ALU registers"), it came as
something of a surprise when programming languages started allowing me
to "pop" elements that weren't at the LIFO-end of the 'list', eg
list.pop( 3 ) where len( list ) > 4!


Next consider how the terms "next" and "element" factor into the
thinking. If we consider a (Python) list there is an implied sequence of
elements based upon their relative position. Notice also that the basic
implementation of list.pop() is LIFO! Whereas, the definition of a set
involves no concept of sequence or order - only of membership (and that
the elements are "hashable"). Accordingly, a pop() operation returns an
"arbitrary value", cf 'next please'.

Similarly, a dict's keys are referred-to as hashable, with the idea of
"random access" to an element via its key (cf the "sequential access" of
a list). Thus, we can ask to pop() a dict, but only if we provide a key
- in which case, pop( key ) is the same as dict[ key ] except that the
key-value pair is also removed from the dict!

Recall though, it is possible to use list.pop() without any argument.
So, consistency has been thrown-out-the-window there as well.

Also, with LIFO in-mind, Python v3.7 brought a concept of 'sequence'
(population order) to dicts, and thus we now have this "guarantee" in
popitem() - and thus a memory-confusion for those of us who learned the
original "arbitrary" definition - confusion both of dict behavior and of
dict.popitem() specifically!

Worse confusion awaits (and referring to a conversation 'here' last
week) Python's pop() exhibits elements of both an "expression" and of a
"statement", ie it not only returns a value, but it affects
(?"side-effects") the underlying collection. Thus, no pop() for strings,
tuples, etc, because they are immutable collections!

The action of pop() is clearly inconsistent across types of collection.
It's effect is data-structure dependent because the purposes of those
structures are inherently different. "Consistency" would aid memory, but
"polymorphism" can only deliver functionality according to the
characteristics of the specific data-type!


Yes, but we can still seek consistency where it is possible


Having entered the queue-of-life a long time ago, and shuffling ever
closer to 'the end of the line', this memory-challenged 'silver-surfer'
prefers to reserve pop() for straightforward stacks and lists, which
implies quite enough inconsistency, without trying to convolute my mind
to pop()-ing dicts, sets (or 'worse'!).

That said, whether I actually use dict.pop() or not, these 'features'
which are consistent in name but not necessarily in arguments or
effects, contribute to Python's great flexibility and power! Thank
goodness for help() and the Python docs...


I don't like 'pop's at all since it meant that a valve had exploded on 
the Ferranti Pegasus that was my first encounter with computers.


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


Re: Behaviour of pop() for dictionaries

2021-06-15 Thread BlindAnagram

On 15/06/2021 01:36, Terry Reedy wrote:

On 6/14/2021 5:18 PM, BlindAnagram wrote:

I believe that consistency in how methods common to different types 
work is useful since it adds to the coherence of the language as a 
whole and avoids the need to remember special cases.


Each collection class *is* a special case, and pop has to be adjusted to 
each.  However, you seem to have missed an essential commonality.


Lists and dicts are both subscripted classes.  So the basic API is 
col.pop(sub), which removes and returns the sub item, whereas col[sub] 
leaves and returns.


Lists have a special index, -1, the most commonly used, so that is the 
default.  In fact, when I proposed list.pop(), I only proposed that, as 
I wanted pop to be the inverse of append, so a list could be used as a 
stack.


Bad list subscripts are an error (unless one is slicing), whereas where 
dicts allow a default (when subscripted with the get method).  Hence the 
optional default only for dicts.


At one time, dicts, like sets, were unordered collections (of functional 
item pairs). dict.pop(), with no arg, could have been used to return a 
random 2-ple, but Guido is generally against having return types depend 
on arguments. So a new popxxx name was added.  Note that deques have a 
popleft in addition to pop (right).


Thanks for the interesting history.

Having found that dict.pop() caused an error, I did wonder whether it 
should have returned a (key, value) pair but quickly came to the 
conclusion that this would be awful because it would be inconsistent 
with the normal value returned by pop(x). Sadly this did not result in 
any recollection that there was a popitem() :-(


   Brian

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


Re: Is there a way to get the following result in Python?

2021-06-15 Thread Jach Feng
Peter Otten 在 2021年6月15日 星期二下午2:48:07 [UTC+8] 的信中寫道:
> On 12/06/2021 04:02, Jach Feng wrote: 
> 
>  def foo(): 
> > ... # do something 
> > ... 
>  a = [] 
>  for i in range(3): 
> > ... a.append(foo()) 
> > ... 
>  a 
> > []
> The most natural way to achieve something similar is to replace append() 
> with extend(): 
> 
> >>> def foo(): return ()
> >>> a = [] 
> >>> for i in range(3):
> a.extend(foo()) 
> 
> 
> >>> a 
> []
Yes, return a list and using extend() to collect value is exactly what I need!
Thank you, Christian and Peter.

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


Re: Why the list creates in two different ways? Does it cause by the mutability of its elements? Where the Python document explains it?

2021-06-15 Thread Jach Feng
Greg Ewing 在 2021年6月15日 星期二下午3:01:46 [UTC+8] 的信中寫道:
> On 15/06/21 3:18 pm, Jach Feng wrote: 
> > From a user's point, I don't really care how Python creates thoseinstances, 
> > > either using an already exist one or create a new one, as
> > long as each element (and its sub-element) are independent from each 
> > other so a modification of one will not influence the other. The real 
> > problem is there are different methods can be used to build it and some 
> > will fail in this purpose. The * operator is one of them, but anyone 
> > else? I really like to know:-)
> This really has nothing to do with how the tuples are created. 
> It all depends on what you choose to put in them. 
> 
> When you use square brackets to build a list, you can be sure that 
> it will create a new list object each time. 
> 
> Also, if you create two tuples, by any means, containing distinct 
> elements, you can be sure that you will get two distinct tuple 
> objects. 
> 
> So, if you do this: 
> 
> a = [1, 2] 
> b = [1, 2] 
> c = [1, 2] 
> d = [1, 2] 
> 
> s = (a, b) 
> t = (c, d) 
> 
> then you are guaranteed to get four different list objects and 
> two diffferent tuple objects. 
> 
> Does that help to ease your fears? 
> 
> -- 
> Greg
But usually the list creation is not in simple way:-) for example:
>>> a = [1,2]
>>> m = [a for i in range(3)]
>>> m
[[1, 2], [1, 2], [1, 2]]
>>> id(m[0]) == id(m[1]) == id(m[2])
True

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


Re: Why the list creates in two different ways? Does it cause by the mutability of its elements? Where the Python document explains it?

2021-06-15 Thread Jach Feng
Chris Angelico 在 2021年6月15日 星期二上午5:23:12 [UTC+8] 的信中寫道:
> On Tue, Jun 15, 2021 at 7:11 AM Rob Cliffe via Python-list 
>  wrote: 
> > 
> > This puzzled me, so I played around with it a bit (Python 3.8.3): 
> > 
> > n = [] 
> > for i in range(3): 
> > n.append((1,7,-3,None,"x")) 
> > for i in range(3): 
> > n.append((1,7,-3,None,"x")) 
> > print([id(x) for x in n]) 
> > 
> > a = 4 
> > n = [] 
> > for i in range(3): 
> > n.append((1,7,-3,a,None,"x")) 
> > for i in range(3): 
> > n.append((1,7,-3,a,None,"x")) 
> > print([id(x) for x in n]) 
> > 
> > Output: 
> > 
> > [27164832, 27164832, 27164832, 27164832, 27164832, 27164832] 
> > [30065208, 30065496, 30237192, 30239976, 30240024, 30343928] 
> > 
> > Evidently the compiler is clever enough to pick out a constant tuple and 
> > create (or cause to get created) a single instance of it which is used 
> > when required. Indeed disassembling the code shows that LOAD_CONST is 
> > used to get the tuple. But it obviously can't do that when the tuple 
> > contains a variable.
> Correct. In theory, Python could intern the tuples (as can be done 
> with strings), noticing that it's constructing one that is identical 
> to one it already has, but the effort of doing that is hard to 
> justify. Simpler to just build a brand new tuple every time. 
> 
> ChrisA
From a user's point, I don't really care how Python creates those instances, 
either using an already exist one or create a new one, as long as each element 
(and its sub-element) are independent from each other so a modification of one 
will not influence the other. The real problem is there are different methods 
can be used to build it and some will fail in this purpose. The * operator is 
one of them, but anyone else? I really like to know:-)

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


Re: Is there a way to get the following result in Python?

2021-06-15 Thread Christian Gollwitzer

Am 12.06.21 um 04:02 schrieb Jach Feng:

def foo():

... # do something
...

a = []
for i in range(3):

... a.append(foo())
...

a

[]




How about having "foo" return a list of things? Then you can append that 
list and return an empty list if you want nothing added:


In [1]: def foo():
   ...: return [1,2,3]
   ...:

In [2]: def bar():
   ...: return []
   ...:

In [3]: a=[]

In [4]: a += foo()

In [5]: a
Out[5]: [1, 2, 3]

In [6]: a += bar()

In [7]: a
Out[7]: [1, 2, 3]


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


Re: Why the list creates in two different ways? Does it cause by the mutability of its elements? Where the Python document explains it?

2021-06-15 Thread Dieter Maurer
Chris Angelico wrote at 2021-6-15 19:08 +1000:
>On Tue, Jun 15, 2021 at 6:32 PM Dieter Maurer  wrote:
>>
>> Chris Angelico wrote at 2021-6-15 05:35 +1000:
>> >On Tue, Jun 15, 2021 at 5:12 AM Jach Feng  wrote:
>> >>
>> >> >>> n = [(1,2) for i in range(3)]
>> >> >>> n
>> >> [(1, 2), (1, 2), (1, 2)]
>> >> >>> id(n[0]) == id(n[1])  == id(n[2])
>> >> True
>> >
>> >This is three tuples. Tuples are immutable and you get three
>> >references to the same thing.
>>
>> In addition: object identity (as revealed by `id(...)`) is
>> an implementation detail. Do not rely on it!
>
>Hmm, not always. In this case, object identity isn't guaranteed -
>every literal could give you a unique object - but in other cases,
>object identity is a language guarantee. For instance:

As far as I know, there are no guarantees are the language level.
There are some (partially documented) implementation details
for CPython (which is just one possible implementation).
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Why the list creates in two different ways? Does it cause by the mutability of its elements? Where the Python document explains it?

2021-06-15 Thread Greg Ewing

On 15/06/21 3:18 pm, Jach Feng wrote:

From a user's point, I don't really care how Python creates thoseinstances, > 
either using an already exist one or create a new one, as
long as each element (and its sub-element) are independent from each
other so a modification of one will not influence the other. The real
problem is there are different methods can be used to build it and some
will fail in this purpose. The * operator is one of them, but anyone
else? I really like to know:-)


This really has nothing to do with how the tuples are created.
It all depends on what you choose to put in them.

When you use square brackets to build a list, you can be sure that
it will create a new list object each time.

Also, if you create two tuples, by any means, containing distinct
elements, you can be sure that you will get two distinct tuple
objects.

So, if you do this:

a = [1, 2]
b = [1, 2]
c = [1, 2]
d = [1, 2]

s = (a, b)
t = (c, d)

then you are guaranteed to get four different list objects and
two diffferent tuple objects.

Does that help to ease your fears?

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


Re: Php vs Python gui (tkinter...) for small remote database app

2021-06-15 Thread Tomasz Rola
On Tue, Jun 15, 2021 at 08:39:51AM +1200, dn via Python-list wrote:
> On 15/06/2021 07.17, Pascal B via Python-list wrote:
> > Hi,
> > I would like to know if for a small app for instance that requires a 
> > connection to a remote server database if php is more suitable than Python 
> > mainly regarding security.
> > Php requires one port for http and one port for the connection to the 
> > database open. If using Python with a tkinter gui, I understand a small app 
> > can connect to a database so only one port to the database would need to be 
> > accessed/open listening to connection. So I would need to worry less about 
> > security if using Python over Php for something small, like a small python 
> > app that I give over to users.
> > 
> > Am I missing something in this assertion?
> 
> Yes - or maybe I'm missing the point of your question?
> 
> There are two connections to consider: the database and the GUI.
> 
> 
> Database:
> 
[...]
> 
> 
> GUI:
> 
[...]
> The (Internet-connected) world runs on TLS. If you wish to
> secure/encrypt communications between application and server, this is
> accepted by most. If you wish to 'secure' by reducing inter-connections,
> then using tkinter and its tight-linkage to Python removes the need for
> the (http) web-server.

I would rather go with https-based "app", but not necessarily in PHP,
if security is to be considered (albeit I am not sure if Python
framework would do better).

Nowadays, there should be a firewall and server sitting behind it
(this is simple description, let us not put load balancing, many
servers etc into the mix, or if firewall really helps). So, in case of
http(s), there should be more tutorials and hints about doing this
well. Browser would do the gui side, http server will talk to the
database and to the world, but database itself is secured (hopefully)
from outside access. I suspect it is easier to secure web server than
db from various kind of 'kacks'. If you go with well rounded Python
framework, you can count on its authors carefully thinking about
various threats to apps written in it. Sorry, I cannot give any hints
- see, I rather deteste browser based apps, so this advice goes
against my own liking but one should be objective when giving
advices...

If you are truly new to this all, I suggest CGI, especially if you
want to do some proof of concept prototype, quickly. CGI is quite easy
to understand and as long as you are working out communications
between your code and DB, I think it simplifies the job a lot. Later
on, choose your framework and do the gui.

If you go with tkinter, then you will have to do the job already done
by authors of web server and web framework, you will have to rethink
various problems they gave their thoughts to, but in much shorter time
and on your own.

-- 
Regards,
Tomasz Rola

--
** A C programmer asked whether computer had Buddha's nature.  **
** As the answer, master did "rm -rif" on the programmer's home**
** directory. And then the C programmer became enlightened...  **
** **
** Tomasz Rola  mailto:tomasz_r...@bigfoot.com **
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue38401] Make dataclass attribute docstrings accessible

2021-06-15 Thread 4-launchpad-kalvdans-no-ip-org


Change by 4-launchpad-kalvdans-no-ip-org :


--
nosy: +4-launchpad-kalvdans-no-ip-org

___
Python tracker 

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



[issue43795] Implement PEP 652 -- Maintaining the Stable ABI

2021-06-15 Thread Petr Viktorin


Change by Petr Viktorin :


--
pull_requests: +25326
pull_request: https://github.com/python/cpython/pull/26740

___
Python tracker 

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



[issue44407] A "Coroutines and Tasks" code example needs "asyncio.run(main())"

2021-06-15 Thread Andrei Kulakov


Andrei Kulakov  added the comment:

I think it's clear that the modification of previous example is limited to 
`main()` because `say_after()` is also omitted. This is very common in Python 
code examples, - it seems to me this change is not needed.

--
nosy: +andrei.avk

___
Python tracker 

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



[issue44422] threading.enumerate(): reentrant call during a GC collection hangs

2021-06-15 Thread miss-islington


miss-islington  added the comment:


New changeset c3b776f83b4c765da6d7b8854e844e07bd33c375 by Miss Islington (bot) 
in branch '3.10':
bpo-44422: Fix threading.enumerate() reentrant call (GH-26727)
https://github.com/python/cpython/commit/c3b776f83b4c765da6d7b8854e844e07bd33c375


--

___
Python tracker 

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



[issue44392] Py_GenericAlias is not documented

2021-06-15 Thread Ken Jin


Change by Ken Jin :


--
pull_requests: +25325
pull_request: https://github.com/python/cpython/pull/26739

___
Python tracker 

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



[issue44422] threading.enumerate(): reentrant call during a GC collection hangs

2021-06-15 Thread miss-islington


Change by miss-islington :


--
pull_requests: +25324
pull_request: https://github.com/python/cpython/pull/26738

___
Python tracker 

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



[issue44422] threading.enumerate(): reentrant call during a GC collection hangs

2021-06-15 Thread miss-islington


Change by miss-islington :


--
nosy: +miss-islington
nosy_count: 1.0 -> 2.0
pull_requests: +25323
pull_request: https://github.com/python/cpython/pull/26737

___
Python tracker 

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



[issue44422] threading.enumerate(): reentrant call during a GC collection hangs

2021-06-15 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 243fd01047ddce1a7eb0f99a49732d123e942c63 by Victor Stinner in 
branch 'main':
bpo-44422: Fix threading.enumerate() reentrant call (GH-26727)
https://github.com/python/cpython/commit/243fd01047ddce1a7eb0f99a49732d123e942c63


--

___
Python tracker 

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



[issue42972] [C API] Heap types (PyType_FromSpec) must fully implement the GC protocol

2021-06-15 Thread miss-islington


miss-islington  added the comment:


New changeset e30fe27dabbc6b48736c3c17d57f6fa542376e8f by Miss Islington (bot) 
in branch '3.10':
bpo-42972: _thread.RLock implements the GH protocol (GH-26734)
https://github.com/python/cpython/commit/e30fe27dabbc6b48736c3c17d57f6fa542376e8f


--

___
Python tracker 

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



[issue42972] [C API] Heap types (PyType_FromSpec) must fully implement the GC protocol

2021-06-15 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 1cd3d859a49b047dd08abb6f44f0539564d3525a by Victor Stinner in 
branch 'main':
bpo-42972: _thread.RLock implements the GH protocol (GH-26734)
https://github.com/python/cpython/commit/1cd3d859a49b047dd08abb6f44f0539564d3525a


--

___
Python tracker 

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



[issue42972] [C API] Heap types (PyType_FromSpec) must fully implement the GC protocol

2021-06-15 Thread miss-islington


Change by miss-islington :


--
pull_requests: +25322
pull_request: https://github.com/python/cpython/pull/26735

___
Python tracker 

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



[issue30260] sock_dealloc() may call __repr__ when socket class is already collected by GC

2021-06-15 Thread asterite


Change by asterite :


--
stage:  -> resolved
status: pending -> closed

___
Python tracker 

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



[issue40240] Expose public spelling of _PyGC_FINALIZED and _PyGC_SET_FINALIZED?

2021-06-15 Thread STINNER Victor


STINNER Victor  added the comment:

Pablo: "That is out of contract and goes against the guarantees on the GC and 
can (will) cause the finalizer of the object to be executed more than once. I 
don't think is a good idea to expose an API that allows breaking the guarantees 
that we give: every object is finalized once."

I concur with Pablo. We must not expose an API to "unfinalize" an object.

Irit Katriel: "Can this be closed now? It seems that the query API was added 
and the set API was rejected."

Right. I close the issue as rejected.

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



[issue42064] Convert sqlite3 to multi-phase initialisation (PEP 489)

2021-06-15 Thread Petr Viktorin


Petr Viktorin  added the comment:


New changeset 10a5c806d4dec6c342dcc9888fbe4fa1fa9b7a1f by Erlend Egeberg 
Aasland in branch 'main':
bpo-42064: Move sqlite3 types to global state (GH-26537)
https://github.com/python/cpython/commit/10a5c806d4dec6c342dcc9888fbe4fa1fa9b7a1f


--
nosy: +petr.viktorin

___
Python tracker 

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



[issue44427] File extension for scripts on windows is unclear

2021-06-15 Thread Malte Kliemann


New submission from Malte Kliemann :

It is common practice to use no extension for python scripts on UNIX. In 
3.8.1.4., it is hinted that a script with a shebang line can be executed on 
windows only if the file extension of the script is associated with the python 
launcher.

I'm not sure where the right place is, but I suggest clearly stating that this 
is a critical requirement. As scripts on UNIX usually don't use file 
extensions, using these scripts without further modification is not possible 
cross-platform.

--
assignee: docs@python
components: Documentation
messages: 395875
nosy: docs@python, maltekliemann
priority: normal
severity: normal
status: open
title: File extension for scripts on windows is unclear
type: enhancement
versions: Python 3.9

___
Python tracker 

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



[issue44426] Docs fail to build with Sphinx 4 due to Invalid C declaration

2021-06-15 Thread Karolina Surma


New submission from Karolina Surma :

Hello all,
I want to build Python 3.10~b2 documentation using Sphinx 4.0.2 (released in 
May 2021) as RPM in Fedora with aim to ship it in Fedora 35.

The build fails with the following error:

Warning, treated as error:
/builddir/build/BUILD/Python-3.10.0b2/Doc/c-api/complex.rst:49:Error in 
declarator or parameters
Error in declarator or parameters
Invalid C declaration: Expected identifier, got keyword: complex [error at 39]
  Py_complex _Py_c_neg(Py_complex complex)
  ---^
make: *** [Makefile:51: build] Error 2


The Sphinx changelog mentions in Bug fixes in 
https://www.sphinx-doc.org/en/master/changes.html#id21 the likely cause:
C, properly reject function declarations when a keyword is used as parameter 
name.

--
assignee: docs@python
components: Documentation
messages: 395874
nosy: docs@python, ksurma
priority: normal
severity: normal
status: open
title: Docs fail to build with Sphinx 4 due to Invalid C declaration
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



[issue44351] distutils.sysconfig.parse_makefile() regression in Python 3.10

2021-06-15 Thread Petr Viktorin


Petr Viktorin  added the comment:


New changeset 2f2ea96c4429b81f491aa1cdc4219ef2fd6d37fb by Miss Islington (bot) 
in branch '3.10':
bpo-44351: Restore back parse_makefile in distutils.sysconfig (GH-26637) 
(GH-26673)
https://github.com/python/cpython/commit/2f2ea96c4429b81f491aa1cdc4219ef2fd6d37fb


--

___
Python tracker 

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



[issue32322] Heap type with Py_TPFLAGS_HAVE_GC leads to segfault due to not incrementing type object refcout in PyObject_GC_New

2021-06-15 Thread Irit Katriel


Irit Katriel  added the comment:

Thanks!

--
resolution:  -> out of date
stage:  -> resolved
status: open -> closed

___
Python tracker 

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



[issue32322] Heap type with Py_TPFLAGS_HAVE_GC leads to segfault due to not incrementing type object refcout in PyObject_GC_New

2021-06-15 Thread Rostislav Kondratenko


Rostislav Kondratenko  added the comment:

Hello, I don't have that code, as I worked around that issue at the time.
I checked with my project, using PyObject_GC_New works fine.
It seems that since then the issue has been fixed at some point since 2017.
Either that or I misinterpreted what was going on back then.
I think we can safely close this issue.

On Tue, 15 Jun 2021 at 14:18, Irit Katriel  wrote:

>
> Irit Katriel  added the comment:
>
> Do you still have the code that created the crash? It would help to
> understand what you are/were seeing.
>
> --
>
> ___
> Python tracker 
> 
> ___
>

--

___
Python tracker 

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



[issue42972] [C API] Heap types (PyType_FromSpec) must fully implement the GC protocol

2021-06-15 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +25321
pull_request: https://github.com/python/cpython/pull/26734

___
Python tracker 

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



[issue40240] Expose public spelling of _PyGC_FINALIZED and _PyGC_SET_FINALIZED?

2021-06-15 Thread Irit Katriel


Irit Katriel  added the comment:

Can this be closed now? It seems that the query API was added and the set API 
was rejected.

--
nosy: +iritkatriel

___
Python tracker 

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



[issue39217] GC of a ctypes object causes application crash

2021-06-15 Thread Irit Katriel


Irit Katriel  added the comment:

As Terry suggested, it would be better to establish whether this is a python 
bug by asking on python-list, where more people are likely to see your question.

A complete script reproducing the crash is *always* better than a verbal 
description that we may or may not understand correctly.

Please reopen this or create a new issue if you are still seeing this issue on 
a recent (3.9+) version and you can provide a complete script that reproduces 
it.

--
nosy: +iritkatriel
resolution:  -> rejected
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



[issue37224] [subinterpreters] test__xxsubinterpreters fails randomly

2021-06-15 Thread hai shi


Change by hai shi :


--
pull_requests: +25320
pull_request: https://github.com/python/cpython/pull/26733

___
Python tracker 

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



[issue32322] Heap type with Py_TPFLAGS_HAVE_GC leads to segfault due to not incrementing type object refcout in PyObject_GC_New

2021-06-15 Thread Irit Katriel


Irit Katriel  added the comment:

Do you still have the code that created the crash? It would help to understand 
what you are/were seeing.

--

___
Python tracker 

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



[issue32322] Heap type with Py_TPFLAGS_HAVE_GC leads to segfault due to not incrementing type object refcout in PyObject_GC_New

2021-06-15 Thread Irit Katriel


Irit Katriel  added the comment:

Are you sure? It seems to me that they both incref the type object in 
_PyObject_Init:
https://github.com/python/cpython/blob/689a84475e7b1da79d5ae82df67ab8897316f98c/Include/internal/pycore_object.h#L43

--
nosy: +iritkatriel

___
Python tracker 

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



[issue44425] 'dirty' added to sys.version on Linux and Mac source builds depending on git version

2021-06-15 Thread Mark Final


New submission from Mark Final :

Hi,

We build Python 3.7 from source in-house for Windows, Linux and macOSX.

It's been noticed that 'dirty' has been appended to sys.version in our builds, 
even though the source tree has not been modified from a git clone. This only 
happens for Linux and macOSX.

I traced this to the following commands (which are unchanged in main):

https://github.com/python/cpython/blob/main/configure#L2833
https://github.com/python/cpython/blob/main/configure.ac#L50

> GITTAG="git --git-dir \$(srcdir)/.git describe --all --always --dirty"

I further traced it to behaviours of different versions of git. In particular, 
when git is invoked outside of the working tree, and --git-dir is used alone, 
'dirty' is always appended.

It's been noticed in a number of places online, including 
https://www.reddit.com/r/git/comments/4edtlx/git_describe_in_makefile_always_dirty/

Additionally using --work-tree does avoid the 'dirty' flag for a clean source 
tree, for git v2.21.0+.

I believe that this was this fix 
https://github.com/git/git/commit/a1e19004e11dcbc0ceebd92c425ceb1770e52d0b

However, since we do have usage of older versions of git, we've had to go with 
a different solution, which was to use git -C, i.e.

GITTAG="git -C \$(srcdir) describe --all --always --dirty"

so that git's working directory is changed to $(srcdir).

The other git commands in the code linked to do not seem to have the same 
issue, but we haven't changed them.

I'm writing this up in case anyone else has seen the issue, and offer the 
solution we found if it is useful.

Many thanks,
Mark

--
components: Build
messages: 395866
nosy: mark.final
priority: normal
severity: normal
status: open
title: 'dirty' added to sys.version on Linux and Mac source builds depending on 
git version
type: enhancement
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



[issue44424] Decompress streaming bz2 file

2021-06-15 Thread Carlos Franzreb


New submission from Carlos Franzreb :

I am trying to lazily load items from a compressed file that resides in Zenodo. 
My goal is to iteratively yield the items without storing the file in my 
computer. My problem is that an EOFerror occurs right after the first non-empty 
line is read. How can I overcome this issue?

Here is my code:

import requests as req
import json
from bz2 import BZ2Decompressor


def lazy_load(file_url):
dec = BZ2Decompressor()
with req.get(file_url, stream=True) as res:
for chunk in res.iter_content(chunk_size=1024):
data = dec.decompress(chunk).decode('utf-8')
# do something with 'data'


if __name__ == "__main__":
creds = json.load(open('credentials.json'))
url = 'https://zenodo.org/api/records/'
id = '4617285'
filename = '10.Papers.nt.bz2'
res = req.get(f'{url}{id}', params={'access_token': 
creds['zenodo_token']})
for file in res.json()['files']:
if file['key'] == filename:
for item in lazy_load(file['links']['self']):
# do something with 'item'

The error I become is the following:

Traceback (most recent call last):
File ".\mag_loader.py", line 51, in 
  for item in lazy_load(file['links']['self']):
File ".\mag_loader.py", line 18, in lazy_load
  data = dec.decompress(chunk)
EOFError: End of stream already reache

To run the code you need a Zenodo access token, for which you need an account. 
Once you have logged in, you can create the token here: 
https://zenodo.org/account/settings/applications/tokens/new/

--

___
Python tracker 

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



[issue44424] Decompress streaming bz2 file

2021-06-15 Thread Carlos Franzreb


Change by Carlos Franzreb :


--
components: Library (Lib)
nosy: carlosfranzreb
priority: normal
severity: normal
status: open
title: Decompress streaming bz2 file
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



[issue30260] sock_dealloc() may call __repr__ when socket class is already collected by GC

2021-06-15 Thread Irit Katriel

Irit Katriel  added the comment:

Since this is fixed in 3.6 and it’s too late for 3.5, I think this issue can be 
closed.

--
nosy: +iritkatriel
resolution:  -> out of date
status: open -> pending

___
Python tracker 

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



Re: Why the list creates in two different ways? Does it cause by the mutability of its elements? Where the Python document explains it?

2021-06-15 Thread Chris Angelico
On Tue, Jun 15, 2021 at 6:32 PM Dieter Maurer  wrote:
>
> Chris Angelico wrote at 2021-6-15 05:35 +1000:
> >On Tue, Jun 15, 2021 at 5:12 AM Jach Feng  wrote:
> >>
> >> >>> n = [(1,2) for i in range(3)]
> >> >>> n
> >> [(1, 2), (1, 2), (1, 2)]
> >> >>> id(n[0]) == id(n[1])  == id(n[2])
> >> True
> >
> >This is three tuples. Tuples are immutable and you get three
> >references to the same thing.
>
> In addition: object identity (as revealed by `id(...)`) is
> an implementation detail. Do not rely on it!

Hmm, not always. In this case, object identity isn't guaranteed -
every literal could give you a unique object - but in other cases,
object identity is a language guarantee. For instance:

>>> l = (1, 2) # or [1, 2]
>>> [l for _ in range(10)]
[(1, 2), (1, 2), (1, 2), (1, 2), (1, 2), (1, 2), (1, 2), (1, 2), (1, 2), (1, 2)]
>>> [id(x) for x in _]
[140499111503808, 140499111503808, 140499111503808, 140499111503808,
140499111503808, 140499111503808, 140499111503808, 140499111503808,
140499111503808, 140499111503808]

In this example, it doesn't matter whether it's a list or a tuple (or
anything else) - the IDs are all guaranteed to be the same.

The only thing that's an implementation detail is whether immutable
objects are folded together. You'll find similar situations with
strings, numbers, etc, etc. For example, "name-like" strings are often
interned in CPython, but other strings aren't, so sometimes you might
find different behaviour if you have a space in the string than if you
don't.

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


  1   2   >