Re: [Python-Dev] Raising OSError concrete classes from errno code

2012-12-26 Thread Serhiy Storchaka

On 25.12.12 23:55, Andrew Svetlov wrote:

Currently we have exception tree of classes inherited from OSError
When we use C API we can call PyErr_SetFromErrno and
PyErr_SetFromErrnoWithFilename[Object] functions.
This ones raise concrete exception class (FileNotFoundError for
example) looking on implicit errno value.
I cannot see the way to do it from python.


>>> raise OSError(errno.ENOENT, 'No such file or directory', 'qwerty')
Traceback (most recent call last):
  File "", line 1, in 
FileNotFoundError: [Errno 2] No such file or directory: 'qwerty'


___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Raising OSError concrete classes from errno code

2012-12-26 Thread Nick Coghlan
On Wed, Dec 26, 2012 at 6:50 PM, Serhiy Storchaka  wrote:
> On 25.12.12 23:55, Andrew Svetlov wrote:
>>
>> Currently we have exception tree of classes inherited from OSError
>> When we use C API we can call PyErr_SetFromErrno and
>> PyErr_SetFromErrnoWithFilename[Object] functions.
>> This ones raise concrete exception class (FileNotFoundError for
>> example) looking on implicit errno value.
>> I cannot see the way to do it from python.
>
>
 raise OSError(errno.ENOENT, 'No such file or directory', 'qwerty')
> Traceback (most recent call last):
>   File "", line 1, in 
> FileNotFoundError: [Errno 2] No such file or directory: 'qwerty'

As Serhiy's example shows, this mapping of error numbers to subclasses
is implemented directly in OSError.__new__. We did this so that code
could catch the new exceptions, even when dealing with old code that
raises the legacy exception types.

http://docs.python.org/3/library/exceptions#OSError could probably do
with an example like the one quoted in order to make this clearer

Cheers,
Nick.


-- 
Nick Coghlan   |   [email protected]   |   Brisbane, Australia
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Raising OSError concrete classes from errno code

2012-12-26 Thread Andrew Svetlov
On Wed, Dec 26, 2012 at 12:16 PM, Nick Coghlan  wrote:
> On Wed, Dec 26, 2012 at 6:50 PM, Serhiy Storchaka  wrote:
>> On 25.12.12 23:55, Andrew Svetlov wrote:
>>>
>>> Currently we have exception tree of classes inherited from OSError
>>> When we use C API we can call PyErr_SetFromErrno and
>>> PyErr_SetFromErrnoWithFilename[Object] functions.
>>> This ones raise concrete exception class (FileNotFoundError for
>>> example) looking on implicit errno value.
>>> I cannot see the way to do it from python.
>>
>>
> raise OSError(errno.ENOENT, 'No such file or directory', 'qwerty')
>> Traceback (most recent call last):
>>   File "", line 1, in 
>> FileNotFoundError: [Errno 2] No such file or directory: 'qwerty'
>
> As Serhiy's example shows, this mapping of error numbers to subclasses
> is implemented directly in OSError.__new__. We did this so that code
> could catch the new exceptions, even when dealing with old code that
> raises the legacy exception types.
>
Sorry.
Looks like OSError.__new__ requires at least two arguments for
executing subclass search mechanism:

>>> OSError(errno.ENOENT)
OSError(2,)
>>> OSError(errno.ENOENT, 'error msg')
FileNotFoundError(2, 'error msg')

I had tried first one and got confuse.

> http://docs.python.org/3/library/exceptions#OSError could probably do
> with an example like the one quoted in order to make this clearer
>
Added http://bugs.python.org/issue16785 for this.


> Cheers,
> Nick.
>
>
> --
> Nick Coghlan   |   [email protected]   |   Brisbane, Australia
> ___
> Python-Dev mailing list
> [email protected]
> http://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe: 
> http://mail.python.org/mailman/options/python-dev/andrew.svetlov%40gmail.com



--
Thanks,
Andrew Svetlov
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Raising OSError concrete classes from errno code

2012-12-26 Thread Serhiy Storchaka
It sould be in Python-Ideas: add keyword argument support for OSError 
and subclasses with suitable default values. I.e.


