[issue37868] `is_dataclass` returns `True` if `getattr` always succeeds.

2019-08-19 Thread miss-islington


Change by miss-islington :


--
pull_requests: +15056
pull_request: https://github.com/python/cpython/pull/15339

___
Python tracker 

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



[issue37868] `is_dataclass` returns `True` if `getattr` always succeeds.

2019-08-19 Thread Eric V. Smith


Eric V. Smith  added the comment:


New changeset b0f4dab8735f692bcfedcf0fa9a25e238a554bab by Eric V. Smith in 
branch 'master':
bpo-37868: Improve is_dataclass for instances. (GH-15325)
https://github.com/python/cpython/commit/b0f4dab8735f692bcfedcf0fa9a25e238a554bab


--

___
Python tracker 

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



[issue37868] `is_dataclass` returns `True` if `getattr` always succeeds.

2019-08-19 Thread miss-islington


Change by miss-islington :


--
pull_requests: +15057
pull_request: https://github.com/python/cpython/pull/15340

___
Python tracker 

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



Re: Which editor is suited for view a python package's source?

2019-08-19 Thread Nick Sarbicki
Yes the community edition works fine.

It seems to require a 64 bit version of Windows 7 or higher (I'm not sure
as I haven't used Windows in years).

On Tue, 20 Aug 2019, 03:27 ,  wrote:

> Nick Sarbicki於 2019年8月19日星期一 UTC+8下午5時33分27秒寫道:
> > PyCharm takes you to the source code within the editor for any
> > variables/functions/classes/modules if you ctrl+click on what you want to
> > see. It allows you to browse the relevant bits of code quickly, as well
> as
> > let you change them in your local environment if need be.
> >
> > That way you don't have to download the source separately, you can just
> use
> > it as a normal dependency.
> >
> > But if you want to view the source of a project in isolation I imagine
> any
> > common editor will suffice. Personally I'll tend to look where the source
> > is hosted (GitHub, GitLab etc) instead of downloading it. But I can
> > understand why some may not trust this.
> >
> > On Mon, 19 Aug 2019, 10:17 ,  wrote:
> >
> > > I like to download one package's source and study it in an editor. It
> > > allows me to open the whole package as a project and let me jump from a
> > > reference in one file to its definition in another file back and
> forth. It
> > > will be even better if it can handle the import modules too. (Maybe
> this is
> > > too much:-)
> > >
> > > Can anyone recommend such a tool?
> > >
> > > --Jach
> > > --
> > > https://mail.python.org/mailman/listinfo/python-list
> > >
>
> There is a free community version of PyCharm. Will it support the
> cross-reference of viewing different files in different subdirectory? and
> what Windows versions it requires?
>
> --Jach
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue37890] Modernize several tests in test_importlib

2019-08-19 Thread Kyle Stanley


Change by Kyle Stanley :


--
stage:  -> needs patch
type:  -> enhancement

___
Python tracker 

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



[issue37835] typing.get_type_hints wrong namespace for forward-declaration of inner class

2019-08-19 Thread Netzeband


Netzeband  added the comment:

I tried my idea with the small example code above. However it does not work 
like expected: 
(see zipped example project, attached to this comment)

At the moment where the function decorator is applied to the method of the 
inner class, the local namespace ("locals()") does not contain any inner class. 
Even not another inner class, define before the corresponding class.

So the only way to get it working is to add the __locals__ attribute manually 
after defining the class, which is even more ugly than my suggested workaround 
with the function decorator :-(

Any further ideas about this?

--
Added file: 
https://bugs.python.org/file48552/get_type_hints_for_inner_classes.zip

___
Python tracker 

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



[issue37754] Persistence of Shared Memory Segment after process exits

2019-08-19 Thread Vinay Sharma


Vinay Sharma  added the comment:

Hi Davin,
Thanks for replying!

As you said I went through the issue, and now understand why segments should 
not be automatically created if they don't exist.

But, after reading that thread I got to know that shared memory is supposed to 
exist even if the process exits, and it can only be freed by unlink, which I 
also believe is an important functionality required by many use cases as you 
mentioned.

But, this is not the behaviour currently.
As soon as the process exists, all the shared memory created is unlinked.

Also, the documentation currently mentions: "shared memory blocks may outlive 
the original process that created them", which is not the case at all.

Currently, the resource_tracker, unlinks the shared memory, by calling unlink 
as specified here:
```
if os.name == 'posix':
import _multiprocessing
import _posixshmem

_CLEANUP_FUNCS.update({
'semaphore': _multiprocessing.sem_unlink,
'shared_memory': _posixshmem.shm_unlink,
})
```

So, is this an expected behaviour, if yes documentation should be updated, and 
if not the code base should be.

I will be happy to submit a patch in both the cases.

PS: I personally believe from my experience that shared memory segments should 
outlive the process, unless specified otherwise. Also, a argument persist=True, 
can be added which can ensure that the shared_memory segment outlives the 
process, and can be used by processes which are spawned later.

--

___
Python tracker 

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



[issue37835] typing.get_type_hints wrong namespace for forward-declaration of inner class

2019-08-19 Thread Netzeband


Netzeband  added the comment:

Thanks for your response. I was also thinking much about it and was not able to 
find a nice idea how to get this working. 

The problem is, that we loose the local-namespace information as soon as we 
leave the context of the function, where the class was defined in. This 
information is not stored in the function object of the method, we want to get 
the type hints from. The only open question, I have in this context is: 

Why can python resolve the reference to class A (also a inner class, but no 
forward declaration)? Is there any chance to use the same mechanism also for 
forward declared references?

Beside from this question, I will give you my thoughts, how I think this issue 
could be addressed:

 - What we need is the local namespace information from the function, where the 
inner class was defined in. This is not stored from python in the function 
object of this class (but __global__ is stored). 
 - Maybe any upcoming python version could store this information in __local__ 
? So maybe we could clone this ticket to the python core in order to address 
this?

 - As long as python is not storing this information, a workaround could be 
used: We could define a function decorator, which adds the attribute __local__ 
to a function object. I think about this syntax:

class InnerClass():
@store_namespace(locals())
def method() -> 'InnerClass':
...

- The get_type_hints function is then checking for the __local__ attribute and 
if it exits it is passed to the function, which resolves the forward 
declaration.

This workaround is not beautiful, since it requires manual work for those 
methods (adding the function decorator to those methods). Furthermore - without 
knowing the internals of the get_type_hints function - this workaround is not 
straight forward and easy to understand. So it needs to be carefully documented 
and even then I expect confusing questions on StackOverflow or other 
communities. 

However, it is a quite rare case that someone really needs to use inner 
classes. Normally one could simply put the class in the global namespace. But 
when this happens and there is really a need for it, than this workaround would 
make it possible. Furthermore, checking a __local__ attribute of the function 
object would be a nice preparation for a feature request to the python core, 
which should store the reference to the local namespace for every function 
object, without using any decorators.

What do you think?

--

___
Python tracker 

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



Re: My pseudocode to Python?

2019-08-19 Thread Kyle Stanley
> Except 'list' is a bad name to use...

Definitely, it's not a good practice to use any reserved names, especially
built-in ones. A pretty common substitute I've seen is "ls", but it would
be preferable to have something more descriptive of the elements within the
list. But, for basic examples, "ls" should be fine.

On Mon, Aug 19, 2019 at 11:35 PM Alan Bawden  wrote:

> Alan Bawden  writes:
>
> > r...@zedat.fu-berlin.de (Stefan Ram) writes:
> > > for i in range( len( list )- 1, 0, -1 ):
> > > if list[ i ]is None: del list[ i ]
> >
> > list = [x for x in list if x is not None]
>
> Except 'list' is a bad name to use...
>
> --
> Alan Bawden
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue37754] Persistence of Shared Memory Segment after process exits

2019-08-19 Thread Vinay Sharma


Change by Vinay Sharma :


--
title: alter size of segment using multiprocessing.shared_memory -> Persistence 
of Shared Memory Segment after process exits

___
Python tracker 

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



[issue37890] Modernize several tests in test_importlib

2019-08-19 Thread Kyle Stanley


Change by Kyle Stanley :


--
nosy: +eric.snow, ncoghlan

___
Python tracker 

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



[issue37890] Modernize several tests in test_importlib

2019-08-19 Thread Kyle Stanley


Kyle Stanley  added the comment:

I'm not entirely certain as to which parts should be modernized, and which ones 
can remain the same. A large part of my uncertainty is that there are no header 
comments for "test_pkg_import.py" to explain the test coverage, so I don't know 
if there are additional tests beyond the existing ones that should be added.

The first steps I can think of: 

1) Use ``importlib.import_module()`` instead of the built-in ``__import__()``

2) Use ``with self.assertRaises(, ): ...`` instead of

```
try: __import__(self.module_name)
except SyntaxError: pass
else: raise RuntimeError('Failed to induce SyntaxError') # self.fail()?

...
```

3) Replace ``self.assertEqual(getattr(module, var), 1)`` with 
``self.assertEqual(getattr(module, var, None), 1)`` so that AttributeErrors are 
not raised when unexpected behaviors occur

4) Provide useful error messages for failed assertions

I'll begin working on those, probably with a separate PR for each of them for 
ease of review. Let me know if there's anything else I should do, or if any of 
the above steps are unneeded. If I think of anything else I'll update the issue 
accordingly.

--

___
Python tracker 

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



Re: My pseudocode to Python?

2019-08-19 Thread Alan Bawden
Alan Bawden  writes:

> r...@zedat.fu-berlin.de (Stefan Ram) writes:
> > for i in range( len( list )- 1, 0, -1 ):
> > if list[ i ]is None: del list[ i ]
> 
> list = [x for x in list if x is not None]

Except 'list' is a bad name to use...

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


Re: My pseudocode to Python?

2019-08-19 Thread Alan Bawden
r...@zedat.fu-berlin.de (Stefan Ram) writes:
> for i in range( len( list )- 1, 0, -1 ):
> if list[ i ]is None: del list[ i ]

list = [x for x in list if x is not None]

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


[issue37890] Modernize several tests in test_importlib

2019-08-19 Thread Kyle Stanley


New submission from Kyle Stanley :

