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
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
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 (
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
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
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
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
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
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
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&
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
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
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
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
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.
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
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?
--
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?
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 _
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
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
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
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
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
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
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
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
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
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
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
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
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',
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
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
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
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
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
Change by Steven D'Aprano :
--
nosy: +steven.daprano
___
Python tracker
<https://bugs.python.org/issue33721>
___
___
Python-bugs-list mailing list
Unsubscr
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
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
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
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
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
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
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
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
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
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
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.
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
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
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
Change by Steven D'Aprano :
--
resolution: -> not a bug
stage: -> resolved
status: open -> closed
___
Python tracker
<https://bugs.pyth
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>
Change by Steven D'Aprano :
--
nosy: +steven.daprano
___
Python tracker
<https://bugs.python.org/issue34483>
___
___
Python-bugs-list mailing list
Unsubscr
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
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
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
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
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
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
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
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
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
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.
--
___
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
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
Change by Steven D'Aprano :
--
nosy: +steven.daprano
___
Python tracker
<https://bugs.python.org/issue34763>
___
___
Python-bugs-list mailing list
Unsubscr
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
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.)
--
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?
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
Steven D'Aprano added the comment:
Please move the "chaos" discussion to #34867
--
___
Python tracker
<https://bugs.python.org/issue34850>
___
___
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
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
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 =
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
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.
-
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"
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
Change by Steven D'Aprano :
--
nosy: +steven.daprano
___
Python tracker
<https://bugs.python.org/issue28716>
___
___
Python-bugs-list mailing list
Unsubscr
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
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
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
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
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
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
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
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
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
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
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&
Change by Steven D'Aprano :
--
resolution: -> not a bug
stage: -> resolved
status: open -> closed
___
Python tracker
<https://bugs.pyth
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
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
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.
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
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
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
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
1001 - 1100 of 1443 matches
Mail list logo