>>> OSError(errno=errno.ENOENT)
FileNotFoundError(2, 'No such file or directory')
>>> FileNotFoundError(filename='qwerty')
FileNotFoundError(2, 'No such file or directory')
>>> FileNotFoundError(strerr='Bad file')
FileNotFoundError(2, 'Bad file')


___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] push changesets hooks failing

2012-12-26 Thread Jesus Cea
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

I got this when pushing:

"""
jcea@ubuntu:~/hg/python/cpython$ hg push
pushing to ssh://[email protected]/cpython/
searching for changes
searching for changes
remote: adding changesets
remote: adding manifests
remote: adding file changes
remote: added 4 changesets with 9 changes to 3 files
remote: buildbot: change(s) sent successfully
remote: sent email to roundup at [email protected]
remote: notified [email protected] of incoming changeset
0ffaf1079a7a
remote: error: incoming.irker hook raised an exception: [Errno 111]
Connection refused
remote: notified [email protected] of incoming changeset
3801ee5d5d73
remote: error: incoming.irker hook raised an exception: [Errno 111]
Connection refused
remote: notified [email protected] of incoming changeset
b6a9f8fd9443
remote: error: incoming.irker hook raised an exception: [Errno 111]
Connection refused
remote: notified [email protected] of incoming changeset
3f7d5c235d82
remote: error: incoming.irker hook raised an exception: [Errno 111]
Connection refused
"""

- -- 
Jesús Cea Avión _/_/  _/_/_/_/_/_/
[email protected] - http://www.jcea.es/ _/_/_/_/  _/_/_/_/  _/_/
jabber / xmpp:[email protected] _/_/_/_/  _/_/_/_/_/
.  _/_/  _/_/_/_/  _/_/  _/_/
"Things are not so easy"  _/_/  _/_/_/_/  _/_/_/_/  _/_/
"My name is Dump, Core Dump"   _/_/_/_/_/_/  _/_/  _/_/
"El amor es poner tu felicidad en la felicidad de otro" - Leibniz
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with undefined - http://www.enigmail.net/

iQCVAwUBUNsdf5lgi5GaxT1NAQKuzQP+IPef5nx00zKdUwL4LoLDds05Dl+WtrFu
Vs+Nvm4haa1+NNJ1owodtA5Xp01pDhMrhv4dvFcfEdbF2zLi3h8Xo+9oO6sEGhqE
cMJZJxRCa4RdC9zpFzw0jWS7Udn/j91veWqaR/HLPYeKWcaXqWOegI+f2aoCBbQ7
5cd8Ynqihxw=
=xUEy
-END PGP SIGNATURE-
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] push changesets hooks failing

2012-12-26 Thread Andrew Svetlov
Looks like IRC bot is broken for last days.
I constantly get the same, but it related only to IRC, not to HG repo itself.

On Wed, Dec 26, 2012 at 5:53 PM, Jesus Cea  wrote:
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
>
> I got this when pushing:
>
> """
> jcea@ubuntu:~/hg/python/cpython$ hg push
> pushing to ssh://[email protected]/cpython/
> searching for changes
> searching for changes
> remote: adding changesets
> remote: adding manifests
> remote: adding file changes
> remote: added 4 changesets with 9 changes to 3 files
> remote: buildbot: change(s) sent successfully
> remote: sent email to roundup at [email protected]
> remote: notified [email protected] of incoming changeset
> 0ffaf1079a7a
> remote: error: incoming.irker hook raised an exception: [Errno 111]
> Connection refused
> remote: notified [email protected] of incoming changeset
> 3801ee5d5d73
> remote: error: incoming.irker hook raised an exception: [Errno 111]
> Connection refused
> remote: notified [email protected] of incoming changeset
> b6a9f8fd9443
> remote: error: incoming.irker hook raised an exception: [Errno 111]
> Connection refused
> remote: notified [email protected] of incoming changeset
> 3f7d5c235d82
> remote: error: incoming.irker hook raised an exception: [Errno 111]
> Connection refused
> """
>
> - --
> Jesús Cea Avión _/_/  _/_/_/_/_/_/
> [email protected] - http://www.jcea.es/ _/_/_/_/  _/_/_/_/  _/_/
> jabber / xmpp:[email protected] _/_/_/_/  _/_/_/_/_/
> .  _/_/  _/_/_/_/  _/_/  _/_/
> "Things are not so easy"  _/_/  _/_/_/_/  _/_/_/_/  _/_/
> "My name is Dump, Core Dump"   _/_/_/_/_/_/  _/_/  _/_/
> "El amor es poner tu felicidad en la felicidad de otro" - Leibniz
> -BEGIN PGP SIGNATURE-
> Version: GnuPG v1.4.10 (GNU/Linux)
> Comment: Using GnuPG with undefined - http://www.enigmail.net/
>
> iQCVAwUBUNsdf5lgi5GaxT1NAQKuzQP+IPef5nx00zKdUwL4LoLDds05Dl+WtrFu
> Vs+Nvm4haa1+NNJ1owodtA5Xp01pDhMrhv4dvFcfEdbF2zLi3h8Xo+9oO6sEGhqE
> cMJZJxRCa4RdC9zpFzw0jWS7Udn/j91veWqaR/HLPYeKWcaXqWOegI+f2aoCBbQ7
> 5cd8Ynqihxw=
> =xUEy
> -END PGP SIGNATURE-
> ___
> Python-Dev mailing list
> [email protected]
> http://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe: 
> http://mail.python.org/mailman/options/python-dev/andrew.svetlov%40gmail.com



