[issue40278] pathlib Path.replace raises OSError when target exists

2020-04-13 Thread Michael Selik


Michael Selik  added the comment:

The docs for ``os.replace`` says "If dst is a directory, OSError will be 
raised."  That's helpful, but the docs for ``pathlib.Path.replace`` make it 
seem like the target will be unconditionally replaced regardless of whether 
it's a file or directory.  Sure, there's the association of the two functions 
in the correspondence table in the pathlib docs, but that's easy to overlook 
when looking up ``pathlib.Path.replace``.

If nothing else, I guess this is a request to alter the docstring.

--

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



[issue40278] pathlib Path.replace raises OSError when target exists

2020-04-13 Thread Michael Selik


New submission from Michael Selik :

The pathlib module ``Path.replace(target)`` states that "If target points to an 
existing file or directory, it will be unconditionally replaced."  However, 
this does not appear to be true.  I experience an OSError ``[Errno 66] 
Directory not empty`` when attempting to ``replace`` to an existant target.

https://docs.python.org/3/library/pathlib.html#pathlib.Path.replace


I see that others on StackOverflow encounter the same issue.  The top answer 
ignores the Python documentation and recommends removing the target directory 
before replacing.

https://stackoverflow.com/questions/50355180/use-pathlib-to-destructively-rename-one-directory-to-another-existing-directory

--
messages: 366363
nosy: selik
priority: normal
severity: normal
status: open
title: pathlib Path.replace raises OSError when target exists
type: behavior
versions: Python 3.8

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



[issue34498] Python 3.7 breaks on singledispatch_function.register(pseudo_type), which Python 3.6 accepted

2019-03-28 Thread Michael Selik


Michael Selik  added the comment:

+1 for this use case. Until it's resolved, perhaps there should be a note in 
the singledispatch docs that types from the ``typing`` module should not be 
used?

--
nosy: +selik

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



[issue36018] Add a Normal Distribution class to the statistics module

2019-02-19 Thread Michael Selik


Michael Selik  added the comment:

+1, This would be useful for quick analyses, avoiding the overhead of 
installing scipy and looking through its documentation.

Given that it's in the statistics namespace, I think the name can be simply 
``Normal`` rather than ``NormalDist``.  Also, instead of ``.from_examples`` 
consider naming the classmethod ``.fit``.

--
nosy: +selik

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



[issue34003] csv.DictReader can return basic dict instead of OrderedDict

2018-06-29 Thread Michael Selik


Michael Selik  added the comment:

I searched for previously submitted issues, but somehow didn't spot #32339.

I'll do some searching for whether anyone uses ``move_to_end`` on DictReader 
rows and respond to the mailing list with a report.

--

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



[issue34003] csv.DictReader can return basic dict instead of OrderedDict

2018-06-29 Thread Michael Selik


Change by Michael Selik :


--
components: +Library (Lib)

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



[issue34003] csv.DictReader can return basic dict instead of OrderedDict

2018-06-29 Thread Michael Selik


Change by Michael Selik :


--
type:  -> performance

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



[issue34003] csv.DictReader can return basic dict instead of OrderedDict

2018-06-29 Thread Michael Selik


Michael Selik  added the comment:

Pull request.

https://github.com/python/cpython/pull/8014

--

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



[issue34003] csv.DictReader can return basic dict instead of OrderedDict

2018-06-29 Thread Michael Selik


Change by Michael Selik :


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

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



[issue34003] csv.DictReader can return basic dict instead of OrderedDict

2018-06-29 Thread Michael Selik


New submission from Michael Selik :

Since dicts are now keeping insertion order as of 3.7, we can switch to the 
more efficient construction of dict rather than OrderedDict for each row in the 
CSV file.

--
messages: 320734
nosy: selik
priority: normal
severity: normal
status: open
title: csv.DictReader can return basic dict instead of OrderedDict
versions: Python 3.8

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



[issue34002] minor efficiency and clarity improvements in email package

2018-06-29 Thread Michael Selik


Change by Michael Selik :


--
components: +email
nosy: +barry, r.david.murray
versions: +Python 3.8

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



[issue34002] minor efficiency and clarity improvements in email package

2018-06-29 Thread Michael Selik


Change by Michael Selik :


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

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



[issue34002] minor efficiency and clarity improvements in email package

2018-06-29 Thread Michael Selik


New submission from Michael Selik :

The primary motivation for these improvements was avoiding a while/pop pattern 
for looping. A for-loop is a big improvement over copying a list, then 
repeatedly popping the 0th element.