Last month, several tests were moved into test_importlib 
(https://bugs.python.org/issue19696): "test_pkg_import.py", 
"test_threaded_import.py", and  "threaded_import_hangers.py".

Those tests were created quite a while ago though and do not currently utilize 
importlib directly. They should be updated accordingly.

Brett Cannon:
> BTW, if you want to open a new issue and modernize the tests to use importlib 
> directly that would be great!

I'm interested in helping with this issue, but I may require some assistance as 
I'm not overly familiar with the internals of importlib. I'll probably start 
with "test_pkg_import.py". 

Anyone else can feel free to work on the other two in the meantime, but they 
should be worked on together as "threaded_import_hangers.py" is a dependency 
for "test_threaded_import.py".

--
components: Tests
messages: 349984
nosy: aeros167, brett.cannon
priority: normal
severity: normal
status: open
title: Modernize several tests in test_importlib
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



Re: Which editor is suited for view a python package's source?

2019-08-19 Thread jfong
Nick Sarbicki於 2019年8月19日星期一 UTC+8下午5時33分27秒寫道:
> PyCharm takes you to the source code within the editor for any
> variables/functions/classes/modules if you ctrl+click on what you want to
> see. It allows you to browse the relevant bits of code quickly, as well as
> let you change them in your local environment if need be.
> 
> That way you don't have to download the source separately, you can just use
> it as a normal dependency.
> 
> But if you want to view the source of a project in isolation I imagine any
> common editor will suffice. Personally I'll tend to look where the source
> is hosted (GitHub, GitLab etc) instead of downloading it. But I can
> understand why some may not trust this.
> 
> On Mon, 19 Aug 2019, 10:17 ,  wrote:
> 
> > I like to download one package's source and study it in an editor. It
> > allows me to open the whole package as a project and let me jump from a
> > reference in one file to its definition in another file back and forth. It
> > will be even better if it can handle the import modules too. (Maybe this is
> > too much:-)
> >
> > Can anyone recommend such a tool?
> >
> > --Jach
> > --
> > https://mail.python.org/mailman/listinfo/python-list
> >

There is a free community version of PyCharm. Will it support the 
cross-reference of viewing different files in different subdirectory? and what 
Windows versions it requires? 

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


[issue36502] str.isspace() for U+00A0 and U+202F differs from document

2019-08-19 Thread Greg Price


Greg Price  added the comment:

Thanks Victor for the reviews and merges!

(Unmarking 2.7, because https://docs.python.org/2/library/stdtypes.html seems 
to not have this issue.)

--
versions:  -Python 2.7

___
Python tracker 

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



Re: How to login remote windos device using python

2019-08-19 Thread Kyle Stanley
I would recommend checking out WMI: https://pypi.org/project/WMI/

For remote connection as a named user (official WMI docs):
http://timgolden.me.uk/python/wmi/tutorial.html#connecting-to-a-remote-machine-as-a-named-user

Also, another example (unofficial):
https://stackoverflow.com/questions/18961213/how-to-connect-to-a-remote-windows-machine-to-execute-commands-using-python.
This was done in Python2, but the example is still useful.

On Mon, Aug 19, 2019 at 2:11 PM Iranna Mathapati 
wrote:

> Hi Team,
>
> can you please let me know, How to login the remote Windows machine using
> python??
>
> Thanks
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue37866] PyModule_GetState Segmentation fault when called Py_Initialize

2019-08-19 Thread Hua Liu


Change by Hua Liu :


--
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: Which editor is suited for view a python package's source?

2019-08-19 Thread Kyle Stanley
> The most popular choices today are probably PyCharm and VSCode.  I prefer
> vim with the syntastic plugin (and a few other plugins including Jedi),
but
> I've heard good things about the other two.

Personally, I've been using VSCode with the Python and Vim extensions. I've
used PyCharm as well and have no issues with it, but I've found VSCode to
be significantly more customizable. I also like that VSCode works across a
number of different languages instead of being exclusive to Python, so it
works great as a general purpose editor. I'm not a huge fan of switching
between different editors constantly, so I usually use Vim for plaintext
and VSCode for anything programming related.

On Mon, Aug 19, 2019 at 8:03 PM Dan Stromberg  wrote:

> Uh oh.  Editor wars.
>
> The most popular choices today are probably PyCharm and VSCode.  I prefer
> vim with the syntastic plugin (and a few other plugins including Jedi), but
> I've heard good things about the other two.  And emacs almost certainly can
> edit/view Python files well, though I haven't heard much about that.
>
> HTH.
>
> On Mon, Aug 19, 2019 at 2:15 AM  wrote:
>
> > I like to download one package's source and study it in an editor. It
> > allows me to open the whole package as a project and let me jump from a
> > reference in one file to its definition in another file back and forth.
> It
> > will be even better if it can handle the import modules too. (Maybe this
> is
> > too much:-)
> >
> > Can anyone recommend such a tool?
> >
> > --Jach
> > --
> > https://mail.python.org/mailman/listinfo/python-list
> >
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Your IDE's?

2019-08-19 Thread Dan Stromberg
I just mentioned essentially this in another thread, but I really like vim
with syntastic and jedi plus a few other plugins.

I keep all my vim config at http://stromberg.dnsalias.org/svn/vimrc/trunk/
so it's easy to set up a new machine.  I haven't used it on anything but
Debian/Ubuntu/Mint recently though, so other OS'es/Distributions may not
work.  It also does bash, lua, etcetera.

On Mon, Mar 25, 2019 at 2:40 PM John Doe  wrote:

>
> What is your favorite Python IDE?
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue37883] threading.Lock.locked is not documented

2019-08-19 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


--
keywords: +newcomer friendly

___
Python tracker 

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



[issue37887] some leak in the compiler_assert function

2019-08-19 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

Hi hai shi,

As you can see in other pars of the code base objects returned from 
PyUnicode_InternFromString that have static storage class do not need to be 
deallocated in case there is a failure, so this is not considered a leak as 
there will be only one owned object across all calls. The Python object is 
reused every time the function is call (so in successive calls the object can 
be reused and therefore assertion_error!= NULL).

--
nosy: +pablogsal

___
Python tracker 

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



Re: Which editor is suited for view a python package's source?

2019-08-19 Thread Dan Stromberg
Uh oh.  Editor wars.

The most popular choices today are probably PyCharm and VSCode.  I prefer
vim with the syntastic plugin (and a few other plugins including Jedi), but
I've heard good things about the other two.  And emacs almost certainly can
edit/view Python files well, though I haven't heard much about that.

HTH.

On Mon, Aug 19, 2019 at 2:15 AM  wrote:

> I like to download one package's source and study it in an editor. It
> allows me to open the whole package as a project and let me jump from a
> reference in one file to its definition in another file back and forth. It
> will be even better if it can handle the import modules too. (Maybe this is
> too much:-)
>
> Can anyone recommend such a tool?
>
> --Jach
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue37834] readlink on Windows cannot read app exec links

2019-08-19 Thread Steve Dower


Steve Dower  added the comment:

> So the order of the GetFileInformationByHandleEx and GetFileType blocks 
> actually needs to be flipped.

I've done that now.

And thanks for confirming. That was my suspicion, but I wasn't sure if you knew 
something here that I didn't (v. likely!).

--

___
Python tracker 

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



[issue37788] fix for bpo-36402 (threading._shutdown() race condition) causes reference leak

2019-08-19 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset d11c2c607768fa549b1aed7899edc061b2ebf19f by Victor Stinner in 
branch 'master':
Revert "bpo-37788: Fix a reference leak if a thread is not joined (GH-15228)" 
(GH-15338)
https://github.com/python/cpython/commit/d11c2c607768fa549b1aed7899edc061b2ebf19f


--

___
Python tracker 

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



[issue37878] Sub-Interpreters : Document PyThreadState_DeleteCurrent()

2019-08-19 Thread STINNER Victor


STINNER Victor  added the comment:

Is it safe to call PyThreadState_DeleteCurrent()?

--
keywords:  -easy

___
Python tracker 

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



[issue37889] Fatal Python error: Py_EndInterpreter: not the last thread

2019-08-19 Thread STINNER Victor


STINNER Victor  added the comment:

It's a regression caused by bpo-37788. I created PR 15338 to revert my change.

--
resolution:  -> duplicate
stage:  -> resolved
status: open -> closed
superseder:  -> fix for bpo-36402 (threading._shutdown() race condition) causes 
reference leak

___
Python tracker 

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



[issue37788] fix for bpo-36402 (threading._shutdown() race condition) causes reference leak

2019-08-19 Thread STINNER Victor


STINNER Victor  added the comment:

> https://github.com/python/cpython/commit/d3dcc92778807ae8f7ebe85178f36a29711cd478

This change introduced a regression :-(
https://github.com/python/cpython/pull/15228#issuecomment-522792133

I created PR 15338 to revert it

--

___
Python tracker 

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



[issue37788] fix for bpo-36402 (threading._shutdown() race condition) causes reference leak

2019-08-19 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +15055
pull_request: https://github.com/python/cpython/pull/15338

___
Python tracker 

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



[issue37889] Fatal Python error: Py_EndInterpreter: not the last thread

2019-08-19 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


--
title: "Fatal Python error: Py_EndInterpreter: not the last thread" that's bad 
-> Fatal Python error: Py_EndInterpreter: not the last thread

___
Python tracker 

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



[issue37889] "Fatal Python error: Py_EndInterpreter: not the last thread" that's bad

2019-08-19 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

See also https://bugs.python.org/issue37788

--

___
Python tracker 

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



[issue37834] readlink on Windows cannot read app exec links

2019-08-19 Thread Eryk Sun


Eryk Sun  added the comment:

> Any particular reason you did GetFileAttributesW(path) in the 
> non-FILE_TYPE_DISK case when we have the hFile around?

The point of getting the file attributes is to identify the root directory of 
the namedpipe and mailslot file systems. For example, os.listdir('//./pipe') 
works because we append "\\*.*" to the path.

GetFileInformationByHandle[Ex] forbids a pipe handle, for reasons that may no 
longer be relevant in Windows 10 (?). I remembered the restriction in the above 
case, but it seems I forgot about it when querying the tag. So the order of the 
GetFileInformationByHandleEx and GetFileType blocks actually needs to be 
flipped. That would be a net improvement anyway since there's no point in 
querying a reparse tag from a device that's not a file system (namedpipe and 
mailslot are 'file systems', but only at the most basic level).

I can't imagine there being a problem with querying FileBasicInfo to get the 
file attributes. I just checked that it works fine with "//./pipe/" and 
"//./mailslot/" -- at least in Windows 10. Anyway, GetFileAttributesW uses a 
query-only open that doesn't create a real file object or even require an IRP 
usually, so it's not adding much cost compared to querying FileBasicInfo using 
the handle.

--

___
Python tracker 

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



[issue37889] "Fatal Python error: Py_EndInterpreter: not the last thread" that's bad

2019-08-19 Thread Pablo Galindo Salgado


New submission from Pablo Galindo Salgado :

The x86-64 High Sierra 3.x buildbot and AMD64 FreeBSD CURRENT Shared 3.x are 
failing with:

Fatal Python error: Py_EndInterpreter: not the last thread

https://buildbot.python.org/all/#/builders/145/builds/2233
https://buildbot.python.org/all/#/builders/168/builds/1295

Fatal Python error: Py_EndInterpreter: not the last thread
Current thread 0x7fff8e587380 (most recent call first):
  File 
"/Users/buildbot/buildarea/3.x.billenstein-sierra/build/Lib/test/support/__init__.py",
 line 2911 in run_in_subinterp
  File 
"/Users/buildbot/buildarea/3.x.billenstein-sierra/build/Lib/test/test_threading.py",
 line 1006 in test_threads_join_2
  File 
"/Users/buildbot/buildarea/3.x.billenstein-sierra/build/Lib/unittest/case.py", 
line 611 in _callTestMethod
  File 