-- 
Thanks,
Andrew Svetlov
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Raising OSError concrete classes from errno code

2012-12-26 Thread Antoine Pitrou
On Wed, 26 Dec 2012 13:37:13 +0200
Andrew Svetlov  wrote:
> >
> > As Serhiy's example shows, this mapping of error numbers to subclasses
> > is implemented directly in OSError.__new__. We did this so that code
> > could catch the new exceptions, even when dealing with old code that
> > raises the legacy exception types.
> >
> Sorry.
> Looks like OSError.__new__ requires at least two arguments for
> executing subclass search mechanism:
> 
> >>> OSError(errno.ENOENT)
> OSError(2,)
> >>> OSError(errno.ENOENT, 'error msg')
> FileNotFoundError(2, 'error msg')

Indeed, it does. I did this for consistency, because calling OSError
with only one argument doesn't set the "errno" attribute at all:

>>> e = OSError(5)
>>> e.errno
>>> 

Regards

Antoine.


___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Raising OSError concrete classes from errno code

2012-12-26 Thread Andrew Svetlov
Thanks for the elaboration!

On Wed, Dec 26, 2012 at 6:42 PM, Antoine Pitrou  wrote:
> On Wed, 26 Dec 2012 13:37:13 +0200
> Andrew Svetlov  wrote:
>> >
>> > As Serhiy's example shows, this mapping of error numbers to subclasses
>> > is implemented directly in OSError.__new__. We did this so that code
>> > could catch the new exceptions, even when dealing with old code that
>> > raises the legacy exception types.
>> >
>> Sorry.
>> Looks like OSError.__new__ requires at least two arguments for
>> executing subclass search mechanism:
>>
>> >>> OSError(errno.ENOENT)
>> OSError(2,)
>> >>> OSError(errno.ENOENT, 'error msg')
>> FileNotFoundError(2, 'error msg')
>
> Indeed, it does. I did this for consistency, because calling OSError
> with only one argument doesn't set the "errno" attribute at all:
>
 e = OSError(5)
 e.errno

>
> Regards
>
> Antoine.
>
>
> ___
> Python-Dev mailing list
> [email protected]
> http://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe: 
> http://mail.python.org/mailman/options/python-dev/andrew.svetlov%40gmail.com



-- 
Thanks,
Andrew Svetlov
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] push changesets hooks failing

2012-12-26 Thread Georg Brandl
Should now be fixed.  I updated the daemon behind the hook to the newest
version, and hope it will be more stable now.

Georg