A lesser improvement is the use of ``a.intersection(b)`` instead of ``c = 
set(b); len(c) > len(c - a)``. The check for intersection is more clear, and it 
avoids an unnecessary set construction.

https://github.com/python/cpython/pull/7999/

--
messages: 320730
nosy: selik
priority: normal
severity: normal
status: open
title: minor efficiency and clarity improvements in email package

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



[issue33462] reversible dict

2018-06-08 Thread Michael Selik


Michael Selik  added the comment:

It looks like there's general agreement on python-dev that this is appropriate 
for v3.8 (not v3.7).

Guido van Rossum and Ramsey D'silva gave a +1. Raymond Hettinger noted some use 
cases. INADA Naoki raised a point about waiting for other implementations, 
which Guido agreed with, but after some research came around to OK'ing this for 
v3.8.

Responding to Serhiy Storchaka's worry about adding new code possibly upsetting 
the compiler optimizations: The implementation seems straightforward and 
unlikely to confuse the compiler. Is there evidence that similar code has 
previously made CPython slower? If the compiler's black magic is too difficult 
to understand, it may be equally plausible that this code causes an improvement 
to the optimization of unrelated code.

--

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



[issue33463] Can namedtuple._asdict return a regular dict instead of OrderedDict?

2018-05-23 Thread Michael Selik

Michael Selik <m...@selik.org> added the comment:

I changed the PR to simply replace OrderedDict with dict. For the docs 
warnings, if I'm understanding correctly, those should be separate pulls for 
older branches?

--

___
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue33463>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33462] reversible dict

2018-05-12 Thread Michael Selik

Michael Selik <m...@selik.org> added the comment:

Right, a blend of the code from dictiterobject 
(https://github.com/python/cpython/blob/master/Objects/dictobject.c#L3309) and 
listreviterobject 
(https://github.com/python/cpython/blob/master/Objects/listobject.c#L3128).

--

___
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue33462>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33463] Can namedtuple._asdict return a regular dict instead of OrderedDict?

2018-05-12 Thread Michael Selik

Change by Michael Selik <m...@selik.org>:


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

___
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue33463>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33463] Can namedtuple._asdict return a regular dict instead of OrderedDict?

2018-05-12 Thread Michael Selik

Michael Selik <m...@selik.org> added the comment:

Is this warning what you had in mind?
https://github.com/python/cpython/pull/6772

--

___
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue33463>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33463] Can namedtuple._asdict return a regular dict instead of OrderedDict?

2018-05-10 Thread Michael Selik

New submission from Michael Selik <m...@selik.org>:

Since the basic dict is now keeping insertion order, can we switch 
namedtuple._asdict to return a basic dict? Other than OrderedDict.move_to_end 
and the repr, I believe there is no compatibility issue.

--
messages: 316387
nosy: selik
priority: normal
severity: normal
status: open
title: Can namedtuple._asdict return a regular dict instead of OrderedDict?
type: enhancement
versions: Python 3.7, Python 3.8

___
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue33463>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33462] reversible dict

2018-05-10 Thread Michael Selik

New submission from Michael Selik <m...@selik.org>:

Now that dicts are tracking insertion order, they can be made reversible via 
the built-in reversed, just like OrderedDict.

--
messages: 316386
nosy: selik
priority: normal
severity: normal
status: open
title: reversible dict
type: enhancement

___
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue33462>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33203] random.choice: raise IndexError on empty sequence even when not using getrandbits internally

2018-04-02 Thread Michael Selik

Michael Selik <m...@selik.org> added the comment:

If you're going to tackle this problem, this should probably be solved for the 
general case of n <= 0 rather than just n == 0.

In [1]: import random

In [2]: class Random(random.Random):
   ...: def random(self):
   ...: return  super().random()
   ...:

In [3]: r = Random()

In [4]: r._randbelow(-1) # Should raise a ValueError
Out[4]: 0

But honestly, if someone is going to override ``random`` I think we can expect 
them to realize they're stepping into the deep end.

--
nosy: +selik

___
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue33203>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue31908] trace module cli does not write cover files

2017-11-13 Thread Michael Selik

Michael Selik <m...@selik.org> added the comment:

You're referring to something like this:

+def test_count_and_summary(self):
+name = TESTFN + '.py'
+with open(name, 'w') as fd:
+self.addCleanup(unlink, name)
+fd.write("""\
+x = 1
+y = 2
+
+def f():
+return x + y
+
+for i in range(10):
+f()
+""")
+status, stdout, stderr = assert_python_ok('-m', 'trace', '-cs', name)
+self.assertEqual(status, 0)
+self.assertIn(b'lines   cov%   module   (path)', stdout)
+self.assertIn(('6   100%%   %s   (%s)' % (TESTFN, name)).encode(), 
stdout)
+

