New submission from Tristan Croll: Possibly related to http://bugs.python.org/issue29327 - yields the same error message:
Objects/tupleobject.c:81: bad argument to internal function I have a large SWIG project which was previously working well in Python 3.5. After migrating to Python 3.6.0, I find I can still create any wrapped object from Python via its constructor(s), but any internal function that returns certain objects fails with the above message. I have so far been unable to find any distinction between classes that do and don't return successfully. Take the below (and attached) headers, for example. Functions that return Spacegroup objects work, as do those that return Metric_tensor objects from the attached cell.h. On the other hand, functions returning Cell or Cell_descr objects fail with the above message. Yet in all cases I can successfully call the objects' constructors. Not ashamed to say I'm a bit lost here. #ifndef CLIPPER_SPACEGROUP #define CLIPPER_SPACEGROUP #include "symop.h" #include "spacegroup_data.h" namespace clipper { // forward definitions class HKL; class HKL_class; class Coord_frac; //! spacegroup description /*! The spacegroup description is a compact description of a spacegroup. It may be initialised from Hall or H-M symbols, a string of symops or a number. Internally a hash code is used to refer to the spacegroup, so this object is only 32 bits in size. For more details of spacegroup symbols, see Sydney R. Hall & Ralf W. Grosse-Kunstleve 'Concise Space-Group Symbols', http://www.kristall.ethz.ch/LFK/software/sginfo/hall_symbols.html */ class Spgr_descr { public: enum TYPE { Hall, HM, XHM, Symops, Number, Unknown }; //! null constructor Spgr_descr(); //! constructor: from symbol or operators. explicit Spgr_descr( const String& symb, TYPE type = Unknown ); //! constructor: from number. explicit Spgr_descr( const int& num ); //! return the spacegroup number int spacegroup_number() const; //! return the Hall symbol String symbol_hall() const; //! return the H-M symbol String symbol_hm() const; //! return the extended H-M symbol String symbol_xhm() const; //! return the extension H-M symbol String symbol_hm_ext() const; //! set preferred default spacegroup choice static void set_preferred( const char& c ); //! Vector of symop codes and associated methods class Symop_codes : public std::vector<Symop_code> { public: //! initialise from Hall symbol void init_hall( const String& symb ); //! initialise from symops void init_symops( const String& symb ); //! expand (incomplete) list of symops Symop_codes expand() const; //! return primitive non-inversion ops (by computation) Symop_codes primitive_noninversion_ops() const; //! return inversion ops (by computation) Symop_codes inversion_ops() const; //! return primitive incl inversion ops (by computation) Symop_codes primitive_ops() const; //! return lattice centering ops (by computation) Symop_codes centering_ops() const; //! return Laue ops Symop_codes laue_ops() const; //! return point group ops Symop_codes pgrp_ops() const; //! return Patterson ops Symop_codes patterson_ops() const; //! return minimal list of generator ops Symop_codes generator_ops() const; //! return product of this (expanded) list by another (expanded) list Symop_codes product( const Symop_codes& ops2 ) const; //! return hash code of symop list unsigned int hash() const; }; //! constructor: from symop list. explicit Spgr_descr( const Symop_codes& ops ); //! return the generators for the spacegroup const Symop_codes& generator_ops() const { return generators_; } //! return the hash code for the spacegroup \internal const unsigned int& hash() const { return hash_; } protected: unsigned int hash_; //!< hash code of spacegroup Symop_codes generators_; //!< codes for symop generators static char pref_12, pref_hr; //!< preferred origin and hex/romb symbols }; // ObjectCache data type class Spgr_cacheobj { public: typedef Spgr_descr Key; Spgr_cacheobj( const Key& spgr_cachekey ); //!< construct entry bool matches( const Key& spgr_cachekey ) const; //!< compare entry String format() const; //!< string description // data Key spgr_cachekey_; //!< spacegroup cachekey int nsym, nsymn, nsymi, nsymc, nsymp; //!< number of syms: total, primitive int lgrp; //!< Laue group number std::vector<Symop> symops; //!< symmetry operators std::vector<Isymop> isymops; //!< symmetry operators Vec3<> asu_min_, asu_max_; //!< real space ASU static Mutex mutex; //!< thread safety }; //! Spacegroup object /*! The spacegroup object is a full description of a spacegroup, including all the most regularly used information in an efficient form. It may be initialised from a clipper::Spgr_descr. This object. For more details of spacegroup symbols, see Sydney R. Hall & Ralf W. Grosse-Kunstleve 'Concise Space-Group Symbols', http://www.kristall.ethz.ch/LFK/software/sginfo/hall_symbols.html */ class Spacegroup : public Spgr_descr { public: //! enumeration for fast construction of Null or P1 spacegroup enum TYPE { Null, P1 }; //! enumeration for cell axes enum AXIS { A=0, B=1, C=2 }; //! null constructor Spacegroup() {}; //! constructor: fast constructor for Null or P1 spacegroup explicit Spacegroup( TYPE type ); //! constructor: from spacegroup description explicit Spacegroup( const Spgr_descr& spgr_descr ); //! initialiser: from spacegroup description void init( const Spgr_descr& spgr_descr ); //! test if object has been initialised bool is_null() const; // methods //! get spacegroup description inline const Spgr_descr& descr() const { return (*this); } //! get number of symops inline const int& num_symops() const { return nsym; } //! get number of primitive symops (identical to num_primitive_symops()) inline const int& num_primops() const { return num_primitive_symops(); } //! get number of primitive symops (inc identity and inversion) inline const int& num_primitive_symops() const { return nsymp; } //! get number of centering symops (inc identity) inline const int& num_centering_symops() const { return nsymc; } //! get number of inversion symops (inc identity) inline const int& num_inversion_symops() const { return nsymi; } //! get number of primitive non-inversion symops (inc identity) inline const int& num_primitive_noninversion_symops() const { return nsymn;} //! get n'th symop inline const Symop& symop( const int& sym_no ) const { return symops[sym_no]; } //! get n'th primitive symop (identical to symop(sym_no)) inline const Symop& primitive_symop( const int& sym_no ) const { return symops[sym_no]; } //! get n'th inversion symop (0...1 max) inline const Symop& inversion_symop( const int& sym_no ) const { return symops[nsymn*sym_no]; } //! get n'th centering symop (0...3 max) inline const Symop& centering_symop( const int& sym_no ) const { return symops[nsymp*sym_no]; } //! get the order of rotational symmetry about a given axis int order_of_symmetry_about_axis( const AXIS axis ) const; //! get 'class' of reflection: multiplicity, allowed phase, absence HKL_class hkl_class( const HKL& hkl ) const; //! test if hkl is in default reciprocal ASU bool recip_asu( const HKL& hkl ) const; //! get symop number corresponding to the product of two symops int product_op( const int& s1, int& s2 ) const; //! get symop number corresponding to the inverse of a symop int inverse_op( const int& s ) const; //! get map ASU, upper bound Coord_frac asu_max() const; //! get map ASU, lower bound Coord_frac asu_min() const; //! test if change of hand preserves spacegroup bool invariant_under_change_of_hand() const; // inherited functions listed for documentation purposes //-- int spacegroup_number() const; //-- String symbol_hall() const; //-- String symbol_hm() const; //! return the Laue group symbol String symbol_laue() const; //! Return P1 spacegroup static Spacegroup p1() { return Spacegroup( P1 ); } //! Return null spacegroup static Spacegroup null() { return Spacegroup( Null ); } void debug() const; private: ObjectCache<Spgr_cacheobj>::Reference cacheref; //!< object cache reference const Symop* symops; //!< fast access ptr const Isymop* isymops; //!< fast access ptr data::ASUfn asufn; //!< fast access ptr int nsym, nsymn, nsymi, nsymc, nsymp; //!< fast access copies }; } // namespace clipper #endif ---------- components: Interpreter Core files: cell.h messages: 289245 nosy: Tristan Croll priority: normal severity: normal status: open title: Previously-working SWIG code fails in Python 3.6 versions: Python 3.6 Added file: http://bugs.python.org/file46711/cell.h _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29758> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com