Python 3 compatibility error: font.printSample()

In FontForge built with Python 3, script API font.printSample() would
reject calls displaying error messages such as:
      TypeError: expected bytes, str found
for any of the arguments accepting strings - the initial, third and
fourth arguments.

This problem not seen running FontForge built with Python 2.

The code had never been converted to be compatible with Python 3, and
was still using PyBytes_* routines to handle strings.  Changed to use
PyArg_ParseTuple() to handle required and optional arguments, while
checking argument types and counts.

Fixed a small gotcha about for reference counting and the use of
PySequence_GetItem().  Also improved the user-directed error messages
for problems with input arguments.

Thoroughly tested with all variations on argument types and counts.
(~280 lines of Python code to test API signature)
Python 3 compatibility: glyph.getPosSub() glyph.removePosSub()

In FontForge built with Python 3, script APIs glyph.getPosSub()
and glyph.removePosSub() would reject all calls displaying error
messages such as:
      TypeError: expected bytes, str found

This problem not seen running FontForge built with Python 2.

The code had never been converted to be compatible with Python 3, and
was still using PyBytes_* routines to handle strings.  Changed to use
PyArg_ParseTuple() to handle the single argument.

Tested with variations on argument types and counts.  API _function_
was not tested.
Python API fails: font.size_feature (getter)

When full 'size' information is present for a font (the 5 value tuple), then
    data = font.size_feature
would fail with an internally-generated Python exception complaining:
      IndexError: tuple assignment index out of range

The code was calling PyTuple_SetItem() using the wrong variable to index into
the new tuple.

This API was unlikely to have ever worked when full 'size' information
was present.  When language info was absent, then only a single value
'design_size' was correctly returned using a different code path.

However, this GPOS 'size' feature apparently had little industry acceptance,
and so not working was likely not a problem...?

Tested with several different 'size' values as set during testing of the setter.
Python API fails: font.size_feature (setter)

Fixed errors:

  Replaced Python2-correct usage of PyBytes_AsString() with the version
  compatibility macros PYGETSTR() and ENDPYGETSTR().  This fixed this
  error seen under Python 3 on second string of (lang,name) pair:
          TypeError: expected bytes, str found

  Checking for whether argument/sub-arguments were the expected tuple or
  list used the check for 'sequences'.  A string is also a sequence,
  making for strange error messages on user goofs.  Changed to check more
  specifically for list or tuple types.

Other changes:

  Improved some error messages from problems with user calling arguments.

  Desire was to allow caller to request that the 'size' value should be
  deleted.  Apparently the existing coded check was only for use of
        del font.size_feature
  Added ability to say
        font.size_feature = None

  Added Py_DECREF()s to pair with PySequence_GetItem() calls as documented
  by Python, but unfortunately not everyplace needed in this code.

However, this GPOS 'size' feature apparently had little industry acceptance,
and so problems with it was likely not a problem...?
Python: minor -Wall complaints

Fix two "unused variable" warnings by removing those declarations.
Python 3 compatibilty error: glyph.glyphclass setter

In FontForge built with Python 3, script API glyph.glyphclass=...
would reject calls to set a new glyph class name string, with error:
      TypeError: expected bytes, str found

This problem not seen running FontForge built with Python 2.

The code had not been converted to be compatible with Python 3 strings
and was still using the Python 2-compatible PyBytes_* APIs.

Tested with variations on argument types and values.
Python 3 compatibility, bugs: font.markClasses

The code tried to use the same value for both indexing into its 1-based
arrays and fetching arguments.  Using PySequence_GetItem(value,1) to
fetch the first argument didn't work.  And since nothing checked the
return value, call PyArg_ParseTuple(NULL,...) got a segmentation fault.

The code used parse format "(sO)" when "sO" was needed, and so was
expecting triply-nested tuples, when a tuple of tuples was needed.

The code used PySequence_Check(), PySequence_Size() and
PySequence_GetItem() without guarding against having received strings
as input, which are also sequences, and would mislead these checks.

The code in GlyphNamesFromTuple() was using PyBytes_AsString() and thus
not allowing Python 3 strings to be used.

And nowhere was code guarding against empty strings for class or glyph
names.

And the bug I was expecting to verify through tests "pt += strlen(pt);"
wasn't a bug after all.  C'est la vie.

Tested with numerous variations on input argument types and counts,
under both Python 3 and 2.

However, not yet tested using Glyph object references, which can be used
in place of glyph name strings.

Note that GlyphNamesFromTuple() is also used from internal routine
ParseClassNames() and external API PyFFGlyph_addPosSub(), so these
fixes will help those also.

Note also that font.markClasses getter/setter is not yet documented.
Python API bugs: PyFF_PrivateIndexAssign

These are the APIs that use the PostScript private dictionary returned
from font.private, which values are found in BeginPrivate sections in
.sfd files such as /tests/Ambrosia.sfd

Very confused code...

The code was accessing the 'index' argument a second time through copy-n-paste
typo, when it meant to gather the input 'value' argument.  Thus the dictionary
entry was being assigned the key as value!

Use of Py_DECREF() to simulate cleanup actions of ENDPYGETSTR() was flawed by
using the wrong variable.

Out of order use of ENDPYGETSTR() and use of string reversed.

The mechanism to free any allocated memory was corrected.

Error messages expanded a bit to be more descriptive.

Tested with several calls and values, but not quite exhaustively, under
both Python 3 and 2.
Merge pull request #1689 from tshinnic/pythonc_fixes_01

Python scripting fixes (1)