"/Users/buildbot/buildarea/3.x.billenstein-sierra/build/Lib/unittest/case.py", 
line 654 in run
  File 
"/Users/buildbot/buildarea/3.x.billenstein-sierra/build/Lib/unittest/case.py", 
line 714 in __call__
  File 
"/Users/buildbot/buildarea/3.x.billenstein-sierra/build/Lib/unittest/suite.py", 
line 122 in run
  File 
"/Users/buildbot/buildarea/3.x.billenstein-sierra/build/Lib/unittest/suite.py", 
line 84 in __call__
  File 
"/Users/buildbot/buildarea/3.x.billenstein-sierra/build/Lib/unittest/suite.py", 
line 122 in run
  File 
"/Users/buildbot/buildarea/3.x.billenstein-sierra/build/Lib/unittest/suite.py", 
line 84 in __call__
  File 
"/Users/buildbot/buildarea/3.x.billenstein-sierra/build/Lib/unittest/suite.py", 
line 122 in run
  File 
"/Users/buildbot/buildarea/3.x.billenstein-sierra/build/Lib/unittest/suite.py", 
line 84 in __call__
  File 
"/Users/buildbot/buildarea/3.x.billenstein-sierra/build/Lib/unittest/runner.py",
 line 176 in run
  File 
"/Users/buildbot/buildarea/3.x.billenstein-sierra/build/Lib/test/support/__init__.py",
 line 1996 in _run_suite
  File 
"/Users/buildbot/buildarea/3.x.billenstein-sierra/build/Lib/test/support/__init__.py",
 line 2092 in run_unittest
  File 
"/Users/buildbot/buildarea/3.x.billenstein-sierra/build/Lib/test/libregrtest/runtest.py",
 line 209 in _test_module
  File 
"/Users/buildbot/buildarea/3.x.billenstein-sierra/build/Lib/test/libregrtest/runtest.py",
 line 234 in _runtest_inner2
  File 
"/Users/buildbot/buildarea/3.x.billenstein-sierra/build/Lib/test/libregrtest/runtest.py",
 line 270 in _runtest_inner
  File 
"/Users/buildbot/buildarea/3.x.billenstein-sierra/build/Lib/test/libregrtest/runtest.py",
 line 153 in _runtest
  File 
"/Users/buildbot/buildarea/3.x.billenstein-sierra/build/Lib/test/libregrtest/runtest.py",
 line 193 in runtest
  File 
"/Users/buildbot/buildarea/3.x.billenstein-sierra/build/Lib/test/libregrtest/main.py",
 line 310 in rerun_failed_tests
  File 
"/Users/buildbot/buildarea/3.x.billenstein-sierra/build/Lib/test/libregrtest/main.py",
 line 678 in _main
  File 
"/Users/buildbot/buildarea/3.x.billenstein-sierra/build/Lib/test/libregrtest/main.py",
 line 628 in main
  File 
"/Users/buildbot/buildarea/3.x.billenstein-sierra/build/Lib/test/libregrtest/main.py",
 line 695 in main
  File 
"/Users/buildbot/buildarea/3.x.billenstein-sierra/build/Lib/test/__main__.py", 
line 2 in 
  File "/Users/buildbot/buildarea/3.x.billenstein-sierra/build/Lib/runpy.py", 
line 85 in _run_code
  File "/Users/buildbot/buildarea/3.x.billenstein-sierra/build/Lib/runpy.py", 
line 192 in _run_module_as_main
make: *** [buildbottest] Abort trap: 6
program finished with exit code 2
elapsedTime=1799.062811
test_threads_join_2 (test.test_threading.SubinterpThreadingTests) ... 

https://buildbot.python.org/all/#/builders/145/builds/2233

--
messages: 349974
nosy: pablogsal, vstinner
priority: normal
severity: normal
status: open
title: "Fatal Python error: Py_EndInterpreter: not the last thread" that's bad
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



[issue37788] fix for bpo-36402 (threading._shutdown() race condition) causes reference leak

2019-08-19 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset d3dcc92778807ae8f7ebe85178f36a29711cd478 by Victor Stinner in 
branch 'master':
bpo-37788: Fix a reference leak if a thread is not joined (GH-15228)
https://github.com/python/cpython/commit/d3dcc92778807ae8f7ebe85178f36a29711cd478


--

___
Python tracker 

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



[issue37788] fix for bpo-36402 (threading._shutdown() race condition) causes reference leak

2019-08-19 Thread miss-islington


Change by miss-islington :


--
pull_requests: +15054
pull_request: https://github.com/python/cpython/pull/15337

___
Python tracker 

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



[issue37788] fix for bpo-36402 (threading._shutdown() race condition) causes reference leak

2019-08-19 Thread miss-islington


Change by miss-islington :


--
pull_requests: +15053
pull_request: https://github.com/python/cpython/pull/15336

___
Python tracker 

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



[issue37834] readlink on Windows cannot read app exec links

2019-08-19 Thread Steve Dower


Steve Dower  added the comment:

Thanks for the code snippet, that helped me a lot (and since you went to the 
trouble of fixing other bugs, I guess I'll have to merge it into my PR now).

Any particular reason you did GetFileAttributesW(path) in the 
non-FILE_TYPE_DISK case when we have the hFile around?

I'm trying to get one more opinion from a colleague on setting S_IFLNK for all 
name surrogate reparse points vs. only symlinks by default (the 
Python/fileutils.c change, and implicitly the fixes to Lib/shutil.py). I might 
try and get some broader opinions as well on whether "is_dir() is true, do you 
suspect it could be a junction" vs "is_link() is true, do you suspect it could 
be a junction", since that is what it really comes down to. (We need to make 
changes to shutil to match Explorer anyway - rmtree should not recurse, and 
copytree should.)

However, the minimal change is to leave S_IFLNK only for symlinks, so unless I 
get a strong case for treating all name surrogates as links, I'll revert to 
that.

--

___
Python tracker 

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



Re: My pseudocode to Python?

2019-08-19 Thread Kyle Stanley
Rather than starting with all seven strings in the list and deleting one if
a conditional is not true, why not start with 6 elements (with the one in
index 3 missing) and insert the 7th element into the third index?

>>> mylist = ['a', 'b', 'c', 'e', 'f', 'g']
>>> if x:
>>>mylist.insert(3, 'd')

>>> mylist
['a', 'b', 'c', 'd', 'e', 'f', 'g']


Regards,
Kyle Stanley (aeros167)


On Mon, Aug 19, 2019 at 2:30 PM Rob Gaddi 
wrote:

> On 8/19/19 10:43 AM, Stefan Ram wrote:
> >Can someone kindly translate my pseudocode to terse Python:
> >
> > list = \
> > [ 'afaueghauihaiuhgaiuhgaiuhgaeihui',
> >'erghariughauieghaiughahgaihgaiuhgaiuh',
> >'rejganregairghaiurghaiuhgauihgauighaei',
> >if x: 'argaeruighaiurhauirguiahuiahgiauhgaeuihi',
> >'reiugaheirughauierhgauiaeihauiehgiuaehuih'
> >'ejiaeigaiuegreaiugheiugheaiughauighaiughaiu'
> >'egairughauirghauiruiegihgruiehgiuaehgiaue' ]
> >
> >? I want the list to have the seven strings shown as entries
> >if bool(x) is True, but otherwise the list should only have
> >six entries - without the entry directly behind "if x: ".
> >
> >
>
> mylist = ['a', 'b', 'c', 'd', 'e', 'f', 'g']
> if not x:
> del mylist[3]
>
>
> --
> Rob Gaddi, Highland Technology -- www.highlandtechnology.com
> Email address domain is currently out of order.  See above to fix.
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue23882] unittest discovery doesn't detect namespace packages when given no parameters

2019-08-19 Thread Roger Gammans


Change by Roger Gammans :


--
nosy: +rgammans

___
Python tracker 

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



[issue35617] unittest discover does not work with implicit namespaces

2019-08-19 Thread Roger Gammans


Change by Roger Gammans :


--
nosy: +rgammans

___
Python tracker 

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



[issue36723] Unittest Discovery for namespace subpackages dot notation fails

2019-08-19 Thread Roger Gammans

Roger Gammans  added the comment:

I think this is a duplicate of one (or both) of 35617, or 23882 .

Both of those have unmerged proposed fixes.

--
nosy: +rgammans

___
Python tracker 

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



[issue37834] readlink on Windows cannot read app exec links

2019-08-19 Thread Eryk Sun


Eryk Sun  added the comment:

Here are two additional differences between mount points and symlinks:

(1) A mount point in a remote path is always evaluated on the server and 
restricted to devices that are local to the server. So if we handle a mount 
point as if it's a POSIX symlink that works with readlink(), then what are we 
to do with the server's drive "Z:"? Genuine symlinks are evaluated on the 
client, so readlink() always makes sense. (Though if we resolve a symlink 
manually, then we're bypassing the system's R2L symlink policy.)

(2) A mount point has its own security that's checked in addition to the 
security on the target directory when it's reparsed. In contrast, security set 
on a symlink is not checked when the link is reparsed, which is why icacls.exe 
implicitly resolves a symlink when setting and viewing security unless the /L 
option is used.

>  - if it's a directory junction, call os.stat instead and return that > (???)

I wanted lstat in Windows to traverse mount points by default (but I gave up on 
this), as it does in Unix, because a mount point behaves like a hard name 
grafting in a path. This is important for relative symlinks that use ".." 
components to traverse above their parent directory. The result is different 
from a directory symlink that targets the same path.

A counter-argument (in favor of winlinks) is that a mount point is still 
ultimately a name-surrogate reparse point, so, unlike a hard link, its 
existence doesn't prevent the directory from being deleted. It's left in place 
as a dangling link if the target is deleted or the device is removed from the 
system. Trying to follow it fails with ERROR_PATH_NOT_FOUND or 
ERROR_FILE_NOT_FOUND. 

Also, handling a mount point as a directory by default would require an 
additional parameter because in some cases we need to be able to open a 
junction instead of traversing it, such as to implement shutil.rmtree to behave 
like CMD's `rmdir /s`. 

Another place identifying a mount point is required, unfortunately, is in 
realpath(). Ideally we would be able to handle mount points as just 
directories. The problem is that NT allows a mount point to target a symlink, 
something that's not allowed in Unix. Traversing the mount point is effectively 
the same as traversing the symlink. So we have to read the mount-point target, 
and if it's a symlink, we have to read and evaluate it. (Consequently it seems 
that getting the real path for a remote path is an intractable problem when 
mount points are involved. We can only get the final path.)

---

Even without the addition of a new parameter, we may still want to limit the 
definition of 'link' in Windows lstat to name-surrogate reparse points, i.e. 
winlinks. Reparse points that aren't name surrogates don't behave like links. 
They behave like the file itself, and reparsing may automatically replace the 
reparse point with the real file. Some of them are even directories that have 
the directory bit (28) set in the tag value, which means they're allowed to 
contain other files. (Without the directory tag bit, setting a reparse point on 
a non-empty directory should fail.)

