[issue32683] isinstance is calling ob.__getattribute__ as a fallback instead of object.__class__.__get__

2021-12-09 Thread Steven D'Aprano
Steven D'Aprano added the comment: I agree that the rules regarding type and `__class__` and isinstance are not clear or well documented. We have: https://docs.python.org/3/library/stdtypes.html#instance.__class__ https://docs.python.org/3/library/functions.html#isinstance but ne

[issue32683] isinstance is calling ob.__getattribute__ as a fallback instead of object.__class__.__get__

2021-12-09 Thread Steven D'Aprano
Steven D'Aprano added the comment: On Fri, Dec 10, 2021 at 12:03:15AM +, Gabriele N Tornetta wrote: > class Side(object): > def __getattribute__(self, name): > ValueError(name) You forgot to actually *raise* the exception. That will just instantiate the Value

[issue32683] isinstance is calling ob.__getattribute__ as a fallback instead of object.__class__.__get__

2021-12-10 Thread Steven D'Aprano
Steven D'Aprano added the comment: The plot thickens. I was wrong to say that type() always and only looks at the "real" underlying type of the instance. type() does look at __class__ as well. But only sometimes. >>> class A: ... __class__ = int ... >>

[issue23522] Misleading note in Statistics module documentation

2021-12-16 Thread Steven D'Aprano
Steven D'Aprano added the comment: Prompted by Guido's reopening of the ticket, I have given it some more thought, and have softened my views. Jake if you're still around, perhaps there is more to what you said than I initially thought, and I just needed fresh eyes to see

[issue46112] PEP 8 code format

2021-12-17 Thread Steven D'Aprano
Steven D'Aprano added the comment: > not complied with the PEP-8 formatting. PEP 8 says: "Some other good reasons to ignore a particular guideline: 3. Because the code in question predates the introduction of the guideline and there is no other reason to be modifying that cod

[issue46153] function fails in exec when locals is given

2021-12-22 Thread Steven D'Aprano
Steven D'Aprano added the comment: The function you use in exec is not a closure. The function: def f(): return a does not capture the top-level variable "a", it does a normal name lookup for a. You can check this yourself by looking at f.__closure__ which you wi

[issue46153] function fails in exec when locals is given

2021-12-22 Thread Steven D'Aprano
Steven D'Aprano added the comment: Here is the key phrase in the docs: "If exec gets two separate objects as globals and locals, the code will be executed as if it were embedded in a class definition." https://docs.python.org/3/library/functions.html#exec And sure enoug

[issue46153] function fails in exec when locals is given

2021-12-22 Thread Steven D'Aprano
Steven D'Aprano added the comment: > I now want to define a closure with exec. I might want to do something like: > exec("def f(): return a", globals(), locals()) That doesn't create a closure. > I would expect f() to look for a in the locals(). I'm

[issue46153] function fails in exec when locals is given

2021-12-22 Thread Steven D'Aprano
Steven D'Aprano added the comment: "Expected" is a strong word. It took me a lot of careful reading of the documentation and experimentation to decide that, yes, I expect the second case to fail when the first case succeeds. Which reminds me of a common anecdote from math

[issue46153] function fails in exec when locals is given

2021-12-22 Thread Steven D'Aprano
Steven D'Aprano added the comment: On Thu, Dec 23, 2021 at 12:15:29AM +, Eryk Sun wrote: > > Eryk Sun added the comment: > > > If exec gets two separate objects as globals and locals, > > the code will be executed as if it were embedded in a > >

[issue46153] function fails in exec when locals is given

2021-12-23 Thread Steven D'Aprano
Steven D'Aprano added the comment: On Thu, Dec 23, 2021 at 05:47:33AM +, Eryk Sun wrote: > > Eryk Sun added the comment: > > > That's taken straight out of the documentation. > > Yes, but it's still a misleading comparison. I asked how you wou

[issue46164] New `both()` operator for matching multiple variables to one

2021-12-23 Thread Steven D'Aprano
Steven D'Aprano added the comment: Just use if a == b == 1: Comparisons can be chained arbitrarily. https://docs.python.org/3/reference/expressions.html#comparisons -- nosy: +steven.daprano resolution: -> rejected stage: -> resolved status: ope

