[issue13062] Introspection generator and function closure state
Changes by Daniel Urban : -- nosy: +durban ___ Python tracker <http://bugs.python.org/issue13062> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13264] Monkeypatching using metaclass
Changes by Daniel Urban : -- nosy: +durban ___ Python tracker <http://bugs.python.org/issue13264> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13264] Monkeypatching using metaclass
Daniel Urban added the comment: > class Meta(ABCMeta): > def __instancecheck__(cls, instance): > # monkeypatching class method > cls.__subclasscheck__ = super(Meta, cls).__subclasscheck__ This line is approximately the same as: cls.__dict__['__subclasscheck__'] = ... So it will put the object in the namespace of cls. The function in the namespace of type(cls) will remain there. (Also, the object you put in there is a bound method, so this is probably not what you want.) > return super(Meta, cls).__instancecheck__(instance) > > def __subclasscheck__(cls, sub): > return cls in sub.mro() > > class A(object): > __metaclass__ = Meta > > class B(object): pass > > # registering class 'B' as a virtual subclass of 'A' > A.register(B) > > >>> issubclass(B, A) > False > >>> isinstance(B(), A) # => method __subclasscheck__ is now > monkeypatched A.__dict__['__subclasscheck__'] is now indeed the other method you put in there, but issubclass will call type(A).__dict__['__subclasscheck__'] which remain the same. (Because __special__ methods a looked up directly in the namespace of the type of an object, see http://docs.python.org/dev/py3k/reference/datamodel#special-lookup). -- ___ Python tracker <http://bugs.python.org/issue13264> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13266] Add inspect.unwrap(f) to easily unravel "__wrapped__" chains
Changes by Daniel Urban : -- nosy: +durban ___ Python tracker <http://bugs.python.org/issue13266> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13264] Monkeypatching using metaclass
Daniel Urban added the comment: > It seems to me this is not a bug. +1 -- ___ Python tracker <http://bugs.python.org/issue13264> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11610] Improved support for abstract base classes with descriptors
Daniel Urban added the comment: It doesn't work with staticmethod: >>> import abc >>> >>> class C(metaclass=abc.ABCMeta): ... @staticmethod ... @abc.abstractmethod ... def foo(x): ... raise NotImplementedError() ... >>> class D(C): ... @staticmethod ... def foo(x): ... return x + 1 ... >>> D() Traceback (most recent call last): File "", line 1, in TypeError: Can't instantiate abstract class D with abstract methods foo.__func__ >>> -- ___ Python tracker <http://bugs.python.org/issue11610> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11610] Improved support for abstract base classes with descriptors
Daniel Urban added the comment: I've posted some comments on Rietveld. -- ___ Python tracker <http://bugs.python.org/issue11610> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12374] Execution model should explain compile vs definition vs execution time
Changes by Daniel Urban : -- nosy: +durban ___ Python tracker <http://bugs.python.org/issue12374> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12459] time.sleep(-1.0) behaviour
Changes by Daniel Urban : -- nosy: +durban ___ Python tracker <http://bugs.python.org/issue12459> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12457] type() returns incorrect type for nested classes
Changes by Daniel Urban : -- nosy: +durban ___ Python tracker <http://bugs.python.org/issue12457> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8639] Allow callable objects in inspect.getargspec
Changes by Daniel Urban : -- nosy: +durban ___ Python tracker <http://bugs.python.org/issue8639> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12559] gzip.open() needs an optional encoding argument
Daniel Urban added the comment: Here is a patch. If the code changes are acceptable I can also make a documentation patch. (I'm surprised to see 3.2 in "Versions". I thought 3.2 only gets bugfixes...) -- keywords: +patch nosy: +durban Added file: http://bugs.python.org/file22661/issue12559.patch ___ Python tracker <http://bugs.python.org/issue12559> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12559] gzip.open() needs an optional encoding argument
Daniel Urban added the comment: > If we go this way, the "errors" and "newline" argument should be added > as well. Yeah, I thought about that. I can make a new patch, that implement this, if needed. Though it seems there is a real problem, the one that Amaury Forgeot d'Arc mentioned. I can't think of a way to solve it in a backwards compatible way. -- ___ Python tracker <http://bugs.python.org/issue12559> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12575] add a AST validator
Changes by Daniel Urban : -- nosy: +durban ___ Python tracker <http://bugs.python.org/issue12575> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12608] crash in PyAST_Compile when running Python code
Changes by Daniel Urban : -- nosy: +durban ___ Python tracker <http://bugs.python.org/issue12608> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12599] Use 'is not None' where appropriate in importlib
Changes by Daniel Urban : -- nosy: +durban ___ Python tracker <http://bugs.python.org/issue12599> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12617] Mutable Sequence Type can work not only with iterable in slice[i:j] = t
Changes by Daniel Urban : -- nosy: +durban ___ Python tracker <http://bugs.python.org/issue12617> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12647] Add __bool__ to None
Changes by Daniel Urban : -- nosy: +durban ___ Python tracker <http://bugs.python.org/issue12647> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12657] Cannot override JSON encoding of basic type subclasses
Changes by Daniel Urban : -- nosy: +durban ___ Python tracker <http://bugs.python.org/issue12657> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12691] tokenize.untokenize is broken
Changes by Daniel Urban : -- nosy: +durban ___ Python tracker <http://bugs.python.org/issue12691> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12675] tokenize module happily tokenizes code with syntax errors
Changes by Daniel Urban : -- nosy: +durban ___ Python tracker <http://bugs.python.org/issue12675> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12735] request full Unicode collation support in std python library
Changes by Daniel Urban : -- nosy: +durban ___ Python tracker <http://bugs.python.org/issue12735> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12732] Can't portably use Unicode in Python identifiers
Changes by Daniel Urban : -- nosy: +durban ___ Python tracker <http://bugs.python.org/issue12732> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12772] fractional day attribute in datetime class
Changes by Daniel Urban : -- nosy: +durban versions: +Python 3.3 -Python 2.7 ___ Python tracker <http://bugs.python.org/issue12772> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12775] immense performance problems related to the garbage collector
Changes by Daniel Urban : -- nosy: +durban ___ Python tracker <http://bugs.python.org/issue12775> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12857] Expose called function on frame object
Changes by Daniel Urban : -- nosy: +durban ___ Python tracker <http://bugs.python.org/issue12857> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12850] [PATCH] stm.atomic
Changes by Daniel Urban : -- nosy: +durban ___ Python tracker <http://bugs.python.org/issue12850> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12915] Add inspect.locate and inspect.resolve
Changes by Daniel Urban : -- nosy: +durban ___ Python tracker <http://bugs.python.org/issue12915> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5867] No way to create an abstract classmethod
Changes by Daniel Urban : -- nosy: +durban ___ Python tracker <http://bugs.python.org/issue5867> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5996] abstract class instantiable when subclassing dict
Daniel Urban added the comment: I think, that the reason is that, object.__new__ checks, if the class is instantiable (object_new in Objects/typeobject.c ). dict.__new__ (and tuple.__new__, and I guess the __new__ method of other built-in types) doesn't call object.__new__, but user defined types typically either doesn't have a __new__, or call object.__new__ from it (directly or with super). -- nosy: +durban ___ Python tracker <http://bugs.python.org/issue5996> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5867] No way to create an abstract classmethod
Daniel Urban added the comment: @abstractmethod @classmethod def ... doesn't work because classmethod objects doesn't have a __dict__, so setting arbitrary attributes don't work, and abstractmethod tries to set the __isabstractmethod__ atribute to True. The other order: @classmethod @abstractmethod def ... doesn't work, because the abstractmethod decorator sets the function's __isabstractmethod__ attribute to True, but when ABCMeta.__new__ checks the object in the namespace of the class, it won't find it, because the classmethod object won't have an __isabstractmethod__ attribute. The situation is the same with staticmethod. One possible solution would be adding a descriptor to classmethod (and staticmethod), with the name "__isabstractmethod__", which on __get__ would check its underlying callable for this attribute, and on __set__ would set this attribute on that callable. I think this way both order should work. -- ___ Python tracker <http://bugs.python.org/issue5867> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5867] No way to create an abstract classmethod
Daniel Urban added the comment: Here is a patch, which adds a descriptor to classmethod and staticmethod. Pseudocode: __get__(self, inst, owner): if getattr(inst.callable, '__isabstractmethod__', False): return True return False __set__(self, inst, value): inst.callable.__isabstractmethod__ = bool(value) -- keywords: +patch Added file: http://bugs.python.org/file18510/issue5867.diff ___ Python tracker <http://bugs.python.org/issue5867> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5867] No way to create an abstract classmethod
Daniel Urban added the comment: If I understand correctly, some tests are needed for the instantiation of classes with abstract static/classmethods. I added them in issue5867a.diff. -- Added file: http://bugs.python.org/file18512/issue5867a.diff ___ Python tracker <http://bugs.python.org/issue5867> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5867] No way to create an abstract classmethod
Daniel Urban added the comment: I'm attaching a new patch adding the abc.abstractclassmethod and abc.abstractstaticmethod decorators. -- Added file: http://bugs.python.org/file18519/abstractclassstaticmethod.diff ___ Python tracker <http://bugs.python.org/issue5867> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5867] No way to create an abstract classmethod
Daniel Urban added the comment: I'm attaching a new patch containing also some documentation for the two new decorators. The doc is rather terse, and english is not my first language, so please let me know if some corrections are needed. -- Added file: http://bugs.python.org/file18542/abstractclassstaticmethod+doc.diff ___ Python tracker <http://bugs.python.org/issue5867> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1615] descriptor protocol bug
Changes by Daniel Urban : -- nosy: +durban ___ Python tracker <http://bugs.python.org/issue1615> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9212] dict_keys purports to implement the Set ABC, but is missing the isdisjoint method
Daniel Urban added the comment: Thanks for the corrections. I'm attaching the new patch as issue9212b.diff. I'm using PyAnySet_Check to determine if the other argument is really a set, but I'm not entirely sure, that this is correct. Please let me know if other corrections are needed. -- Added file: http://bugs.python.org/file18702/issue9212b.diff ___ Python tracker <http://bugs.python.org/issue9212> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9731] Add ABCMeta.has_methods and tests that use it
Changes by Daniel Urban : -- nosy: +durban ___ Python tracker <http://bugs.python.org/issue9731> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9213] range purports to implement the Sequence ABC, but is missing index and count methods
Daniel Urban added the comment: > Attached is a greatly revised patch, with two significant changes: > - Adds support for !PyLong_CheckExact (using _PySequence_IterSearch) Thanks, indeed, we should support that. > Any strong feelings on whether range.index should support the start and > stop arguments provided by list.index, tuple.index, and str.index, but > not by collections.Sequence.index? I don't think that this is very important. -- ___ Python tracker <http://bugs.python.org/issue9213> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8699] Equality and hashing for functools.partial
Daniel Urban added the comment: Is there anybody, who is interested in this? There are some substantial problems with it (hashing a dict), so I suggest that this should be closed, unless somebody is interested. -- status: open -> pending ___ Python tracker <http://bugs.python.org/issue8699> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4761] create Python wrappers for openat() and others
Changes by Daniel Urban : -- nosy: +durban ___ Python tracker <http://bugs.python.org/issue4761> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9746] All sequence types support .index and .count
Changes by Daniel Urban : -- nosy: +durban ___ Python tracker <http://bugs.python.org/issue9746> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9756] Crash with custom __getattribute__
Changes by Daniel Urban : -- nosy: +durban ___ Python tracker <http://bugs.python.org/issue9756> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9896] Introspectable range objects
New submission from Daniel Urban : The attached patch adds the start, stop and step members to range objects, corresponding the contructor arguments. The patch also include tests and documentation changes. -- components: Interpreter Core files: range_attrs.diff keywords: patch messages: 116824 nosy: durban priority: normal severity: normal status: open title: Introspectable range objects type: feature request versions: Python 3.2 Added file: http://bugs.python.org/file18922/range_attrs.diff ___ Python tracker <http://bugs.python.org/issue9896> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9896] Introspectable range objects
Daniel Urban added the comment: > What is the use case for this? The basic idea was, that in Python almost everything is introspectable, so why range objects aren't. It was pretty straightforward to implement it, so I've done it (actually when I was working on rangeobject.c, I was surprised to see that these members aren't available from python code). But if this isn't needed, I'm absolutely ok with that. I think this would be a nice to have feature, but of course not necessary. Also, if it violates the moratorium (I don't know), then of course this sould be at least postponed. -- ___ Python tracker <http://bugs.python.org/issue9896> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9971] Optimize BufferedReader.readinto
Changes by Daniel Urban : -- nosy: +durban ___ Python tracker <http://bugs.python.org/issue9971> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9533] metaclass can't derive from ABC
Daniel Urban added the comment: If we create a new class, which is a metaclass, and also inherits an ABC, we create a new instance of ABCMeta. When ABCMeta.__new__ creates the __abstractmethods__ attribute of the new class, it iterates over the __abstractmethods__ attribute of every base class (and checks every name in it, if it's abstract in the new class). One of the base classes of a metaclass is of course type. The type.__abstractmethods__ object is a getset descriptor (its __set__ switches some flags in tp_flags), which isn't iterable, so it raises the exception. Ideas for possible solutions: 1. In ABCMeta.__new__ special case type (do not check its __abstractmethods__attribute). 2. In ABCMeta.__new__ check if the __abstractmethods__ attribute is in fact an iterable, before we try to iterate over it. (I don't think this would be a very good solution, because if a base class' __abstractmethods__ isn't iterable, it should be an error, except if the base class is type itself. So we should special case type anyway.) I can't come up with a use case for this right now, but I don't see why it shouldn't work. -- components: +Library (Lib) ___ Python tracker <http://bugs.python.org/issue9533> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10006] non-Pythonic fate of __abstractmethods__
Changes by Daniel Urban : -- nosy: +durban ___ Python tracker <http://bugs.python.org/issue10006> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10049] Add a "no-op" (null) context manager to contextlib
Changes by Daniel Urban : -- nosy: +durban ___ Python tracker <http://bugs.python.org/issue10049> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10224] Build 3.x documentation using python3.x
Changes by Daniel Urban : -- nosy: +durban ___ Python tracker <http://bugs.python.org/issue10224> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11297] Make ChainMap() public in the collections module.
Changes by Daniel Urban : -- nosy: +durban ___ Python tracker <http://bugs.python.org/issue11297> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11333] Add empty __slots__ to collections.abc abstract base classes
New submission from Daniel Urban : Currently instances of classes which inherit an ABC in collections.abc will have a __dict__. This can be a problem for example a tree-like data structure. It would make sense to inherit for example MutableMapping, but that would possibly mean, that every node in the tree would have a __dict__, which is probably a waste of memory. A workaround for this problem is not inheriting the ABC, and using ABCMeta.register (and optionally adding the mixin methods explicitly), but this feels like a hack. The attached patch adds an empty __slots__ to the ABCs in collections.abc. I excluded the mapping views (MappingView, KeysView, ItemsView and ValuesView), because they can't have an empty __slots__, and I think using a nonempty __slots__ possibly can cause problems in some cases with multiple inheritance. -- components: Library (Lib) files: collections_abc_slots.diff keywords: patch messages: 129534 nosy: durban, rhettinger, stutzbach priority: normal severity: normal status: open title: Add empty __slots__ to collections.abc abstract base classes type: feature request versions: Python 3.3 Added file: http://bugs.python.org/file20910/collections_abc_slots.diff ___ Python tracker <http://bugs.python.org/issue11333> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10868] ABCMeta.register() should work as a decorator
Daniel Urban added the comment: > In what use-cases would you want to call MyABC.register() when defining > a class instead of inheriting from MyABC? For example if you don't want to inherit a __dict__ for a tree-like data structure (see also issue11333). -- ___ Python tracker <http://bugs.python.org/issue10868> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11256] inspect.getcallargs raises TypeError on valid arguments
Daniel Urban added the comment: Updated patch with extra tests. -- Added file: http://bugs.python.org/file20911/issue11256_2.diff ___ Python tracker <http://bugs.python.org/issue11256> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11256] inspect.getcallargs raises TypeError on valid arguments
Daniel Urban added the comment: I found another case, when this is a problem: if there are no **kwargs, but there are some keyword-only arguments: >>> def f(*, a, b): pass ... >>> f(a=1, b=2) >>> >>> getcallargs(f, a=1, b=2) Traceback (most recent call last): ... TypeError: f() takes no arguments (2 given) The attached issue11256_3.diff patch also fixes this problem, and adds tests that would have detected this case. -- Added file: http://bugs.python.org/file20930/issue11256_3.diff ___ Python tracker <http://bugs.python.org/issue11256> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11339] annotation for class being defined
Changes by Daniel Urban : -- nosy: +durban ___ Python tracker <http://bugs.python.org/issue11339> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9276] pickle should support methods
Changes by Daniel Urban : -- nosy: +durban ___ Python tracker <http://bugs.python.org/issue9276> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11378] os.path.join when second argument starts with '/' (linux/unix)
Daniel Urban added the comment: It does exactly what is documented: "If any component is an absolute path, all previous components (on Windows, including the previous drive letter, if there was one) are thrown away, and joining continues." (http://docs.python.org/dev/py3k/library/os.path#os.path.join) -- nosy: +durban ___ Python tracker <http://bugs.python.org/issue11378> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11388] Implement MutableSequence.clear()
Changes by Daniel Urban : -- nosy: +durban ___ Python tracker <http://bugs.python.org/issue11388> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4806] Function calls taking a generator as star argument can mask TypeErrors in the generator
Changes by Daniel Urban : -- nosy: +durban ___ Python tracker <http://bugs.python.org/issue4806> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7689] Pickling of classes with a metaclass and copy_reg
Changes by Daniel Urban : -- nosy: +durban ___ Python tracker <http://bugs.python.org/issue7689> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4806] Function calls taking a generator as star argument can mask TypeErrors in the generator
Daniel Urban added the comment: I think the patch isn't entirely correct. It uses PyIter_Check for detecting the case when an *iterable* raises TypeError, but that function actually checks for an *iterator*. The check on the tp_iter member mentioned by Amaury Forgeot d'Arc probably would be better, but even that wouldn't detect every iterable: "Its presence normally signals that the instances of this type are iterable (although sequences may be iterable without this function)." (http://docs.python.org/dev/py3k/c-api/typeobj.html#PyTypeObject.tp_iter) (Apparently any object with a __getitem__ is iterable. By the way, collections.abc.Iterable also doesn't detect this case.) -- versions: +Python 3.3 ___ Python tracker <http://bugs.python.org/issue4806> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4806] Function calls taking a generator as star argument can mask TypeErrors in the generator
Daniel Urban added the comment: I'm attaching an updated patch. Instead !PyIter_Check() this patch checks for tp_iter == NULL && !PySequence_Check. If this condition is false, PyObject_GetIter has a chance to succeed (and if it fails, we shouldn't mask the exception). I also added more tests which show why the previous patch was incorrect. -- Added file: http://bugs.python.org/file21028/issue4806.patch ___ Python tracker <http://bugs.python.org/issue4806> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11441] compile() raises SystemError if called from except clause
Daniel Urban added the comment: Apparently ast_error_finish calls PyTuple_GetItem with a value that is not a tuple, but a SyntaxError instance (in Python/ast.c line 112). It seems that ast_error_finish expects that PyErr_Fetch will return the exception value as a tuple, and in some cases this seems correct (for example when not in an except clause), but not in this case. I don't know much about Python exception handling in C, but it seems to me, that it shouldn't expect always a tuple (see also http://docs.python.org/dev/py3k/c-api/exceptions.html#PyErr_NormalizeException). -- nosy: +durban versions: +Python 3.2 ___ Python tracker <http://bugs.python.org/issue11441> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11441] compile() raises SystemError if called from except clause
Daniel Urban added the comment: Here is a patch. I wasn't sure, where to put the test, so I put it in test_ast. -- keywords: +patch Added file: http://bugs.python.org/file21054/issue11441.patch ___ Python tracker <http://bugs.python.org/issue11441> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11441] compile() raises SystemError if called from except clause
Daniel Urban added the comment: Okay, here is a new patch with the test in the correct place (I hope). -- Added file: http://bugs.python.org/file21055/issue11441_2.patch ___ Python tracker <http://bugs.python.org/issue11441> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11441] compile() raises SystemError if called from except clause
Daniel Urban added the comment: > Why is the exception normalized at the end? I suppose it's because > when value is an exception instance, it's replaced by a tuple, but the > original value has to be recreated at the end. So in some cases, the > SyntaxError object is created twice... > > If PyErr_NormalizeException() can't be avoided, I suggest to call it > at the start, just after PyErr_Fetch, and use the PySyntaxErrorObject* > structure directly to get the file name and line numbers. Yeah, it is because ast_error_finish creates a new tuple to use as the exception value. (It creates a new (errstr, (filename, lineno, offset, loc)) tuple from the original (errstr, lineno, offset) tuple). And yes, in some cases the SyntaxError instance is created twice. I wasn't sure if it's okay to simply replace the args field of a PyBaseExceptionObject. I don't know, if PyErr_NormalizeException() can be avoided, you wrote, that it "should probably normalize the exception as well". Would it be better, if we, when got an exception instance, create the new tuple from the info, and replace the args field of the instance with it? (But it also seems to me, that the SyntaxError objects have other fields as well, so probably we should modify them also. That's why I thought that calling PyErr_NormalizeException with the new tuple is the simplest thing to do, becuase I guess that'll take care of all fields automatically.) -- ___ Python tracker <http://bugs.python.org/issue11441> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11441] compile() raises SystemError if called from except clause
Daniel Urban added the comment: > You could also call PyErr_NormalizeException at the beginning, and > update the fields directly in the PySyntaxErrorObject structure. No > need to deal with any tuple. Sorry, but I don't really understand. If I call PyErr_NormalizeException at the beginning, the SyntaxError instance will be initialized with the wrong 3-tuple: (errstr, lineno, offset). If after that I update the msg, filename, ... fields, they will be correct, but I think the args field still will be the wrong 3-tuple. So I'll have to still create the new tuple, and replace the args field, right? -- ___ Python tracker <http://bugs.python.org/issue11441> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11441] compile() raises SystemError if called from except clause
Daniel Urban added the comment: So, I see four possible solutions: 1. If we get a tuple, create the new tuple, normalize the exception, and store it. If we get a SyntaxError instance, use its args, create the new tuple, normalize, and store. (In this case a SyntaxError instance will be created twice.) 2. If we get a tuple, create the new tuple and store it without normalization. If we get a SyntaxError instance use its args to create the new tuple and store it without normalization. (I think, that later it's still possible that a new SynaxError will be created, but we don't create it here.) 3. If we get a tuple, create the new tuple, and store it without normalization. If we get a SyntaxError, take its args, create the new tuple, and call SyntaxError.__init__ with it. I think this will set all fields properly. 4. Like 3., but if we got a tuple, store the new tuple with normalization. My patch currently does 1. My patch, without the PyErr_NormalizeException() call would be 2. I think maybe 3. would be the best solution, or 4., if normalization is desired in all cases. I can write a new patch, if the experts tell me what is the best solution from the four (or some other I didn't think of). -- ___ Python tracker <http://bugs.python.org/issue11441> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11441] compile() raises SystemError if called from except clause
Daniel Urban added the comment: Err... sorry, I don't understand again: If we get a tuple, create a new, store it without normalization. That's okay, I understand. If we get a SyntaxError instance, then take its args field, create the new tuple. Then call PyErr_NormalizeException(), with: a) the new tuple? But this will create a new SyntaxError instance... b) the old SyntaxError instance? But this won't correct the wrong fields of the instance. (I think SyntaxError.__init__ would correct them without creating a new instance.) c) or replace the args of the SyntaxError instance with the new tuple, then call PyErr_NormalizeException() on the instance? But I think that still won't correct the other fields of the instance... Sorry for all these questions... I'd just like to help. -- ___ Python tracker <http://bugs.python.org/issue11441> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11455] issue a warning when populating a CPython type dict with non-string keys
Daniel Urban added the comment: > Can somebody propose a patch? Yes, here it is. (I'm not sure if the test is in the correct file.) -- keywords: +patch nosy: +durban Added file: http://bugs.python.org/file21072/issue11455.patch ___ Python tracker <http://bugs.python.org/issue11455> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11470] Flag inappropriate uses of callable class attributes
Changes by Daniel Urban : -- nosy: +durban ___ Python tracker <http://bugs.python.org/issue11470> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11477] Bug in code dispatching based on internal slots
Changes by Daniel Urban : -- nosy: +durban ___ Python tracker <http://bugs.python.org/issue11477> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11480] Cannot copy a class with a metaclass other than type
New submission from Daniel Urban : copy.copy cannot copy a class which have a metaclass other than type: >>> import abc >>> import copy >>> >>> class C(metaclass=abc.ABCMeta): ... pass ... >>> copy.copy(C) Traceback (most recent call last): ... TypeError: can't pickle int objects The reason seems to be, as described in msg8329 (issue494904) that the __reduce_ex__ function inherited from object will be called instead of the method bound to the class object (that's the reason of the strange error message). (See also issue7689.) The interesting thing is, that copy.deepcopy was already fixed in 4680ef4fe90a. I'm attaching a patch, that does basically the same for copy that was done with deepcopy (it also includes a test). -- components: Library (Lib) files: copy_metaclass.patch keywords: patch messages: 130731 nosy: durban priority: normal severity: normal status: open title: Cannot copy a class with a metaclass other than type type: behavior versions: Python 3.1, Python 3.2, Python 3.3 Added file: http://bugs.python.org/file21100/copy_metaclass.patch ___ Python tracker <http://bugs.python.org/issue11480> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11481] The copy module already uses copyreg
New submission from Daniel Urban : In the copyreg documentation there is this sentence: "The copy module is likely to use this in the future as well." (http://docs.python.org/dev/py3k/library/copyreg) But the copy module already uses the copyreg module. -- assignee: docs@python components: Documentation messages: 130732 nosy: docs@python, durban priority: normal severity: normal status: open title: The copy module already uses copyreg versions: Python 3.1, Python 3.2, Python 3.3 ___ Python tracker <http://bugs.python.org/issue11481> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7689] Pickling of classes with a metaclass and copy_reg
Daniel Urban added the comment: Attaching an updated patch for py3k. > Not an expert, but the Python parts of your patch look good to me. Me neither, but the C parts also look good to me. The tests fail without the patch, succeed with it. Note, that it is possible, that the copy module also should be fixed similarly (but currently that can't even copy non-dynamic classes with a metaclass, see issue11480). -- components: +Extension Modules versions: +Python 3.3 Added file: http://bugs.python.org/file21101/issue7689.patch ___ Python tracker <http://bugs.python.org/issue7689> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11549] Rewrite peephole to work on AST
Changes by Daniel Urban : -- nosy: +durban ___ Python tracker <http://bugs.python.org/issue11549> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11133] inspect.getattr_static code execution
Daniel Urban added the comment: The new entry in Misc/NEWS says: "Patch by Daniel Urban." But it wasn't me, who made the patch, I just opened the issue. -- ___ Python tracker <http://bugs.python.org/issue11133> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11562] += on list inside a tuple raises TypeError but succeds anyway
Daniel Urban added the comment: The reason of this behaviour is that x += 1 basically is the same as x = x.__iadd__(1). In the tuple case: t[1] = t[1].__iadd__([6]). The __iadd__ call mutates the list, then the tuple item assignment raises the TypeError. See these examples: >>> import dis >>> dis.dis('x += 1') 1 0 LOAD_NAME0 (x) 3 LOAD_CONST 0 (1) 6 INPLACE_ADD 7 STORE_NAME 0 (x) 10 LOAD_CONST 1 (None) 13 RETURN_VALUE >>> >>> dis.dis('t[1] += [6]') 1 0 LOAD_NAME0 (t) 3 LOAD_CONST 0 (1) 6 DUP_TOP_TWO 7 BINARY_SUBSCR 8 LOAD_CONST 1 (6) 11 BUILD_LIST 1 14 INPLACE_ADD 15 ROT_THREE 16 STORE_SUBSCR 17 LOAD_CONST 2 (None) 20 RETURN_VALUE -- nosy: +durban ___ Python tracker <http://bugs.python.org/issue11562> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11572] bring Lib/copy.py to 100% coverage
Changes by Daniel Urban : -- nosy: +durban ___ Python tracker <http://bugs.python.org/issue11572> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11256] inspect.getcallargs raises TypeError on valid arguments
Daniel Urban added the comment: Updated the patch for mercurial. -- Added file: http://bugs.python.org/file21281/issue11256_4.patch ___ Python tracker <http://bugs.python.org/issue11256> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11610] Improving property to accept abstract methods
Changes by Daniel Urban : -- nosy: +durban ___ Python tracker <http://bugs.python.org/issue11610> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11610] Improving property to accept abstract methods
Daniel Urban added the comment: I looked at the patch (I didn't test it yet), my comments are on Rietveld. -- ___ Python tracker <http://bugs.python.org/issue11610> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11610] Improving property to accept abstract methods
Daniel Urban added the comment: I tried to test your patch, but the build dies with this error: Fatal Python error: Py_Initialize: can't initialize sys standard streams Traceback (most recent call last): File ".../cpython/Lib/io.py", line 60, in Aborted I don't know why is this, but I get this error consistently with your patch, and no error without the patch. On Sat, Mar 19, 2011 at 22:13, wrote: > Thank you for the feedback. The reason I suggested deprecating > abstractproperty is that I think it is essentially broken. Subclasses > have to redeclare the entire property, and if they forget to declare > the setter for what is supposed to be a read/write property, there is > no way to catch it. With the new approach, it is possible to ensure > that all the required features of the property have been implemented. ... > On 2011/03/19 21:36:09, durban wrote: > > I don't think abstractproperty should be deprecated. It is still > > perfectly good to define a read-only abstract property (with one > > decorator instead of two). > > Zen of python. I'm guessing you're referring to "There should be one-- and preferably only one --obvious way to do it." That is a good point. But currently the one way to: - create an abstract static method: @abstractstaticmethod - create an abstract class method: @abstractclassmethod - create an abstract property: @abstractproperty (as you pointed out, this has some problems) With your proposed change the one way to: - create an abstract static method: @abstractstaticmethod - create an abstract class method: @abstractclassmethod - create an abstract property: @abstractmethod + @property This is not a very good API. Note, that a similar thing could be done for class/staticmethod, and then using @abstractmethod + @classmethod would be possible, and the API would be more consistent. But it wasn't done because Guido objected it (see issue5867). > This is the part where I am weak. Can you point me to documentation? > Why is an exception check necessary? Do PyObject_IsTrue and Py_DECREF > not know what to do when passed NULL? http://docs.python.org/dev/py3k/c-api/object.html#PyObject_GetAttrString If a Python API function returns NULL, that usually means that an exception was raised. If you don't want the exception to propagate, you should call PyErr_Clear. And I think it is not a good idea to call a function with NULL, unless the docs explicitly say that it can be passed NULL. -- components: +Interpreter Core ___ Python tracker <http://bugs.python.org/issue11610> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7913] Enhance Cmd support for docstrings and document it.
Daniel Urban added the comment: inspect.cleandoc (which is also used by inspect.getdoc and pydoc.getdoc) seems to do a similar thing. Maybe that could be used for this? -- nosy: +durban ___ Python tracker <http://bugs.python.org/issue7913> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10977] Concrete object C API needs abstract path for subclasses of builtin types
Daniel Urban added the comment: Here is a patch for list. It modifies the following C API functions: PyList_SetItem PyList_Insert PyList_Append PyList_SetSlice PyList_Sort PyList_Reverse _PyList_Extend It also includes tests (with ctypes). I plan to do next the same for dict, but first I'd wait for comments, to know if I'm doing something completely wrong :-) -- keywords: +patch Added file: http://bugs.python.org/file21303/issue10977_list.patch ___ Python tracker <http://bugs.python.org/issue10977> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11455] issue a warning when populating a CPython type dict with non-string keys
Daniel Urban added the comment: > I would prefer an explicit PyExc_RuntimeWarning to not have to read the > source of PyErr_WarnFormat() or its documentation. The patch at issue11470 adds a new warning type, CompatibilityWarning. I think probably that should be used here too. -- ___ Python tracker <http://bugs.python.org/issue11455> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11660] closure with too few cells segfaults
Changes by Daniel Urban : -- nosy: +durban ___ Python tracker <http://bugs.python.org/issue11660> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11664] Add patch method to unittest.TestCase
Changes by Daniel Urban : -- nosy: +durban ___ Python tracker <http://bugs.python.org/issue11664> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11640] Shelve references globals in its __del__ method
Changes by Daniel Urban : -- nosy: +durban ___ Python tracker <http://bugs.python.org/issue11640> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5135] Expose simplegeneric function in functools module
Changes by Daniel Urban : -- nosy: +durban ___ Python tracker <http://bugs.python.org/issue5135> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11680] decimal module generates AttributeError: on call to as_integer_ratio
Daniel Urban added the comment: The problem seems to be that you're calling Decimal.from_float with a Decimal instance, not a float. I'm not sure that should even work. The Decimal constructor can create a decimal from an other decimal. Your suggested solution probably would solve this exception, but I'm not sure it would be the good solution. This way when creating a decimal from another decimal with from_float (which doesn't makes much sense, I think) could result in a loss of precision: >>> Decimal(Decimal('0.9')) Decimal('0.9') >>> >>> math.fabs(Decimal('0.9')) 1.0 >>> -- nosy: +durban type: crash -> behavior versions: +Python 3.1, Python 3.2, Python 3.3 ___ Python tracker <http://bugs.python.org/issue11680> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue887237] Machine integers
Changes by Daniel Urban : -- nosy: +durban ___ Python tracker <http://bugs.python.org/issue887237> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11549] Rewrite peephole to work on AST
Daniel Urban added the comment: > not x == 2 can be theoretically optimized to x != 2, ... I don't think it can: >>> class X: ... def __eq__(self, other): ... return True ... def __ne__(self, other): ... return True ... >>> x = X() >>> >>> not x == 2 False >>> x != 2 True >>> -- ___ Python tracker <http://bugs.python.org/issue11549> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7796] No way to find out if an object is an instance of a namedtuple
Changes by Daniel Urban : -- nosy: +durban ___ Python tracker <http://bugs.python.org/issue7796> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11707] Create C version of functools.cmp_to_key()
Changes by Daniel Urban : -- nosy: +durban ___ Python tracker <http://bugs.python.org/issue11707> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1294232] Error in metaclass search order
Daniel Urban added the comment: The attached test case currently fails. I'll try to make a patch soon. > Perhaps __build_class__ (which I have not read) should either call > type_new or a new function with the winner calculation factored out of > type_new. Yeah, that's exactly what I'm planning to do (the factoring out). -- components: +Interpreter Core keywords: +patch nosy: +benjamin.peterson, gvanrossum type: feature request -> behavior Added file: http://bugs.python.org/file21522/test_issue1294232.patch ___ Python tracker <http://bugs.python.org/issue1294232> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11759] assert for exception parameters
Daniel Urban added the comment: What about this: >>> class MyTestCase(TestCase): ... def test_foo(self): ... with self.assertRaises(SyntaxError) as cm: ... compile('asdf jkl', 'file.py', 'eval') ... self.assertEqual('file.py', cm.exception.filename) This isn't good enough? -- nosy: +durban ___ Python tracker <http://bugs.python.org/issue11759> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1294232] Error in metaclass search order
Daniel Urban added the comment: The attached patch seems to correct this issue. It contains the test attached yesterday, and it passes now. I factored out the winner calculation from type_new to a new _PyType_CalculateWinner function, and type_new calls this. I've put the declaration of this function into object.h, so __build_class__ can also call it, instead of using the metaclass of the first base. (Am I correct in thinking that the underscore prefix keeps it out of the public API?) A slight problem may be, that in some cases this function will be called twice. But it is quite simple, so I don't think it matters much: Without patch: $ ./python -m timeit -- "class A(type): pass class B: pass class C(metaclass=A): pass class D(B, C): pass " 1 loops, best of 3: 371 usec per loop With patch: $ ./python -m timeit -- "class A(type): pass class B: pass class C(metaclass=A): pass class D(B, C): pass " 1 loops, best of 3: 381 usec per loop (Note, that I generated the patch with hg extdiff, because the output of hg qdiff was much more unreadable than simple diff. I can provide an equivalent patch generated by hg if needed.) -- Added file: http://bugs.python.org/file21530/issue_1294232.patch ___ Python tracker <http://bugs.python.org/issue1294232> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11764] inspect.getattr_static code execution w/ class body as non dict
Changes by Daniel Urban : -- nosy: +durban ___ Python tracker <http://bugs.python.org/issue11764> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com