The counter-argument to changing lstat to only open winlinks is that changing 
the meaning of 'link' in lstat is too disruptive to existing software that may 
depend on the old behavior, i.e. opening any reparse point. I think the use 
cases for opening non-links are rare enough that it's not beyond the pale to 
change this behavior in 3.8 or 3.9.

> Right, but is that because they deliberately want the junction 
> to be treated like a file? Or because they want it to be treated 
> like the directory is really right there?

For copytree it makes sense to traverse a mount point as a directory. We can't 
reliably copy a mount point. In Unix, even when a volume mount or bind mount 
can be detected, there's no standard way to clone it to a new mount point, and 
even if there were, that would require super-user access. In Windows, we could 
wrap CreateDirectorExW, which can copy a mount point, but it requires 
administrator access to copy a volume mount point (i.e. 
"?\\Volume{...}\\"), for which it calls SetVolumeMountPointW in order to 
update the mount-point manager in the kernel. 

We also have a limited ability to create mount points via 
_winapi.CreateJunction, but it's buggy in corner cases and incomplete. It 
suffices for the reason it was added -- testing the ability to delete a 
junction via os.remove(). 

> os.rmdir() already does special things to behave like a junction 
> rather than the real directory, 

This is similar in spirit to Unix, except Unix refuses to delete a mount point. 
For example, if we have a Unix bind mount to a non-empty directory, rmdir() 
fails with EBUSY. On the other hand, rmdir() on the real directory fails with 
ENOTEMPTY. If Unix handled the mount point as if it's just the mounted 
directory, I'd expect the error to be the same. 

It's not particularly special in 

[issue37834] readlink on Windows cannot read app exec links

2019-08-19 Thread Eryk Sun


Eryk Sun  added the comment:

Here's the requested overview for the case where name-surrogate reparse points 
are handled as winlinks (Windows links), but S_IFLNK is reserved for 
IO_REPARSE_TAG_SYMLINK. I took the time this afternoon to write it up in C, 
which hopefully is clearer than my prose.  It handles all CreateFileW failures 
inline, but uses a recursive call to traverse a non-link. No reparse tag values 
are hard coded in win32_xstat_impl.

I extended it to support devices that aren't file systems, such as "con", disk 
volumes, and raw disks. This enhancement was requested on another issue, but it 
may as well get updated in this issue if win32_xstat_impl is getting 
overhauled. Some of these devices are already supported by fstat(). The latter 
can be extended similarly to support volume devices and raw disk devices.

I opted to fail the call in the unhandled-tag case if it opens a link that 
should be traversed. Either it's an unhandled link, which is an unacceptable 
condition (i.e. it should be a sink, not a link), or it's a link or sequence of 
links to an unhandled reparse point. Returning the link reparse-point data is 
not what the caller wants from a successful stat().

---