[issue46173] float(x) with large x not raise OverflowError

2021-12-24 Thread Steven D'Aprano
Steven D'Aprano added the comment: float(x) performs rounding. Only if the value after rounding is out of range is OverflowError raised. M + 1, when correctly rounded to the nearest even float, gives sys.float_info.max. Likewise for M+2, M+3 etc all the way to M+K where K equals 2

[issue46183] float function errors on negative number string with comma seperator ex: '-1, 234.0'

2021-12-26 Thread Steven D'Aprano
Steven D'Aprano added the comment: The behaviour is correct and not a bug. Commas are not supported when converting strings to float. The allowed format for floats as strings is described in the docs: https://docs.python.org/3/library/functions.html#float By the way, the negative si

[issue46183] float function errors on negative number string with comma seperator ex: '-1, 234.0'

2021-12-26 Thread Steven D'Aprano
Steven D'Aprano added the comment: Aside: for what it is worth, the British style with a middle dot is also not supported: float('1ยท234') also raises ValueError. -- ___ Python tracker <https://bugs.pyt

[issue46188] dictionary creation error

2021-12-28 Thread Steven D'Aprano
Steven D'Aprano added the comment: > I still can not figure out why the first two elements are inconsistent from the rest of the dictionary, and why they appear in the first place. Hi Tobias, This is a bug tracker for reporting bugs in Python, not a help desk to ask for explanati

[issue46199] Calculation influenced by print

2021-12-30 Thread Steven D'Aprano
Steven D'Aprano added the comment: Please try to provide a minimal reproducible example: https://stackoverflow.com/help/minimal-reproducible-example http://sscce.org/ At the very least, you need to provide three pieces of information: 1. What you tried. 2. What you expected to happen

[issue46213] webbrowser.open doesn't work in Termux

2021-12-31 Thread Steven D'Aprano
Steven D'Aprano added the comment: I think the existence of sys.getandroidapilevel is evidence that Android is somewhat supported, even if it is not supported to the same degree that Linux and Windows are. https://docs.python.org/3/library/sys.html#sys.getandroidapilevel See also:

[issue46282] print() docs do not indicate its return value

2022-01-06 Thread Steven D'Aprano
New submission from Steven D'Aprano : Do the print docs need to mention something so obvious? Functions and methods which operate by side-effect typically don't mention that they return None, see for example the docs for various builtin methods: https://docs.python.org

[issue46282] print() docs do not indicate its return value

2022-01-06 Thread Steven D'Aprano
Steven D'Aprano added the comment: Sure, there will always be some users who will find certain things not obvious. Sometimes I'm that user myself. What did this user think print() returned? What precisely was their question? Perhaps if I saw the conversation in context, I wou

[issue46293] Typo in specifying escape sequence

2022-01-07 Thread Steven D'Aprano
Steven D'Aprano added the comment: Serhiy is correct. The table is correct, \n can be found further down the table, the first entry is backslash newline, as it says. -- nosy: +steven.daprano resolution: -> not a bug stage: -> resolved status: ope

[issue46302] IndexError inside list comprehension + workaround

2022-01-07 Thread Steven D'Aprano
Steven D'Aprano added the comment: > it returns IndexError (instead of "u") if used in a list comprehension Works as expected inside a list comprehension: >>> var = "u2" >>> [var.strip()[0] for i in range(2)] ['u', 'u'] >

[issue46302] IndexError inside list comprehension + workaround

2022-01-07 Thread Steven D'Aprano
Steven D'Aprano added the comment: Your functions test1 and test2 are irrelevant to the bug report. The driver code using eval() to pick which function to call is unneeded. The business of simulating a file is complexity for no purpose. Those ignore, count, unique functions are

[issue46324] 'import traceback' Causes a Crash

2022-01-09 Thread Steven D'Aprano
Steven D'Aprano added the comment: Your module token.py "shadowed" the stdlib token.py, and prevented it from being seen until you changed the name. -- nosy: +steven.daprano resolution: -> not a bug stage: -> resolved status: open -> closed

[issue46349] inspect.getdoc() should append parent class method docs when encountering a local one line docstring

2022-01-11 Thread Steven D'Aprano
Steven D'Aprano added the comment: Many docstrings are only 1 line without being "See base class." And many docstrings are multiple lines while also referring the reader to see the parent class for further details. So this DWIM heuristic to guess whether or not to display

