[issue32163] getattr() returns None even when default is given

2017-11-28 Thread Steven D'Aprano
Steven D'Aprano added the comment: That's not a bug. That's because the file object does have an encoding attribute, which is set to None. getattr only returns the default when the attribute doesn't exist, not if it exists but is None. -- nosy: +steven.daprano r

[issue32172] Add length counter for iterables

2017-11-29 Thread Steven D'Aprano
Steven D'Aprano added the comment: Not every trivial one-liner needs to be in the standard library. In this case, there are two easy (and obvious) ways to do it: sum(1 for x in iterator) len(list(iterator)) (The first probably saves memory; the second probably is faster.) Given how ra

[issue32242] loop in loop with with 'zip'ped object misbehaves in py3.6

2017-12-07 Thread Steven D'Aprano
Steven D'Aprano added the comment: I'm sorry, I have no idea how to read an Anaconda notebook file. In the browser it looks like some sort of nested dictionary. I can find the code: j = [1, 2, 3, 4] k = [5, 6, 7, 8] z = zip(j, k) for x, y in z: for m, n in z: print (

[issue32242] loop in loop with with 'zip'ped object misbehaves in py3.6

2017-12-07 Thread Steven D'Aprano
Steven D'Aprano added the comment: I decided to run the code in 3.5 and 2.7, and now that I know what I'm looking for, I can see the results buried in the Anaconda notebook. This is not a bug, zip has been changed in Python 3 to return an iterator instead of a list. To get the sa

[issue32259] Misleading "not iterable" Error Message when generator return a "simple" type, and a tuple is expected

2017-12-09 Thread Steven D'Aprano
Steven D'Aprano added the comment: I agree with Camion that the error message is misleading, and not just for beginners. It threw me for a loop too, when I first read it. Serhiy is right, the exception type cannot and should not be changed, but we can change the error message. I'm

[issue32259] Misleading "not iterable" Error Message when generator return a "simple" type, and a tuple is expected

2017-12-10 Thread Steven D'Aprano
Steven D'Aprano added the comment: On Sun, Dec 10, 2017 at 09:15:16AM +, Serhiy Storchaka wrote: > My point is that the current error message is correct and is not misleading. With respect Serhiy, in this bug report you have TWO PEOPLE who have said that it is misleading in this

[issue32259] Misleading "not iterable" Error Message when generator return a "simple" type, and a tuple is expected

2017-12-10 Thread Steven D'Aprano
Steven D'Aprano added the comment: On Sun, Dec 10, 2017 at 10:00:27AM +, Camion wrote: > Understanding that, I suggest to simply add "(expected 'tuple')" at the end > of the message. > ex : TypeError: 'int' object is not iterable (expected

[issue32285] In `unicodedata`, it should be possible to check a unistr's normal form without necessarily copying it

2017-12-12 Thread Steven D'Aprano
Steven D'Aprano added the comment: Python 2.7 is in feature freeze, so this can only go into 3.7. I would find this useful, and would like this feature. However, I'm concerned by your comment that you fall back on creating a normalized copy and comparing. That could be expe

[issue32288] Inconsistent behavior with slice assignment?

2017-12-12 Thread Steven D'Aprano
Steven D'Aprano added the comment: Please don't report three issues under one ticket, unless they are so closely related that they cannot be separated. I don't understand what your second issue actually is. You refer to the docs that specify extended syntax as [start:stop:ste

[issue32289] Glossary does not define "extended slicing"

2017-12-12 Thread Steven D'Aprano
New submission from Steven D'Aprano : Looking at issue 32288, I realised that the glossary doesn't define "extended slicing" or "extended slice", even though they are common terms. Although I thought I know what they meant, on closer reflection I realised I wasn&

[issue32301] Typo in array documentation

2017-12-13 Thread Steven D'Aprano
Steven D'Aprano added the comment: The given version is correct: the comma is only required if the initializer is given. Your suggested version typecode, [initializer] implies that the comma is always required whether the initializer is given or not. If we want to be absol

[issue32321] functools.reduce has a redundant guard or needs a pure Python fallback

2017-12-14 Thread Steven D'Aprano
New submission from Steven D'Aprano : The functools module imports reduce from _functools, using a guard in case it is not present: try: from _functools import reduce except ImportError: pass However, the documentation says nothing about reduce being optional, and

[issue32412] help() of bitwise operators should mention sets as well

2017-12-22 Thread Steven D'Aprano
New submission from Steven D'Aprano : If you ask for help on the set operators ^ & and | then help docs only talk about them as bitwise operators. Since sets and frozensets are important, built-in types, the help should mention them as well. -- assignee: docs@python c

[issue32413] Document that locals() may return globals()

2017-12-22 Thread Steven D'Aprano
New submission from Steven D'Aprano : The obvious documentation for locals() fails to mention that when called from the top level of a module (outside of a function or class body) it returns the same dict as globals(). https://docs.python.org/2/library/functions.html#l

[issue32452] Brackets and Parentheses used in an ambiguous way

2017-12-29 Thread Steven D'Aprano
Steven D'Aprano added the comment: In British, Australian, New Zealander, and Indian English (and sometimes Canada), at least, "bracket" on its own typically means round brackets () and is rarely if ever used for square brackets [] or curly brackets {} without the adjective.

[issue32474] argparse nargs should support string wrapped integers too

2017-12-31 Thread Steven D'Aprano
New submission from Steven D'Aprano : What do you mean by "string wrapped integers", and how should it support them? -- nosy: +steven.daprano ___ Python tracker <https://bugs.pyt

[issue32474] argparse nargs should support string wrapped integers too

2017-12-31 Thread Steven D'Aprano
Steven D'Aprano added the comment: > Values like "1", "2", "3", should be supported. You mean you want to call parser.add_argument('--foo', nargs="2") instead of parser.add_argument('--foo', nargs=2)? Why? --

[issue32508] Problem while reading back from a list of lists

2018-01-06 Thread Steven D'Aprano
Steven D'Aprano added the comment: It isn't clear to me what bug you are reporting here: - What do you mean by "problem reading back from a list of lists"? What sort of problem? - What makes you think that there is a bug in the interpreter, rather than in your own code?

[issue32509] doctest syntax ambiguity between continuation line and ellipsis

2018-01-06 Thread Steven D'Aprano
Steven D'Aprano added the comment: Here's a simple demonstration of the issue: # --- cut %< --- import doctest def hash_files(): """ >>> hash_files() # doctest: +ELLIPSIS ... d41d8cd98f00b204e9800998ecf8427e _

[issue32509] doctest syntax ambiguity between continuation line and ellipsis

2018-01-06 Thread Steven D'Aprano
Steven D'Aprano added the comment: Oops, somehow managed to accidentally unsubscribe r.david.murray -- nosy: +r.david.murray ___ Python tracker <https://bugs.python.org/is

[issue32509] doctest syntax ambiguity between continuation line and ellipsis

2018-01-07 Thread Steven D'Aprano
Steven D'Aprano added the comment: Tim Peters said: > Right, "..." immediately after a ">>>" line is taken to indicate a code > continuation line, and there's no way to stop that short of rewriting the > parser. I haven't gone through t

[issue32510] Broken comparisons (probably caused by wrong caching of values)

2018-01-07 Thread Steven D'Aprano
Steven D'Aprano added the comment: That is nearly two hundred lines of quite complex code. What results are you expecting and what results are you getting? I've just tried running it under Python 3.3 and 3.5 on a RedHat-based Linux, and after generating a large amount of output (27

[issue32510] Broken comparisons (probably caused by wrong caching of values)

2018-01-07 Thread Steven D'Aprano
Steven D'Aprano added the comment: Oh, by the way... are you aware that the Recursor class defines a class attribute `branches` which is shared by all instances? You create multiple recursor objects, but they all share the same `branches` attribute. That might be intentional, but i

[issue33574] Conversion of Number to String(str(number))

2018-05-19 Thread Steven D'Aprano
Steven D'Aprano added the comment: Also note that shadowing builtins *deliberately* is a powerful and useful technique used for advanced programming. -- nosy: +steven.daprano ___ Python tracker <https://bugs.python.org/is

[issue33573] statistics.median does not work with ordinal scale

2018-05-19 Thread Steven D'Aprano
Steven D'Aprano added the comment: For ordinal scales, you should use either median_low or median_high. I don't think the standard median function ought to choose for you whether to take the low or high median. It is better to be explicit about which you want, by calling th

[issue33573] statistics.median does not work with ordinal scale

2018-05-19 Thread Steven D'Aprano
Steven D'Aprano added the comment: By the way, this isn't a crash (that's for things which cause the interpreter to segfault). I'm marking this as Not a bug, but I'm open to suggestions to improve either the documentation or the median functions. -- resol

[issue33430] Import secrets module in secrets examples

2018-05-19 Thread Steven D'Aprano
Steven D'Aprano added the comment: Unless I've mucked it up, I just committed your patch on Github so I'm closing this ticket. Thanks. -- stage: patch review -> resolved status: open -> closed ___ Python tracker <https://bu

[issue33573] statistics.median does not work with ordinal scale

2018-05-19 Thread Steven D'Aprano
Steven D'Aprano added the comment: What do you think of adding a note in the documentation for median? "If your data is ordinal (supports order operations) but not numeric (doesn't support addition), you should use ``median_low`` or ``median

[issue33588] Unicode function arguments aren't preserved

2018-05-20 Thread Steven D'Aprano
Steven D'Aprano added the comment: This does seem to be a normalisation issue: py> unicodedata.normalize('NFKC', 'ϵαγϕ') == ''.join(func.__code__.co_varnames) True so I'm closing this as not a bug. Mike, thank you for copying and pasting the relevan

[issue33636] Unexpected behavior with * and arrays

2018-05-24 Thread Steven D'Aprano
Steven D'Aprano added the comment: This is not a bug, it is the documented behaviour: the * operator does not copy the lists, it duplicates references to the same list. There's even a FAQ for it: https://docs.python.org/3/faq/programming.html#how-do-i-create-a-multidimens

[issue33636] Unexpected behavior with * and arrays

2018-05-24 Thread Steven D'Aprano
Steven D'Aprano added the comment: Nathan, the bug tracker is not the place to debate Python behaviour. For the purposes of the bug tracker, all we need say is that it is documented behaviour and not a bug. If you want to change that behaviour, there is a process to follow, and asking s

[issue33681] itertools.groupby() returned igroup is only callable once

2018-05-29 Thread Steven D'Aprano
Steven D'Aprano added the comment: This is standard behaviour for all iterators. Once you have iterated over them once, they are consumed, and iterating over them again returns nothing: py> it = iter("abc") py> print(list(it)) ['a', 'b', &#x

[issue33682] Optimize the bytecode for float(0) ?

2018-05-29 Thread Steven D'Aprano
Steven D'Aprano added the comment: I'm sorry, it isn't clear what optimizations for float(X) and int(X) you are referring to. I can only guess that you want to optimize: float(0) to use LOAD_CONST 0.0 instead of calling the float() function. If that is what you want, w

[issue33685] Instances bound methods with different memory addresses but sharing same id

2018-05-29 Thread Steven D'Aprano
Steven D'Aprano added the comment: ID numbers in Python are only guaranteed to be unique for the lifespan of the object. In CPython they can be re-used. (In other implementations, like Jython and IronPython, IDs are allocated as sequential numbers and won't be reused.) The othe

[issue33705] Unicode is normalised after keywords are checked for

2018-05-30 Thread Steven D'Aprano
New submission from Steven D'Aprano : There is a loophole in the Unicode normalisation which allows the creation of names matching keywords. class Spam: locals()['if'] = 1 Spam.𝐢𝐟# U+1D422 U+1D41F # returns 1 Those two characters are 'MATHEMATICAL BOLD SMALL

[issue33705] Unicode is normalised after keywords are checked for

2018-05-30 Thread Steven D'Aprano
Steven D'Aprano added the comment: Possibly the correct term is canonicalisation rather than normalisation, although I think the two are interchangeable. -- ___ Python tracker <https://bugs.python.org/is

[issue33728] pandas.to_records can not be saved by numpy.savez

2018-05-31 Thread Steven D'Aprano
Steven D'Aprano added the comment: Sorry, this tracker is for the interpreter and standard library. For bugs in third party code like numpy and pandas, you will have to report it on their own bug trackers. -- nosy: +steven.daprano resolution: -> third party stage: -&g

[issue33721] os.path.exists() ought to return False if pathname contains NUL

2018-06-02 Thread Steven D'Aprano
Change by Steven D'Aprano : -- nosy: +steven.daprano ___ Python tracker <https://bugs.python.org/issue33721> ___ ___ Python-bugs-list mailing list Unsubscr

[issue33790] Decorated (inner/wrapped) function kwarg defaults dont pass through decorator.

2018-06-06 Thread Steven D'Aprano
Steven D'Aprano added the comment: I think you have misunderstood where and when default arguments are assigned. When you call func() with no arguments, kwargs is empty, and it is correct that the output will be -> Decorator: In the following line, you call the original fun

[issue33814] exec() maybe has a memory leak

2018-06-09 Thread Steven D'Aprano
Steven D'Aprano added the comment: Perhaps a little less self-righteous anger and a little more detail on this alleged bug would be appropriate. Quote: I still think it's ridiculous that every item added to that dict has an "extra", non-obvious reference count t

[issue33814] exec() maybe has a memory leak

2018-06-09 Thread Steven D'Aprano
Steven D'Aprano added the comment: I decided to risk this "catastrophic" leak, and ran this: py> x = leaks() py> x ((2, 3), , 24) py> import gc py> gc.collect() 22 py> x ((2, 3), , 24) so I think Eric is correct, it is just a garbage collection issue. Po

[issue33835] Too strong side effect?

2018-06-11 Thread Steven D'Aprano
Steven D'Aprano added the comment: Both names "v1" and "v2" refer to the same object. Python does not make copies of objects on assignment, so if you write: a = [] b = a then a and b both refer to the same list object, and the names "a" and "b&quo

[issue33856] Type "help" is not present on win32

2018-06-14 Thread Steven D'Aprano
New submission from Steven D'Aprano : What do you mean "type help"? help() is added by the site module, if you've done something to skip running the site module it won't be added. Can you give an example of what you are trying to do, what happens and what you expe

[issue33721] os.path.exists() ought to return False if pathname contains NUL

2018-06-14 Thread Steven D'Aprano
Steven D'Aprano added the comment: Eric wrote: > I don't know of any OS that supports NULs in filenames HFS, HFS Plus, and Apple File System all support NULs in filenames. HFS Plus volumes include a special special directory called the metadata directory, in the volume

[issue33721] os.path.exists() ought to return False if pathname contains NUL

2018-06-14 Thread Steven D'Aprano
Steven D'Aprano added the comment: Eryk Sun says: > It has to be a ValueError since the error is an invalid parameter at the > Python level. How does the first follow from the second? Strings with NULs in them aren't errors or invalid parameters at the Python level, and the

[issue33865] unknown encoding: 874

2018-06-14 Thread Steven D'Aprano
Steven D'Aprano added the comment: Please don't post screenshots of text, they make it difficult for the blind and visually impaired to contribute. Instead, please copy and paste the error message into the body of your bug report. (Which I see you have done, which makes the

[issue33893] Linux terminal shortcuts support in python shell

2018-06-18 Thread Steven D'Aprano
Steven D'Aprano added the comment: Terry asked: > I have a question about Linux consoles. [...] Does a Linux console retrieve > all 5 at once, as IDLE does? Not typically. Like the Windows console, Linux consoles are also line-oriented, and hitting up-arrow cycles through each l

[issue33991] lib2to3 should parse f-strings

2018-06-28 Thread Steven D'Aprano
Steven D'Aprano added the comment: I'm curious how you are getting f-strings (introduced in Python 3.6) in Python 2 code that you are passing to 2to3. -- nosy: +steven.daprano ___ Python tracker <https://bugs.python.o

[issue33991] lib2to3 should parse f-strings

2018-06-29 Thread Steven D'Aprano
Steven D'Aprano added the comment: > @Steven lib2to3 is no longer specifically for python 2 code, it also > parses python 3 code Ah, all good then. Thanks. -- ___ Python tracker <https://bugs.python.

[issue33998] random.randrange completely ignores the step argument when stop is None

2018-06-29 Thread Steven D'Aprano
Steven D'Aprano added the comment: "I have a really hard time believing that [...] others haven't noticed this rather glaring flaw in the code." *shrug* Easy or hard for you to believe, nevertheless this same quote-unquote "flaw" goes back to Python 1.5 or

[issue34039] Loop limited to 1000

2018-07-04 Thread Steven D'Aprano
Steven D'Aprano added the comment: Sorry, this is for reporting bugs in the Python interpreter and standard library, not your own code. If you have a bug in your pyinator project, you should report it to yourself, not us :-) If you think my analysis of the problem below is wrong, and

[issue34346] dir() hangs interpreter

2018-08-06 Thread Steven D'Aprano
Steven D'Aprano added the comment: I don't think the description you give is very accurate. The description in the file splat.py says: "Hangs/core dumps Python2 when instantiated" (which is it? hang or core dump?) but I can't replicate that. Instantiating A() i

[issue34358] round() combined with product outputs ugly result

2018-08-08 Thread Steven D'Aprano
Change by Steven D'Aprano : -- resolution: -> not a bug stage: -> resolved status: open -> closed ___ Python tracker <https://bugs.pyth

[issue34437] print statement using \x results in improper and extra bytes

2018-08-19 Thread Steven D'Aprano
Steven D'Aprano added the comment: You wrote: > There are 6 bytes not 4 and where did the c3, bd, and c2 come from? In Python 2, strings are byte strings, in Python 3, strings by default are Unicode text strings. You are seeing the UTF-8 representation of the text string. py>

[issue34483] eval() raises NameError: name '...' is not defined

2018-08-23 Thread Steven D'Aprano
Change by Steven D'Aprano : -- nosy: +steven.daprano ___ Python tracker <https://bugs.python.org/issue34483> ___ ___ Python-bugs-list mailing list Unsubscr

[issue34543] _struct.Struct: calling functions without calling __init__ results in SystemError

2018-08-29 Thread Steven D'Aprano
Steven D'Aprano added the comment: This exception goes back to at least Python 2.6 (if not older) but I'm not convinced it is a bug. Calling __new__ alone is not guaranteed to initialise a new instance completely. The public API for creating an instance is to call the class obje

[issue34543] _struct.Struct: calling functions without calling __init__ results in SystemError

2018-08-29 Thread Steven D'Aprano
Steven D'Aprano added the comment: _struct is a private implementation detail. You shouldn't use it. You shouldn't care where the implementation "really is" in your Python code, because it could move without warning. There are no backwards-compatibility guarantees

[issue34543] _struct.Struct: calling functions without calling __init__ results in SystemError

2018-09-02 Thread Steven D'Aprano
Steven D'Aprano added the comment: I've tried running this code in Python 3.6: from _struct import Struct for i in range(10): L = [Struct.__new__(Struct) for j in range(1000)] for s in L: try: x = s.pack_into(bytearray()) except S

[issue34543] _struct.Struct: calling functions without calling __init__ results in SystemError

2018-09-03 Thread Steven D'Aprano
Steven D'Aprano added the comment: Thanks for confirming the seg fault. I've changed this to a crasher. Should we change the exception to RuntimeError? -- components: +Library (Lib) -Extension Modules type: behavior -> crash ___ P

[issue34596] [unittest] raise error if @skip is used with an argument that looks like a test method

2018-09-06 Thread Steven D'Aprano
Steven D'Aprano added the comment: Is there a use-case for reason to be anything but a string? -- nosy: +steven.daprano ___ Python tracker <https://bugs.python.org/is

[issue34605] Avoid master/slave terminology

2018-09-07 Thread Steven D'Aprano
Steven D'Aprano added the comment: I strongly disagree with this as a general principle. "Master/slave" is a powerful, obvious metaphor which works well and is not the same as parent/child, server/client or employer/worker. In fact, in the BDSM subcultures, "master/slave

[issue34596] [unittest] raise error if @skip is used with an argument that looks like a test method

2018-09-09 Thread Steven D'Aprano
Steven D'Aprano added the comment: For what its worth, I'm +1 with Serhiy that we raise an exception on a non-string argument, including the case where the caller forgets to provide a reason at all. I don't think that @skip with no reason was ever intended to work (it c

[issue34644] Bug in reverse method

2018-09-12 Thread Steven D'Aprano
Steven D'Aprano added the comment: This is not a bug or a syntax error, and the behaviour goes back to at least Python 1.5 if not older. List.reverse returns a reference to the method object itself. List.reverse() *calls* the method. This is standard behaviour in Python, all method

[issue34645] math and numpy yield different results (nan)

2018-09-12 Thread Steven D'Aprano
Steven D'Aprano added the comment: Your code gives runtime warnings of invalid values. You should fix that. If your values are invalid, there's probably a bug in your code. RuntimeWarning: invalid value encountered in double_scalars Your code is also very complex. You ought to si

[issue34645] math and numpy yield different results (nan)

2018-09-12 Thread Steven D'Aprano
Steven D'Aprano added the comment: Oops, sorry, I mistyped. I said: So there's a problem. You're trying to raise a negative number to a positive value I meant to say a *fractional* value. Sorry for the confusion. -- ___

[issue34645] math and numpy yield different results (nan)

2018-09-12 Thread Steven D'Aprano
Steven D'Aprano added the comment: > Well, the thing is that i pass two (apparent) identical values into the same > function, Even if they have the same *numeric* value, they aren't the same kind of value, and they aren't the same function. One is and the othe

[issue34709] Suggestion: make getuser.getpass() also look at SUDO_USER environment variable

2018-09-27 Thread Steven D'Aprano
Steven D'Aprano added the comment: Versions 3.7 and below are all in feature-freeze, so this change could only apply to 3.8 and above. I don't know if this feature is desirable or not. If it is (sometimes?) desirable, my guess is that it would be undesirable to use SUDO_USER *u

[issue34763] Python lacks 0x4E17

2018-09-27 Thread Steven D'Aprano
Change by Steven D'Aprano : -- nosy: +steven.daprano ___ Python tracker <https://bugs.python.org/issue34763> ___ ___ Python-bugs-list mailing list Unsubscr

[issue34835] Multiprocessing module update fails with pip3

2018-09-28 Thread Steven D'Aprano
Steven D'Aprano added the comment: ``pip3 search multiprocessing`` says: multiprocessing (2.6.2.1)- Backport of the multiprocessing package to Python 2.4 and 2.5 so you are trying to install a Python 2.4/2.5 package into Python 3.7, which naturally cannot work. In Pytho

[issue34850] Emit a syntax warning for "is" with a literal

2018-09-30 Thread Steven D'Aprano
Steven D'Aprano added the comment: I like this solution of a syntax warning for `is ` and I agree that `== None` should not be a warning. (And for what its worth, I strongly disagree with making `is` a hybrid sometimes-check-identity-sometimes-check-equality operator.) --

[issue34850] Emit a syntax warning for "is" with a literal

2018-10-01 Thread Steven D'Aprano
Steven D'Aprano added the comment: On Sun, Sep 30, 2018 at 10:24:41PM +, Nathaniel Smith wrote: > Would it make sense to implement a "chaos" mode (that e.g. testing > tools could enable unconditionally), that disables the small integer > and small string caches?

[issue34867] Add mode to disable small integer and interned string caches

2018-10-01 Thread Steven D'Aprano
New submission from Steven D'Aprano : Split off from #34850 by Guido's request. To help catch incorrect use of `is` when `==` is intended, perhaps we should add an interpreter mode that disables the caches for small ints and interned strings. Nathaniel called it "chaos mo

[issue34850] Emit a syntax warning for "is" with a literal

2018-10-01 Thread Steven D'Aprano
Steven D'Aprano added the comment: Please move the "chaos" discussion to #34867 -- ___ Python tracker <https://bugs.python.org/issue34850> ___ ___

[issue34880] About the "assert" bytecode

2018-10-03 Thread Steven D'Aprano
Steven D'Aprano added the comment: If I have understood you correctly, you are asking whether it is expected behaviour for assert to use the global AssertionError instead of the built-in AssertionError. I don't see why it shouldn't. In any case, that behaviour goes back to

[issue34880] About the "assert" bytecode

2018-10-03 Thread Steven D'Aprano
Steven D'Aprano added the comment: On Wed, Oct 03, 2018 at 09:49:06AM +, thautwarm wrote: > Steven, this problem is quite interesting because it just allows users > to cause fatal errors without any invalid operations. How is that different from every other case of shadowin

[issue34880] About the "assert" bytecode

2018-10-03 Thread Steven D'Aprano
Steven D'Aprano added the comment: On Wed, Oct 03, 2018 at 01:56:00PM +, Eric V. Smith wrote: > I think this is a bug that should be fixed. Supporting this position, shadowing other exceptions doesn't change the exception generated by the interpreter: py> TypeError =

[issue34880] About the "assert" bytecode

2018-10-03 Thread Steven D'Aprano
Steven D'Aprano added the comment: > And, I think a broader discussion on python-dev might be useful, too, in > order to get more opinions. Done: https://mail.python.org/pipermail/python-dev/2018-October/155410.html Changing the status to Pending until we have more clarity on w

[issue34907] calculation not working properly

2018-10-05 Thread Steven D'Aprano
Steven D'Aprano added the comment: For future reference, please don't post unnecessary screen shots and images. Code is text, please copy and paste it as text, not as pixels. Images make it difficult or impossible for the blind and visually impaired to contribute. -

[issue22232] str.splitlines splitting on non-\r\n characters

2018-10-07 Thread Steven D'Aprano
Steven D'Aprano added the comment: I don't like the idea of adding a second bool parameter to splitlines. Guido has a rough rule of thumb (which I agree with) of "no constant bool parameters". If people will typically call a function with some sort of "mode"

[issue33084] Computing median, median_high an median_low in statistics library

2018-10-07 Thread Steven D'Aprano
Steven D'Aprano added the comment: I want to revisit this for 3.8. I agree that the current implementation-dependent behaviour when there are NANs in the data is troublesome. But I don't think that there is a single right answer. I also agree with Mark that if we change median, w

[issue28716] Fractions instantiation revisited

2018-10-07 Thread Steven D'Aprano
Change by Steven D'Aprano : -- nosy: +steven.daprano ___ Python tracker <https://bugs.python.org/issue28716> ___ ___ Python-bugs-list mailing list Unsubscr

[issue34928] string method .upper() converts 'ß' to 'SS' instead of 'ẞ'

2018-10-08 Thread Steven D'Aprano
Steven D'Aprano added the comment: We match the Unicode specification, not arbitrary language rules. (Austrian and Swiss German are, I believe, phasing out ß altogether, and haven't added an uppercase variant.) Until the Unicode consortium change their case conversion rules, i

[issue34948] Document __warningregister__

2018-10-09 Thread Steven D'Aprano
New submission from Steven D'Aprano : The warnings module makes use of a per-module global ``__warningregister__`` which is briefly mentioned in the docs but not documented. https://docs.python.org/3/library/warnings.html#warnings.warn_explicit Given that it is part of the warn_explici

[issue34948] Document __warningregister__

2018-10-10 Thread Steven D'Aprano
Steven D'Aprano added the comment: On Wed, Oct 10, 2018 at 05:11:01AM +, Serhiy Storchaka wrote: > I don't think that it is necessary to state its format. It is an > opaque dictionary, and its format is an implementation detail. There is at least one use-case for wanti

[issue34991] variable type list [] referential integrity data loss

2018-10-15 Thread Steven D'Aprano
Steven D'Aprano added the comment: I don't know what you mean by "referential integrity data loss". I have absolutely no idea how to interpret the wall of output you have provided. If there is a bug here, how do you know it is a language bug rather than a bug in your

[issue35010] sort by partially reversed key tuple

2018-10-17 Thread Steven D'Aprano
Steven D'Aprano added the comment: Since sort is guaranteed to be stable, can't you sort in two runs? py> values = ['bc', 'da', 'ba', 'abx', 'ac', 'ce', 'dc', 'ca', 'aby'] py> values.so

[issue35010] sort by partially reversed key tuple

2018-10-17 Thread Steven D'Aprano
Steven D'Aprano added the comment: The ``sorted`` docs links to the Sorting HOWTO, the ``list.sort`` docs should do the same. https://docs.python.org/3/library/functions.html#sorted https://docs.python.org/3/library/stdtypes.html#list

[issue35010] sort by partially reversed key tuple

2018-10-17 Thread Steven D'Aprano
Steven D'Aprano added the comment: > And you are free to use whatever sorting algorithms in its implementation for > this kind of task. That's very kind of you *wink* At this point, I don't think there's much more point to discussing this further until Tim Peters

[issue35069] Unexecuted import in function causes UnboundLocalError

2018-10-25 Thread Steven D'Aprano
Steven D'Aprano added the comment: This is expected behaviour: import is a form of assignment. "import logging", like "logging = 1", tells the compiler to treat logging as a local variable (unless you declare logging as global). As the exception says, you are try

[issue35069] Unexecuted import in function causes UnboundLocalError

2018-10-25 Thread Steven D'Aprano
Steven D'Aprano added the comment: Stéphane, I'm curious why you asked for a pastebin when James already provided the code right here in the tracker? (Your email even included a copy of that code.) Why split the information into anoth

[issue35069] Unexecuted import in function causes UnboundLocalError

2018-10-25 Thread Steven D'Aprano
Steven D'Aprano added the comment: Yes, that's exactly right. That's how local variables work in Python: x = 999 # global x def demo(): if False: x = 1 x # local x has no value does the same thing. This is standard, documented behaviour, regardless of which kin

[issue35085] FileNotFoundError: [Errno 2] No such file or directory:

2018-10-27 Thread Steven D'Aprano
Steven D'Aprano added the comment: What do you mean, a crash report? You get a traceback telling you the problem: the file is missing. What behaviour did you expect if you try to decode a non-existent file? Perhaps you meant to write: python3 -m base64 -t "12s345a2" I don&

[issue35085] FileNotFoundError: [Errno 2] No such file or directory:

2018-10-28 Thread Steven D'Aprano
Change by Steven D'Aprano : -- resolution: -> not a bug stage: -> resolved status: open -> closed ___ Python tracker <https://bugs.pyth

[issue35098] Deleting __new__ does not restore previous behavior

2018-10-28 Thread Steven D'Aprano
Steven D'Aprano added the comment: I think the real WTF here is that you can write to arbitrary dunder attributes even if they aren't listed in __slots__. py> Color.__NOBODY_expects_the_Spanish_Inquisition__ = "What?" py> Color.__NOBODY_expects_the_Spanish_Inquisiti

[issue35098] Deleting __new__ does not restore previous behavior

2018-10-28 Thread Steven D'Aprano
Steven D'Aprano added the comment: > Its quite valid to assign to __new__ to replace the behavior of how an > instance is created. Of course it is, and I never argued otherwise. > Finally as for `Color.__x__` assignment, this has nothing to do with > `__slots__` as i

[issue35129] Different behaviour comparing versions (distutils.version.LooseVersion) between python2.7 and python3.x

2018-10-31 Thread Steven D'Aprano
Steven D'Aprano added the comment: There is no need to split the relevant code into a third-party website, especially when it is so small and can be included in-line here. Python 2.7: py> import distutils.version py> distutils.version.LooseVersion('7') > distutils.

[issue35123] Add style guide for sentinel usage

2018-10-31 Thread Steven D'Aprano
Steven D'Aprano added the comment: I was not aware that there currently were arguments about the use of sentinels in future code. I feel that you are being excessively prescriptive here: "we should nip it in the bud" is good advice for gardening, but for programming it just r

[issue35124] Add style guide for unit tests

2018-10-31 Thread Steven D'Aprano
Steven D'Aprano added the comment: I think this is being excessively prescriptive and solving a problem that isn't a problem. But perhaps if you start by proposing a concrete style guide, I can judge better. -- nosy: +steven.daprano

[issue35146] Bad Regular Expression Broke re.findall()

2018-11-02 Thread Steven D'Aprano
Steven D'Aprano added the comment: This is not a bug in Python, it is an invalid (broken) regular expression. There is nothing that the interpreter or the regular expression engine can do, because you are telling it to do something that makes no sense. What do you expect findall to fin

[issue35165] Possible wrong method name in attribute references doc

2018-11-04 Thread Steven D'Aprano
Steven D'Aprano added the comment: https://docs.python.org/3/reference/expressions.html#attribute-references __getattr__ is the correct method to override in most (but not all) cases. I don't think we should encourage people to override __getattribute__ as the fi

<    6   7   8   9   10   11   12   13   14   15   >