[issue19019] Investigate using Apple clang for building OS X installers

2013-10-24 Thread Andrew Barnert
Andrew Barnert added the comment: Now that Xcode 5 is out, and does not have anything named gcc-4.2 (it _does_ still have something called gcc, which is now a wrapper around clang instead of a wrapper around llvm-gcc-4.2), this seems a lot more critical, because (as far as I can tell) nobody

[issue20230] structseq types should expose _fields

2014-01-12 Thread Andrew Barnert
New submission from Andrew Barnert: A PyStructSequence type doesn't expose its field names in any way to Python code (except indirectly, via the repr, which you could parse if you really wanted to…). The docs claim that Struct sequence objects are the C equivalent of namedtuple() objects, so

[issue7796] No way to find out if an object is an instance of a namedtuple

2014-01-12 Thread Andrew Barnert
Andrew Barnert added the comment: I believe the structseq issues are a lot easier to solve than the appear. See #20230, which adds a _fields member to every structseq type. Having done that, a NamedTuple ABC works on them just fine. And of course duck typing them without an ABC does too

[issue20230] structseq types should expose _fields

2014-01-12 Thread Andrew Barnert
Andrew Barnert added the comment: After more searching (I should have searched on structseq instead of PyStructSequence…), this might be a dup of #1820. If so, apologies. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20230

[issue1820] Enhance Object/structseq.c to match namedtuple and tuple api

2014-01-12 Thread Andrew Barnert
Andrew Barnert added the comment: See issue20230, which includes a patch implementing just the first part of part 2 (adding _fields, but not _asdict or _replace). Since this one has been open for 5+ years, if it's not going to be done soon, any chance of the easy (_fields) change being

[issue20250] defaultdict docstring neglects the *args

2014-01-13 Thread Andrew Barnert
New submission from Andrew Barnert: The docstring for defaultdict shows only a single argument, default_factory, and gives no clue that you can pass additional arguments: | defaultdict(default_factory) -- dict with default factory | | The default factory is called without

[issue1820] Enhance Object/structseq.c to match namedtuple and tuple api

2014-06-11 Thread Andrew Barnert
Andrew Barnert added the comment: Hi, Stephan. Sorry, for some reason Yahoo was sending updates from the tracker to spam again, so I missed this. I'd be glad to sign a contributor agreement if it's still relevant, but it looks like there's a later patch that does what mine did and more

[issue1820] Enhance Object/structseq.c to match namedtuple and tuple api

2014-06-11 Thread Andrew Barnert
Andrew Barnert added the comment: Sorry, Stefan, not Stephan. Anyway, I've signed the agreement. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1820

[issue22004] io documentation refers to newline as newlines

2014-07-18 Thread Andrew Barnert
New submission from Andrew Barnert: In at least one place in the io module documentation (io.IOBase.readline), and in the corresponding docstring, the newline parameter to open (and io.open, and io.Foo.__init__) is referred to as newlines: The line terminator is always b'\n' for binary files

[issue22004] io documentation refers to newline as newlines

2014-07-18 Thread Andrew Barnert
Andrew Barnert added the comment: Searching the source and the help page, it looks like the one example I gave is the only place it's wrong in each of the two, not one of multiple places. -- ___ Python tracker rep...@bugs.python.org http

[issue1152248] Add support for reading records with arbitrary separators to the standard IO stack

2014-07-19 Thread Andrew Barnert
Andrew Barnert added the comment: http://thread.gmane.org/gmane.comp.python.ideas/28310 discusses the same idea. Guido raised a serious problem with either adding an argument to readline and friends, or adding new methods readrecord and friends: It means the hundreds of existing file-like

[issue1152248] Add support for reading records with arbitrary separators to the standard IO stack

2014-07-19 Thread Andrew Barnert
Andrew Barnert added the comment: While we're at it, Douglas Alan's solution wouldn't be an ideal solution even if it were a builtin. A fileLineIter obviously doesn't support the stream API. It means you end up with two objects that share the same file, but have separate buffers and out