[issue46350] re.sub, re.Match.expand, etc doesn't allow x, u, U, or N escapes in the template

2022-01-11 Thread Steven D'Aprano
Steven D'Aprano added the comment: It is better to raise each issue in its own ticket. You seem to have three distinct issues here: - The issue listed in the title, which I don't understand. A demonstration of the issue would be helpful. - The unrelated(?) issue of bad \N{} esca

[issue46354] AttributeError: module 'collections' has no attribute 'Mapping'

2022-01-12 Thread Steven D'Aprano
Steven D'Aprano added the comment: Hi mareklachbc, What makes you think that this is a bug? Since at least version 3.7, you will have seen this warning: >>> import collections >>> collections.Mapping __main__:1: DeprecationWarning: Using or

[issue46365] _ curses module is not installed

2022-01-13 Thread Steven D'Aprano
Steven D'Aprano added the comment: Did you look in setup.py in detect_modules() for the module's name to see what was missing? How do you know the curses dependencies have been installed? What dependencies did you install? -- nosy: +stev

[issue46385] Remove parenthetical symbols for readability and nlp

2022-01-14 Thread Steven D'Aprano
Steven D'Aprano added the comment: Dennis beat me to it in saying that tuples cannot be replaced by lists. But I also wanted to say that it is *not true* that removing bracket symbols would increase readability. Natural language allows parenthetical phrases -- which can be bracketed

[issue46385] Remove parenthetical symbols for readability and nlp

2022-01-14 Thread Steven D'Aprano
Steven D'Aprano added the comment: Please don't reopen this issue. If you really want to take it to the Python-Ideas mailing list, you can: https://mail.python.org/mailman3/lists/python-ideas.python.org/ or to Discuss: https://discuss.python.org/c/ideas/6 -- status: open

[issue46393] Generate frozenset constants when explicitly appropriate

2022-01-15 Thread Steven D'Aprano
Steven D'Aprano added the comment: The difficulty is that frozenset may have been shadowed, or builtins monkey-patched, so we cannot know what frozenset({1, 2, 3}) will return until runtime. Should we re-consider a frozenset display literal? f{1, 2, 3} works for me. --

[issue46393] Generate frozenset constants when explicitly appropriate

2022-01-16 Thread Steven D'Aprano
Steven D'Aprano added the comment: Proposed on Python-Ideas. https://mail.python.org/archives/list/python-id...@python.org/message/GRMNMWUQXG67PXXNZ4W7W27AQTCB6UQQ/ -- ___ Python tracker <https://bugs.python.org/is

[issue46393] Generate frozenset constants when explicitly appropriate

2022-01-16 Thread Steven D'Aprano
Steven D'Aprano added the comment: That's not always the case though. >>> def f(): ... return frozenset({1, 2, 3}) ... >>> a = f.__code__.co_consts[1] >>> a frozenset({1, 2, 3}) >>> b = f() >>> assert a == b >>>

[issue46466] help function reads comments

2022-01-21 Thread Steven D'Aprano
Steven D'Aprano added the comment: That's not a bug. https://docs.python.org/3/library/pydoc.html "If there is no docstring, pydoc tries to obtain a description from the block of comment lines just above the definition of the class, function or method in the source file, o

[issue46467] Rounding 5, 50, 500 behaves differently depending on preceding value

2022-01-21 Thread Steven D'Aprano
Steven D'Aprano added the comment: As documented, this is not a bug. "if two multiples are equally close, rounding is done toward the even choice" https://docs.python.org/3/library/functions.html#round This is also called "Banker's Rounding" or "Round h

[issue46612] Unclear behavior of += operator

2022-02-02 Thread Steven D'Aprano
Steven D'Aprano added the comment: You say: "The documentation says ..." but don't tell us which documentation. This documentation: https://docs.python.org/3/reference/simple_stmts.html#augmented-assignment-statements tells us that augmented assignment is assign

[issue46639] Ceil division with math.ceildiv

2022-02-07 Thread Steven D'Aprano
Steven D'Aprano added the comment: I don't understand why math.ceildiv couldn't ducktype. There's no rule that says it *must* convert arguments to float first, that's just a convention, and we've broken it before. >>> math.prod([Fraction(1, 3), 7]) Fra

