After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 586879 - [girepository] Add short/ushort support
[girepository] Add short/ushort support
Status: RESOLVED FIXED
Product: pygobject
Classification: Bindings
Component: general
Git master
Other All
: Normal enhancement
: ---
Assigned To: Nobody's working on this now (help wanted and appreciated)
Python bindings maintainers
Depends on:
Blocks:
 
 
Reported: 2009-06-24 19:11 UTC by Mark Lee
Modified: 2012-04-04 12:26 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
girepository-Add-short-ushort-support.patch (5.02 KB, patch)
2009-06-24 19:22 UTC, Mark Lee
none Details | Review
patch based off of the invoke-checks-rewriting branch (6.96 KB, patch)
2009-06-28 08:02 UTC, Mark Lee
none Details | Review

Description Mark Lee 2009-06-24 19:11:26 UTC
Adds short/ushort support to girepository parameters, function return types, and unit tests.
Comment 1 Mark Lee 2009-06-24 19:22:13 UTC
Created attachment 137338 [details] [review]
girepository-Add-short-ushort-support.patch
Comment 2 Johan (not receiving bugmail) Dahlin 2009-06-24 20:59:08 UTC
Comment on attachment 137338 [details] [review]
girepository-Add-short-ushort-support.patch

Patch looks good!

Simon is moving the type check code over to PythonC, you should probably sort out conflicts with him before landing this.
Comment 3 Simon van der Linden 2009-06-25 10:34:05 UTC
>diff --git a/girepository/btypes.py b/girepository/btypes.py
>index 46319c4..6eb6d24 100644
>--- a/girepository/btypes.py
>+++ b/girepository/btypes.py
>@@ -45,8 +45,10 @@ class Callable(object):
>                         name, type(value).__name__))
>         elif tag in (repo.TYPE_TAG_INT,
>                      repo.TYPE_TAG_INT8,
>+                     repo.TYPE_TAG_SHORT,
>                      repo.TYPE_TAG_UINT,
>                      repo.TYPE_TAG_UINT8,
>+                     repo.TYPE_TAG_USHORT,
>                      repo.TYPE_TAG_INT16,
>                      repo.TYPE_TAG_UINT16,
>                      repo.TYPE_TAG_INT32):
>@@ -56,6 +58,7 @@ class Callable(object):
>                 raise TypeError("%s must be int, not %s" % (name, type(value).__name__))
>             if tag in (repo.TYPE_TAG_UINT,
>                        repo.TYPE_TAG_UINT8,
>+                       repo.TYPE_TAG_USHORT,
>                        repo.TYPE_TAG_UINT16) and value < 0:
>                 raise TypeError("%s must be an unsigned value, not %s", name, value)
>         elif tag in (repo.TYPE_TAG_UINT32,

Indeed, I rewrote those checks in C (but my branch is not public yet).

>diff --git a/tests/test_girepository.py b/tests/test_girepository.py
>index 3c626e5..dc77aed 100644
>--- a/tests/test_girepository.py
>+++ b/tests/test_girepository.py
>@@ -43,6 +43,11 @@ class TestGIEverything(unittest.TestCase):
>         self.assertFalse(Everything.test_boolean(0))
>         self.assertTrue(Everything.test_boolean(2))
> 
>+    def testShort(self):
>+        self.assertEqual(3, Everything.test_short(3))
>+        self.assertEqual(-3, Everything.test_short(-3))
>+        self.assertRaises(TypeError, Everything.test_short, 'a')
>+
>     def testInt(self):
>         self.assertEqual(3, Everything.test_int(3))
>         self.assertEqual(-3, Everything.test_int(-3))


Wouldn't it be helpful to test that it works (and make it working that way) with Python longs as well, and that G_MINSHORT and G_MAXSHORT are accepted whereas G_MINSHORT-1 and G_MAXSHORT+1 raise an error?

This is not what is currently in upstream, but I've got patches for the other cases.
Comment 4 Mark Lee 2009-06-28 08:02:26 UTC
Created attachment 137484 [details] [review]
patch based off of the invoke-checks-rewriting branch

(In reply to comment #3)
> Indeed, I rewrote those checks in C (but my branch is not public yet).

This new patch is based off of this branch. I'm not obsoleting the other patch, at Simon's request.

> Wouldn't it be helpful to test that it works (and make it working that way)
> with Python longs as well, and that G_MINSHORT and G_MAXSHORT are accepted
> whereas G_MINSHORT-1 and G_MAXSHORT+1 raise an error?

These tests are now incorporated into the short/ushort unit tests.
Comment 5 johnp 2010-09-23 16:33:39 UTC
This is a year old.  Is it still relevant?
Comment 6 André Klapper 2010-12-30 00:25:40 UTC
Mark: Is this still relevant?
Comment 7 Tobias Mueller 2011-02-28 12:53:34 UTC
Mark, Ping.
Comment 8 Tobias Mueller 2011-06-30 19:54:08 UTC
Reopening as I can't see any non-developer question. But a maintainer might want to clear to question reg. the relevance of this bug.
Comment 9 Martin Pitt 2012-04-04 12:26:08 UTC
3.2.0 (and earlier versions as well) support short, and have test cases. Closing.