[issue1152248] Add support for reading records with arbitrary separators to the standard IO stack

2014-07-19 Thread Andrew Barnert
Andrew Barnert added the comment: One last thing, a quick dirty solution that works today, if you don't mind accessing private internals of stdlib classes, and don't mind giving up the performance of _io for _pyio, and don't need a solution for binary files: class MyTextIOWrapper

[issue1152248] Add support for reading records with arbitrary separators to the standard IO stack

2014-07-20 Thread Andrew Barnert
Changes by Andrew Barnert abarn...@yahoo.com: Added file: http://bugs.python.org/file36008/pep-newline.txt ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1152248

[issue1152248] Add support for reading records with arbitrary separators to the standard IO stack

2014-07-20 Thread Andrew Barnert
Changes by Andrew Barnert abarn...@yahoo.com: Added file: http://bugs.python.org/file36009/pep-peek.txt ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1152248

[issue1152248] Add support for reading records with arbitrary separators to the standard IO stack

2014-07-27 Thread Andrew Barnert
Andrew Barnert added the comment: Akira, your patch does this: -self._writetranslate = newline != '' -self._writenl = newline or os.linesep +self._writetranslate = newline in (None, '\r', '\r\n') +self._writenl = newline if newline is not None else os.linesep

[issue22755] contextlib.closing documentation should use a new example

2014-10-28 Thread Andrew Barnert
Andrew Barnert added the comment: It may be pretty hard to come up with a good example for closing in the stdlib that shouldn't just be turned into a context manager… There are some types where using it in a with statement is sensible, but unusual enough that you might want to make

[issue23226] Add float linspace recipe to docs