[issue46639] Ceil division with math.ceildiv

2022-02-07 Thread Steven D'Aprano
Steven D'Aprano added the comment: Decimal is a good question. Why does floor division not do floor division on Decimal? The documentation says The integer division operator // behaves analogously, returning the integer part of the true quotient (truncating towards zero) r

[issue39805] Copying functions doesn't actually copy them

2022-02-13 Thread Steven D'Aprano
Steven D'Aprano added the comment: If we can't change the default behaviour of copying functions, can we add a specialised copy_function() function, for when we really need to make a genuine copy? -- ___ Python tracker <https://bu

[issue46766] Add a class for file operations so a syntax such as open("file.img", File.Write | File.Binary | File.Disk) is possible.

2022-02-15 Thread Steven D'Aprano
Steven D'Aprano added the comment: I'm sorry, I don't see why you think this will improve code readability. I also expect it will be harder to teach than the current code. open("file.img", "wb") just needs the user to learn about reading and writing files

[issue46766] Add a class for file operations so a syntax such as open("file.img", File.Write | File.Binary | File.Disk) is possible.

2022-02-16 Thread Steven D'Aprano
Steven D'Aprano added the comment: True, but you did say it would be with the io module in your original suggestion. -- ___ Python tracker <https://bugs.python.org/is

[issue46776] RecursionError when using property() inside classes

2022-02-17 Thread Steven D'Aprano
Steven D'Aprano added the comment: This is not a bug, Python is working correctly here. The interpreter is doing exactly what you told it to do, and then raising a RecursionError before you can crash the system. You have a property instance.bar which returns instance.bar, which re

[issue46776] RecursionError when using property() inside classes

2022-02-17 Thread Steven D'Aprano
Steven D'Aprano added the comment: Maybe you expected to do this: class C: def __init__(self): self._value = 999 @property def bar(self): return self._value obj = C() obj.bar # returns 999 -- ___ Python tr

[issue46803] Item not shown when using mouse wheel to scroll for Listbox/Combobox

2022-02-19 Thread Steven D'Aprano
Steven D'Aprano added the comment: Replicated on Linux, Python 3.10. It looks like mousewheel scrolling jumps by the wrong amount as it pages down (or up), and consequently some lines never appear in the view area. I ran a slightly modified version of the code that had 16 entries inste

[issue46803] Item not shown when using mouse wheel to scroll for Listbox/Combobox

2022-02-20 Thread Steven D'Aprano
Change by Steven D'Aprano : -- Removed message: https://bugs.python.org/msg413566 ___ Python tracker <https://bugs.python.org/issue46803> ___ ___ Pytho

[issue46803] Item not shown when using mouse wheel to scroll for Listbox/Combobox

2022-02-20 Thread Steven D'Aprano
Change by Steven D'Aprano : -- Removed message: https://bugs.python.org/msg413567 ___ Python tracker <https://bugs.python.org/issue46803> ___ ___ Pytho

[issue46803] Item not shown when using mouse wheel to scroll for Listbox/Combobox

2022-02-20 Thread Steven D'Aprano
Change by Steven D'Aprano : -- Removed message: https://bugs.python.org/msg413568 ___ Python tracker <https://bugs.python.org/issue46803> ___ ___ Pytho

[issue46803] Item not shown when using mouse wheel to scroll for Listbox/Combobox

2022-02-20 Thread Steven D'Aprano
Change by Steven D'Aprano : -- nosy: -xiaox55066 ___ Python tracker <https://bugs.python.org/issue46803> ___ ___ Python-bugs-list mailing list Unsubscr

[issue46803] Item not shown when using mouse wheel to scroll for Listbox/Combobox

2022-02-20 Thread Steven D'Aprano
Change by Steven D'Aprano : Removed file: https://bugs.python.org/file50635/6.jpeg ___ Python tracker <https://bugs.python.org/issue46803> ___ ___ Python-bugs-list m

[issue46871] BaseManager.register no longer supports lambda callable 3.8.12+

2022-02-26 Thread Steven D'Aprano
Steven D'Aprano added the comment: Works for me in Python 3.10.0 on Linux. After running your code, I get shared_dict is a DictProxy: >>> shared_dict >>> list(shared_dict.items()) [('number', 0), ('text', 'Hello World')] and shared_lo

