py/parse: Treat constants that start with underscore as private.

Assignments of the form "_id = const(value)" are treated as private
(following a similar CPython convention) and code is no longer emitted
for the assignment to a global variable.

See issue #2111.
diff --git a/py/parse.c b/py/parse.c
index 7da484c..1ec995c 100644
--- a/py/parse.c
+++ b/py/parse.c
@@ -461,6 +461,8 @@
 STATIC MP_DEFINE_CONST_MAP(mp_constants_map, mp_constants_table);
 #endif
 
+STATIC void push_result_rule(parser_t *parser, size_t src_line, const rule_t *rule, size_t num_args);
+
 #if MICROPY_COMP_CONST_FOLDING
 STATIC bool fold_constants(parser_t *parser, const rule_t *rule, size_t num_args) {
     // this code does folding of arbitrary integer expressions, eg 1 + 2 * 3 + 4
@@ -587,6 +589,15 @@
                 assert(elem->value == MP_OBJ_NULL);
                 elem->value = MP_OBJ_NEW_SMALL_INT(value);
 
+                // If the constant starts with an underscore then treat it as a private
+                // variable and don't emit any code to store the value to the id.
+                if (qstr_str(id)[0] == '_') {
+                    pop_result(parser); // pop const(value)
+                    pop_result(parser); // pop id
+                    push_result_rule(parser, 0, rules[RULE_pass_stmt], 0); // replace with "pass"
+                    return true;
+                }
+
                 // replace const(value) with value
                 pop_result(parser);
                 push_result_node(parser, pn_value);