New submission from Sergey :
See attached tmp1.py
It is very simple but it doesn't work
It raises NameError
NameError: global name 'arg' is not defined
--
components: None
files: tmp1.py
messages: 116515
nosy: webcubator
priority: normal
severity: normal
status: open
tit
New submission from Sergey :
MagicMock allows to check parameters of calls by using "assert_has_calls".
However it fails if argument has a mutable type and was changed in-place before
the second call.
The example is provided in attached file.
In "func1" value in &qu
New submission from Sergey:
Problem
===
Code:
sum([[1,2,3]]*100, [])
takes forever to complete.
Suggestion
==
Patch sum() function so that it did not created 100 copies of result, but
created just one. Attached patch does that.
Before patch:
$ ./python -mtimeit --setup
Sergey added the comment:
> The issue of quadratic performance of sum(sequences, null_seq) is known
I hope it's never too late to fix some bugs... :)
> sum([[1,2,3]]*n, []) == [1,2,3]*n == list(chain.from_iterable([[1,2,3]]*n))
But if you already have a list of lists, and you need
Sergey added the comment:
> I don't know about IronPython, but Jython and PyPy have same behavior as
> CPython.
Right. I was wrong, at least Jython and PyPy suffer from this bug too.
> I think that it is worthwhile to discuss the idea at first in the
> Python-Ideas mail
Sergey added the comment:
This patch implements another solution to the same bug. But instead of changing
default code it adds a special case optimization for lists, tuples and strings,
similar to those two special cases for numbers, that are already there.
=== Lists ===
No patch
Sergey added the comment:
Steven D'Aprano noticed that there's an obscure case of:
>>> class A(list):
... def __add__(self, other):
... return A(super(A,self).__add__(other))
... def __radd__(self, other):
... return A(other) + self
...
Where:
&
Sergey added the comment:
> This "optimisation" is a semantic change. It breaks backward
> compatibility in cases where a = a + b and a += b do not result
> in the name a having the same value. In particular this breaks
> backward compatibility for numpy users.
I didn
Sergey added the comment:
Attached fasttuple.py is a Proof-of-Concept implementation of tuple, that
reuses same data storage when possible. Its possible usage looks similar to
built-in tuples:
from fasttuple import ft
a = ft([1,2])
b = a + ft([3,4])
c = b + ft([5,6])
d = b + ft([7,8
Sergey added the comment:
> I guess such implementation of tuple will increase memory usage
> and creation time which are critical important for tuples.
On the contrary, it will reduce memory usage and creation time compared to
regular tuples, because in cases like:
c = a + b
you do no
Sergey added the comment:
> This is not a common case. A common case is creating short tuples and keeping
> a lot of tuples in memory.
> For fast += you need keep not only a size of tuple, but also a size of
> allocated memory. It's a cause of sys.getsizeof([1, 2]) > sy
New submission from Sergey:
Wrong ling following to Windows help file on the Python 2.7.6 RC 1 Web page.
It is the following:
http://www.python.org/ftp/python/2.7.6/python275.chm
And should be:
http://www.python.org/ftp/python/2.7.6/python276rc1.chm
--
components: Build
messages
New submission from Sergey:
email.Message class has method get_params() that can decode(unquote) header
values in compliance with RFC2231 and RFC2047. But if in email message exists
multiple headers with the same key it can't be used to decode other headers
than first.
In my applicat
Changes by Sergey :
--
type: behavior -> enhancement
___
Python tracker
<http://bugs.python.org/issue29678>
___
___
Python-bugs-list mailing list
Unsubscrib
New submission from Sergey Dorofeev :
Python 3.2.2 (default, Nov 16 2011, 10:58:44) [C] on sunos5
Type "help", "copyright", "credits" or "license" for more information.
>>> import ast
>>> ast.literal_eval('10')
10
>>> a
Sergey Dorofeev added the comment:
python 3 feature - should use 0o10
need to rebuild data file :(
--
resolution: -> rejected
status: open -> closed
___
Python tracker
<http://bugs.python.org/i
Sergey Schetinin added the comment:
It does work (Python 2.7.1 here):
>>> import cgi
>>> cgi.parse_header('Content-Disposition: form-data; name=""%22"')
('Content-Disposition: form-data', {'name': '"%22'})
&
Sergey Schetinin added the comment:
I wanted to add that the fact that browsers encode the field names in the page
encoding does not change that they should escape the header according to RFC
2047.
The percent-encoding used in the field name has nothing to do with
multipart/form-data or
Sergey Schetinin added the comment:
I don't think that's a security issue, just something that would break with
certain filenames. And I said that it's a browsers' problem in the sense that
it can only be fixed /
New submission from Sergey Mezentsev :
I run this code:
"""
from multiprocessing import Pool
def myfunc(x):
assert False
#if __debug__: print 'debug'
return x - 1
if __name__ == '__main__':
pool = Pool(processes=1)
it = pool.imap(myfunc,
Sergey Mezentsev added the comment:
In my system (Windows 7 (64) SP1, Python 2.6.6 32-bit) I have:
"""
d:\temp>python -O pool.py
('parent optimize?', 1)
('child', 4712, 'optimize?', 0)
(Traceback (most recent call last):
' File "new.p
Sergey Mezentsev added the comment:
I create patch for Popen.get_command_line() ('2.6' and 'default' branches).
I don't know how to write the test. The sys.flags structure are read only.
--
keywords: +patch
Added file: http://bugs.python.org/file22021/Is
Changes by Sergey Mezentsev :
Added file: http://bugs.python.org/file22022/Issue12098.branch-default.patch
___
Python tracker
<http://bugs.python.org/issue12098>
___
___
Changes by Sergey Mezentsev :
Removed file: http://bugs.python.org/file22021/Issue12098.branch-2.6.patch
___
Python tracker
<http://bugs.python.org/issue12098>
___
___
Changes by Sergey Mezentsev :
Removed file: http://bugs.python.org/file22022/Issue12098.branch-default.patch
___
Python tracker
<http://bugs.python.org/issue12
Changes by Sergey Mezentsev :
Added file: http://bugs.python.org/file22041/Issue12098.branch-2.6.patch
___
Python tracker
<http://bugs.python.org/issue12098>
___
___
Pytho
Changes by Sergey Mezentsev :
Added file: http://bugs.python.org/file22042/Issue12098.branch-default.patch
___
Python tracker
<http://bugs.python.org/issue12098>
___
___
Sergey Mezentsev added the comment:
I updated the patch.
Added a test and remove arguments for frozen interpreter.
--
___
Python tracker
<http://bugs.python.org/issue12
Sergey Shepelev added the comment:
Here's patch against 2.6
--- a/Python/modsupport.c Tue Aug 24 18:19:58 2010 +0200
+++ b/Python/modsupport.c Tue Jan 11 23:50:40 2011 +0300
@@ -459,6 +459,16 @@
return v;
}
+case '?':
+{
+
New submission from Sergey Schetinin :
Tested on Python 2.7, but probably affects all versions. Test case is attached.
The reason this went unnoticed until now is that browsers are very conservative
when quoting field names, so most field names are the same after their quoting.
Related bug in
Sergey Schetinin added the comment:
And here's a patch.
--
keywords: +patch
Added file: http://bugs.python.org/file20820/cgi-patch.patch
___
Python tracker
<http://bugs.python.org/is
Sergey Schetinin added the comment:
I've dug into the RFCs and tested various browsers.
RFC 2388 (the one defining multipart/form-data) says:
Field names originally in non-ASCII character sets may be encoded
within the value of the "name" parameter using the standard method
d
Sergey Lipnevich <[EMAIL PROTECTED]> added the comment:
I don't know what the proper procedure is (reopening or filing a new
ticket), but I see this problem with Sphinx 0.5dev-20081015 and Python
2.6 on Windows XP. The change recommended by Winfried in msg73874 seems
to fix it (pat
New submission from Sergey Fedorov :
While adding definitions for additional universal binary option (ppc+ppc64) is
rather straightforward (following already existing examples in the source
code), and Python 3.x after patching do build as universal for named two arch,
trying to install any
New submission from Sergey Fedoseev :
When compiled with default NSMALLPOSINTS, _PyLong_FromUnsignedChar() is
significantly faster than other PyLong_From*():
$ python -m perf timeit -s "from collections import deque; consume =
deque(maxlen=0).extend; b = bytes(2**20)" "consume
Change by Sergey Fedoseev :
--
keywords: +patch
pull_requests: +14971
stage: -> patch review
pull_request: https://github.com/python/cpython/pull/15251
___
Python tracker
<https://bugs.python.org/issu
New submission from Sergey Fedoseev :
bytearray_getitem() adjusts negative index, though that's already done by
PySequence_GetItem().
This makes PySequence_GetItem(bytearray(1), -2) to return 0 instead of raise
IndexError.
--
components: Interpreter Core
messages: 349545
nosy
Change by Sergey Fedoseev :
--
keywords: +patch
pull_requests: +14972
stage: -> patch review
pull_request: https://github.com/python/cpython/pull/15250
___
Python tracker
<https://bugs.python.org/issu
New submission from Sergey Fedoseev :
Argument Clinic generates `{NULL, NULL}` initializer for Py_buffer variables.
Such initializer zeroes all Py_buffer members, but as I understand only `obj`
and `buf` members are really had to be initialized. Avoiding unneeded
initialization provides tiny
Change by Sergey Fedoseev :
--
keywords: +patch
pull_requests: +14975
stage: -> patch review
pull_request: https://github.com/python/cpython/pull/15254
___
Python tracker
<https://bugs.python.org/issu
New submission from Sergey Fedoseev :
PyLong_As*() functions computes result for large longs like this:
size_t x, prev;
x = 0;
while (--i >= 0) {
prev = x;
x = (x << PyLong_SHIFT) | v->ob_digit[i];
if ((x >> PyLong_SHIFT) != prev) {
*overflow = sign;
Change by Sergey Fedoseev :
--
keywords: +patch
pull_requests: +15074
stage: -> patch review
pull_request: https://github.com/python/cpython/pull/15363
___
Python tracker
<https://bugs.python.org/issu
Change by Sergey Fedoseev :
--
pull_requests: +15094
pull_request: https://github.com/python/cpython/pull/15385
___
Python tracker
<https://bugs.python.org/issue27
Change by Sergey Fedoseev :
--
pull_requests: +15095
pull_request: https://github.com/python/cpython/pull/15386
___
Python tracker
<https://bugs.python.org/issue27
Change by Sergey Fedoseev :
--
pull_requests: +15098
pull_request: https://github.com/python/cpython/pull/15388
___
Python tracker
<https://bugs.python.org/issue27
Change by Sergey Fedoseev :
--
keywords: +patch
pull_requests: +15152
stage: -> patch review
pull_request: https://github.com/python/cpython/pull/15457
___
Python tracker
<https://bugs.python.org/issu
New submission from Sergey Fedoseev :
PyLong_As*() functions have a lot of duplicated code, creating draft PR with
attempt to deduplicate them.
--
components: Interpreter Core
messages: 350367
nosy: sir-sigurd
priority: normal
severity: normal
status: open
title: refactor PyLong_As
Sergey Fedoseev added the comment:
$ gcc -v 2>&1 | grep 'gcc version'
gcc version 8.3.0 (Debian 8.3.0-19)
using ./configure --enable-optimizations --with-lto
$ python -m perf timeit -s "from collections import deque; consume =
deque(maxlen=0).extend; b = bytes(2**20)&qu
Sergey Fedoseev added the comment:
Previous benchmarks results were obtained with non-LTO build.
Here are results for LTO build:
$ python -m perf timeit -s "from itertools import repeat; _len = repeat(None,
0).__length_hint__" "_len()" --compare-to=../cpython-ma
Sergey Fedoseev added the comment:
These last results are invalid :-)
I thought that I was checking _PyLong_FromUnsignedChar() on top of GH-15192,
but that wasn't true. So the correct results for LTO build are:
$ python -m perf timeit -s "from collections import deque; consum
New submission from Sergey Fedoseev :
In [8]: help(sys.float_info)
...
|
| dig
| DBL_DIG -- digits
|
This is not very helpful,
https://docs.python.org/3/library/sys.html#sys.float_info is more verbose, so
probably docstrings should be updated from where.
--
assignee
New submission from Sergey Fedoseev :
In [3]: help(zip)
class zip(object)
| zip(*iterables) --> zip object
|
| Return a zip object whose .__next__() method returns a tuple where
| the i-th element comes from the i-th iterable argument. The .__next__()
| method continues until
New submission from Sergey Fedoseev :
zip() shadows TypeError raised in __iter__() of source iterable:
In [21]: class Iterable:
...: def __init__(self, n):
...: self.n = n
...: def __iter__(self):
...: return iter(range(self.n))
...:
In [22
Change by Sergey Fedoseev :
--
keywords: +patch
pull_requests: +15268
stage: -> patch review
pull_request: https://github.com/python/cpython/pull/15592
___
Python tracker
<https://bugs.python.org/issu
Sergey Fedoseev added the comment:
Maybe it's not clear from description, but traceback only show the line with
zip(), so it doesn't help at localizing the source of exception at all.
You only see that 'argument #N must support iteration', but that argument has
__iter_
Sergey Fedoseev added the comment:
Also using this example class:
In [5]: iter(Iterable('one'))
---
TypeError Traceback (most recent call last)
in ()
> 1 iter(Iterable
Sergey Fedoseev added the comment:
> map() does not have anything special.
Just for the reference, in Python 2.7 map() has the same behavior and it caused
many problems for me and other people working with/developing Django.
--
___
Python trac
New submission from Sergey Fedoseev :
This patch simplifies fast path for floats that fit into C long and moves it
from float.__trunc__ to PyLong_FromDouble().
+-+-+--+
| Benchmark | long-from-float-ref | long-from
Change by Sergey Fedoseev :
--
pull_requests: +15372
pull_request: https://github.com/python/cpython/pull/15718
___
Python tracker
<https://bugs.python.org/issue38
Sergey Fedoseev added the comment:
I added similar patch that replaces get_small_int() with macro version, since
it also induces unnecessary casts and makes machine code less efficient.
Example assembly can be checked at https://godbolt.org/z/1SjG3E.
This change produces tiny, but
Sergey Fedoseev added the comment:
I use GCC 9.2.
--
___
Python tracker
<https://bugs.python.org/issue38015>
___
___
Python-bugs-list mailing list
Unsubscribe:
Change by Sergey Fedoseev :
--
keywords: +patch
pull_requests: +15471
stage: -> patch review
pull_request: https://github.com/python/cpython/pull/14838
___
Python tracker
<https://bugs.python.org/issu
Change by Sergey Fedoseev :
--
keywords: +patch
pull_requests: +15517
stage: -> patch review
pull_request: https://github.com/python/cpython/pull/15274
___
Python tracker
<https://bugs.python.org/issu
New submission from Sergey Fedoseev :
GCC (along with Clang and ICC) has __builtin_unreachable() and MSVC has
__assume() builtins, that can be used to optimize out unreachable conditions.
So we could add macro like this:
#ifdef Py_DEBUG
# define Py_ASSUME(cond) (assert(cond))
#else
# if
Sergey Fedoseev added the comment:
I believe that the problem is caused by the change in Py_UNREACHABLE()
(https://github.com/python/cpython/commit/3ab61473ba7f3dca32d779ec2766a4faa0657923).
Before the mentioned commit Py_UNREACHABLE() was an expression, now it's a
block. Py_UNREAC
Sergey Fedoseev added the comment:
Also quote from Py_UNREACHABLE() doc:
> Use this in places where you might be tempted to put an assert(0) or abort()
> call.
https://github.com/python/cpython/commit/6b519985d23bd0f0bd072b5d5d5f2c60a81a19f2
does exactly that, it replaces assert(0
New submission from Sergey Fedoseev :
I wrote patch that cleans up type_init():
1. Removes conditions already checked by assert()
2. Removes object_init() call that effectively creates an empty tuple and
checks that this tuple is empty
--
messages: 352710
nosy: sir-sigurd
priority
Change by Sergey Fedoseev :
--
keywords: +patch
pull_requests: +15852
stage: -> patch review
pull_request: https://github.com/python/cpython/pull/16257
___
Python tracker
<https://bugs.python.org/issu
Sergey Fedoseev added the comment:
FWIW I proposed to add Py_ASSUME() macro that uses __builtin_unreachable() in
bpo-38147.
--
___
Python tracker
<https://bugs.python.org/issue38
Sergey Fedoseev added the comment:
> If you care of _PyLong_Copy() performance, you should somehow manually inline
> _PyLong_New() inside _PyLong_Copy().
It doesn't solve this:
> We could add a function that bypass that check, but in LTO build
> PyObject_MALLOC(
Sergey Fedoseev added the comment:
These warnings are caused by
https://github.com/python/cpython/commit/c6734ee7c55add5fdc2c821729ed5f67e237a096.
I'd fix them, but I'm not sure if we are going to restore CHECK_SMALL_INT()
¯\_(ツ)_/¯
--
nosy: +
Sergey Fedoseev added the comment:
issue38524 is related.
--
nosy: +sir-sigurd
___
Python tracker
<https://bugs.python.org/issue38517>
___
___
Python-bugs-list m
Change by Sergey Fedoseev :
--
nosy: +sir-sigurd
___
Python tracker
<https://bugs.python.org/issue38524>
___
___
Python-bugs-list mailing list
Unsubscribe:
Change by Sergey Polischouck :
--
nosy: +polischouckserg
___
Python tracker
<https://bugs.python.org/issue15907>
___
___
Python-bugs-list mailing list
Unsub
New submission from Sergey Maslyakov :
https://docs.python.org/3/library/subprocess.html#subprocess.check_output
The code sample seems to have a misplaced closing round bracket. It should go
after "stdout"
```
run(..., check=True, stdout=PIPE).stdout
```
--
assignee: d
Sergey Maslyakov added the comment:
Thank you, Dennis! I was wrong. Closing the ticket.
--
resolution: -> not a bug
stage: -> resolved
status: open -> closed
___
Python tracker
<https://bugs.python.or
Change by Sergey Fedoseev :
--
nosy: +sir-sigurd
___
Python tracker
<https://bugs.python.org/issue39759>
___
___
Python-bugs-list mailing list
Unsubscribe:
Change by Sergey Fedoseev :
--
nosy: +sir-sigurd
nosy_count: 8.0 -> 9.0
pull_requests: +25593
pull_request: https://github.com/python/cpython/pull/27033
___
Python tracker
<https://bugs.python.org/issu
New submission from Sergey M. :
Due to
```python
try:
self.handle()
finally:
self.finish()
```
construct in `socketserver.BaseRequestHandler.__init__()` method inherited
classes with `overrided __init__()` method may suffer from incomplete
initialization.
For example, in the
Change by Sergey Fedoseev :
--
pull_requests: +16894
pull_request: https://github.com/python/cpython/pull/17413
___
Python tracker
<https://bugs.python.org/issue37
Change by Sergey Fedoseev :
--
pull_requests: +17021
pull_request: https://github.com/python/cpython/pull/17539
___
Python tracker
<https://bugs.python.org/issue27
Change by Sergey Fedoseev :
--
nosy: +sir-sigurd
nosy_count: 3.0 -> 4.0
pull_requests: +19338
pull_request: https://github.com/python/cpython/pull/15659
___
Python tracker
<https://bugs.python.org/issu
New submission from Sergey Fedoseev :
Currently patlib.Path.iterdir() filters out '.' and '..'.
It's unneeded since patlib.Path.iterdir() uses os.listdir() under the hood,
which returns neither '.' nor '..'.
https://docs.python.org/3/library/os.ht
Change by Sergey Fedoseev :
--
keywords: +patch
pull_requests: +20336
stage: -> patch review
pull_request: https://github.com/python/cpython/pull/21179
___
Python tracker
<https://bugs.python.org/issu
New submission from Sergey Fedoseev :
In [191]: import dataclasses, pydoc
In [192]: @dataclass
...: class C:
...: pass
...:
In [193]: print(pydoc.render_doc(C))
Python Library Documentation: class C in module __main__
class C(builtins.object)
| C() -> None
|
|
Change by Sergey Fedoseev :
--
keywords: +patch
pull_requests: +20793
stage: -> patch review
pull_request: https://github.com/python/cpython/pull/21652
___
Python tracker
<https://bugs.python.org/issu
Change by Sergey Fedoseev :
--
nosy: +sir-sigurd
___
Python tracker
<https://bugs.python.org/issue26834>
___
___
Python-bugs-list mailing list
Unsubscribe:
Change by Sergey Fedoseev :
--
nosy: +sir-sigurd
___
Python tracker
<https://bugs.python.org/issue35276>
___
___
Python-bugs-list mailing list
Unsubscribe:
Change by Sergey Fedoseev :
--
nosy: +sir-sigurd
nosy_count: 4.0 -> 5.0
pull_requests: +21279
pull_request: https://github.com/python/cpython/pull/21763
___
Python tracker
<https://bugs.python.org/issu
Sergey Nudnou added the comment:
Hello,
I've just run into a related issue. I have a python script, which starts an
another python script using subprocess.Popen(). The parent script gets pid of
the child and monitors up its activity through a database by this pid. The
child script up
New submission from Sergey Dorofeev :
unzip does extract files but zipfile no
works fine with python2.7 but fails with python 3.2.2
tested on solaris 11 express and windows xp
>>> import zipfile
>>> zipfile.ZipFile("test.zip")
>>> z=_
>>>
Change by Sergey Fedoseev :
--
pull_requests: +13420
___
Python tracker
<https://bugs.python.org/issue31862>
___
___
Python-bugs-list mailing list
Unsubscribe:
Sergey Fedoseev added the comment:
`BytesIO.write()` and `BytesIO.writelines()` are independent of each other.
--
___
Python tracker
<https://bugs.python.org/issue34
New submission from Sergey Fedoseev :
Currently PyLong_FromSize_t() uses PyLong_FromLong() for values < PyLong_BASE.
It's suboptimal because PyLong_FromLong() needs to handle the sign. Removing
PyLong_FromLong() call and handling small ints directly in PyLong_FromSize_t()
makes i
Change by Sergey Fedoseev :
--
keywords: +patch
pull_requests: +14924
stage: -> patch review
pull_request: https://github.com/python/cpython/pull/15192
___
Python tracker
<https://bugs.python.org/issu
New submission from Sergey Fedoseev:
Currently TestResult.addSubTest() is called just before TestResult.stopTest(),
but docs says that addSubTest is "Called when a subtest finishes". IMO that
means that it will be called immediately after subtest finishes, but not after
indefinite t
Changes by Sergey Fedoseev :
--
components: +Library (Lib)
___
Python tracker
<http://bugs.python.org/issue30856>
___
___
Python-bugs-list mailing list
Unsub
New submission from Sergey Kostyuk:
Good day
Maybe I misunderstood something, but I'm failed to fetch any data by calling
asyncio.StreamReader.read if `n` is less than zero (or left default). It just
hangs in the loop forever (see line number 614 of asyncio/streams.py:
https://githu
Changes by Sergey Fedoseev :
--
pull_requests: +3025
___
Python tracker
<http://bugs.python.org/issue31108>
___
___
Python-bugs-list mailing list
Unsubscribe:
New submission from Sergey Fedoseev:
> python -mtimeit -s "l = list(range(10))" "l[-1] in l"
1000 loops, best of 3: 1.34 msec per loop
> python -mtimeit -s "l = list(range(10))" "l[-1] in iter(l)"
>
1 - 100 of 298 matches
Mail list logo