[issue46882] Clarify argument type of platform.platform(aliased, terse) to boolean

2022-02-28 Thread Steven D'Aprano
Steven D'Aprano added the comment: > Both arguments `aliased` and `terse` should be boolean instead of integer. Why should they be strictly True/False booleans? I disagree strongly that they should be. Any object that duck-types as a true or false value is sufficient. Trea

[issue46883] Add glossary entries to clarify the true/True and false/False distinction

2022-02-28 Thread Steven D'Aprano
New submission from Steven D'Aprano : There is a long-standing tradition, going back to Python 1.x days before we had dedicated True and False values, to use the lowercase "true" and "false" to mean *any value that duck-types as True* and *any value that duck-type

[issue46882] Clarify argument type of platform.platform(aliased, terse) to boolean

2022-02-28 Thread Steven D'Aprano
Steven D'Aprano added the comment: See #46883 -- ___ Python tracker <https://bugs.python.org/issue46882> ___ ___ Python-bugs-list mailing list Unsubscr

[issue46883] Add glossary entries to clarify the true/True and false/False distinction

2022-02-28 Thread Steven D'Aprano
Steven D'Aprano added the comment: Note also that this is mentioned here: https://docs.python.org/3/library/stdtypes.html#boolean-values "[True and False] are used to represent truth values (although other values can also be considered false or true)." although it is perha

[issue46871] Lambda can't be pickled with "spawn" and only "fork"

2022-03-01 Thread Steven D'Aprano
Steven D'Aprano added the comment: > The "spawn" method requires pickling the data and callable passed to > the child proces, and that's not supported for lambda's. Ah, today I learned something. Kyle, looks like you were right about it being due to the lambd

[issue46871] Lambda can't be pickled with "spawn" and only "fork"

2022-03-01 Thread Steven D'Aprano
Steven D'Aprano added the comment: Oops, replying by email reopens the ticket. Back to pending you go! -- status: open -> pending ___ Python tracker <https://bugs.python.org

[issue46923] Implement stack overflow protection for supported platforms

2022-03-04 Thread Steven D'Aprano
Steven D'Aprano added the comment: > Personally I'd prefer a new exception `StackOverflow` to `MemoryError` +1 on a new exception (presumably a subclass of MemoryError). How about using OverflowedStack instead? The situation is not quite as bad as you suggest. Googling for &q

[issue12790] doctest.testmod does not run tests in functools.partial functions

2011-08-19 Thread Steven D'Aprano
New submission from Steven D'Aprano : Functions with docstrings which were created with partial are not run by doctest.testmod(). See the test script, which prints: Expected 1 failure from 2 tests, but got 0 from 0. -- files: partial_doctest.py messages: 142512 nosy: ste

[issue2636] Regexp 2.7 (modifications to current re 2.2.2)

2011-08-27 Thread Steven D'Aprano
Steven D'Aprano added the comment: I'm not sure if this belongs here, or on the Google code project page, so I'll add it in both places :) Feature request: please change the NEW flag to something else. In five or six years (give or take), the re module will be long forgotten

[issue2636] Adding a new regex module (compatible with re)

2011-09-01 Thread Steven D'Aprano
Steven D'Aprano added the comment: Matthew Barnett wrote: > Matthew Barnett added the comment: > > I think I need a show of hands. > > Should the default be old behaviour (like re) or new behaviour? (It might be > old now, new later.) > > Should there be a NE

[issue2636] Adding a new regex module (compatible with re)

2011-09-01 Thread Steven D'Aprano
Steven D'Aprano added the comment: Ezio Melotti wrote: > Ezio Melotti added the comment: > > Also note that some behaviors are not "old" or "compatible", but just > different. For example why inline flags should be the old (or new) behavior? > Or

[issue2636] Adding a new regex module (compatible with re)

2011-09-06 Thread Steven D'Aprano
Steven D'Aprano added the comment: Matthew Barnett wrote: > So, VERSION0 and VERSION1, with "(?V0)" and "(?V1)" in the pattern? Seems reasonable to me. +1 -- ___ Python tracker <h