On 12/26/2012 05:07 PM, Andrew Svetlov wrote:
> Looks like IRC bot is broken for last days.
> I constantly get the same, but it related only to IRC, not to HG repo itself.
> 
> On Wed, Dec 26, 2012 at 5:53 PM, Jesus Cea  wrote:
> I got this when pushing:
> 
> """
> jcea@ubuntu:~/hg/python/cpython$ hg push
> pushing to ssh://[email protected]/cpython/
> searching for changes
> searching for changes
> remote: adding changesets
> remote: adding manifests
> remote: adding file changes
> remote: added 4 changesets with 9 changes to 3 files
> remote: buildbot: change(s) sent successfully
> remote: sent email to roundup at [email protected]
> remote: notified [email protected] of incoming changeset
> 0ffaf1079a7a
> remote: error: incoming.irker hook raised an exception: [Errno 111]
> Connection refused
> remote: notified [email protected] of incoming changeset
> 3801ee5d5d73
> remote: error: incoming.irker hook raised an exception: [Errno 111]
> Connection refused
> remote: notified [email protected] of incoming changeset
> b6a9f8fd9443
> remote: error: incoming.irker hook raised an exception: [Errno 111]
> Connection refused
> remote: notified [email protected] of incoming changeset
> 3f7d5c235d82
> remote: error: incoming.irker hook raised an exception: [Errno 111]
> Connection refused
> """
> 
>> ___
>> Python-Dev mailing list
>> [email protected]
>> http://mail.python.org/mailman/listinfo/python-dev
>> Unsubscribe: 
>> http://mail.python.org/mailman/options/python-dev/andrew.svetlov%40gmail.com
> 
> 
> 


___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] push changesets hooks failing

2012-12-26 Thread Andrew Svetlov
Thanks

On Wed, Dec 26, 2012 at 7:50 PM, Georg Brandl  wrote:
> Should now be fixed.  I updated the daemon behind the hook to the newest
> version, and hope it will be more stable now.
>
> Georg
>
> On 12/26/2012 05:07 PM, Andrew Svetlov wrote:
>> Looks like IRC bot is broken for last days.
>> I constantly get the same, but it related only to IRC, not to HG repo itself.
>>
>> On Wed, Dec 26, 2012 at 5:53 PM, Jesus Cea  wrote:
>> I got this when pushing:
>>
>> """
>> jcea@ubuntu:~/hg/python/cpython$ hg push
>> pushing to ssh://[email protected]/cpython/
>> searching for changes
>> searching for changes
>> remote: adding changesets
>> remote: adding manifests
>> remote: adding file changes
>> remote: added 4 changesets with 9 changes to 3 files
>> remote: buildbot: change(s) sent successfully
>> remote: sent email to roundup at [email protected]
>> remote: notified [email protected] of incoming changeset
>> 0ffaf1079a7a
>> remote: error: incoming.irker hook raised an exception: [Errno 111]
>> Connection refused
>> remote: notified [email protected] of incoming changeset
>> 3801ee5d5d73
>> remote: error: incoming.irker hook raised an exception: [Errno 111]
>> Connection refused
>> remote: notified [email protected] of incoming changeset
>> b6a9f8fd9443
>> remote: error: incoming.irker hook raised an exception: [Errno 111]
>> Connection refused
>> remote: notified [email protected] of incoming changeset
>> 3f7d5c235d82
>> remote: error: incoming.irker hook raised an exception: [Errno 111]
>> Connection refused
>> """
>>
>>> ___
>>> Python-Dev mailing list
>>> [email protected]
>>> http://mail.python.org/mailman/listinfo/python-dev
>>> Unsubscribe: 
>>> http://mail.python.org/mailman/options/python-dev/andrew.svetlov%40gmail.com
>>
>>
>>
>
>
> ___
> Python-Dev mailing list
> [email protected]
> http://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe: 
> http://mail.python.org/mailman/options/python-dev/andrew.svetlov%40gmail.com



-- 
Thanks,
Andrew Svetlov
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Running GUI and "GObject.mainloop.run()" together?

2012-12-26 Thread Ajay Garg
Oops.. I am extremely sorry for posting to Python-Dev (I did not intend to;
just a bad habit of "Reply-to-All").
Sorry again.

On Thu, Dec 27, 2012 at 1:28 AM, Glyph  wrote:

> On Dec 25, 2012, at 9:05 AM, Ajay Garg  wrote:
>
> > Also, I think I  am now starting to get a hang of things; however, one
> doubt solved raises another doubt :D
> >
> > The reason I began looking out for the two-threads-approach, is because
> when trying to use the GUI (Gtk) application as a dbus-service, I was
> getting the error "This connection was not provided by any of .service
> files".
>
> Please stop cross-posting this to the python-dev list.  It isn't
> appropriate, as several people have said already.
>
> -glyph
>
>


-- 
Regards,
Ajay
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com