?

--

___
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue31908>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue31908] trace module cli does not write cover files

2017-11-13 Thread Michael Selik

Change by Michael Selik <m...@selik.org>:


--
nosy: +selik

___
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue31908>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue31915] (list).insert() not working

2017-10-31 Thread Michael Selik

New submission from Michael Selik <michael.se...@gmail.com>:

What behavior did you expect from your code?
What behavior did you get instead?

It looks like you're not calling the list copy method correctly. Try writing 
"tables2.copy()" instead of "tables2.copy". It also looks like you have other 
bugs in your code.

This forum is for reporting bugs in the Python language. If you'd like help 
with bugs in your own code, try asking on StackOverflow 
(https://stackoverflow.com/) or on the Python Help mailing list 
(https://mail.python.org/mailman/listinfo/python-help).

--
nosy: +Michael Selik

___
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue31915>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue31908] trace module cli does not write cover files

2017-10-31 Thread Michael Selik

Michael Selik <michael.se...@gmail.com> added the comment:

Ok, pull request submitted:
https://github.com/python/cpython/pull/4205

--

___
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue31908>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue31908] trace module cli does not write cover files

2017-10-31 Thread Michael Selik

Change by Michael Selik <m...@selik.org>:


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

___
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue31908>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue31908] trace module cli does not write cover files

2017-10-31 Thread Michael Selik

Michael Selik <michael.se...@gmail.com> added the comment:

While writing a patch for this, I noticed the ``lnotab`` parameter seems nearly 
unused. It's a dict, but is only used for its keys.

https://github.com/python/cpython/blob/master/Lib/trace.py#L333

Further, the choice to count unreached lines only when ``show_missing`` was set 
seems inconsistent.

https://github.com/python/cpython/blob/master/Lib/trace.py#L335

https://github.com/python/cpython/blob/master/Lib/trace.py#L280

--

___
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue31908>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue31908] trace module cli does not write cover files

2017-10-31 Thread Michael Selik

Michael Selik <michael.se...@gmail.com> added the comment:

The problem appears to be a mistake in commit 
f026dae130bf6f9015c4b212f16852ba4a3f3dec

https://github.com/python/cpython/commit/f026dae130bf6f9015c4b212f16852ba4a3f3dec

This made the writing of cover files conditional on ``show_missing`` which is 
the option to mark lines which weren't executed with several angle brackets 
">>>>>".

https://github.com/python/cpython/blob/3.5/Lib/trace.py#L326

mike on mac in ~/
$ python -m trace --count foo.py
hello

mike on mac in ~/
$ ls *.cover
ls: *.cover: No such file or directory

mike on mac in ~/
$ python -m trace --count -m foo.py
hello

mike on mac in ~/
$ ls *.cover
-rw-r--r--  1 mike  staff22B Oct 31 15:40 foo.cover

--

___
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue31908>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue31908] trace module cli does not write cover files

2017-10-30 Thread Michael Selik

New submission from Michael Selik <michael.se...@gmail.com>:

The trace module command-line utility doesn't write cover files. I've noticed 
this issue for some years now. It works fine in Python 2. When using Python 3, 
no ".cover" files are written, regardless of how "--coverdir" is specified.

mike on macbook in ~/
$ echo 'print("hello")' > foo.py

mike on macbook in ~/
$ python -m trace --count foo.py
hello

mike on macbook in ~/
$ ls *.cover
ls: *.cover: No such file or directory


My apologies if this is a duplicate bug. I searched the tracker and Google for 
a while, but couldn't find a relevant issue.

------
messages: 305268
nosy: Michael Selik
priority: normal
severity: normal
status: open
title: trace module cli does not write cover files
type: behavior
versions: Python 3.6

___
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue31908>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue29965] MatchObject __getitem__() should support slicing and len

2017-04-03 Thread Michael Selik

Michael Selik added the comment:

Sorry, it looks like I got the issue number wrong. My comparison should not 
have been with #24454, but instead with an issue I can't locate at the moment. 
Reproducing the example:

for g0, g1, g2 in re.finditer(r'(\d+)/(\d+)', 'Is 1/3 the same as 2/6?'):
ratio = Fraction(int(g1), int(g2))

Better:

for mo in re.finditer(r'(\d+)/(\d+)', 'Is 1/3 the same as 2/6?'):
ratio = Fraction(*map(int, mo[1:3]))