[issue6210] Exception Chaining missing method for suppressing context

2010-12-03 Thread Steven D'Aprano
Steven D'Aprano added the comment: It seems to me that an explicit raise inside an except block should *not* chain exceptions by default. The rationale for chaining exceptions is to detect bugs in the exception handler: try: something except SomeError: y = 1/x # oops, what ha

[issue7821] Command line option -U not documented

2010-01-30 Thread Steven D'Aprano
New submission from Steven D'Aprano : There is a command line switch -U (uppercase U) which is mentioned in PEP 3147 http://www.python.org/dev/peps/pep-3147/ but doesn't appear to be documented anywhere. It is listed here, but not described: http://docs.python.org/using/cmdline

[issue7821] Command line option -U not documented

2010-01-31 Thread Steven D'Aprano
Steven D'Aprano added the comment: If the switch is intentionally not documented, perhaps it should be removed from here: http://docs.python.org/using/cmdline.html#command-line where it is listed but not explained anywhere. As it stands now, the *existence* of the switch is documented

[issue4037] doctest.py should include method descriptors when looking inside a class __dict__

2010-02-06 Thread Steven D'Aprano
Steven D'Aprano added the comment: The patch you suggest is *not* sufficient, at least not by my testing. However, the attached patch does work, according to my tests. -- nosy: +stevenjd Added file: http://bugs.python.org/file16158/patch ___ P

[issue4037] doctest.py should include method descriptors when looking inside a class __dict__

2010-02-09 Thread Steven D'Aprano
Steven D'Aprano added the comment: Attached is a simple test script for the patch I submitted. I have tested it with Python 2.6 both before and after applying the patch. Run it from the command line. With the unpatched doctest module, it prints: "Expected 2 doctests, but on

[issue8128] String interpolation with unicode subclass fails to call __str__

2010-03-12 Thread Steven D'Aprano
New submission from Steven D'Aprano : String interpolation % operates on unicode strings directly without calling the __str__ method. In Python 2.5 and 2.6: >>> class K(unicode): ... def __str__(self): return "Surprise!" ... >>> u"%s" % K("so

[issue8128] String interpolation with unicode subclass fails to call __str__

2010-03-20 Thread Steven D'Aprano
Steven D'Aprano added the comment: I've assumed that the documentation is correct, and that "%s"%obj should call __str__ for unicode objects as well as everything else. Attached in a test file. -- Added file: http://bugs.python.org/file16595/t

[issue4037] doctest.py should include method descriptors when looking inside a class __dict__

2010-03-20 Thread Steven D'Aprano
Steven D'Aprano added the comment: I have fixed the issue with line length, and taken Brian's advice re valname. Updated patch for doctest and test.test_doctest2 is attached. -- Added file: http://bugs.python.org/file16599/doctest_patch

[issue4255] timing module refers to non-existent documentation

2008-11-03 Thread Steven D'Aprano
New submission from Steven D'Aprano <[EMAIL PROTECTED]>: import timing help(timing) => MODULE DOCS http://www.python.org/doc/current/lib/module-timing.html but there doesn't appear to be any such page: the URL gives Error 404: File Not Found. Searching the reference

[issue4457] __import__ documentation obsolete

2008-11-28 Thread Steven D'Aprano
New submission from Steven D'Aprano <[EMAIL PROTECTED]>: The documentation for __import__ says that it primarily exists "so that you can replace it with another function that has a compatible interface, in order to change the semantics of the import statement". http://do

[issue4795] inspect.isgeneratorfunction inconsistent with other inspect functions

2008-12-31 Thread Steven D'Aprano
New submission from Steven D'Aprano : The inspect isSOMETHING() functions all return True or False, except for isgeneratorfunction(), which returns True or None. The body of the function is very brief: if (isfunction(object) or ismethod(object)) and \ object.func_code.co_

[issue4796] Decimal to receive from_float method

2008-12-31 Thread Steven D'Aprano
New submission from Steven D'Aprano : In the PEP for Decimal, it was discussed that the class should have a from_float() method for converting from floats, but to leave it out of the Python 2.4 version: http://www.python.org/dev/peps/pep-0327/#from-float Following discussions with

[issue4796] Decimal to receive from_float method

