question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] Access Method returning Incomplete Tuple

See original GitHub issue

The Bug

Familiarising myself with Evennia, I was running through the First Steps coding tutorial. As documented, I re-wrote the at_object_creation function in the Character class to assign 3 persistent ability attributes (self.db.strength, self.db.agility, self.db.magic) the values of 5, 4, and 2 respectively. Then, I wrote a function to return those values as a tuple.

When I @reload, @update, and call this function in-game, however, it only returns the first element, 5. The entries exist in the database, confirmed with @examine self, and the values can be printed and indexed from the tuple.

Input

In typeclasses.characters, as found in the documentation:


    def at_object_creation(self):
        """
        Called only at initial creation. This is a rather silly
        example since ability scores should vary from Character to
        Character and is usually set during some character
        generation step instead.
        """
        #set persistent attributes
        self.db.strength = 5
        self.db.agility = 4
        self.db.magic = 2

    def get_abilities(self):
        """
        Simple access method to return ability
        scores as a tuple (str,agi,mag)
        """
        return self.db.strength, self.db.agility, self.db.magic

Expected Result

@py self.get_abilities() *>>> (5, 4, 2)

Evennia correctly returns all elements in the tuple corresponding to persistent data.

Actual Result

reload

Server restart initiated … … Server restarted. update rainboa rainboa updated its existing typeclass (typeclasses.characters.Character). Only the at_object_creation hook was run (update mode). Attributes set before swap were not removed. py self.get_abilities() >>> self.get_abilities() 5 examine self

Name/key: rainboa (#1) Session id(s): #1 Account: rainboa Account Perms: <Superuser> Typeclass: Character (typeclasses.characters.Character) Location: Limbo (#2) Home: Limbo (#2) Permissions: developer [Superuser] Locks: … Commands: … Persistent attributes: desc = This is User #1. prelogout_location = Limbo strength = 5 agility = 4 magic = 2

Steps Taken

I have:

  • Tried this on a clean database.
  • Tried this on a new character.
  • Reproduced this in Linux and Windows.
  • Experimented with writing different functions that do the same thing.
  • Experimented with making the attributes non-persistent.

Systems Information

OS
  1. Windows 10Ver1909 (64-bit) build 18363.592
  2. Debian GNU/Linux 10
Python, Evennia, Etc

Evennia version: 0.9.0 (rev 798cacc2) OS: nt Python: 3.8.1 Twisted: 19.10.0 Django: 2.2.9

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:15 (11 by maintainers)

github_iconTop GitHub Comments

3reactions
strikacocommented, Jan 29, 2020

@Oscuro87

Your notation should not be an issue be you never know.

Even though that wasn’t the issue in this case, this is still a fair concern to be wary of in any Python codebase that was ever ported from 2.x to 3.x. There are quite a few subtle syntactical gotchas that were introduced in that migration, affecting even basic mechanics like how the division operator works 😕

0reactions
Oscuro87commented, Jan 29, 2020

@Oscuro87

Your notation should not be an issue be you never know.

Even though that wasn’t the issue in this case, this is still a fair concern to be wary of in any Python codebase that was ever ported from 2.x to 3.x. There are quite a few subtle syntactical gotchas that were introduced in that migration, affecting even basic mechanics like how the division operator works 😕

True, I even remember when I first came across python 3, and all my print "some string" suddenly died 🤣. Thankfully the error message was developer friendly IIRC.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Issue 15108: Incomplete tuple created by PyTuple_New() and ...
Hi, Sporadically, while running an sqlite3 query, the above error is ... to issue793822: gc.get_referrers() can access unfinished tuples.
Read more >
Index of incomplete tuple in list of tuples - python
Here's one way to do it using a generator expression that returns the index of the first matching tuple by calling next on...
Read more >
subject:"\[issue15108\] Incomplete tuple created by PyTuple_New ...
[issue15108] Incomplete tuple created by PyTuple_New() and accessed via the GC can ... Python without the user calling ever any function from the...
Read more >
std::tuple<> compiler error for incomplete type reference.
std::tuple<> compiler error for incomplete type reference. - Visual Studio Feedback.
Read more >
Creating the same tuple should return an error #1011 - GitHub
I am using the admin API to create a tuple. I would expecting that calling the same API with the same tuple would...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found