2015-01-12 Thread Andrew Barnert
New submission from Andrew Barnert: In a recent thread on python-ideas (https://mail.python.org/pipermail/python-ideas/2015-January/030817.html), it was concluded that Python should not have a range-like type for floats in the stdlib, but there should be some simple discussion

[issue23226] Add float linspace recipe to docs

2015-01-12 Thread Andrew Barnert
Andrew Barnert added the comment: As suggested by the review: removing unnecessary parenthetical, changing ulp to digit, and fixing the recipe link. -- Added file: http://bugs.python.org/file37685/stdtypes.rst.diff ___ Python tracker rep

[issue23226] Add float linspace recipe to docs

2015-01-13 Thread Andrew Barnert
Andrew Barnert added the comment: So something like the first version below? Or should even the example be inline, as in the second version below? (Apologies if the formatting gets screwed up pasting from docs to bugs.) --- Range objects are inappropriate for non-integral types, especially

[issue23525] isbuiltin, isroutine, etc.

2015-02-25 Thread Andrew Barnert
New submission from Andrew Barnert: The documentation and implementation for `inspect.isbuiltin` and related functions do not match. While #4968 attempted to clarify things to make the documentation match the behavior, the actual committed changes are still wrong. `isbuiltin` says Return true

[issue24113] shlex constructor unreachable code

2015-05-03 Thread Andrew Barnert
Andrew Barnert added the comment: Presumably ESR thought that information was useful enough to send Guido a patch to add it. But apparently nobody's missed it in the 15 years it's been checked in but unreachable. If anyone needed to know the `instream` and `lineno` right after initialization

[issue25864] collections.abc.Mapping should include a __reversed__ that raises TypeError

2015-12-16 Thread Andrew Barnert
Andrew Barnert added the comment: @Swati Jaiswal: > But the work around suggested here ... is also not a general solution, i.e. > ... for any other mapping which does not have 0 as a key, it results in > KeyError. You're missing the point. The workaround isn't intended to be

[issue25864] collections.abc.Mapping should include a __reversed__ that raises TypeError

2015-12-16 Thread Andrew Barnert
Andrew Barnert added the comment: @R. David Murray: > What is it that makes reversed raise a typeerror on dict here? There are separate slots for tp_as_sequence and tp_as_mapping, so a C type can be (and generally is) one or the other, not both. But for Python types, anything that

[issue25864] collections.abc.Mapping should include a __reversed__ that raises TypeError

2015-12-14 Thread Andrew Barnert
New submission from Andrew Barnert: Example: class MyDict(collections.abc.Mapping): def __init__(self, d): self.d = d def __len__(self): return len(self.d) def __getitem__(self, key): return self.d[key] def __iter__(self): return iter(self.d) d = {1:2, 3

[issue25864] collections.abc.Mapping should include a __reversed__ that raises TypeError

2015-12-14 Thread Andrew Barnert
Andrew Barnert added the comment: > It seems no more interesting or problematic than sequence argument unpacking > working with dictionaries, "a, b = {'one': 1, 'two': 2}". Dictionaries (including dicts, dict subclasses, and custom Mappings) are iterables. People use that

[issue25866] Reference 3. Data Model: miscellaneous minor cleanups on the word "sequence".

2015-12-15 Thread Andrew Barnert
New submission from Andrew Barnert: None of the below are very serious or likely to mislead anyone using or implementing Python, but... --- 3.3.2. Customizing attribute access The docs for `__dir__` say: > A sequence must be returned. dir() converts the returned sequence to a l

[issue25865] 7.2 Assignment statements documentation is vague and slightly misleading

2015-12-14 Thread Andrew Barnert
New submission from Andrew Barnert: >From >https://docs.python.org/3/reference/simple_stmts.html#assignment-statements > If the target list contains one target prefixed with an asterisk, called a > “starred” target: The object must be a sequence with at least a

[issue25865] 7.2 Assignment statements documentation is vague and slightly misleading

2015-12-14 Thread Andrew Barnert
Andrew Barnert added the comment: As a side note, why isn't () allowed as an empty target list, like []? Then the rules for target lists vs. single targets would be exactly parallel to the rules for tuple and list displays. And the error message `can't assign to ()` seems a bit weird--you

[issue25864] collections.abc.Mapping should include a __reversed__ that raises TypeError

2015-12-14 Thread Andrew Barnert
Andrew Barnert added the comment: > What are we exactly expecting here? Well, naively, I was expecting a TypeError, just as you get for dict, or a subclass of dict, or a custom extension type that implements the C-API mapping protocol. Once you understand how reversed works, you

[issue25864] collections.abc.Mapping should include a __reversed__ that raises TypeError

2016-01-04 Thread Andrew Barnert
Andrew Barnert added the comment: > My main concern about the documentation was that in your patch you say _all_ > special methods are now allowed to be None, but in your code you only check > __iter__(). This is adding new undocumented inconsistencies e.g. with > Iterable

[issue25958] Implicit ABCs have no means of "anti-registration"

2016-01-04 Thread Andrew Barnert
Andrew Barnert added the comment: Is an hg export patch usable? If not, let me know and I'll flatten it. Anyway, the attached patch fixes #25987 and #25864 as well as this one, as follows: * Every ABC in collections.abc that has a subclass hook now treats None as blocking, instead of a few

[issue25958] Implicit ABCs have no means of "anti-registration"

2016-01-04 Thread Andrew Barnert
Andrew Barnert added the comment: > A Mercurial export patch should work with the Reitveld review thing if it is > a single revision (and based on a public revision). Well, it's 7 separate commits on a work branch, so I could check in each piece and test it separately, and then

[issue25958] Implicit ABCs have no means of "anti-registration"

2016-01-01 Thread Andrew Barnert
Andrew Barnert added the comment: > I don’t think you need to define __len__() to get an iterable, only > __getitem__(). The "old-style sequence protocol" means having a __getitem__ that works for values from 0 to __len__() and raises IndexError at __len__(). You don't need

[issue25987] collections.abc.Reversible

2016-01-01 Thread Andrew Barnert
New submission from Andrew Barnert: This came up as a side issue in the -ideas discussion on deprecating the old-style sequence protocol that came out of Guido's suggestion on https://github.com/ambv/typehinting/issues/170 (http://article.gmane.org/gmane.comp.python.ideas/37599): > I a

[issue25958] Implicit ABCs have no means of "anti-registration"

2016-01-01 Thread Andrew Barnert
Andrew Barnert added the comment: > Also, if I understand your problem, Container would also be susceptible in > theory You're right, but not in the details. Being iterable (whether via __iter__ or via the old-style sequence protocol) makes you a container. But, again, false neg

[issue25864] collections.abc.Mapping should include a __reversed__ that raises TypeError

2016-01-01 Thread Andrew Barnert
Andrew Barnert added the comment: > If this patch goes ahead, I think the ABC documentation should clarify which > methods are checked for None and which aren’t. That seems fair. Also, as you pointed out on #25958, at least one other ABC has the same problem as Iterable: you can

[issue25988] collections.abc.Indexable

2016-01-01 Thread Andrew Barnert
New submission from Andrew Barnert: In an -ideas thread, Guido suggested (http://article.gmane.org/gmane.comp.python.ideas/37599): > If we want some way to turn something that just defines __getitem__ and > __len__ into a proper sequence, it should just be made to inherit from >

[issue26019] collections.abc documentation incomplete

2016-01-05 Thread Andrew Barnert
Andrew Barnert added the comment: The attached patch is, I think, the smallest change that includes all the necessary information. Of course it will need to be redone if #25958 goes through, with a version-changed note explaining that prior to 3.6 some of the implicit ABCs (maybe with a list

[issue19251] bitwise ops for bytes of equal length

2016-01-07 Thread Andrew Barnert
Andrew Barnert added the comment: For what it's worth, I looked at some old code (a clean re-implementation of a crypto algorithm in Python, used as a unit test for production code in C++) and found this: class BytesBits(bytes): # from a quick test, 1.12us in NumPy, 1.39us in C, 2.55us

[issue25958] Implicit ABCs have no means of "anti-registration"

2016-01-05 Thread Andrew Barnert
Andrew Barnert added the comment: The second patch takes into account all the issues raised by Martin and Guido, as well as some other changes that didn't make it into the first patch because Windows hates me. And it should be flattened into a single commit, and therefore should hopefully

[issue22268] add dedicated functions mrohasattr and mrogetattr

2016-01-05 Thread Andrew Barnert
Andrew Barnert added the comment: See #25958, which incorporates a similar refactoring in service of making all of the subclasshooks in collections.abc handle None the same way. We definitely do want something public in the abc module like this, rather than the private function

[issue26019] collections.abc documentation incomplete

2016-01-05 Thread Andrew Barnert
New submission from Andrew Barnert: Some of the modules in collections.abc have a subclass hook that implicitly registers any type that declares the right methods, like Iterator. Others do not, like Sequence. For those that do have the hook, it's not always obvious what methods are tested

[issue25958] Implicit ABCs have no means of "anti-registration"

2016-01-07 Thread Andrew Barnert
Changes by Andrew Barnert <abarn...@yahoo.com>: Added file: http://bugs.python.org/file41527/patch4a.diff ___ Python tracker <rep...@bugs.python.org> <http://bugs.python

[issue25864] collections.abc.Mapping should include a __reversed__ that raises TypeError

2015-12-26 Thread Andrew Barnert
Andrew Barnert added the comment: > Perhaps there is a bug in typing.Reversible. It doesn't accept all types > supported by reversed(). > ... And accepts types that don't work with reversed(). The problem is the way the two are defined: * Reversible is true if you implement __r

[issue25958] Implicit ABCs have no means of "anti-registration"

2015-12-26 Thread Andrew Barnert
Andrew Barnert added the comment: As Guido pointed out on -ideas, hashing already uses the convention of `__hash__ is None` to declare a type unhashable, and `collections.abc.Hashable.__subclasshook__` already checks for that. Meanwhile, setting `__iter__` and `__reversed__` to `None` already

[issue25864] collections.abc.Mapping should include a __reversed__ that raises TypeError

2015-12-26 Thread Andrew Barnert
Andrew Barnert added the comment: As mentioned in #25958, Guido pointed out on -ideas that `__hash__ = None` is already the standard way to declare a class unhashable, and it's recognized by `collections.abc.Hashable`. Doing `__reversed__ = None` does make `reversed(m)` raise a `TypeError

[issue25864] collections.abc.Mapping should include a __reversed__ that raises TypeError

2015-12-26 Thread Andrew Barnert
Andrew Barnert added the comment: > This sounds good. Also, reversed() could then be modified to produce a better error. Should `iter` also be modified to produce a better error if `__iter__` is None? Also, should this be documented? Maybe a sentence in the "Special method names&q

[issue25864] collections.abc.Mapping should include a __reversed__ that raises TypeError

2015-12-26 Thread Andrew Barnert
Andrew Barnert added the comment: Serhiy already filed the typing.Reversible bug on the separate typehinting tracker (https://github.com/ambv/typehinting/issues/170). So, unless fixing that bug requires some changes back to collections.abc or something else in the stdlib, I think the only

[issue25958] Implicit ABCs have no means of "anti-registration"

2015-12-26 Thread Andrew Barnert
New submission from Andrew Barnert: Serhiy Storchaka raised an issue (http://bugs.python.org/msg256910) with static type hints on #25864 (http://bugs.python.org/issue25864), which I believe also applies to runtime ABCs. Consider this class, which uses `[]` in a way similar to generic types

[issue25864] collections.abc.Mapping should include a __reversed__ that raises TypeError

2015-12-26 Thread Andrew Barnert
Andrew Barnert added the comment: Also, I filed #25958 as an ABC equivalent to Serhiy's typehinting problem. I don't know if that actually needs to be solved, but that definitely takes it out of the way for this issue. -- ___ Python tracker <

[issue25958] Implicit ABCs have no means of "anti-registration"

2015-12-26 Thread Andrew Barnert
Andrew Barnert added the comment: As Serhiy pointed out on -ideas, there's no reason `reversed` couldn't add special handling for `__reversed__ is None`, akin to `hash`'s special handling for `__hash__ is None`, to produce whatever error message we wanted in the `TypeError`, instead

[issue25958] Implicit ABCs have no means of "anti-registration"

2015-12-28 Thread Andrew Barnert
Andrew Barnert added the comment: Hashable and Awaitable already treat None (actually any falsey value) as not implementing the special method, and blocking any superclass implementation, in their __subclasshook__. (This only blocks implicit subclassing--anything that actually directly

[issue25864] collections.abc.Mapping should include a __reversed__ that raises TypeError

2015-12-28 Thread Andrew Barnert
Andrew Barnert added the comment: The attached patch does the following: * collections.abc.Mapping.__reversed__ = None. * collections.abc.Iterable.__subclasshook__ checks for None the same way Hashable does: * This tests for any falsey value, not just None. I'm not sure this is ideal

[issue19251] bitwise ops for bytes of equal length

2016-01-08 Thread Andrew Barnert
Andrew Barnert added the comment: There are a number of existing libraries on PyPI for bit arrays and bit sets. There are a lot more API choices than you'd think of in advance, and between them they explore most of the useful space. And I don't think any of them need to be in the stdlib

[issue19251] bitwise ops for bytes of equal length

2016-01-10 Thread Andrew Barnert
Andrew Barnert added the comment: On Jan 10, 2016, at 06:48, cowlicks <rep...@bugs.python.org> wrote: > > > Personally this came up while I was playing with toy crypto problems. I > expected to already be part of the language, but it wasn't. I think this is a > natura

[issue25958] Implicit ABCs have no means of "anti-registration"

2016-01-18 Thread Andrew Barnert
Andrew Barnert added the comment: Style changes based on Martin's review -- Added file: http://bugs.python.org/file41650/patch5.diff ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/i

[issue25958] Implicit ABCs have no means of "anti-registration"

2016-01-18 Thread Andrew Barnert
Changes by Andrew Barnert <abarn...@yahoo.com>: Removed file: http://bugs.python.org/file41650/patch5.diff ___ Python tracker <rep...@bugs.python.org> <http://bugs.python

[issue26300] "unpacked" bytecode

2016-02-06 Thread Andrew Barnert
Andrew Barnert added the comment: Reading more about wpython (slide 23 of https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/wpython2/Cleanup%20and%20new%20optimizations%20in%20WPython%201.1.pdf), one of his optimizations was moving the peephole optimizer

[issue26300] "unpacked" bytecode

2016-02-05 Thread Andrew Barnert
New submission from Andrew Barnert: Currently, the compiler starts with a list of arrays of instructions, packs them to 1/3/6-bytes-apiece bytecodes, fixes up all the jumps, and then calls PyCode_Optimize on the result. This makes the peephole optimizer much more complicated. Assuming PEP 511

[issue26225] New misleading wording in execution model documenation

2016-01-27 Thread Andrew Barnert
New submission from Andrew Barnert: In #24129, the wording describing class local bindings in 4.2.2 "Resolution of names" was changed for Python 3.4, 3.5, and 3.6. The new version is a lot clearer for classes--but now it's misleading for `exec`/`eval`. --- > Class defi

[issue26225] New misleading wording in execution model documenation

2016-01-27 Thread Andrew Barnert
Changes by Andrew Barnert <abarn...@yahoo.com>: -- type: -> enhancement ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26225> ___ _

[issue25958] Implicit ABCs have no means of "anti-registration"

2016-02-01 Thread Andrew Barnert
Andrew Barnert added the comment: > I did actually mean a version changed notice for the data model change. I see > this as a small expansion of the Python object API. Previously, > __reversed__() had to be a function, now you are also allowed to set it to > None. The coll

[issue26267] UUID docs should say how to get "standard form"

2016-02-02 Thread Andrew Barnert
New submission from Andrew Barnert: Most real-world code that uses the UUID module wants either the standard format '{12345678-1234-5678-1234-567812345678}', or the same thing without the braces. There are a number of different documented accessors, but none of them give you either

[issue26267] UUID docs should say how to get "standard form"

2016-02-02 Thread Andrew Barnert
Andrew Barnert added the comment: > The docs seem to clearly show a str(x) as the way to produce the desired form > (without braces). https://docs.python.org/3/library/uuid.html#example Please read the last paragraph of the original m

[issue26267] UUID docs should say how to get "standard form"

2016-02-02 Thread Andrew Barnert
Andrew Barnert added the comment: No, I suggest we add something for users who don't think that a comment in an example is the place to look for documentation, but do think that actual documentation of a class or method is. -- ___ Python tracker

[issue25958] Implicit ABCs have no means of "anti-registration"

2016-02-01 Thread Andrew Barnert
Andrew Barnert added the comment: > This is not really my area of expertise, but I would have thought if you > defined a __special__ method to something illegal (non-callable, or wrong > signature) it would be reasonable for Python to raise an error at class > definition (or assi

[issue26152] A non-breaking space in a source

2016-01-19 Thread Andrew Barnert
Andrew Barnert added the comment: Ultimately, this is because the tokenizer works byte by byte instead of character by character, as far as possible. Since any byte >= 128 must be part of some non-ASCII character, and the only legal use for non-ASCII characters outside of quotes and comme

[issue26152] A non-breaking space in a source

2016-01-20 Thread Andrew Barnert
Andrew Barnert added the comment: > Assuming Andrew is correct, it sounds like the tokenizer is treating the NBSP > and the “2” as part of the same token, because NBSP is non-ASCII. It's more complicated than that. When you get an invalid character, it splits the token up. So, in thi

[issue34447] ttk.TreeView (and maybe other functions) is overzealous in converting item values to ints

2018-08-20 Thread Andrew Barnert
New submission from Andrew Barnert : See this StackOverflow question for a repro case: https://stackoverflow.com/questions/51941260/ If you store a string that looks like an int in a TreeView's values, then call widget.item(row), the dict's 'values' value has that string converted to an int