2009-01-02 Thread Steven D'Aprano
Steven D'Aprano added the comment: Mark suggested the following strategy for Decimal.from_float: "always use the largest exponent possible". Just for the avoidance of all doubt, do you mean the largest exponent with the number normalised to one digit to the right of the

[issue4796] Decimal to receive from_float method

2009-01-02 Thread Steven D'Aprano
Steven D'Aprano added the comment: Raymond: > Accordingly, I recommend Decimal.from_float(f) with no > qualifiers or optional arguments. -0 on this one. It's going to confuse an awful lot of newbies when they write Decimal.from_float(1.1) and get Decimal('1100

[issue4796] Decimal to receive from_float method

2009-01-02 Thread Steven D'Aprano
Steven D'Aprano added the comment: Mark wrote: >> Also, why not just extend the Decimal() constructor to accept >> a float as the argument? Why have a separate from_float() >> method at all? > > This was discussed extensively when the decimal module was > bein

[issue4947] sys.stdout fails to use default encoding as advertised

2009-01-14 Thread Steven D'Aprano
New submission from Steven D'Aprano : Documentation for files states that when writing to a file, unicode strings are converted to byte strings using the encoding specified by file.encoding. http://docs.python.org/library/stdtypes.html#file.encoding sys.stdout is a file, but it doe

[issue2527] Pass a namespace to timeit

2009-01-23 Thread Steven D'Aprano
Changes by Steven D'Aprano : -- nosy: +stevenjd ___ Python tracker <http://bugs.python.org/issue2527> ___ ___ Python-bugs-list mailing list Unsubsc

[issue5065] IDLE improve Subprocess Startup Error message

2009-01-25 Thread Steven D'Aprano
New submission from Steven D'Aprano : When launching IDLE, it reports: "IDLE's subprocess didn't make connection. Either IDLE can't start a subprocess or personal firewall software is blocking the connection." This should report what needs to be opened on the fir

[issue5066] IDLE documentation for Unix obsolete/incorrect

2009-01-25 Thread Steven D'Aprano
New submission from Steven D'Aprano : Documentation for IDLE states: Starting IDLE on UNIX On Unix, just type "idle" at a command prompt. This should bring up a Window similar to the one above. (If it doesn't, look for the "idle" script in the Tool

[issue5067] Error msg from using wrong quotes in JSON is unhelpful

2009-01-25 Thread Steven D'Aprano
New submission from Steven D'Aprano : Using the wrong sort of quotes in json gives unhelpful error messages: >>> json.loads("{'test':'test'}") Traceback (most recent call last): ... ValueError: Expecting property name: line 1 column 1 (char 1)

[issue5067] Error msg from using wrong quotes in JSON is unhelpful

2009-01-26 Thread Steven D'Aprano
Changes by Steven D'Aprano : -- components: +Library (Lib) type: -> behavior ___ Python tracker <http://bugs.python.org/issue5067> ___ ___ Python-bugs-lis

[issue1108] Problem with doctest and decorated functions

2009-02-13 Thread Steven D'Aprano
Steven D'Aprano added the comment: For what it's worth, this bug appears to go back to at least Python 2.4, and it affects functions using decorators even if they are defined in the same module as the decorated function. I've applied the patch to my 2.4 installation, and it

[issue1108] Problem with doctest and decorated functions

2009-02-14 Thread Steven D'Aprano
Steven D'Aprano added the comment: Earlier I wrote: "I've applied the patch to my 2.4 installation, and it doesn't fix the issue. I'd like to request this be reopened, because I don't believe the patch works as advertised." Nevermind, I withdraw the request.

[issue46947] unicodedata.name gives ValueError for control characters

2022-03-07 Thread Steven D'Aprano
Steven D'Aprano added the comment: The behaviour is technically correct, but confusing and unfortunate, and I don't think we can fix it. Unicode does not define names for the ASCII control characters. But it does define aliases for them, based on the C0 control cha

[issue46961] Caching/interning of small ints sometimes fails

2022-03-08 Thread Steven D'Aprano
New submission from Steven D'Aprano : I'm reluctant to call this a bug, as small int interning/caching is an implementation detail and there are no hard guarantees made. But on the other hand, it seems that the intention is that small ints such as 0, 1 and 2 should be cached. Her

[issue46967] Type union for except

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

[issue47018] ImportError: cannot import name '_simple_enum' from 'enum'

2022-03-14 Thread Steven D'Aprano
Steven D'Aprano added the comment: What makes you think you are supposed to be able to import _simple_enum? It is a name with a leading underscore, so even if it exists, it is private and you shouldn't touch it. Unless _simple_enum is documented as something you can use, this is

[issue47031] math.nan should note that NANs do not compare equal to anything

2022-03-15 Thread Steven D'Aprano
New submission from Steven D'Aprano : The IEEE-754 requirement that NANs are never equal to anything, even to themselves, is a common stumbling block for those new to the consequences of IEEE-754. See for example #47020. The documentation for math.nan would be a good place to add a note

[issue45297] Improve the IDLE shell save command

2022-03-20 Thread Steven D'Aprano
Steven D'Aprano added the comment: Here is another example of a newbie caught by this: https://discuss.python.org/t/syntax-error-in-python-3-10-when-running-on-terminal/14462 -- ___ Python tracker <https://bugs.python.org/is

[issue47031] math.nan should note that NANs do not compare equal to anything

2022-03-24 Thread Steven D'Aprano
Steven D'Aprano added the comment: > We cannot guarantee that NAN never equal to anything, because we can > create an object equal to it. For example mock.ANY Sure. I don't expect that mock.ANY or other weird objects should obey the IEEE-754 rules. But we're talking num

[issue47134] Document the meaning of the number in OverflowError

2022-03-26 Thread Steven D'Aprano
New submission from Steven D'Aprano : OverflowError sometimes (but not always) includes some sort of numeric code: >>> 1e+300 ** 2 Traceback (most recent call last): File "", line 1, in OverflowError: (34, 'Numerical result out of range') but the meaning o

[issue47133] enhance unittest to show test name and docstring on one line

2022-03-26 Thread Steven D'Aprano
Steven D'Aprano added the comment: I don't think this change of behaviour should be accepted without discussion, and I'm not sure why you think Python-Dev is the right place, rather than here. Messing around with unittest and docstrings has already caused issues in th

[issue47133] enhance unittest to show test name and docstring on one line

2022-03-26 Thread Steven D'Aprano
Steven D'Aprano added the comment: I have no problem with pinging Python-Dev, or any other forum, asking for interested parties. I just don't think we should be intentionally spliting the discussion more than it's going to get split organically. (If this is interesting to pe

[issue47135] Allow decimal.localcontext to accept keyword arguments to set context attributes

2022-03-27 Thread Steven D'Aprano
New submission from Steven D'Aprano : Whenever I use decimal and need to change the context temporarily, without fail I try to write with decimal.localcontext(prec=10): ... or similar. Then I get surprised that it fails, and re-write it as with decimal.localcontext() a

[issue47136] Wrong value assigned automatically to the variable __module__ in the class body.

2022-03-27 Thread Steven D'Aprano
Steven D'Aprano added the comment: > the programmer may use the variable __name__ for some other purposes Dunder names like `__name__` are reserved for the use of the interpreter. If the programmer uses them for "other purposes", the programmer is responsible for any failu

[issue47133] enhance unittest to show test name and docstring on one line

2022-03-27 Thread Steven D'Aprano
Steven D'Aprano added the comment: Rather than an option for this, it would be cleaner to deprecate the current output in 3.11, and fix it in 3.12 or 3.13. Otherwise we have to maintain the old (bad?) output and the new output both fo

[issue40469] TimedRotatingFileHandler rotating on use not time

2022-03-31 Thread Steven D'Aprano
Steven D'Aprano added the comment: See this thread on Discuss: https://discuss.python.org/t/logging-timedrotatingfilehandler-never-rotates-in-certain-cases/14747/1 -- nosy: +steven.daprano ___ Python tracker <https://bugs.python.org/is

[issue47135] Allow decimal.localcontext to accept keyword arguments to set context attributes

2022-04-01 Thread Steven D'Aprano
Steven D'Aprano added the comment: I'm not sure what the implementation uses to enforce this, but decimal contexts already seem to reject arbitrary attributes. So a naive implementation that just setattr()'s the keyword arguments will automatically fail: >>> from d

  1   2   3   4   5   6   7   8   9   10   >