Amaury Forgeot d'Arc added the comment:
On Windows at least: I think "another C module" should be understood as
"another DLL or executable".
A user extension module is a different DLL from the core Python, so the advice
is still valid.
--
Amaury Forgeot d'Arc added the comment:
inspect.isdatadescriptor() is better indeed.
(I was initially working on an old version of mock.py which does not import
inspect, and I did not want to add the dependency there).
- inspect uses hasattr(type(obj)) instead of hasatr(obj). This is b
Amaury Forgeot d'Arc added the comment:
Updated patch with review comments.
--
Added file: http://bugs.python.org/file42891/mock-descriptor-2.patch
___
Python tracker
<http://bugs.python.org/is
New submission from Amaury Forgeot d'Arc:
When patching a class, mock.create_autospec() correctly detects properties and
__slot__ attributes, but not subclasses of property() or other kinds of data
descriptors.
The attached patch detects all data descriptors and patch them the way
Amaury Forgeot d'Arc added the comment:
Indeed. Here is another version of the script, it crashes when I set
PYTHONHASHSEED=1 and passes with PYTHONHASHSEED=3::
class Meta(type):
def __new__(meta, clsname, bases, methods):
cls = super(Meta, meta).__new__(meta, clsname,
Amaury Forgeot d'Arc added the comment:
I don't reproduce the crash, but I noticed that the binary imports and executes
the system's /usr/lib/python2.7/site.py.
I think it's cython's fault (or maybe the way you use it): "cython --embed" is
not really isola
Amaury Forgeot d'Arc added the comment:
The Python program itself has no UI and cannot be marked as "DPI aware".
Instead, applications should call the win32 function "SetProcessDPIAwareness":
https://msdn.microsoft.com/en-us/library/windows/desktop/
Amaury Forgeot d'Arc added the comment:
Looks good to me.
--
nosy: +amaury.forgeotdarc
___
Python tracker
<http://bugs.python.org/issue22681>
___
___
Pytho
Amaury Forgeot d'Arc added the comment:
Please go ahead! Or do you expect someone else to review the patch?
--
___
Python tracker
<http://bugs.python.org/is
Amaury Forgeot d'Arc added the comment:
About the patch: I'm sure there are other tests to change,
in test_syntax.py for example::
It's a syntax error to assign to the empty tuple. Why isn't it an
error to assign to the empty list? It will always raise some e
Amaury Forgeot d'Arc added the comment:
Probably a PyType_Ready() missing.
--
___
Python tracker
<http://bugs.python.org/issue23815>
___
___
Python-bugs-l
Amaury Forgeot d'Arc added the comment:
Hi,
First, please fill and submit a Contribution Agreement:
https://www.python.org/psf/contrib/
Then about the patch:
- This is a patch against Python2.7, which is frozen for new developments. This
change will only be applied to python 3.5 or
Amaury Forgeot d'Arc added the comment:
Ah, the NULL case is indeed tested just above. So the current code works
correctly.
--
resolution: -> fixed
status: open -> closed
___
Python tracker
<http://bugs.python.
Amaury Forgeot d'Arc added the comment:
I'm not sure that this change is correct.
I have Tcl version 8.6 installed, and I checked that "app->BooleanType" is NULL.
Fortunately value->typePtr is probably never NULL, but I think the comparison
should be skipped in thi
Changes by Amaury Forgeot d'Arc :
--
nosy: +pitrou
___
Python tracker
<http://bugs.python.org/issue23720>
___
___
Python-bugs-list mailing list
Unsubscr
Amaury Forgeot d'Arc added the comment:
Actually there *is* a cycle:
assert a.vector is a.vector.device.__class__.__del__.__globals__['a'].vector
A workaround is to not store objects with __del__ in module globals...
Or have only one (the Main instance in your case)
Amaury Forgeot d'Arc added the comment:
Sorry, I missed the important point:
"for classes without __init__"
--
___
Python tracker
<http://bugs.pyt
Amaury Forgeot d'Arc added the comment:
But isn't the result different?
NEWOBJ calls cls.__new__() and __init__ is skipped.
REDUCE calls cls(): both __new__ and __init__ are used.
--
nosy: +amaury.forgeotdarc
___
Python trac
Amaury Forgeot d'Arc added the comment:
So the recursion crash was fixed in python3,
but it's still one of the limits of the Python AST compiler.
I suggest to replace your long expression by a list:
exprs = [(1-a36)*(a37)*(1-a41), (a22)*(a33)*(1-a23), ...]
return sum(exprs)
.
Amaury Forgeot d'Arc added the comment:
Probably a stack overflow, when the AST is too deep:
eval("+1" * 748580) also crashed for me
--
nosy: +amaury.forgeotdarc
___
Python tracker
<http://bugs.pyt
Amaury Forgeot d'Arc added the comment:
Simple script to reproduce the issue:
import sys, time
class C(object):
def __float__(self):
return ""
for x in range(1):
try:
time.sleep(C())
except TypeError:
pass
if x % 1000 == 0:
print(sys.getrefcount("
Amaury Forgeot d'Arc added the comment:
& is an entity reference.
Either pass "convert_charrefs=True" to the constructor, or implement a method
"def handle_entityref(self, data)" to receive them as events.
https://docs.python.org/3.4/library/html
Amaury Forgeot d'Arc added the comment:
This change will cause the module to be imported twice:
progname = runpy.run_module(args[0])['__file__']
... and then the runctx() call.
What about something like:
code = "runpy.run_module(modname, run_name='__main_
Amaury Forgeot d'Arc added the comment:
The patch does not seem to allow parameters after the -m option.
I'm sure this restriction can be lifted.
--
nosy: +amaury.forgeotdarc
___
Python tracker
<http://bugs.python.o
Amaury Forgeot d'Arc added the comment:
PEP384 is presented as a new way to write modules that can be loaded by
multiple Python versions, specially on Windows.
I could not find any place that says that modules not using the stable ABI need
to be recompiled.
I'm not against changing
Amaury Forgeot d'Arc added the comment:
I would not mind the change, but I've always thought the opposite (except on
Windows, where the string Python27.dll is stored in the .pyd)
There are traces of this binary compatibility still today in the 3.4 headers:
https://hg.python.org/cp
Amaury Forgeot d'Arc added the comment:
Oh, has this ABI compatibility requirement changed from the 2.x series?
--
___
Python tracker
<http://bugs.python.org/is
Amaury Forgeot d'Arc added the comment:
Here is a test module that segfaults on Python3.5.
It's derived from _testcapi, but it can be anything with a PyNumberMethods.
I compiled with
gcc -g -I path/to/cpython3.4/Include/ -I /path/to/cpython3.4 mytest.c -fPIC
--shared -o mytest.
New submission from Amaury Forgeot d'Arc:
When an extension module is compiled with CPython3.4, the nb_matrix_multiply
slot is not filled, and no memory is allocated for it.
If the extension module is imported by CPython3.5, nb_matrix_multiply contains
garbage and segfaults the interp
Amaury Forgeot d'Arc added the comment:
Better use utf-16-le encoding:
len(data.encode('utf-16-le')) + 2
otherwise the encoded bytes start with the \fffe BOM.
--
___
Python tracker
<http://bugs.pyt
Amaury Forgeot d'Arc added the comment:
(you swapped the unicode values: \U0001f4cb is copied as \U0001f400)
On Windows, strings have changed in 3.3. See in
https://docs.python.org/3/whatsnew/3.3.html, "len() now always returns 1 for
non-BMP characters".
The call to GlobalA
Amaury Forgeot d'Arc added the comment:
issue5006 was supposed to take care of this, but it has a flaw IMO:
This statement
https://hg.python.org/cpython/file/0744ceb5c0ed/Lib/_pyio.py#l2003 is missing
an "and whence!=2".
--
nosy: +ama
Amaury Forgeot d'Arc added the comment:
No, OSError.errno is converted from the Windows error code.
There is a translation map (see PC/errmap.h, built with the _dosmaperr()
function) and the default value is EINVAL.
It's working as intended. What was the winerror code? do you think
Amaury Forgeot d'Arc added the comment:
Agreed. environ.pop() was fixed a long time ago with issue1287.
It seems that all mutable methods of the environ pseudo-dict are now correctly
reflected to the platform environ.
The other direction (updates from C code should be reflected in os.en
Amaury Forgeot d'Arc added the comment:
The patch looks good to me.
But it seems that the reverse operation is not possible in the general case:
.decode('unicode_escape') assumes a latin-1 or ascii encoding.
Should we document this?
--
nosy: +ama
Amaury Forgeot d'Arc added the comment:
Closing this old issue: either use the 'regex' module, or wait for issue2636.
--
nosy: +amaury.forgeotdarc
resolution: -> works for me
status: open -> closed
___
Python tracker
&l
Changes by Amaury Forgeot d'Arc :
--
resolution: -> works for me
status: open -> closed
___
Python tracker
<http://bugs.python.org/issue1962>
___
___
Amaury Forgeot d'Arc added the comment:
"solution.put(c)" takes a *reference* to the list c.
And then the test() function continues running!
By the time the list is serialized and sent back to the main process (in
another thread), the test() function has already changed it...
Amaury Forgeot d'Arc added the comment:
You can try to run IDLE from a command prompt. Type the command:
path_to_python34.exe -m idlelib
and look at error messages.
--
nosy: +amaury.forgeotdarc
___
Python tracker
<http://bugs.py
Amaury Forgeot d'Arc added the comment:
So, dir(C) contains '__mro__', but not 'mro'?
I'm -1 on the change.
>From https://docs.python.org/3.4/library/functions.html#dir :
"""
Note Because dir() is supplied primarily as a convenience for use
Amaury Forgeot d'Arc added the comment:
Why did you specify "during class initialization" only? When I print
dir(Foo.Bar) at top-level, there is no __qualname__.
Then, note that '__name__' is not listed either, so it's not about new
attributes.
It was chosen tha
Amaury Forgeot d'Arc added the comment:
Looks good to me.
I checked that there are only 16 differences between cp1251 and kz1048,
and that the two standards define the same mapping.
--
nosy: +amaury.forgeotdarc
___
Python tracker
Amaury Forgeot d'Arc added the comment:
What if [some flavor of] pprint sorted items not by value, but by their repr()
string?
It's probably faster than any other algorithm, and guaranteed to produce
consistent results.
Or use this idea only for ambiguous cases?
-
Amaury Forgeot d'Arc added the comment:
> You need to use codecs.open instead of open
No, why? in python3 open() supports the errors handler.
--
___
Python tracker
<http://bugs.python.org
Amaury Forgeot d'Arc added the comment:
What about
open(..., encoding='latin-1', errors='xmlcharrefreplace')
--
nosy: +amaury.forgeotdarc
stage: resolved -> needs patch
___
Python tracker
<ht
Amaury Forgeot d'Arc added the comment:
html is text, so the file mode should be 'w'.
But I don't reproduce the behavior with Python version v3.4.2.
Which version are you using exactly?
--
nosy: +amaury.forgeotdarc
___
P
Amaury Forgeot d'Arc added the comment:
I'd use a much simpler encoding.
Maybe something like
name.encode('unicode-escape').replace(b'\\', b'_')
As you said, simplicity is important for tools which generate cod
Amaury Forgeot d'Arc added the comment:
PyPy also has a "C-translated" version of the io module.
It's a bit faster I think, but more importantly it has correct behavior with
signals and other asynchronous errors.
_pyio.py can be stopped in the middle of any function, a
Amaury Forgeot d'Arc added the comment:
permutations() returns a generator.
If you consume it with list(), the second time will return the empty list.
Use list(permutations(...)) if you plan to use the result multiple times.
--
nosy: +amaury.forgeotdarc
resolution: -> invali
Amaury Forgeot d'Arc added the comment:
Is the error still current? io.StringIO is now completely implemented in
_io/textio.c, and should not have any Python-level __del__.
--
___
Python tracker
<http://bugs.python.org/i
Amaury Forgeot d'Arc added the comment:
Functions are pickled by name, not by code.
Unpickling will only work if a function with the same name is present in in the
same module (__main__ in your example)
This is why pickling a lambda won't work: they have no individual names.
-
Amaury Forgeot d'Arc added the comment:
The NoneType that fails is in typeobject.c:
_PyObject_CallMethodId(copyreg, &PyId__slotnames, "O", cls);
The error here is that copyreg comes from a cached reference to the module,
stored in a static variable (cached_copyreg
Amaury Forgeot d'Arc added the comment:
It never worked for me.
Are you using a custom shell or cygwin or something?
--
nosy: +amaury.forgeotdarc
___
Python tracker
<http://bugs.python.org/is
Amaury Forgeot d'Arc added the comment:
getsizeof() is interesting only if it gives sensible results when used
correctly, especially if you want to sum these values and get a global memory
usage.
One usage is to traverse objects through gc.get_referents(); in this case the
definition
Amaury Forgeot d'Arc added the comment:
I like the definition of __sizeof__ that was discussed some time ago:
http://bugs.python.org/issue14520#msg157798
With that definition (do we have it somewhere in the docs, by the way?)
The current code works gives the correct answer.
--
Amaury Forgeot d'Arc added the comment:
> 2. _PyVerify_fd(fd) is always true. Given the current definition:
> #define _PyVerify_fd(fd) (_get_osfhandle(fd) >= 0)
> for those values of fd _get_osfhandle(fd) >= 0, always.
Hum, are you sure this is the selected implementation?
Amaury Forgeot d'Arc added the comment:
Ah, http://hg.python.org/cpython/rev/80d491aaeed2/ as well then.
--
___
Python tracker
<http://bugs.python.org/is
Amaury Forgeot d'Arc added the comment:
http://hg.python.org/cpython/rev/c4bbda2d4c49 looks relevant.
--
___
Python tracker
<http://bugs.python.org/is
Amaury Forgeot d'Arc added the comment:
To ensure it's a real memory leak: do the figures increase when the code is
called in a loop?
I would not consider a single-time malloc (stored in some static variable) to
be a leak.
--
nosy: +amaury.f
Amaury Forgeot d'Arc added the comment:
Is it really impossible to use a standard Python dict instead of cfuhash?
--
nosy: +amaury.forgeotdarc
___
Python tracker
<http://bugs.python.org/is
Amaury Forgeot d'Arc added the comment:
Did you consider creating a copy with a random suffix?
--
nosy: +amaury.forgeotdarc
___
Python tracker
<http://bugs.python.org/is
Amaury Forgeot d'Arc added the comment:
This is a memory corruption.
Please look at the memory before the freed address (0x449e6900), maybe there is
an indication of some buffer overflow?
--
nosy: +amaury.forgeotdarc
___
Python tracker
Amaury Forgeot d'Arc added the comment:
I think it's the opposite: when Unix support was added to ctypes, 'import
ctypes.wintypes' was not considered. By that logic, the patch is a new feature.
IMO "historical" arguments are moot :-)
I agree with the conclusion t
Amaury Forgeot d'Arc added the comment:
You need a better use case though.
termios awful constant names ('TIOCGWINSZ') and values ('\x1b') won't become
more easy with a nametuple.
--
resolution: -> works for me
status: open -> closed
__
Amaury Forgeot d'Arc added the comment:
namedtuple has a _replace method, but I agree that it would be an incompatible
change. "namedlist" someone?
class tcattributes(object):
__slots__ = ['iflag', 'oflag', 'cflag', 'lflag',
Amaury Forgeot d'Arc added the comment:
+1 for PyException_SetContext or similar. The C code should behave like a
"finally: x.finalize()".
--
nosy: +amaury.forgeotdarc
___
Python tracker
<http://bugs.pyt
Amaury Forgeot d'Arc added the comment:
This is expected. When you assign to "n.__div__" a function which takes two
parameters, you have to call it with two parameters:
aFunction = lambda x, y: (x, y)
n.__div__ = aFunction
aFunction(1, 2)
n.__div__(1, 2)
After
Amaury Forgeot d'Arc added the comment:
Returning another kind of module can be dangerous here, because extension
modules are handled specially (see _PyImport_FixupExtensionObject),
and it's not obvious what this does to normal modules.
But I agree that _imp.load_dynamic() could be e
Amaury Forgeot d'Arc added the comment:
I was thinking of a message similar to the one above.
The eventual exception set by PyModule_GetDef(m) is less explicit.
if (def == NULL) {
PyErr_Format(PyExc_SystemError,
"initialization of %s did not return an extens
Changes by Amaury Forgeot d'Arc :
--
status: closed -> open
___
Python tracker
<http://bugs.python.org/issue18426>
___
___
Python-bugs-list mailing li
Amaury Forgeot d'Arc added the comment:
I'm not sure the fix is correct: PyModule_GetDef() can return NULL without
setting an error, for example when the init function returns a regular Python
module.
I'm OK to require the init function to return a module created with
PyModul
Amaury Forgeot d'Arc added the comment:
This is expected, your class must say how this __new__ constructor can be
called.
http://docs.python.org/2/library/pickle.html#object.__getnewargs__
--
nosy: +amaury.forgeotdarc
resolution: -> works for me
status: open -
Amaury Forgeot d'Arc added the comment:
Sorry, this bug tracker is for core Python only. Please discuss this issue on
wxPython-dev mailing list.
--
___
Python tracker
<http://bugs.python.org/is
Amaury Forgeot d'Arc added the comment:
This is an issue with wxPython, please report this issue to the wxPython team.
--
___
Python tracker
<http://bugs.python.org/is
Amaury Forgeot d'Arc added the comment:
wxPython tests override unittest.TextTestRunner:
self.stream = unittest.runner._WritelnDecorator(BytesIO())
Using bytes is wrong. Output stream should be a text file.
--
nosy: +amaury.forgeotdarc
resolution: -> invalid
status: open -
Amaury Forgeot d'Arc added the comment:
Fortunately, compatible_for_assignment() handles both arguments exactly the
same way, except maybe in error messages.
--
nosy: +amaury.forgeotdarc
___
Python tracker
<http://bugs.python.org/is
Amaury Forgeot d'Arc added the comment:
Since this error can occur only during the development of a C extension, I
would not worry too much. The traceback will already indicate the imported
module, this is much better than a segfault later in
Amaury Forgeot d'Arc added the comment:
The patch is not complete: PyType_Ready() returns -1 but no no exception is set.
--
___
Python tracker
<http://bugs.python.org/is
Amaury Forgeot d'Arc added the comment:
RPython... let's be serious. The code of pythonw.exe is very simple, see
PC/WinMain.c.
No, pythonw.exe is not "meant to suppresses the terminal window on startup".
This is only a consequence of being a "windows applic
Amaury Forgeot d'Arc added the comment:
The proper solution if you use pythonw.exe is to define sys.stdout/sys.stderr
yourself in pythonw.exe::
sys.stdout = open('c:/temp/output.txt', 'w')
IOW, do the redirect from inside the program, don't rely on the shel
Amaury Forgeot d'Arc added the comment:
Yes, in pythonw.exe the C stderr is not really usable, and this leads to
unpredictable results.
It's difficult to fix in python2 though; python3 has fixed this issue, but in a
way that cannot be backported.
Some workarounds:
- don't use p
Amaury Forgeot d'Arc added the comment:
> Let's unify os' and select's behavior!
OK, let's do that on Windows first :-)
--
___
Python tracker
<ht
Amaury Forgeot d'Arc added the comment:
Do we want the low-level os.write() to work with file objects, or sockets?
--
nosy: +amaury.forgeotdarc
___
Python tracker
<http://bugs.python.org/is
Amaury Forgeot d'Arc added the comment:
Times in a ZIP files have a two-seconds resolution (in the old DOS FAT format:
5 bits for the hours, 6 bits for the minutes, and only 5 bits left for the
seconds)
Some fuziness logic is needed when comparing against a time_t.
--
Amaury Forgeot d'Arc added the comment:
PyShell.py, line 1541:
if shell and cmd or script:
Does it need parentheses?
if shell and (cmd or script):
--
nosy: +amaury.forgeotdarc
___
Python tracker
<http://bugs.python.org/is
Amaury Forgeot d'Arc added the comment:
in encoder.py:
...
elif instance(value, int):
yield buf + str(value)
...
What if we use int(str(value)) instead?
--
nosy: +amaury.forgeotdarc
___
Python tracker
<http://bugs.py
Amaury Forgeot d'Arc added the comment:
FYI, PyPy recently got bitten by this: https://bugs.pypy.org/issue1518
A posix.libc_getenv() function could be a solution.
--
nosy: +amaury.forgeotdarc
___
Python tracker
<http://bugs.python.org/i
Amaury Forgeot d'Arc added the comment:
LGTM. I checked in Makefile.am, and the list of platform-specific files is the
same.
--
___
Python tracker
<http://bugs.python.org/is
Amaury Forgeot d'Arc added the comment:
You can also use "_pack_ = 1" to override the default alignment rules:
http://docs.python.org/3/library/ctypes.html#ctypes.Structure._pack_
--
nosy: +amaury.forgeotdarc
___
Python
Amaury Forgeot d'Arc added the comment:
Aditya, python3 changed the API to create modules. See issue18210.
--
nosy: +amaury.forgeotdarc
___
Python tracker
<http://bugs.python.org/is
Amaury Forgeot d'Arc added the comment:
Python3 has a new API to create modules: PyModule_Create() and PyModuleDef.
See also:
http://docs.python.org/3/howto/cporting.html?highlight=pymodule_create#module-initialization-and-state
--
nosy: +amaury.forgeotdarc
resolution: ->
Amaury Forgeot d'Arc added the comment:
This is one case of chained comparisons:
http://docs.python.org/3/reference/expressions.html#not-in
"x <= y <= z" is equivalent to "(x <= y) and (y <= z)"
"x in y == z" is equivalent to "(x in y) and
Amaury Forgeot d'Arc added the comment:
Surely there are already good places to help with 2->3 transition?
The Library Reference is not such a place.
--
nosy: +amaury.forgeotdarc
___
Python tracker
<http://bugs.python.org
Amaury Forgeot d'Arc added the comment:
Most concrete variable-sized types don't use tp_basicsize to know where the
data lives. For example, PyBytesObject has a "char ob_sval[1];" member, and
PyBytes_AsString() looks at this fixed offset.
For this reason, additional d
Amaury Forgeot d'Arc added the comment:
Is it possible to avoid a new slot?
for example, super() could walk the tp_base-> chain and call tp_getattro each
time the value changes.
--
___
Python tracker
<http://bugs.python.org
Amaury Forgeot d'Arc added the comment:
I prefer the new version without PYMEM_TRACE_MALLOC :-)
Can we rename "API" and "api_id" to something more specific? maybe DOMAIN and
domain_id?
--
___
Python tracker
<http
Amaury Forgeot d'Arc added the comment:
issue783528 was a bit similar.
--
___
Python tracker
<http://bugs.python.org/issue18181>
___
___
Python-bugs-list m
Amaury Forgeot d'Arc added the comment:
>>> a = chr(0x84b2e)+chr(0x109710)
>>> a.lower()
SystemError: invalid maximum character passed to PyUnicode_New
The MAX_MAXCHAR() macro only works for 'maxchar' values, like 0xff, 0x...
in do_upper_or_lower() it&
Amaury Forgeot d'Arc added the comment:
Do you have an example in pure Python code?
--
nosy: +amaury.forgeotdarc
___
Python tracker
<http://bugs.python.org/is
Amaury Forgeot d'Arc added the comment:
Said simpler: dlmalloc.c code is indeed compiled twice:
- once as part of closures.c, which #include "dlmalloc.c"; this is done
carefully (with 'static' and 'USE_DL_PREFIX') to not clash with standard malloc
fun
1 - 100 of 2691 matches
Mail list logo