static int
win32_xstat_impl(const wchar_t *path, struct _Py_stat_struct *result,
 BOOL traverse)
{
HANDLE hFile;
BY_HANDLE_FILE_INFORMATION fileInfo;
FILE_ATTRIBUTE_TAG_INFO tagInfo = { 0 };
DWORD fileType, error;
BOOL isUnhandledTag = FALSE;
int retval = 0;

DWORD access = FILE_READ_ATTRIBUTES;
DWORD flags = FILE_FLAG_BACKUP_SEMANTICS; /* Allow opening directories. */
if (!traverse) {
flags |= FILE_FLAG_OPEN_REPARSE_POINT;
}

hFile = CreateFileW(path, access, 0, NULL, OPEN_EXISTING, flags, NULL);
if (hFile == INVALID_HANDLE_VALUE) {
/* Either the path doesn't exist, or the caller lacks access. */
error = GetLastError();
switch (error) {
case ERROR_ACCESS_DENIED: /* Cannot sync or read attributes. */
case ERROR_SHARING_VIOLATION: /* It's a paging file. */
/* Try reading the parent directory. */
if (!attributes_from_dir(path, , )) {
/* Cannot read the parent directory. */
SetLastError(error);
return -1;
}
if (fileInfo.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) {
if (traverse ||
!IsReparseTagNameSurrogate(tagInfo.ReparseTag)) {
/* The stat call has to traverse but cannot, so fail. */
SetLastError(error);
return -1;
}
}
break;

case ERROR_INVALID_PARAMETER:
/* \\.\con requires read or write access. */
hFile = CreateFileW(path, access | GENERIC_READ,
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
OPEN_EXISTING, flags, NULL);
if (hFile == INVALID_HANDLE_VALUE) {
SetLastError(error);
return -1;
}
break;

case ERROR_CANT_ACCESS_FILE:
/* bpo37834: open unhandled reparse points if traverse fails. */
if (traverse) {
traverse = FALSE;
isUnhandledTag = TRUE;
hFile = CreateFileW(path, access, 0, NULL, OPEN_EXISTING,
flags | FILE_FLAG_OPEN_REPARSE_POINT, NULL);
}
if (hFile == INVALID_HANDLE_VALUE) {
SetLastError(error);
return -1;
}
break;

default:
return -1;
}
}

if (hFile != INVALID_HANDLE_VALUE) {

/* Query the reparse tag, and traverse a non-link. */
if (!traverse) {
if (!GetFileInformationByHandleEx(hFile, FileAttributeTagInfo,
, sizeof(tagInfo))) {
/* Allow devices that do no support FileAttributeTagInfo. */
error = GetLastError() ;
if (error == ERROR_INVALID_PARAMETER ||
error == ERROR_INVALID_FUNCTION ||
error == ERROR_NOT_SUPPORTED) {
tagInfo.FileAttributes = FILE_ATTRIBUTE_NORMAL;
tagInfo.ReparseTag = 0;
} else {
retval = -1;
goto cleanup;
}
} else if (tagInfo.FileAttributes &
 FILE_ATTRIBUTE_REPARSE_POINT) {
if (IsReparseTagNameSurrogate(tagInfo.ReparseTag)) {
if (isUnhandledTag) {
/* Traversing previously failed for either this link
   or its target. */
SetLastError(ERROR_CANT_ACCESS_FILE);
retval = -1;
goto cleanup;
}
/* Traverse a 

[issue34155] email.utils.parseaddr mistakenly parse an email

2019-08-19 Thread Abhilash Raj


Abhilash Raj  added the comment:

2.7 needs a separate PR since the code is very different and my familiarity 
with 2.7 version of email package is very limited. 

I am going to work on a separate patch later this week for 2.7.

--

___
Python tracker 

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



Re: absolute path to a file

2019-08-19 Thread Paul St George

On 19/08/2019 14:16, Cameron Simpson wrote:

On 19Aug2019 08:52, Paul St George  wrote:

On 19/08/2019 01:31, Cameron Simpson wrote:

On 18Aug2019 17:29, Paul St George  wrote:

On 18/08/2019 02:03, Cameron Simpson wrote:
1: Is image01.tif a real existing file when you ran this code?
Yes. image01.tif is real, existing and apparent.
But in what directory? What is its _actual_ full path as you expect 
it to be?


Aha. The Blender file that I am using to test this on has two images 
used as textures. They reside at:

/Users/Lion/Desktop/test8/image01.tif
/Users/Lion/Desktop/images/image02.tif

The Blender file is at /Users/Lion/Desktop/test8/tifftest8.blend


There's a remark on that web page I mentioned that suggests that the 
leading '//' indicates the filename is relative to the Blender model, so 
the context directory for the '//' is likely /Users/Lion/Desktop/test8.


Yes. That makes sense. The reason I was testing with two images, one at 
/Users/Lion/Desktop/test8/image01.tif and the other at 
/Users/Lion/Desktop/images/image02.tif is that I cannot rely on images 
being in the same folder as the Blender file.


So, let's assume the context directory is /Users/Lion/Desktop/test8
and see how we get on below.



(Chris and Peter lead me to believe that Blender has a special kind 
of relative path. The double slashes replace the path to the blend 
file’s directory.) realpath has done something but I know not what.


realpath needs a UNIX path. Your //image01.tif isn't a UNIX path, it is 
a special Blender path. First you need to convert it. By replacing '//' 
with the blend file's directory. Then you can call realpath. If you 
still need to.


Understood. Now. Thanks!


[...snip...]


Did you just [...snip...] yourself?


So you might want to write an unBlenderiser (untested example):

 from os.path import isabs, join as joinpath

 def unblenderise(filename, context_dir=None):
   # transmute Blender "relative" path
   if filename.startswith('//'):
 filename = filename[2:]
   if not isabs(filename) and context_dir is not None:
 # attach the filename to `context_dir` if supplied
 filename = joinpath(context_dir, filename)
   return filename

The idea here is to get back a meaningful UNIX path from a Blender 
path. It first strips a leading '//'. Next, _if_ the filename is 
relative _and_ you supplied the optional context_dir (eg the 
directory used for a file brwoser dialogue box), then it prepends 
that context directory.


This _does not_ call abspath or realpath or anything, it just returns 
a filename which can be used with them.


The idea is that if you know where image01.tif lives, you could 
supply that as the context directory.


Yes! Until Peter Otten's timely intervention, I was trying to do this 
and had managed to join the 
path_to_the_folder_that_contains_the_Blender_file to 
the_name_of_the_image (stripped of its preceding slashes).


Your unblenderise looks much better than my nascent saneblender so 
thank you. I will explore more!


Looks like you want wd=os.path.dirname(path_of_blend_file).


Thank you!


Does it depend on knowing where image01.tif lives and manually 
supplying that?


Sort of.

What you've got is '//image01.tif', which is Blender's special notation 
indicating a filename relative to the blend file's directory. All the 
Python library stuff expects an OS path (OS==UNIX on a Mac). So you want 
to convert that into a UNIX path.  For example:


    from os.path import dirname

    # Get this from somewhere just hardwiring it for the example.
    # Maybe from your 'n' object below?
    blend_file = '/Users/Lion/Desktop/test8/tifftest8.blend'

Is this setting a relative path?


    blender_image_file = n.image.filename

    unix_image_file = unblenderise(blender_image_file, dirname(blend_file))

Now you have a UNIX path. If blend_file is an absolute path, 
unix_image_path will also be an absolute path. But if blend_file is a 
relative path (eg you opened up "tifftest8.blend") unix_image_path will 
be a relative path.



Does unix_image_path = unix_image_file?

Two possibilities here.
blend_file (and so unix_image_file) is an absolute path OR blend_file 
(and so unix_image_file) is a relative path.


I just want to check my understanding. If I supply the path to 
blend_file then it is absolute, and if I ask Python to generate the path 
to blend_file from within Blender it is relative. Have I got it?




You don't need to use realpath or abspath on that _unless_ you need to 
reference the file from any directory (i.e. _not_ relative to where you 
currently are).


If I decided not to supply the path and so ended up with a relative UNIX 
path, I could now use realpath or abspath to find the absolute path. 
Have I still got it?


#
I combined your unblenderise and your use of it (see below). Is my 
attempt error free?


It works very well. So thank you! I tested it with a Blend file that had 
two images, one in the same folder as the Blend file and the other was 
in a 

[issue37884] Optimize Fraction() and statistics.mean()

2019-08-19 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

AFAICT, no end-user has ever requested this ever.   Despite your insistence, we 
really don't have to clutter the math module with this.

We sometimes do have two or three repetitions of logic in the standard library; 
however, our needs tend to be much different from end-users. Also, we tend to 
benefit from the loose coupling and not turning every little detail into a 
published cross-module API.

Now that we've propagated the as_integer_ratio() into bool, int, float,  
Decimal, and Fraction, I propose we stop there.  This micro-problem to too 
small to warrant adding yet more machinery and API creep.

--

___
Python tracker 

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



[issue37884] Optimize Fraction() and statistics.mean()

2019-08-19 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

This issue if for optimization only. It does not expand the math module API.

Adding public math.as_integer_ratio() has other benefits (it allows to simplify 
the user code), but it is a different issue (see issue37822).

--

___
Python tracker 

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



[issue37884] Optimize Fraction() and statistics.mean()

2019-08-19 Thread Jeroen Demeyer


Jeroen Demeyer  added the comment:

> ISTM that small and probably unimportant opimizations shouldn't spill-over 
> into API feature creep.

The way I see it, the optimization is besides the point here. Regardless of 
performance, the added function is a useful feature to have to avoid forcing 
people to reinvent the wheel.  For example, would you want the exact same code 
duplicated for fractions.Fraction() and for statictics.mean()?

See also #37836 in case you didn't know about that issue.

--

___
Python tracker 

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



Re: Application Preferences

2019-08-19 Thread dboland9 via Python-list
Wow, what happened here?  I posted this to the Python discussion group as it is 
a Python question, not an SQL question.  That said, I agree with what you have 
said, and that was the plan.  Plans get changed.  A number of apps. allow the 
user to specify the location of data and configuration files, and for good 
reason.  Some folders are auto-backup in that they are either journaled or 
backed up multiple times per day.  I think that is the argument in this case.

Dave,

Sent with [ProtonMail](https://protonmail.com) Secure Email.

‐‐‐ Original Message ‐‐‐
On Monday, August 19, 2019 1:53 PM, Barry Scott  wrote:

>> On 19 Aug 2019, at 13:43, Dave via Python-list  
>> wrote:
>>
>> The plan for an app that I'm doing was to use SQLite for data and to hold 
>> the preference settings as some apps do.  The plan was changed last week to 
>> allow the user to select the location of the data files (SQLite) rather than 
>> putting it where the OS would dictate.  Ok with that, but it brings up some 
>> questions.  First, I will need to have a file that points to the location of 
>> the data file  since that can't be hard coded. Second, if I have to have a 
>> file that is likely part of the application group of files, would it make 
>> more sense to use a more traditional preferences file?  How have other 
>> Python app developers done in this case?
>
> There are expected locations for config files and data files on each OS.
>
> On macOS you would use ~/Library/Preferences/ and put a file or a folder of 
> files in there.
> The convention is use your website name as the base name of the  file or 
> folder.
> For example for scm-workbench I use: org.barrys-emacs.scm-workbench as the 
> folder name for
> all the scm-workbench files.
>
> On Windows you can use a file or folder in %APPDATA% that is named after your 
> app. You should
> find the folder by doing a win32 API call to get the value. See 
> getPreferencesDir()  in
> https://github.com/barry-scott/scm-workbench/blob/master/Source/Common/wb_platform_win32_specific.py
> for how to get the value.
>
> On Linux the XDG spec says that you should put config files in 
> ~/.config/ and data files
> in  ~/.local/share/. Doing XDG to the spec is a little involved. I 
> have some experimental
> code that implements the logic for config the XdgConfigPath class in:
> https://github.com/barry-scott/CLI-tools/blob/master/Source/smart_find/__init__.py
>
> Putting a file directly in the $HOME folder is no longer recommended.
>
> The format of the config data you are free to choose.
> I have been using JSON files recently as it allow for structured data.
>
> Barry
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Application Preferences

2019-08-19 Thread Dave via Python-list

On 8/19/19 1:53 PM, Barry Scott wrote:




On 19 Aug 2019, at 13:43, Dave via Python-list  wrote:

The plan for an app that I'm doing was to use SQLite for data and to hold the 
preference settings as some apps do.  The plan was changed last week to allow 
the user to select the location of the data files (SQLite) rather than putting 
it where the OS would dictate.  Ok with that, but it brings up some questions.  
First, I will need to have a file that points to the location of the data file  
since that can't be hard coded. Second, if I have to have a file that is likely 
part of the application group of files, would it make more sense to use a more 
traditional preferences file?  How have other Python app developers done in 
this case?


There are expected locations for config files and data files on each OS.

On macOS you would use ~/Library/Preferences/ and put a file or a folder of 
files in there.
The convention is use your website name as the base name of the  file or folder.
For example for scm-workbench I use: org.barrys-emacs.scm-workbench as the 
folder name for
all the scm-workbench files.

On Windows you can use a file or folder in %APPDATA% that is named after your 
app. You should
find the folder by doing a win32 API call to get the value. See 
getPreferencesDir()  in
https://github.com/barry-scott/scm-workbench/blob/master/Source/Common/wb_platform_win32_specific.py
 

for how to get the value.

On Linux the XDG spec says that you should put config files in 
~/.config/ and data files
in  ~/.local/share/. Doing XDG to the spec is a little involved. I 
have some experimental
code that implements the logic for config the XdgConfigPath class in:
https://github.com/barry-scott/CLI-tools/blob/master/Source/smart_find/__init__.py 


Putting a file directly in the $HOME folder is no longer recommended.

The format of the config data you are free to choose.
I have been using JSON files recently as it allow for structured data.


Barry



Barry, and all,

I agree that various OS's have a favorite place to put things.  Python 
has a library that will help.  However, there are valid reasons to let 
the customer choose.  Perhaps the drive/folder is a journaling one, or 
one that is backed up multiple times per day.  My take is to start with 
the OS solution, but let the customer decide.


How did this thread show up in the SQLite mailing list anyway?  Really 
has nothing to do with SQLite that I can see.


Dave,


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


[issue37888] Sub-interpreters : Confusing docs about state after calling Py_NewInterpreter()

2019-08-19 Thread Joannah Nanjekye


New submission from Joannah Nanjekye :

In the documentation for Py_NewInterpreter(): It is said that :

The return value points to the first thread state created in the new 
sub-interpreter.  This thread state is made in the current thread state.

I think changing :

This thread state is made in the current thread state.

To:

This thread state is made the current thread state.

Sounds good. Since a call such as:

substate = Py_NewInterpreter()

makes *substate* the current state. no?

The *in* takes me in a different direction of thought.

--
messages: 349964
nosy: nanjekyejoannah
priority: normal
severity: normal
status: open
title: Sub-interpreters : Confusing docs about state after calling 
Py_NewInterpreter()

___
Python tracker 

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



Re: Application Preferences

2019-08-19 Thread Barry Scott



> On 19 Aug 2019, at 13:43, Dave via Python-list  wrote:
> 
> The plan for an app that I'm doing was to use SQLite for data and to hold the 
> preference settings as some apps do.  The plan was changed last week to allow 
> the user to select the location of the data files (SQLite) rather than 
> putting it where the OS would dictate.  Ok with that, but it brings up some 
> questions.  First, I will need to have a file that points to the location of 
> the data file  since that can't be hard coded. Second, if I have to have a 
> file that is likely part of the application group of files, would it make 
> more sense to use a more traditional preferences file?  How have other Python 
> app developers done in this case?

There are expected locations for config files and data files on each OS.

On macOS you would use ~/Library/Preferences/ and put a file or a folder of 
files in there.
The convention is use your website name as the base name of the  file or folder.
For example for scm-workbench I use: org.barrys-emacs.scm-workbench as the 
folder name for
all the scm-workbench files.

On Windows you can use a file or folder in %APPDATA% that is named after your 
app. You should
find the folder by doing a win32 API call to get the value. See 
getPreferencesDir()  in
https://github.com/barry-scott/scm-workbench/blob/master/Source/Common/wb_platform_win32_specific.py
 

for how to get the value.

On Linux the XDG spec says that you should put config files in 
~/.config/ and data files
in  ~/.local/share/. Doing XDG to the spec is a little involved. I 
have some experimental
code that implements the logic for config the XdgConfigPath class in:
https://github.com/barry-scott/CLI-tools/blob/master/Source/smart_find/__init__.py
 


Putting a file directly in the $HOME folder is no longer recommended.

The format of the config data you are free to choose.
I have been using JSON files recently as it allow for structured data.


Barry

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


[issue37875] gzip module any difference for compressing png file in version 2.X and 3.X

2019-08-19 Thread Zachary Ware


Change by Zachary Ware :


--
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

___
Python tracker 

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



Re: My pseudocode to Python?

2019-08-19 Thread Rob Gaddi

On 8/19/19 10:43 AM, Stefan Ram wrote:

   Can someone kindly translate my pseudocode to terse Python:

list = \
[ 'afaueghauihaiuhgaiuhgaiuhgaeihui',
   'erghariughauieghaiughahgaihgaiuhgaiuh',
   'rejganregairghaiurghaiuhgauihgauighaei',
   if x: 'argaeruighaiurhauirguiahuiahgiauhgaeuihi',
   'reiugaheirughauierhgauiaeihauiehgiuaehuih'
   'ejiaeigaiuegreaiugheiugheaiughauighaiughaiu'
   'egairughauirghauiruiegihgruiehgiuaehgiaue' ]

   ? I want the list to have the seven strings shown as entries
   if bool(x) is True, but otherwise the list should only have
   six entries - without the entry directly behind "if x: ".




mylist = ['a', 'b', 'c', 'd', 'e', 'f', 'g']
if not x:
   del mylist[3]


--
Rob Gaddi, Highland Technology -- www.highlandtechnology.com
Email address domain is currently out of order.  See above to fix.
--
https://mail.python.org/mailman/listinfo/python-list


[issue37884] Optimize Fraction() and statistics.mean()

2019-08-19 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Mark, I don't think the math module API should be expanded for 
as_integer_ratio().  ISTM that small and probably unimportant opimizations 
shouldn't spill-over into API feature creep.  What do you think?

--
assignee:  -> mark.dickinson

___
Python tracker 

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



How to login remote windos device using python

2019-08-19 Thread Iranna Mathapati
Hi Team,

can you please let me know, How to login the remote Windows machine using
python??

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


[issue37764] email.Message.as_string infinite loop

2019-08-19 Thread Ashwin Ramaswami


Ashwin Ramaswami  added the comment:

Thanks, I've fixed the first case as you suggested.

I found an example of the 2nd case -- '=?utf-8?q?=somevalue?=' -- which causes 
the method to hang. I've added a fix, though I'm not sure if it treats the 
string properly -- it parses it as '=?utf-8?q?=somevalue?=' and doesn't raise 
any defects. Is that the behavior we would want?

--

___
Python tracker 

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



Re: Meanwhile Norwegian trolls created ...

2019-08-19 Thread John Ladasky
On Saturday, August 17, 2019 at 2:40:14 AM UTC-7, Abdur-Rahmaan Janhangeer 
wrote:
> But it is not so easy to combine different memory management paradigms.

Oh, I feel this.  I love the look and feel of PyQt5, but object management has 
bitten me more than once.
-- 
https://mail.python.org/mailman/listinfo/python-list


Xlabel and ylabel are not shown

2019-08-19 Thread Amirreza Heidari
plt.figure(1)
plt.plot(history.history["loss"], "b", label="Mean Square Error of training")
plt.plot(history.history["val_loss"], "g", label="Mean Square Error of 
validation")
plt.legend()
plt.xlabel("Epoche")
plt.ylabel("Mean Square Error")
plt.xlim(0,200)
plt.show()
plt.savefig(r"C:\Users\aheidari\Dropbox\Dissertation\primary hot water use 
prediction\Diagrams\UnivariateTrainingerror.png", dpi=1200)
-- 
https://mail.python.org/mailman/listinfo/python-list


Using scapy to defeat the dns poisoning, is it possible?

2019-08-19 Thread Hongyi Zhao
Hi,

See my following testings:

$ dig www.twitter.com @8.8.8.8 +short
66.220.147.44

While the tcpdump gives the following at the meanwhile:


$ sudo tcpdump -n 'host 8.8.8.8 and port 53'
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on enp5s0, link-type EN10MB (Ethernet), capture size 262144 
bytes
06:49:35.779852 IP 192.168.1.2.59443 > 8.8.8.8.53: 56457+ [1au] A? 
www.twitter.com. (44)
06:49:35.818492 IP 8.8.8.8.53 > 192.168.1.2.59443: 56457 1/0/0 A 
66.220.147.44 (49)
06:49:35.818531 IP 8.8.8.8.53 > 192.168.1.2.59443: 56457 1/0/0 A 
69.171.248.65 (49)
06:49:35.824454 IP 8.8.8.8.53 > 192.168.1.2.59443: 56457 3/0/1 CNAME 
twitter.com., A 104.244.42.129, A 104.244.42.65 (90)


As you can see, the dns is poisoned, is it possible to defeat this with 
scapy or some techniques with python?

Regards
-- 
.: Hongyi Zhao [ hongyi.zhao AT gmail.com ] Free as in Freedom :.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue37886] PyStructSequence_UnnamedField not exported

2019-08-19 Thread Jeff Robbins


Jeff Robbins  added the comment:

Editing one line in structseq.h seems to fix the issue.

I changed this

extern char* PyStructSequence_UnnamedField;

to

PyAPI_DATA(char*) PyStructSequence_UnnamedField;

rebuilt, and now my C extension can use PyStructSequence_UnnamedField.

--
Added file: https://bugs.python.org/file48551/structseq.h

___
Python tracker 

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



[issue37878] Sub-Interpreters : Document PyThreadState_DeleteCurrent()

2019-08-19 Thread Joannah Nanjekye


Joannah Nanjekye  added the comment:

>From what I know the GIL is released by calling PyEval_ReleaseThread() or 
>PyEval_SaveThread(). 

I see we can use PyThreadState_Delete() to clean up-specifically destroy thread 
state but does not release the GIL and requires a thread state. On the other 
hand, PyThreadState_DeleteCurrent() allows to both clean up the current thread 
state - no thread state is required as well release the GIL which is 
convenient. I would not fight so much to keep it public given we have 
PyEval_ReleaseThread() or PyEval_SaveThread().

--

___
Python tracker 

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



Re: Application Preferences

2019-08-19 Thread Malcolm Greene
Hi Dave,

> I agree that a traditional INI file is the easiest way, especially since 
> Python supports them.  So if I understand you, your apps look like this:

Yes with the following nuance for our application sized scripts that require 
multiple configuration files. In this latter case, we place all config files in 
a ../conf folder (see the OR option below).

-App Dir
   |
   +-App Code Folder (src)
  |
  +-App INI file

OR

-App Dir
   |
   +-conf
  |
  +-App INI file

AND

-Home Folder (the default location, but user can select other locations)
   |
   +-App INI Folder
  |
  +-App INI file

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


[issue37887] some leak in the compiler_assert function

2019-08-19 Thread hai shi


New submission from hai shi :

Some reference leak in compiler_assert function, due to not using  
Py_DECREF(assertion_error) before return. And having a question about code 
order in compiler_assert function.

--
components: Interpreter Core
files: compiler_assert.patch
keywords: patch
messages: 349959
nosy: pitrou, shihai1991, vstinner
priority: normal
severity: normal
status: open
title: some leak in the compiler_assert function
type: resource usage
versions: Python 3.9
Added file: https://bugs.python.org/file48550/compiler_assert.patch

___
Python tracker 

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



[issue37835] typing.get_type_hints wrong namespace for forward-declaration of inner class

2019-08-19 Thread Ivan Levkivskyi


Ivan Levkivskyi  added the comment:

Thanks for reporting!

I spent some time thinking about this and I can't find any reasonable way of 
doing this, sorry. Anyway, let's keep this open, maybe someone will come up 
with a proposal.

--

___
Python tracker 

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



[issue34155] email.utils.parseaddr mistakenly parse an email

2019-08-19 Thread STINNER Victor


STINNER Victor  added the comment:

> Created a backport PR for 3.5.

Thanks. I reviewed it (LGTM).

What about Python 2.7, it's also vulnerable, no?

--

___
Python tracker 

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



Re: Application Preferences

2019-08-19 Thread Dave via Python-list

On 8/19/19 9:22 AM, Malcolm Greene wrote:

Hi Dave,


The plan for an app that I'm doing was to use SQLite for data and to hold the 
preference settings as some apps do.  The plan was changed last week to allow 
the user to select the location of the data files (SQLite) rather than putting 
it where the OS would dictate.  Ok with that, but it brings up some questions.  
First, I will need to have a file that points to the location of the data file  
since that can't be hard coded. Second, if I have to have a file that is likely 
part of the application group of files, would it make more sense to use a more 
traditional preferences file?  How have other Python app developers done in 
this case?


We handle the "where is my config file" question by defaulting to script's 
current directory, then a script-specific folder within their home directory. Users can 
override that behavior by setting a script specific environment variable or by using a 
command line switch to point to a different location or config file.

We store our preferences in an INI style config file which we've found easier 
to support when there's problems.

Malcolm



Malcolm,

Thanks for the reply.  I agree that a traditional INI file is the 
easiest way, especially since Python supports them.  So if I understand 
you, your apps look like this:


-App Dir
  |
  +-App Code Folder
 |
 +-(File to direct to home folder)

-Home Folder (the default location, but user can select other locations)
  |
  +-App INI Folder
 |
 +-App INI file
--
https://mail.python.org/mailman/listinfo/python-list


Re: Application Preferences

2019-08-19 Thread Malcolm Greene
Hi Dave,

> The plan for an app that I'm doing was to use SQLite for data and to hold the 
> preference settings as some apps do.  The plan was changed last week to allow 
> the user to select the location of the data files (SQLite) rather than 
> putting it where the OS would dictate.  Ok with that, but it brings up some 
> questions.  First, I will need to have a file that points to the location of 
> the data file  since that can't be hard coded. Second, if I have to have a 
> file that is likely part of the application group of files, would it make 
> more sense to use a more traditional preferences file?  How have other Python 
> app developers done in this case?

We handle the "where is my config file" question by defaulting to script's 
current directory, then a script-specific folder within their home directory. 
Users can override that behavior by setting a script specific environment 
variable or by using a command line switch to point to a different location or 
config file.

We store our preferences in an INI style config file which we've found easier 
to support when there's problems.

Malcolm


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


Pythran 0.9.3 - Hañv

2019-08-19 Thread Serge Guelton
Hi folks,

I just released version 0.9.3 of the Pythran package,

Short reminder: Pythran is an ahead-of-time compiler for scientific Python,
with a focus on high-level numerical kernels, parallelism and vectorisation.

Here is a simple kernel example, with a pythran annotation. Note that that
kernel is still Python-compatible (from 
https://stackoverflow.com/questions/57199248/) :

import numpy as np
#pythran export col_sum(int[:,:] or float[:,:], int[:])
def col_sum(data, idx):
return data.T[idx].sum(0)

The Pythran package is available on PyPI, Github and Conda

https://pypi.org/project/pythran/
https://anaconda.org/conda-forge/pythran
https://github.com/serge-sans-paille/pythran

The interested reader can have a look to the changelog for details

https://pythran.readthedocs.io/en/latest/Changelog.html

Long story short: bug fixes and better 32bit arch support. Plus (Thanks to Miro
Hrončok), pythran is now available on Fedora \o/

Huge thanks to all contributors and bug reporters:

Jean Laroche
Yann Diorcet
DWesl
Miro Hrončok
Piotr Bartmann
Jochen Schröder
Sylwester Arabas
Marti Bosch
rorroiga
Pierre Augier
Anubhab Haldar
nbecker


--
Python-announce-list mailing list -- python-announce-list@python.org
To unsubscribe send an email to python-announce-list-le...@python.org
https://mail.python.org/mailman3/lists/python-announce-list.python.org/

Support the Python Software Foundation:
http://www.python.org/psf/donations/


Application Preferences

2019-08-19 Thread Dave via Python-list
The plan for an app that I'm doing was to use SQLite for data and to 
hold the preference settings as some apps do.  The plan was changed last 
week to allow the user to select the location of the data files (SQLite) 
rather than putting it where the OS would dictate.  Ok with that, but it 
brings up some questions.  First, I will need to have a file that points 
to the location of the data file  since that can't be hard coded. 
Second, if I have to have a file that is likely part of the application 
group of files, would it make more sense to use a more traditional 
preferences file?  How have other Python app developers done in this case?


Thanks,
Dave
--
https://mail.python.org/mailman/listinfo/python-list


[issue37886] PyStructSequence_UnnamedField not exported

2019-08-19 Thread Jeff Robbins


New submission from Jeff Robbins :

Python 3.8.0b3 has the fixed 
https://docs.python.org/3/c-api/tuple.html#c.PyStructSequence_NewType, but one 
of the documented features of PyStructSequence is the special 
https://docs.python.org/3/c-api/tuple.html#c.PyStructSequence_UnnamedField 
which is meant to be used for unnamed (and presumably also "hidden") fields.

However, this variable is not "exported" (via __declspec(dllexport) or the 
relevant Python C macro) and so my C extension cannot "import" it and use it.

My guess is that this passed testing because the only tests using it are 
internal modules linked into python38.dll, which are happy with the `extern` in 
the header:

Include\structseq.h:extern char* PyStructSequence_UnnamedField;

--
components: Windows
messages: 349956
nosy: je...@livedata.com, paul.moore, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: PyStructSequence_UnnamedField not exported
type: compile error
versions: Python 3.8

___
Python tracker 

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



Re: absolute path to a file

2019-08-19 Thread Cameron Simpson

On 19Aug2019 08:52, Paul St George  wrote:

On 19/08/2019 01:31, Cameron Simpson wrote:

On 18Aug2019 17:29, Paul St George  wrote:

On 18/08/2019 02:03, Cameron Simpson wrote:
1: Is image01.tif a real existing file when you ran this code?
Yes. image01.tif is real, existing and apparent.
But in what directory? What is its _actual_ full path as you expect it 
to be?


Aha. The Blender file that I am using to test this on has two images 
used as textures. They reside at:

/Users/Lion/Desktop/test8/image01.tif
/Users/Lion/Desktop/images/image02.tif

The Blender file is at /Users/Lion/Desktop/test8/tifftest8.blend


There's a remark on that web page I mentioned that suggests that the 
leading '//' indicates the filename is relative to the Blender model, so 
the context directory for the '//' is likely /Users/Lion/Desktop/test8.


(Chris and Peter lead me to believe that Blender has a special kind 
of relative path. The double slashes replace the path to the blend 
file’s directory.) realpath has done something but I know not what.


realpath needs a UNIX path. Your //image01.tif isn't a UNIX path, it is 
a special Blender path. First you need to convert it. By replacing '//' 
with the blend file's directory. Then you can call realpath. If you 
still need to.


[...snip...]

So you might want to write an unBlenderiser (untested example):

 from os.path import isabs, join as joinpath

 def unblenderise(filename, context_dir=None):
   # transmute Blender "relative" path
   if filename.startswith('//'):
 filename = filename[2:]
   if not isabs(filename) and context_dir is not None:
 # attach the filename to `context_dir` if supplied
 filename = joinpath(context_dir, filename)
   return filename

The idea here is to get back a meaningful UNIX path from a Blender 
path. It first strips a leading '//'. Next, _if_ the filename is 
relative _and_ you supplied the optional context_dir (eg the 
directory used for a file brwoser dialogue box), then it prepends 
that context directory.


This _does not_ call abspath or realpath or anything, it just 
returns a filename which can be used with them.


The idea is that if you know where image01.tif lives, you could 
supply that as the context directory.


Yes! Until Peter Otten's timely intervention, I was trying to do this 
and had managed to join the 
path_to_the_folder_that_contains_the_Blender_file to 
the_name_of_the_image (stripped of its preceding slashes).


Your unblenderise looks much better than my nascent saneblender so 
thank you. I will explore more!


Looks like you want wd=os.path.dirname(path_of_blend_file).

Does it depend on knowing where image01.tif lives and manually 
supplying that?


Sort of.

What you've got is '//image01.tif', which is Blender's special notation 
indicating a filename relative to the blend file's directory. All the 
Python library stuff expects an OS path (OS==UNIX on a Mac). So you want 
to convert that into a UNIX path.  For example:


   from os.path import dirname

   # Get this from somewhere just hardwiring it for the example.
   # Maybe from your 'n' object below?
   blend_file = '/Users/Lion/Desktop/test8/tifftest8.blend'

   blender_image_file = n.image.filename

   unix_image_file = unblenderise(blender_image_file, dirname(blend_file))

Now you have a UNIX path. If blend_file is an absolute path, 
unix_image_path will also be an absolute path. But if blend_file is a 
relative path (eg you opened up "tifftest8.blend") unix_image_path will 
be a relative path.


You don't need to use realpath or abspath on that _unless_ you need to 
reference the file from any directory (i.e. _not_ relative to where you 
currently are).


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


[issue37866] PyModule_GetState Segmentation fault when called Py_Initialize

2019-08-19 Thread STINNER Victor


STINNER Victor  added the comment:

Python 3.5 no longer accept bug fixes. Are you able to reproduce the bug with 
Python 3.8, or Python 3.7?

> the crash file came out when i tried to call Py_Initialize in a C file.

Can you provide this file?

What is your OS and OS version? How did you install Python?

--

___
Python tracker 

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



[issue37878] Sub-Interpreters : Document PyThreadState_DeleteCurrent()

2019-08-19 Thread STINNER Victor


STINNER Victor  added the comment:

I'm not sure why PyThreadState_DeleteCurrent() is exposed. Why would anyone use 
it?

It is used internally by the _thread module when the thread function completes.

I suggest to make the function internal instead of documenting it.

Eric, Joannah: what do you think?

--

___
Python tracker 

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



[issue37565] test_faulthandler: test_register_chain() crash with SIGSEGV (signal 11) on Skylake chipset

2019-08-19 Thread STINNER Victor


STINNER Victor  added the comment:

Bennet Fauber:
> It would appear that jshelly was correct and this is resolved by fixing the 
> problem isolated in issue 21131, which was closed and a patch was committed.

Great! I close this issue as a duplicate of bpo-21131.

--
resolution:  -> duplicate
stage:  -> resolved
status: open -> closed
superseder:  -> test_faulthandler.test_register_chain fails on 64bit ppc/arm 
with kernel >= 3.10

___
Python tracker 

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



[issue18835] Add PyMem_AlignedAlloc()

2019-08-19 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +15052
pull_request: https://github.com/python/cpython/pull/15333

___
Python tracker 

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



[issue37732] Possible uninitialized variable in Objects/obmalloc.c

2019-08-19 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +15051
pull_request: https://github.com/python/cpython/pull/15333

___
Python tracker 

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



[issue37869] Compilation warning on GCC version 7.4.0-1ubuntu1~18.04.1

2019-08-19 Thread STINNER Victor


Change by STINNER Victor :


--
stage:  -> resolved
status: open -> closed
superseder:  -> Possible uninitialized variable in Objects/obmalloc.c

___
Python tracker 

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



[issue37732] Possible uninitialized variable in Objects/obmalloc.c

2019-08-19 Thread STINNER Victor


STINNER Victor  added the comment:

bpo-37869 has been marked as a duplicate of this issue.

--
nosy: +vstinner

___
Python tracker 

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



[issue37869] Compilation warning on GCC version 7.4.0-1ubuntu1~18.04.1

2019-08-19 Thread STINNER Victor


STINNER Victor  added the comment:

Duplicate of bpo-37732.

--

___
Python tracker 

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



[issue36502] str.isspace() for U+00A0 and U+202F differs from document

2019-08-19 Thread STINNER Victor


STINNER Victor  added the comment:

str.isspace() documentation has been fixed, thanks Greg Price for the fix! I 
close the issue.

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



[issue21131] test_faulthandler.test_register_chain fails on 64bit ppc/arm with kernel >= 3.10

2019-08-19 Thread STINNER Victor


STINNER Victor  added the comment:

> Its interesting to read the comment on the IA64 definition for SIGSTKSZ:

Python doesn't support IA64 architecture.

Note: I'm not sure that this architecture is going to survive in the long 
term... More and more systems stopped to support it.


> Well, one argument for the dynamic approach is that existing python
binaries can adjust without needing to be respun for new CPUs.

PR 13649 gets the default thread stack size, it doesn't get SIGSTKSZ. I expect 
a thread stack size to be way larger than SIGSTKSZ.

For on my Fedora 30 (Linux kernel 5.1.19-300.fc30.x86_64, 
glibc-2.29-15.fc30.x86_64) on x86-64, SIGSTKSZ is just 8 KiB (8192 bytes) 
whereas pthread_attr_getstacksize() returns 8 MiB (8388608 bytes).

As I already wrote, using 8 MiB instead of 8 KiB looks like a waste of memory: 
faulthandler is only useful for stack overflow, which is a very unlikely bug.

--

___
Python tracker 

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



[issue36502] str.isspace() for U+00A0 and U+202F differs from document

2019-08-19 Thread miss-islington


miss-islington  added the comment:


New changeset 0fcdd8d6d67f57733203fc79e6a07a89b924a390 by Miss Islington (bot) 
in branch '3.7':
bpo-36502: Correct documentation of str.isspace() (GH-15019) (GH-15296)
https://github.com/python/cpython/commit/0fcdd8d6d67f57733203fc79e6a07a89b924a390


--
nosy: +miss-islington

___
Python tracker 

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



[issue36502] str.isspace() for U+00A0 and U+202F differs from document

2019-08-19 Thread miss-islington


Change by miss-islington :


--
pull_requests: +15050
pull_request: https://github.com/python/cpython/pull/15332

___
Python tracker 

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



[issue36502] str.isspace() for U+00A0 and U+202F differs from document

2019-08-19 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 8c1c426a631ba02357112657193f82c58d3e08b4 by Victor Stinner (Greg 
Price) in branch '3.8':
bpo-36502: Correct documentation of str.isspace() (GH-15019) (GH-15296)
https://github.com/python/cpython/commit/8c1c426a631ba02357112657193f82c58d3e08b4


--

___
Python tracker 

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



Re: Which editor is suited for view a python package's source?

2019-08-19 Thread Nick Sarbicki
PyCharm takes you to the source code within the editor for any
variables/functions/classes/modules if you ctrl+click on what you want to
see. It allows you to browse the relevant bits of code quickly, as well as
let you change them in your local environment if need be.

That way you don't have to download the source separately, you can just use
it as a normal dependency.

But if you want to view the source of a project in isolation I imagine any
common editor will suffice. Personally I'll tend to look where the source
is hosted (GitHub, GitLab etc) instead of downloading it. But I can
understand why some may not trust this.

On Mon, 19 Aug 2019, 10:17 ,  wrote:

> I like to download one package's source and study it in an editor. It
> allows me to open the whole package as a project and let me jump from a
> reference in one file to its definition in another file back and forth. It
> will be even better if it can handle the import modules too. (Maybe this is
> too much:-)
>
> Can anyone recommend such a tool?
>
> --Jach
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Which editor is suited for view a python package's source?

2019-08-19 Thread jfong
I like to download one package's source and study it in an editor. It allows me 
to open the whole package as a project and let me jump from a reference in one 
file to its definition in another file back and forth. It will be even better 
if it can handle the import modules too. (Maybe this is too much:-)

Can anyone recommend such a tool?

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


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

2019-08-19 Thread Jeroen Demeyer


Jeroen Demeyer  added the comment:

> Sorry, but I do not understand why adding Fraction.as_integer_ratio() 
> prevents adding math.as_integer_ratio().

I also support a public function for that. It seems that we're planning this 
"as_integer_ratio" thing to become public API, so why not have a function as 
Serhiy proposes?

I consider the situation with as_integer_ratio() very analogous to __index__ 
where we have operator.index(), so I would actually suggest 
operator.as_integer_ratio() but that's bikeshedding territory.

--
nosy: +jdemeyer

___
Python tracker 

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



[issue37836] Support .as_integer_ratio() in fractions.Fraction

2019-08-19 Thread Jeroen Demeyer


Jeroen Demeyer  added the comment:

> I afraid this can slow down the Fraction constructor.

No, it doesn't! It even speeds up the constructor in some cases:

./python -m perf timeit --duplicate 200 -s 'from fractions import Fraction; x = 
1' 'Fraction(x)'
BEFORE: Mean +- std dev: 826 ns +- 20 ns
AFTER:  Mean +- std dev: 814 ns +- 17 ns

./python -m perf timeit --duplicate 200 -s 'from fractions import Fraction; x = 
1' 'Fraction(x, x)'
BEFORE: Mean +- std dev: 1.44 us +- 0.03 us
AFTER:  Mean +- std dev: 1.46 us +- 0.02 us

./python -m perf timeit --duplicate 200 -s 'from fractions import Fraction; x = 
Fraction(1)' 'Fraction(x)'
BEFORE: Mean +- std dev: 1.64 us +- 0.03 us
AFTER:  Mean +- std dev: 1.30 us +- 0.04 us

./python -m perf timeit --duplicate 200 -s 'from fractions import Fraction; x = 
Fraction(1)' 'Fraction(x, x)'
BEFORE: Mean +- std dev: 3.03 us +- 0.05 us
AFTER:  Mean +- std dev: 2.34 us +- 0.06 us

./python -m perf timeit --duplicate 200 -s 'from fractions import Fraction; x = 
1.0' 'Fraction(x)'
BEFORE: Mean +- std dev: 1.82 us +- 0.02 us
AFTER:  Mean +- std dev: 1.29 us +- 0.04 us

--

___
Python tracker 

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



[issue37885] venv: Don't produce unbound variable warning on deactivate

2019-08-19 Thread Daniel Abrahamsson


Change by Daniel Abrahamsson :


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

___
Python tracker 

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



[issue37885] venv: Don't produce unbound variable warning on deactivate

2019-08-19 Thread Daniel Abrahamsson


New submission from Daniel Abrahamsson :

Running deactivate from a bash shell configured to treat undefined variables as 
errors (`set -u`) produces a warning:

``` 
$ python3 -m venv test
$ source test/bin/activate
(test) $ deactivate
-bash: $1: unbound variable
```

--
components: Library (Lib)
messages: 349944
nosy: danabr
priority: normal
severity: normal
status: open
title: venv: Don't produce unbound variable warning on deactivate
type: enhancement

___
Python tracker 

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



[issue37884] Optimize Fraction() and statistics.mean()

2019-08-19 Thread Jeroen Demeyer


Jeroen Demeyer  added the comment:

> There is a 14% regression in creating a Fraction from an integer

Isn't that the main use case? I suggest to keep the special case for 'int' as 
fast path to avoid this regression.

--
nosy: +jdemeyer

___
Python tracker 

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



[issue37836] Support .as_integer_ratio() in fractions.Fraction

2019-08-19 Thread Jeroen Demeyer


Jeroen Demeyer  added the comment:

> See issue37884 which uses a C accelerator.

Note that that doesn't replace this issue, because I need to support 
as_integer_ratio both in the *numerator* and *denominator*.

--

___
Python tracker 

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



[issue37664] Update bundled pip and setuptools

2019-08-19 Thread Pradyun Gedam


Pradyun Gedam  added the comment:

There wasn't a new setuptools release when I updated these the last time,
IIRC.

Anyway, I'll cut a new release for pip, file a new b.p.o. issue and get to
updating both of these sometime this week.

On Mon, 19 Aug 2019 at 11:20 AM, Inada Naoki  wrote:

>
> Inada Naoki  added the comment:
>
> When updating pip next time, please update setuptools too.
> https://setuptools.readthedocs.io/en/latest/history.html#v41-1-0
>
> > #1788: Changed compatibility fallback logic for html.unescape to avoid
> accessing HTMLParser.unescape when not necessary. HTMLParser.unescape is
> deprecated and will be removed in Python 3.9.
>
> This is blocking #37328.
>
> --
> nosy: +inada.naoki
>
> ___
> Python tracker 
> 
> ___
>

--

___
Python tracker 

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



Re: absolute path to a file

2019-08-19 Thread Paul St George

On 19/08/2019 01:31, Cameron Simpson wrote:

Paul, I can see we must train you in the interleaved response style :-)

On 18Aug2019 17:29, Paul St George  wrote:

On 18/08/2019 02:03, Cameron Simpson wrote:
1: Is image01.tif a real existing file when you ran this code?

Yes. image01.tif is real, existing and apparent.


But in what directory? What is its _actual_ full path as you expect it 
to be?


Aha. The Blender file that I am using to test this on has two images 
used as textures. They reside at:

/Users/Lion/Desktop/test8/image01.tif
/Users/Lion/Desktop/images/image02.tif

The Blender file is at /Users/Lion/Desktop/test8/tifftest8.blend



print(obj.name,'uses',n.image.name,'saved at',n.image.filepath, 

'which is at', realpath(n.image.filepath))
gives:
Plane uses image01.tif saved at //image01.tif which is at /image01.tif

(Chris and Peter lead me to believe that Blender has a special kind of 
relative path. The double slashes replace the path to the blend file’s 
directory.) realpath has done something but I know not what.


I expect that realpath has normalised the string '//image01.tif' into 
the normal UNIX path '/image01.tif'. Because realpath works with UNIX 
paths, '//image01.tif' is not the path to an existing file from its 
point of view, because that would be in / ('//' is equivalent to '/' in 
UNIX, because multiple slashes coalesce).



2a:
What is your current working directory when you run this code?

Well, there at least two answers to that question. Within Blender's 
Python Console:

os.getcwd()

‘/‘


Did you run the other code in Blender's Console?


I ran this from Blender's console:
>>>filename = "/Users/Lion/Desktop/test8/readout.py"
>>>exec(compile(open(filename).read(), filename, 'exec'))

I ran os.getcwd() from both within /Users/Lion/Desktop/test8/readout.py
and directly within the Blender console.

>> ‘/‘



The thing to bear in mind is that on many GUI desktops a GUI 
application's working directory may be '/'. Specificly, _not_ your home 
directory. This is because they're invoked (usually) by the desktop 
manager programme. And also because it sidesteps awkward situations like 
having the working directory in some removable medium such as a thumb 
drive, which might get removed.


So the Blender CWD is _not_ your home directory or whatever directory 
your terminal prompt may be in.


And therefore things that depend on the current directory will behave 
counterintuitively. In your case, by getting '/' from os.getcwd().


So: if the image01.tif file is _not_ in '/' (which I expect to be the 
case) then Python's realpath will be doing a lexical operation because 
as far as it is concerned the pathname ('//image01.tif') is not the path 
of an existing file. And its getcwd() isn't what you expect, thus the 
result not being what you want.



But I am *guessing* the real location of the CWD is
/Applications/Blender/blender.app/Contents/Resources/2.79/scripts


This isn't a meaningful statement to me. The CWD is the working 
directory of the python interpreter running your code. If that is the 
Blender Console and the consale says the cwd is '/', then that's what it 
is.


In particular, if you invoke some Python script as /path/to/script.py, 
your cwd does not magicly become '/path/to'.


The cwd is a per process ephemeral thing, which is why the shell "cd" 
command works: it switches the working directory for the shell, and that 
context is inherited by child processes (your commands).


I tried using realpath, bpy.path.abspath, and os.path.abspath on this 
forward slash but nothing changed.


Because the leading slash makes it an absolute path by UNIX rules. The 
cwd never gets a look in; it is irrelevant.



For amusement, I also tried print(os.path.join(os.getcwd(), os.getcwd()))


os.path.join is pretty lexical; it largely exists to avoid wiring in an 
OS-dependent path separator into your code (eg Windows' '\\' versus UNIX 
'/' or OS9 ':'). But it notices an absolute path in the sequence and 
discards earlier values, so the second getcwd is kept; not sure why this 
is useful behaviour. But putting an absolute path on the right hand end 
of a join isn't meaningful either, so the result is at best amusing anyway.



2b:
If the underlying OS realpath fails, the Python library function might 
fall back on os.path.join(os.getcwd(), filename).


It should, shouldn’t it. But it doesn’t.


Well, I over simplified. If your path doesn't stat() (== "resolve 
directly to a filesystem object", on which the OS realpath relies), 
Python's realpath seems to be doing a _purely lexical_ path 
normalisation, like os.path.normpath.


So, what have you passed in? '//image01.tif'. That is an absolute path. 
The cwd is not relevant, realpath runs with it as is. 'image01.tif' is 
not in '/', so it doesn't stat(), so we just normalise the path to 
'/image01.tif'.


Alternative values:

'image01.tif' (your n.image.filepath[2:], to skip the Blender specific 
'//' relative pathname notation). 

[issue37836] Support .as_integer_ratio() in fractions.Fraction

2019-08-19 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

See issue37884 which uses a C accelerator.

--

___
Python tracker 

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



[issue37884] Optimize Fraction() and statistics.mean()

2019-08-19 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


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

___
Python tracker 

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



[issue37884] Optimize Fraction() and statistics.mean()

2019-08-19 Thread Serhiy Storchaka


New submission from Serhiy Storchaka :

The proposed PR optimizes the Fraction constructor and statistics.mean() (and 
several other statistics functions) by using a private helper implemented in C 
which abstracts converting a number to an integer ratio.

$ ./python -m timeit -s "from fractions import Fraction as F" "F(123)"
50 loops, best of 5: 655 nsec per loop
50 loops, best of 5: 749 nsec per loop

$ ./python -m timeit -s "from fractions import Fraction as F" "F(1.23)"
20 loops, best of 5: 1.29 usec per loop
20 loops, best of 5: 1.03 usec per loop

$ ./python -m timeit -s "from fractions import Fraction as F; f = F(22, 7)" 
"F(f)"
20 loops, best of 5: 1.17 usec per loop
50 loops, best of 5: 899 nsec per loop

$ ./python -m timeit -s "from fractions import Fraction as F; from decimal 
import Decimal as D; d = D('1.23')" "F(d)"
20 loops, best of 5: 1.64 usec per loop
20 loops, best of 5: 1.29 usec per loop


$ ./python -m timeit -s "from statistics import mean; a = [1]*1000" "mean(a)"
500 loops, best of 5: 456 usec per loop
1000 loops, best of 5: 321 usec per loop

$ ./python -m timeit -s "from statistics import mean; a = [1.23]*1000" "mean(a)"
500 loops, best of 5: 645 usec per loop
500 loops, best of 5: 659 usec per loop

$ ./python -m timeit -s "from statistics import mean; from fractions import 
Fraction as F; a = [F(22, 7)]*1000" "mean(a)"
500 loops, best of 5: 637 usec per loop
500 loops, best of 5: 490 usec per loop

$ ./python -m timeit -s "from statistics import mean; from decimal import 
Decimal as D; a = [D('1.23')]*1000" "mean(a)"
500 loops, best of 5: 946 usec per loop
500 loops, best of 5: 915 usec per loop

There is a 14% regression in creating a Fraction from an integer, but for 
non-integer numbers it gains 25% speed up. The effect on statistics.mean() 
varies from insignificant to +40%.

--
components: Library (Lib)
messages: 349939
nosy: mark.dickinson, rhettinger, serhiy.storchaka, steven.daprano
priority: normal
severity: normal
status: open
title: Optimize Fraction() and statistics.mean()
type: performance
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



[issue37873] unittest: execute tests in parallel

2019-08-19 Thread Terry J. Reedy


Change by Terry J. Reedy :


--
nosy: +ezio.melotti, michael.foord

___
Python tracker 

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



  1   2   >