Fail 3.10.8 version installation on Windows 11 21H2
Hi All,
Do anyone face issue like in log below?
I got last installer (3.10.8) and try to install it 'for all users' with
downloading precompiled (pdb) files.
And installation fails saying permission error.
Installer says downloading error in the log.
I repeated it three times with same result
Just to test I got previous version (3.10.6) and it is installed without
any errors with same installer settings.
begin here part of installer log file
---
[183C:19E4][2022-10-12T12:01:23]e000: Error 0x80070005: Failed attempt
to download URL:
'https://www.python.org/ftp/python/3.10.8/amd64/core_pdb.msi' to:
'C:\Users\Kirill\AppData\Local\Temp\{93FCA30B-7B82-4BF0-B911-5223F0E6A053}\core_AllUsers_pdb'
[183C:19E4][2022-10-12T12:01:23]w343: Prompt for source of package:
core_AllUsers_pdb, payload: core_AllUsers_pdb, path:
C:\Users\Kirill\Downloads\core_pdb.msi
[183C:19E4][2022-10-12T12:01:26]i338: Acquiring package:
core_AllUsers_pdb, payload: core_AllUsers_pdb, download from:
https://www.python.org/ftp/python/3.10.8/amd64/core_pdb.msi
[183C:19E4][2022-10-12T12:01:26]e000: Error 0x80070005: Failed attempt
to download URL:
'https://www.python.org/ftp/python/3.10.8/amd64/core_pdb.msi' to:
'C:\Users\Kirill\AppData\Local\Temp\{93FCA30B-7B82-4BF0-B911-5223F0E6A053}\core_AllUsers_pdb'
[183C:19E4][2022-10-12T12:01:26]w343: Prompt for source of package:
core_AllUsers_pdb, payload: core_AllUsers_pdb, path:
C:\Users\Kirill\Downloads\core_pdb.msi
[183C:19E4][2022-10-12T12:01:29]i338: Acquiring package:
core_AllUsers_pdb, payload: core_AllUsers_pdb, download from:
https://www.python.org/ftp/python/3.10.8/amd64/core_pdb.msi
[183C:19E4][2022-10-12T12:01:29]e000: Error 0x80070005: Failed attempt
to download URL:
'https://www.python.org/ftp/python/3.10.8/amd64/core_pdb.msi' to:
'C:\Users\Kirill\AppData\Local\Temp\{93FCA30B-7B82-4BF0-B911-5223F0E6A053}\core_AllUsers_pdb'
[183C:19E4][2022-10-12T12:01:29]w343: Prompt for source of package:
core_AllUsers_pdb, payload: core_AllUsers_pdb, path:
C:\Users\Kirill\Downloads\core_pdb.msi
[183C:19E4][2022-10-12T12:01:32]i338: Acquiring package:
core_AllUsers_pdb, payload: core_AllUsers_pdb, download from:
https://www.python.org/ftp/python/3.10.8/amd64/core_pdb.msi
[183C:19E4][2022-10-12T12:01:32]e000: Error 0x80070005: Failed attempt
to download URL:
'https://www.python.org/ftp/python/3.10.8/amd64/core_pdb.msi' to:
'C:\Users\Kirill\AppData\Local\Temp\{93FCA30B-7B82-4BF0-B911-5223F0E6A053}\core_AllUsers_pdb'
[183C:19E4][2022-10-12T12:01:32]e000: Error 0x80070005: Failed to
acquire payload from:
'https://www.python.org/ftp/python/3.10.8/amd64/core_pdb.msi' to working
path:
'C:\Users\Kirill\AppData\Local\Temp\{93FCA30B-7B82-4BF0-B911-5223F0E6A053}\core_AllUsers_pdb'
[183C:19E4][2022-10-12T12:01:32]e313: Failed to acquire payload:
core_AllUsers_pdb to working path:
C:\Users\Kirill\AppData\Local\Temp\{93FCA30B-7B82-4BF0-B911-5223F0E6A053}\core_AllUsers_pdb,
error: 0x80070005.
[08CC:3570][2022-10-12T12:01:32]i351: Removing cached package:
core_AllUsers, from path: C:\ProgramData\Package
Cache\{6463E43B-54B1-4407-818D-DD90D11CDD06}v3.10.8150.0\
[183C:313C][2022-10-12T12:01:32]e000: Error 0x80070005: Cache thread
exited unexpectedly.
end here part of installer log file
---
--
https://mail.python.org/mailman/listinfo/python-list
Re: is mypy failing here
Hi Robin, mypy --strict gives you detail info. On Thu, Nov 24, 2022 at 10:05 +, Robin Becker wrote: > I haven't used dataclasses or typing very much, but while playing about I > found this didn't give me an expected error > > (.py312) robin@minikat:~/devel/reportlab > $ cat tmp/examples/tdc.py && python tmp/examples/tdc.py && mypy > tmp/examples/tdc.py > ## > from dataclasses import dataclass > > @dataclass > class DC: > a: str > b: str > > def main(): > dc = DC(DC, "B") > print(dc) > > if __name__ == "__main__": > main() > ## > DC(a=, b='B') > Success: no issues found in 1 source file > (.py312) robin@minikat:~/devel/reportlab > > DC.a is supposed to be a str and I expected mypy to indicate a type error > > should typing work for this case? > -- > Robin Becker > -- > https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: How to detect an undefined method?
Hi
You can get all methods of your object and check the method you want to
call is there or not.
|methods = [method for method in dir() if
callable(getattr(, method))] if 'method_you_need' in
methods: . // BR |
27.03.2022 12:24, Manfred Lotz пишет:
Let's say I have a Python app and have used an undefined method somewhere. Let
us further assume I have not detected it thru my tests.
Is there a way to detect it before deploying the app? pylint doesn't notice it.
Minimal example:
#!/usr/bin/env python3
import logging
from logging import Logger
from random import randrange
def main():
"""
Below logger.err gives
'Logger' object has no attribute 'err'
"""
logger = logging.getLogger('sample')
logger.setLevel(logging.DEBUG)
handler = logging.StreamHandler()
logger.addHandler(handler)
num = randrange(0,1000)
if num == 0:
logger.err("got zero")
else:
logger.info(f'got a positive integer: {num}')
if __name__ == "__main__":
main()
--
https://mail.python.org/mailman/listinfo/python-list
Re: How to detect an undefined method?
I just started to think from your example with method 'err' of logger
object.
In this particular case you can check method 'err' exists or not before
call this.
But if you mean general case ... . If for example I use some library
which uses another library and someone just 'typo' there ...
Here is example from my code:
calc: Calculator = Calculator()
...
actions: Dict[str, Callable] = {
"s.sysinfo": calc.get_system_info,
"s.setloglevel": calc.set_log_level,
...
}
...
def do_action(action: str, params: Dict[str, str]) -> ActionResult:
return await actions[action](params)
And if I make mistake and type 'calc.get_s*i*stem_info' instead
'calc.get_s*y*stem_info. Error appears on rutime stage only.
And neither 'mypy --strict' or 'pyre' can find such error.
I guess there is not warranty to detect such sitations in huge codebase.
It's python dynamic nature.
May be dynamic checkers can help in such situations ...
27.03.2022 20:07, Manfred Lotz пишет:
On 3/27/22 18:57, Kirill Ratkin wrote:
Hi
You can get all methods of your object and check the method you want to call is
there or not.
|methods = [method for method in dir() if
callable(getattr(, method))] if 'method_you_need' in methods:
. // BR |
I don't understand how this may help. Assume somebody has a codebase of 15T
lines of Python code. How do you want to apply your method?
But perhaps I overlook things.
--
https://mail.python.org/mailman/listinfo/python-list
Re: calling a function asynchronously
Hi,
You can use asyncio.create_task and gather results. See docs -
https://docs.python.org/3/library/asyncio-task.html
But think twice what you want to do in async task. Do you use synchronous
requests to database? If yes it will blocks eventloop...
If you use Django it makes sense to use something like
'django-background-tasks'
It just saves your time possibly.
// BR
ср, 30 мар. 2022 г., 19:14 Larry Martell :
> I have a django app, and for a certain request I need to kick off a
> long running task. I want to do this asynchronously and immediately
> return a response. I tried using subprocess.Process() but the forked
> process does not have a django database connection. I then tried
> posting a request using ajax but that does not have a django session
> so it's not authorized. Tried using asyncio but I am finding the
> caller of the async function does not return until the async function
> returns - maybe I am doing something wrong, as it does appear to be
> actually asynchronous. I tried this test:
>
> import asyncio
> import time
>
> async def long():
> for i in range(100):
>time.sleep(10)
>
> asyncio.run(long())
> print('after asyncio.run')
>
> The final print does not come out until after long() completes.
>
> Is there any way to do this?
> --
> https://mail.python.org/mailman/listinfo/python-list
>
--
https://mail.python.org/mailman/listinfo/python-list
Re: calling a function asynchronously
Hi again,
I changed a bit your example and it works as you expected I hope.
import asyncio
async def long():
for i in range(100):
await asyncio.sleep(10)
print("long is done")
loop = asyncio.get_event_loop()
task = loop.create_task(long())
print('after asyncio.run')
loop.run_until_complete(asyncio.gather(task))
But how I wrote before ... if you are in big Django project just look at
existent django libraries for long task running. One of it I sent you.
There is 'celery' as well.
It's more pragmatic way ...
30.03.2022 19:10, Larry Martell пишет:
import asyncio
import time
async def long():
for i in range(100):
time.sleep(10)
asyncio.run(long())
print('after asyncio.run')
--
https://mail.python.org/mailman/listinfo/python-list
Re: calling a function asynchronously
Hi
30.03.2022 21:44, Larry Martell пишет:
On Wed, Mar 30, 2022 at 2:40 PM Kirill Ratkin via Python-list
wrote:
Hi again,
I changed a bit your example and it works as you expected I hope.
import asyncio
async def long():
for i in range(100):
await asyncio.sleep(10)
print("long is done")
loop = asyncio.get_event_loop()
task = loop.create_task(long())
print('after asyncio.run')
loop.run_until_complete(asyncio.gather(task))
But how I wrote before ... if you are in big Django project just look at
existent django libraries for long task running. One of it I sent you.
There is 'celery' as well.
It's more pragmatic way ...
Appreciate the reply. I did not know about django-background-tasks -
thanks. I've been trying to make use of that. I do not get the errors
I was getting before but it does not appear that my long running task
is running at all. Still debugging. But concerting asyncio - doesn't
run_until_complete block until long() completes?
Yes, It runs until the /future/ has completed.
In example above 'gather' is not necessary because you create one async
task only.
You can pass 'task' to run_until_complete directly.
But if you create several tasks, all of it need to be run concurently
and 'gather' does it.
import asyncio
import random
async def long(x):
duration = random.randint(2, 5)
await asyncio.sleep(duration)
print(f"long is done {x} slept for {duration} seconds")
loop = asyncio.get_event_loop()
task1 = loop.create_task(long(1))
task2 = loop.create_task(long(2))
task3 = loop.create_task(long(3))
print('after asyncio.run')
loop.run_until_complete(asyncio.gather(task1, task2, task3))
So here run_until_complete will wait untill all three tasks complete or
cancel for some reasons (then exception happens. btw we don't handle it
in example).
In your example you use 'asyncio.run'. Internally it does things like to
this
def run(ft)
loop = asyncio.get_event_loop()
task = loop.create_task(ft())
loop.run_until_complete(asyncio.gather(task))
Of course real asyncio.run is much more complicated but model is same, i
think.
It creates loop and future and 'run_until_complete' for future/task in
the loop.
That's why you never get 'print' before asyncio.run finishes.
You also can split run_until_complete and gather.
s = asyncio.gather(task1, task2, task3)
print('after asyncio.run')
loop.run_until_complete(s)
Then 'gather' starts schedule all tasks before 'print' executes. For
example, if you have some network IO operations instead this 'print' ...
maybe few of your async tasks are done during this time.
30.03.2022 19:10, Larry Martell пишет:
import asyncio
import time
async def long():
for i in range(100):
time.sleep(10)
asyncio.run(long())
print('after asyncio.run')
--
https://mail.python.org/mailman/listinfo/python-list
--
https://mail.python.org/mailman/listinfo/python-list
Re: dict.get_deep()
Hi Marco.
Recently I met same issue. A service I intergated with was documented
badly and sent ... unpredictable jsons.
And pattern matching helped me in first solution. (later I switched to
Pydantic models)
For your example I'd make match rule for key path you need. For example:
data = {"users": [{"address": {"street": "Baker"}}]}
match data:
case {"users": [{"address": {"street": street}}]}:
print(f"street: {street}")
case _:
print("unsupported message structure")
Structural matching gives you warranty you process exactly message you
expect and explicitly discards messages with another structure.
But type is still issue. I don't know how to say 'street' must be 'str'
not 'int'. That's why I switched to Pydantic.
02.04.2022 23:44, Marco Sulla пишет:
A proposal. Very often dict are used as a deeply nested carrier of
data, usually decoded from JSON. Sometimes I needed to get some of
this data, something like this:
data["users"][0]["address"]["street"]
What about something like this instead?
data.get_deep("users", 0, "address", "street")
and also, instead of this
try:
result = data["users"][0]["address"]["street"]
except KeyError, IndexError:
result = "second star"
write this:
data.get_deep("users", 0, "address", "street", default="second star")
?
--
https://mail.python.org/mailman/listinfo/python-list
Re: dict.get_deep()
To my previous post.
It seems 'case if' should help with types:
case {"users": [{"address": {"street": street}}]} if isinstance(street,
str):
:)
// BR
02.04.2022 23:44, Marco Sulla пишет:
A proposal. Very often dict are used as a deeply nested carrier of
data, usually decoded from JSON. Sometimes I needed to get some of
this data, something like this:
data["users"][0]["address"]["street"]
What about something like this instead?
data.get_deep("users", 0, "address", "street")
and also, instead of this
try:
result = data["users"][0]["address"]["street"]
except KeyError, IndexError:
result = "second star"
write this:
data.get_deep("users", 0, "address", "street", default="second star")
?
--
https://mail.python.org/mailman/listinfo/python-list
Re: dict.get_deep()
Hello,
Yes, I misunderstood as well because started to think about pattern
matching which is good but this is not subject the question was about.
Sorry for my mistake.
Because question was about 'builtin' function which means stdlib
function implemented in python itself or even in C.
It seems, maybe I miss again, but we are talking about similar ideas
behind 'xpath' or 'jsonpath' or even 'LINQ'. We want to find some 'dsl'
which give us simple and safe way to get deeply nested values from dict.
There are several similar solutions on pypi
(https://pypi.org/project/dpath/, https://pypi.org/project/path-dict/).
But maybe (and maybe I miss again) we talk about language embedded
solution like operator ? or ??.
For example deep dict extraction could look like: street =
data["users"]?[0]?["address"]?["street"]?.
// BR
04.04.2022 2:24, Avi Gross via Python-list пишет:
I may have misunderstood something.
The original post in this subject sounded to ME likethey had nested
dictionaries and wanted to be ableto ask a method in the first dictionary
totake an unspecified number of arguments thatwould be successive keys and
return the results.
I mean if A was a dictionary containing saycities and it had an alphabetical
index of lettersA to Z and those contained dictionaries ofsay last names as
additional dictionaries andso on, then they wanted to perhaps say;
A.getdeep("Boston", "S", "Smith", "Address", default="None")
But the replies I am seeing look so different that I mayhave missed something
as it seems more about usingpattern matching on the data used to make the
dictionariesor something.
So I was happy to see Marco suggesting a function alongthe lines of my thought
process. But I have another thought.A stand-alone function along his lines
might be fine. Buta method built into a general Dictionary class is
anotherthing as it asks a method in one dictionary to march aroundinto other
dictionaries. So I wonder if a better methodis sort of recursive.
If you had a class like dictionary that had a getdeep function,and it got
called with N arguments, and perhaps a namedargument supplying a default, then
would it make sensefor the function checking to see if the FIRST argument canbe
found as a key to the current dictionary.
If arguments remain then it should expect to finda result that is a dictionary
(or perhaps some otherobject that supports the getdeep() protocol and ask
thatobject to operate on the N-1 remaining arguments, passingthe default along
too.
If the request is valid, after some iterations an object willhave a method
invoked with a single argument (plus default)and a value passed back up the
chain. For any errors alongthe way, the default would be returned.
Is this closer to the spirit of the request? I view this versionof nested
dictionaries as a sort of tree structure with variablebranches along the way.
So an approach like this could makesense and perhaps Python could be updated
eventually to havesome objects support such a protocol.
Of course you could sort of do it yourself by subclassing somethingand making
changes but that may not work for what is already asort of built-in data
structure but could work for one of many variantsalready implemented in modules.
-Original Message-
From: Marco Sulla
To: Peter J. Holzer
Cc: [email protected]
Sent: Sun, Apr 3, 2022 5:17 pm
Subject: Re: dict.get_deep()
On Sun, 3 Apr 2022 at 21:46, Peter J. Holzer wrote:
data.get_deep("users", 0, "address", "street", default="second star")
Yep. Did that, too. Plus pass the final result through a function before
returning it.
I didn't understand. Have you added a func parameter?
I'm not sure whether I considered this when I wrote it, but a function
has the advantage of working with every class which can be indexed. A
method must be implemented on any class (so at least dict and list to be
useful).
You're right, but where to put it? I don't know if an iterableutil package
exists. If included in the stdlib, I don't know where to put it. In
collections maybe?
PS: if you're interested, here is my implementation:
def get_deep(self, *args, default=_sentinel):
r"""
Get a nested element of the dictionary.
The method accepts multiple arguments or a single one. If a single
argument is passed, it must be an iterable. This represents the
keys or indexes of the nested element.
The method first tries to get the value v1 of the dict using the
first key. If it finds v1 and there's no other key, v1 is
returned. Otherwise, the method tries to retrieve the value from v1
associated with the second key/index, and so on.
If in any point, for any reason, the value can't be retrieved, the
`default` parameter is returned if specified. Otherwise, a
KeyError or an IndexError is raised.
"""
if len(args) == 1:
single = True
it_tpm = args[0]
try:
len(it_tpm)
