[issue22774] Weird S.rstrip() result

2014-10-31 Thread Szieberth Ádám

New submission from Szieberth Ádám:

I just faced the following bug (v3.4.2):

 t1 = '#5 amarg (Concession)'
 t2 = '#6 ironman (Concession)'
 s = ' (Concession)'
 t1.rstrip(s)
'#5 amarg'
 t2.rstrip(s)
'#6 ironma'
 t1[:-len(s)]
'#5 amarg'
 t2[:-len(s)]
'#6 ironman'

--
messages: 230343
nosy: SzieberthAdam
priority: normal
severity: normal
status: open
title: Weird S.rstrip() result
type: behavior
versions: Python 3.4

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22774
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21205] Unable to make decorated generator object to inherit generator function's __name__

2014-04-12 Thread Szieberth Ádám

New submission from Szieberth Ádám:

I faced this particular issue by writing decorators for asyncio coroutines. 

I even posted a question to SO: 
http://stackoverflow.com/questions/23015626/how-to-decorate-an-asyncio-coroutine-to-retain-its-name

However, since that I realized the problem is more general. I believe that a 
generator object should inherit its function's __name__ attribute instead of 
ignoring it. Example:



import functools

def decorated(genfunc):
@functools.wraps(genfunc)
def wrapper(*args, **kargs):
print('inside wrapper')
for x in genfunc(*args, **kargs):
yield 'decorated: {!r}'.format(x)
print('outside wrapper')
print('wrapper.__name__: {!r}'.format(wrapper.__name__))
return wrapper

@decorated
def simple_genfunc():
Testdoc.
yield from range(10)

if __name__ == '__main__':
print('simple_genfunc.__name__: {!r}'.format(
simple_genfunc.__name__))
print('simple_genfunc().__name__: {!r}'.format(
simple_genfunc().__name__))


And its result:

Z:\python -i genfuncdec.py
outside wrapper
wrapper.__name__: 'simple_genfunc'
simple_genfunc.__name__: 'simple_genfunc'
simple_genfunc().__name__: 'wrapper'
 simple_genfunc
function simple_genfunc at 0x00C30420
 simple_genfunc.__wrapped__
function simple_genfunc at 0x00C304B0
 simple_genfunc()
generator object wrapper at 0x00C0EE18
 simple_genfunc.__wrapped__()
generator object simple_genfunc at 0x00C0ED28

As you can see the generator object's __name__ remained the hardcoded one.

--
messages: 215968
nosy: SzieberthAdam
priority: normal
severity: normal
status: open
title: Unable to make decorated generator object to inherit generator 
function's __name__
type: enhancement
versions: Python 3.4

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21205
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com