The map in the last one isn't very pretty, but I hope it illustrates the gist 
of what I'd like to do for a much larger pattern with many capture groups.

--

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue29965>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue29965] MatchObject __getitem__() should support slicing and len

2017-04-03 Thread Michael Selik

Michael Selik added the comment:

Yesterday I wanted to do a destructuring bind on a slice of groups in a 
finditer. Similar situation to the use case of Issue #24454. It might not be 
"normal code" but I end up in that situation every month or so when parsing 
semi-structured documents. I found myself wishing for a mapping-destructuring 
bind, but that's another story.

I haven't read the full discussion of ``len`` on MatchObject yet, but I 
tentatively agree with Brandon Rhodes' comment in Issue #19536:

"My retort is that concentric groups can happen anyway:
that Group Zero, holding the entire match, is not really
as special as the newcomer might suspect, because you can
always wind up with groups inside of other groups; it is
simply part of the semantics of regular expressions that
groups might overlap or might contain one another ..."

@Serhiy, I was unaware of the feature of passing several arguments to groups. 
Unfortunately, the regex pattern I was using had a very large set of groups. A 
slice would have been particularly elegant. Passing several arguments to 
mo.groups() will be helpful, but still more awkward than a slice.

Perhaps it is a can of worms, but I was pleased to see indexing available and 
was disappointed not to find the typically supported corresponding features.

--

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue29965>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue29965] MatchObject __getitem__() should support slicing and len

2017-04-02 Thread Michael Selik

Michael Selik added the comment:

This would also enable negative indexing, which currently raises "IndexError: 
no such group".

Edit: I meant whole numbers, not natural numbers.

--
versions: +Python 3.7

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue29965>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue29965] MatchObject __getitem__() should support slicing and len

2017-04-02 Thread Michael Selik

Changes by Michael Selik <m...@selik.org>:


--
components: +Regular Expressions
nosy: +ezio.melotti, mrabarnett
type:  -> enhancement

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue29965>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue29965] MatchObject __getitem__() should support slicing and len

2017-04-02 Thread Michael Selik

New submission from Michael Selik:

Currently, slicing a MatchObject causes an IndexError and len() a TypeError. 
It's natural to expect slicing and len to work on objects of a finite length 
that index by natural numbers.

--
messages: 291050
nosy: selik
priority: normal
severity: normal
status: open
title: MatchObject __getitem__() should support slicing and len

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue29965>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue29957] unnecessary LBYL for key contained in defaultdict, lib2to3/btm_matcher

2017-04-01 Thread Michael Selik

Michael Selik added the comment:

Ok, I'll change the PR.

--

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue29957>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue29957] unnecessary LBYL for key contained in defaultdict, lib2to3/btm_matcher

2017-03-31 Thread Michael Selik

Michael Selik added the comment:

PR submitted. I also signed the contributor agreement, but the bot doesn't seem 
to have noticed.

--

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue29957>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue29957] unnecessary LBYL for key contained in defaultdict, lib2to3/btm_matcher

2017-03-31 Thread Michael Selik

Michael Selik added the comment:

I'll submit a pull request momentarily.

--

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue29957>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue29957] unnecessary LBYL for key contained in defaultdict, lib2to3/btm_matcher

2017-03-31 Thread Michael Selik

New submission from Michael Selik:

Minor, but it looks like someone decided to use a defaultdict but forgot to 
remove the checks for whether a key exists.

Creating a defaultdict(list):
https://github.com/python/cpython/blob/6f0eb93183519024cb360162bdd81b9faec97ba6/Lib/lib2to3/btm_matcher.py#L100

Checking for the key, then initializing an empty list:
https://github.com/python/cpython/blob/6f0eb93183519024cb360162bdd81b9faec97ba6/Lib/lib2to3/btm_matcher.py#L120

Again:
https://github.com/python/cpython/blob/6f0eb93183519024cb360162bdd81b9faec97ba6/Lib/lib2to3/btm_matcher.py#L137

Because the ``results`` is getting returned, perhaps it'd be better to use a 
regular dict and dict.setdefault instead of a defaultdict.

--
components: 2to3 (2.x to 3.x conversion tool)
messages: 290955
nosy: selik
priority: normal
severity: normal
status: open
title: unnecessary LBYL for key contained in defaultdict, lib2to3/btm_matcher

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue29957>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23883] __all__ lists are incomplete

2015-11-04 Thread Michael Selik

Michael Selik added the comment:

many things are not present in os.__all__ that should be, including
os.getcwd

--
nosy: +selik

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue23883>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com