Re: [Python-Dev] [Python-checkins] cpython: fix compiler warnings

2011-10-04 Thread Victor Stinner

Le 05/10/2011 00:30, Vlad Riscutia a écrit :

Why does the function even return a value? As Benjamin said, it is just
a bunch of asserts with return 1 at the end.


It's just to be able to write assert(_PyUnicode_CheckConsistency(...)). 
assert() is just used to remove the instruction in release mode.


Victor
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] [Python-checkins] cpython: fix compiler warnings

2011-10-04 Thread Vlad Riscutia
Why does the function even return a value? As Benjamin said, it is just a
bunch of asserts with return 1 at the end.

I believe another way you can get rid of "statement with no effect" is to
cast return value to void, like (void)_PyUnicode_CHECK(unicode).

Thank you,
Vlad

On Tue, Oct 4, 2011 at 4:57 AM, Benjamin Peterson wrote:

> 2011/10/4 Victor Stinner :
> > Le 04/10/2011 01:34, benjamin.peterson a écrit :
> >>
> >> http://hg.python.org/cpython/rev/afb60b190f1c
> >> changeset:   72633:afb60b190f1c
> >> user:Benjamin Peterson
> >> date:Mon Oct 03 19:34:12 2011 -0400
> >> summary:
> >>   fix compiler warnings
> >>
> >> +++ b/Objects/unicodeobject.c
> >> @@ -369,6 +369,12 @@
> >>  }
> >>  return 1;
> >>  }
> >> +#else
> >> +static int
> >> +_PyUnicode_CheckConsistency(void *op)
> >> +{
> >> +return 1;
> >> +}
> >>  #endif
> >
> > Oh no, please don't do that. Calling _PyUnicode_CheckConsistency() is
> > reserved to debug builds. In release mode, we should not check string
> > consistency (it would slow down Python).
>
> It should be optimized out.
>
> >
> > Yes, there was a warning:
> >
> > Objects/unicodeobject.c:539:13: warning: statement with no effect
> >_PyUnicode_CHECK(unicode);
> >
> > I added these checks recently to ensure that strings are consistent just
> > before exiting (to help me to track down a bug).
> >
> > The right fix is just to replace _PyUnicode_CHECK(unicode) by
> > assert(_PyUnicode_CHECK(unicode)).
>
> But _PyUnicode_CheckConsistency is just a string of assertions. What
> sense does it make to check the return value?
>
>
> --
> Regards,
> Benjamin
> ___
> Python-Dev mailing list
> Python-Dev@python.org
> http://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe:
> http://mail.python.org/mailman/options/python-dev/riscutiavlad%40gmail.com
>
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] [Python-checkins] cpython: fix compiler warnings

2011-10-04 Thread Benjamin Peterson
2011/10/4 Victor Stinner :
> Le 04/10/2011 01:34, benjamin.peterson a écrit :
>>
>> http://hg.python.org/cpython/rev/afb60b190f1c
>> changeset:   72633:afb60b190f1c
>> user:        Benjamin Peterson
>> date:        Mon Oct 03 19:34:12 2011 -0400
>> summary:
>>   fix compiler warnings
>>
>> +++ b/Objects/unicodeobject.c
>> @@ -369,6 +369,12 @@
>>      }
>>      return 1;
>>  }
>> +#else
>> +static int
>> +_PyUnicode_CheckConsistency(void *op)
>> +{
>> +    return 1;
>> +}
>>  #endif
>
> Oh no, please don't do that. Calling _PyUnicode_CheckConsistency() is
> reserved to debug builds. In release mode, we should not check string
> consistency (it would slow down Python).

It should be optimized out.

>
> Yes, there was a warning:
>
> Objects/unicodeobject.c:539:13: warning: statement with no effect
>            _PyUnicode_CHECK(unicode);
>
> I added these checks recently to ensure that strings are consistent just
> before exiting (to help me to track down a bug).
>
> The right fix is just to replace _PyUnicode_CHECK(unicode) by
> assert(_PyUnicode_CHECK(unicode)).

But _PyUnicode_CheckConsistency is just a string of assertions. What
sense does it make to check the return value?


-- 
Regards,
Benjamin
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] [Python-checkins] cpython: fix compiler warnings

2011-10-04 Thread Victor Stinner

Le 04/10/2011 01:34, benjamin.peterson a écrit :

http://hg.python.org/cpython/rev/afb60b190f1c
changeset:   72633:afb60b190f1c
user:Benjamin Peterson
date:Mon Oct 03 19:34:12 2011 -0400
summary:
   fix compiler warnings

+++ b/Objects/unicodeobject.c
@@ -369,6 +369,12 @@
  }
  return 1;
  }
+#else
+static int
+_PyUnicode_CheckConsistency(void *op)
+{
+return 1;
+}
  #endif


Oh no, please don't do that. Calling _PyUnicode_CheckConsistency() is 
reserved to debug builds. In release mode, we should not check string 
consistency (it would slow down Python).


Yes, there was a warning:

Objects/unicodeobject.c:539:13: warning: statement with no effect
_PyUnicode_CHECK(unicode);

I added these checks recently to ensure that strings are consistent just 
before exiting (to help me to track down a bug).


The right fix is just to replace _PyUnicode_CHECK(unicode) by 
assert(_PyUnicode_CHECK(unicode)).


Victor
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com