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
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
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
...
>>
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
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
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
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
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
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
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
> >
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
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
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
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
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
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
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
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:
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
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
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
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']
>
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
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
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
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
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
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
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
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
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.
--
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
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
>>>
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
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
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
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
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
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
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
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
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
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
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
Change by Steven D'Aprano :
--
Removed message: https://bugs.python.org/msg413566
___
Python tracker
<https://bugs.python.org/issue46803>
___
___
Pytho
Change by Steven D'Aprano :
--
Removed message: https://bugs.python.org/msg413567
___
Python tracker
<https://bugs.python.org/issue46803>
___
___
Pytho
Change by Steven D'Aprano :
--
Removed message: https://bugs.python.org/msg413568
___
Python tracker
<https://bugs.python.org/issue46803>
___
___
Pytho
Change by Steven D'Aprano :
--
nosy: -xiaox55066
___
Python tracker
<https://bugs.python.org/issue46803>
___
___
Python-bugs-list mailing list
Unsubscr
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
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
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
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
Steven D'Aprano added the comment:
See #46883
--
___
Python tracker
<https://bugs.python.org/issue46882>
___
___
Python-bugs-list mailing list
Unsubscr
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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_
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
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
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
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
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
Changes by Steven D'Aprano :
--
nosy: +stevenjd
___
Python tracker
<http://bugs.python.org/issue2527>
___
___
Python-bugs-list mailing list
Unsubsc
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
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
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)
Changes by Steven D'Aprano :
--
components: +Library (Lib)
type: -> behavior
___
Python tracker
<http://bugs.python.org/issue5067>
___
___
Python-bugs-lis
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
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.
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
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
Change by Steven D'Aprano :
--
nosy: +steven.daprano
___
Python tracker
<https://bugs.python.org/issue46967>
___
___
Python-bugs-list mailing list
Unsubscr
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
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
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
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
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
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
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
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
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
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
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
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 - 100 of 1443 matches
Mail list logo