On 2011/9/21 Thomas Paviot wrote:
> 2011/9/21 D. Barbier <bou...@gmail.com>
>>
>> On 2011/9/20 Thomas Paviot wrote:
>> > 2011/9/20 D. Barbier wrote
>> [...]
>> >> but get now a segmentation fault:
>> >>  testHash (wrapper_features_unittest.TestWrapperFeatures) ... Test:
>> >> __hash__ overloading
>> >>  Segmentation fault
>> >>
>> >> More precisely:
>> >>  $ python
>> >>  Python 2.6.7 (r267:88850, Aug  3 2011, 11:33:52)
>> >>  [GCC 4.6.1] on linux2
>> >>  Type "help", "copyright", "credits" or "license" for more information.
>> >>  >>> import OCC.Standard
>> >>  >>> s = OCC.Standard.Standard_Transient()
>> >>  >>> hash1_s = s.__hash__()
>> >>  >>> hash2_s = s.HashCode(pow(2,31)-1)
>> >>  Segmentation fault
>> [...]
>> > When compiling pythonocc, you must pass -D__PYTHONOCCOCC_MAXINT__
>> > integer.
>> > It's equal to 2^32-1 on 32bit platforms, 2^64-1 on 64bit. This is
>> > computed
>> > from the file environment.py
>> >
>> > (https://github.com/tpaviot/pythonocc/blob/master/src/wrapper/environment.py)
>> > called when compiling pythonocc from the setup.py script.
>>
>> Hmmm, I am confused, this is hardcoded to 2^31-1 for 32 and 64 bits:
>>
>>  # Define HASHCODE_MAXINT. Even on 64 bits systems, HashCode method
>> require a 32 bits Standard_Integer
>>  #
>>  HASHCODE_MAXINT = pow(2,31)-1
>
> You're right. This hack is a bit old, and I didn't remember exactly the
> reasons for creating this __PYTHONOCC_MAXINT__. Anyway, it is unuseful since
> the value passed is always the same and independant from the platform (in
> all cases, pow(2,31)-1). It can be hardcoded into the SWIG file by using
> return $self->HashCode(2147483647).
>
> I pushed tp/__hash_-overloading to fix this issue. You should be able to use
> your CMakeList.txt file as is (but you will have to recompile all the
> modules).

Sorry I do not understand your reasoning; this patch does nothing,
since  __PYTHONOCC_MAXINT__ is defined as 2147483647 by
environment.py.  Anyway I tried your branch, and __hash__ overloading
still segfaults :(

Denis

_______________________________________________
Pythonocc-users mailing list
Pythonocc-users@gna.org
https://mail.gna.org/listinfo/pythonocc-users

Reply via email to